A validator that checks if a given path is a valid output directory.
More...
#include <seqan3/argument_parser/validators.hpp>
|
|
std::vector< std::string > | extensions {} |
| | Stores the extensions.
|
| |
A validator that checks if a given path is a valid output directory.
The class acts as a functor that throws a seqan3::validation_error exception whenever a given path (std::filesystem::path) is not writable. This can happen if either the parent path does not exists, or the path doesn't have the proper write permissions.
int main(int argc, const char ** argv)
{
std::filesystem::path mydir{};
myparser.
add_option(mydir,
'd',
"dir",
"The output directory for storing the files.",
try
{
myparser.parse();
}
{
std::cerr << "[PARSER ERROR] " << ext.what() << "\n";
return -1;
}
return 0;
}
Meta-Header for the argument parser module.
Argument parser exception that is thrown whenever there is an error while parsing the command line ar...
Definition: exceptions.hpp:49
The SeqAn command line parser.
Definition: argument_parser.hpp:154
void add_option(option_type &value, char const short_id, std::string const &long_id, std::string const &desc, option_spec const spec=option_spec::DEFAULT, validator_type option_validator=validator_type{})
Adds an option to the seqan3::argument_parser.
Definition: argument_parser.hpp:237
A validator that checks if a given path is a valid output directory.
Definition: validators.hpp:766
Provides seqan3::debug_stream and related types.
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
@ DEFAULT
The default were no checking or special displaying is happening.
Definition: auxiliary.hpp:234
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
- Note
- The validator works on every type that can be implicitly converted to std::filesystem::path.
◆ operator()() [1/2]
template<std::ranges::forward_range range_type>
| void seqan3::file_validator_base::operator() |
( |
range_type const & |
v | ) |
const |
|
inlineinherited |
Tests whether every path in list v passes validation. See operator()(option_value_type const & value) for further information.
- Template Parameters
-
| 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. |
- Parameters
-
| v | The input range to iterate over and check every element. |
- Exceptions
-
◆ operator()() [2/2]
| virtual void seqan3::output_directory_validator::operator() |
( |
std::filesystem::path const & |
dir | ) |
const |
|
inlineoverridevirtual |
Tests whether path is writable.
- Parameters
-
| dir | The input value to check. |
- Exceptions
-
| 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.
◆ validate_filename()
| void seqan3::file_validator_base::validate_filename |
( |
std::filesystem::path const & |
path | ) |
const |
|
inlineprotectedinherited |
Validates the given filename path based on the specified extensions.
- Parameters
-
- Exceptions
-
| seqan3::validation_error | if the specified extensions don't match the given path, or std::filesystem::filesystem_error on underlying OS API errors. |
◆ validate_readability()
| void seqan3::file_validator_base::validate_readability |
( |
std::filesystem::path const & |
path | ) |
const |
|
inlineprotectedinherited |
Checks if the given path is readable.
- Parameters
-
- Returns
true if readable, otherwise false.
- Exceptions
-
◆ validate_writeability()
| void seqan3::file_validator_base::validate_writeability |
( |
std::filesystem::path const & |
path | ) |
const |
|
inlineprotectedinherited |
Checks if the given path is writable.
- Parameters
-
- Returns
true if writable, otherwise false.
- Exceptions
-
| seqan3::validation_error | if the file could not be opened for writing, or std::filesystem::filesystem_error on underlying OS API errors. |
◆ operator()()
Validates the value 'cmp' and throws a seqan3::validation_error on failure.
- Template Parameters
-
| option_value_type | The type of the value to be validated. |
- Parameters
-
| [in,out] | cmp | The value to be validated. |
- Exceptions
-
- 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: