SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::file_validator_base Class Referenceabstract

An abstract base class for the file and directory validators. More...

#include <seqan3/argument_parser/validators.hpp>

+ Inheritance diagram for seqan3::file_validator_base:

Public Types

using option_value_type = std::string
 Type of values that are tested by validator.
 

Public Member Functions

virtual void operator() (std::filesystem::path const &path) const =0
 Tests if the given path is a valid input, respectively output, file or directory. More...
 
template<std::ranges::forward_range range_type>
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. More...
 
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_baseoperator= (file_validator_base const &)=default
 Defaulted.
 
file_validator_baseoperator= (file_validator_base &&)=default
 Defaulted.
 
virtual ~file_validator_base ()=default
 

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::stringextensions {}
 Stores the extensions.
 

Detailed Description

An abstract base class for the file and directory validators.

Template Parameters
file_tThe 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.

Constructor & Destructor Documentation

◆ ~file_validator_base()

virtual seqan3::file_validator_base::~file_validator_base ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ operator()() [1/2]

virtual void seqan3::file_validator_base::operator() ( std::filesystem::path const &  path) const
pure virtual

Tests if the given path is a valid input, respectively output, file or directory.

Parameters
pathThe path to validate.

This is a pure virtual function and must be overloaded by the derived class.

Implemented in seqan3::output_directory_validator, seqan3::input_directory_validator, seqan3::output_file_validator< file_t >, and seqan3::input_file_validator< file_t >.

◆ operator()() [2/2]

template<std::ranges::forward_range range_type>
void seqan3::file_validator_base::operator() ( range_type const &  v) const
inline

Tests whether every path in list v passes validation. See operator()(option_value_type const & value) for further information.

Template Parameters
range_typeThe type of range to check; must model std::ranges::forward_range and the value type must be convertible to std::filesystem::path.
Parameters
vThe input range to iterate over and check every element.
Exceptions
parser_invalid_argument

◆ validate_filename()

void seqan3::file_validator_base::validate_filename ( std::filesystem::path const &  path) const
inlineprotected

Validates the given filename path based on the specified extensions.

Parameters
pathThe filename path.
Exceptions
parser_invalid_argumentif 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
inlineprotected

Checks if the given path is readable.

Parameters
pathThe path to check.
Returns
true if readable, otherwise false.
Exceptions
seqan3::parser_invalid_argumentif the path is not readable, or std::filesystem::filesystem_error on underlying OS API errors.

◆ validate_writeability()

void seqan3::file_validator_base::validate_writeability ( std::filesystem::path const &  path) const
inlineprotected

Checks if the given path is writable.

Parameters
pathThe path to check.
Returns
true if writable, otherwise false.
Exceptions
seqan3::parser_invalid_argumentif the file could not be opened for writing, or std::filesystem::filesystem_error on underlying OS API errors.

The documentation for this class was generated from the following file: