| 1 | #ifndef CURL_CONTAINER_H |
|---|---|
| 2 | #define CURL_CONTAINER_H |
| 3 | |
| 4 | #include <initializer_list> |
| 5 | #include <memory> |
| 6 | #include <string> |
| 7 | #include <vector> |
| 8 | |
| 9 | #include "cpr/curlholder.h" |
| 10 | |
| 11 | |
| 12 | namespace cpr { |
| 13 | |
| 14 | struct Parameter { |
| 15 | Parameter(std::string p_key, std::string p_value) : key{std::move(p_key)}, value{std::move(p_value)} {} |
| 16 | |
| 17 | std::string key; |
| 18 | std::string value; |
| 19 | }; |
| 20 | |
| 21 | struct Pair { |
| 22 | Pair(std::string p_key, std::string p_value) : key(std::move(p_key)), value(std::move(p_value)) {} |
| 23 | |
| 24 | std::string key; |
| 25 | std::string value; |
| 26 | }; |
| 27 | |
| 28 | |
| 29 | template <class T> |
| 30 | class CurlContainer { |
| 31 | public: |
| 32 | /** |
| 33 | * Enables or disables URL encoding for keys and values when calling GetContent(...). |
| 34 | **/ |
| 35 | bool encode = true; |
| 36 | |
| 37 | CurlContainer() = default; |
| 38 | CurlContainer(const std::initializer_list<T>&); |
| 39 | |
| 40 | void Add(const std::initializer_list<T>&); |
| 41 | void Add(const T&); |
| 42 | |
| 43 | const std::string GetContent(const CurlHolder&) const; |
| 44 | |
| 45 | protected: |
| 46 | std::vector<T> containerList_; |
| 47 | }; |
| 48 | |
| 49 | } // namespace cpr |
| 50 | |
| 51 | #endif // |
| 52 |