publicFunExport.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _OTHER_PUBLICFUNCEXPORT_HEADER_
  2. #define _OTHER_PUBLICFUNCEXPORT_HEADER_
  3. #pragma once
  4. #include "cJSON.h"
  5. #include <map>
  6. #include <string>
  7. #include <vector>
  8. #include "publicExport.h"
  9. using namespace std;
  10. #define STR_TRUE "True"
  11. #define STR_FALSE "False"
  12. #define STR_NULL "Null"
  13. PUBLIC_API std::pair<bool, std::string> generateJsonStr(std::map<std::string, std::string> &objectArr);
  14. PUBLIC_API std::vector<std::string> parseJsonStr(const std::string jsonStr, const std::vector<std::string>& keys);
  15. PUBLIC_API bool checkHttpActive(const char* httpUrl);
  16. PUBLIC_API int str2int(const string str);
  17. PUBLIC_API string int2str(const int num);
  18. class PUBLIC_API RVCJson{
  19. public:
  20. cJSON* pJson;
  21. public:
  22. RVCJson();
  23. RVCJson(bool notNewArray);
  24. ~RVCJson();
  25. void SetJson(const char*jsonStr);
  26. void SetJson(RVCJson* cmbJson);
  27. void AddNullToObject(const char*key);
  28. void AddBoolToObject(const char*key, bool value);
  29. void AddNumberToObject(const char*key, double value);
  30. void AddStringToObject(const char*key, char*value);
  31. void AddItemToObject(const char*key, RVCJson* rvcJson);
  32. void AddItemToArray(RVCJson* rvcJson);
  33. RVCJson* Get();
  34. char*GetJsonStr();
  35. bool GetBoolValue(const char*key);
  36. double GetNumberValue(const char*key);
  37. int GetNumberIntValue(const char*key);
  38. char*GetStringValue(const char*key);
  39. RVCJson* GetJsonValue(const char*key);
  40. int GetArraySize();
  41. RVCJson* GetArrayValue(int index);
  42. void Destory();
  43. };
  44. #endif //_OTHER_PUBLICFUNCEXPORT_HEADER_