AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::conf::Placeholders Class Reference

Configuration placeholders resolution. More...

#include <placeholders.hpp>

Collaboration diagram for anch::conf::Placeholders:

Public Member Functions

 Placeholders (anch::conf::Section &section, std::size_t maxDepth=DEFAULT_MAX_DEPTH) noexcept
 Placeholders (const Placeholders &)=delete
virtual ~Placeholders () noexcept
std::size_t resolve ()
Placeholders & operator= (const Placeholders &)=delete

Static Public Attributes

static constexpr std::size_t DEFAULT_MAX_DEPTH = 64

Detailed Description

Configuration placeholders resolution.

A placeholder is ${alternative|alternative|...} in a configuration value. An alternative is either resolver=argument (env=HOME , conf=section.key , registered resolvers) or a default value. The first alternative which resolves is used:

url=http://${env=HOST|localhost}:${conf=server.port}/

Resolution is event driven: values without pending dependency are resolved first; each resolved value is written in its section and fires a "resolved" event in a synchronous queue. Values which reference it with conf= are then completed and fire their own event, until the queue is empty.

Resolved values are literal: a value which contains ${...} after resolution (for example an environment variable) is not interpreted again. With the watchdog, resolution always terminates:

  • a resolution chain longer than the maximum depth is an error (CYCLE )
  • values still waiting when the queue is empty reference each other: the cycle is an error (CYCLE )

Other errors: unknown resolver (RES_NOT_FOUND ), placeholder without resolvable alternative (NOT_RES ), invalid syntax such as nested placeholders (PARSING_ERROR ).

Author
Vincent Lachenal
Since
0.2

Constructor & Destructor Documentation

◆ Placeholders() [1/2]

anch::conf::Placeholders::Placeholders ( anch::conf::Section & section,
std::size_t maxDepth = DEFAULT_MAX_DEPTH )
explicitnoexcept

Placeholders constructor

Parameters
sectionthe root section (resolved values are written in it)
maxDepththe maximum resolution chain length

◆ Placeholders() [2/2]

anch::conf::Placeholders::Placeholders ( const Placeholders & )
delete

Prohibit Placeholders copy

Here is the call graph for this function:

◆ ~Placeholders()

virtual anch::conf::Placeholders::~Placeholders ( )
virtualnoexcept

Placeholders destructor

Member Function Documentation

◆ operator=()

Placeholders & anch::conf::Placeholders::operator= ( const Placeholders & )
delete

Prohibit Placeholders copy

Here is the call graph for this function:

◆ resolve()

std::size_t anch::conf::Placeholders::resolve ( )

Resolve every placeholder of the section and its subsections

Returns
the number of resolved values
Exceptions
anch::conf::ConfErroron resolution error
Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_MAX_DEPTH

std::size_t anch::conf::Placeholders::DEFAULT_MAX_DEPTH = 64
staticconstexpr

Default maximum resolution chain length


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