Version: 0.6.0

The JSON value class implementation. More...

Collaboration diagram for wxJSONValue:

Public Member Functions

 wxJSONValue ()
 Constructors. More...
 
 wxJSONValue (wxJSONType type)
 
 wxJSONValue (int i)
 
 wxJSONValue (unsigned int i)
 
 wxJSONValue (short i)
 
 wxJSONValue (unsigned short i)
 
 wxJSONValue (long int i)
 
 wxJSONValue (unsigned long int i)
 
 wxJSONValue (bool b)
 
 wxJSONValue (double d)
 
 wxJSONValue (const wxChar *str)
 
 wxJSONValue (const wxString &str)
 
 wxJSONValue (const wxMemoryBuffer &buff)
 Construct a JSON value object of type memory buffer. More...
 
 wxJSONValue (const void *buff, size_t len)
 Construct a JSON value object of type memory buffer. More...
 
 wxJSONValue (const wxJSONValue &other)
 Copy constructor. More...
 
virtual ~wxJSONValue ()
 Dtor - calls UnRef().
 
wxJSONType GetType () const
 Return the type of the value stored in the object. More...
 
bool IsValid () const
 Return TRUE if the value stored is valid. More...
 
bool IsNull () const
 Return TRUE if the type of the value is wxJSONTYPE_NULL.
 
bool IsInt () const
 Return TRUE if the type of the value stored is integer. More...
 
bool IsUInt () const
 Return TRUE if the type of the value stored is a unsigned int. More...
 
bool IsShort () const
 Return TRUE if the type of the value stored is 16-bit integer. More...
 
bool IsUShort () const
 Return TRUE if the type of the value stored is a unsigned short. More...
 
bool IsLong () const
 Return TRUE if the stored value is an integer which fits in a long int. More...
 
bool IsULong () const
 Return TRUE if the stored value is an integer which fits in a unsigned long int. More...
 
bool IsBool () const
 Return TRUE if the type of the value stored is a boolean.
 
bool IsDouble () const
 Return TRUE if the type of the value stored is a double.
 
bool IsString () const
 Return TRUE if the type of the value stored is a wxString object.
 
bool IsCString () const
 Return TRUE if the type of the value stored is a pointer to a static C string. More...
 
bool IsArray () const
 Return TRUE if the type of the value stored is an array type.
 
bool IsObject () const
 Return TRUE if the type of this value is a key/value map.
 
bool IsMemoryBuff () const
 Return TRUE if the type of this value is a binary memory buffer.
 
int AsInt () const
 Return the stored value as an integer. More...
 
unsigned int AsUInt () const
 Return the stored value as a unsigned int. More...
 
short AsShort () const
 Returns the value as a short integer. More...
 
unsigned short AsUShort () const
 Returns the value as a unsigned short integer. More...
 
long int AsLong () const
 Returns the value as a long integer. More...
 
unsigned long AsULong () const
 Returns the value as a unsigned long integer. More...
 
bool AsInt (int &i) const
 Stores the value of this object in the provided argument. More...
 
bool AsUInt (unsigned int &ui) const
 
bool AsShort (short int &s) const
 
bool AsUShort (unsigned short &us) const
 
bool AsLong (long int &l) const
 
bool AsULong (unsigned long &ul) const
 
bool AsBool () const
 Return the stored value as a boolean. More...
 
double AsDouble () const
 Return the stored value as a double. More...
 
wxString AsString () const
 Return the stored value as a wxWidget's string. More...
 
const wxChar * AsCString () const
 Return the stored value as a pointer to a static C string. More...
 
bool AsBool (bool &b) const
 
bool AsDouble (double &d) const
 
bool AsString (wxString &str) const
 Return this string value in the provided argument. More...
 
bool AsCString (wxChar *ch) const
 
wxMemoryBuffer AsMemoryBuff () const
 Returns the value as a memory buffer. More...
 
bool AsMemoryBuff (wxMemoryBuffer &buff) const
 Returns the value as a memory buffer. More...
 
const wxJSONInternalMap * AsMap () const
 Return the stored value as a map object. More...
 
const wxJSONInternalArray * AsArray () const
 Return the stored value as an array object. More...
 
bool HasMember (unsigned index) const
 Return TRUE if the object contains an element at the specified index. More...
 
bool HasMember (const wxString &key) const
 Return TRUE if the object contains an element at the specified key. More...
 
int Size () const
 Return the size of the array or map stored in this value. More...
 
wxArrayString GetMemberNames () const
 Return the array of keys of this JSON object. More...
 
wxJSONValueAppend (const wxJSONValue &value)
 Append the specified value in the array. More...
 
wxJSONValueAppend (bool b)
 
wxJSONValueAppend (int i)
 
wxJSONValueAppend (unsigned int ui)
 
wxJSONValueAppend (short int i)
 
wxJSONValueAppend (unsigned short int ui)
 
wxJSONValueAppend (long int l)
 
wxJSONValueAppend (unsigned long int ul)
 
wxJSONValueAppend (double d)
 
wxJSONValueAppend (const wxChar *str)
 
wxJSONValueAppend (const wxString &str)
 
wxJSONValueAppend (const wxMemoryBuffer &buff)
 
wxJSONValueAppend (const void *buff, size_t len)
 
bool Remove (int index)
 Remove the item at the specified index or key. More...
 
bool Remove (const wxString &key)
 
void Clear ()
 Clear the object value. More...
 
bool Cat (const wxChar *str)
 
bool Cat (const wxString &str)
 Concatenate a string to this string object. More...
 
bool Cat (const wxMemoryBuffer &buff)
 Concatenate a memory buffer to this memory buffer object. More...
 
wxJSONValueItem (unsigned index)
 Return the item at the specified index. More...
 
wxJSONValueItem (const wxString &key)
 Return the item at the specified key. More...
 
wxJSONValue ItemAt (unsigned index) const
 Return the item at the specified index. More...
 
wxJSONValue ItemAt (const wxString &key) const
 Return the item at the specified key. More...
 
wxJSONValueoperator[] (unsigned index)
 Return the item at the specified index. More...
 
wxJSONValueoperator[] (const wxString &key)
 Return the item at the specified key. More...
 
wxJSONValue operator[] (unsigned index) const
 
wxJSONValue operator[] (const wxString &key) const
 
wxJSONValueoperator= (int i)
 Assign the specified value to this object replacing the old value. More...
 
wxJSONValueoperator= (unsigned int ui)
 
wxJSONValueoperator= (short int i)
 
wxJSONValueoperator= (unsigned short int ui)
 
wxJSONValueoperator= (long int l)
 
wxJSONValueoperator= (unsigned long int ul)
 
wxJSONValueoperator= (bool b)
 
wxJSONValueoperator= (double d)
 
wxJSONValueoperator= (const wxChar *str)
 
wxJSONValueoperator= (const wxString &str)
 
wxJSONValueoperator= (const wxMemoryBuffer &buff)
 Assigns to this object a memory buffer type. More...
 
wxJSONValueoperator= (const wxJSONValue &value)
 Assignment operator using reference counting. More...
 
wxJSONValue Get (const wxString &key, const wxJSONValue &defaultValue) const
 Return a value or a default value. More...
 
bool IsSameAs (const wxJSONValue &other) const
 The comparison function. More...
 
int AddComment (const wxString &str, int position=wxJSONVALUE_COMMENT_DEFAULT)
 Add a comment to this JSON value object. More...
 
int AddComment (const wxArrayString &comments, int position=wxJSONVALUE_COMMENT_DEFAULT)
 Add one or more comments to this JSON value object. More...
 
wxString GetComment (int idx=-1) const
 Return a comment string. More...
 
int GetCommentPos () const
 Return the comment position.
 
int GetCommentCount () const
 Return the number of comment strings.
 
void ClearComments ()
 Clear all comment strings.
 
const wxArrayString & GetCommentArray () const
 Get the comment string's array.
 
wxString GetInfo () const
 Returns informations about the object. More...
 
wxString Dump (bool deep=false, int mode=0) const
 Returns informations about the object. More...
 
wxJSONRefDataGetRefData () const
 Return the pointer to the referenced data structure.
 
wxJSONRefDataSetType (wxJSONType type)
 Set the type of the stored value. More...
 
int GetLineNo () const
 Return the line number of this JSON value object. More...
 
void SetLineNo (int num)
 Set the line number of this JSON value object.
 
void UnShare ()
 Makes an exclusive copy of shared data.
 

Static Public Member Functions

static wxString TypeToString (wxJSONType type)
 Return a string description of the type. More...
 
static wxString MemoryBuffToString (const wxMemoryBuffer &buff, size_t len=-1)
 Convert memory buffer object to a string representation.
 
static wxString MemoryBuffToString (const void *buff, size_t len, size_t actualLen=-1)
 Convert a binary memory buffer to a string representation.
 
static int CompareMemoryBuff (const wxMemoryBuffer &buff1, const wxMemoryBuffer &buff2)
 Compares two memory buffer objects. More...
 
static int CompareMemoryBuff (const wxMemoryBuffer &buff1, const void *buff2)
 Compares a memory buffer object and a memory buffer. More...
 
static wxMemoryBuffer ArrayToMemoryBuff (const wxJSONValue &value)
 Converts an array of INTs to a memory buffer. More...
 

Protected Member Functions

wxJSONValueFind (unsigned index) const
 Find an element. More...
 
wxJSONValueFind (const wxString &key) const
 Find an element. More...
 
void DeepCopy (const wxJSONValue &other)
 Do a deep copy of the other object. More...
 
wxJSONRefDataInit (wxJSONType type)
 Initialize the JSON value class. More...
 
wxJSONRefDataCOW ()
 Make sure the referenced data is unique. More...
 
virtual wxJSONRefDataCloneRefData (const wxJSONRefData *data) const
 Make a copy of the referenced data. More...
 
virtual wxJSONRefDataCreateRefData () const
 Create a new data structure. More...
 
void SetRefData (wxJSONRefData *data)
 Set the pointer to the referenced data.
 
void Ref (const wxJSONValue &clone)
 Increments the referenced data counter.
 
void UnRef ()
 Unreferences the shared data. More...
 
void AllocExclusive ()
 Makes a private copy of the referenced data.
 

Protected Attributes

wxJSONRefDatam_refData
 the referenced data
 

Friends

class wxJSONReader
 

Detailed Description

The JSON value class implementation.

This class holds a JSON value which may be of variuos types (see the wxJSONType constants for a description of the types). To know more about the internal representation of JSON values see pg_json_internals.

Starting from version 0.5 the wxJSON library supports 64-bits integers on platforms that have native support for very large integers. Note that the integer type is still stored as a generic wxJSONTYPE_(U)INT constant regardless the size of the value but the JSON value class defines functions in order to let the user know if an integer value fits in 16, 32 or 64 bit integer. To know more about 64-bits integer support see json_internals_integer

Storing values in a JSON value object of this class is very simple. The following is an example:

wxJSONValue v( _T( "A string")); // store a string value in the object
wxString s = v.AsString(); // get the string value
v = 12; // now 'v' contains an integer value
int i = v.AsInt(); // get the integer
The C-string JSON value object

The wxJSONValue(const wxChar*) ctor allows you to create a JSON value object that contains a string value which is stored as a pointer-to-static-string. Beware that this ctor DOES NOT copy the string: it only stores the pointer in a data member and the pointed-to buffer is not deleted by the dtor. If the string is not static you have to use the wxJSONValue(const wxString&) constructor.

Also note that this does NOT mean that the value stored in this JSON object cannot change: you can assign whatever other value you want, an integer, a double or an array of values. What I intended is that the pointed-to string must exist for the lifetime of the wxJSONValue object. The following code is perfectly legal:

wxJSONvalue aString( "this is a static string" );
aString = 10;

To know more about this topic see json_internals_cstring.

Starting from version 1.3 the class can hold binary memory buffers as an extension to the JSON syntax. Memory buffers are stored as wxMemoryBuffer objects which contain binary data. The class uses reference counting for the copy and assignment operation but it is not a copy-on-write structure. To know more about memory buffers read wxjson_tutorial_memorybuff

See Also
the wxjson_tutorial.

Constructor & Destructor Documentation

wxJSONValue::wxJSONValue ( )

Constructors.

The overloaded constructors allow the user to construct a JSON value object that holds the specified value and type of value. The default ctor construct a valid JSON object that constains a null value.

If you want to create an invalid JSON value object you have to use the wxJSONValue( wxJSONTYPE_INVALID ) ctor. Note that this object is not a valid JSON value - to know more about this topic see the SetType() function.

To create an empty array or key/value map use the following:

wxJSONvalue v1( wxJSONTYPE_ARRAY );
wxJSONvalue v2( wxJSONTYPE_OBJECT );

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( wxJSONType  type)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( int  i)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( unsigned int  ui)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( unsigned short  ui)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( long int  l)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( unsigned long int  ul)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( bool  b)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( double  d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( const wxChar *  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( const wxString &  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( const wxMemoryBuffer &  buff)

Construct a JSON value object of type memory buffer.

Note that this ctor makes a deep copy of buff so changes made to the original buffer does not reflect to the buffer stored in this JSON value.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( const void *  buff,
size_t  len 
)

Construct a JSON value object of type memory buffer.

Note that this ctor makes a deep copy of buff so changes made to the original buffer does not reflect to the buffer stored in this JSON value.

Here is the call graph for this function:

wxJSONValue::wxJSONValue ( const wxJSONValue other)

Copy constructor.

The function copies the content of other in this object. Note that the JSON value object is not really copied; the function calls Ref() in order to increment the reference count of the wxJSONRefData structure.

Here is the call graph for this function:

Member Function Documentation

int wxJSONValue::AddComment ( const wxString &  str,
int  position = wxJSONVALUE_COMMENT_DEFAULT 
)

Add a comment to this JSON value object.

The function adds a comment string to this JSON value object and returns the total number of comment strings belonging to this value. Note that the comment string must be a valid C/C++ comment because the wxJSONWriter does not modify it. In other words, a C++ comment string must start with '//' and must end with a new-line character. If the final LF char is missing, the automatically adds it. You can also add C-style comments which must be enclosed in the usual C-comment characters. For C-style comments, the function does not try to append the final comment characters but allows trailing whitespaces and new-line chars. The position parameter is one of:

  • wxJSONVALUE_COMMENT_BEFORE: the comment will be written before the value
  • wxJSONVALUE_COMMENT_INLINE: the comment will be written on the same line
  • wxJSONVALUE_COMMENT_AFTER: the comment will be written after the value
  • wxJSONVALUE_COMMENT_DEFAULT: the old value of comment's position is not changed; if no comments were added to the value object this is the same as wxJSONVALUE_COMMENT_BEFORE.

To know more about comment's storage see json_comment_add

Here is the call graph for this function:

Here is the caller graph for this function:

int wxJSONValue::AddComment ( const wxArrayString &  comments,
int  position = wxJSONVALUE_COMMENT_DEFAULT 
)

Add one or more comments to this JSON value object.

The function adds the strings contained in comments to the comment's string array of this value object by calling the AddComment( const wxString&,int) function for every string in the comment array. Returns the number of strings correctly added.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( const wxJSONValue value)

Append the specified value in the array.

The function appends the value specified in the parameter to the array contained in this object. If this object does not contain an array type, the actual content is deleted, a new array type is created and the JSON value value is appended to the newly created array. Returns a reference to the appended object.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONValue & wxJSONValue::Append ( bool  b)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( int  i)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( unsigned int  ui)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( short int  i)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( long int  l)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( double  d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( const wxChar *  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( const wxString &  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( const wxMemoryBuffer &  buff)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::Append ( const void *  buff,
size_t  len 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxMemoryBuffer wxJSONValue::ArrayToMemoryBuff ( const wxJSONValue value)
static

Converts an array of INTs to a memory buffer.

This static function converts an array of INTs stored in a wxJSONvalue object into a memory buffer object. The wxJSONvalue object passed as parameter must be of type ARRAY and must contain INT types whose values are between 0 and 255.

Every element of the array si converted to a BYTE value and appended to the returned wxMemoryBuffer object. The following rules apply in the conversion:

  • if value is not an ARRAY type, an empty memory buffer is returned
  • if the value array contains elements of type other than INT, those elements are ignored
  • if the value array contains elements of type INT which value is outside the range 0..255, those elements are ignored
  • if the value array contains only ignored elements an empty wxMemoryBuffer object is returned.

This function can be used to get a memory buffer object from valid JSON text. Please note that the wxJSONReader cannot know which array of INTs represent a binary memory buffer unless you use the wxJSON memory buffer extension in the writer and in the reader.

Here is the call graph for this function:

const wxJSONInternalArray * wxJSONValue::AsArray ( ) const

Return the stored value as an array object.

This function is for testing and debugging purposes and you shold never use it. To retreive values from an array or map JSON object use the Item() or ItemAt() memberfunctions or the subscript operator. If the stored value is not an array type, returns a NULL pointer.

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::AsBool ( ) const

Return the stored value as a boolean.

The function returns the stored value as a boolean. Note that the function does not check that the type of the value is actually a boolean and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value is wxJSONTYPE_BOOL.

See Also
wxjson_tutorial_get

Here is the call graph for this function:

const wxChar * wxJSONValue::AsCString ( ) const

Return the stored value as a pointer to a static C string.

If the type of the value is stored as a C-string data type the function just returns that pointer. If the stored value is a wxString object, the function returns the pointer returned by the wxString::c_str() function. If the stored value is of all other JSON types, the functions returns a NULL pointer.

Note that in versions prior to 0.5, the function returned a NULL pointer also if the value is a wxString object.

See Also
json_internals_cstring
wxjson_tutorial_get

Here is the call graph for this function:

double wxJSONValue::AsDouble ( ) const

Return the stored value as a double.

The function returns the stored value as a double. Note that the function does not check that the type of the value is actually a double and it just returns the content of the wxJSONValueHolder union as if it was a double. However, in debug builds, the function ASSERTs that the type of the stored value IsDouble().

See Also
wxjson_tutorial_get

Here is the call graph for this function:

int wxJSONValue::AsInt ( ) const

Return the stored value as an integer.

The function returns the stored value as an integer. Note that the function does not check that the type of the value is actually an integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value IsInt().

See Also
json_internals_integer
wxjson_tutorial_get

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::AsInt ( int &  i) const

Stores the value of this object in the provided argument.

The functions of the form AsXxxxxx(T&) are the same as the AsXxxxxxx() but store the value in the provided argument and return TRUE if the value of this object is of the correct type. By using these functions you can get the value and test if the JSON value is of the expected type in only one step. For example:

int i; wxJSONValue v(10);
if ( !v.AsInt( i )) {
cout << "Error: value is not of the expected type";
}

This is the same as:

int i; wxJSONValue v(10);
if ( v.IsInt() {
i = v.AsInt();
}
else {
cout << "Error: value is not of the expected type";
}

Thanks to catalin who has suggested this new feature.

Here is the call graph for this function:

long int wxJSONValue::AsLong ( ) const

Returns the value as a long integer.

The function returns the stored value as a long integer. Note that the function does not check that the type of the value is actually a long integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value IsLong().

See Also
json_internals_integer
wxjson_tutorial_get

Here is the call graph for this function:

Here is the caller graph for this function:

const wxJSONInternalMap * wxJSONValue::AsMap ( ) const

Return the stored value as a map object.

This function is for testing and debugging purposes and you shold never use it. To retreive values from an array or map JSON object use the Item() or ItemAt() memberfunctions or the subscript operator. If the stored value is not a map type, returns a NULL pointer.

Here is the call graph for this function:

Here is the caller graph for this function:

wxMemoryBuffer wxJSONValue::AsMemoryBuff ( ) const

Returns the value as a memory buffer.

The function returns the memory buffer object stored in this JSON object. Note that as of wxWidgets 2.8 and 2.9 the wxMemoryBuffer object uses reference counting when copying the actual buffer but the class itself is not a copy-on-write structure so changes made to one buffer affects all other copies made from it. This means that if you make a change to the returned copy of the memory buffer, the change affects also the memory buffer stored in this JSON value.

If this JSON object does not contain a wxJSONTYPE_MEMORYBUFF type the function returns an empty memory buffer object. An empty memory buffer is also returned if this JSON type contains a valid, empty memory buffer. You have to use the IsMemoryBuff() function to known the type of the JSON value contained in this object, or the overloaded version of this function.

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::AsMemoryBuff ( wxMemoryBuffer &  buff) const

Returns the value as a memory buffer.

The function returns the memory buffer object stored in this JSON object. Note that as of wxWidgets 2.8 and 2.9 the wxMemoryBuffer object uses reference counting when copying the actual buffer but the class itself is not a copy-on-write structure so changes made to one buffer affects all other copies made from it. This means that if you make a change to the returned copy of the memory buffer, the change affects also the memory buffer stored in this JSON value.

If this JSON object does not contain a wxJSONTYPE_MEMORYBUFF type the function returns an empty memory buffer object. An empty memory buffer is also returned if this JSON type contains a valid, empty memory buffer. You have to use the IsMemoryBuff() function to known the type of the JSON value contained in this object, or the overloaded version of this function.

Here is the call graph for this function:

short int wxJSONValue::AsShort ( ) const

Returns the value as a short integer.

The function returns the stored value as a short integer. Note that the function does not check that the type of the value is actually a short integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value IsShort().

See Also
json_internals_integer
wxjson_tutorial_get

Here is the call graph for this function:

Here is the caller graph for this function:

wxString wxJSONValue::AsString ( ) const

Return the stored value as a wxWidget's string.

The function returns a string representation of the value stored in the JSON object. All value types are converted to a string by this function and returned as a string:

  • For integer the string is the string representation of the numerical value in decimal notation; the function uses the wxString::Printf() function for the conversion
  • for doubles, the value is converted to a string using the wxString::Printf("%.10g") function; the format string specifies a precision of ten decimal digits and suppress trailing ZEROes
  • for booleans the string returned is: true or false.
  • if the value is a NULL value the null literal string is returned.
  • if the value is of type wxJSONTYPE_INVALID, the literal string <invalid> is returned. Note that this is NOT a valid JSON text.
  • if the value is of type wxJSONTYPE_MEMORYBUFF the string returned contains the hexadecimal digits of the first 5 bytes preceeded by the length of the buffer, enclosed in parenthesis

If the value is an array or map, the returned string is the number of elements is the array/object enclosed in the JSON special characters that identifies the array/object. Example:

[0] // an empty array
{12} // an object of 12 elements
See Also
wxjson_tutorial_get

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::AsString ( wxString &  str) const

Return this string value in the provided argument.

This function is different from AsString because the latter always returns a string also when this object does not contain a string. In that case, a string representation of this value is returned. This function, instead, returns TRUE only if this object contains a string, that is only if IsString() returns TRUE. Also note that the string value is only stored in str if this object actually contains a string or c-string value. str will never contain a string representation of other types.

Here is the call graph for this function:

unsigned int wxJSONValue::AsUInt ( ) const

Return the stored value as a unsigned int.

The function returns the stored value as a unsigned integer. Note that the function does not check that the type of the value is actually a unsigned integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value is wxJSONTYPE_UINT.

See Also
json_internals_integer
wxjson_tutorial_get

Here is the call graph for this function:

unsigned long int wxJSONValue::AsULong ( ) const

Returns the value as a unsigned long integer.

The function returns the stored value as a unsigned long integer. Note that the function does not check that the type of the value is actually a unsigned long integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value IsLong().

See Also
json_internals_integer
wxjson_tutorial_get

Here is the call graph for this function:

unsigned short wxJSONValue::AsUShort ( ) const

Returns the value as a unsigned short integer.

The function returns the stored value as a unsigned short integer. Note that the function does not check that the type of the value is actually a unsigned short and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value IsUShort().

See Also
json_internals_integer
wxjson_tutorial_get

Here is the call graph for this function:

bool wxJSONValue::Cat ( const wxChar *  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::Cat ( const wxString &  str)

Concatenate a string to this string object.

The function concatenates str to the string contained in this object and returns TRUE if the operation is succefull. If the value stored in this value is not a string object the function does nothing and returns FALSE. Note that in order to be successfull, the value must contain a wxString object and not a pointer to C-string.

Here is the call graph for this function:

bool wxJSONValue::Cat ( const wxMemoryBuffer &  buff)

Concatenate a memory buffer to this memory buffer object.

The function concatenates buff to the wxMemoryBuffer object contained in this object and returns TRUE if the operation is succefull. If the value stored in this value is not a memory buffer object the function does nothing and returns FALSE.

Here is the call graph for this function:

void wxJSONValue::Clear ( void  )

Clear the object value.

This function causes the object to be empty. The function simply calls UnRef() making this object to become invalid and set its type to wxJSONTYPE_INVALID.

Here is the call graph for this function:

wxJSONRefData * wxJSONValue::CloneRefData ( const wxJSONRefData otherData) const
protectedvirtual

Make a copy of the referenced data.

The function allocates a new instance of the wxJSONRefData structure, copies the content of other and returns the pointer to the newly created structure. This function is called by the wxObject::UnRef() function when a non-const member function is called on multiple referenced data.

Here is the caller graph for this function:

int wxJSONValue::CompareMemoryBuff ( const wxMemoryBuffer &  buff1,
const wxMemoryBuffer &  buff2 
)
static

Compares two memory buffer objects.

The function is the counterpart of the comparison operator == for two wxMemoryBuffer objects. You may noticed that the wxMemoryBuffer class does not define comparison operators so if you write a code snippset like the following:

wxMemoryBuffer b1;
wxMemoryBuffer b2;
b1.AppendData( "1234567890", 10 );
b2.AppendData( "1234567890", 10 );
bool r = b1 == b2;

you may expect that r is TRUE, because both objects contain the same data. This is not true. The result you get is FALSE because the default comparison operator is used, which just compares the data members of the class. The data member is the pointer to the allocated memory that contains the data and they are not equal. This function uses the (fast) memcmp function to compare the actual data contained in the nenory buffer objects thus doing a deep comparison. The function returns the return value of memcmp:

the memcmp() function returns an integer less than, equal to, or greater than zero if the first n bytes of buff1 is found, respectively, to be less than, to match, or be greater than the first n bytes of buff2.

Here is the caller graph for this function:

int wxJSONValue::CompareMemoryBuff ( const wxMemoryBuffer &  buff1,
const void *  buff2 
)
static

Compares a memory buffer object and a memory buffer.

The function compares the data contained in a memory buffer object with a memory buffer. This function uses the (fast) memcmp function to compare the actual data contained in the nenory buffer object thus doing a deep comparison. The function returns the return value of memcmp:

The memcmp() function returns an integer less than, equal to, or greater than zero if the first n bytes of buff1 is found, respectively, to be less than, to match, or be greater than the first n bytes of buff2.

wxJSONRefData * wxJSONValue::COW ( )
protected

Make sure the referenced data is unique.

This function is called by all non-const member functions and makes sure that the referenced data is unique by calling UnShare() If the referenced data is shared acrosss other wxJSONValue instances, the UnShare() function makes a private copy of the shared data.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONRefData * wxJSONValue::CreateRefData ( ) const
protectedvirtual

Create a new data structure.

The function allocates a new instance of the wxJSONRefData structure and returns its pointer. The type of the JSON value is set to wxJSONTYPE_INVALID (= a not initialized value).

Here is the caller graph for this function:

void wxJSONValue::DeepCopy ( const wxJSONValue other)
protected

Do a deep copy of the other object.

This function allocates a new ref-data structure and copies it from the object other.

Here is the call graph for this function:

wxString wxJSONValue::Dump ( bool  deep = false,
int  indent = 0 
) const

Returns informations about the object.

The function is only usefull for debugging purposes and will probably be dropped in future versions. Returns a string that contains info about the object such as:

  • the type of the object
  • the size
  • the progressive counter
  • the pointer to referenced data
  • the progressive counter of referenced data
  • the number of share of referenced data

The deep parameter is used to specify if the function will be called recursively in order to dump sub-items. If the parameter is TRUE than a deep dump is executed.

The indent is the initial indentation: it is incremented by 3 every time the Dump() function is called recursively.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONValue * wxJSONValue::Find ( unsigned  index) const
protected

Find an element.

The function returns a pointer to the element at index index or a NULL pointer if index does not exist. A NULL pointer is also returned if the object does not contain an array nor a key/value map.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONValue * wxJSONValue::Find ( const wxString &  key) const
protected

Find an element.

The function returns a pointer to the element with key key or a NULL pointer if key does not exist. A NULL pointer is also returned if the object does not contain a key/value map.

Here is the call graph for this function:

wxJSONValue wxJSONValue::Get ( const wxString &  key,
const wxJSONValue defaultValue 
) const

Return a value or a default value.

This function returns a copy of the value object for the specified key. If the key is not found, a copy of defaultValue is returned. Note that the returned values are not real copy of the key or the default values because copy-on-write is used by this class. However, you have to treat them as real copies; in other words, if you change the values of the returned object your changes does not reflect in the otiginal value. Example:

wxJSONValue defaultValue( 0 );
wxJSONvalue v1;
v1["key"] = 100; // 'v1["key"]' contains the integer 100
// 'v2' contains 100 but it is a swallow copy of 'v1["key"]'
wxJSONValue v2 = v1.Get( "key", defaultValue );
// 'v1["key"]' still contains 100
v2 = 200;
// if you want your change to be reflected in the 'v1' object
// you have to assign it
v1["key"] = v2;

Here is the call graph for this function:

Here is the caller graph for this function:

wxString wxJSONValue::GetComment ( int  idx = -1) const

Return a comment string.

The function returns the comment string at index idx. If idx is out of range, an empty string is returned. If idx is equal to -1, then the function returns a string that contains all comment's strings stored in the array.

Here is the call graph for this function:

wxString wxJSONValue::GetInfo ( ) const

Returns informations about the object.

The function is only usefull for debugging purposes and will probably be dropped in future versions. You should not rely on this function to exist in future versions.

Here is the call graph for this function:

Here is the caller graph for this function:

int wxJSONValue::GetLineNo ( ) const

Return the line number of this JSON value object.

The line number of a JSON value object is set to -1 when the object is constructed. The line number is set by the parser class, wxJSONReader, when a JSON text is read from a stream or a string. it is used when reading a comment line: comment lines that apear on the same line as a value are considered inline comments of the value.

Here is the call graph for this function:

Here is the caller graph for this function:

wxArrayString wxJSONValue::GetMemberNames ( ) const

Return the array of keys of this JSON object.

If the stored value is a key/value map, the function returns an array of strings containing the key of all elements. Note that the returned array may be empty if the map has ZERO elements. An empty string array is also returned if the stored value is not a key/value map. Also note that in debug builds, the function wxJSON_ASSERTs that the type of the stored object is wxJSONTYPE_OBJECT.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONType wxJSONValue::GetType ( void  ) const

Return the type of the value stored in the object.

This function is the only one that does not ASSERT that the m_refData data member is not NULL. In fact, if the JSON value object does not contain a pointer to a wxJSONRefData structure, the function returns the wxJSONTYPE_INVALID constant which represent an invalid JSON value object. Also note that the pointer to the referenced data structure should NEVER be NULL.

Integer types

Integers are stored internally in a signed/unsigned long int or, on platforms that support 64-bits integers, in a wx(U)Int64 data type. When constructed, it is assigned a generic integer type that only depends on the sign: wxJSON_(U)INT regardless the size of the stored value.

This function can be used to know the actual size requirement of the stored value and how it can be retrieved. The value returned by this function is:

  • for signed integers:
    • wxJSONTYPE_SHORT if the value is between SHORT_MIN and SHORT_MAX
    • wxJSONTYPE_LONG if the value is between LONG_MIN and LONG_MAX and greater than SHORT_MAX and less than SHORT_MIN
    • wxJSONTYPE_INT64 if the value is greater than LONG_MAX and less than LONG_MIN
  • for unsigned integers:
    • wxJSONTYPE_USHORT if the value is between 0 and USHORT_MAX
    • wxJSONTYPE_ULONG if the value is between 0 and ULONG_MAX and greater than USHORT_MAX
    • wxJSONTYPE_UINT64 if the value is greater than ULONG_MAX

Note that this function never returns the wxJSONTYPE_(U)INT constant because the int data type may have the same width as SHORT or LONG depending on the platform. This does not mean that you cannot use int as the return value: if you use wxWidgets to develop application in only one platform, you can use int because you know the size of the data type. Otherwise, if is preferable to always use long instead of int.

Also note that the class defines the IsInt() memberfunction which works fine regardless the actual width of the int data type. This function returns TRUE if the stored value fits in a int data type whatever its size is on the current platform (16 or 32-bits).

See Also
SetType IsInt

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::HasMember ( unsigned  index) const

Return TRUE if the object contains an element at the specified index.

If the stoerd value is not an array or a map, the function returns FALSE.

Here is the call graph for this function:

bool wxJSONValue::HasMember ( const wxString &  key) const

Return TRUE if the object contains an element at the specified key.

If the stored value is not a key/map map, the function returns FALSE.

Here is the call graph for this function:

wxJSONRefData * wxJSONValue::Init ( wxJSONType  type)
protected

Initialize the JSON value class.

The function is called by the ctors and allocates a new instance of the wxJSONRefData class and sets the type of the JSON value. Note that only the type is set, not the value. Also note that this function may be called from other memberfunctions if the m_refData data member is NULL.

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsCString ( ) const

Return TRUE if the type of the value stored is a pointer to a static C string.

This function returns TRUE if, and only if the stored value is a pointer to a static C-string and the C-string storage is enabled in the wxJSON library. By default, C-string storage is not enabled in the library so this function always returns FALSE. To know more about C-strings read json_internals_cstring

Here is the call graph for this function:

bool wxJSONValue::IsInt ( ) const

Return TRUE if the type of the value stored is integer.

This function returns TRUE if the stored value is of type signed integer and the numeric value fits in a int data type. In other words, the function returns TRUE if the wxJSONRefData::m_type data member is of type wxJSONTYPE_INT and:

INT_MIN <= m_value <= INT_MAX

Note that if you are developing cross-platform applications you should never use int as the integer data type but long for 32-bits integers and short for 16-bits integers. This is because the int data type may have different width on different platforms. Regardless the widht of the data type (16 or 32 bits), the function returns the correct result because it relies on the INT_MAX and INT_MIN macros.

See Also
json_internals_integer

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsLong ( ) const

Return TRUE if the stored value is an integer which fits in a long int.

This function returns TRUE if the stored value is of type signed LONG integer and the numeric value fits int a long int data type. In other words, the function returns TRUE if the wxJSONRefData::m_type data member is of type wxJSONTYPE_INT and:

LONG_MIN <= m_value <= LONG_MAX
See Also
json_internals_integer

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsSameAs ( const wxJSONValue other) const

The comparison function.

This function returns TRUE if this object looks like other. Note that this class does not define a comparison operator (the classical operator== function) because the notion of equal for JSON values objects is not applicable. The comment strings array are not compared: JSON value objects are the same if they contains the same values, regardless the comment's strings.

Note that the function does not return the element that cause the comparison to return FALSE. There is not a good structure to tell this information. If you need it for debugging purposes, you have to turn on the sameas tracing feature by setting the WXTRACE environment variable (you need a debug version of the application):

export WXTRACE=sameas // for unix systems that use bash

Note that if the two JSON value objects share the same referenced data, the function immediatly returns TRUE without doing a deep comparison which is, sure, useless. For further info see json_internals_compare.

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsShort ( ) const

Return TRUE if the type of the value stored is 16-bit integer.

This function returns TRUE if the stored value is of type signed integer and the numeric value fits in a short int data type (16-bit integer). In other words, the function returns TRUE if the wxJSONRefData::m_type data member is of type wxJSONTYPE_INT and:

SHORT_MIN <= m_value <= SHORT_MAX
See Also
json_internals_integer

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsUInt ( ) const

Return TRUE if the type of the value stored is a unsigned int.

This function returns TRUE if the stored value is of type unsigned integer and the numeric value fits int a int data type. In other words, the function returns TRUE if the wxJSONRefData::m_type data member is of type wxJSONTYPE_UINT and:

0 <= m_value <= UINT_MAX

Note that if you are developing cross-platform applications you should never use unsigned int as the integer data type but unsigned long for 32-bits integers and unsigned short for 16-bits integers. This is because the unsigned int data type may have different width on different platforms. Regardless the widht of the data type (16 or 32 bits), the function returns the correct result because it relies on the UINT_MAX macro.

See Also
json_internals_integer

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsULong ( ) const

Return TRUE if the stored value is an integer which fits in a unsigned long int.

This function returns TRUE if the stored value is of type unsigned LONG integer and the numeric value fits int a unsigned long int data type. In other words, the function returns TRUE if the wxJSONRefData::m_type data member is of type wxJSONTYPE_UINT and:

0 <= m_value <= ULONG_MAX
See Also
json_internals_integer

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsUShort ( ) const

Return TRUE if the type of the value stored is a unsigned short.

This function returns TRUE if the stored value is of type unsigned integer and the numeric value fits in a unsigned short int data type. In other words, the function returns TRUE if the wxJSONRefData::m_type data member is of type wxJSONTYPE_UINT and:

0 <= m_value <= USHORT_MAX
See Also
json_internals_integer

Here is the call graph for this function:

Here is the caller graph for this function:

bool wxJSONValue::IsValid ( void  ) const

Return TRUE if the value stored is valid.

The function returns TRUE if the wxJSONValue object was correctly initialized - that is it contains a valid value. A JSON object is valid if its type is not equal to wxJSONTYPE_INVALID. Please note that the default ctor of wxJSONValue constructs a valid JSON object of type null. To create an invalid object you have to use;

wxJSONValue v( wxJSONTYPE_INVALID );

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONValue & wxJSONValue::Item ( unsigned  index)

Return the item at the specified index.

The function returns a reference to the object at the specified index. If the element does not exist, the array is enlarged to index + 1 elements and a reference to the last element will be returned. New elements will contain NULL values. If this object does not contain an array, the old value is replaced by an array object which will be enlarged to the needed dimension.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONValue & wxJSONValue::Item ( const wxString &  key)

Return the item at the specified key.

The function returns a reference to the object in the map that has the specified key. If key does not exist, a new NULL value is created with the provided key and a reference to it is returned. If this object does not contain a map, the old value is replaced by a map object.

Here is the call graph for this function:

wxJSONValue wxJSONValue::ItemAt ( unsigned  index) const

Return the item at the specified index.

The function returns a copy of the object at the specified index. If the element does not exist, the function returns an invalid value.

Here is the call graph for this function:

Here is the caller graph for this function:

wxJSONValue wxJSONValue::ItemAt ( const wxString &  key) const

Return the item at the specified key.

The function returns a copy of the object in the map that has the specified key. If key does not exist, an invalid value is returned.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( int  i)

Assign the specified value to this object replacing the old value.

The assignment operator assigns to this object the value specified in the right operand of the assignment operator. Note that the old value is deleted but not the other data members in the wxJSONRefData structure. This is particularly usefull for the parser class which stores comment lines in a temporary wxJSONvalue object that is of type wxJSONTYPE_INVALID. As comment lines may apear before the value they refer to, comments are stored in a value that is not yet being read. when the value is read, it is assigned to the temporary JSON value object without deleting the comment lines.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( unsigned int  ui)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( bool  b)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( double  d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( const wxChar *  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( const wxString &  str)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( const wxMemoryBuffer &  buff)

Assigns to this object a memory buffer type.

As with the ctor, this function makes a deep copy of the memory buffer buff so changes made to the original buffer does not reflect to the memory buffer stored in this JSON value.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator= ( const wxJSONValue other)

Assignment operator using reference counting.

Unlike all other assignment operators, this one makes a swallow copy of the other JSON value object. The function calls Ref() to get a shared referenced data.

See Also
json_internals_cow

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator[] ( unsigned  index)

Return the item at the specified index.

The function returns a reference to the object at the specified index. If the element does not exist, the array is enlarged to index + 1 elements and a reference to the last element will be returned. New elements will contain NULL values. If this object does not contain an array, the old value is replaced by an array object.

Here is the call graph for this function:

wxJSONValue & wxJSONValue::operator[] ( const wxString &  key)

Return the item at the specified key.

The function returns a reference to the object in the map that has the specified key. If key does not exist, a new NULL value is created with the provided key and a reference to it is returned. If this object does not contain a map, the old value is replaced by a map object.

Here is the call graph for this function:

bool wxJSONValue::Remove ( int  index)

Remove the item at the specified index or key.

The function removes the item at index index or at the specified key in the array or map. If this object does not contain an array (for a index parameter) or a map (for a key parameter), the function does nothing and returns FALSE. If the element does not exist, FALSE is returned.

Here is the call graph for this function:

bool wxJSONValue::Remove ( const wxString &  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Here is the call graph for this function:

wxJSONRefData * wxJSONValue::SetType ( wxJSONType  type)

Set the type of the stored value.

The function sets the type of the stored value as specified in the provided argument. If the actual type is equal to type, nothing happens and this JSON value object retains the original type and value. If the type differs, however, the original type and value are lost.

The function just sets the type of the object and not the value itself. If the object does not have a data structure it is allocated using the CreateRefData() function unless the type to be set is wxJSONTYPE_INVALID. In this case and if a data structure is not yet allocated, it is not allocated.

If the object already contains a data structure it is not deleted but the type is changed in the original data structure. Complex values in the old structure are cleared. The type argument can be one of the following:

  • wxJSONTYPE_INVALID: an empty (not initialized) JSON value
  • wxJSONTYPE_NULL: a NULL value
  • wxJSONTYPE_INT: an integer value
  • wxJSONTYPE_UINT: an unsigned integer
  • wxJSONTYPE_DOUBLE: a double precision number
  • wxJSONTYPE_BOOL: a boolean
  • wxJSONTYPE_CSTRING: a C string
  • wxJSONTYPE_STRING: a wxString object
  • wxJSONTYPE_ARRAY: an array of wxJSONValue objects
  • wxJSONTYPE_OBJECT: a hashmap of key/value pairs where value is a wxJSONValue object
  • wxJSONTYPE_LONG: a 32-bits integer value
  • wxJSONTYPE_ULONG: an unsigned 32-bits integer
  • wxJSONTYPE_INT64: a 64-bits integer value
  • wxJSONTYPE_UINT64: an unsigned 64-bits integer
  • wxJSONTYPE_SHORT: a signed short integer
  • wxJSONTYPE_USHORT: an unsigned short integer
  • wxJSONTYPE_MEMORYBUFF: a binary memory buffer

The integer storage depends on the platform: for platforms that support 64-bits integers, integers are always stored as 64-bits integers. On platforms that do not support 64-bits integers, ints are stored as long int. To know more about the internal representation of integers, read json_internals_integer.

Note that there is no need to set a type for the object in order to assign a value to it. In other words, if you want to construct a JSON value which holds an integer value of 10, just use the specific constructor:

wxJSONValue value( 10 );

which sets the integer type and also the numeric value. Moreover, there is no need to set the type for none of the handled types, not only for primitive types but for complex types, too. For example, if you want to construct an array of JSON values, just use the default ctor and call the Append() member function which will append the first element to the array and will set the array type:

value.Append( "a string" );
See Also
GetType

Here is the call graph for this function:

Here is the caller graph for this function:

int wxJSONValue::Size ( ) const

Return the size of the array or map stored in this value.

Note that both the array and the key/value map may have a size of ZERO elements. If the stored value is not an array nor a key/value hashmap, the function returns -1.

Here is the call graph for this function:

Here is the caller graph for this function:

wxString wxJSONValue::TypeToString ( wxJSONType  type)
static

Return a string description of the type.

This static function is only usefull for debugging purposes and should not be used by users of this class. It simply returns a string representation of the JSON value type stored in a object. For example, if type is wxJSONTYPE_INT the function returns the string "wxJSONTYPE_INT". If type is out of range, an empty string is returned (should never happen).

Here is the caller graph for this function:

void wxJSONValue::UnRef ( )
protected

Unreferences the shared data.

The function decrements the number of shares in wxJSONRefData::m_refCount and if it is ZERO, deletes the referenced data. It is called by the destructor and by the copy-on-write functions.

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
  • /home/bishop/work/projects/nextgismanager/include/wxgis/core/json/jsonval.h
  • /home/bishop/work/projects/nextgismanager/src/core/json/jsonval.cpp