Wrapper class for a concrete value. More...

#include <json_value.hpp>

Public Member Functions

 json_value ()
 
 json_value (const json_value &x)
 
 json_value (json_type *x)
 
 json_value (const std::string &x)
 
 json_value (const char *x)
 
 json_value (int x)
 
 json_value (double x)
 
 json_value (bool x)
 
json_valueoperator= (const json_value &x)
 
json_valueoperator= (json_type *x)
 
json_valueoperator= (const std::string &x)
 
json_valueoperator= (const char *x)
 
json_valueoperator= (double x)
 
json_valueoperator= (bool x)
 
json_valueoperator[] (const std::string &key)
 
json_valueoperator[] (size_t index)
 
const json_valueoperator[] (size_t index) const
 
void push_back (const json_value &x)
 
size_t size () const
 
template<class T >
bool is_type () const
 
template<class T >
const T * value_type () const
 

Static Public Member Functions

static json_value create (std::istream &in)
 

Friends

OOS_API std::istream & operator>> (std::istream &str, json_value &value)
 
OOS_API std::ostream & operator<< (std::ostream &str, const json_value &value)
 

Detailed Description

Wrapper class for a concrete value.

This class is a wrapper class for a concrete value. It holds an object of json_type which implements the concrete type.

Constructor & Destructor Documentation

oos::json_value::json_value ( )

Default constructor

oos::json_value::json_value ( const json_value x)

Copy constructor

Parameters
xValue to copy from.
oos::json_value::json_value ( json_type x)

Creates a new json_value and initializes it with a concrete json_type.

Parameters
xA concrete json_type object.
oos::json_value::json_value ( const std::string &  x)

Creates a new json_value and initializes it with a string. Internaly an object of type json_string is created.

Parameters
xThe string to initialize from.
oos::json_value::json_value ( const char *  x)

Creates a new json_value and initializes it with a string. Internaly an object of type json_string is created.

Parameters
xThe string to initialize from.
oos::json_value::json_value ( int  x)

Creates a new json_value and initializes it with a integer. Internaly an object of type json_number is created.

Parameters
xThe integer to initialize from.
oos::json_value::json_value ( double  x)

Creates a new json_value and initializes it with a double. Internaly an object of type json_number is created.

Parameters
xThe double to initialize from.
oos::json_value::json_value ( bool  x)

Creates a new json_value and initializes it with a boolean. Internaly an object of type json_bool is created.

Parameters
xThe boolean to initialize from.

Member Function Documentation

static json_value oos::json_value::create ( std::istream &  in)
static

Creates a json_value from the given input stream.

Parameters
inThe input stream to read from.
Returns
The newly created json_value.
template<class T >
bool oos::json_value::is_type ( ) const
inline

Return true if the json_value is of concrete type T.

Template Parameters
TThe requested type info
Returns
True if the type matches
json_value& oos::json_value::operator= ( const json_value x)

Assign from a json_value

Parameters
xThe json_value to assign from.
Returns
The initialized json_value.
json_value& oos::json_value::operator= ( json_type x)

Assign from a json_type

Parameters
xThe json_type to assign from.
Returns
The initialized json_value.
json_value& oos::json_value::operator= ( const std::string &  x)

Assign from a std::string

Parameters
xThe std::string to assign from.
Returns
The initialized json_value.
json_value& oos::json_value::operator= ( const char *  x)

Assign from a character array

Parameters
xThe character array to assign from.
Returns
The initialized json_value.
json_value& oos::json_value::operator= ( double  x)

Assign from a double value

Parameters
xThe double value to assign from.
Returns
The initialized json_value.
json_value& oos::json_value::operator= ( bool  x)

Assign from a boolean value

Parameters
xThe boolean value to assign from.
Returns
The initialized json_value.
json_value& oos::json_value::operator[] ( const std::string &  key)

Returns a json_value with the given key. If the concrete type doesn't support this method an exception is thrown.

Parameters
keyThe key of the json_value.
Returns
the corresponding json_value.
json_value& oos::json_value::operator[] ( size_t  index)

Returns a json_value at the given index. If the concrete type doesn't support this method an exception is thrown.

Parameters
indexThe index of the json_value.
Returns
the corresponding json_value.
const json_value& oos::json_value::operator[] ( size_t  index) const

Returns a json_value at the given index. If the concrete type doesn't support this method an exception is thrown.

Parameters
indexThe index of the json_value.
Returns
the corresponding json_value.
void oos::json_value::push_back ( const json_value x)

Adds a json_value to the current value. If the concrete type doesn't support this method an exception is thrown.

Parameters
xThe json_value to add.
size_t oos::json_value::size ( ) const

Returns the size of the json_value. If the concrete type doesn't support this method an exception is thrown.

Returns
The size of the json_value.
template<class T >
const T* oos::json_value::value_type ( ) const
inline

Returns the concrete value. If the value couldn't be cast to the requested type null is returned.

Template Parameters
Therequested value type.
Returns
The concrete value of json_value.

Friends And Related Function Documentation

OOS_API std::ostream& operator<< ( std::ostream &  str,
const json_value value 
)
friend

Output operator for json_value. Each concrete type overloads a print method, to have it print out correctly.

Parameters
strThe output stream to print on.
valueThe json_value to print.
Returns
The modified output stream.
OOS_API std::istream& operator>> ( std::istream &  str,
json_value value 
)
friend

Input operator for a json_value.

Parameters
strThe input stream to read from.
valueThe json_value read in.
Returns
The modified input stream.

The documentation for this class was generated from the following file:
  • json/json_value.hpp