Fawkes API  Fawkes Development Version
ConfigTree Class Reference

ConfigTree representation for JSON transfer. More...

#include <ConfigTree.h>

Public Member Functions

 ConfigTree ()
 Constructor. More...
 
 ConfigTree (const std::string &json)
 Constructor from JSON. More...
 
 ConfigTree (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual std::string to_json (bool pretty=false) const
 Render object to JSON. More...
 
virtual void to_json_value (rapidjson::Document &d, rapidjson::Value &v) const
 Render object to JSON. More...
 
virtual void from_json (const std::string &json)
 Retrieve data from JSON string. More...
 
virtual void from_json_value (const rapidjson::Value &v)
 Retrieve data from JSON string. More...
 
virtual void validate (bool subcall=false) const
 Validate if all required fields have been set. More...
 
std::optional< std::string > kind () const
 Get kind value. More...
 
void set_kind (const std::string &kind)
 Set kind value. More...
 
std::optional< std::string > apiVersion () const
 Get apiVersion value. More...
 
void set_apiVersion (const std::string &apiVersion)
 Set apiVersion value. More...
 
std::shared_ptr< rapidjson::Document > config () const
 Get config value. More...
 
void set_config (const std::shared_ptr< rapidjson::Document > &config)
 Set config value. More...
 

Static Public Member Functions

static std::string api_version ()
 Get version of implemented API. More...
 

Detailed Description

ConfigTree representation for JSON transfer.

Definition at line 25 of file ConfigTree.h.

Constructor & Destructor Documentation

◆ ConfigTree() [1/3]

ConfigTree::ConfigTree ( )

Constructor.

Definition at line 22 of file ConfigTree.cpp.

◆ ConfigTree() [2/3]

ConfigTree::ConfigTree ( const std::string &  json)

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 26 of file ConfigTree.cpp.

References from_json().

◆ ConfigTree() [3/3]

ConfigTree::ConfigTree ( const rapidjson::Value &  v)

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 31 of file ConfigTree.cpp.

References from_json_value().

Member Function Documentation

◆ api_version()

static std::string ConfigTree::api_version ( )
inlinestatic

Get version of implemented API.

Returns
string representation of version

Definition at line 44 of file ConfigTree.h.

◆ apiVersion()

std::optional<std::string> ConfigTree::apiVersion ( ) const
inline

Get apiVersion value.

Returns
apiVersion value

Definition at line 105 of file ConfigTree.h.

Referenced by set_apiVersion().

◆ config()

std::shared_ptr<rapidjson::Document> ConfigTree::config ( ) const
inline

Get config value.

Returns
config value

Definition at line 122 of file ConfigTree.h.

Referenced by set_config().

◆ from_json()

void ConfigTree::from_json ( const std::string &  json)
virtual

Retrieve data from JSON string.

Parameters
jsonJSON representation suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 79 of file ConfigTree.cpp.

References from_json_value().

Referenced by ConfigTree().

◆ from_json_value()

void ConfigTree::from_json_value ( const rapidjson::Value &  v)
virtual

Retrieve data from JSON string.

Parameters
vRapidJSON value suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 88 of file ConfigTree.cpp.

Referenced by ConfigTree(), and from_json().

◆ kind()

std::optional<std::string> ConfigTree::kind ( ) const
inline

Get kind value.

Returns
kind value

Definition at line 88 of file ConfigTree.h.

Referenced by set_kind().

◆ set_apiVersion()

void ConfigTree::set_apiVersion ( const std::string &  apiVersion)
inline

Set apiVersion value.

Parameters
apiVersionnew value

Definition at line 114 of file ConfigTree.h.

References apiVersion().

◆ set_config()

void ConfigTree::set_config ( const std::shared_ptr< rapidjson::Document > &  config)
inline

Set config value.

Parameters
confignew value

Definition at line 131 of file ConfigTree.h.

References config().

◆ set_kind()

void ConfigTree::set_kind ( const std::string &  kind)
inline

Set kind value.

Parameters
kindnew value

Definition at line 97 of file ConfigTree.h.

References kind().

◆ to_json()

std::string ConfigTree::to_json ( bool  pretty = false) const
virtual

Render object to JSON.

Parameters
prettytrue to enable pretty printing (readable spacing)
Returns
JSON string

Definition at line 37 of file ConfigTree.cpp.

References to_json_value().

◆ to_json_value()

void ConfigTree::to_json_value ( rapidjson::Document &  d,
rapidjson::Value &  v 
) const
virtual

Render object to JSON.

Parameters
dRapidJSON document to retrieve allocator from
vRapidJSON value to add data to

Definition at line 56 of file ConfigTree.cpp.

Referenced by to_json().

◆ validate()

void ConfigTree::validate ( bool  subcall = false) const
virtual

Validate if all required fields have been set.

Parameters
subcalltrue if this is called from another class, e.g., a sub-class or array holder. Will modify the kind of exception thrown.
Exceptions
std::vector<std::string>thrown if required information is missing and subcall is set to true. Contains a list of missing fields.
std::runtime_errorinformative message describing the missing fields

Definition at line 103 of file ConfigTree.cpp.


The documentation for this class was generated from the following files: