| 1 | #ifndef CPR_ACCEPT_ENCODING_H |
| 2 | #define CPR_ACCEPT_ENCODING_H |
| 3 | |
| 4 | #include <curl/curlver.h> |
| 5 | #include <initializer_list> |
| 6 | #include <map> |
| 7 | #include <string> |
| 8 | #include <unordered_set> |
| 9 | |
| 10 | namespace cpr { |
| 11 | |
| 12 | enum class AcceptEncodingMethods { |
| 13 | identity, |
| 14 | deflate, |
| 15 | zlib, |
| 16 | gzip, |
| 17 | disabled, |
| 18 | }; |
| 19 | |
| 20 | // NOLINTNEXTLINE(cert-err58-cpp) |
| 21 | static const std::map<AcceptEncodingMethods, std::string> AcceptEncodingMethodsStringMap{{AcceptEncodingMethods::identity, "identity" }, {AcceptEncodingMethods::deflate, "deflate" }, {AcceptEncodingMethods::zlib, "zlib" }, {AcceptEncodingMethods::gzip, "gzip" }, {AcceptEncodingMethods::disabled, "disabled" }}; |
| 22 | |
| 23 | class AcceptEncoding { |
| 24 | public: |
| 25 | AcceptEncoding() = default; |
| 26 | // NOLINTNEXTLINE(google-explicit-constructor) |
| 27 | AcceptEncoding(const std::initializer_list<AcceptEncodingMethods>& methods); |
| 28 | // NOLINTNEXTLINE(google-explicit-constructor) |
| 29 | AcceptEncoding(const std::initializer_list<std::string>& methods); |
| 30 | |
| 31 | [[nodiscard]] bool empty() const noexcept; |
| 32 | [[nodiscard]] const std::string getString() const; |
| 33 | [[nodiscard]] bool disabled() const; |
| 34 | |
| 35 | private: |
| 36 | std::unordered_set<std::string> methods_; |
| 37 | }; |
| 38 | |
| 39 | } // namespace cpr |
| 40 | |
| 41 | #endif |
| 42 | |