MySQL 9.1.0
Source Code Documentation
keyring_common::config::Config_reader Class Reference

#include <config_reader.h>

Public Member Functions

 Config_reader (std::string config_file_path)
 Constructor. More...
 
template<typename T >
bool get_element (const std::string &element_name, T &element_value, const Config_object &parent=nullptr)
 Get an element value from parent element or top level of JSON document. More...
 
bool get_element (const std::string &element_name, Config_object &element_value)
 Get an object element from top level of JSON document. More...
 
bool get_element (const Config_object &parent, const std::string &element_name, Config_object &element_value)
 Get an object element value from parent element of JSON document. More...
 
bool is_valid (std::string &err) const
 Check if the object is valid, in particular if there was no parse error. More...
 

Private Member Functions

template<typename P , typename T >
bool get_element_inner (const P &parent, const std::string &element_name, T &element_value)
 Get an element value. More...
 

Private Attributes

std::string config_file_path_
 Configuration file path. More...
 
rapidjson::Document data_
 Configuration data in JSON. More...
 
bool valid_
 Validity of configuration data. More...
 
std::string err_
 When not valid: cause of invalidity of configuration data. More...
 

Constructor & Destructor Documentation

◆ Config_reader()

keyring_common::config::Config_reader::Config_reader ( std::string  config_file_path)
explicit

Constructor.

Reads JSON from config file and stores it in memory.

Parameters
[in]config_file_pathFull path to configuration file

Member Function Documentation

◆ get_element() [1/3]

bool keyring_common::config::Config_reader::get_element ( const Config_object parent,
const std::string &  element_name,
Config_object element_value 
)
inline

Get an object element value from parent element of JSON document.

Parameters
[in]parentparent element
[in]element_nameName of the element being searched
[out]element_valueObject element
Returns
status of search operation
Return values
falseSuccess. Refer to element_value
trueFailure.

◆ get_element() [2/3]

bool keyring_common::config::Config_reader::get_element ( const std::string &  element_name,
Config_object element_value 
)
inline

Get an object element from top level of JSON document.

Parameters
[in]element_nameName of the element being searched
[out]element_valueObject element
Returns
status of search operation
Return values
falseSuccess. Refer to element_value
trueFailure.

◆ get_element() [3/3]

template<typename T >
bool keyring_common::config::Config_reader::get_element ( const std::string &  element_name,
T &  element_value,
const Config_object parent = nullptr 
)
inline

Get an element value from parent element or top level of JSON document.

Template Parameters
TType of the element value

Assumption: Type is compatible with Get() function and type of element is matching with template argument.

Parameters
[in]element_nameName of the element being searched
[out]element_valueValue of the element
[in]parentParent element, if null top level is being searched
Returns
status of search operation
Return values
falseSuccess. Refer to element_value
trueFailure.

◆ get_element_inner()

template<typename P , typename T >
bool keyring_common::config::Config_reader::get_element_inner ( const P parent,
const std::string &  element_name,
T &  element_value 
)
inlineprivate

Get an element value.

Template Parameters
PType of the parent
TType of the element value

Assumption: Type is compatible with Get() function and type of element is matching with template argument.

Parameters
[in]parentparent element
[in]element_nameName of the element being searched
[out]element_valueValue of the element
Returns
status of search operation
Return values
falseSuccess. Refer to element_value
trueFailure.

◆ is_valid()

bool keyring_common::config::Config_reader::is_valid ( std::string &  err) const
inline

Check if the object is valid, in particular if there was no parse error.

Parameters
[out]errwhen not valid: cause of invalidity
Returns
validity status
Return values
falseobject not valid, an error occured while creation
trueobject is valid

Member Data Documentation

◆ config_file_path_

std::string keyring_common::config::Config_reader::config_file_path_
private

Configuration file path.

◆ data_

rapidjson::Document keyring_common::config::Config_reader::data_
private

Configuration data in JSON.

◆ err_

std::string keyring_common::config::Config_reader::err_
private

When not valid: cause of invalidity of configuration data.

◆ valid_

bool keyring_common::config::Config_reader::valid_
private

Validity of configuration data.


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