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_value & | operator= (const json_value &x) |
json_value & | operator= (json_type *x) |
json_value & | operator= (const std::string &x) |
json_value & | operator= (const char *x) |
json_value & | operator= (double x) |
json_value & | operator= (bool x) |
json_value & | operator[] (const std::string &key) |
json_value & | operator[] (size_t index) |
const json_value & | operator[] (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
-
x Value 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
-
x A 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
-
x The 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
-
x The 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
-
x The 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
-
x The 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
-
x The boolean to initialize from.
Member Function Documentation
|
static |
Creates a json_value from the given input stream.
- Parameters
-
in The input stream to read from.
- Returns
- The newly created json_value.
|
inline |
Return true if the json_value is of concrete type T.
- Template Parameters
-
T The 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
-
x The 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
-
x The 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
-
x The 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
-
x The character array to assign from.
- Returns
- The initialized json_value.
json_value& oos::json_value::operator= | ( | double | x | ) |
Assign from a double value
- Parameters
-
x The double value to assign from.
- Returns
- The initialized json_value.
json_value& oos::json_value::operator= | ( | bool | x | ) |
Assign from a boolean value
- Parameters
-
x The 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
-
key The 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
-
index The 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
-
index The 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
-
x The 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.
|
inline |
Returns the concrete value. If the value couldn't be cast to the requested type null is returned.
- Template Parameters
-
The requested value type.
- Returns
- The concrete value of json_value.
Friends And Related Function Documentation
|
friend |
Output operator for json_value. Each concrete type overloads a print method, to have it print out correctly.
- Parameters
-
str The output stream to print on. value The json_value to print.
- Returns
- The modified output stream.
|
friend |
Input operator for a json_value.
- Parameters
-
str The input stream to read from. value The json_value read in.
- Returns
- The modified input stream.
The documentation for this class was generated from the following file:
- json/json_value.hpp