Sharg 1.1.2-rc.1
The argument parser for bio-c++ tools.
|
The Validators Module. More...
Concepts | |
concept | sharg::validator |
The concept for option validators passed to add_option/positional_option. | |
Classes | |
class | sharg::arithmetic_range_validator< option_value_t > |
A validator that checks whether a number is inside a given range. More... | |
class | sharg::value_list_validator< option_value_t > |
A validator that checks whether a value is inside a list of valid values. More... | |
class | sharg::file_validator_base |
An abstract base class for the file and directory validators. More... | |
class | sharg::input_file_validator |
A validator that checks if a given path is a valid input file. More... | |
class | sharg::output_file_validator |
A validator that checks if a given path is a valid output file. More... | |
class | sharg::input_directory_validator |
A validator that checks if a given path is a valid input directory. More... | |
class | sharg::output_directory_validator |
A validator that checks if a given path is a valid output directory. More... | |
class | sharg::regex_validator |
A validator that checks if a matches a regular expression pattern. More... | |
Functions | |
template<validator validator1_type, validator validator2_type> requires std::common_with<typename std::remove_reference_t<validator1_type>::option_value_type, typename std::remove_reference_t<validator2_type>::option_value_type> | |
auto | sharg::operator| (validator1_type &&vali1, validator2_type &&vali2) |
Enables the chaining of validators. | |
The Validators Module.
auto sharg::operator| | ( | validator1_type && | vali1, |
validator2_type && | vali2 ) |
Enables the chaining of validators.
validator1_type | The type of the fist validator; Must satisfy the sharg::validator and the same option_value_type as the second validator type. |
validator2_type | The type of the second validator; Must satisfy the sharg::validator and the same option_value_type as the fist validator type. |
[in] | vali1 | The first validator to chain. |
[in] | vali2 | The second validator to chain. |
The pipe operator is the AND operation for two validators, which means that a value must pass both validators in order to be accepted by the new validator.
For example you may want a file name that only accepts absolute paths but also must have one out of some given file extensions. For this purpose you can chain a sharg::regex_validator to a sharg::input_file_validator like this:
You can chain as many validators as you want which will be evaluated one after the other from left to right (first to last).