All the config data will be stored and extracted from this class.
More...
#include <ConfigDefinition.hpp>
|
using | KeyValuePair = std::pair<std::string_view, std::variant<ConfigValue, Array>> |
|
|
| ClioConfigDefinition (std::initializer_list< KeyValuePair > pair) |
| Constructs a new ClioConfigDefinition.
|
|
std::optional< std::vector< Error > > | parse (ConfigFileInterface const &config) |
| Parses the configuration file.
|
|
ObjectView | getObject (std::string_view prefix, std::optional< std::size_t > idx=std::nullopt) const |
| Returns the ObjectView specified with the prefix.
|
|
ValueView | getValueView (std::string_view fullKey) const |
| Returns the specified ValueView object associated with the key.
|
|
template<typename T > |
T | get (std::string_view fullKey) const |
| Returns the specified value of given string if value exists.
|
|
ValueView | getValueInArray (std::string_view fullKey, std::size_t index) const |
| Returns the specified ValueView object in an array with a given index.
|
|
ArrayView | getArray (std::string_view prefix) const |
| Returns the specified Array object from ClioConfigDefinition.
|
|
bool | contains (std::string_view key) const |
| Checks if a key is present in the configuration map.
|
|
bool | hasItemsWithPrefix (std::string_view key) const |
| Checks if any key in config starts with "key".
|
|
Array const & | asArray (std::string_view key) const |
| Returns the Array object associated with the specified key.
|
|
std::size_t | arraySize (std::string_view prefix) const |
| Returns the size of an Array.
|
|
template<typename T > |
std::optional< T > | maybeValue (std::string_view fullKey) const |
| Returns the specified value of given string of type T if type and value exists.
|
|
auto | begin () const |
| Returns an iterator to the beginning of the configuration map.
|
|
auto | end () const |
| Returns an iterator to the end of the configuration map.
|
|
|
static std::chrono::milliseconds | toMilliseconds (float value) |
| Method to convert a float seconds value to milliseconds.
|
|
All the config data will be stored and extracted from this class.
Represents all the possible config data
◆ ClioConfigDefinition()
util::config::ClioConfigDefinition::ClioConfigDefinition |
( |
std::initializer_list< KeyValuePair > | pair | ) |
|
Constructs a new ClioConfigDefinition.
Initializes the configuration with a predefined set of key-value pairs If a key contains "[]", the corresponding value must be an Array
- Parameters
-
pair | A list of key-value pairs for the predefined set of clio configurations |
◆ arraySize()
std::size_t util::config::ClioConfigDefinition::arraySize |
( |
std::string_view | prefix | ) |
const |
|
nodiscard |
Returns the size of an Array.
- Parameters
-
prefix | The prefix whose associated Array object is to be returned. |
- Returns
- The size of the array associated with the specified prefix.
◆ asArray()
Array const & util::config::ClioConfigDefinition::asArray |
( |
std::string_view | key | ) |
const |
|
nodiscard |
Returns the Array object associated with the specified key.
- Parameters
-
key | The key whose associated Array object is to be returned. |
- Returns
- The Array object associated with the specified key.
◆ begin()
auto util::config::ClioConfigDefinition::begin |
( |
| ) |
const |
|
inlinenodiscard |
Returns an iterator to the beginning of the configuration map.
- Returns
- A constant iterator to the beginning of the map.
◆ contains()
bool util::config::ClioConfigDefinition::contains |
( |
std::string_view | key | ) |
const |
|
nodiscard |
Checks if a key is present in the configuration map.
- Parameters
-
key | The key to search for in the configuration map. |
- Returns
- True if the key is present, false otherwise.
◆ end()
auto util::config::ClioConfigDefinition::end |
( |
| ) |
const |
|
inlinenodiscard |
Returns an iterator to the end of the configuration map.
- Returns
- A constant iterator to the end of the map.
◆ get()
template<typename T >
T util::config::ClioConfigDefinition::get |
( |
std::string_view | fullKey | ) |
const |
|
inline |
Returns the specified value of given string if value exists.
- Template Parameters
-
- Parameters
-
fullKey | The config key to search for |
- Returns
- Value of key of type T
◆ getArray()
ArrayView util::config::ClioConfigDefinition::getArray |
( |
std::string_view | prefix | ) |
const |
|
nodiscard |
Returns the specified Array object from ClioConfigDefinition.
- Parameters
-
prefix | The prefix to search config keys from |
- Returns
- ArrayView with all key-value pairs where key starts with "prefix"
◆ getObject()
ObjectView util::config::ClioConfigDefinition::getObject |
( |
std::string_view | prefix, |
|
|
std::optional< std::size_t > | idx = std::nullopt ) const |
|
nodiscard |
Returns the ObjectView specified with the prefix.
- Parameters
-
prefix | The key prefix for the ObjectView |
idx | Used if getting Object in an Array |
- Returns
- ObjectView with the given prefix
◆ getValueInArray()
ValueView util::config::ClioConfigDefinition::getValueInArray |
( |
std::string_view | fullKey, |
|
|
std::size_t | index ) const |
|
nodiscard |
Returns the specified ValueView object in an array with a given index.
- Parameters
-
fullKey | The config key to search for |
index | The index of the config value inside the Array to get |
- Returns
- ValueView associated with the given key
◆ getValueView()
ValueView util::config::ClioConfigDefinition::getValueView |
( |
std::string_view | fullKey | ) |
const |
|
nodiscard |
Returns the specified ValueView object associated with the key.
- Parameters
-
fullKey | The config key to search for |
- Returns
- ValueView associated with the given key
◆ hasItemsWithPrefix()
bool util::config::ClioConfigDefinition::hasItemsWithPrefix |
( |
std::string_view | key | ) |
const |
|
nodiscard |
Checks if any key in config starts with "key".
- Parameters
-
key | The key to search for in the configuration map. |
- Returns
- True if the any key in config starts with "key", false otherwise.
◆ maybeValue()
template<typename T >
std::optional< T > util::config::ClioConfigDefinition::maybeValue |
( |
std::string_view | fullKey | ) |
const |
|
inline |
Returns the specified value of given string of type T if type and value exists.
- Template Parameters
-
- Parameters
-
fullKey | The config key to search for |
- Returns
- The value of type T if it exists, std::nullopt otherwise.
◆ parse()
Parses the configuration file.
Also checks that no extra configuration key/value pairs are present. Adds to list of Errors if it does
- Parameters
-
config | The configuration file interface |
- Returns
- An optional vector of Error objects stating all the failures if parsing fails
◆ toMilliseconds()
std::chrono::milliseconds util::config::ClioConfigDefinition::toMilliseconds |
( |
float | value | ) |
|
|
static |
Method to convert a float seconds value to milliseconds.
- Parameters
-
value | The value to convert |
- Returns
- The value in milliseconds
The documentation for this class was generated from the following files:
- /__w/clio/clio/src/util/newconfig/ConfigDefinition.hpp
- /__w/clio/clio/src/util/newconfig/ConfigDefinition.cpp