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

Provides a view into a subset of configuration data defined by a prefix. More...

#include <ObjectView.hpp>

Public Member Functions

 ObjectView (std::string_view prefix, ClioConfigDefinition const &clioConfig)
 Constructs an ObjectView for the specified prefix. The view must be of type object.
 
 ObjectView (std::string_view prefix, std::size_t arrayIndex, ClioConfigDefinition const &clioConfig)
 Constructs an ObjectView for an indexed array within the specified prefix.
 
bool containsKey (std::string_view key) const
 Checks if prefix_.key (fullkey) exists in ClioConfigDefinition.
 
ValueView getValueView (std::string_view key) const
 Retrieves the value associated with the specified prefix._key in ClioConfigDefinition.
 
template<typename T >
get (std::string_view key) const
 Returns the specified value of given string if value exists.
 
template<typename T >
std::optional< T > maybeValue (std::string_view key) const
 Returns the specified value of given string of type T if type and value exists.
 
ObjectView getObject (std::string_view key) const
 Retrieves an ObjectView in ClioConfigDefinition with key that starts with prefix_.key. The view must be of type object.
 
ArrayView getArray (std::string_view key) const
 Retrieves an ArrayView in ClioConfigDefinition with key that starts with prefix_.key. The view must be of type object.
 

Detailed Description

Provides a view into a subset of configuration data defined by a prefix.

Allows querying and accessing configuration values based on the provided prefix

Constructor & Destructor Documentation

◆ ObjectView() [1/2]

util::config::ObjectView::ObjectView ( std::string_view prefix,
ClioConfigDefinition const & clioConfig )

Constructs an ObjectView for the specified prefix. The view must be of type object.

Parameters
prefixThe prefix indicating the subset of configuration data to view
clioConfigReference to the ClioConfigDefinition containing all the configuration data

◆ ObjectView() [2/2]

util::config::ObjectView::ObjectView ( std::string_view prefix,
std::size_t arrayIndex,
ClioConfigDefinition const & clioConfig )

Constructs an ObjectView for an indexed array within the specified prefix.

Parameters
prefixThe prefix indicating the subset of configuration data to view
arrayIndexThe index of the array object element to view
clioConfigReference to the ClioConfigDefinition containing all the configuration data

Member Function Documentation

◆ containsKey()

bool util::config::ObjectView::containsKey ( std::string_view key) const
nodiscard

Checks if prefix_.key (fullkey) exists in ClioConfigDefinition.

Parameters
keyThe suffix of the key
Returns
true if the full key exists, otherwise false

◆ get()

template<typename T >
T util::config::ObjectView::get ( std::string_view key) const
inline

Returns the specified value of given string if value exists.

Template Parameters
TThe type T to return
Parameters
keyThe config key to add to prefix and then search for
Returns
Value of key of type T

◆ getArray()

ArrayView util::config::ObjectView::getArray ( std::string_view key) const
nodiscard

Retrieves an ArrayView in ClioConfigDefinition with key that starts with prefix_.key. The view must be of type object.

Parameters
keyThe suffix of the key
Returns
An ObjectView representing the subset of configuration data

◆ getObject()

ObjectView util::config::ObjectView::getObject ( std::string_view key) const
nodiscard

Retrieves an ObjectView in ClioConfigDefinition with key that starts with prefix_.key. The view must be of type object.

Parameters
keyThe suffix of the key
Returns
An ObjectView representing the subset of configuration data

◆ getValueView()

ValueView util::config::ObjectView::getValueView ( std::string_view key) const
nodiscard

Retrieves the value associated with the specified prefix._key in ClioConfigDefinition.

Parameters
keyThe suffix of the key
Returns
A ValueView object representing the value associated with the key

◆ maybeValue()

template<typename T >
std::optional< T > util::config::ObjectView::maybeValue ( std::string_view key) const
inline

Returns the specified value of given string of type T if type and value exists.

Template Parameters
TThe type T to return
Parameters
keyThe config key to add to prefix and then search for
Returns
The value of type T if it exists, std::nullopt otherwise.

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