Class Options

Class Documentation

class Options

Container for options stored as key-value pairs.

Keys are unique strings. This is not thread-safe and locking is the responsibility of the caller.

Public Functions

Options(const Options &other)
template<typename T, typename ...Args>
Options(const std::string &key, T value, Args&&... moreArgs)
Options(const YAML::Node &node)
template<typename ...Args>
Ptr<Options> with(Args&&... args) const
Options clone() const

Return a copy of the object that can be safely modified.

YAML::Node cloneToYamlNode() const
void parse(const std::string &yaml)
void merge(const YAML::Node &node, bool overwrite = false)

Splice options from a YAML node.

By default, only options with keys that do not already exist in options_ are extracted from node. These options are cloned if overwrite is true.

  • node: a YAML node to transfer the options from

  • overwrite: overwrite all options

void merge(Ptr<Options> options)
std::string asYamlString()
template<typename T>
void set(const std::string &key, T value)
template<typename T, typename ...Args>
void set(const std::string &key, T value, Args&&... moreArgs)
template<typename T>
T get(const char *const key) const
template<typename T>
T get(const std::string &key) const
template<typename T>
T get(const char *const key, T defaultValue) const
template<typename T>
T get(const std::string &key, T defaultValue) const
bool hasAndNotEmpty(const char *const key) const

Check if a sequence or string option is defined and nonempty.

Aborts if the option does not store a sequence or string value. Returns false if an option with the given key does not exist.


true if the option is defined and is a nonempty sequence or string

  • key: option name

bool hasAndNotEmpty(const std::string &key) const
bool has(const char *const key) const
bool has(const std::string &key) const

Protected Functions

void setLazyRebuild() const
void lazyRebuild() const

Protected Attributes

YAML::Node options_
FastOpt fastOptions_
bool lazyRebuildPending_ = {false}