#pragma once #include #include // curl #define USE_OPENSSL #define CURL_STATICLIB #include #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "wldap32.lib") #pragma comment(lib, "libcurl.lib") #pragma comment(lib,"Crypt32.lib") //#include //#pragma comment(lib,"jsoncpp_static.lib") class CHttpClient { public: CURLcode curl_post_req(const char* url, const char* postParams, std::string &response); static CHttpClient* GetInStance() { return &sp; } private: CHttpClient() {}; CHttpClient(const CHttpClient&); CHttpClient& operator = (const CHttpClient&) = delete; ~CHttpClient() {}; static size_t req_reply(void * ptr, size_t size, size_t nmemb, void * stream); static std::wstring string_to_wstring(const std::string &s) { using default_convert = std::codecvt; static std::wstring_convertconv(new(std::nothrow) default_convert("CHS")); return conv.from_bytes(s); } static std::string ansi_to_utf8(const std::string &s) { static std::wstring_convert > conv; return conv.to_bytes(string_to_wstring(s)); } static std::string wstring_to_string(const std::wstring &s) { using default_convert = std::codecvt; static std::wstring_convertconv(new(std::nothrow) default_convert("CHS")); return conv.to_bytes(s); } static std::string utf8_to_ansi(const std::string& s) { static std::wstring_convert > conv; return wstring_to_string(conv.from_bytes(s)); } static CHttpClient sp; };