An abstract base class for the file and directory validators. More...
#include <seqan3/argument_parser/validators.hpp>
Public Types | |
using | option_value_type = std::string |
Type of values that are tested by validator. | |
Public Member Functions | |
template<std::ranges::forward_range range_type> | |
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. More... | |
virtual void | operator() (std::filesystem::path const &path) const =0 |
Tests if the given path is a valid input, respectively output, file or directory. More... | |
Constructors, destructor and assignment | |
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 |
Protected Member Functions | |
void | validate_filename (std::filesystem::path const &path) const |
Validates the given filename path based on the specified extensions. More... | |
void | validate_readability (std::filesystem::path const &path) const |
Checks if the given path is readable. More... | |
void | validate_writeability (std::filesystem::path const &path) const |
Checks if the given path is writable. More... | |
Protected Attributes | |
std::vector< std::string > | extensions {} |
Stores the extensions. | |
An abstract base class for the file and directory validators.
file_t | The type of the file to get the valid extensions for; void on default. |
This class provides a common interface for seqan3::input_file_validator and the seqan3::output_file_validator as well as the seqan3::input_directory_validator and seqan3::output_directory_validator.
The type can be further specialised for the seqan3::input_file_validator and the seqan3::output_file_validator using the template argument to determine the valid extensions from the given file type.
|
virtualdefault |
Virtual destructor.
|
inline |
Tests whether every path in list v
passes validation. See operator()(option_value_type const & value) for further information.
range_type | The type of range to check; must model std::ranges::forward_range and the value type must be convertible to std::filesystem::path. |
v | The input range to iterate over and check every element. |
parser_invalid_argument |
|
pure virtual |
Tests if the given path is a valid input, respectively output, file or directory.
path | The path to validate. |
This is a pure virtual function and must be overloaded by the derived class.
Implemented in seqan3::output_file_validator< file_t >, seqan3::input_file_validator< file_t >, seqan3::output_directory_validator, and seqan3::input_directory_validator.
|
inlineprotected |
Validates the given filename path based on the specified extensions.
path | The filename path. |
parser_invalid_argument | if the specified extensions don't match the given path, or std::filesystem::filesystem_error on underlying OS API errors. |
|
inlineprotected |
Checks if the given path is readable.
path | The path to check. |
true
if readable, otherwise false
. seqan3::parser_invalid_argument | if the path is not readable, or std::filesystem::filesystem_error on underlying OS API errors. |
|
inlineprotected |
Checks if the given path is writable.
path | The path to check. |
true
if writable, otherwise false
. seqan3::parser_invalid_argument | if the file could not be opened for writing, or std::filesystem::filesystem_error on underlying OS API errors. |