Sharg 1.1.2-rc.1
The argument parser for bio-c++ tools.
|
A validator that checks if a matches a regular expression pattern. More...
#include <sharg/validators.hpp>
Public Types | |
using | option_value_type = std::string |
Type of values that are tested by validator. | |
Public Member Functions | |
regex_validator (std::string const &pattern_) | |
Constructing from a vector. | |
void | operator() (option_value_type const &cmp) const |
Tests whether cmp lies inside values. | |
template<std::ranges::forward_range range_type> requires std::convertible_to<std::ranges::range_reference_t<range_type>, std::string const &> | |
void | operator() (range_type const &v) const |
Tests whether every entry in list v matches the pattern. | |
std::string | get_help_page_message () const |
Returns a message that can be appended to the (positional) options help page info. | |
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 sharg::validation_error exception whenever string does not match the pattern.
|
inline |
Constructing from a vector.
[in] | pattern_ | The pattern to match. |
|
inline |
Returns a message that can be appended to the (positional) options help page info.
|
inline |
Tests whether cmp lies inside values.
[in] | cmp | The value to validate. |
sharg::validation_error |
|
inline |
Tests whether every entry in list v matches the pattern.
range_type | The type of range to check; must model std::ranges::forward_range and the value type must be convertible to std::string. |
v | The input range to iterate over and check every element. |
sharg::validation_error |