ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

#include <json.h>

Collaboration diagram for Common::JSONValue:

List of all members.

Public Member Functions

 JSONValue ()
 Basic constructor for creating a JSON Value of type NULL.
 JSONValue (const char *charValue)
 Basic constructor for creating a JSON Value of type String.
 JSONValue (const String &stringValue)
 Basic constructor for creating a JSON Value of type String.
 JSONValue (bool boolValue)
 Basic constructor for creating a JSON Value of type Bool.
 JSONValue (double numberValue)
 Basic constructor for creating a JSON Value of type Number.
 JSONValue (long long int numberValue)
 Basic constructor for creating a JSON Value of type Number (Integer).
 JSONValue (const JSONArray &arrayValue)
 Basic constructor for creating a JSON Value of type Array.
 JSONValue (const JSONObject &objectValue)
 Basic constructor for creating a JSON Value of type Object.
 JSONValue (const JSONValue &source)
 Copy constructor to perform a deep copy of array / object values.
 ~JSONValue ()
 The destructor for the JSON Value object Handles deleting the objects in the array or the object value.
bool isNull () const
 Checks if the value is a NULL.
bool isString () const
 Checks if the value is a String.
bool isBool () const
 Checks if the value is a Bool.
bool isNumber () const
 Checks if the value is a Number.
bool isIntegerNumber () const
 Checks if the value is an Integer.
bool isArray () const
 Checks if the value is an Array.
bool isObject () const
 Checks if the value is an Object.
const StringasString () const
 Retrieves the String value of this JSONValue Use isString() before using this method.
bool asBool () const
 Retrieves the Bool value of this JSONValue Use isBool() before using this method.
double asNumber () const
 Retrieves the Number value of this JSONValue Use isNumber() before using this method.
long long int asIntegerNumber () const
 Retrieves the Integer value of this JSONValue Use isIntegerNumber() before using this method.
const JSONArrayasArray () const
 Retrieves the Array value of this JSONValue Use isArray() before using this method.
const JSONObjectasObject () const
 Retrieves the Object value of this JSONValue Use isObject() before using this method.
size_t countChildren () const
 Retrieves the number of children of this JSONValue.
bool hasChild (size_t index) const
JSONValuechild (size_t index)
bool hasChild (const char *name) const
 Checks if this JSONValue has a child at the given key.
JSONValuechild (const char *name)
 Retrieves the child of this JSONValue at the given key.
Array< StringobjectKeys () const
 Retrieves the keys of the JSON Object or an empty vector if this value is not an object.
String stringify (bool const prettyprint=false) const
 Creates a JSON encoded string for the value with all necessary characters escaped.

Static Protected Member Functions

static JSONValueparse (const char **data)
 Parses a JSON encoded value to a JSONValue object.

Private Member Functions

String stringifyImpl (size_t const indentDepth) const
 Creates a JSON encoded string for the value with all necessary characters escaped.

Static Private Member Functions

static String stringifyString (const String &str)
 Creates a JSON encoded string with all required fields escaped Works from http://www.ecma-internationl.org/publications/files/ECMA-ST/ECMA-262.pdf Section 15.12.3.
static uint32 decodeUtf8Char (String::const_iterator &begin, const String::const_iterator &end)
 Decode the next utf-8 character in the String pointed to by begin.
static uint8 decodeUtf8Byte (uint8 state, uint32 &codepoint, uint8 byte)
 Decode one byte from a UTF-8 string.
static String indent (size_t depth)
 Creates the indentation string for the depth given.

Private Attributes

JSONType _type
union {
   bool   _boolValue
   double   _numberValue
   long long int   _integerValue
   String *   _stringValue
   JSONArray *   _arrayValue
   JSONObject *   _objectValue
}; 

Friends

class JSON

Detailed Description

Definition at line 90 of file json.h.


Constructor & Destructor Documentation

Common::JSONValue::JSONValue (  ) 

Basic constructor for creating a JSON Value of type NULL.

public

Definition at line 570 of file json.cpp.

Common::JSONValue::JSONValue ( const char *  charValue  ) 

Basic constructor for creating a JSON Value of type String.

public

Parameters:
char* m_char_value The string to use as the value

Definition at line 581 of file json.cpp.

Common::JSONValue::JSONValue ( const String stringValue  ) 

Basic constructor for creating a JSON Value of type String.

public

Parameters:
String m_string_value The string to use as the value

Definition at line 593 of file json.cpp.

Common::JSONValue::JSONValue ( bool  boolValue  ) 

Basic constructor for creating a JSON Value of type Bool.

public

Parameters:
bool m_bool_value The bool to use as the value

Definition at line 605 of file json.cpp.

Common::JSONValue::JSONValue ( double  numberValue  ) 

Basic constructor for creating a JSON Value of type Number.

public

Parameters:
double m_number_value The number to use as the value

Definition at line 617 of file json.cpp.

Common::JSONValue::JSONValue ( long long int  numberValue  ) 

Basic constructor for creating a JSON Value of type Number (Integer).

public

Parameters:
int numberValue The number to use as the value

Definition at line 629 of file json.cpp.

Common::JSONValue::JSONValue ( const JSONArray arrayValue  ) 

Basic constructor for creating a JSON Value of type Array.

public

Parameters:
JSONArray m_array_value The JSONArray to use as the value

Definition at line 641 of file json.cpp.

Common::JSONValue::JSONValue ( const JSONObject objectValue  ) 

Basic constructor for creating a JSON Value of type Object.

public

Parameters:
JSONObject m_object_value The JSONObject to use as the value

Definition at line 653 of file json.cpp.

Common::JSONValue::JSONValue ( const JSONValue source  ) 

Copy constructor to perform a deep copy of array / object values.

public

Parameters:
JSONValue m_source The source JSONValue that is being copied

Definition at line 665 of file json.cpp.

Common::JSONValue::~JSONValue (  ) 

The destructor for the JSON Value object Handles deleting the objects in the array or the object value.

public

Definition at line 719 of file json.cpp.


Member Function Documentation

const JSONArray & Common::JSONValue::asArray (  )  const

Retrieves the Array value of this JSONValue Use isArray() before using this method.

public

Returns:
JSONArray Returns the array value

Definition at line 869 of file json.cpp.

bool Common::JSONValue::asBool (  )  const

Retrieves the Bool value of this JSONValue Use isBool() before using this method.

public

Returns:
bool Returns the bool value

Definition at line 833 of file json.cpp.

long long int Common::JSONValue::asIntegerNumber (  )  const

Retrieves the Integer value of this JSONValue Use isIntegerNumber() before using this method.

public

Returns:
int Returns the number value

Definition at line 857 of file json.cpp.

double Common::JSONValue::asNumber (  )  const

Retrieves the Number value of this JSONValue Use isNumber() before using this method.

public

Returns:
double Returns the number value

Definition at line 845 of file json.cpp.

const JSONObject & Common::JSONValue::asObject (  )  const

Retrieves the Object value of this JSONValue Use isObject() before using this method.

public

Returns:
JSONObject Returns the object value

Definition at line 881 of file json.cpp.

const String & Common::JSONValue::asString (  )  const

Retrieves the String value of this JSONValue Use isString() before using this method.

public

Returns:
String Returns the string value

Definition at line 821 of file json.cpp.

JSONValue* Common::JSONValue::child ( size_t  index  ) 
JSONValue * Common::JSONValue::child ( const char *  name  ) 

Retrieves the child of this JSONValue at the given key.

Use isObject() before using this method.

public

Returns:
JSONValue* Returns JSONValue for the given key in the object or NULL if it doesn't exist.

Definition at line 963 of file json.cpp.

std::size_t Common::JSONValue::countChildren (  )  const

Retrieves the number of children of this JSONValue.

This number will be 0 or the actual number of children if isArray() or isObject().

public

Returns:
The number of children.

Definition at line 894 of file json.cpp.

uint8 Common::JSONValue::decodeUtf8Byte ( uint8  state,
uint32 codepoint,
uint8  byte 
) [static, private]

Decode one byte from a UTF-8 string.

The function must initially (for the first byte) be called with a state of 0, and then with the state from the previous byte until it returns 0 (success) or 1 (failure).

Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.

private

Parameters:
uint8 state The state from the previous byte, or 0 when decoding the first byte.
uint32 &codepoint The codepoint value. Unless the returned state is 0, the codepoint is a partial reasult and the function needs to be called again with the next byte.
uint8 byte The byte to decode.
Returns:
The state of the utf8 decoder: 0 if a character has been decoded, 1 in case of error, and any other value for decoding in progress.

Definition at line 1192 of file json.cpp.

uint32 Common::JSONValue::decodeUtf8Char ( String::const_iterator iter,
const String::const_iterator end 
) [static, private]

Decode the next utf-8 character in the String pointed to by begin.

Parameters:
String::const_iterator &iter Iterator pointing to the start of the character to decode.
const String::const_iterator &end Iterator pointing past the end of the string being decoded.
Returns:
The codepoint value for the next utf-8 character starting at the current iterator position, or 0xFFFFFFFF in case of error.

Definition at line 1147 of file json.cpp.

bool Common::JSONValue::hasChild ( const char *  name  )  const

Checks if this JSONValue has a child at the given key.

Use isObject() before using this method.

public

Returns:
bool Returns true if the object has a value at the given key.

Definition at line 946 of file json.cpp.

bool Common::JSONValue::hasChild ( size_t  index  )  const
String Common::JSONValue::indent ( size_t  depth  )  [static, private]

Creates the indentation string for the depth given.

private

Parameters:
size_t indent The prettyprint indentation depth (0 : no indentation)
Returns:
String Returns the string

Definition at line 1226 of file json.cpp.

bool Common::JSONValue::isArray (  )  const

Checks if the value is an Array.

public

Returns:
bool Returns true if it is an Array value, false otherwise

Definition at line 798 of file json.cpp.

bool Common::JSONValue::isBool (  )  const

Checks if the value is a Bool.

public

Returns:
bool Returns true if it is a Bool value, false otherwise

Definition at line 765 of file json.cpp.

bool Common::JSONValue::isIntegerNumber (  )  const

Checks if the value is an Integer.

public

Returns:
bool Returns true if it is an Integer value, false otherwise

Definition at line 787 of file json.cpp.

bool Common::JSONValue::isNull (  )  const

Checks if the value is a NULL.

public

Returns:
bool Returns true if it is a NULL value, false otherwise

Definition at line 743 of file json.cpp.

bool Common::JSONValue::isNumber (  )  const

Checks if the value is a Number.

public

Returns:
bool Returns true if it is a Number value, false otherwise

Definition at line 776 of file json.cpp.

bool Common::JSONValue::isObject (  )  const

Checks if the value is an Object.

public

Returns:
bool Returns true if it is an Object value, false otherwise

Definition at line 809 of file json.cpp.

bool Common::JSONValue::isString (  )  const

Checks if the value is a String.

public

Returns:
bool Returns true if it is a String value, false otherwise

Definition at line 754 of file json.cpp.

Array< String > Common::JSONValue::objectKeys (  )  const

Retrieves the keys of the JSON Object or an empty vector if this value is not an object.

public

Returns:
std::vector<String> A vector containing the keys.

Definition at line 980 of file json.cpp.

JSONValue * Common::JSONValue::parse ( const char **  data  )  [static, protected]

Parses a JSON encoded value to a JSONValue object.

protected

Parameters:
char** data Pointer to a char* that contains the data
Returns:
JSONValue* Returns a pointer to a JSONValue object on success, NULL on error

Definition at line 332 of file json.cpp.

String Common::JSONValue::stringify ( bool const   prettyprint = false  )  const

Creates a JSON encoded string for the value with all necessary characters escaped.

public

Parameters:
bool prettyprint Enable prettyprint
Returns:
String Returns the JSON string

Definition at line 1004 of file json.cpp.

String Common::JSONValue::stringifyImpl ( size_t const   indentDepth  )  const [private]

Creates a JSON encoded string for the value with all necessary characters escaped.

private

Parameters:
size_t indentDepth The prettyprint indentation depth (0 : no prettyprint)
Returns:
String Returns the JSON string

Definition at line 1019 of file json.cpp.

String Common::JSONValue::stringifyString ( const String str  )  [static, private]

Creates a JSON encoded string with all required fields escaped Works from http://www.ecma-internationl.org/publications/files/ECMA-ST/ECMA-262.pdf Section 15.12.3.

private

Parameters:
String str The string that needs to have the characters escaped
Returns:
String Returns the JSON string

Definition at line 1099 of file json.cpp.


Friends And Related Function Documentation

friend class JSON [friend]

Definition at line 91 of file json.h.


Member Data Documentation

union { ... } [private]

Definition at line 145 of file json.h.

Definition at line 141 of file json.h.

Definition at line 143 of file json.h.

Definition at line 142 of file json.h.

Definition at line 146 of file json.h.

Definition at line 144 of file json.h.

Definition at line 138 of file json.h.


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


Generated on Sat Sep 12 2020 05:04:26 for ResidualVM by doxygen 1.7.1
curved edge   curved edge