A validator that checks if a matches a regular expression pattern.
More...
#include <seqan3/argument_parser/validators.hpp>
|
using | option_value_type = std::string |
| Type of values that are tested by validator.
|
|
A validator that checks if a matches a regular expression pattern.
On construction, the validator must receive a pattern for a regular expression. The pattern variable will be used for constructing a std::regex and the validator will call std::regex_match on the command line argument. Note: A regex_match will only return true if the strings matches the pattern completely (in contrast to regex_search which also matches substrings).
The class than acts as a functor, that throws a seqan3::validation_error exception whenever string does not match the pattern.
int main(int argc, char const ** argv)
{
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:37
The SeqAn command line parser.
Definition argument_parser.hpp:145
A validator that checks if a matches a regular expression pattern.
Definition validators.hpp:928
Provides seqan3::debug_stream and related types.
@ standard
The default were no checking or special displaying is happening.
Definition auxiliary.hpp:248
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
◆ regex_validator()
seqan3::regex_validator::regex_validator |
( |
std::string const & |
pattern_ | ) |
|
|
inline |
Constructing from a vector.
- Parameters
-
[in] | pattern_ | The pattern to match. |
◆ get_help_page_message()
std::string seqan3::regex_validator::get_help_page_message |
( |
| ) |
const |
|
inline |
Returns a message that can be appended to the (positional) options help page info.
Implements validator.
◆ operator()() [1/2]
Tests whether cmp lies inside values.
- Parameters
-
[in] | cmp | The value to validate. |
- Exceptions
-
◆ operator()() [2/2]
template<std::ranges::forward_range range_type>
requires std::convertible_to<std::ranges::range_reference_t<range_type>,
option_value_type const &>
void seqan3::regex_validator::operator() |
( |
range_type const & |
v | ) |
const |
|
inline |
Tests whether every filename in list v matches the pattern.
- Template Parameters
-
range_type | The type of range to check; must model std::ranges::forward_range and the value type must be convertible to std::string. |
- Parameters
-
v | The input range to iterate over and check every element. |
- Exceptions
-
The documentation for this class was generated from the following file: