A validator that checks whether a value is inside a list of valid values.
More...
#include <seqan3/argument_parser/validators.hpp>
|
using | value_type = option_value_type |
| Type of values that are tested by validator.
|
|
|
(Note that these are not member functions.)
|
|
You can expect these (meta-)functions on all types that implement seqan3::validator_concept.
|
void | operator() (value_type const &cmp) const |
| Validates the value 'cmp' and throws a seqan3::validation_error on failure. More...
|
|
template<typename option_value_type>
class seqan3::value_list_validator< option_value_type >
A validator that checks whether a value is inside a list of valid values.
On construction, the validator must receive a list (vector) of valid values. The struct than acts as a functor, that throws a seqan3::parser_invalid_argument exception whenever a given value is not in the given list.
int main(int argc, const char ** argv)
{
int myint;
myparser.add_option(myint,'i',"integer","Give me a number.",
try
{
myparser.parse();
}
{
std::cerr << "[PARSER ERROR] " << ext.what() << "\n";
return -1;
}
{
return 0;
}
return 0;
}
◆ value_list_validator() [1/2]
template<typename option_value_type >
Constructing from a vector.
- Parameters
-
[in] | v | The vector of valid values to test. |
◆ value_list_validator() [2/2]
template<typename option_value_type >
Constructing from an initializer_list.
- Parameters
-
[in] | v | The initializer_list of valid values to test. |
◆ operator()()
template<typename option_value_type >
Tests whether cmp lies inside values.
- Parameters
-
cmp | The input value to check. |
- Exceptions
-
◆ operator()()
Validates the value 'cmp' and throws a seqan3::validation_error on failure.
- Template Parameters
-
- Parameters
-
[in,out] | cmp | The value to be validated. |
- Exceptions
-
seqan3::validation_error | if value 'cmp' does not pass validation. |
- Attention
- This is a concept requirement, not an actual function (however types satisfying this concept will provide an implementation).
The documentation for this class was generated from the following file: