A validator that checks if a filenames has one of the valid extensions.
More...
#include <seqan3/argument_parser/validators.hpp>
|
using | value_type = std::string |
| Type of values that are tested by validator.
|
|
|
| file_ext_validator (std::vector< std::string > const &v) |
| Constructing from a vector. More...
|
|
| file_ext_validator (std::initializer_list< std::string > const &v) |
| Constructing from an initializer_list. More...
|
|
std::string | get_help_page_message () const |
| Returns a message that can be appended to the (positional) options help page info.
|
|
void | operator() (filesystem::path const &path) const |
| Tests whether the filepath path ends with a valid extension. More...
|
|
void | operator() (std::vector< std::string > const &v) const |
| Tests whether every value of v lies inside extensions.
|
|
|
(Note that these are not member functions.)
|
|
You can expect these (meta-)functions on all types that implement seqan3::validator_concept.
|
void | operator() (value_type const &cmp) const |
| Validates the value 'cmp' and throws a seqan3::validation_error on failure. More...
|
|
A validator that checks if a filenames has one of the valid extensions.
On construction, the validator must receive a list (vector) of valid file extensions. The struct than acts as a functor, that throws a seqan3::parser_invalid_argument exception whenever a given filename (string) is not in the given extension list.
int main(int argc, const char ** argv)
{
std::string myfile;
myparser.add_option(myfile,'f',"file","Give me a filename.",
try
{
myparser.parse();
}
{
std::cerr << "[PARSER ERROR] " << ext.what() << "\n";
return -1;
}
{
return 0;
}
return 0;
}
◆ file_ext_validator() [1/2]
seqan3::file_ext_validator::file_ext_validator |
( |
std::vector< std::string > const & |
v | ) |
|
|
inline |
Constructing from a vector.
- Parameters
-
[in] | v | The vector of valid file extensions to test (e.g. {"fa", "fasta"}). |
◆ file_ext_validator() [2/2]
seqan3::file_ext_validator::file_ext_validator |
( |
std::initializer_list< std::string > const & |
v | ) |
|
|
inline |
Constructing from an initializer_list.
- Parameters
-
[in] | v | The initializer_list of valid file extensions to test (e.g. {"fa", "fasta"}). |
◆ operator()()
void seqan3::file_ext_validator::operator() |
( |
filesystem::path const & |
path | ) |
const |
|
inline |
Tests whether the filepath path
ends with a valid extension.
- Parameters
-
path | The input value to check. |
- Exceptions
-
◆ operator()()
Validates the value 'cmp' and throws a seqan3::validation_error on failure.
- Template Parameters
-
- Parameters
-
[in,out] | cmp | The value to be validated. |
- Exceptions
-
seqan3::validation_error | if value 'cmp' does not pass validation. |
- 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: