JSONNode.h | JSONNode.h | |||
---|---|---|---|---|
skipping to change at line 16 | skipping to change at line 16 | |||
#include "JSON_Strings.h" | #include "JSON_Strings.h" | |||
#define foreach(iterator, container)\ | #define foreach(iterator, container)\ | |||
for (typeof(container.begin()) iterator = container.begin(), iterator## _end = container.end();\ | for (typeof(container.begin()) iterator = container.begin(), iterator## _end = container.end();\ | |||
iterator != iterator##_end;\ | iterator != iterator##_end;\ | |||
++iterator) | ++iterator) | |||
using namespace std; | using namespace std; | |||
union value_union_t { | union value_union_t { | |||
bool _bool; | bool _bool; | |||
double _number; | double _number; | |||
size_t lastreal; //This is used to determine the last real entry in th | ||||
e Children, because it's possible to have comments at the end, we don't wan | ||||
t commas before them | ||||
}; | }; | |||
class JSONNode { | class JSONNode { | |||
public: | public: | |||
JSONNode(const json_string & name_t, const json_string & value_t) ; | JSONNode(const json_string & name_t, const json_string & value_t) ; | |||
JSONNode(void){}; //Used ONLY for duplicating | JSONNode(void){}; //Used ONLY for duplicating | |||
JSONNode(JSONNode * parent); | JSONNode(JSONNode * parent); | |||
~JSONNode(void); | ~JSONNode(void); | |||
void SetMyValue(const json_string & value_t); | void SetMyValue(const json_string & value_t); | |||
void PurgeChildren(void); | void PurgeChildren(void); | |||
skipping to change at line 82 | skipping to change at line 83 | |||
unsigned int GetMemoryUsage(void); | unsigned int GetMemoryUsage(void); | |||
json_string MemDump(unsigned int indent = 0); | json_string MemDump(unsigned int indent = 0); | |||
#endif | #endif | |||
//This is the name of the node, the encoded flag tells the writer wh ether or not to re-escape it when it gets written | //This is the name of the node, the encoded flag tells the writer wh ether or not to re-escape it when it gets written | |||
json_string _name; bool name_encoded; | json_string _name; bool name_encoded; | |||
//This is the json_string that is the value of the node, this mig ht be a json_string, a number, or even a set of nodes or array that hasn't been parsed yet | //This is the json_string that is the value of the node, this mig ht be a json_string, a number, or even a set of nodes or array that hasn't been parsed yet | |||
json_string _string; bool string_encoded; | json_string _string; bool string_encoded; | |||
//boolean and floating point values of the value, only applicable if the node is of that type | //internal structure changes depending on type | |||
value_union_t _value; | value_union_t _value; | |||
vector<JSONNode *> Children; | vector<JSONNode *> Children; | |||
size_t lastreal; //This is used to determine the last real entry | ||||
in the Children, because it's possible to have comments at the end, we don | ||||
't want commas before them | ||||
private: | private: | |||
json_string WriteChildren(unsigned int indent); | json_string WriteChildren(unsigned int indent); | |||
json_string WriteName(bool formatted) const; | json_string WriteName(bool formatted) const; | |||
json_string WriteComment(unsigned int indent) const; | json_string WriteComment(unsigned int indent) const; | |||
}; | }; | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
7 lines changed or deleted | 7 lines changed or added | |||
JSON_Defs.h | JSON_Defs.h | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
typedef void (*JSON_SetValue_t)(const JSONNODE, const json_char *); | typedef void (*JSON_SetValue_t)(const JSONNODE, const json_char *); | |||
typedef void (*JSON_SetStringValue_t)(const JSONNODE, const json_char * ); | typedef void (*JSON_SetStringValue_t)(const JSONNODE, const json_char * ); | |||
typedef void (*JSON_AddComment_t)(const JSONNODE, const json_char *); | typedef void (*JSON_AddComment_t)(const JSONNODE, const json_char *); | |||
typedef json_char *(*JSON_Write_t)(const JSONNODE); | typedef json_char *(*JSON_Write_t)(const JSONNODE); | |||
typedef json_char *(*JSON_WriteFormatted_t)(const JSONNODE); | typedef json_char *(*JSON_WriteFormatted_t)(const JSONNODE); | |||
typedef void (*JSON_Free_t)(json_char * str); | typedef void (*JSON_Free_t)(json_char * str); | |||
typedef json_char *(*JSON_Dump_t)(const JSONNODE); | typedef json_char *(*JSON_Dump_t)(const JSONNODE); | |||
typedef unsigned int (*JSON_GetMemoryUsage_t)(const JSONNODE); | ||||
#else | #else | |||
#include "JSONNode.h" | #include "JSONNode.h" | |||
#define JSONNODE JSONNode | #define JSONNODE JSONNode | |||
#endif | #endif | |||
//If the JSON engine is compiled without the DEBUG definition, there are no callback functions | //If the JSON engine is compiled without the DEBUG definition, there are no callback functions | |||
typedef void (*JSON_ErrorCallback)(const json_char *); | typedef void (*JSON_ErrorCallback)(const json_char *); | |||
typedef void (*JSON_RegisterErrorCallback_t)(JSON_ErrorCallback); | typedef void (*JSON_RegisterErrorCallback_t)(JSON_ErrorCallback); | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 1 lines changed or added | |||
JSON_Worker.h | JSON_Worker.h | |||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
#endif | #endif | |||
static json_string FixString(const json_string & value_t, bool & flag); | static json_string FixString(const json_string & value_t, bool & flag); | |||
static json_string UnfixString(const json_string & value_t, bool flag); | static json_string UnfixString(const json_string & value_t, bool flag); | |||
private: | private: | |||
static json_char Hex(const json_char * & pos); | static json_char Hex(const json_char * & pos); | |||
static unsigned json_char UTF8(const json_char * & pos); | static unsigned json_char UTF8(const json_char * & pos); | |||
static json_string toUTF8(unsigned json_char p); | static json_string toUTF8(unsigned json_char p); | |||
#ifdef JSON_UNICODE | #ifdef JSON_UNICODE | |||
static json_string UTF(const json_char * & pos); | static json_string UTF(const json_char * & pos); | |||
static json_string toSurrogatePair(unsigned json_char pos); | static json_string toSurrogatePair(unsigned json_char pos); | |||
static unsigned json_char SurrogatePair(const unsigned json_cha r first, const unsigned json_char second); | ||||
#endif | #endif | |||
static json_char FromOctal(const json_char * & pos); | static json_char FromOctal(const json_char * & pos); | |||
static void SpecialChar(const json_char * & pos, json_string & re s); | static void SpecialChar(const json_char * & pos, json_string & re s); | |||
static size_t FindNextRelevant(json_char ch, const json_string & value_t, const size_t pos); | static size_t FindNextRelevant(json_char ch, const json_string & value_t, const size_t pos); | |||
}; | }; | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 0 lines changed or added | |||
jsonmain.h | jsonmain.h | |||
---|---|---|---|---|
skipping to change at line 69 | skipping to change at line 69 | |||
//These are for going from nodes to strings | //These are for going from nodes to strings | |||
void JSON_AddComment(const JSONNODE parent, const json_char * com ment); | void JSON_AddComment(const JSONNODE parent, const json_char * com ment); | |||
json_char * JSON_Write(const JSONNODE node); | json_char * JSON_Write(const JSONNODE node); | |||
json_char * JSON_WriteFormatted(const JSONNODE node); | json_char * JSON_WriteFormatted(const JSONNODE node); | |||
void JSON_Free(json_char * str); | void JSON_Free(json_char * str); | |||
#ifdef DEBUG | #ifdef DEBUG | |||
//Registering an error callback | //Registering an error callback | |||
void JSON_RegisterErrorCallback(ErrorCallback method); | void JSON_RegisterErrorCallback(ErrorCallback method); | |||
json_char * JSON_Dump(const JSONNODE root); | json_char * JSON_Dump(const JSONNODE root); | |||
unsigned int JSON_GetMemoryUsage(const JSONNODE root); | ||||
#endif | #endif | |||
} | } | |||
#else | #else | |||
//Embedded helper class | //Embedded helper class | |||
class libJSON { | class libJSON { | |||
public: | public: | |||
static JSONNode * Parse(const json_string & json); | static JSONNode * Parse(const json_string & json); | |||
static JSONNode * NewNode(const json_string & name, const json_ string & value); | static JSONNode * NewNode(const json_string & name, const json_ string & value); | |||
static JSONNode * NewStringNode(const json_string & name, const json_string & value); | static JSONNode * NewStringNode(const json_string & name, const json_string & value); | |||
static void Delete(JSONNODE * node); | static void Delete(JSONNODE * node); | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 1 lines changed or added | |||