SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
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> 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. | |
virtual void | operator() (std::filesystem::path const &path) const =0 |
Tests if the given path is a valid input, respectively output, file or directory. | |
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 | |
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 | |
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.
|
inlineprotected |
Helper function that checks if a string is a suffix of another string. Case insensitive.
str | The string to be searched. |
suffix | The suffix to be searched for. |
true
if suffix
is a suffix of str
, otherwise false
.
|
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. |
seqan3::validation_error |
|
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::input_directory_validator, seqan3::output_directory_validator, seqan3::input_file_validator< file_t >, and seqan3::output_file_validator< file_t >.
|
inlineprotected |
Validates the given filename path based on the specified extensions.
path | The filename path. |
seqan3::validation_error | 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. |
seqan3::validation_error | 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. |
seqan3::validation_error | if the file could not be opened for writing, or std::filesystem::filesystem_error on underlying OS API errors. |