template<typename file_t = void>
class seqan3::output_file_validator< file_t >
A validator that checks if a given path is a valid output file.
- Template Parameters
-
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::string) is not in the given list of valid file extensions, or if the parent path does not have the proper writer permissions. In addition, the validator receives a seqan3::output_file_open_options which allows you to specify what to do if your output file already exists. seqan3::output_file_open_options::create_new will throw a seqan3::validation_error exception if it already exists and seqan3::output_file_open_options::open_or_create will skip this check (that means you are allowed to overwrite the existing file).
int main(int argc, const char ** argv)
{
std::filesystem::path myfile{};
myparser.
add_option(myfile,
'f',
"file",
"Output file containing the processed sequences.",
myparser.add_option(myfile, 'g', "file2", "Output file containing the processed sequences.",
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:38
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::standard, validator_type option_validator=validator_type{})
Adds an option to the seqan3::argument_parser.
Definition: argument_parser.hpp:248
A validator that checks if a given path is a valid output file.
Definition: validators.hpp:634
Provides seqan3::debug_stream and related types.
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
@ standard
The default were no checking or special displaying is happening.
Definition: auxiliary.hpp:239
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:37
@ create_new
Forbid overwriting the output file.
@ open_or_create
Allow to overwrite the output file.
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::output_file_validator.
int main(int argc, const char ** argv)
{
std::vector{std::string{"exe"}, std::string{"fasta"}}};
{
};
return 0;
}
Provides seqan3::sequence_file_output and corresponding traits classes.
Provides some standard validators for (positional) options.
- Note
- The validator works on every type that can be implicitly converted to std::filesystem::path.