NGen
|
@TODO: Convert JSONProperty into a variant of the supported types
More...
#include <JSONProperty.hpp>
Classes | |
struct | AsVectorVisitor |
Visitor to filter boost variants by type T into a vector of type T. More... | |
Public Member Functions | |
JSONProperty (std::string value_key, const boost::property_tree::ptree &property_tree) | |
JSONProperty (std::string value_key, short value) | |
Create a JSONProperty that stores a natural number. | |
JSONProperty (std::string value_key, int value) | |
Create a JSONProperty that stores a natural number. | |
JSONProperty (std::string value_key, long value) | |
Create a JSONProperty that stores a natural number. | |
JSONProperty (std::string value_key, float value) | |
Create a JSONProperty that stores a floating point number. | |
JSONProperty (std::string value_key, double value) | |
Create a JSONProperty that stores a floating point number. | |
JSONProperty (std::string value_key, const char *value) | |
Create a JSONProperty that stores text. | |
JSONProperty (std::string value_key, std::string value) | |
Create a JSONProperty that stores text. | |
JSONProperty (std::string value_key, std::vector< JSONProperty > properties) | |
JSONProperty (const JSONProperty &original) | |
JSONProperty (const std::string &value_key, const JSONProperty &original) | |
Copy construct a JSONProperty, but use a new key value for the property. | |
virtual | ~JSONProperty () |
A basic destructor. | |
JSONProperty (std::string value_key, bool value) | |
Create a JSONProperty that stores a true or false value. | |
JSONProperty (std::string value_key, PropertyMap &value) | |
Create a JSONProperty that stores a nested map of properties. | |
PropertyType | get_type () const |
Get the type of the property (Natural, Real, String, etc) | |
long | as_natural_number () const |
Attempt to get the natural numeric value stored within the property. | |
double | as_real_number () const |
bool | as_boolean () const |
template<typename T > | |
void | as_vector (std::vector< T > &vector) const |
Populates a std::vector<T> with PropertyVariant values. | |
std::vector< JSONProperty > | as_list () const |
std::vector< long > | as_natural_vector () const |
std::vector< double > | as_real_vector () const |
std::vector< std::string > | as_string_vector () const |
std::vector< bool > | as_boolean_vector () const |
std::string | as_string () const |
JSONProperty | at (std::string key) const |
std::vector< std::string > | keys () const |
std::map< std::string, JSONProperty > | get_values () const |
std::string | get_key () const |
bool | has_key (std::string key) const |
bool | operator== (const JSONProperty &other) const |
bool | operator!= (const JSONProperty &other) |
Static Public Member Functions | |
static void | print_property (const geojson::JSONProperty &p, int tab=0, bool newline=true) |
Pretty print the property to standard out stream. | |
Private Attributes | |
std::string | key |
PropertyType | type |
PropertyMap | values |
std::vector< JSONProperty > | value_list |
PropertyVariant | data |
@TODO: Convert JSONProperty into a variant of the supported types
Object used to store basic geojson property data
|
inline |
Referenced by as_list().
|
inline |
Create a JSONProperty that stores a natural number.
value_key | The name of the key that stores this value |
value | The natural number that will be stored |
References geojson::Natural.
|
inline |
Create a JSONProperty that stores a natural number.
value_key | The name of the key that stores this value |
value | The natural number that will be stored |
References geojson::Natural.
|
inline |
Create a JSONProperty that stores a natural number.
value_key | The name of the key that stores this value |
value | The natural number that will be stored |
References geojson::Natural.
|
inline |
Create a JSONProperty that stores a floating point number.
value_key | The name of the key that stores this value |
value | The floating point number that will be stored |
References geojson::Real.
|
inline |
Create a JSONProperty that stores a floating point number.
value_key | The name of the key that stores this value |
value | The floating point number that will be stored |
References geojson::Real.
|
inline |
Create a JSONProperty that stores text.
value_key | The name of the key that stores this value |
value | The text that will be stored |
References geojson::String.
|
inline |
Create a JSONProperty that stores text.
value_key | The name of the key that stores this value |
value | The text that will be stored |
|
inline |
|
inline |
References data, key, type, value_list, and values.
|
inline |
Copy construct a JSONProperty, but use a new key value for the property.
value_key | |
original |
|
inlinevirtual |
A basic destructor.
|
inline |
Create a JSONProperty that stores a true or false value.
value_key | The name of the key that stores this value |
value | The true or false value that will be stored |
References geojson::Boolean.
|
inline |
Create a JSONProperty that stores a nested map of properties.
value_key | The name of the key that stores this value |
value | A map of nested properties that will be stored |
bool JSONProperty::as_boolean | ( | ) | const |
References geojson::Boolean, data, geojson::get_propertytype_name(), get_type(), key, and type.
Referenced by print_property().
std::vector< bool > JSONProperty::as_boolean_vector | ( | ) | const |
References as_vector(), and values.
std::vector< JSONProperty > JSONProperty::as_list | ( | ) | const |
References JSONProperty(), geojson::get_propertytype_name(), get_type(), key, geojson::List, geojson::Object, type, and value_list.
Referenced by Partitions_Parser::parse_partition_file(), and print_property().
long JSONProperty::as_natural_number | ( | ) | const |
Attempt to get the natural numeric value stored within the property.
An exception will be thrown if this property doesn't store a natural number
References data, geojson::get_propertytype_name(), get_type(), key, geojson::Natural, and type.
Referenced by print_property().
std::vector< long > JSONProperty::as_natural_vector | ( | ) | const |
References as_vector(), and values.
double JSONProperty::as_real_number | ( | ) | const |
References data, geojson::get_propertytype_name(), get_type(), key, geojson::Natural, geojson::Real, and type.
Referenced by realization::Bmi_Multi_Formulation::create_multi_formulation(), and print_property().
std::vector< double > JSONProperty::as_real_vector | ( | ) | const |
References as_vector(), and values.
std::string JSONProperty::as_string | ( | ) | const |
References geojson::Boolean, data, geojson::get_propertytype_name(), get_type(), key, geojson::List, geojson::Natural, geojson::Real, geojson::String, type, and value_list.
Referenced by realization::Bmi_Multi_Formulation::create_multi_formulation(), geojson::FeatureBase::get_id(), and print_property().
std::vector< std::string > JSONProperty::as_string_vector | ( | ) | const |
References as_vector(), and values.
|
inline |
Populates a std::vector<T> with PropertyVariant values.
Scalar properties will yeild a vector of size 1.
List properties will yield a vector of compatible types. E.g. a List with [1, 2.1, 3] can upcast the Natural number 1 and 3 iff a container is provided with sufficient datatype (double)
std::vector<double> double_vec; as_vector(double_vec);
Will give a vector of doubles = {1.0, 2.1, 3.0}.
However, if a vector of long is used, only the Natural numbers will be extracted
std::vector<long> long_vec; as_vector(long_vec);
Will give a vector of longs = {1, 3}.
Other than this caveat, as_vector effetively filters the property list for types representable by T.
T |
vector |
Referenced by as_boolean_vector(), as_natural_vector(), as_real_vector(), and as_string_vector().
JSONProperty JSONProperty::at | ( | std::string | key | ) | const |
References geojson::get_propertytype_name(), get_type(), key, geojson::Object, type, and values.
Referenced by realization::Bmi_Multi_Formulation::create_multi_formulation(), operator==(), and Partitions_Parser::parse_partition_file().
std::string JSONProperty::get_key | ( | ) | const |
References key.
PropertyType JSONProperty::get_type | ( | ) | const |
Get the type of the property (Natural, Real, String, etc)
References type.
Referenced by as_boolean(), as_list(), as_natural_number(), as_real_number(), as_string(), at(), get_values(), keys(), Partitions_Parser::parse_partition_file(), and print_property().
PropertyMap JSONProperty::get_values | ( | ) | const |
References geojson::get_propertytype_name(), get_type(), key, geojson::Object, type, and values.
Referenced by print_property().
std::vector< std::string > JSONProperty::keys | ( | ) | const |
References geojson::get_propertytype_name(), get_type(), key, geojson::Object, type, and values.
Referenced by has_key(), and operator==().
|
inline |
|
inline |
|
inlinestatic |
Pretty print the property to standard out stream.
Recurses through the property to tab/print nested objects/lists.
p | Property to print |
tab | (optional) Additional starting tab to indent (default 0) |
newline | (optional) Add a new line to the end of the print (default true) |
References as_boolean(), as_list(), as_natural_number(), as_real_number(), as_string(), geojson::Boolean, get_type(), get_values(), geojson::List, geojson::Natural, geojson::Object, geojson::Real, and geojson::String.
Referenced by realization::config::Formulation::Formulation().
|
private |
Referenced by JSONProperty(), as_boolean(), as_natural_number(), as_real_number(), as_string(), and operator==().
|
private |
Referenced by JSONProperty(), as_boolean(), as_list(), as_natural_number(), as_real_number(), as_string(), at(), get_key(), get_values(), has_key(), and keys().
|
private |
Referenced by JSONProperty(), as_boolean(), as_list(), as_natural_number(), as_real_number(), as_string(), at(), get_type(), get_values(), keys(), and operator==().
|
private |
Referenced by JSONProperty(), as_list(), and as_string().
|
private |
Referenced by JSONProperty(), as_boolean_vector(), as_natural_vector(), as_real_vector(), as_string_vector(), at(), get_values(), keys(), and operator==().