An interface to enforce constraints on certain values within ClioConfigDefinition.
More...
#include <ConfigConstraints.hpp>
|
std::optional< Error > | checkConstraint (Value const &val) const |
| Check if the value meets the specific constraint.
|
|
|
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< Error > | checkTypeImpl (Value const &val) const =0 |
| Check if the value is of a correct type for the constraint.
|
|
virtual std::optional< Error > | checkValueImpl (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.
|
|
|
std::ostream & | operator<< (std::ostream &stream, Constraint const &cons) |
| Custom output stream for constraint.
|
|
An interface to enforce constraints on certain values within ClioConfigDefinition.
◆ checkConstraint()
std::optional< Error > util::config::Constraint::checkConstraint |
( |
Value const & | val | ) |
const |
|
inlinenodiscard |
Check if the value meets the specific constraint.
- Parameters
-
val | The 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
-
val | The 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
-
val | The 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,the | size of the array of hardcoded values |
- Parameters
-
key | The key to the value |
value | The value the user provided |
arr | The 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
-
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & | stream, |
|
|
Constraint const & | cons ) |
|
friend |
Custom output stream for constraint.
- Parameters
-
stream | The output stream |
cons | The constraint |
- Returns
- The same ostream we were given
The documentation for this class was generated from the following file: