79 template <
typename val
idator_type>
83 requires(validator_type validator,
88 { validator(value) } -> void;
89 { validator.get_help_page_message() } ->
std::string;
127 if (!((cmp <= max) && (cmp >= min)))
137 template <std::ranges::ForwardRange range_type>
143 std::for_each(range.begin(), range.end(), [&] (
auto cmp) { (*this)(cmp); });
149 return detail::to_string(
"Value must be in range [", min,
",", max,
"].");
172 template <
typename option_value_type>
200 template <std::ranges::ForwardRange range_type>
206 std::for_each(range.begin(), range.end(), [&] (
auto cmp) { (*this)(cmp); });
212 return detail::to_string(
"Value must be one of ",
std::view::all(values),
".");
226 template <Arithmetic option_value_type>
229 template <Arithmetic option_value_type>
285 template <std::ranges::ForwardRange range_type>
310 " has no extension. Expected one of the following valid" 327 extensions,
"! Got ", drop_less_ext,
" instead!")};
344 if (static_cast<bool>(ec))
354 if (!file.is_open() || !file.good())
368 detail::safe_filesystem_entry file_guard{path};
370 bool is_open = file.is_open();
371 bool is_good = file.good();
374 if (!is_good || !is_open)
420 using file_validator_base::operator();
453 return detail::to_string(
"Valid input file formats: ",
495 using file_validator_base::operator();
527 return detail::to_string(
"Valid output file formats: ",
567 using file_validator_base::operator();
600 return detail::to_string(
"An existing, readable path for the input directory.");
639 using file_validator_base::operator();
653 if (static_cast<bool>(ec))
660 detail::safe_filesystem_entry dir_guard{dir};
662 dir_guard.remove_all();
682 return detail::to_string(
"A valid path for the output directory.");
733 template <std::ranges::ForwardRange range_type>
739 std::for_each(v.begin(), v.end(), [&] (
auto cmp) { (*this)(cmp); });
745 return detail::to_string(
"Value must match the pattern '", pattern,
"'.");
765 template <
typename option_value_type>
766 struct default_validator
769 using value_type = option_value_type;
772 void operator()(option_value_type
const & )
const noexcept
793 template <Val
idator val
idator1_type, Val
idator val
idator2_type>
797 class validator_chain_adaptor
801 using value_type =
typename validator1_type::value_type;
806 validator_chain_adaptor() =
delete;
807 validator_chain_adaptor(validator_chain_adaptor
const & pf) =
default;
808 validator_chain_adaptor & operator=(validator_chain_adaptor
const & pf) =
default;
809 validator_chain_adaptor(validator_chain_adaptor &&) =
default;
810 validator_chain_adaptor & operator=(validator_chain_adaptor &&) =
default;
816 validator_chain_adaptor(validator1_type vali1_, validator2_type vali2_) :
817 vali1{std::move(vali1_)}, vali2{std::move(vali2_)}
821 ~validator_chain_adaptor() =
default;
832 template <
typename cmp_type>
845 return detail::to_string(vali1.get_help_page_message(),
" ", vali2.get_help_page_message());
850 validator1_type vali1;
852 validator2_type vali2;
884 template <Val
idator val
idator1_type, Val
idator val
idator2_type>
889 auto operator|(validator1_type && vali1, validator2_type && vali2)
891 return detail::validator_chain_adaptor{std::forward<validator1_type>(vali1),
892 std::forward<validator2_type>(vali2)};
virtual void operator()(std::filesystem::path const &path) const =0
Tests if the given path is a valid input, respectively output, file or directory. ...
virtual ~output_file_validator()=default
Virtual Destructor.
::ranges::equal equal
Alias for ranges::equal. Determines if two sets of elements are the same.
Definition: algorithm:54
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:147
Provides concepts for core language types and relations that don't have concepts in C++20 (yet)...
A validator that checks if a given path is a valid output directory.
Definition: validators.hpp:618
virtual ~output_directory_validator()=default
Virtual Destructor.
A validator that checks if a given path is a valid output file.
Definition: validators.hpp:474
std::string value_type
Type of values that are tested by validator.
Definition: validators.hpp:250
void operator()(range_type const &v) const
Tests whether every path in list v passes validation. See operator()(value_type const & value) for fu...
Definition: validators.hpp:289
Provides various transformation trait base templates and shortcuts.
file_validator_base()=default
Defaulted.
void operator()(value_type const &cmp) const
Validates the value 'cmp' and throws a seqan3::validation_failed on failure.
virtual ~file_validator_base()=default
Virtual destructor.
void operator()(value_type const &cmp) const
Tests whether cmp lies inside values.
Definition: validators.hpp:720
Provides parser related exceptions.
T is_regular_file(T... args)
A validator that checks if a matches a regular expression pattern.
Definition: validators.hpp:703
constexpr auto drop
A view adaptor that returns all elements after n from the underlying range (or an empty range if the ...
Definition: drop.hpp:171
constexpr auto all
A view adaptor that behaves like std::view:all, but type erases contiguous ranges.
Definition: view_all.hpp:160
The main SeqAn3 namespace.
Auxiliary for pretty printing of exception messages.
std::vector< std::string > extensions
Stores the extensions.
Definition: validators.hpp:381
constexpr auto join
Flattens a View of ranges into a View.
Definition: ranges:683
value_list_validator(std::vector< value_type > v)
Constructing from a vector.
Definition: validators.hpp:182
void operator()(range_type const &v) const
Tests whether every filename in list v matches the pattern.
Definition: validators.hpp:737
T current_exception(T... args)
void operator()(value_type const &cmp) const
Tests whether cmp lies inside values.
Definition: validators.hpp:189
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:680
The concept std::ConvertibleTo<From, To> specifies that an expression of the type and value category ...
void operator()(value_type const &cmp) const
Tests whether cmp lies inside [min, max].
Definition: validators.hpp:125
file_validator_base(std::vector< std::string > extensions)
Constructs from a set of valid extensions.
Definition: validators.hpp:265
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
T has_extension(T... args)
Adaptations of concepts from the Ranges TS.
auto const to_lower
A view that calls seqan3::to_lower() on each element in the input range.
Definition: to_lower.hpp:67
T throw_with_nested(T... args)
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:210
option_value_type value_type
Type of values that are tested by validator.
Definition: validators.hpp:177
virtual void operator()(std::filesystem::path const &dir) const override
Tests whether path is writable.
Definition: validators.hpp:646
arithmetic_range_validator(value_type const min_, value_type const max_)
The constructor.
Definition: validators.hpp:117
Argument parser exception that is thrown whenever there is an error while parsing the command line ar...
Definition: exceptions.hpp:37
An abstract base class for the file and directory validators.
Definition: validators.hpp:245
A validator that checks whether a number is inside a given range.
Definition: validators.hpp:107
regex_validator(std::string const &pattern_)
Constructing from a vector.
Definition: validators.hpp:712
virtual void operator()(std::filesystem::path const &file) const override
Tests whether path is does not already exists and is writable.
Definition: validators.hpp:502
T create_directory(T... args)
double value_type
The type of value that this validator invoked upon.
Definition: validators.hpp:111
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:525
output_directory_validator()=default
Defaulted.
output_file_validator()=default
Defaulted.
Subsumes std::Movable, std::CopyConstructible, and requires that the type be std::Assignable bool fro...
void validate_filename(std::filesystem::path const &path) const
Validates the given filename path based on the specified extensions.
Definition: validators.hpp:301
Provides various type traits on generic types.
auto operator|(validator1_type &&vali1, validator2_type &&vali2)
Enables the chaining of validators.
Definition: validators.hpp:889
void operator()(range_type const &range) const
Tests whether every element in range lies inside [min, max].
Definition: validators.hpp:141
Adaptations of algorithms from the Ranges TS.
Provides seqan3::view::to_lower.
output_file_validator & operator=(output_file_validator const &)=default
Defaulted.
A validator that checks whether a value is inside a list of valid values.
Definition: validators.hpp:173
Specifies whether the given callable is invocable with the given arguments.
void validate_writeability(std::filesystem::path const &path) const
Checks if the given path is writable.
Definition: validators.hpp:365
::ranges::find_if find_if
Alias for ranges::find_if. Returns the first element in the range for which the predicate returns tru...
Definition: algorithm:69
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:743
Provides seqan3::detail::safe_filesystem_entry.
T rethrow_exception(T... args)
Provides seqan3::view::drop.
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Adaptations of concepts from the standard library.
Exposes the value_type of another type.
Definition: pre.hpp:41
void validate_readability(std::filesystem::path const &path) const
Checks if the given path is readable.
Definition: validators.hpp:337
A type that satisfies std::is_arithmetic_v<t>.
output_directory_validator & operator=(output_directory_validator const &)=default
Defaulted.
void operator()(range_type const &range) const
Tests whether every element in range lies inside values.
Definition: validators.hpp:204
using value_type
The type of value on which the validator is called on.
file_validator_base & operator=(file_validator_base const &)=default
Defaulted.
This header includes C++17 filesystem support and imports it into namespace seqan3::filesystem (indep...
T is_directory(T... args)