A validator that checks whether a number is inside a given range.
More...
#include <seqan3/argument_parser/validators.hpp>
A validator that checks whether a number is inside a given range.
On construction, the validator must receive a maximum and a minimum number. The class than acts as a functor, that throws a seqan3::validation_error exception whenever a given value does not lie inside the given min/max range.
int main(int argc, const char ** argv)
{
int myint;
myparser.add_option(myint,'i',"integer","Give me a number.",
try
{
myparser.parse();
}
{
return -1;
}
return 0;
}
Meta-Header for the argument parser module.
Argument parser exception that is thrown whenever there is an error while parsing the command line ar...
Definition: exceptions.hpp:49
The SeqAn command line parser.
Definition: argument_parser.hpp:154
A validator that checks whether a number is inside a given range.
Definition: validators.hpp:120
Provides seqan3::debug_stream and related types.
@ standard
The default were no checking or special displaying is happening.
Definition: auxiliary.hpp:234
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
◆ arithmetic_range_validator()
The constructor.
- Parameters
-
[in] | min_ | Minimum set for the range to test. |
[in] | max_ | Maximum set for the range to test. |
◆ operator()() [1/2]
void seqan3::arithmetic_range_validator::operator() |
( |
option_value_type const & |
cmp | ) |
const |
|
inline |
Tests whether cmp lies inside [min
, max
].
- Parameters
-
cmp | The input value to check. |
- Exceptions
-
◆ operator()() [2/2]
template<std::ranges::forward_range range_type>
void seqan3::arithmetic_range_validator::operator() |
( |
range_type const & |
range | ) |
const |
|
inline |
Tests whether every element in range
lies inside [min
, max
].
- Template Parameters
-
range_type | The type of range to check; must model std::ranges::forward_range. The value type must model seqan3::arithmetic. |
- Parameters
-
range | The input range to iterate over and check every element. |
- Exceptions
-
◆ operator()()
Validates the value 'cmp' and throws a seqan3::validation_error on failure.
- Template Parameters
-
option_value_type | The type of the value to be validated. |
- Parameters
-
[in,out] | cmp | The value to be validated. |
- Exceptions
-
- 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: