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

Represents the config values for Json/Yaml config. More...

#include <ConfigValue.hpp>

Public Member Functions

constexpr ConfigValue (ConfigType type)
 Constructor initializing with the config type.
 
ConfigValuedefaultValue (Value value)
 Sets the default value for the config.
 
std::optional< ErrorsetValue (Value value, std::optional< std::string_view > key=std::nullopt)
 Sets the value current ConfigValue given by the User's defined value.
 
constexpr ConfigValuewithConstraint (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 ConfigValueoptional ()
 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.
 

Friends

std::ostream & operator<< (std::ostream &stream, ConfigValue val)
 Prints all the info of this config value to the output stream.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ConfigValue()

util::config::ConfigValue::ConfigValue ( ConfigType type)
inlineconstexpr

Constructor initializing with the config type.

Parameters
typeThe type of the config value

Member Function Documentation

◆ defaultValue()

ConfigValue & util::config::ConfigValue::defaultValue ( Value value)
inlinenodiscard

Sets the default value for the config.

Parameters
valueThe default value
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()

ConfigValue & util::config::ConfigValue::optional ( )
inlinenodiscardconstexpr

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
valueThe value to set
keyThe 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()

ConfigValue & util::config::ConfigValue::withConstraint ( Constraint const & cons)
inlinenodiscardconstexpr

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
consThe constraint to be applied to the ConfigValue.
Returns
A reference to the modified ConfigValue object.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
ConfigValue val )
friend

Prints all the info of this config value to the output stream.

Parameters
streamThe output stream
valThe config value to output to osstream
Returns
The same ostream we were given

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