A validator that checks whether a value is inside a list of valid values. More...
#include <seqan3/argument_parser/validators.hpp>
Public Types | |
using | option_value_type = option_value_t |
Type of values that are tested by validator. | |
Public Member Functions | |
std::string | get_help_page_message () const |
Returns a message that can be appended to the (positional) options help page info. | |
void | operator() (option_value_type const &cmp) const |
Tests whether cmp lies inside values. More... | |
template<std::ranges::forward_range range_type> | |
void | operator() (range_type const &range) const |
Tests whether every element in range lies inside values. More... | |
Constructors, destructor and assignment | |
value_list_validator ()=default | |
Defaulted. | |
value_list_validator (value_list_validator const &)=default | |
Defaulted. | |
value_list_validator (value_list_validator &&)=default | |
Defaulted. | |
value_list_validator & | operator= (value_list_validator const &)=default |
Defaulted. | |
value_list_validator & | operator= (value_list_validator &&)=default |
Defaulted. | |
~value_list_validator ()=default | |
Defaulted. | |
template<std::ranges::forward_range range_type> | |
value_list_validator (range_type rng) | |
Constructing from a range. More... | |
template<typename ... option_types> | |
value_list_validator (option_types &&...opts) | |
Constructing from a parameter pack. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<arithmetic ... option_types> | |
value_list_validator (option_types...) -> value_list_validator< double > | |
Type deduction guides. More... | |
template<std::ranges::forward_range range_type> | |
value_list_validator (range_type &&rng) -> value_list_validator< double > | |
Deduction guide for ranges over an arithmetic type. | |
template<typename ... option_types> | |
value_list_validator (option_types...) -> value_list_validator< std::string > | |
Given a parameter pack of types that are convertible to std::string, delegate to value type std::string. | |
template<std::ranges::forward_range range_type> | |
value_list_validator (range_type &&rng) -> value_list_validator< std::string > | |
Deduction guide for ranges over a value type convertible to std::string. | |
template<typename ... option_types> | |
value_list_validator (option_types...) -> value_list_validator< seqan3::pack_traits::front< option_types... >> | |
Deduction guide for a parameter pack. | |
template<std::ranges::forward_range range_type> | |
value_list_validator (range_type &&rng) -> value_list_validator< std::ranges::range_value_t< range_type >> | |
Deduction guide for ranges. | |
Requirements for seqan3::validator | |
You can expect these (meta-)functions on all types that implement seqan3::validator. | |
void | operator() (option_value_type const &cmp) const |
Validates the value 'cmp' and throws a seqan3::validation_failed on failure. More... | |
A validator that checks whether a value is inside a list of valid values.
option_value_t | Must be a (container of) arithmetic type(s). |
On construction, the validator must receive a range or parameter pack 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.
double
for ranges whose value type models seqan3::arithmetic, and to std::string
if the ranges value type is convertible to it. Otherwise, the option value type is deduced to the value type of the range.
|
inline |
Constructing from a range.
range_type | The type of range; must model std::ranges::forward_range and value_list_validator::option_value_type must be constructible from the rvalue reference type of the given range. |
[in] | rng | The range of valid values to test. |
|
inline |
Constructing from a parameter pack.
option_types | The type of option values in the parameter pack; The value_list_validator::option_value_type must be constructible from each type in the parameter pack. |
[in] | opts | The parameter pack values. |
|
inline |
Tests whether cmp lies inside values.
cmp | The input value to check. |
parser_invalid_argument |
|
inline |
Tests whether every element in range
lies inside values.
range_type | The type of range to check; must model std::ranges::forward_range. |
range | The input range to iterate over and check every element. |
parser_invalid_argument |
|
related |
Validates the value 'cmp' and throws a seqan3::validation_failed on failure.
option_value_type | The type of the value to be validated. |
[in,out] | cmp | The value to be validated. |
seqan3::validation_failed | if value 'cmp' does not pass validation. |
|
related |
Type deduction guides.
Deduction guide for a parameter pack over an arithmetic type.