|
DiFfRG
|
A wrapper around the boost json value class. More...
#include <json.hh>
Public Member Functions | |
| JSONValue () | |
| Construct an empty JSONValue object. | |
| JSONValue (const std::string filename) | |
| Construct a new JSONValue object from a json file. | |
| JSONValue (const json::value &v) | |
| Construct a new JSONValue object. | |
| json::value & | operator() () |
| The call operator gives access to the wrapped json value. | |
| operator json::value () const | |
| The call operator gives access to the wrapped json value. | |
| bool | operator== (const JSONValue &other) const |
| Equality operator. Checks all values in the json object to be equal. | |
| double | get_double (const std::string &key) const |
| Get the value of a key in the json object. | |
| int | get_int (const std::string &key) const |
| Get the value of a key in the json object. | |
| uint | get_uint (const std::string &key) const |
| Get the value of a key in the json object. | |
| std::string | get_string (const std::string &key) const |
| Get the value of a key in the json object. | |
| bool | get_bool (const std::string &key) const |
| Get the value of a key in the json object. | |
| double | get_double (const std::string &key, const double def) const |
| Get the value of a key in the json object, with a default value. | |
| int | get_int (const std::string &key, const int def) const |
| Get the value of a key in the json object, with a default value. | |
| uint | get_uint (const std::string &key, const uint def) const |
| Get the value of a key in the json object, with a default value. | |
| std::string | get_string (const std::string &key, const std::string &def) const |
| Get the value of a key in the json object, with a default value. | |
| bool | get_bool (const std::string &key, const bool def) const |
| Get the value of a key in the json object, with a default value. | |
| void | set_double (const std::string &key, double value) |
| Set the value of a key in the json object. | |
| void | set_int (const std::string &key, int value) |
| Set the value of a key in the json object. | |
| void | set_uint (const std::string &key, uint value) |
| Set the value of a key in the json object. | |
| void | set_string (const std::string &key, const std::string &value) |
| Set the value of a key in the json object. | |
| void | set_bool (const std::string &key, bool value) |
| Set the value of a key in the json object. | |
| void | print (std::ostream &os) const |
| Pretty-print the json value to a stream. | |
Private Member Functions | |
| void | pretty_print (std::ostream &os, json::value const &v, std::string *indent=nullptr) const |
Private Attributes | |
| json::value | value |
A wrapper around the boost json value class.
This class allows to easily access and modify the values stored in a json object.
| DiFfRG::JSONValue::JSONValue | ( | ) |
Construct an empty JSONValue object.
| DiFfRG::JSONValue::JSONValue | ( | const std::string | filename | ) |
Construct a new JSONValue object from a json file.
| filename | The name of the file to read. |
| DiFfRG::JSONValue::JSONValue | ( | const json::value & | v | ) |
Construct a new JSONValue object.
| v | The json value to wrap. |
| bool DiFfRG::JSONValue::get_bool | ( | const std::string & | key | ) | const |
Get the value of a key in the json object.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| bool DiFfRG::JSONValue::get_bool | ( | const std::string & | key, |
| const bool | def ) const |
Get the value of a key in the json object, with a default value.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| def | The default value to return if the key is not found. |
| double DiFfRG::JSONValue::get_double | ( | const std::string & | key | ) | const |
Get the value of a key in the json object.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| double DiFfRG::JSONValue::get_double | ( | const std::string & | key, |
| const double | def ) const |
Get the value of a key in the json object, with a default value.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| def | The default value to return if the key is not found. |
| int DiFfRG::JSONValue::get_int | ( | const std::string & | key | ) | const |
Get the value of a key in the json object.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| int DiFfRG::JSONValue::get_int | ( | const std::string & | key, |
| const int | def ) const |
Get the value of a key in the json object, with a default value.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| def | The default value to return if the key is not found. |
| std::string DiFfRG::JSONValue::get_string | ( | const std::string & | key | ) | const |
Get the value of a key in the json object.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| std::string DiFfRG::JSONValue::get_string | ( | const std::string & | key, |
| const std::string & | def ) const |
Get the value of a key in the json object, with a default value.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| def | The default value to return if the key is not found. |
| uint DiFfRG::JSONValue::get_uint | ( | const std::string & | key | ) | const |
Get the value of a key in the json object.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
Get the value of a key in the json object, with a default value.
| key | The key to get the value for. Format: "/category/subcategory/.../key". |
| def | The default value to return if the key is not found. |
| DiFfRG::JSONValue::operator json::value | ( | ) | const |
The call operator gives access to the wrapped json value.
| json::value & DiFfRG::JSONValue::operator() | ( | ) |
The call operator gives access to the wrapped json value.
| bool DiFfRG::JSONValue::operator== | ( | const JSONValue & | other | ) | const |
Equality operator. Checks all values in the json object to be equal.
|
private |
| void DiFfRG::JSONValue::print | ( | std::ostream & | os | ) | const |
Pretty-print the json value to a stream.
| void DiFfRG::JSONValue::set_bool | ( | const std::string & | key, |
| bool | value ) |
Set the value of a key in the json object.
| key | The key to set the value for. Format: "/category/subcategory/.../key". |
| value | The value to set. |
| void DiFfRG::JSONValue::set_double | ( | const std::string & | key, |
| double | value ) |
Set the value of a key in the json object.
| key | The key to set the value for. Format: "/category/subcategory/.../key". |
| value | The value to set. |
| void DiFfRG::JSONValue::set_int | ( | const std::string & | key, |
| int | value ) |
Set the value of a key in the json object.
| key | The key to set the value for. Format: "/category/subcategory/.../key". |
| value | The value to set. |
| void DiFfRG::JSONValue::set_string | ( | const std::string & | key, |
| const std::string & | value ) |
Set the value of a key in the json object.
| key | The key to set the value for. Format: "/category/subcategory/.../key". |
| value | The value to set. |
| void DiFfRG::JSONValue::set_uint | ( | const std::string & | key, |
| uint | value ) |
Set the value of a key in the json object.
| key | The key to set the value for. Format: "/category/subcategory/.../key". |
| value | The value to set. |
|
private |