Lysa  0.0
Lysa 3D Engine
JsonValue Class Reference

Detailed Description

A read/write handle on a value of a JsonDocument.

Public Member Functions

 JsonValue () = default
 
JsonType getType () const
 
bool isValid () const
 
bool isNull () const
 
bool isBoolean () const
 
bool isNumber () const
 
bool isString () const
 
bool isArray () const
 
bool isObject () const
 
bool getBoolean (bool defaultValue=false) const
 
std::int64_t getInteger (std::int64_t defaultValue=0) const
 
double getDouble (double defaultValue=0.0) const
 
float getFloat (float defaultValue=0.0f) const
 
std::string getString (const std::string &defaultValue={}) const
 
float2 getFloat2 (const float2 &defaultValue={}) const
 
float3 getFloat3 (const float3 &defaultValue={}) const
 
float4 getFloat4 (const float4 &defaultValue={}) const
 
quaternion getQuaternion (const quaternion &defaultValue={}) const
 
bool contains (const std::string &key) const
 
std::vector< std::string > getKeys () const
 
JsonValue operator[] (const std::string &key) const
 
bool getBoolean (const std::string &key, bool defaultValue) const
 
std::int64_t getInteger (const std::string &key, std::int64_t defaultValue) const
 
double getDouble (const std::string &key, double defaultValue) const
 
float getFloat (const std::string &key, float defaultValue) const
 
std::string getString (const std::string &key, const std::string &defaultValue) const
 
float2 getFloat2 (const std::string &key, const float2 &defaultValue) const
 
float3 getFloat3 (const std::string &key, const float3 &defaultValue) const
 
float4 getFloat4 (const std::string &key, const float4 &defaultValue) const
 
quaternion getQuaternion (const std::string &key, const quaternion &defaultValue) const
 
std::size_t getSize () const
 
JsonValue operator[] (std::size_t index) const
 
std::vector< JsonValue > getValues () const
 
void setNull (const std::string &key) const
 
void set (const std::string &key, bool value) const
 
void set (const std::string &key, const char *value) const
 
void set (const std::string &key, const std::string &value) const
 
template<std::integral T>
void set (const std::string &key, const T value) const
 
template<std::floating_point T>
void set (const std::string &key, const T value) const
 
void set (const std::string &key, const float2 &value) const
 
void set (const std::string &key, const float3 &value) const
 
void set (const std::string &key, const float4 &value) const
 
void set (const std::string &key, const quaternion &value) const
 
JsonValue setObject (const std::string &key) const
 
JsonValue setArray (const std::string &key) const
 
void remove (const std::string &key) const
 
void addNull () const
 
void add (bool value) const
 
void add (const char *value) const
 
void add (const std::string &value) const
 
template<std::integral T>
void add (const T value) const
 
template<std::floating_point T>
void add (const T value) const
 
void add (const float2 &value) const
 
void add (const float3 &value) const
 
void add (const float4 &value) const
 
void add (const quaternion &value) const
 
JsonValue addObject () const
 
JsonValue addArray () const
 
void clear () const
 

Constructor & Destructor Documentation

JsonValue ( )
default

Constructs an UNDEFINED value

Member Function Documentation

void add ( bool  value) const

Appends a boolean to an array

void add ( const char *  value) const

Appends a string to an array

void add ( const float2 &  value) const

Appends a float2 to an array, stored as an array

void add ( const float3 &  value) const

Appends a float3 to an array, stored as an array

void add ( const float4 &  value) const

Appends a float4 to an array, stored as an array

void add ( const quaternion &  value) const

Appends a quaternion to an array, stored as an array

void add ( const std::string &  value) const

Appends a string to an array

void add ( const T  value) const
inline

Appends an integer number to an array

void add ( const T  value) const
inline

Appends a floating point number to an array

JsonValue addArray ( ) const

Appends an empty array to an array and returns it

void addNull ( ) const

Appends a JSON null to an array

JsonValue addObject ( ) const

Appends an empty object to an array and returns it

void clear ( ) const

Removes all the elements of an array or all the members of an object

bool contains ( const std::string &  key) const

Returns true if the value is an object having a key member

bool getBoolean ( bool  defaultValue = false) const

Returns the value as a boolean

bool getBoolean ( const std::string &  key,
bool  defaultValue 
) const

Returns the key member as a boolean

double getDouble ( const std::string &  key,
double  defaultValue 
) const

Returns the key member as a double

double getDouble ( double  defaultValue = 0.0) const

Returns the value as a double

float getFloat ( const std::string &  key,
float  defaultValue 
) const

Returns the key member as a float

float getFloat ( float  defaultValue = 0.0f) const

Returns the value as a float

float2 getFloat2 ( const float2 &  defaultValue = {}) const

Returns the value as a float2

float2 getFloat2 ( const std::string &  key,
const float2 &  defaultValue 
) const

Returns the key member as a float2

float3 getFloat3 ( const float3 &  defaultValue = {}) const

Returns the value as a float3

float3 getFloat3 ( const std::string &  key,
const float3 &  defaultValue 
) const

Returns the key member as a float3

float4 getFloat4 ( const float4 &  defaultValue = {}) const

Returns the value as a float4

float4 getFloat4 ( const std::string &  key,
const float4 &  defaultValue 
) const

Returns the key member as a float4

std::int64_t getInteger ( const std::string &  key,
std::int64_t  defaultValue 
) const

Returns the key member as an integer

std::int64_t getInteger ( std::int64_t  defaultValue = 0) const

Returns the value as an integer

std::vector<std::string> getKeys ( ) const

Returns the members names of an object, in the document order

quaternion getQuaternion ( const quaternion &  defaultValue = {}) const

Returns the value as a quaternion

quaternion getQuaternion ( const std::string &  key,
const quaternion &  defaultValue 
) const

Returns the key member as a quaternion

std::size_t getSize ( ) const

Returns the number of elements of an array or the number of keys of an object

std::string getString ( const std::string &  defaultValue = {}) const

Returns the value as a string

std::string getString ( const std::string &  key,
const std::string &  defaultValue 
) const

Returns the key member as a string

JsonType getType ( ) const

Returns the type of the value

std::vector<JsonValue> getValues ( ) const

Returns all the elements of an array, or all the keys values of an object

bool isArray ( ) const
inline

Returns true if the value is an array

bool isBoolean ( ) const
inline

Returns true if the value is a boolean

bool isNull ( ) const
inline

Returns true if the value is a JSON null

bool isNumber ( ) const
inline

Returns true if the value is a number

bool isObject ( ) const
inline

Returns true if the value is an object

bool isString ( ) const
inline

Returns true if the value is a string

bool isValid ( ) const
inline

Returns true if the value exists

JsonValue operator[] ( const std::string &  key) const

Returns the key member of an object or UNDEFINED if it does not exist.

JsonValue operator[] ( std::size_t  index) const

Returns the element at index of an array or UNDEFINED

void remove ( const std::string &  key) const

Removes the key member of an object

void set ( const std::string &  key,
bool  value 
) const

Sets the key member to a boolean

void set ( const std::string &  key,
const char *  value 
) const

Sets the key member to a string

void set ( const std::string &  key,
const float2 &  value 
) const

Sets the key member to a float2, stored as an array

void set ( const std::string &  key,
const float3 &  value 
) const

Sets the key member to a float3, stored as an array

void set ( const std::string &  key,
const float4 &  value 
) const

Sets the key member to a float4, stored as an array

void set ( const std::string &  key,
const quaternion &  value 
) const

Sets the key member to a quaternion, stored as an array

void set ( const std::string &  key,
const std::string &  value 
) const

Sets the key member to a string

void set ( const std::string &  key,
const T  value 
) const
inline

Sets the key member to an integer number

void set ( const std::string &  key,
const T  value 
) const
inline

Sets the key member to a floating point number

JsonValue setArray ( const std::string &  key) const

Sets the key member to an empty array and returns it

void setNull ( const std::string &  key) const

Sets the key member to a JSON null

JsonValue setObject ( const std::string &  key) const

Sets the key member to an empty object and returns it

Friends And Related Function Documentation

friend class JsonDocument
friend