CppZmqZoltanExt 0.0.1
Loading...
Searching...
No Matches
zmqzext::zpl_config_t Class Reference

ZPL configuration tree loaded from text or file. More...

#include <zpl_config.h>

Classes

struct  impl_t
 

Public Member Functions

 zpl_config_t () noexcept
 Construct an empty configuration.
 
 zpl_config_t (std::istream &input)
 Construct and parse a configuration from a stream.
 
void load (std::istream &input)
 Load configuration data from a stream.
 
void load_from_file (const std::string &file_path)
 Load configuration data from a file.
 
bool empty () const noexcept
 Check whether the configuration is empty.
 
const std::string & name () const noexcept
 Get the node name.
 
const std::string & value () const noexcept
 Get the node value.
 
bool contains (const std::string &path) const noexcept
 Check if a path exists.
 
const std::string & get (const std::string &path) const
 Get a property value by path.
 
std::optional< std::string > try_get (const std::string &path) const noexcept
 Try to get a property value by path.
 
std::string get_or (const std::string &path, std::string default_value) const noexcept
 Get a property value or return a default.
 
zpl_config_t child (const std::string &path) const
 Get a child node by path.
 
std::optional< zpl_config_ttry_child (const std::string &path) const noexcept
 Try to get a child node by path.
 
std::vector< zpl_config_tchildren () const noexcept
 Get direct children of this node.
 

Static Public Member Functions

static zpl_config_t from_stream (std::istream &input)
 Parse and return a configuration from a stream.
 
static zpl_config_t from_file (const std::string &file_path)
 Parse and return a configuration from a file.
 

Detailed Description

ZPL configuration tree loaded from text or file.

The zpl_config_t class provides a read-only view over a parsed ZPL (ZeroMQ Property Language) configuration. Each instance represents a node in the configuration tree. Nodes expose their name and value, and can be queried for children by path.

Paths are expressed in ZPL relative/path/to/property notation (e.g. "child/key") relative to the current configuration node. A property in the tree can be accessed by its full path from the root or by navigating through all path segments. Query methods throw when a path is invalid or missing, while try_* variants return empty optionals or defaults.

Note
This class is not thread-safe.

Definition at line 137 of file zpl_config.h.

Constructor & Destructor Documentation

◆ zpl_config_t() [1/2]

zmqzext::zpl_config_t::zpl_config_t ( )
noexcept

Construct an empty configuration.

Definition at line 374 of file zpl_config.cpp.

◆ zpl_config_t() [2/2]

zmqzext::zpl_config_t::zpl_config_t ( std::istream &  input)
explicit

Construct and parse a configuration from a stream.

Parameters
inputInput stream containing ZPL text
Exceptions
zpl_parse_erroron parse errors
std::ios_base::failureif any error during input reading occurs

Definition at line 378 of file zpl_config.cpp.

Member Function Documentation

◆ child()

zpl_config_t zmqzext::zpl_config_t::child ( const std::string &  path) const

Get a child node by path.

Parameters
pathZPL path to a property relative to this node
Returns
Child configuration node
Exceptions
zpl_property_not_foundif the path does not exist

Definition at line 446 of file zpl_config.cpp.

◆ children()

std::vector< zpl_config_t > zmqzext::zpl_config_t::children ( ) const
noexcept

Get direct children of this node.

Returns
Vector of child configuration nodes

Definition at line 468 of file zpl_config.cpp.

◆ contains()

bool zmqzext::zpl_config_t::contains ( const std::string &  path) const
noexcept

Check if a path exists.

Parameters
pathZPL path to a property relative to this node
Returns
true if the path exists, false otherwise

Definition at line 418 of file zpl_config.cpp.

◆ empty()

bool zmqzext::zpl_config_t::empty ( ) const
noexcept

Check whether the configuration is empty.

Returns
true if no root node is present, false otherwise

Definition at line 402 of file zpl_config.cpp.

◆ from_file()

zpl_config_t zmqzext::zpl_config_t::from_file ( const std::string &  file_path)
static

Parse and return a configuration from a file.

Parameters
file_pathPath to the ZPL file
Returns
Parsed configuration
Exceptions
zpl_parse_erroron parse errors
std::ios_base::failureif the path is invalid or any error during file reading occurs

Definition at line 386 of file zpl_config.cpp.

◆ from_stream()

zpl_config_t zmqzext::zpl_config_t::from_stream ( std::istream &  input)
static

Parse and return a configuration from a stream.

Parameters
inputInput stream containing ZPL text
Returns
Parsed configuration
Exceptions
zpl_parse_erroron parse errors
std::ios_base::failureif any error during input reading occurs

Definition at line 380 of file zpl_config.cpp.

◆ get()

const std::string & zmqzext::zpl_config_t::get ( const std::string &  path) const

Get a property value by path.

Parameters
pathZPL path to a property relative to this node
Returns
Property value
Exceptions
zpl_property_not_foundif the path does not exist

Definition at line 422 of file zpl_config.cpp.

◆ get_or()

std::string zmqzext::zpl_config_t::get_or ( const std::string &  path,
std::string  default_value 
) const
noexcept

Get a property value or return a default.

Parameters
pathZPL path to a property relative to this node
default_valueValue returned when the property is not found
Returns
Property value if found, otherwise default_value

Definition at line 438 of file zpl_config.cpp.

◆ load()

void zmqzext::zpl_config_t::load ( std::istream &  input)

Load configuration data from a stream.

Replaces the current configuration with the parsed content.

Parameters
inputInput stream containing ZPL text
Exceptions
zpl_parse_erroron parse errors
std::ios_base::failureif any error during input reading occurs

Definition at line 392 of file zpl_config.cpp.

◆ load_from_file()

void zmqzext::zpl_config_t::load_from_file ( const std::string &  file_path)

Load configuration data from a file.

Replaces the current configuration with the parsed content.

Parameters
file_pathPath to the ZPL file
Exceptions
zpl_parse_erroron parse errors
std::ios_base::failureif the path is invalid or any error during file reading occurs

Definition at line 394 of file zpl_config.cpp.

◆ name()

const std::string & zmqzext::zpl_config_t::name ( ) const
noexcept

Get the node name.

Returns
Node name

Definition at line 404 of file zpl_config.cpp.

◆ try_child()

std::optional< zpl_config_t > zmqzext::zpl_config_t::try_child ( const std::string &  path) const
noexcept

Try to get a child node by path.

Parameters
pathZPL path to a property relative to this node
Returns
Child configuration node if found, std::nullopt otherwise

Definition at line 457 of file zpl_config.cpp.

◆ try_get()

std::optional< std::string > zmqzext::zpl_config_t::try_get ( const std::string &  path) const
noexcept

Try to get a property value by path.

Parameters
pathZPL path to a property relative to this node
Returns
Property value if found, std::nullopt otherwise

Definition at line 430 of file zpl_config.cpp.

◆ value()

const std::string & zmqzext::zpl_config_t::value ( ) const
noexcept

Get the node value.

Returns
Node value

Definition at line 411 of file zpl_config.cpp.


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