Template Class Config¶
Defined in File Objects.h
Inheritance Relationships¶
Base Type¶
public uconfig::Object
(Class Object)
Class Documentation¶
-
template<typename ...
FormatTs
>
classuconfig
::
Config
: public uconfig::Object¶ Configuration object.
- tparam FormatTs
Types of the formatter to parse/emit.
Public Types
-
template<typename
F
>
usingiface_type
= ConfigIface<F>¶
Public Functions
-
Config
(bool optional = false)¶ Constructor.
- Parameters
[in] optional – If section considered to be optional (may be not initialized). Default false.
-
virtual
~Config
() = default¶ Destructor.
-
template<typename
F
>
boolParse
(const F &parser, const std::string &path, const typename F::source_type *source, bool throw_on_fail = true)¶ Parse the config at
path
fromsource
usingparser
.- Template Parameters
F – Type of the parser to use. Should be one of FormatTs.
- Parameters
[in] parser – Parser instance to use.
[in] path – Path where the config resides in
source
.[in] source – Source to parse from.
[in] throw_on_fail – Will throw an uconfig::ParseError is failed to parse all mandatory children. Default true.
- Throws
uconfig::ParseError – Thrown if
throw_on_fail
.- Returns
true if config has been found in some form in the
source
, false otherwise.
-
template<typename
F
>
voidEmit
(const F &emitter, const std::string &path, typename F::dest_type *destination, bool throw_on_fail = true)¶ Emit the config at
path
todestination
usingemitter
.- Template Parameters
F – Type of the emitter to use. Should be one of FormatTs.
- Parameters
[in] emitter – Emitter instance to use.
[in] path – Path where the config should be in
destination
.[in] destination – Destination to emit into.
[in] throw_on_fail – Will throw an uconfig::EmitError is failed to emit. Default true.
- Throws
uconfig::EmitError – Thrown if
throw_on_fail
.
-
virtual bool
Initialized
() const noexcept override¶ Check if config has all mandatory values.
- Returns
true if it has, false otherwise.
-
virtual bool
Optional
() const noexcept override¶ Check if config is marked as optional.
- Returns
true if has been, false otherwise.
Protected Functions
-
virtual void
Init
(const std::string &config_path) = 0¶ Initialize config before parsing.
This function get called within Parse() and expected to register all variables in the config with respected paths. To register a variable call Register().
- Parameters
[in] config_path – Path of this config for the Format.
-
template<typename
F
, typenameT
>
voidRegister
(const std::string &element_path, T *element) noexcept¶ Register a child for this config.
This function should be called for all children of the config to get them parsed/emitted.
- Template Parameters
F – Type of the format to register for.
T – Type of element to register. Should be either uconfig::Variable, uconfig::Vector or derivative of uconfig::Config.
- Parameters
[in] element_path – Path of the child.
[in] element – Pointer to the child.
Friends
- friend class ConfigIface