Base class for all json types.
More...
#include <json_type.hpp>
Inherited by oos::json_array, oos::json_bool, oos::json_null, oos::json_number, oos::json_object, and oos::json_string.
|
| json_type (const std::string &name) |
|
void | type (const std::string &type) |
|
Base class for all json types.
This is the base class for all json types
- array
- object
- string
- number
- boolean
- null
It provides all accessors to get the values for each concrete class.
oos::json_type::json_type |
( |
const std::string & |
name | ) |
|
|
explicitprotected |
Creates a json_type of a certain type
- Parameters
-
virtual json_value& oos::json_type::operator[] |
( |
const std::string & |
key | ) |
|
|
virtual |
Returns a json_value with the given key. If the concrete type doesn't support this method an exception is thrown.
- Parameters
-
- Returns
- the corresponding json_value.
Reimplemented in oos::json_object.
virtual json_value& oos::json_type::operator[] |
( |
size_t |
index | ) |
|
|
virtual |
Returns a json_value at the given index. If the concrete type doesn't support this method an exception is thrown.
- Parameters
-
- Returns
- the corresponding json_value.
Reimplemented in oos::json_array.
virtual const json_value& oos::json_type::operator[] |
( |
size_t |
index | ) |
const |
|
virtual |
Returns a json_value at the given index. If the concrete type doesn't support this method an exception is thrown.
- Parameters
-
- Returns
- the corresponding json_value.
Reimplemented in oos::json_array.
virtual bool oos::json_type::parse |
( |
std::istream & |
in | ) |
|
|
pure virtual |
virtual void oos::json_type::print |
( |
std::ostream & |
out | ) |
const |
|
pure virtual |
virtual void oos::json_type::push_back |
( |
const json_value & |
x | ) |
|
|
virtual |
Adds a json_value to the current value. If the concrete type doesn't support this method an exception is thrown.
- Parameters
-
Reimplemented in oos::json_array.
virtual size_t oos::json_type::size |
( |
| ) |
const |
|
virtual |
std::string oos::json_type::type |
( |
| ) |
const |
Return the type string of the json_type.
- Returns
- The type string.
void oos::json_type::type |
( |
const std::string & |
type | ) |
|
|
protected |
Sets the type string of the json_type.
- Parameters
-
type | The type string to set |
OOS_API std::ostream& operator<< |
( |
std::ostream & |
str, |
|
|
const json_type & |
value |
|
) |
| |
|
friend |
Output operator for json_type. Each concrete type overloads a print method, to have it print out correctly.
- Parameters
-
str | The output stream to print on. |
value | The json_type to print. |
- Returns
- The modified output stream.
OOS_API std::istream& operator>> |
( |
std::istream & |
str, |
|
|
json_object & |
obj |
|
) |
| |
|
friend |
Input operator for json_object. In order to parse an object the corresponding input operator needs access to json_type.
- Parameters
-
str | The input stream to print on. |
obj | The json_object to parse. |
- Returns
- The modified input stream.
OOS_API std::istream& operator>> |
( |
std::istream & |
str, |
|
|
json_array & |
obj |
|
) |
| |
|
friend |
Input operator for json_array. In order to parse an array the corresponding input operator needs access to json_type.
- Parameters
-
str | The input stream to print on. |
obj | The json_array to parse. |
- Returns
- The modified input stream.
The documentation for this class was generated from the following file: