SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
A validator that checks if a given path is a valid input file. More...
#include <seqan3/argument_parser/validators.hpp>
Public Types | |
using | option_value_type = std::string |
Type of values that are tested by validator. | |
Public Types inherited from seqan3::file_validator_base | |
using | option_value_type = std::string |
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. | |
virtual void | operator() (std::filesystem::path const &file) const override |
Tests whether path is an existing regular file and is readable. | |
Constructors, destructor and assignment | |
input_file_validator () | |
Default constructor. | |
input_file_validator (input_file_validator const &)=default | |
Defaulted. | |
input_file_validator (input_file_validator &&)=default | |
Defaulted. | |
input_file_validator & | operator= (input_file_validator const &)=default |
Defaulted. | |
input_file_validator & | operator= (input_file_validator &&)=default |
Defaulted. | |
virtual | ~input_file_validator ()=default |
Virtual destructor. | |
input_file_validator (std::vector< std::string > extensions) | |
Constructs from a given collection of valid extensions. | |
file_validator_base ()=default | |
Defaulted. | |
file_validator_base (file_validator_base const &)=default | |
Defaulted. | |
file_validator_base (file_validator_base &&)=default | |
Defaulted. | |
Public Member Functions inherited from seqan3::file_validator_base | |
template<std::ranges::forward_range range_type> requires (std::convertible_to<std::ranges::range_value_t<range_type>, std::filesystem::path const &> && !std::convertible_to<range_type, std::filesystem::path const &>) | |
void | operator() (range_type const &v) const |
Tests whether every path in list v passes validation. See operator()(option_value_type const & value) for further information. | |
file_validator_base ()=default | |
Defaulted. | |
file_validator_base (file_validator_base const &)=default | |
Defaulted. | |
file_validator_base (file_validator_base &&)=default | |
Defaulted. | |
file_validator_base & | operator= (file_validator_base const &)=default |
Defaulted. | |
file_validator_base & | operator= (file_validator_base &&)=default |
Defaulted. | |
virtual | ~file_validator_base ()=default |
Additional Inherited Members | |
Protected Member Functions inherited from seqan3::file_validator_base | |
bool | case_insensitive_string_ends_with (std::string_view str, std::string_view suffix) const |
Helper function that checks if a string is a suffix of another string. Case insensitive. | |
std::string | valid_extensions_help_page_message () const |
Returns the information of valid file extensions. | |
void | validate_filename (std::filesystem::path const &path) const |
Validates the given filename path based on the specified extensions. | |
void | validate_readability (std::filesystem::path const &path) const |
Checks if the given path is readable. | |
void | validate_writeability (std::filesystem::path const &path) const |
Checks if the given path is writable. | |
Protected Attributes inherited from seqan3::file_validator_base | |
std::vector< std::string > | extensions {} |
Stores the extensions. | |
Related Symbols inherited from validator | |
using | option_value_type |
The type of value on which the validator is called on. | |
void | operator() (option_value_type const &cmp) const |
Validates the value 'cmp' and throws a seqan3::validation_error on failure. | |
A validator that checks if a given path is a valid input file.
file_t | The type of the file to get the valid extensions for; void on default. |
On construction, the validator can receive a list (std::vector over std::string) of valid file extensions. The class acts as a functor that throws a seqan3::validation_error exception whenever a given filename's extension (std::filesystem::path) is not in the given list of valid file extensions, if the file does not exist, or if the file does not have the proper read permissions.
The valid extensions can also be obtained from a seqan3 formatted file type, e.g. seqan3::sequence_input_file, if it is given as template argument to this class. The following snippet demonstrates the different ways to instantiate the seqan3::input_file_validator.
|
inline |
Default constructor.
If the class' template argument file_t
names a valid seqan3 file type that contains a static member valid_formats
, e.g. seqan3::sequence_input_file::valid_formats, then it generates the list of valid extensions from this file. Otherwise the extensions list is empty.
|
inlineexplicit |
Constructs from a given collection of valid extensions.
[in] | extensions | The valid extensions to validate for. |
This constructor is only available if file_t
does not name a valid seqan3 file type that contains a static member valid_formats
.
|
inline |
Returns a message that can be appended to the (positional) options help page info.
Implements validator.
|
inlineoverridevirtual |
Tests whether path is an existing regular file and is readable.
file | The input value to check. |
seqan3::validation_error | if the validation process failed. Might be nested with std::filesystem::filesystem_error on unhandled OS API errors. |
Implements seqan3::file_validator_base.