scenepic 1.1.0
3D Visualization Made Easy
Public Member Functions | Static Public Member Functions | List of all members
scenepic::JsonValue Class Reference

Representation of a JSON value according to the specification at https://www.json.org/json-en.html. More...

#include <json_value.h>

Public Member Functions

 JsonValue ()
 Constructor. More...
 
 JsonValue (JsonType type)
 Constructor. More...
 
 JsonValue (const std::string &value)
 Constructor. More...
 
 JsonValue (std::string &&value)
 Constructor. More...
 
 JsonValue (const char *value)
 Constructor. More...
 
 JsonValue (double value)
 Constructor. More...
 
 JsonValue (std::int64_t value)
 Constructor. More...
 
 JsonValue (bool value)
 Constructor. More...
 
void resize (std::size_t size)
 Convert this objec to an array of the specified size. More...
 
void append (JsonValue &&object)
 Append the object to this array. More...
 
void append (const JsonValue &object)
 Append the object to this array. More...
 
JsonValueoperator[] (const std::string &key)
 Return the value stored in this object at the specified key. More...
 
const JsonValueoperator[] (const std::string &key) const
 Return the value stored in this object at the specified key. More...
 
JsonValueoperator= (const std::string &value)
 Set the value of this object to the specified value. More...
 
JsonValueoperator= (std::string &&value)
 Set the value of this object to the specified value. More...
 
JsonValueoperator= (const char *value)
 Set the value of this object to the specified value. More...
 
JsonValueoperator= (double value)
 Set the value of this object to the specified value. More...
 
JsonValueoperator= (std::int64_t value)
 Set the value of this object to the specified value. More...
 
JsonValueoperator= (bool value)
 Set the value of this object to the specified value. More...
 
JsonType type () const
 The type of this object. More...
 
std::string to_string () const
 A string representation of this object in valid JSON. More...
 
const std::string & as_string () const
 Return this object interpreted as a string. More...
 
double as_double () const
 Return this object interpreted as a double. More...
 
float as_float () const
 Return this object intepreted as a float. More...
 
std::int64_t as_int () const
 Return this object intepreted as an integer. More...
 
bool as_boolean () const
 Return this object intepreted as a boolean. More...
 
const std::vector< JsonValue > & values () const
 Return the values of this JSON array. More...
 
const std::map< std::string, JsonValue > & lookup () const
 Return the key/value lookup for this JSON object. More...
 

Static Public Member Functions

static JsonValue parse (std::istream &stream)
 Parse a JsonValue object from the provided input stream. More...
 
static JsonValue nullSingleton ()
 Return a singleton representating a JSON NULL object. More...
 

Detailed Description

Representation of a JSON value according to the specification at https://www.json.org/json-en.html.

Constructor & Destructor Documentation

◆ JsonValue() [1/8]

scenepic::JsonValue::JsonValue ( )

Constructor.

Creates a default JSON object type.

◆ JsonValue() [2/8]

scenepic::JsonValue::JsonValue ( JsonType  type)

Constructor.

Parameters
typedesired type of Json object

◆ JsonValue() [3/8]

scenepic::JsonValue::JsonValue ( const std::string &  value)

Constructor.

Parameters
valuestring value to represent

◆ JsonValue() [4/8]

scenepic::JsonValue::JsonValue ( std::string &&  value)

Constructor.

Parameters
valuestring value to represent

◆ JsonValue() [5/8]

scenepic::JsonValue::JsonValue ( const char *  value)

Constructor.

Parameters
valuestring value to represent

◆ JsonValue() [6/8]

scenepic::JsonValue::JsonValue ( double  value)

Constructor.

Parameters
valuefloating point value to represent

◆ JsonValue() [7/8]

scenepic::JsonValue::JsonValue ( std::int64_t  value)

Constructor.

Parameters
valueinteger value to represent

◆ JsonValue() [8/8]

scenepic::JsonValue::JsonValue ( bool  value)

Constructor.

Parameters
valueboolean value to represent

Member Function Documentation

◆ append() [1/2]

void scenepic::JsonValue::append ( const JsonValue object)

Append the object to this array.

Parameters
objectthe object to append.

◆ append() [2/2]

void scenepic::JsonValue::append ( JsonValue &&  object)

Append the object to this array.

Parameters
objectthe object to append.

◆ as_boolean()

bool scenepic::JsonValue::as_boolean ( ) const

Return this object intepreted as a boolean.

◆ as_double()

double scenepic::JsonValue::as_double ( ) const

Return this object interpreted as a double.

◆ as_float()

float scenepic::JsonValue::as_float ( ) const

Return this object intepreted as a float.

◆ as_int()

std::int64_t scenepic::JsonValue::as_int ( ) const

Return this object intepreted as an integer.

◆ as_string()

const std::string & scenepic::JsonValue::as_string ( ) const

Return this object interpreted as a string.

◆ lookup()

const std::map< std::string, JsonValue > & scenepic::JsonValue::lookup ( ) const

Return the key/value lookup for this JSON object.

◆ nullSingleton()

static JsonValue scenepic::JsonValue::nullSingleton ( )
static

Return a singleton representating a JSON NULL object.

◆ operator=() [1/6]

JsonValue & scenepic::JsonValue::operator= ( bool  value)

Set the value of this object to the specified value.

Parameters
valuethe value to use

◆ operator=() [2/6]

JsonValue & scenepic::JsonValue::operator= ( const char *  value)

Set the value of this object to the specified value.

Parameters
valuethe value to use

◆ operator=() [3/6]

JsonValue & scenepic::JsonValue::operator= ( const std::string &  value)

Set the value of this object to the specified value.

Parameters
valuethe value to use

◆ operator=() [4/6]

JsonValue & scenepic::JsonValue::operator= ( double  value)

Set the value of this object to the specified value.

Parameters
valuethe value to use

◆ operator=() [5/6]

JsonValue & scenepic::JsonValue::operator= ( std::int64_t  value)

Set the value of this object to the specified value.

Parameters
valuethe value to use

◆ operator=() [6/6]

JsonValue & scenepic::JsonValue::operator= ( std::string &&  value)

Set the value of this object to the specified value.

Parameters
valuethe value to use

◆ operator[]() [1/2]

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

Return the value stored in this object at the specified key.

Parameters
keythe locator key
Returns
the stored object

◆ operator[]() [2/2]

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

Return the value stored in this object at the specified key.

Parameters
keythe locator key
Returns
the stored object

◆ parse()

static JsonValue scenepic::JsonValue::parse ( std::istream &  stream)
static

Parse a JsonValue object from the provided input stream.

Parameters
streaman input stream
Returns
the stream interpreted as a JSON object

◆ resize()

void scenepic::JsonValue::resize ( std::size_t  size)

Convert this objec to an array of the specified size.

Parameters
sizethe number of elements in the array

◆ to_string()

std::string scenepic::JsonValue::to_string ( ) const

A string representation of this object in valid JSON.

◆ type()

JsonType scenepic::JsonValue::type ( ) const

The type of this object.

◆ values()

const std::vector< JsonValue > & scenepic::JsonValue::values ( ) const

Return the values of this JSON array.


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