A validator that checks if a given path is a valid output file.
More...
#include <seqan3/argument_parser/validators.hpp >
using option_value_type = std::string
Type of values that are tested by validator.
using option_value_type = std::string
Type of values that are tested by validator.
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, char const ** argv)
{
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();
}
{
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:37
The SeqAn command line parser.
Definition argument_parser.hpp:145
A validator that checks if a given path is a valid output file.
Definition validators.hpp:645
Provides seqan3::debug_stream and related types.
@ standard
The default were no checking or special displaying is happening.
Definition auxiliary.hpp:248
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()
{
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 .
◆ output_file_validator() [1/2] [no-api]
template<typename file_t = void>
Default constructor.
If the class' template argument file_t
names a valid seqan3 file type that contains a static member valid_formats
, e.g. seqan3::sequence_input_file::valid_formats, then it generates the list of valid extensions from this file. Otherwise the extensions list is empty.
◆ output_file_validator() [2/2] [no-api]
template<typename file_t = void>
Constructs from a given overwrite mode and a list of valid extensions.
Parameters
◆ default_extensions() [no-api]
template<typename file_t = void>
The default extensions of file_t
.
Returns A list of default extensions for file_t
, will be empty if file_t
is void
.
If file_t
does name a valid seqan3 file type that contains a static member valid_formats
returns the extensions of that file_t
type. Otherwise returns an empty list.
◆ get_help_page_message() [no-api]
template<typename file_t = void>
Returns a message that can be appended to the (positional) options help page info.
Implements validator .
◆ operator()() [no-api]
template<typename file_t = void>
no-api inline override virtual
Tests whether path is does not already exists and is writable.
Parameters
file The input value to check.
Exceptions
Implements seqan3::file_validator_base .
The documentation for this class was generated from the following file: