Base class to check a value.
The ValueCheckBase class, is a abstract base class, allowing to implement a single check on a string value.
A check derived from this class can be combined in ValueCheck class to expressions.
- See Also
- ValueRegExCheck, ValueIntCheck and the ValueCheck class.
virtual std::string ca_mgm::ValueCheckBase::explain |
( |
const std::string & |
value | ) |
const |
|
pure virtual |
Returns a string explaining / showing the check.
For example, if your check implements the evaluation whether the value (e.g. "2"
) is lower than 5
, implement it as:
*
return str::form(
"MyCheck('%1' < 5)", value);
*
The resulting string will be "MyCheck('2' < 5)"
if the value parameter string was "2"
.
- Parameters
-
value | The value to evaluate. |
- Returns
- A string showing the check.
Implemented in ca_mgm::ValueCheck, ca_mgm::ValueIntCheck, ca_mgm::ValuePerlRECheck, and ca_mgm::ValuePosixRECheck.
virtual bool ca_mgm::ValueCheckBase::isValid |
( |
const std::string & |
value | ) |
const |
|
pure virtual |
Evaluates a check for the specified string value parameter to a boolean or throws an exception on failure.
For example, if you want a check that evaluates whether the value (e.g. "2"
) is lower than 5
, implement it as:
* return (value.toInt() < 5);
*
- Parameters
-
value | The value to evaluate. |
- Returns
- The boolean result of the check.
Implemented in ca_mgm::ValueCheck, ca_mgm::ValueIntCheck, ca_mgm::ValuePerlRECheck, and ca_mgm::ValuePosixRECheck.