diff --git a/src/requester.cpp b/src/requester.cpp index 7ae84ff..304af8d 100644 --- a/src/requester.cpp +++ b/src/requester.cpp @@ -4,6 +4,8 @@ #include #include +using namespace sc; + size_t requester::write_data(char *buf, size_t sz, size_t nmemb, void *user_data) { size_t realsize = sz * nmemb; requester* req {reinterpret_cast(user_data)}; diff --git a/src/requester.hpp b/src/requester.hpp index 174c3df..c64e6b8 100644 --- a/src/requester.hpp +++ b/src/requester.hpp @@ -6,34 +6,37 @@ #include #include -class requester { - public: - // callback for data receiving - static size_t write_data(char* buf, size_t sz, size_t nmemb, void* user_data); +namespace sc { - // this class is a RAII class for a curl handle - requester(); - ~requester(); + class requester { + public: + // callback for data receiving + static size_t write_data(char* buf, size_t sz, size_t nmemb, void* user_data); - // forbid copying and moving - requester(const requester&) = delete; - requester& operator=(const requester&) = delete; - requester(requester&&) = delete; - requester& operator=(requester&&) = delete; + // this class is a RAII class for a curl handle + requester(); + ~requester(); - // optional logger - void logger(sc::logger* logger) { _logger = logger; } + // forbid copying and moving + requester(const requester&) = delete; + requester& operator=(const requester&) = delete; + requester(requester&&) = delete; + requester& operator=(requester&&) = delete; - // perform a http get request - std::string get(const std::string& url); + // optional logger + void logger(sc::logger* logger) { _logger = logger; } - // perform a http post request - std::string post(const std::string& url, const std::string& json); + // perform a http get request + std::string get(const std::string& url); - private: - std::unique_ptr _h {nullptr, curl_easy_cleanup}; - sc::logger* _logger {nullptr}; - std::string _text; -}; + // perform a http post request + std::string post(const std::string& url, const std::string& json); + private: + std::unique_ptr _h {nullptr, curl_easy_cleanup}; + sc::logger* _logger {nullptr}; + std::string _text; + }; + +} #endif // _requester_H_