esp::core::config::ConfigValue class

This class uses an anonymous tagged union to store values of different types, as well as providing access to the values in a type safe manner.

Constructors, destructors, conversion operators

ConfigValue() defaulted
Constructor.
ConfigValue(const ConfigValue& otr)
Copy Constructor.
ConfigValue(ConfigValue&& otr) noexcept
Move Constructor.
~ConfigValue()

Public functions

auto operator=(const ConfigValue& otr) -> ConfigValue&
Copy assignment.
auto operator=(ConfigValue&& otr) -> ConfigValue& noexcept
Move assignment.
auto isValid() const -> bool
Whether this ConfigValue is valid.
auto writeToJsonObject(io::JsonAllocator& allocator) const -> io::JsonGenericValue
Write this ConfigValue to an appropriately configured json object.
template<typename T>
void set(const T& value, bool isTranslated = false)
Set the passed value as the data for this ConfigValue, while also setting the appropriate type.
template<typename T>
void setHidden(const T& value, bool isTranslated = false)
Set the passed value as the data for this ConfigValue, while also setting the appropriate type. This ConfigValue is hidden, to be used internally and not expected to be exposed to user interaction except for potentially debugging.
template<typename T>
void init(const T& value, bool isTranslated = false)
Set the passed value as the programmatic default/initialization data for this ConfigValue, while also setting the appropriate type. This value will not be saved to file unless it is changed by file read or user input.
template<typename T>
auto get() const -> const T&
Retrieve an appropriately cast copy of the data stored in this ConfigValue.
auto getType() const -> ConfigValType
Returns the current type of this ConfigValue.
auto getState(const uint64_t mask) const -> bool
Get whether the flags specified by mask are true or not.
void setState(const uint64_t mask, bool val)
Set the flags specified by mask to be val.
auto isDefaultVal() const -> bool
Check whether this ConfigVal was set as a programmatic default value or was set from metadata or other intentional sources. We may not wish to write this value to file if it was only populated with a default value programmatically.
void setDefaultVal(bool isDefault)
Set whether this ConfigVal was set as a programmatic default value or was set from metadata or other intentional sources. We may not wish to write this value to file if it was only populated with a default value programmatically.
auto isHiddenVal() const -> bool
Check whether this ConfigVal is an internal value used programmatically in conjunction with other data in the owning Configuration. These values probably should never be written to file or shared with the user except for debugging purposes.
void setHiddenVal(bool isHidden)
Set whether this ConfigVal is an internal value used programmatically in conjunction with other data in the owning Configuration. These values probably should never be written to file or shared with the user except for debugging purposes.
auto isTranslated() const -> bool
Check whether this ConfigVal is translated before use, for example to an enum. This is generally to limit values and provide context and meaning to the values it holds. These ConfigVals are stored intnerally in a Configuration as strings but are consumed as their translated value (i.e enums). Because of this, they need custom handling to be read from file.
void setTranslatedVal(bool isTranslated)
Set whether this ConfigVal is translated before use, for example to an enum. This is generally to limit values and provide context and meaning to the values it holds. These ConfigVals are stored intnerally in a Configuration as strings but are consumed as their translated value (i.e enums). Because of this, they need custom handling to be read from file.
auto reqsFuzzyCompare() const -> bool
Check whether this ConfigVal requires a fuzzy comparison for equality (i.e. for a scalar double).
void setReqsFuzzyCompare(bool fuzzyCompare)
Check whether this ConfigVal requires a fuzzy comparison for equality (i.e. for a scalar double).
auto shouldWriteToFile() const -> bool
Whether or not this ConfigValue should be written to file during common execution. The reason we may not want to do this might be that the value was only set to a programmatic default value, and not set intentionally from the source file or user input; we also do not want to write any internal/hidden values to files.
auto getAsString() const -> std::string
Retrieve a string representation of the data held in this ConfigValue.
auto putValueInConfigGroup(const std::string& key, Cr::Utility::ConfigurationGroup& cfg) const -> bool
Copy this ConfigValue into the passed Corrade::Utility::ConfigurationGroup.

Friends

auto operator==(const ConfigValue& a, const ConfigValue& b) -> bool
Comparison.
auto operator!=(const ConfigValue& a, const ConfigValue& b) -> bool
Inequality Comparison.

Function documentation

bool esp::core::config::ConfigValue::isValid() const

Whether this ConfigValue is valid.

Returns Whether or not the specified type of this ConfigValue is known.

template<typename T>
void esp::core::config::ConfigValue::set(const T& value, bool isTranslated = false)

Set the passed value as the data for this ConfigValue, while also setting the appropriate type.

Parameters
value The value to store in this ConfigValue
isTranslated Whether this value is translated before use or not.

template<typename T>
void esp::core::config::ConfigValue::setHidden(const T& value, bool isTranslated = false)

Set the passed value as the data for this ConfigValue, while also setting the appropriate type. This ConfigValue is hidden, to be used internally and not expected to be exposed to user interaction except for potentially debugging.

Parameters
value The value to store in this ConfigValue
isTranslated Whether this value is translated before use or not.

template<typename T>
void esp::core::config::ConfigValue::init(const T& value, bool isTranslated = false)

Set the passed value as the programmatic default/initialization data for this ConfigValue, while also setting the appropriate type. This value will not be saved to file unless it is changed by file read or user input.

Parameters
value The value to store in this ConfigValue
isTranslated Whether this value is translated before use or not.

bool esp::core::config::ConfigValue::isTranslated() const

Check whether this ConfigVal is translated before use, for example to an enum. This is generally to limit values and provide context and meaning to the values it holds. These ConfigVals are stored intnerally in a Configuration as strings but are consumed as their translated value (i.e enums). Because of this, they need custom handling to be read from file.

NOTE : Any ConfigValues specified as isTranslated need to have their Json read handled by the consuming class, as they will not be necessarily properly read from file otherwise.

void esp::core::config::ConfigValue::setTranslatedVal(bool isTranslated)

Set whether this ConfigVal is translated before use, for example to an enum. This is generally to limit values and provide context and meaning to the values it holds. These ConfigVals are stored intnerally in a Configuration as strings but are consumed as their translated value (i.e enums). Because of this, they need custom handling to be read from file.

NOTE : Any ConfigValues specified as isTranslated need to have their Json read handled by the consuming class, as they will not be necessarily properly read from file otherwise.

bool esp::core::config::ConfigValue::reqsFuzzyCompare() const

Check whether this ConfigVal requires a fuzzy comparison for equality (i.e. for a scalar double).

The comparisons for such a type should use Magnum::Math::equal to be consistent with similarly configured magnum types.

void esp::core::config::ConfigValue::setReqsFuzzyCompare(bool fuzzyCompare)

Check whether this ConfigVal requires a fuzzy comparison for equality (i.e. for a scalar double).

The comparisons for such a type should use Magnum::Math::equal to be consistent with similarly configured magnum types.