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

An interface to enforce constraints on certain values within ClioConfigDefinition. More...

#include <ConfigConstraints.hpp>

Inheritance diagram for util::config::Constraint:

Public Member Functions

std::optional< ErrorcheckConstraint (Value const &val) const
 Check if the value meets the specific constraint.
 

Protected Member Functions

template<std::size_t ArrSize>
constexpr std::string makeErrorMsg (std::string_view key, Value const &value, std::array< char const *, ArrSize > arr) const
 Creates an error message for all constraints that must satisfy certain hard-coded values.
 
virtual std::optional< ErrorcheckTypeImpl (Value const &val) const =0
 Check if the value is of a correct type for the constraint.
 
virtual std::optional< ErrorcheckValueImpl (Value const &val) const =0
 Check if the value is within the constraint.
 
virtual void print (std::ostream &stream) const =0
 Prints to the output stream for this specific constraint.
 

Friends

std::ostream & operator<< (std::ostream &stream, Constraint const &cons)
 Custom output stream for constraint.
 

Detailed Description

An interface to enforce constraints on certain values within ClioConfigDefinition.

Member Function Documentation

◆ checkConstraint()

std::optional< Error > util::config::Constraint::checkConstraint ( Value const & val) const
inlinenodiscard

Check if the value meets the specific constraint.

Parameters
valThe value to be checked
Returns
An Error object if the constraint is not met, nullopt otherwise

◆ checkTypeImpl()

virtual std::optional< Error > util::config::Constraint::checkTypeImpl ( Value const & val) const
protectedpure virtual

Check if the value is of a correct type for the constraint.

Parameters
valThe value type to be checked
Returns
An Error object if the constraint is not met, nullopt otherwise

◆ checkValueImpl()

virtual std::optional< Error > util::config::Constraint::checkValueImpl ( Value const & val) const
protectedpure virtual

Check if the value is within the constraint.

Parameters
valThe value type to be checked
Returns
An Error object if the constraint is not met, nullopt otherwise

◆ makeErrorMsg()

template<std::size_t ArrSize>
std::string util::config::Constraint::makeErrorMsg ( std::string_view key,
Value const & value,
std::array< char const *, ArrSize > arr ) const
inlineconstexprprotected

Creates an error message for all constraints that must satisfy certain hard-coded values.

Template Parameters
arrSize,thesize of the array of hardcoded values
Parameters
keyThe key to the value
valueThe value the user provided
arrThe array with hard-coded values to add to error message
Returns
The error message specifying what the value of key must be

◆ print()

virtual void util::config::Constraint::print ( std::ostream & stream) const
protectedpure virtual

Prints to the output stream for this specific constraint.

Parameters
streamThe output stream

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
Constraint const & cons )
friend

Custom output stream for constraint.

Parameters
streamThe output stream
consThe constraint
Returns
The same ostream we were given

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