Operator Console
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
internalJSONNode Class Reference

#include <internalJSONNode.h>

Classes

union  value_union_t
 

Public Member Functions

 internalJSONNode (char mytype=JSON_NULL) json_nothrow json_hot
 
 internalJSONNode (const json_string &unparsed) json_nothrow json_hot
 
 internalJSONNode (const json_string &name_t, const json_string &value_t) json_nothrow json_read_priority
 
 internalJSONNode (const internalJSONNode &orig) json_nothrow json_hot
 
internalJSONNodeoperator= (const internalJSONNode &) json_nothrow json_hot
 
 ~internalJSONNode (void) json_nothrow json_hot
 
json_index_t size (void) const json_nothrow json_read_priority
 
bool empty (void) const json_nothrow
 
unsigned char type (void) const json_nothrow json_read_priority
 
json_string name (void) const json_nothrow json_read_priority
 
void setname (const json_string &newname) json_nothrow json_write_priority
 
void setcomment (const json_string &comment) json_nothrow
 
json_string getcomment (void) const json_nothrow
 
void preparse (void) json_nothrow
 
void push_back (const JSONNode &node) json_nothrow
 
void reserve (json_index_t siz) json_nothrow
 
void push_front (const JSONNode &node) json_nothrow
 
JSONNodepop_back (json_index_t pos) json_nothrow
 
JSONNodepop_back (const json_string &name_t) json_nothrow
 
JSONNodepop_back_nocase (const json_string &name_t) json_nothrow
 
JSONNodeat (json_index_t pos) json_nothrow
 
JSONNode ** at (const json_string &name_t) json_nothrow
 
JSONNode ** at_nocase (const json_string &name_t) json_nothrow
 
void Set (const json_string &val) json_nothrow json_write_priority
 
void Set (long double val) json_nothrow json_write_priority
 
void Set (float val) json_nothrow json_write_priority
 
void Set (double val) json_nothrow json_write_priority
 
 operator long double () const json_nothrow
 
 operator float () const json_nothrow
 
 operator double () const json_nothrow
 
 operator json_string () const json_nothrow
 
 operator bool () const json_nothrow
 
void Set (bool val) json_nothrow
 
bool IsEqualTo (const json_string &val) const json_nothrow
 
bool IsEqualTo (bool val) const json_nothrow
 
bool IsEqualTo (const internalJSONNode *val) const json_nothrow
 
template<typename T >
bool IsEqualToNum (T val) const json_nothrow
 
internalJSONNodeincRef (void) json_nothrow
 
void decRef (void) json_nothrow json_hot
 
bool hasNoReferences (void) json_nothrow json_hot
 
internalJSONNodemakeUnique (void) json_nothrow json_hot
 
JSONNode ** begin (void) const json_nothrow
 
JSONNode ** end (void) const json_nothrow
 
bool Fetched (void) const json_nothrow json_hot
 
void WriteName (bool formatted, bool arrayChild, json_string &output) const json_nothrow json_write_priority
 
void WriteChildren (unsigned int indent, json_string &output) const json_nothrow json_write_priority
 
void WriteComment (unsigned int indent, json_string &output) const json_nothrow json_write_priority
 
void Write (unsigned int indent, bool arrayChild, json_string &output) const json_nothrow json_write_priority
 
bool isContainer (void) const json_nothrow
 
bool isNotContainer (void) const json_nothrow
 
void Nullify (void) const json_nothrow
 
void SetFetched (bool val) const json_nothrow json_hot
 
void Fetch (void) const json_nothrow json_hot
 
void FetchString (void) const json_nothrow json_read_priority
 
void FetchNode (void) const json_nothrow json_read_priority
 
void FetchArray (void) const json_nothrow json_read_priority
 
void FetchNumber (void) const json_nothrow json_read_priority
 
void clearname (void) json_nothrow
 
unsigned char _type BITS (3)
 
bool _name_encoded BITS (1)
 
bool _string_encoded BITS (1)
 
size_t refcount PACKED (20)
 
bool fetched BITS (1)
 
 internalJSONNode (char mytype=JSON_NULL) json_nothrow json_hot
 
 internalJSONNode (const json_string &unparsed) json_nothrow json_hot
 
 internalJSONNode (const json_string &name_t, const json_string &value_t) json_nothrow json_read_priority
 
 internalJSONNode (const internalJSONNode &orig) json_nothrow json_hot
 
internalJSONNodeoperator= (const internalJSONNode &) json_nothrow json_hot
 
 ~internalJSONNode (void) json_nothrow json_hot
 
json_index_t size (void) const json_nothrow json_read_priority
 
bool empty (void) const json_nothrow
 
unsigned char type (void) const json_nothrow json_read_priority
 
json_string name (void) const json_nothrow json_read_priority
 
void setname (const json_string &newname) json_nothrow json_write_priority
 
void setcomment (const json_string &comment) json_nothrow
 
json_string getcomment (void) const json_nothrow
 
void preparse (void) json_nothrow
 
void push_back (const JSONNode &node) json_nothrow
 
void reserve (json_index_t siz) json_nothrow
 
void push_front (const JSONNode &node) json_nothrow
 
JSONNodepop_back (json_index_t pos) json_nothrow
 
JSONNodepop_back (const json_string &name_t) json_nothrow
 
JSONNodepop_back_nocase (const json_string &name_t) json_nothrow
 
JSONNodeat (json_index_t pos) json_nothrow
 
JSONNode ** at (const json_string &name_t) json_nothrow
 
JSONNode ** at_nocase (const json_string &name_t) json_nothrow
 
void Set (const json_string &val) json_nothrow json_write_priority
 
void Set (long double val) json_nothrow json_write_priority
 
void Set (float val) json_nothrow json_write_priority
 
void Set (double val) json_nothrow json_write_priority
 
 operator long double () const json_nothrow
 
 operator float () const json_nothrow
 
 operator double () const json_nothrow
 
 operator json_string () const json_nothrow
 
 operator bool () const json_nothrow
 
void Set (bool val) json_nothrow
 
bool IsEqualTo (const json_string &val) const json_nothrow
 
bool IsEqualTo (bool val) const json_nothrow
 
bool IsEqualTo (const internalJSONNode *val) const json_nothrow
 
template<typename T >
bool IsEqualToNum (T val) const json_nothrow
 
internalJSONNodeincRef (void) json_nothrow
 
void decRef (void) json_nothrow json_hot
 
bool hasNoReferences (void) json_nothrow json_hot
 
internalJSONNodemakeUnique (void) json_nothrow json_hot
 
JSONNode ** begin (void) const json_nothrow
 
JSONNode ** end (void) const json_nothrow
 
bool Fetched (void) const json_nothrow json_hot
 
void WriteName (bool formatted, bool arrayChild, json_string &output) const json_nothrow json_write_priority
 
void WriteChildren (unsigned int indent, json_string &output) const json_nothrow json_write_priority
 
void WriteComment (unsigned int indent, json_string &output) const json_nothrow json_write_priority
 
void Write (unsigned int indent, bool arrayChild, json_string &output) const json_nothrow json_write_priority
 
bool isContainer (void) const json_nothrow
 
bool isNotContainer (void) const json_nothrow
 
void Nullify (void) const json_nothrow
 
void SetFetched (bool val) const json_nothrow json_hot
 
void Fetch (void) const json_nothrow json_hot
 
void FetchString (void) const json_nothrow json_read_priority
 
void FetchNode (void) const json_nothrow json_read_priority
 
void FetchArray (void) const json_nothrow json_read_priority
 
void FetchNumber (void) const json_nothrow json_read_priority
 
void clearname (void) json_nothrow
 
unsigned char _type BITS (3)
 
bool _name_encoded BITS (1)
 
bool _string_encoded BITS (1)
 
size_t refcount PACKED (20)
 
bool fetched BITS (1)
 

Static Public Member Functions

static internalJSONNodenewInternal (char mytype=JSON_NULL) json_hot
 
static internalJSONNodenewInternal (const json_string &unparsed) json_hot
 
static internalJSONNodenewInternal (const json_string &name_t, const json_string &value_t) json_hot
 
static internalJSONNodenewInternal (const internalJSONNode &orig) json_hot
 
static void deleteInternal (internalJSONNode *ptr) json_nothrow json_hot
 
static bool AreEqualNoCase (const json_char *ch_one, const json_char *ch_two) json_nothrow json_read_priority
 
static internalJSONNodenewInternal (char mytype=JSON_NULL) json_hot
 
static internalJSONNodenewInternal (const json_string &unparsed) json_hot
 
static internalJSONNodenewInternal (const json_string &name_t, const json_string &value_t) json_hot
 
static internalJSONNodenewInternal (const internalJSONNode &orig) json_hot
 
static void deleteInternal (internalJSONNode *ptr) json_nothrow json_hot
 
static bool AreEqualNoCase (const json_char *ch_one, const json_char *ch_two) json_nothrow json_read_priority
 

Public Attributes

json_string _name
 
json_string _string
 
value_union_t _value
 
json_string _comment
 
jsonChildrenCHILDREN
 

Constructor & Destructor Documentation

internalJSONNode::internalJSONNode ( char  mytype = JSON_NULL)
inline

References CHILDREN, incinternalAllocCount, and jsonChildren::newChildren().

Referenced by newInternal().

302  : _type(mytype), _name(), _name_encoded(), _string(), _string_encoded(), _value()
303  initializeMutex(0)
305  initializeFetch(true)
306  initializeComment(json_global(EMPTY_JSON_STRING))
307  initializeChildren((_type == JSON_NODE || _type == JSON_ARRAY) ? jsonChildren::newChildren() : 0){
308 
310 
311  #ifdef JSON_LESS_MEMORY
312  //if not less memory, its in the initialization list
313  if (isContainer()){
315  }
316  #endif
317 }
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
#define initializeMutex(x)
Definition: internalJSONNode.h:40
json_string _string
Definition: internalJSONNode.h:268
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define initializeRefCount(x)
Definition: internalJSONNode.h:52
#define initializeFetch(x)
Definition: internalJSONNode.h:48
#define initializeComment(x)
Definition: internalJSONNode.h:58
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define initializeChildren(x)
Definition: internalJSONNode.h:85
#define JSON_NODE
Definition: JSONDefs.h:26
#define incinternalAllocCount()
Definition: internalJSONNode.h:66
static jsonChildren * newChildren(void)
Definition: JSONChildren.h:273
value_union_t _value
Definition: internalJSONNode.h:279
json_string _name
Definition: internalJSONNode.h:265
Definition: JSONChildren.h:42
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

Here is the caller graph for this function:

internalJSONNode::internalJSONNode ( const json_string &  unparsed)

References CHILDREN, incinternalAllocCount, JSON_ARRAY, JSON_FAIL_SAFE, JSON_NODE, JSON_TEXT, and jsonChildren::newChildren().

64  : _type(), _name(),_name_encoded(false), _string(unparsed), _string_encoded(), _value()
67  initializeFetch(false)
68  initializeComment(json_global(EMPTY_JSON_STRING))
70 
72  switch (unparsed[0]){
73  case JSON_TEXT('{'): //node
74  _type = JSON_NODE;
76  #ifdef JSON_PREPARSE
77  FetchNode();
78  #endif
79  break;
80  case JSON_TEXT('['): //array
81  _type = JSON_ARRAY;
83  #ifdef JSON_PREPARSE
84  FetchArray();
85  #endif
86  break;
87  default:
88  JSON_FAIL_SAFE(JSON_TEXT("root not starting with either { or ["), Nullify(););
89  break;
90  }
91 }
#define JSON_FAIL_SAFE(msg, code)
Definition: JSONDebug.h:50
void FetchNode(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:193
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define initializeMutex(x)
Definition: internalJSONNode.h:40
json_string _string
Definition: internalJSONNode.h:268
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define initializeRefCount(x)
Definition: internalJSONNode.h:52
#define initializeFetch(x)
Definition: internalJSONNode.h:48
#define initializeComment(x)
Definition: internalJSONNode.h:58
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define initializeChildren(x)
Definition: internalJSONNode.h:85
#define JSON_NODE
Definition: JSONDefs.h:26
#define incinternalAllocCount()
Definition: internalJSONNode.h:66
static jsonChildren * newChildren(void)
Definition: JSONChildren.h:273
value_union_t _value
Definition: internalJSONNode.h:279
void Nullify(void) const json_nothrow
Definition: internalJSONNode.cpp:402
json_string _name
Definition: internalJSONNode.h:265
void FetchArray(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:201
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

internalJSONNode::internalJSONNode ( const json_string &  name_t,
const json_string &  value_t 
)

References CHILDREN, incinternalAllocCount, JSON_ARRAY, JSON_ASSERT_SAFE, JSON_BOOL, json_char, json_global, JSON_NODE, JSON_NULL, JSON_NUMBER, JSON_STRING, JSON_TEXT, json_unlikely, LETTERCASE, jsonChildren::newChildren(), and SetFetchedFalseOrDo.

102  : _type(), _name_encoded(), _name(JSONWorker::FixString(name_t, NAME_ENCODED)), _string(), _string_encoded(), _value()
103  initializeMutex(0)
105  initializeFetch(false)
106  initializeComment(json_global(EMPTY_JSON_STRING))
108 
110 
111  #ifdef JSON_STRICT
112  JSON_ASSERT_SAFE(!value_t.empty(), JSON_TEXT("empty node"), Nullify(); return;);
113  #else
114  if (json_unlikely(value_t.empty())){
115  _type = JSON_NULL;
116  SetFetched(true);
117  return;
118  }
119  #endif
120 
121  _string = value_t;
122 
123  const json_char firstchar = value_t[0];
124  #if defined JSON_DEBUG || defined JSON_SAFE
125  const json_char lastchar = value_t[value_t.length() - 1];
126  #endif
127 
128  switch (firstchar){
129  case JSON_TEXT('\"'): //a json_string literal, still escaped and with leading and trailing quotes
130  JSON_ASSERT_SAFE(lastchar == JSON_TEXT('\"'), JSON_TEXT("Unterminated quote"), Nullify(); return;);
131  _type = JSON_STRING;
133  break;
134  case JSON_TEXT('{'): //a child node, or set of children
135  JSON_ASSERT_SAFE(lastchar == JSON_TEXT('}'), JSON_TEXT("Missing }"), Nullify(); return;);
136  _type = JSON_NODE;
139  break;
140  case JSON_TEXT('['): //an array
141  JSON_ASSERT_SAFE(lastchar == JSON_TEXT(']'), JSON_TEXT("Missing ]"), Nullify(); return;);
142  _type = JSON_ARRAY;
145  break;
146  LETTERCASE('t', 'T'):
147  JSON_ASSERT_SAFE(value_t == json_global(CONST_TRUE), json_string(json_global(ERROR_UNKNOWN_LITERAL) + value_t).c_str(), Nullify(); return;);
148  _value._bool = true;
149  _type = JSON_BOOL;
150  SetFetched(true);
151  break;
152  LETTERCASE('f', 'F'):
153  JSON_ASSERT_SAFE(value_t == json_global(CONST_FALSE), json_string(json_global(ERROR_UNKNOWN_LITERAL) + value_t).c_str(), Nullify(); return;);
154  _value._bool = false;
155  _type = JSON_BOOL;
156  SetFetched(true);
157  break;
158  LETTERCASE('n', 'N'):
159  JSON_ASSERT_SAFE(value_t == json_global(CONST_NULL), json_string(json_global(ERROR_UNKNOWN_LITERAL) + value_t).c_str(), Nullify(); return;);
160  _type = JSON_NULL;
161  SetFetched(true);
162  break;
163  default:
164  JSON_ASSERT_SAFE(NumberToString::isNumeric(value_t), json_string(json_global(ERROR_UNKNOWN_LITERAL) + value_t).c_str(), Nullify(); return;);
165  _type = JSON_NUMBER;
167  break;
168  }
169 }
void FetchNode(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:193
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
void FetchString(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:183
#define JSON_BOOL
Definition: JSONDefs.h:24
#define initializeMutex(x)
Definition: internalJSONNode.h:40
json_string _string
Definition: internalJSONNode.h:268
#define json_unlikely(x)
Definition: Unknown_C.h:17
#define LETTERCASE(x, y)
Definition: internalJSONNode.cpp:94
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define initializeRefCount(x)
Definition: internalJSONNode.h:52
void SetFetched(bool val) const json_nothrow json_hot
Definition: internalJSONNode.h:410
#define initializeFetch(x)
Definition: internalJSONNode.h:48
#define initializeComment(x)
Definition: internalJSONNode.h:58
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define initializeChildren(x)
Definition: internalJSONNode.h:85
#define json_char
Definition: Strings_Defs.h:21
void FetchNumber(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:212
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_NULL
Definition: JSONDefs.h:21
#define incinternalAllocCount()
Definition: internalJSONNode.h:66
static jsonChildren * newChildren(void)
Definition: JSONChildren.h:273
value_union_t _value
Definition: internalJSONNode.h:279
#define JSON_STRING
Definition: JSONDefs.h:22
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
void Nullify(void) const json_nothrow
Definition: internalJSONNode.cpp:402
#define NAME_ENCODED
Definition: JSONWorker.h:35
json_string _name
Definition: internalJSONNode.h:265
static json_string FixString(const json_string &value_t, bool &flag) json_nothrow json_read_priority
Definition: JSONWorker.cpp:467
#define SetFetchedFalseOrDo(code)
Definition: internalJSONNode.cpp:59
#define JSON_NUMBER
Definition: JSONDefs.h:23
void FetchArray(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:201
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

internalJSONNode::internalJSONNode ( const internalJSONNode orig)

References CHILDREN, incinternalAllocCount, json_foreach, json_likely, jsonChildren::newChildren(), and JSONNode::newJSONNode().

31  :
32  _type(orig._type), _name(orig._name), _name_encoded(orig._name_encoded),
33  _string(orig._string), _string_encoded(orig._string_encoded), _value(orig._value)
36  initializeFetch(orig.fetched)
39 
40 
42  if (isContainer()){
44  if (json_likely(!orig.CHILDREN -> empty())){
45  CHILDREN -> reserve(orig.CHILDREN -> size());
46  json_foreach(orig.CHILDREN, myrunner){
47  CHILDREN -> push_back(JSONNode::newJSONNode((*myrunner) -> duplicate()));
48  }
49  }
50  }
51  #ifdef JSON_MUTEX_CALLBACKS
52  _set_mutex(orig.mylock, false);
53  #endif
54 }
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
#define initializeMutex(x)
Definition: internalJSONNode.h:40
json_string _string
Definition: internalJSONNode.h:268
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define initializeRefCount(x)
Definition: internalJSONNode.h:52
#define initializeFetch(x)
Definition: internalJSONNode.h:48
void push_back(const JSONNode &node) json_nothrow
Definition: internalJSONNode.cpp:421
#define initializeComment(x)
Definition: internalJSONNode.h:58
#define initializeChildren(x)
Definition: internalJSONNode.h:85
#define json_foreach(chldrn, itrtr)
Definition: JSONChildren.h:15
bool empty(void) const json_nothrow
Definition: internalJSONNode.h:334
json_string _comment
Definition: internalJSONNode.h:294
#define incinternalAllocCount()
Definition: internalJSONNode.h:66
static jsonChildren * newChildren(void)
Definition: JSONChildren.h:273
value_union_t _value
Definition: internalJSONNode.h:279
json_index_t size(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:328
#define json_likely(x)
Definition: Unknown_C.h:16
json_string _name
Definition: internalJSONNode.h:265
void reserve(json_index_t siz) json_nothrow
Definition: internalJSONNode.h:444
static JSON_PRIVATE JSONNode * newJSONNode(const JSONNode &orig JSON_MUTEX_COPY_DECL2) json_hot
Definition: JSONNode.cpp:347

Here is the call graph for this function:

internalJSONNode::~internalJSONNode ( void  )

References decinternalAllocCount, and DELETE_CHILDREN.

174  {
176  #ifdef JSON_MUTEX_CALLBACKS
177  _unset_mutex();
178  #endif
179  DELETE_CHILDREN();
180 }
#define decinternalAllocCount()
Definition: internalJSONNode.h:67
#define DELETE_CHILDREN()
Definition: internalJSONNode.h:80
internalJSONNode::internalJSONNode ( char  mytype = JSON_NULL)
internalJSONNode::internalJSONNode ( const json_string &  unparsed)
internalJSONNode::internalJSONNode ( const json_string &  name_t,
const json_string &  value_t 
)
internalJSONNode::internalJSONNode ( const internalJSONNode orig)
internalJSONNode::~internalJSONNode ( void  )

Member Function Documentation

bool internalJSONNode::AreEqualNoCase ( const json_char ch_one,
const json_char ch_two 
)
static

References json_char.

480  {
481  while (*ch_one){ //only need to check one, if the other one terminates early, the check will cause it to fail
482  const json_char c_one = *ch_one;
483  const json_char c_two = *ch_two;
484  if (c_one != c_two){
485  if ((c_two > 64) && (c_two < 91)){ //A - Z
486  if (c_one != (json_char)(c_two + 32)) return false;
487  } else if ((c_two > 96) && (c_two < 123)){ //a - z
488  if (c_one != (json_char)(c_two - 32)) return false;
489  } else { //not a letter, so return false
490  return false;
491  }
492  }
493  ++ch_one;
494  ++ch_two;
495 
496  }
497  return *ch_two == '\0'; //this one has to be null terminated too, or else json_string two is longer, hence, not equal
498  }
#define json_char
Definition: Strings_Defs.h:21
static bool internalJSONNode::AreEqualNoCase ( const json_char ch_one,
const json_char ch_two 
)
static
JSONNode* internalJSONNode::at ( json_index_t  pos)
JSONNode * internalJSONNode::at ( json_index_t  pos)
inline

References CHILDREN, JSON_ASSERT_SAFE, and JSON_TEXT.

435  {
436  JSON_ASSERT_SAFE(isContainer(), JSON_TEXT("calling at on non-container type"), return 0;);
437  Fetch();
438  return (*CHILDREN)[pos];
439 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
JSONNode ** internalJSONNode::at ( const json_string &  name_t)

References CHILDREN, JSON_ASSERT, JSON_ASSERT_SAFE, json_foreach, json_global, JSON_TEXT, and json_unlikely.

469  {
470  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("at"), return 0;);
471  Fetch();
472  json_foreach(CHILDREN, myrunner){
473  JSON_ASSERT(*myrunner != NULL, json_global(ERROR_NULL_IN_CHILDREN));
474  if (json_unlikely((*myrunner) -> name() == name_t)) return myrunner;
475  }
476  return 0;
477 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
#define json_unlikely(x)
Definition: Unknown_C.h:17
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define json_foreach(chldrn, itrtr)
Definition: JSONChildren.h:15
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
json_string name(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:344
JSONNode** internalJSONNode::at ( const json_string &  name_t)
JSONNode ** internalJSONNode::at_nocase ( const json_string &  name_t)

References CHILDREN, JSON_ASSERT, JSON_ASSERT_SAFE, json_foreach, json_global, JSON_TEXT, and json_unlikely.

500  {
501  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("at_nocase"), return 0;);
502  Fetch();
503  json_foreach(CHILDREN, myrunner){
504  JSON_ASSERT(*myrunner, json_global(ERROR_NULL_IN_CHILDREN));
505  if (json_unlikely(AreEqualNoCase((*myrunner) -> name().c_str(), name_t.c_str()))) return myrunner;
506  }
507  return 0;
508  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
#define json_unlikely(x)
Definition: Unknown_C.h:17
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
static bool AreEqualNoCase(const json_char *ch_one, const json_char *ch_two) json_nothrow json_read_priority
Definition: internalJSONNode.cpp:480
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define json_foreach(chldrn, itrtr)
Definition: JSONChildren.h:15
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
json_string name(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:344
JSONNode** internalJSONNode::at_nocase ( const json_string &  name_t)
JSONNode ** internalJSONNode::begin ( void  ) const
inline

References CHILDREN, Fetch(), isContainer(), JSON_ASSERT_SAFE, json_global, and JSON_TEXT.

423  {
424  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("begin"), return 0;);
425  Fetch();
426  return CHILDREN -> begin();
427 }
JSONNode ** begin(void) const json_nothrow
Definition: internalJSONNode.h:423
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49

Here is the call graph for this function:

JSONNode** internalJSONNode::begin ( void  ) const
unsigned char _type internalJSONNode::BITS ( )
mutable
unsigned char _type internalJSONNode::BITS ( )
mutable
bool _name_encoded internalJSONNode::BITS ( )
mutable
bool _name_encoded internalJSONNode::BITS ( )
mutable
bool _string_encoded internalJSONNode::BITS ( )
mutable
bool _string_encoded internalJSONNode::BITS ( )
mutable
bool fetched internalJSONNode::BITS ( )
mutable
bool fetched internalJSONNode::BITS ( )
mutable
void internalJSONNode::clearname ( void  )
inline

References _name, and clearString().

251  {
253  }
json_string _name
Definition: internalJSONNode.h:265
static void clearString(json_string &str) json_nothrow
Definition: JSONMemory.h:147

Here is the call graph for this function:

void internalJSONNode::clearname ( void  )
inline

References _name, and clearString().

251  {
253  }
json_string _name
Definition: internalJSONNode.h:265
static void clearString(json_string &str) json_nothrow
Definition: JSONMemory.h:147

Here is the call graph for this function:

void internalJSONNode::decRef ( void  )
inline

References JSON_ASSERT, and JSON_TEXT.

Referenced by makeUnique().

386  {
387  JSON_ASSERT(refcount != 0, JSON_TEXT("decRef on a 0 refcount internal"));
388  --refcount;
389  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53

Here is the caller graph for this function:

void internalJSONNode::decRef ( void  )
static void internalJSONNode::deleteInternal ( internalJSONNode ptr)
static
void internalJSONNode::deleteInternal ( internalJSONNode ptr)
static

Referenced by JSONNode::decRef().

692  {
693  #ifdef JSON_MEMORY_POOL
694  ptr -> ~internalJSONNode();
695  json_internal_mempool.deallocate((void*)ptr);
696  #elif defined(JSON_MEMORY_CALLBACKS)
697  ptr -> ~internalJSONNode();
698  libjson_free<internalJSONNode>(ptr);
699  #else
700  delete ptr;
701  #endif
702 }
~internalJSONNode(void) json_nothrow json_hot
Definition: internalJSONNode.cpp:174

Here is the caller graph for this function:

bool internalJSONNode::empty ( void  ) const
bool internalJSONNode::empty ( void  ) const
inline

References CHILDREN, Fetch(), and isNotContainer().

334  {
335  if (isNotContainer()) return true;
336  Fetch();
337  return CHILDREN -> empty();
338 }
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
bool isNotContainer(void) const json_nothrow
Definition: internalJSONNode.h:216
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
bool empty(void) const json_nothrow
Definition: internalJSONNode.h:334

Here is the call graph for this function:

JSONNode ** internalJSONNode::end ( void  ) const
inline

References CHILDREN, Fetch(), isContainer(), JSON_ASSERT_SAFE, json_global, and JSON_TEXT.

429  {
430  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("end"), return 0;);
431  Fetch();
432  return CHILDREN -> end();
433 }
JSONNode ** end(void) const json_nothrow
Definition: internalJSONNode.h:429
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49

Here is the call graph for this function:

JSONNode** internalJSONNode::end ( void  ) const
void internalJSONNode::Fetch ( void  ) const

References FetchArray(), FetchNode(), FetchNumber(), FetchString(), JSON_ARRAY, JSON_FAIL, JSON_NODE, JSON_NUMBER, JSON_STRING, JSON_TEXT, Nullify(), and type().

Referenced by begin(), empty(), end(), preparse(), and size().

251  {
252  if (fetched) return;
253  switch (type()){
254  case JSON_STRING:
255  FetchString();
256  break;
257  case JSON_NODE:
258  FetchNode();
259  break;
260  case JSON_ARRAY:
261  FetchArray();
262  break;
263  case JSON_NUMBER:
264  FetchNumber();
265  break;
266  #if defined JSON_DEBUG || defined JSON_SAFE
267  default:
268  JSON_FAIL(JSON_TEXT("Fetching an unknown type"));
269  Nullify();
270  #endif
271  }
272  fetched = true;
273  }
void FetchNode(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:193
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
void FetchString(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:183
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
void FetchNumber(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:212
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_STRING
Definition: JSONDefs.h:22
void Nullify(void) const json_nothrow
Definition: internalJSONNode.cpp:402
#define JSON_NUMBER
Definition: JSONDefs.h:23
void FetchArray(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:201
#define JSON_FAIL(msg)
Definition: JSONDebug.h:54
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::Fetch ( void  ) const
void internalJSONNode::FetchArray ( void  ) const

References _string, clearString(), JSONWorker::DoArray(), JSON_ASSERT_SAFE, JSON_TEXT, and Nullify().

Referenced by Fetch().

201  {
202  JSON_ASSERT_SAFE(!_string.empty(), JSON_TEXT("JSON node type is empty?"), Nullify(); return;);
203  JSON_ASSERT_SAFE(_string[0] == JSON_TEXT('['), JSON_TEXT("JSON node type doesn't start with a square bracket?"), Nullify(); return;);
204  JSON_ASSERT_SAFE(_string[_string.length() - 1] == JSON_TEXT(']'), JSON_TEXT("JSON node type doesn't end with a square bracket?"), Nullify(); return;);
207  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
json_string _string
Definition: internalJSONNode.h:268
static void DoArray(const internalJSONNode *parent, const json_string &value_t) json_nothrow json_read_priority
Definition: JSONWorker.cpp:638
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
void Nullify(void) const json_nothrow
Definition: internalJSONNode.cpp:402
static void clearString(json_string &str) json_nothrow
Definition: JSONMemory.h:147

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::FetchArray ( void  ) const
bool internalJSONNode::Fetched ( void  ) const
inline
415  {
416  #if !defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)
417  return fetched;
418  #else
419  return true;
420  #endif
421 }
bool internalJSONNode::Fetched ( void  ) const
void internalJSONNode::FetchNode ( void  ) const

References _string, clearString(), JSONWorker::DoNode(), JSON_ASSERT_SAFE, JSON_TEXT, and Nullify().

Referenced by Fetch().

193  {
194  JSON_ASSERT_SAFE(!_string.empty(), JSON_TEXT("JSON node type is empty?"), Nullify(); return;);
195  JSON_ASSERT_SAFE(_string[0] == JSON_TEXT('{'), JSON_TEXT("JSON node type doesn't start with a bracket?"), Nullify(); return;);
196  JSON_ASSERT_SAFE(_string[_string.length() - 1] == JSON_TEXT('}'), JSON_TEXT("JSON node type doesn't end with a bracket?"), Nullify(); return;);
199  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
json_string _string
Definition: internalJSONNode.h:268
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
void Nullify(void) const json_nothrow
Definition: internalJSONNode.cpp:402
static void clearString(json_string &str) json_nothrow
Definition: JSONMemory.h:147
static void DoNode(const internalJSONNode *parent, const json_string &value_t) json_nothrow json_read_priority
Definition: JSONWorker.cpp:676

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::FetchNode ( void  ) const
void internalJSONNode::FetchNumber ( void  ) const
void internalJSONNode::FetchNumber ( void  ) const

References internalJSONNode::value_union_t::_number, _string, _value, clearString(), json_char, and json_auto< T >::ptr.

Referenced by Fetch().

212  {
213  #ifdef JSON_STRICT
214  _value._number = NumberToString::_atof(_string.c_str());
215  #else
216  #ifdef JSON_UNICODE
217  const size_t len = _string.length();
218  #if defined(_MSC_VER) && defined(JSON_SAFE)
219  const size_t bytes = (len * (sizeof(json_char) / sizeof(char))) + 1;
220  json_auto<char> temp(bytes);
221  size_t res;
222  errno_t err = std::wcstombs_s(&res, temp.ptr, bytes, _string.c_str(), len);
223  if (err != 0){
224  _value._number = (json_number)0.0;
225  return;
226  }
227  #elif defined(JSON_SAFE)
228  const size_t bytes = (len * (sizeof(json_char) / sizeof(char))) + 1;
229  json_auto<char> temp(bytes);
230  size_t res = std::wcstombs(temp.ptr, _string.c_str(), len);
231  if (res == (size_t)-1){
232  _value._number = (json_number)0.0;
233  return;
234  }
235  #else
236  json_auto<char> temp(len + 1);
237  size_t res = std::wcstombs(temp.ptr, _string.c_str(), len);
238  #endif
239  temp.ptr[res] = '\0';
240  _value._number = (json_number)std::atof(temp.ptr);
241  #else
242  _value._number = (json_number)std::atof(_string.c_str());
243  #endif
244  #endif
245  #if((!defined(JSON_CASTABLE) && defined(JSON_LESS_MEMORY)) && !defined(JSON_WRITE_PRIORITY))
247  #endif
248 }
json_string _string
Definition: internalJSONNode.h:268
Definition: JSONMemory.h:129
#define json_char
Definition: Strings_Defs.h:21
value_union_t _value
Definition: internalJSONNode.h:279
double json_number
Definition: JSONDefs.h:91
static void clearString(json_string &str) json_nothrow
Definition: JSONMemory.h:147
json_number _number
Definition: internalJSONNode.h:274

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::FetchString ( void  ) const

References _string, JSONWorker::FixString(), JSON_ASSERT, JSON_ASSERT_SAFE, JSON_TEXT, Nullify(), and STRING_ENCODED.

Referenced by Fetch().

183  {
184  JSON_ASSERT_SAFE(!_string.empty(), JSON_TEXT("JSON json_string type is empty?"), Nullify(); return;);
185  JSON_ASSERT_SAFE(_string[0] == JSON_TEXT('\"'), JSON_TEXT("JSON json_string type doesn't start with a quotation?"), Nullify(); return;);
186  JSON_ASSERT_SAFE(_string[_string.length() - 1] == JSON_TEXT('\"'), JSON_TEXT("JSON json_string type doesn't end with a quotation?"), Nullify(); return;);
187  _string = JSONWorker::FixString(json_string(_string.begin() + 1, _string.end() - 1), STRING_ENCODED);
188  #ifdef JSON_LESS_MEMORY
189  JSON_ASSERT(_string.capacity() == _string.length(), JSON_TEXT("_string object too large 2"));
190  #endif
191  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
json_string _string
Definition: internalJSONNode.h:268
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
void Nullify(void) const json_nothrow
Definition: internalJSONNode.cpp:402
#define STRING_ENCODED
Definition: JSONWorker.h:36
static json_string FixString(const json_string &value_t, bool &flag) json_nothrow json_read_priority
Definition: JSONWorker.cpp:467

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::FetchString ( void  ) const
json_string internalJSONNode::getcomment ( void  ) const
json_string internalJSONNode::getcomment ( void  ) const
inline

References _comment.

Referenced by JSONNode::get_comment().

361  {
362  return _comment;
363  }
json_string _comment
Definition: internalJSONNode.h:294

Here is the caller graph for this function:

bool internalJSONNode::hasNoReferences ( void  )
inline

Referenced by JSONNode::decRef().

391  {
392  return refcount == 0;
393  }

Here is the caller graph for this function:

bool internalJSONNode::hasNoReferences ( void  )
internalJSONNode * internalJSONNode::incRef ( void  )
inline

References makeUnique().

319  {
320  #ifdef JSON_REF_COUNT
321  ++refcount;
322  return this;
323  #else
324  return makeUnique();
325  #endif
326 }
internalJSONNode * makeUnique(void) json_nothrow json_hot
Definition: internalJSONNode.h:396

Here is the call graph for this function:

internalJSONNode* internalJSONNode::incRef ( void  )
bool internalJSONNode::isContainer ( void  ) const
inline

References JSON_ARRAY, and JSON_NODE.

Referenced by begin(), end(), and preparse().

213  {
214  return (_type == JSON_NODE || _type == JSON_ARRAY);
215  }
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the caller graph for this function:

bool internalJSONNode::isContainer ( void  ) const
inline

References JSON_ARRAY, and JSON_NODE.

213  {
214  return (_type == JSON_NODE || _type == JSON_ARRAY);
215  }
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_ARRAY
Definition: JSONDefs.h:25
bool internalJSONNode::IsEqualTo ( const json_string &  val) const
inline

References JSON_STRING.

366  {
367  if (type() != JSON_STRING) return false;
368  Fetch();
369  return _string == val;
370 }
json_string _string
Definition: internalJSONNode.h:268
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_STRING
Definition: JSONDefs.h:22
bool internalJSONNode::IsEqualTo ( const json_string &  val) const
bool internalJSONNode::IsEqualTo ( bool  val) const
inline

References JSON_BOOL.

372  {
373  if (type() != JSON_BOOL) return false;
374  Fetch();
375  return val == _value._bool;
376 }
#define JSON_BOOL
Definition: JSONDefs.h:24
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
value_union_t _value
Definition: internalJSONNode.h:279
bool internalJSONNode::IsEqualTo ( bool  val) const
bool internalJSONNode::IsEqualTo ( const internalJSONNode val) const

References _floatsAreEqual(), CHILDREN, JSON_ARRAY, JSON_ASSERT, JSON_BOOL, json_foreach, json_global, JSON_NODE, JSON_NULL, JSON_NUMBER, JSON_STRING, and JSON_TEXT.

369  {
370  if (this == val) return true; //same internal object, so they must be equal (not only for ref counting)
371  if (type() != val -> type()) return false; //aren't even same type
372  if (_name != val -> _name) return false; //names aren't the same
373  if (type() == JSON_NULL) return true; //both null, can't be different
374  #if !defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)
375  Fetch();
376  val -> Fetch();
377  #endif
378  switch (type()){
379  case JSON_STRING:
380  return val -> _string == _string;
381  case JSON_NUMBER:
382  return _floatsAreEqual(val -> _value._number, _value._number);
383  case JSON_BOOL:
384  return val -> _value._bool == _value._bool;
385  };
386 
387  JSON_ASSERT(type() == JSON_NODE || type() == JSON_ARRAY, JSON_TEXT("Checking for equality, not sure what type"));
388  if (CHILDREN -> size() != val -> CHILDREN -> size()) return false; //if they arne't he same size then they certainly aren't equal
389 
390  //make sure each children is the same
391  JSONNode ** valrunner = val -> CHILDREN -> begin();
392  json_foreach(CHILDREN, myrunner){
393  JSON_ASSERT(*myrunner != NULL, json_global(ERROR_NULL_IN_CHILDREN));
394  JSON_ASSERT(*valrunner != NULL, json_global(ERROR_NULL_IN_CHILDREN));
395  JSON_ASSERT(valrunner != val -> CHILDREN -> end(), JSON_TEXT("at the end of other one's children, but they're the same size?"));
396  if (**myrunner != **valrunner) return false;
397  ++valrunner;
398  }
399  return true;
400 }
JSONNode ** end(void) const json_nothrow
Definition: internalJSONNode.h:429
JSONNode ** begin(void) const json_nothrow
Definition: internalJSONNode.h:423
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define JSON_BOOL
Definition: JSONDefs.h:24
json_string _string
Definition: internalJSONNode.h:268
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define json_foreach(chldrn, itrtr)
Definition: JSONChildren.h:15
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
Definition: JSONNode.h:132
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_NULL
Definition: JSONDefs.h:21
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
value_union_t _value
Definition: internalJSONNode.h:279
#define JSON_STRING
Definition: JSONDefs.h:22
json_index_t size(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:328
json_string _name
Definition: internalJSONNode.h:265
static bool _floatsAreEqual(const json_number &one, const json_number &two) json_pure
Definition: NumberToString.h:41
json_number _number
Definition: internalJSONNode.h:274
#define JSON_NUMBER
Definition: JSONDefs.h:23
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

bool internalJSONNode::IsEqualTo ( const internalJSONNode val) const
template<typename T >
bool internalJSONNode::IsEqualToNum ( val) const
inline

References JSON_NUMBER.

379  {
380  if (type() != JSON_NUMBER) return false;
381  Fetch();
382  return (json_number)val == _value._number;
383 }
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
value_union_t _value
Definition: internalJSONNode.h:279
double json_number
Definition: JSONDefs.h:91
json_number _number
Definition: internalJSONNode.h:274
#define JSON_NUMBER
Definition: JSONDefs.h:23
template<typename T >
bool internalJSONNode::IsEqualToNum ( val) const
bool internalJSONNode::isNotContainer ( void  ) const
inline

References JSON_ARRAY, and JSON_NODE.

Referenced by empty(), and size().

216  {
217  return (_type != JSON_NODE && _type != JSON_ARRAY);
218  }
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the caller graph for this function:

bool internalJSONNode::isNotContainer ( void  ) const
inline

References JSON_ARRAY, and JSON_NODE.

216  {
217  return (_type != JSON_NODE && _type != JSON_ARRAY);
218  }
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_ARRAY
Definition: JSONDefs.h:25
internalJSONNode * internalJSONNode::makeUnique ( void  )
inline

References decRef(), JSON_ASSERT, JSON_TEXT, and newInternal().

Referenced by incRef(), and JSONNode::makeUniqueInternal().

396  {
397  #ifdef JSON_REF_COUNT
398  if (refcount > 1){
399  decRef();
400  return newInternal(*this);
401  }
402  JSON_ASSERT(refcount == 1, JSON_TEXT("makeUnique on a 0 refcount internal"));
403  return this;
404  #else
405  return newInternal(*this);
406  #endif
407 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
static internalJSONNode * newInternal(char mytype=JSON_NULL) json_hot
Definition: internalJSONNode.cpp:704
void decRef(void) json_nothrow json_hot
Definition: internalJSONNode.h:386
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

internalJSONNode* internalJSONNode::makeUnique ( void  )
json_string internalJSONNode::name ( void  ) const
json_string internalJSONNode::name ( void  ) const
inline

References _name.

344  {
345  return _name;
346 }
json_string _name
Definition: internalJSONNode.h:265
static internalJSONNode* internalJSONNode::newInternal ( char  mytype = JSON_NULL)
static
internalJSONNode * internalJSONNode::newInternal ( char  mytype = JSON_NULL)
static

References internalJSONNode().

Referenced by makeUnique().

704  {
705  #ifdef JSON_MEMORY_POOL
706  return new((internalJSONNode*)json_internal_mempool.allocate()) internalJSONNode(mytype);
707  #elif defined(JSON_MEMORY_CALLBACKS)
708  return new(json_malloc<internalJSONNode>(1)) internalJSONNode(mytype);
709  #else
710  return new internalJSONNode(mytype);
711  #endif
712 }
internalJSONNode(char mytype=JSON_NULL) json_nothrow json_hot
Definition: internalJSONNode.h:302
Definition: internalJSONNode.h:88

Here is the call graph for this function:

Here is the caller graph for this function:

static internalJSONNode* internalJSONNode::newInternal ( const json_string &  unparsed)
static
internalJSONNode * internalJSONNode::newInternal ( const json_string &  unparsed)
static

References internalJSONNode().

715  {
716  #ifdef JSON_MEMORY_POOL
717  return new((internalJSONNode*)json_internal_mempool.allocate()) internalJSONNode(unparsed);
718  #elif defined(JSON_MEMORY_CALLBACKS)
719  return new(json_malloc<internalJSONNode>(1)) internalJSONNode(unparsed);
720  #else
721  return new internalJSONNode(unparsed);
722  #endif
723 }
internalJSONNode(char mytype=JSON_NULL) json_nothrow json_hot
Definition: internalJSONNode.h:302
Definition: internalJSONNode.h:88

Here is the call graph for this function:

static internalJSONNode* internalJSONNode::newInternal ( const json_string &  name_t,
const json_string &  value_t 
)
static
internalJSONNode * internalJSONNode::newInternal ( const json_string &  name_t,
const json_string &  value_t 
)
static

References internalJSONNode().

725  {
726  #ifdef JSON_MEMORY_POOL
727  return new((internalJSONNode*)json_internal_mempool.allocate()) internalJSONNode(name_t, value_t);
728  #elif defined(JSON_MEMORY_CALLBACKS)
729  return new(json_malloc<internalJSONNode>(1)) internalJSONNode(name_t, value_t);
730  #else
731  return new internalJSONNode(name_t, value_t);
732  #endif
733 }
internalJSONNode(char mytype=JSON_NULL) json_nothrow json_hot
Definition: internalJSONNode.h:302
Definition: internalJSONNode.h:88

Here is the call graph for this function:

static internalJSONNode* internalJSONNode::newInternal ( const internalJSONNode orig)
static
internalJSONNode * internalJSONNode::newInternal ( const internalJSONNode orig)
static

References internalJSONNode().

737  {
738  #ifdef JSON_MEMORY_POOL
739  return new((internalJSONNode*)json_internal_mempool.allocate()) internalJSONNode(orig);
740  #elif defined(JSON_MEMORY_CALLBACKS)
741  return new(json_malloc<internalJSONNode>(1)) internalJSONNode(orig);
742  #else
743  return new internalJSONNode(orig);
744  #endif
745 }
internalJSONNode(char mytype=JSON_NULL) json_nothrow json_hot
Definition: internalJSONNode.h:302
Definition: internalJSONNode.h:88

Here is the call graph for this function:

void internalJSONNode::Nullify ( void  ) const

References _string, clearString(), json_global, JSON_NULL, and SetFetched().

Referenced by Fetch(), FetchArray(), FetchNode(), FetchString(), and JSONNode::nullify().

402  {
403  _type = JSON_NULL;
404  #if(defined(JSON_CASTABLE) || !defined(JSON_LESS_MEMORY) || defined(JSON_WRITE_PRIORITY))
405  _string = json_global(CONST_NULL);
406  #else
408  #endif
409  SetFetched(true);
410 }
json_string _string
Definition: internalJSONNode.h:268
void SetFetched(bool val) const json_nothrow json_hot
Definition: internalJSONNode.h:410
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define JSON_NULL
Definition: JSONDefs.h:21
static void clearString(json_string &str) json_nothrow
Definition: JSONMemory.h:147

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::Nullify ( void  ) const
internalJSONNode::operator bool ( ) const

References _floatsAreEqual(), JSON_ASSERT, JSON_BOOL, json_global, JSON_NULL, JSON_NUMBER, and JSON_TEXT.

522  {
523  Fetch();
524  #ifdef JSON_CASTABLE
525  switch(type()){
526  case JSON_NUMBER:
527  return !_floatsAreEqual(_value._number, (json_number)0.0);
528  case JSON_NULL:
529  return false;
530  }
531  #endif
532  JSON_ASSERT(type() == JSON_BOOL, json_global(ERROR_UNDEFINED) + JSON_TEXT("(bool)"));
533  return _value._bool;
534 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define JSON_BOOL
Definition: JSONDefs.h:24
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
#define json_global(NAME)
Definition: JSONGlobals.h:26
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_NULL
Definition: JSONDefs.h:21
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
value_union_t _value
Definition: internalJSONNode.h:279
double json_number
Definition: JSONDefs.h:91
static bool _floatsAreEqual(const json_number &one, const json_number &two) json_pure
Definition: NumberToString.h:41
json_number _number
Definition: internalJSONNode.h:274
#define JSON_NUMBER
Definition: JSONDefs.h:23

Here is the call graph for this function:

internalJSONNode::operator bool ( ) const
internalJSONNode::operator double ( ) const
internalJSONNode::operator double ( ) const
inline
496  {
497  return static_cast<double>(static_cast<long double>(*this));
498  }
internalJSONNode::operator float ( ) const
inline
493  {
494  return static_cast<float>(static_cast<long double>(*this));
495  }
internalJSONNode::operator float ( ) const
internalJSONNode::operator json_string ( ) const
inline
485  {
486  Fetch();
487  return _string;
488 }
json_string _string
Definition: internalJSONNode.h:268
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
internalJSONNode::operator json_string ( ) const
internalJSONNode::operator long double ( ) const
internalJSONNode::operator long double ( ) const

References JSON_ASSERT, JSON_BOOL, json_global, JSON_NULL, JSON_NUMBER, JSON_STRING, and JSON_TEXT.

571  {
572  Fetch();
573  #ifdef JSON_CASTABLE
574  switch(type()){
575  case JSON_NULL:
576  return (long double)0.0;
577  case JSON_BOOL:
578  return (long double)(_value._bool ? 1.0 : 0.0);
579  case JSON_STRING:
580  FetchNumber();
581  }
582  #endif
583  JSON_ASSERT(type() == JSON_NUMBER, json_global(ERROR_UNDEFINED) + JSON_TEXT("(long double)"));
584  return (long double)_value._number;
585  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define JSON_BOOL
Definition: JSONDefs.h:24
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
#define json_global(NAME)
Definition: JSONGlobals.h:26
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
void FetchNumber(void) const json_nothrow json_read_priority
Definition: internalJSONNode.cpp:212
#define JSON_NULL
Definition: JSONDefs.h:21
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
value_union_t _value
Definition: internalJSONNode.h:279
#define JSON_STRING
Definition: JSONDefs.h:22
json_number _number
Definition: internalJSONNode.h:274
#define JSON_NUMBER
Definition: JSONDefs.h:23
internalJSONNode& internalJSONNode::operator= ( const internalJSONNode )
internalJSONNode& internalJSONNode::operator= ( const internalJSONNode )
size_t refcount internalJSONNode::PACKED ( 20  )
size_t refcount internalJSONNode::PACKED ( 20  )
JSONNode * internalJSONNode::pop_back ( json_index_t  pos)

References CHILDREN, JSON_ASSERT_SAFE, json_global, and JSON_TEXT.

439  {
440  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("pop_back"), return 0;);
441  JSONNode * result = (*CHILDREN)[pos];
442  JSONNode ** temp = CHILDREN -> begin() + pos;
443  CHILDREN -> erase(temp);
444  return result;
445 }
JSONNode ** begin(void) const json_nothrow
Definition: internalJSONNode.h:423
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
Definition: JSONNode.h:132
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
JSONNode* internalJSONNode::pop_back ( json_index_t  pos)
JSONNode * internalJSONNode::pop_back ( const json_string &  name_t)

References CHILDREN, JSON_ASSERT_SAFE, json_global, and JSON_TEXT.

447  {
448  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("pop_back(str)"), return 0;);
449  if (JSONNode ** res = at(name_t)){
450  JSONNode * result = *res;
451  CHILDREN -> erase(res);
452  return result;
453  }
454  return 0;
455 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
Definition: JSONNode.h:132
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
JSONNode * at(json_index_t pos) json_nothrow
Definition: internalJSONNode.h:435
JSONNode* internalJSONNode::pop_back ( const json_string &  name_t)
JSONNode * internalJSONNode::pop_back_nocase ( const json_string &  name_t)

References CHILDREN, JSON_ASSERT_SAFE, json_global, and JSON_TEXT.

458  {
459  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("pop_back_nocase"), return 0;);
460  if (JSONNode ** res = at_nocase(name_t)){
461  JSONNode * result = *res;
462  CHILDREN -> erase(res);
463  return result;
464  }
465  return 0;
466  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
JSONNode ** at_nocase(const json_string &name_t) json_nothrow
Definition: internalJSONNode.cpp:500
#define json_global(NAME)
Definition: JSONGlobals.h:26
Definition: JSONNode.h:132
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
JSONNode* internalJSONNode::pop_back_nocase ( const json_string &  name_t)
void internalJSONNode::preparse ( void  )
void internalJSONNode::preparse ( void  )

References CHILDREN, Fetch(), isContainer(), and json_foreach.

512  {
513  Fetch();
514  if (isContainer()){
515  json_foreach(CHILDREN, myrunner){
516  (*myrunner) -> preparse();
517  }
518  }
519  }
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_foreach(chldrn, itrtr)
Definition: JSONChildren.h:15
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
void preparse(void) json_nothrow
Definition: internalJSONNode.cpp:512

Here is the call graph for this function:

void internalJSONNode::push_back ( const JSONNode node)
void internalJSONNode::push_back ( const JSONNode node)

References CHILDREN, JSON_ASSERT_SAFE, json_global, JSON_MUTEX_COPY, JSON_TEXT, and JSONNode::newJSONNode().

Referenced by JSONNode::push_back().

421  {
422 #endif
423  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("push_back"), return;);
424  #ifdef JSON_LIBRARY
425  #ifdef JSON_MUTEX_CALLBACKS
426  if (mylock != 0) node -> set_mutex(mylock);
427  #endif
428  CHILDREN -> push_back(node);
429  #else
431  #endif
432 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
void push_back(const JSONNode &node) json_nothrow
Definition: internalJSONNode.cpp:421
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
#define JSON_MUTEX_COPY
Definition: internalJSONNode.cpp:415
static JSON_PRIVATE JSONNode * newJSONNode(const JSONNode &orig JSON_MUTEX_COPY_DECL2) json_hot
Definition: JSONNode.cpp:347

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::push_front ( const JSONNode node)

References CHILDREN, JSON_ASSERT_SAFE, json_global, JSON_MUTEX_COPY, JSON_TEXT, and JSONNode::newJSONNode().

434  {
435  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("push_front"), return;);
437 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
void push_front(const JSONNode &node) json_nothrow
Definition: internalJSONNode.cpp:434
#define JSON_MUTEX_COPY
Definition: internalJSONNode.cpp:415
static JSON_PRIVATE JSONNode * newJSONNode(const JSONNode &orig JSON_MUTEX_COPY_DECL2) json_hot
Definition: JSONNode.cpp:347

Here is the call graph for this function:

void internalJSONNode::push_front ( const JSONNode node)
void internalJSONNode::reserve ( json_index_t  siz)
void internalJSONNode::reserve ( json_index_t  siz)
inline

References CHILDREN, JSON_ASSERT_SAFE, json_global, JSON_TEXT, and jsonChildren::reserve2().

Referenced by JSONNode::reserve().

446 {
447  JSON_ASSERT_SAFE(isContainer(), json_global(ERROR_NON_CONTAINER) + JSON_TEXT("reserve"), return;);
448  Fetch();
450 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
bool isContainer(void) const json_nothrow
Definition: internalJSONNode.h:213
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
#define json_global(NAME)
Definition: JSONGlobals.h:26
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_ASSERT_SAFE(condition, msg, code)
Definition: JSONDebug.h:49
static void reserve2(jsonChildren *&mine, json_index_t amount) json_nothrow
Definition: JSONChildren.cpp:9

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::Set ( const json_string &  val)
void internalJSONNode::Set ( const json_string &  val)

References JSON_STRING, makeNotContainer, and shrinkString.

276  {
278  _type = JSON_STRING;
279  _string = shrinkString(val);
280  _string_encoded = true;
281  SetFetched(true);
282 }
#define shrinkString(str)
Definition: JSONMemory.h:162
json_string _string
Definition: internalJSONNode.h:268
void SetFetched(bool val) const json_nothrow json_hot
Definition: internalJSONNode.h:410
#define JSON_STRING
Definition: JSONDefs.h:22
#define makeNotContainer()
Definition: internalJSONNode.h:83
void internalJSONNode::Set ( long double  val)
void internalJSONNode::Set ( long double  val)
void internalJSONNode::Set ( float  val)
void internalJSONNode::Set ( float  val)
void internalJSONNode::Set ( double  val)
void internalJSONNode::Set ( double  val)
void internalJSONNode::Set ( bool  val)

References JSON_BOOL, json_global, and makeNotContainer.

359  {
361  _type = JSON_BOOL;
362  _value._bool = val;
363  #if(defined(JSON_CASTABLE) || !defined(JSON_LESS_MEMORY) || defined(JSON_WRITE_PRIORITY))
364  _string = val ? json_global(CONST_TRUE) : json_global(CONST_FALSE);
365  #endif
366  SetFetched(true);
367 }
#define JSON_BOOL
Definition: JSONDefs.h:24
json_string _string
Definition: internalJSONNode.h:268
void SetFetched(bool val) const json_nothrow json_hot
Definition: internalJSONNode.h:410
#define json_global(NAME)
Definition: JSONGlobals.h:26
value_union_t _value
Definition: internalJSONNode.h:279
#define makeNotContainer()
Definition: internalJSONNode.h:83
void internalJSONNode::Set ( bool  val)
void internalJSONNode::setcomment ( const json_string &  comment)
void internalJSONNode::setcomment ( const json_string &  comment)
inline

Referenced by JSONNode::set_comment().

357  {
358  _comment = comment;
359  }
json_string _comment
Definition: internalJSONNode.h:294

Here is the caller graph for this function:

void internalJSONNode::SetFetched ( bool  val) const
inline

Referenced by Nullify().

410  {
411  fetched = val;
412  }

Here is the caller graph for this function:

void internalJSONNode::SetFetched ( bool  val) const
void internalJSONNode::setname ( const json_string &  newname)
void internalJSONNode::setname ( const json_string &  newname)
inline

References JSON_ASSERT, and JSON_TEXT.

Referenced by JSONNode::set_name().

348  {
349  #ifdef JSON_LESS_MEMORY
350  JSON_ASSERT(newname.capacity() == newname.length(), JSON_TEXT("name object too large"));
351  #endif
352  _name = newname;
353  _name_encoded = true;
354 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
json_string _name
Definition: internalJSONNode.h:265

Here is the caller graph for this function:

json_index_t internalJSONNode::size ( void  ) const
json_index_t internalJSONNode::size ( void  ) const
inline

References CHILDREN, Fetch(), and isNotContainer().

328  {
329  if (isNotContainer()) return 0;
330  Fetch();
331  return CHILDREN -> size();
332 }
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
bool isNotContainer(void) const json_nothrow
Definition: internalJSONNode.h:216
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
json_index_t size(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:328

Here is the call graph for this function:

unsigned char internalJSONNode::type ( void  ) const
inline

Referenced by Fetch(), JSONNode::write(), and JSONNode::write_formatted().

340  {
341  return _type;
342 }

Here is the caller graph for this function:

unsigned char internalJSONNode::type ( void  ) const
void internalJSONNode::Write ( unsigned int  indent,
bool  arrayChild,
json_string &  output 
) const
void internalJSONNode::Write ( unsigned int  indent,
bool  arrayChild,
json_string &  output 
) const

References JSON_ARRAY, JSON_ASSERT, JSON_BOOL, json_likely, JSON_NODE, JSON_NULL, JSON_NUMBER, JSON_STRING, JSON_TEXT, JSONWorker::UnfixString(), and used_ascii_one.

Referenced by JSONNode::write(), and JSONNode::write_formatted().

181  {
182  const bool formatted = indent != 0xFFFFFFFF;
183  WriteComment(indent, output);
184 
185  #if !defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)
186  if (!(formatted || fetched)){ //It's not formatted or fetched, just do a raw dump
187  WriteName(false, arrayChild, output);
188  //first remove the \1 characters
189  if (used_ascii_one){ //if it hasn't been used yet, don't bother checking
190  json_string result(_string.begin(), _string.end());
191  for(json_string::iterator beg = result.begin(), en = result.end(); beg != en; ++beg){
192  if (*beg == JSON_TEXT('\1')) *beg = JSON_TEXT('\"');
193  }
194  output += result;
195  return;
196  }
197  output.append(_string.begin(), _string.end());
198  return;
199  }
200  #endif
201 
202  WriteName(formatted, arrayChild, output);
203  //It's either formatted or fetched
204  switch (_type){
205  case JSON_NODE: //got members, write the members
206  Fetch();
207  output += JSON_TEXT("{");
208  WriteChildren(indent, output);
209  output += JSON_TEXT("}");
210  return;
211  case JSON_ARRAY: //write out the child nodes int he array
212  Fetch();
213  output += JSON_TEXT("[");
214  #ifdef JSON_ARRAY_SIZE_ON_ONE_LINE
215  if (size() <= JSON_ARRAY_SIZE_ON_ONE_LINE){
216  WriteChildrenOneLine(indent, output);
217  } else {
218  #endif
219  WriteChildren(indent, output);
220  #ifdef JSON_ARRAY_SIZE_ON_ONE_LINE
221  }
222  #endif
223  output += JSON_TEXT("]");
224  return;
225  case JSON_NUMBER: //write out a literal, without quotes
226  case JSON_NULL:
227  case JSON_BOOL:
228  output.append(_string.begin(), _string.end());
229  return;
230  }
231 
232  JSON_ASSERT(_type == JSON_STRING, JSON_TEXT("Unknown json node type"));
233  //If it go here, then it's a json_string
234  #if !defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)
235  if (json_likely(fetched)){
236  #endif
237  output += JSON_TEXT("\"");
238  JSONWorker::UnfixString(_string, _string_encoded, output); //It's already been fetched, meaning that it's unescaped
239  output += JSON_TEXT("\"");
240  #if !defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)
241  } else {
242  output.append(_string.begin(), _string.end()); //it hasn't yet been fetched, so it's already unescaped, just do a dump
243  }
244  #endif
245 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
static void UnfixString(const json_string &value_t, bool flag, json_string &res) json_nothrow
Definition: JSONWorker.cpp:541
void WriteComment(unsigned int indent, json_string &output) const json_nothrow json_write_priority
Definition: JSONWriter.cpp:127
#define JSON_BOOL
Definition: JSONDefs.h:24
json_string _string
Definition: internalJSONNode.h:268
bool used_ascii_one
Definition: JSONWorker.cpp:3
void WriteChildren(unsigned int indent, json_string &output) const json_nothrow json_write_priority
Definition: JSONWriter.cpp:78
void Fetch(void) const json_nothrow json_hot
Definition: internalJSONNode.cpp:251
#define JSON_NODE
Definition: JSONDefs.h:26
#define JSON_NULL
Definition: JSONDefs.h:21
#define JSON_ASSERT(condition, msg)
Definition: JSONDebug.h:53
#define JSON_STRING
Definition: JSONDefs.h:22
json_index_t size(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:328
#define json_likely(x)
Definition: Unknown_C.h:16
#define JSON_NUMBER
Definition: JSONDefs.h:23
void WriteName(bool formatted, bool arrayChild, json_string &output) const json_nothrow json_write_priority
Definition: JSONWriter.cpp:70
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

Here is the caller graph for this function:

void internalJSONNode::WriteChildren ( unsigned int  indent,
json_string &  output 
) const

References CHILDREN, JSON_ARRAY, json_global, json_likely, JSON_TEXT, and makeIndent().

78  {
79  //Iterate through the children and write them
80  if (json_likely(CHILDREN -> empty())) return;
81 
82  json_string indent_plus_one;
83  //handle whether or not it's formatted JSON
84  if (indent != 0xFFFFFFFF){ //it's formatted, make the indentation strings
85  indent_plus_one = json_global(NEW_LINE) + makeIndent(++indent);
86  }
87 
88  //else it's not formatted, leave the indentation strings empty
89  const size_t size_minus_one = CHILDREN -> size() - 1;
90  size_t i = 0;
91  JSONNode ** it = CHILDREN -> begin();
92  for(JSONNode ** it_end = CHILDREN -> end(); it != it_end; ++it, ++i){
93 
94  output += indent_plus_one;
95  (*it) -> internal -> Write(indent, type() == JSON_ARRAY, output);
96  if (json_likely(i < size_minus_one)) output += JSON_TEXT(','); //the last one does not get a comma, but all of the others do
97  }
98  if (indent != 0xFFFFFFFF){
99  output += json_global(NEW_LINE);
100  output += makeIndent(indent - 1);
101  }
102 }
JSONNode ** end(void) const json_nothrow
Definition: internalJSONNode.h:429
JSONNode ** begin(void) const json_nothrow
Definition: internalJSONNode.h:423
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
void Write(unsigned int indent, bool arrayChild, json_string &output) const json_nothrow json_write_priority
Definition: JSONWriter.cpp:181
unsigned char type(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:340
jsonChildren * CHILDREN
Definition: internalJSONNode.h:298
json_string makeIndent(unsigned int amount) json_nothrow
Definition: JSONWriter.cpp:21
#define json_global(NAME)
Definition: JSONGlobals.h:26
Definition: JSONNode.h:132
bool empty(void) const json_nothrow
Definition: internalJSONNode.h:334
json_index_t size(void) const json_nothrow json_read_priority
Definition: internalJSONNode.h:328
#define json_likely(x)
Definition: Unknown_C.h:16
#define JSON_ARRAY
Definition: JSONDefs.h:25

Here is the call graph for this function:

void internalJSONNode::WriteChildren ( unsigned int  indent,
json_string &  output 
) const
void internalJSONNode::WriteComment ( unsigned int  indent,
json_string &  output 
) const
void internalJSONNode::WriteComment ( unsigned int  indent,
json_string &  output 
) const

References json_global, json_likely, JSON_TEXT, json_unlikely, and makeIndent().

127  {
128  if (indent == 0xFFFFFFFF) return;
129  if (json_likely(_comment.empty())) return;
130  size_t pos = _comment.find(JSON_TEXT('\n'));
131 
132  const json_string current_indent(json_global(NEW_LINE) + makeIndent(indent));
133 
134  if (json_likely(pos == json_string::npos)){ //Single line comment
135  output += current_indent;
136  output += json_global(SINGLELINE_COMMENT);
137  output.append(_comment.begin(), _comment.end());
138  output += current_indent;
139  return;
140  }
141 
142  /*
143  Multiline comments
144  */
145  output += current_indent;
146  #if !(defined(JSON_WRITE_BASH_COMMENTS) || defined(JSON_WRITE_SINGLE_LINE_COMMENTS))
147  const json_string current_indent_plus_one(json_global(NEW_LINE) + makeIndent(indent + 1));
148  output += JSON_TEXT("/*");
149  output += current_indent_plus_one;
150  #endif
151  size_t old = 0;
152  while(pos != json_string::npos){
153  if (json_unlikely(pos && _comment[pos - 1] == JSON_TEXT('\r'))) --pos;
154  #if defined(JSON_WRITE_BASH_COMMENTS) || defined(JSON_WRITE_SINGLE_LINE_COMMENTS)
155  output += json_global(SINGLELINE_COMMENT);
156  #endif
157  output.append(_comment.begin() + old, _comment.begin() + pos);
158 
159  #if defined(JSON_WRITE_BASH_COMMENTS) || defined(JSON_WRITE_SINGLE_LINE_COMMENTS)
160  output += current_indent;
161  #else
162  output += current_indent_plus_one;
163  #endif
164  old = (_comment[pos] == JSON_TEXT('\r')) ? pos + 2 : pos + 1;
165  pos = _comment.find(JSON_TEXT('\n'), old);
166  }
167  #if defined(JSON_WRITE_BASH_COMMENTS) || defined(JSON_WRITE_SINGLE_LINE_COMMENTS)
168  output += json_global(SINGLELINE_COMMENT);
169  #endif
170  output.append(_comment.begin() + old, _comment.end());
171  output += current_indent;
172  #if !(defined(JSON_WRITE_BASH_COMMENTS) || defined(JSON_WRITE_SINGLE_LINE_COMMENTS))
173  output += JSON_TEXT("*/");
174  output += current_indent;
175  #endif
176  }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
#define json_unlikely(x)
Definition: Unknown_C.h:17
json_string makeIndent(unsigned int amount) json_nothrow
Definition: JSONWriter.cpp:21
#define json_global(NAME)
Definition: JSONGlobals.h:26
json_string _comment
Definition: internalJSONNode.h:294
#define json_likely(x)
Definition: Unknown_C.h:16

Here is the call graph for this function:

void internalJSONNode::WriteName ( bool  formatted,
bool  arrayChild,
json_string &  output 
) const

References JSON_TEXT, and JSONWorker::UnfixString().

70  {
71  if (!arrayChild){
72  output += JSON_TEXT("\"");
73  JSONWorker::UnfixString(_name, _name_encoded, output);
74  output += ((formatted) ? JSON_TEXT("\" : ") : JSON_TEXT("\":"));
75  }
76 }
#define JSON_TEXT(s)
Definition: Strings_Defs.h:30
static void UnfixString(const json_string &value_t, bool flag, json_string &res) json_nothrow
Definition: JSONWorker.cpp:541
json_string _name
Definition: internalJSONNode.h:265

Here is the call graph for this function:

void internalJSONNode::WriteName ( bool  formatted,
bool  arrayChild,
json_string &  output 
) const

Member Data Documentation

json_string internalJSONNode::_comment

Referenced by getcomment().

json_string internalJSONNode::_name

Referenced by clearname(), and name().

json_string internalJSONNode::_string
mutable
value_union_t internalJSONNode::_value
mutable

Referenced by FetchNumber().

jsonChildren * internalJSONNode::CHILDREN

Referenced by begin(), empty(), end(), preparse(), and size().


The documentation for this class was generated from the following files: