OpenCPN Partial API docs
|
The JSON value class implementation. More...
Public Member Functions | |
wxJSONValue () | |
Constructors. | |
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. | |
wxJSONValue (const void *buff, size_t len) | |
Construct a JSON value object of type memory buffer. | |
wxJSONValue (const wxJSONValue &other) | |
Copy constructor. | |
virtual | ~wxJSONValue () |
Dtor - calls UnRef(). | |
wxJSONType | GetType () const |
Return the type of the value stored in the object. | |
bool | IsValid () const |
Return TRUE if the value stored is valid. | |
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. | |
bool | IsUInt () const |
Return TRUE if the type of the value stored is a unsigned int. | |
bool | IsShort () const |
Return TRUE if the type of the value stored is 16-bit integer. | |
bool | IsUShort () const |
Return TRUE if the type of the value stored is a unsigned short. | |
bool | IsLong () const |
Return TRUE if the stored value is an integer which fits in a long int. | |
bool | IsULong () const |
Return TRUE if the stored value is an integer which fits in a unsigned long int. | |
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. | |
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. | |
unsigned int | AsUInt () const |
Return the stored value as a unsigned int. | |
short | AsShort () const |
Returns the value as a short integer. | |
unsigned short | AsUShort () const |
Returns the value as a unsigned short integer. | |
long int | AsLong () const |
Returns the value as a long integer. | |
unsigned long | AsULong () const |
Returns the value as a unsigned long integer. | |
bool | AsInt (int &i) const |
Stores the value of this object in the provided argument. | |
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. | |
double | AsDouble () const |
Return the stored value as a double. | |
wxString | AsString () const |
Return the stored value as a wxWidget's string. | |
const wxChar * | AsCString () const |
Return the stored value as a pointer to a static C string. | |
bool | AsBool (bool &b) const |
bool | AsDouble (double &d) const |
bool | AsString (wxString &str) const |
Return this string value in the provided argument. | |
bool | AsCString (wxChar *ch) const |
wxMemoryBuffer | AsMemoryBuff () const |
Returns the value as a memory buffer. | |
bool | AsMemoryBuff (wxMemoryBuffer &buff) const |
Returns the value as a memory buffer. | |
const wxJSONInternalMap * | AsMap () const |
Return the stored value as a map object. | |
const wxJSONInternalArray * | AsArray () const |
Return the stored value as an array object. | |
bool | HasMember (unsigned index) const |
Return TRUE if the object contains an element at the specified index. | |
bool | HasMember (const wxString &key) const |
Return TRUE if the object contains an element at the specified key. | |
int | Size () const |
Return the size of the array or map stored in this value. | |
wxArrayString | GetMemberNames () const |
Return the array of keys of this JSON object. | |
wxJSONValue & | Append (const wxJSONValue &value) |
Append the specified value in the array. | |
wxJSONValue & | Append (bool b) |
wxJSONValue & | Append (int i) |
wxJSONValue & | Append (unsigned int ui) |
wxJSONValue & | Append (short int i) |
wxJSONValue & | Append (unsigned short int ui) |
wxJSONValue & | Append (long int l) |
wxJSONValue & | Append (unsigned long int ul) |
wxJSONValue & | Append (double d) |
wxJSONValue & | Append (const wxChar *str) |
wxJSONValue & | Append (const wxString &str) |
wxJSONValue & | Append (const wxMemoryBuffer &buff) |
wxJSONValue & | Append (const void *buff, size_t len) |
bool | Remove (int index) |
Remove the item at the specified index or key. | |
bool | Remove (const wxString &key) |
void | Clear () |
Clear the object value. | |
bool | Cat (const wxChar *str) |
bool | Cat (const wxString &str) |
Concatenate a string to this string object. | |
bool | Cat (const wxMemoryBuffer &buff) |
Concatenate a memory buffer to this memory buffer object. | |
wxJSONValue & | Item (unsigned index) |
Return the item at the specified index. | |
wxJSONValue & | Item (const wxString &key) |
Return the item at the specified key. | |
wxJSONValue | ItemAt (unsigned index) const |
Return the item at the specified index. | |
wxJSONValue | ItemAt (const wxString &key) const |
Return the item at the specified key. | |
wxJSONValue & | operator[] (unsigned index) |
Return the item at the specified index. | |
wxJSONValue & | operator[] (const wxString &key) |
Return the item at the specified key. | |
wxJSONValue & | operator= (int i) |
Assign the specified value to this object replacing the old value. | |
wxJSONValue & | operator= (unsigned int ui) |
wxJSONValue & | operator= (short int i) |
wxJSONValue & | operator= (unsigned short int ui) |
wxJSONValue & | operator= (long int l) |
wxJSONValue & | operator= (unsigned long int ul) |
wxJSONValue & | operator= (bool b) |
wxJSONValue & | operator= (double d) |
wxJSONValue & | operator= (const wxChar *str) |
wxJSONValue & | operator= (const wxString &str) |
wxJSONValue & | operator= (const wxMemoryBuffer &buff) |
Assigns to this object a memory buffer type. | |
wxJSONValue & | operator= (const wxJSONValue &value) |
Assignment operator using reference counting. | |
wxJSONValue | Get (const wxString &key, const wxJSONValue &defaultValue) const |
Return a value or a default value. | |
bool | IsSameAs (const wxJSONValue &other) const |
The comparison function. | |
int | AddComment (const wxString &str, int position=wxJSONVALUE_COMMENT_DEFAULT) |
Add a comment to this JSON value object. | |
int | AddComment (const wxArrayString &comments, int position=wxJSONVALUE_COMMENT_DEFAULT) |
Add one or more comments to this JSON value object. | |
wxString | GetComment (int idx=-1) const |
Return a comment string. | |
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. | |
wxString | Dump (bool deep=false, int mode=0) const |
Returns informations about the object. | |
wxJSONRefData * | GetRefData () const |
Return the pointer to the referenced data structure. | |
wxJSONRefData * | SetType (wxJSONType type) |
Set the type of the stored value. | |
int | GetLineNo () const |
Return the line number of this JSON value object. | |
void | SetLineNo (int num) |
Set the line number of this JSON value object. | |
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) | |
wxJSONValue (const void *buff, size_t len) | |
wxJSONValue (const wxJSONValue &other) | |
wxJSONType | GetType () const |
bool | IsValid () const |
bool | IsNull () const |
bool | IsInt () const |
bool | IsUInt () const |
bool | IsShort () const |
bool | IsUShort () const |
bool | IsLong () const |
bool | IsULong () const |
bool | IsBool () const |
bool | IsDouble () const |
bool | IsString () const |
bool | IsCString () const |
bool | IsArray () const |
bool | IsObject () const |
bool | IsMemoryBuff () const |
int | AsInt () const |
unsigned int | AsUInt () const |
short | AsShort () const |
unsigned short | AsUShort () const |
long int | AsLong () const |
unsigned long | AsULong () const |
bool | AsInt (int &i) const |
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 |
double | AsDouble () const |
wxString | AsString () const |
const wxChar * | AsCString () const |
bool | AsBool (bool &b) const |
bool | AsDouble (double &d) const |
bool | AsString (wxString &str) const |
bool | AsCString (wxChar *ch) const |
wxMemoryBuffer | AsMemoryBuff () const |
bool | AsMemoryBuff (wxMemoryBuffer &buff) const |
const wxJSONInternalMap * | AsMap () const |
const wxJSONInternalArray * | AsArray () const |
bool | HasMember (unsigned index) const |
bool | HasMember (const wxString &key) const |
int | Size () const |
wxArrayString | GetMemberNames () const |
wxJSONValue & | Append (const wxJSONValue &value) |
wxJSONValue & | Append (bool b) |
wxJSONValue & | Append (int i) |
wxJSONValue & | Append (unsigned int ui) |
wxJSONValue & | Append (short int i) |
wxJSONValue & | Append (unsigned short int ui) |
wxJSONValue & | Append (long int l) |
wxJSONValue & | Append (unsigned long int ul) |
wxJSONValue & | Append (double d) |
wxJSONValue & | Append (const wxChar *str) |
wxJSONValue & | Append (const wxString &str) |
wxJSONValue & | Append (const wxMemoryBuffer &buff) |
wxJSONValue & | Append (const void *buff, size_t len) |
bool | Remove (int index) |
bool | Remove (const wxString &key) |
void | Clear () |
bool | Cat (const wxChar *str) |
bool | Cat (const wxString &str) |
bool | Cat (const wxMemoryBuffer &buff) |
wxJSONValue & | Item (unsigned index) |
wxJSONValue & | Item (const wxString &key) |
wxJSONValue | ItemAt (unsigned index) const |
wxJSONValue | ItemAt (const wxString &key) const |
wxJSONValue & | operator[] (unsigned index) |
wxJSONValue & | operator[] (const wxString &key) |
wxJSONValue & | operator= (int i) |
wxJSONValue & | operator= (unsigned int ui) |
wxJSONValue & | operator= (short int i) |
wxJSONValue & | operator= (unsigned short int ui) |
wxJSONValue & | operator= (long int l) |
wxJSONValue & | operator= (unsigned long int ul) |
wxJSONValue & | operator= (bool b) |
wxJSONValue & | operator= (double d) |
wxJSONValue & | operator= (const wxChar *str) |
wxJSONValue & | operator= (const wxString &str) |
wxJSONValue & | operator= (const wxMemoryBuffer &buff) |
wxJSONValue & | operator= (const wxJSONValue &value) |
wxJSONValue | Get (const wxString &key, const wxJSONValue &defaultValue) const |
bool | IsSameAs (const wxJSONValue &other) const |
int | AddComment (const wxString &str, int position=wxJSONVALUE_COMMENT_DEFAULT) |
int | AddComment (const wxArrayString &comments, int position=wxJSONVALUE_COMMENT_DEFAULT) |
wxString | GetComment (int idx=-1) const |
int | GetCommentPos () const |
int | GetCommentCount () const |
void | ClearComments () |
const wxArrayString & | GetCommentArray () const |
wxString | GetInfo () const |
wxString | Dump (bool deep=false, int mode=0) const |
wxJSONRefData * | GetRefData () const |
wxJSONRefData * | SetType (wxJSONType type) |
int | GetLineNo () const |
void | SetLineNo (int num) |
Static Public Member Functions | |
static wxString | TypeToString (wxJSONType type) |
Return a string description of the type. | |
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. | |
static int | CompareMemoryBuff (const wxMemoryBuffer &buff1, const void *buff2) |
Compares a memory buffer object and a memory buffer. | |
static wxMemoryBuffer | ArrayToMemoryBuff (const wxJSONValue &value) |
Converts an array of INTs to a memory buffer. | |
static wxString | TypeToString (wxJSONType type) |
static wxString | MemoryBuffToString (const wxMemoryBuffer &buff, size_t len=-1) |
static wxString | MemoryBuffToString (const void *buff, size_t len, size_t actualLen=-1) |
static int | CompareMemoryBuff (const wxMemoryBuffer &buff1, const wxMemoryBuffer &buff2) |
static int | CompareMemoryBuff (const wxMemoryBuffer &buff1, const void *buff2) |
static wxMemoryBuffer | ArrayToMemoryBuff (const wxJSONValue &value) |
Protected Member Functions | |
wxJSONValue * | Find (unsigned index) const |
Find an element. | |
wxJSONValue * | Find (const wxString &key) const |
Find an element. | |
void | DeepCopy (const wxJSONValue &other) |
Do a deep copy of the other object. | |
wxJSONRefData * | Init (wxJSONType type) |
Initialize the JSON value class. | |
wxJSONRefData * | COW () |
Make sure the referenced data is unique. | |
virtual wxJSONRefData * | CloneRefData (const wxJSONRefData *data) const |
Make a copy of the referenced data. | |
virtual wxJSONRefData * | CreateRefData () const |
Create a new data structure. | |
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. | |
void | UnShare () |
Makes an exclusive copy of shared data. | |
void | AllocExclusive () |
Makes a private copy of the referenced data. | |
wxJSONValue * | Find (unsigned index) const |
wxJSONValue * | Find (const wxString &key) const |
void | DeepCopy (const wxJSONValue &other) |
wxJSONRefData * | Init (wxJSONType type) |
wxJSONRefData * | COW () |
virtual wxJSONRefData * | CloneRefData (const wxJSONRefData *data) const |
virtual wxJSONRefData * | CreateRefData () const |
void | SetRefData (wxJSONRefData *data) |
void | Ref (const wxJSONValue &clone) |
void | UnRef () |
void | UnShare () |
void | AllocExclusive () |
Protected Attributes | |
wxJSONRefData * | m_refData |
the referenced data | |
Friends | |
class | wxJSONReader |
Related Symbols | |
(Note that these are not member symbols.) | |
Cat | |
Cat | |
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:
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:
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
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:
Definition at line 183 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | wxJSONType | type | ) |
Definition at line 224 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | int | i | ) |
Definition at line 230 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | unsigned int | i | ) |
Definition at line 242 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | unsigned short | i | ) |
Definition at line 266 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | long int | i | ) |
Definition at line 323 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | unsigned long int | i | ) |
Definition at line 333 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | bool | b | ) |
Definition at line 278 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | double | d | ) |
Definition at line 288 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | const wxChar * | str | ) |
Definition at line 298 of file jsonval.cpp.
wxJSONValue::wxJSONValue | ( | const wxString & | str | ) |
Definition at line 313 of file jsonval.cpp.
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.
Definition at line 348 of file jsonval.cpp.
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.
Definition at line 368 of file jsonval.cpp.
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.
Definition at line 386 of file jsonval.cpp.
|
virtual |
Dtor - calls UnRef().
Definition at line 403 of file jsonval.cpp.
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.
Definition at line 2405 of file jsonval.cpp.
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:
To know more about comment's storage see json_comment_add
Definition at line 2346 of file jsonval.cpp.
|
protected |
Makes a private copy of the referenced data.
Definition at line 2768 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | bool | b | ) |
Definition at line 1422 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | const void * | buff, |
size_t | len | ||
) |
Definition at line 1478 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | const wxChar * | str | ) |
Definition at line 1457 of file jsonval.cpp.
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.
Definition at line 1385 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | const wxMemoryBuffer & | buff | ) |
Definition at line 1471 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | const wxString & | str | ) |
Definition at line 1464 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | double | d | ) |
Definition at line 1450 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | int | i | ) |
Definition at line 1401 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | long int | l | ) |
Definition at line 1415 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | short int | i | ) |
Definition at line 1408 of file jsonval.cpp.
wxJSONValue & wxJSONValue::Append | ( | unsigned int | ui | ) |
Definition at line 1429 of file jsonval.cpp.
|
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:
value
is not an ARRAY type, an empty memory buffer is returned value
array contains elements of type other than INT, those elements are ignored value
array contains elements of type INT which value is outside the range 0..255, those elements are ignored 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.
Definition at line 2943 of file jsonval.cpp.
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 nullptr pointer.
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.
Definition at line 1281 of file jsonval.cpp.
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.
Definition at line 809 of file jsonval.cpp.
bool wxJSONValue::AsBool | ( | bool & | b | ) | const |
Definition at line 1152 of file jsonval.cpp.
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 nullptr pointer.
Note that in versions prior to 0.5, the function returned a nullptr pointer also if the value is a wxString
object.
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.
Definition at line 947 of file jsonval.cpp.
bool wxJSONValue::AsCString | ( | wxChar * | ch | ) | const |
Definition at line 1188 of file jsonval.cpp.
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()
.
Definition at line 827 of file jsonval.cpp.
bool wxJSONValue::AsDouble | ( | double & | d | ) | const |
Definition at line 1161 of file jsonval.cpp.
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()
.
Definition at line 789 of file jsonval.cpp.
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:
This is the same as:
Thanks to catalin who has suggested this new feature.
Definition at line 1098 of file jsonval.cpp.
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()
.
Definition at line 997 of file jsonval.cpp.
bool wxJSONValue::AsLong | ( | long int & | l | ) | const |
Definition at line 1134 of file jsonval.cpp.
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 nullptr pointer.
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.
Definition at line 1263 of file jsonval.cpp.
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.
Definition at line 1215 of file jsonval.cpp.
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.
Definition at line 1246 of file jsonval.cpp.
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()
.
Definition at line 1040 of file jsonval.cpp.
bool wxJSONValue::AsShort | ( | short int & | s | ) | const |
Definition at line 1116 of file jsonval.cpp.
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:
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:
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:
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:
Definition at line 872 of file jsonval.cpp.
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.
Definition at line 1180 of file jsonval.cpp.
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.
Definition at line 976 of file jsonval.cpp.
bool wxJSONValue::AsUInt | ( | unsigned int & | ui | ) | const |
Definition at line 1107 of file jsonval.cpp.
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()
.
Definition at line 1019 of file jsonval.cpp.
bool wxJSONValue::AsULong | ( | unsigned long & | ul | ) | const |
Definition at line 1143 of file jsonval.cpp.
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()
.
Definition at line 1062 of file jsonval.cpp.
bool wxJSONValue::AsUShort | ( | unsigned short & | us | ) | const |
Definition at line 1125 of file jsonval.cpp.
bool wxJSONValue::Cat | ( | const wxChar * | str | ) |
Definition at line 1529 of file jsonval.cpp.
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.
Definition at line 1514 of file jsonval.cpp.
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.
Definition at line 1493 of file jsonval.cpp.
void wxJSONValue::Clear | ( | ) |
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.
Definition at line 1584 of file jsonval.cpp.
void wxJSONValue::ClearComments | ( | ) |
Clear all comment strings.
Definition at line 2466 of file jsonval.cpp.
|
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.
Definition at line 2698 of file jsonval.cpp.
|
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
.
Definition at line 2914 of file jsonval.cpp.
|
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:
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
.
Definition at line 2887 of file jsonval.cpp.
|
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.
Definition at line 2756 of file jsonval.cpp.
|
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).
Definition at line 2743 of file jsonval.cpp.
|
protected |
Do a deep copy of the other object.
This function allocates a new ref-data structure and copies it from the object other
.
Definition at line 2677 of file jsonval.cpp.
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 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.
Definition at line 2003 of file jsonval.cpp.
|
protected |
Find an element.
The function returns a pointer to the element with key key
or a nullptr pointer if key
does not exist. A nullptr pointer is also returned if the object does not contain a key/value map.
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.
Definition at line 1928 of file jsonval.cpp.
|
protected |
Find an element.
The function returns a pointer to the element at index index
or a nullptr pointer if index
does not exist. A nullptr pointer is also returned if the object does not contain an array nor a key/value map.
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.
Definition at line 1906 of file jsonval.cpp.
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:
Definition at line 1878 of file jsonval.cpp.
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.
Definition at line 2424 of file jsonval.cpp.
const wxArrayString & wxJSONValue::GetCommentArray | ( | ) | const |
Get the comment string's array.
Definition at line 2458 of file jsonval.cpp.
int wxJSONValue::GetCommentCount | ( | ) | const |
Return the number of comment strings.
Definition at line 2441 of file jsonval.cpp.
int wxJSONValue::GetCommentPos | ( | ) | const |
Return the comment position.
Definition at line 2451 of file jsonval.cpp.
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.
Definition at line 2075 of file jsonval.cpp.
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.
Definition at line 2617 of file jsonval.cpp.
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.
Definition at line 1357 of file jsonval.cpp.
wxJSONRefData * wxJSONValue::GetRefData | ( | ) | const |
Return the pointer to the referenced data structure.
Definition at line 2684 of file jsonval.cpp.
wxJSONType wxJSONValue::GetType | ( | ) | 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 nullptr. 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 nullptr.
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:
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).
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.
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:
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).
Definition at line 458 of file jsonval.cpp.
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.
Definition at line 1311 of file jsonval.cpp.
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.
Definition at line 1298 of file jsonval.cpp.
|
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 nullptr.
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.
Definition at line 196 of file jsonval.cpp.
bool wxJSONValue::IsArray | ( | ) | const |
Return TRUE if the type of the value stored is an array type.
Definition at line 746 of file jsonval.cpp.
bool wxJSONValue::IsBool | ( | ) | const |
Return TRUE if the type of the value stored is a boolean.
Definition at line 697 of file jsonval.cpp.
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
Definition at line 736 of file jsonval.cpp.
bool wxJSONValue::IsDouble | ( | ) | const |
Return TRUE if the type of the value stored is a double.
Definition at line 707 of file jsonval.cpp.
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:
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.
Definition at line 552 of file jsonval.cpp.
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:
Definition at line 663 of file jsonval.cpp.
bool wxJSONValue::IsMemoryBuff | ( | ) | const |
Return TRUE if the type of this value is a binary memory buffer.
Definition at line 766 of file jsonval.cpp.
bool wxJSONValue::IsNull | ( | ) | const |
Return TRUE if the type of the value is wxJSONTYPE_NULL.
Definition at line 500 of file jsonval.cpp.
bool wxJSONValue::IsObject | ( | ) | const |
Return TRUE if the type of this value is a key/value map.
Definition at line 756 of file jsonval.cpp.
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):
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.
Definition at line 2126 of file jsonval.cpp.
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:
Definition at line 581 of file jsonval.cpp.
bool wxJSONValue::IsString | ( | ) | const |
Return TRUE if the type of the value stored is a wxString object.
Definition at line 717 of file jsonval.cpp.
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:
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.
Definition at line 613 of file jsonval.cpp.
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:
Definition at line 687 of file jsonval.cpp.
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:
Definition at line 640 of file jsonval.cpp.
bool wxJSONValue::IsValid | ( | ) | 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;
Definition at line 521 of file jsonval.cpp.
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 nullptr 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.
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.
Definition at line 1630 of file jsonval.cpp.
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 nullptr 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.
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.
Definition at line 1602 of file jsonval.cpp.
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.
Definition at line 1678 of file jsonval.cpp.
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.
Definition at line 1657 of file jsonval.cpp.
|
static |
Convert a binary memory buffer to a string representation.
Definition at line 2832 of file jsonval.cpp.
|
static |
Convert memory buffer object to a string representation.
Definition at line 2803 of file jsonval.cpp.
wxJSONValue & wxJSONValue::operator= | ( | bool | b | ) |
Definition at line 1754 of file jsonval.cpp.
wxJSONValue & wxJSONValue::operator= | ( | const wxChar * | str | ) |
Definition at line 1803 of file jsonval.cpp.
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.
Definition at line 1845 of file jsonval.cpp.
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.
Definition at line 1826 of file jsonval.cpp.
wxJSONValue & wxJSONValue::operator= | ( | const wxString & | str | ) |
Definition at line 1814 of file jsonval.cpp.
wxJSONValue & wxJSONValue::operator= | ( | double | d | ) |
Definition at line 1796 of file jsonval.cpp.
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.
Definition at line 1747 of file jsonval.cpp.
wxJSONValue & wxJSONValue::operator= | ( | unsigned int | ui | ) |
Definition at line 1761 of file jsonval.cpp.
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 nullptr 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.
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.
Definition at line 1721 of file jsonval.cpp.
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 nullptr values. If this object does not contain an array, the old value is replaced by an array object.
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.
Definition at line 1707 of file jsonval.cpp.
|
protected |
Increments the referenced data counter.
Definition at line 2638 of file jsonval.cpp.
bool wxJSONValue::Remove | ( | const wxString & | key | ) |
Definition at line 1564 of file jsonval.cpp.
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.
Definition at line 1551 of file jsonval.cpp.
void wxJSONValue::SetLineNo | ( | int | num | ) |
Set the line number of this JSON value object.
Definition at line 2628 of file jsonval.cpp.
|
protected |
Set the pointer to the referenced data.
Definition at line 2635 of file jsonval.cpp.
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:
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:
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:
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:
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:
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:
Definition at line 2535 of file jsonval.cpp.
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.
Definition at line 1332 of file jsonval.cpp.
|
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).
Definition at line 1954 of file jsonval.cpp.
|
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.
Definition at line 2658 of file jsonval.cpp.
|
protected |
Makes an exclusive copy of shared data.
Definition at line 2670 of file jsonval.cpp.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
friend |
|
protected |