Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General warning removal, curl_pair specialization. #128 #133

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions include/curl_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,41 @@ namespace curl {
inline const struct curl_httppost *curl_form::get() const {
return this->form_post;
}

/**
* Re-declaring template curl_pair, in case this is not in include path
*/
template<class T, class K> class curl_pair;

/**
* Template specialization of curl_pair for curl_form type.
*/
template<class T> class curl_pair<T,curl_form> {
public:
/**
* The two parameters constructor gives users a fast way to build an object of
* this type.
*/
curl_pair(const T option, const curl_form &value) : option(option), value(value) {}
/**
* Simple method that returns the first field of the pair.
*/
inline T first() const NOEXCEPT {
return this->option;
}
/**
* Simple method that returns the second field of the pair as a
* C struct curl_httppost pointer.
*/
inline const curl_httppost *second() const NOEXCEPT {
return (this->value).get();
}
private:
const T option;
const curl_form &value;
};


}

#endif /* defined(__curlcpp__curl_form__) */
34 changes: 34 additions & 0 deletions include/curl_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,40 @@ namespace curl {
this->add(*begin);
}
}

/**
* Re-declaring template curl_pair, in case this is not in include path
*/
template<class T, class K> class curl_pair;

/**
* Template specialization of curl_pair for curl_header type.
*/
template<class T> class curl_pair<T,curl_header> {
public:
/**
* Thw two parameters constructor gives users a fast way to build an object
* of this type.
*/
curl_pair(const T option, const curl_header &value) : option(option), value(value) {}
/**
* Simple method that returns the first field of the pair.
*/
inline T first() const NOEXCEPT {
return this->option;
}
/**
* Simple method that returns the second field of the pair as a C struct
* curl_slist pointer.
*/
inline const curl_slist *second() const NOEXCEPT {
return (this->value).get();
}
private:
const T option;
const curl_header &value;
};

}

#endif /* defined(__curlcpp__curl_header__) */
52 changes: 4 additions & 48 deletions include/curl_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,62 +135,18 @@ namespace curl {
* curl_form wraps a struct curl_httppost list. libcurl functions can't handle
* curl_form type, so we need to specialize curl_pair to return a struct
* curl_httppost *.
* Definition at curl_form.h
*/
template<class T> class curl_pair<T,curl_form> {
public:
/**
* The two parameters constructor gives users a fast way to build an object of
* this type.
*/
curl_pair(const T option, const curl_form &value) : option(option), value(value) {}
/**
* Simple method that returns the first field of the pair.
*/
inline T first() const NOEXCEPT {
return this->option;
}
/**
* Simple method that returns the second field of the pair as a
* C struct curl_httppost pointer.
*/
inline const curl_httppost *second() const NOEXCEPT {
return (this->value).get();
}
private:
const T option;
const curl_form &value;
};
template<class T> class curl_pair<T,curl_form>;

/**
* Template specialization for curl_header type. Why do we need this? Because
* curl_header wraps a struct curl_slist list of headers. libcurl functions can't
* handle a curl_header type, so we need to specialize curl_pair to return a
* struct curl_slist *.
* Definition at curl_header.h
*/
template<class T> class curl_pair<T,curl_header> {
public:
/**
* Thw two parameters constructor gives users a fast way to build an object
* of this type.
*/
curl_pair(const T option, const curl_header &value) : option(option), value(value) {}
/**
* Simple method that returns the first field of the pair.
*/
inline T first() const NOEXCEPT {
return this->option;
}
/**
* Simple method that returns the second field of the pair as a C struct
* curl_slist pointer.
*/
inline const curl_slist *second() const NOEXCEPT {
return (this->value).get();
}
private:
const T option;
const curl_header &value;
};
template<class T> class curl_pair<T,curl_header>;
}

#endif /* defined(__curlcpp__curl_pair__) */