JSONWorker.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef JSON_WORKER_H
  2. #define JSON_WORKER_H
  3. #include "JSONNode.h"
  4. #include "JSONSharedString.h"
  5. class JSONWorker {
  6. public:
  7. static json_string RemoveWhiteSpaceAndComments(const json_string & value_t, bool escapeQuotes) json_nothrow json_read_priority;
  8. static json_char * RemoveWhiteSpaceAndCommentsC(const json_string & value_t, bool escapeQuotes) json_nothrow json_read_priority;
  9. #ifdef JSON_READ_PRIORITY
  10. static JSONNode parse(const json_string & json) json_throws(std::invalid_argument) json_read_priority;
  11. static JSONNode parse_unformatted(const json_string & json) json_throws(std::invalid_argument) json_read_priority;
  12. static JSONNode _parse_unformatted(const json_char * json, const json_char * const end) json_throws(std::invalid_argument) json_read_priority;
  13. static json_char * RemoveWhiteSpace(const json_string & value_t, size_t & len, bool escapeQuotes) json_nothrow json_read_priority;
  14. static void DoArray(const internalJSONNode * parent, const json_string & value_t) json_nothrow json_read_priority;
  15. static void DoNode(const internalJSONNode * parent, const json_string & value_t) json_nothrow json_read_priority;
  16. #ifdef JSON_LESS_MEMORY
  17. #define NAME_ENCODED this, true
  18. #define STRING_ENCODED this, false
  19. static json_string FixString(const json_string & value_t, const internalJSONNode * flag, bool which) json_nothrow json_read_priority;
  20. #else
  21. #define NAME_ENCODED _name_encoded
  22. #define STRING_ENCODED _string_encoded
  23. static json_string FixString(const json_string & value_t, bool & flag) json_nothrow json_read_priority;
  24. #endif
  25. #endif
  26. #if defined(JSON_READ_PRIORITY) || defined(JSON_STREAM)
  27. #if (JSON_READ_PRIORITY == HIGH) && (!(defined(JSON_LESS_MEMORY)))
  28. template<json_char ch>
  29. static size_t FindNextRelevant(const json_string & value_t, const size_t pos) json_nothrow json_read_priority;
  30. #else
  31. static size_t FindNextRelevant(json_char ch, const json_string & value_t, const size_t pos) json_nothrow json_read_priority;
  32. #endif
  33. #endif
  34. static void UnfixString(const json_string & value_t, bool flag, json_string & res) json_nothrow;
  35. JSON_PRIVATE
  36. #ifdef JSON_READ_PRIORITY
  37. static json_char Hex(const json_char * & pos) json_nothrow;
  38. static json_uchar UTF8(const json_char * & pos, const json_char * const end) json_nothrow;
  39. #endif
  40. #ifdef JSON_ESCAPE_WRITES
  41. static json_string toUTF8(json_uchar p) json_nothrow;
  42. #endif
  43. #ifdef JSON_UNICODE
  44. static void UTF(const json_char * & pos, json_string & result, const json_char * const end) json_nothrow;
  45. #ifdef JSON_ESCAPE_WRITES
  46. static json_string toSurrogatePair(json_uchar pos) json_nothrow;
  47. #endif
  48. #endif
  49. #ifdef JSON_READ_PRIORITY
  50. static void SpecialChar(const json_char * & pos, const json_char * const end, json_string & res) json_nothrow;
  51. static void NewNode(const internalJSONNode * parent, const json_string & name, const json_string & value, bool array) json_nothrow;
  52. #endif
  53. private:
  54. JSONWorker(void);
  55. };
  56. #endif