Represents the config values for Json/Yaml config.
More...
#include <ConfigValue.hpp>
|
constexpr | ConfigValue (ConfigType type) |
| Constructor initializing with the config type.
|
|
ConfigValue & | defaultValue (Value value) |
| Sets the default value for the config.
|
|
std::optional< Error > | setValue (Value value, std::optional< std::string_view > key=std::nullopt) |
| Sets the value current ConfigValue given by the User's defined value.
|
|
constexpr ConfigValue & | withConstraint (Constraint const &cons) |
| Assigns a constraint to the ConfigValue.
|
|
constexpr std::optional< std::reference_wrapper< Constraint const > > | getConstraint () const |
| Retrieves the constraint associated with this ConfigValue, if any.
|
|
constexpr ConfigType | type () const |
| Gets the config type.
|
|
constexpr ConfigValue & | optional () |
| Sets the config value as optional, meaning the user doesn't have to provide the value in their config.
|
|
bool constexpr | isOptional () const |
| Checks if configValue is optional.
|
|
bool constexpr | hasValue () const |
| Check if value is optional.
|
|
Value const & | getValue () const |
| Get the value of config.
|
|
|
std::ostream & | operator<< (std::ostream &stream, ConfigValue val) |
| Prints all the info of this config value to the output stream.
|
|
Represents the config values for Json/Yaml config.
Used in ClioConfigDefinition to indicate the required type of value and whether it is mandatory to specify in the configuration
◆ ConfigValue()
util::config::ConfigValue::ConfigValue |
( |
ConfigType | type | ) |
|
|
inlineconstexpr |
Constructor initializing with the config type.
- Parameters
-
type | The type of the config value |
◆ defaultValue()
ConfigValue & util::config::ConfigValue::defaultValue |
( |
Value | value | ) |
|
|
inlinenodiscard |
Sets the default value for the config.
- Parameters
-
- Returns
- Reference to this ConfigValue
◆ getConstraint()
std::optional< std::reference_wrapper< Constraint const > > util::config::ConfigValue::getConstraint |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Retrieves the constraint associated with this ConfigValue, if any.
- Returns
- An optional reference to the associated Constraint.
◆ getValue()
Value const & util::config::ConfigValue::getValue |
( |
| ) |
const |
|
inlinenodiscard |
Get the value of config.
- Returns
- Config Value
◆ hasValue()
bool constexpr util::config::ConfigValue::hasValue |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Check if value is optional.
- Returns
- if value is optiona, false otherwise
◆ isOptional()
bool constexpr util::config::ConfigValue::isOptional |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Checks if configValue is optional.
- Returns
- true if optional, false otherwise
◆ optional()
Sets the config value as optional, meaning the user doesn't have to provide the value in their config.
- Returns
- Reference to this ConfigValue
◆ setValue()
std::optional< Error > util::config::ConfigValue::setValue |
( |
Value | value, |
|
|
std::optional< std::string_view > | key = std::nullopt ) |
|
inlinenodiscard |
Sets the value current ConfigValue given by the User's defined value.
- Parameters
-
value | The value to set |
key | The Config key associated with the value. Optional to include; Used for debugging message to user. |
- Returns
- optional Error if user tries to set a value of wrong type or not within a constraint
◆ type()
ConfigType util::config::ConfigValue::type |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Gets the config type.
- Returns
- The config type
◆ withConstraint()
Assigns a constraint to the ConfigValue.
This method associates a specific constraint with the ConfigValue. If the ConfigValue already holds a value, the method will check whether the value satisfies the given constraint. If the constraint is not satisfied, an assertion failure will occur with a detailed error message.
- Parameters
-
- Returns
- A reference to the modified ConfigValue object.
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & | stream, |
|
|
ConfigValue | val ) |
|
friend |
Prints all the info of this config value to the output stream.
- Parameters
-
stream | The output stream |
val | The config value to output to osstream |
- Returns
- The same ostream we were given
The documentation for this class was generated from the following file: