Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::config::ValueView Class Reference

Provides view into ConfigValues that represents values in Clio Config. More...

#include <ValueView.hpp>

Public Member Functions

 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 >
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 >
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.
 

Friends

std::ostream & operator<< (std::ostream &stream, ValueView value)
 Custom output stream for ValueView.
 

Detailed Description

Provides view into ConfigValues that represents values in Clio Config.

Constructor & Destructor Documentation

◆ ValueView()

util::config::ValueView::ValueView ( ConfigValue const & configVal)

Constructs a ValueView object.

Parameters
configValthe config Value to view

Member Function Documentation

◆ asBool()

bool util::config::ValueView::asBool ( ) const
nodiscard

Retrieves the value as a boolean.

Returns
The value as a boolean
Exceptions
std::bad_variant_accessif 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_accessif 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_accessif 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_errorif the int < 0 and user requested unsigned int
std::bad_variant_accessif 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
TThe 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_accessif the value is not a string

◆ getConstraint()

std::optional< std::reference_wrapper< Constraint const > > util::config::ValueView::getConstraint ( ) const
inlinenodiscardconstexpr

Retrieves the constraint associated with the ConfigValue in this ValueView, if any.

Returns
An optional reference to the associated Constraint

◆ getValueImpl()

template<typename T >
T util::config::ValueView::getValueImpl ( ) const
inline

Retrieves the stored value as the specified type T.

Template Parameters
TThe 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

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
ValueView value )
friend

Custom output stream for ValueView.

Parameters
streamThe output stream
valueThe ValueView
Returns
The same ostream we were given

The documentation for this class was generated from the following files: