49 lines
1.9 KiB
Plaintext
49 lines
1.9 KiB
Plaintext
namespace YYCC::Constraints {
|
|
/**
|
|
|
|
\page constraints Constraints
|
|
|
|
YYCC::Constraints namespace provide Constraint struct declaration
|
|
and various common constraint generator function.
|
|
|
|
This namespace is specifically used by YYCC::ConfigManager and YYCC::ArgParser namespaces.
|
|
See \ref config_manager chapter and \ref arg_parser chapter for how to utlize this namespace.
|
|
|
|
\section constraints__prototype Prototype
|
|
|
|
Constraint instruct library how check whether given value is in range,
|
|
and how to clamp it if it is invalid.
|
|
For example, you can use constraint to limit a number in given minimum maximum value,
|
|
or limit a string in specific format by using regex and etc.
|
|
|
|
Constraint is a template struct.
|
|
The argument of template is the underlying data type which need to be checked.
|
|
The struct with different template argument is not compatible.
|
|
|
|
Currently, this struct only contain 1 function pointer,
|
|
which is used for detecting whether given value is in range / valid.
|
|
|
|
\subsection constraints__presets Constraint Presets
|
|
|
|
YYCC::Constraints provides some constraint presets which are commonly used.
|
|
All functions inside this namespace will return a Constraint instance,
|
|
and you can directly use it.
|
|
|
|
There is a list of all provided functions:
|
|
|
|
\li GetMinMaxRangeConstraint(): Limit the number value in given minimum maximum value range (inclusive).
|
|
\li GetEnumEnumerationConstraint(): Limit the enum value by given all possible value set.
|
|
\li GetStringEnumerationConstraint(): Limit the string by given all possible value set.
|
|
|
|
\subsection config_manager__constraint__custom Custom Constraint
|
|
|
|
For creating your personal constraint,
|
|
you need to create Constraint instance manually.
|
|
You can browse all existing constraint preset functions code for know how to write it.
|
|
|
|
The things you need to do is simple.
|
|
First, you need decide the template argument of Constraint.
|
|
Second, you need assign class member of Constraint by C++ lambda syntax.
|
|
|
|
*/
|
|
} |