Diag-Client-Lib
Typedefs | Enumerations | Functions
boost_support::parser Namespace Reference

Typedefs

using boost_tree = boost::property_tree::ptree
 Type alias for boost property tree. More...
 

Enumerations

enum class  ParsingErrorCode : std::uint8_t { kError = 0U }
 Definitions of Parsing failure error codes. More...
 

Functions

core_type::Result< void, ParsingErrorCodeRead (std::string_view config_path, boost_tree &json_tree)
 Parser to get the configuration from json file. More...
 

Typedef Documentation

◆ boost_tree

using boost_support::parser::boost_tree = typedef boost::property_tree::ptree

Type alias for boost property tree.

Definition at line 23 of file json_parser.h.

Enumeration Type Documentation

◆ ParsingErrorCode

enum boost_support::parser::ParsingErrorCode : std::uint8_t
strong

Definitions of Parsing failure error codes.

Enumerator
kError 

Definition at line 28 of file json_parser.h.

28 : std::uint8_t { kError = 0U };

Function Documentation

◆ Read()

core_type::Result< void, ParsingErrorCode > boost_support::parser::Read ( std::string_view  config_path,
boost_tree json_tree 
)

Parser to get the configuration from json file.

Parameters
[in]config_pathThe path to config file present
[in,out]json_treeThe config tree or success or empty on failure
Returns
The result of type void on success or error code

Definition at line 16 of file json_parser.cpp.

16  {
18  // Get the tree with configuration details
19  try {
20  boost::property_tree::read_json(std::string{config_path}, json_tree);
21  parse_result.EmplaceValue();
22  } catch (boost::property_tree::json_parser_error &error) {
23  parse_result.EmplaceError(ParsingErrorCode::kError);
24  common::logger::LibBoostLogger::GetLibBoostLogger().GetLogger().LogError(
25  __FILE__, __LINE__, __func__,
26  [&error](std::stringstream &msg) { msg << "Reading of config failed with error: " << error.message(); });
27  }
28  return parse_result;
29 }
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
Definition: result.h:29
void EmplaceValue(Args &&...args) noexcept
Put a new value into this instance, constructed in-place from the given arguments.
Definition: result.h:187

References core_type::Result< T, E >::EmplaceValue(), boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), and kError.

Referenced by diag::client::DiagClient::DiagClientImpl::Initialize().

Here is the call graph for this function:
Here is the caller graph for this function: