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