A validator that checks if a given path is a valid output file. More...
#include <seqan3/argument_parser/validators.hpp>
Public Types | |
using | 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. | |
template<std::ranges::ForwardRange range_type> | |
void | operator() (range_type const &v) const |
Tests whether every path in list v passes validation. See operator()(value_type const & value) for further information. More... | |
virtual void | operator() (std::filesystem::path const &file) const override |
Tests whether path is does not already exists and is writable. More... | |
Constructors, destructor and assignment | |
output_file_validator ()=default | |
Defaulted. | |
output_file_validator (output_file_validator const &)=default | |
Defaulted. | |
output_file_validator (output_file_validator &&)=default | |
Defaulted. | |
output_file_validator & | operator= (output_file_validator const &)=default |
Defaulted. | |
output_file_validator & | operator= (output_file_validator &&)=default |
Defaulted. | |
virtual | ~output_file_validator ()=default |
Virtual Destructor. | |
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 (std::vector< std::string > extensions) | |
Constructs from a set of valid extensions. More... | |
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. | |
Related Functions | |
(Note that these are not member functions.) | |
Requirements for seqan3::Validator | |
You can expect these (meta-)functions on all types that implement seqan3::Validator. | |
void | operator() (value_type const &cmp) const |
Validates the value 'cmp' and throws a seqan3::validation_failed on failure. More... | |
A validator that checks if a given path is a valid output file.
On construction, the validator can receive a list (std::vector over std::string) of valid file extensions. The struct acts as a functor that throws a seqan3::parser_invalid_argument exception whenever a given filename's extension (sts::string) is not in the given list of valid file extensions, if the file already exist, or if the parent path does not have the proper writer permissions.
|
inlineexplicit |
Constructs from a set of valid extensions.
[in] | extensions | The valid extensions to validate for. |
|
inlineinherited |
Tests whether every path in list v
passes validation. See operator()(value_type const & value) for further information.
range_type | The type of range to check; must model std::ranges::ForwardRange 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 |
|
inlineoverridevirtual |
Tests whether path is does not already exists and is writable.
file | The input value to check. |
parser_invalid_argument | if the validation process failed. Might be nested with std::filesystem::filesystem_error on unhandled OS API errors. |
Implements seqan3::file_validator_base.
|
inlineprotectedinherited |
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. |
|
inlineprotectedinherited |
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. |
|
inlineprotectedinherited |
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. |
|
related |
Validates the value 'cmp' and throws a seqan3::validation_failed on failure.
value_type | The type of the value to be validated. |
[in,out] | cmp | The value to be validated. |
seqan3::validation_failed | if value 'cmp' does not pass validation. |