Provides view into ConfigValues that represents values in Clio Config.
More...
#include <ValueView.hpp>
|
| | ValueView (ConfigValue const &configVal) |
| | Constructs a ValueView object.
|
| std::string | asString () const |
| | Retrieves the value as a string.
|
| bool | asBool () const |
| | Retrieves the value as a boolean.
|
| template<typename T> |
| T | asIntType () const |
| | Retrieves any type of "int" value (uint_32, int64_t etc)
|
| double | asDouble () const |
| | Retrieves the value as a double.
|
| float | asFloat () const |
| | Retrieves the value as a float.
|
| constexpr ConfigType | type () const |
| | Gets the config type.
|
| bool constexpr | hasValue () const |
| | Check if Config Value exists.
|
| bool constexpr | isOptional () const |
| | Check if config value is optional.
|
| constexpr std::optional< std::reference_wrapper< Constraint const > > | getConstraint () const |
| | Retrieves the constraint associated with the ConfigValue in this ValueView, if any.
|
| template<typename T> |
| T | getValueImpl () const |
| | Retrieves the stored value as the specified type T.
|
| template<typename T> |
| std::optional< T > | asOptional () const |
| | Returns an optional value of the specified type T if valid.
|
Provides view into ConfigValues that represents values in Clio Config.
◆ ValueView()
| util::config::ValueView::ValueView |
( |
ConfigValue const & | configVal | ) |
|
Constructs a ValueView object.
- Parameters
-
| configVal | the config Value to view |
◆ asBool()
| bool util::config::ValueView::asBool |
( |
| ) |
const |
|
nodiscard |
Retrieves the value as a boolean.
- Returns
- The value as a boolean
- Exceptions
-
| std::bad_variant_access | if the value is not a boolean |
◆ asDouble()
| double util::config::ValueView::asDouble |
( |
| ) |
const |
|
nodiscard |
Retrieves the value as a double.
- Returns
- The value as a double
- Exceptions
-
| std::bad_variant_access | if the value cannot be retrieved as a Double |
◆ asFloat()
| float util::config::ValueView::asFloat |
( |
| ) |
const |
|
nodiscard |
Retrieves the value as a float.
- Returns
- The value as a float
- Exceptions
-
| std::bad_variant_access | if the value cannot be retrieved as a float |
◆ asIntType()
template<typename T>
| T util::config::ValueView::asIntType |
( |
| ) |
const |
|
inlinenodiscard |
Retrieves any type of "int" value (uint_32, int64_t etc)
- Returns
- The value with user requested type (if convertible)
- Exceptions
-
| std::logic_error | if the int < 0 and user requested unsigned int |
| std::bad_variant_access | if the value is not of type int |
◆ asOptional()
template<typename T>
| std::optional< T > util::config::ValueView::asOptional |
( |
| ) |
const |
|
inline |
Returns an optional value of the specified type T if valid.
- Template Parameters
-
| T | The type of value to retrieve (must be compatible with internal type) |
- Returns
- Returns the value as an optional<T> value exists, or std::nullopt if not
◆ asString()
| std::string util::config::ValueView::asString |
( |
| ) |
const |
|
nodiscard |
Retrieves the value as a string.
- Returns
- The value as a string
- Exceptions
-
| std::bad_variant_access | if the value is not a string |
◆ getConstraint()
| std::optional< std::reference_wrapper< Constraint const > > util::config::ValueView::getConstraint |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
◆ getValueImpl()
template<typename T>
| T util::config::ValueView::getValueImpl |
( |
| ) |
const |
|
inline |
Retrieves the stored value as the specified type T.
- Template Parameters
-
| T | The type to cast the stored value to |
- Returns
- The value cast to the specified type T
◆ hasValue()
| bool constexpr util::config::ValueView::hasValue |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Check if Config Value exists.
- Returns
- true if exists, false otherwise
◆ isOptional()
| bool constexpr util::config::ValueView::isOptional |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Check if config value is optional.
- Returns
- true if optional, false otherwise
◆ type()
| ConfigType util::config::ValueView::type |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Gets the config type.
- Returns
- The config type
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & | stream, |
|
|
ValueView | value ) |
|
friend |
Custom output stream for ValueView.
- Parameters
-
- Returns
- The same ostream we were given
The documentation for this class was generated from the following files:
- /__w/clio/clio/src/util/config/ValueView.hpp
- /__w/clio/clio/src/util/config/ValueView.cpp