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

Array definition to store multiple values provided by the user from Json/Yaml. More...

#include <Array.hpp>

Public Member Functions

 Array (ConfigValue arg)
 Constructs an Array with provided Arg.
 
std::optional< ErroraddValue (Value value, std::optional< std::string_view > key=std::nullopt)
 Add ConfigValues to Array class.
 
size_t size () const
 Returns the number of values stored in the Array.
 
ConfigValue const & at (std::size_t idx) const
 Returns the ConfigValue at the specified index.
 
ConfigValue const & getArrayPattern () const
 Returns the ConfigValue that defines the type/constraint every ConfigValue must follow in Array.
 
std::vector< ConfigValue >::const_iterator begin () const
 Returns an iterator to the beginning of the ConfigValue vector.
 
std::vector< ConfigValue >::const_iterator end () const
 Returns an iterator to the end of the ConfigValue vector.
 

Static Public Member Functions

static std::string_view prefix (std::string_view key)
 Extract array prefix from a key, For example for a key foo.[].bar the method will return foo.[].
 

Detailed Description

Array definition to store multiple values provided by the user from Json/Yaml.

Used in ClioConfigDefinition to represent multiple potential values (like whitelist) Is constructed with only 1 element which states which type/constraint must every element In the array satisfy

Constructor & Destructor Documentation

◆ Array()

util::config::Array::Array ( ConfigValue arg)

Constructs an Array with provided Arg.

Parameters
argArgument to set the type and constraint of ConfigValues in Array

Member Function Documentation

◆ addValue()

std::optional< Error > util::config::Array::addValue ( Value value,
std::optional< std::string_view > key = std::nullopt )

Add ConfigValues to Array class.

Parameters
valueThe ConfigValue to add
keyoptional string key to include that will show in error message
Returns
optional error if adding config value to array fails. nullopt otherwise

◆ at()

ConfigValue const & util::config::Array::at ( std::size_t idx) const
nodiscard

Returns the ConfigValue at the specified index.

Parameters
idxIndex of the ConfigValue to retrieve
Returns
ConfigValue at the specified index

◆ begin()

std::vector< ConfigValue >::const_iterator util::config::Array::begin ( ) const
nodiscard

Returns an iterator to the beginning of the ConfigValue vector.

Returns
A constant iterator to the beginning of the vector.

◆ end()

std::vector< ConfigValue >::const_iterator util::config::Array::end ( ) const
nodiscard

Returns an iterator to the end of the ConfigValue vector.

Returns
A constant iterator to the end of the vector.

◆ getArrayPattern()

ConfigValue const & util::config::Array::getArrayPattern ( ) const
nodiscard

Returns the ConfigValue that defines the type/constraint every ConfigValue must follow in Array.

Returns
The item_pattern

◆ prefix()

std::string_view util::config::Array::prefix ( std::string_view key)
static

Extract array prefix from a key, For example for a key foo.[].bar the method will return foo.[].

Note
Provided key must contain '.[]'
Warning
Be careful with string_view! Returned value is valid only while the key is valid
Parameters
keyThe key to extract the array prefix from
Returns
Prefix of array extracted from the key

◆ size()

size_t util::config::Array::size ( ) const
nodiscard

Returns the number of values stored in the Array.

Returns
Number of values stored in the Array

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