webfun.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef WEBFUN_H
  2. #define WEBFUN_H
  3. #ifdef _WIN32
  4. #ifdef HTTPLIBEXPORTS
  5. #define WEBFUN_API __declspec(dllexport)
  6. #else
  7. #define WEBFUN_API __declspec(dllimport)
  8. #ifdef _DEBUG
  9. #pragma comment (lib, "httplibd.lib")
  10. #else
  11. #pragma comment (lib, "httplib.lib")
  12. #endif
  13. #endif
  14. #else
  15. #define WEBFUN_API
  16. #endif
  17. #include <set>
  18. #include <map>
  19. #include <string>
  20. #include <functional>
  21. #include <boost/any.hpp>
  22. namespace weblib
  23. {
  24. struct httpinfo
  25. {
  26. std::string strurl{};
  27. std::string strtarget{};
  28. std::string strjson{};
  29. std::string stronly{};
  30. std::map<std::string, std::string> addheadinfo{};
  31. std::set<int> setresult_int{};
  32. };
  33. WEBFUN_API inline void* webini(int iport = 0, bool blog = true);
  34. WEBFUN_API inline void webrun(void* pweb);
  35. WEBFUN_API inline void delweb(void* pweb);
  36. WEBFUN_API inline void addmsg(void* pweb, boost::any thttp);
  37. WEBFUN_API inline void* httpini();
  38. WEBFUN_API inline void delhttp(void* phttp);
  39. WEBFUN_API inline void addhttpmsg(void* phttp, boost::any thttp);
  40. WEBFUN_API inline void sendhttp(void* phttp, httpinfo&& thttpinfo, std::function<void(std::string, int)> &&dofun = nullptr);
  41. }
  42. #endif // WEBSOCKET_HPP