publicFunExport.h 1.4 KB

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