82 template <
typename val
idator_type>
86 requires(validator_type validator,
91 { validator(value) } -> void;
92 { validator.get_help_page_message() } ->
std::string;
128 if (!((cmp <= max) && (cmp >= min)))
138 template <std::ranges::forward_range range_type>
144 std::for_each(range.begin(), range.end(), [&] (
auto cmp) { (*this)(cmp); });
150 return detail::to_string(
"Value must be in range [", min,
",", max,
"].");
178 template <
typename option_value_t>
200 template <std::ranges::forward_range range_type>
215 template <
typename ...option_types>
221 (values.emplace_back(std::forward<option_types>(opts)), ...);
231 if (!(
std::find(values.begin(), values.end(), cmp) != values.end()))
240 template <std::ranges::forward_range range_type>
246 std::for_each(std::ranges::begin(range), std::ranges::end(range), [&] (
auto cmp) { (*this)(cmp); });
252 return detail::to_string(
"Value must be one of ",
std::views::all(values),
".");
270 template <std::ranges::forward_range range_type>
277 template <
typename ...option_types>
284 template <std::ranges::forward_range range_type>
291 template <
typename ...option_types>
295 template <std::ranges::forward_range range_type>
345 template <std::ranges::forward_range range_type>
364 if (extensions.empty())
370 " has no extension. Expected one of the following valid" 371 " extensions:", extensions,
"!")};
387 extensions,
"! Got ", drop_less_ext,
" instead!")};
404 if (static_cast<bool>(ec))
414 if (!file.is_open() || !file.good())
428 detail::safe_filesystem_entry file_guard{path};
430 bool is_open = file.is_open();
431 bool is_good = file.good();
434 if (!is_good || !is_open)
466 template <
typename file_t =
void>
472 "Expected either a template type with a static member called valid_formats (a file type) or void.");
523 using file_validator_base::operator();
538 validate_readability(file);
541 validate_filename(file);
556 return detail::to_string(
"Valid input file formats: [",
584 template <
typename file_t =
void>
590 "Expected either a template type with a static member called valid_formats (a file type) or void.");
627 using file_validator_base::operator();
642 validate_writeability(file);
644 validate_filename(file);
659 return detail::to_string(
"Valid output file formats: [",
700 using file_validator_base::operator();
718 validate_readability(dir);
733 return detail::to_string(
"An existing, readable path for the input directory.");
772 using file_validator_base::operator();
786 if (static_cast<bool>(ec))
793 detail::safe_filesystem_entry dir_guard{dir};
794 validate_writeability(dir /
"dummy.txt");
795 dir_guard.remove_all();
799 validate_writeability(dir /
"dummy.txt");
815 return detail::to_string(
"A valid path for the output directory.");
866 template <std::ranges::forward_range range_type>
872 std::for_each(v.begin(), v.end(), [&] (
auto cmp) { (*this)(cmp); });
878 return detail::to_string(
"Value must match the pattern '", pattern,
"'.");
899 template <
typename option_value_t>
900 struct default_validator
906 void operator()(option_value_t
const & )
const noexcept
927 template <val
idator val
idator1_type, val
idator val
idator2_type>
931 class validator_chain_adaptor
940 validator_chain_adaptor() =
delete;
941 validator_chain_adaptor(validator_chain_adaptor
const & pf) =
default;
942 validator_chain_adaptor & operator=(validator_chain_adaptor
const & pf) =
default;
943 validator_chain_adaptor(validator_chain_adaptor &&) =
default;
944 validator_chain_adaptor & operator=(validator_chain_adaptor &&) =
default;
950 validator_chain_adaptor(validator1_type vali1_, validator2_type vali2_) :
955 ~validator_chain_adaptor() =
default;
966 template <
typename cmp_type>
979 return detail::to_string(vali1.get_help_page_message(),
" ", vali2.get_help_page_message());
984 validator1_type vali1;
986 validator2_type vali2;
1018 template <val
idator val
idator1_type, val
idator val
idator2_type>
1023 auto operator|(validator1_type && vali1, validator2_type && vali2)
1025 return detail::validator_chain_adaptor{std::forward<validator1_type>(vali1),
1026 std::forward<validator2_type>(vali2)};
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:148
Provides concepts for core language types and relations that don't have concepts in C++20 (yet)...
typename decltype(detail::front< pack_t... >())::type front
Return the first type from the type pack.
Definition: traits.hpp:240
double option_value_type
The type of value that this validator invoked upon.
Definition: validators.hpp:112
output_file_validator(std::vector< std::string > extensions)
Constructs from a given collection of valid extensions.
Definition: validators.hpp:613
A validator that checks if a given path is a valid output directory.
Definition: validators.hpp:751
A validator that checks if a given path is a valid output file.
Definition: validators.hpp:585
std::string option_value_type
Type of values that are tested by validator.
Definition: validators.hpp:316
void operator()(range_type const &v) const
Tests whether every path in list v passes validation. See operator()(option_value_type const & value)...
Definition: validators.hpp:349
Provides various transformation trait base templates and shortcuts.
Specifies whether the given callable is invocable with the given arguments.
file_validator_base()=default
Defaulted.
Provides parser related exceptions.
T is_regular_file(T... args)
Provides traits for seqan3::type_list.
A validator that checks if a matches a regular expression pattern.
Definition: validators.hpp:836
Provides seqan3::views::join.
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:250
The main SeqAn3 namespace.
Auxiliary for pretty printing of exception messages.
std::vector< std::string > extensions
Stores the extensions.
Definition: validators.hpp:441
A type that satisfies std::is_arithmetic_v<t>.
void operator()(range_type const &v) const
Tests whether every filename in list v matches the pattern.
Definition: validators.hpp:870
T current_exception(T... args)
arithmetic_range_validator(option_value_type const min_, option_value_type const max_)
The constructor.
Definition: validators.hpp:118
detail::search_mode_all constexpr all
Configuration element to receive all hits within the error bounds.
Definition: mode.hpp:43
option_value_t option_value_type
Type of values that are tested by validator.
Definition: validators.hpp:183
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:813
auto const to_lower
A view that calls seqan3::to_lower() on each element in the input range.
Definition: to_lower.hpp:66
void operator()(option_value_type const &cmp) const
Tests whether cmp lies inside values.
Definition: validators.hpp:853
Provides various utility functions.
virtual void operator()(std::filesystem::path const &file) const override
Tests whether path is does not already exists and is writable.
Definition: validators.hpp:634
T has_extension(T... args)
Adaptations of concepts from the Ranges TS.
T throw_with_nested(T... args)
constexpr ptrdiff_t find_if
Get the index of the first type in a pack that satisfies the given predicate.
Definition: traits.hpp:175
virtual void operator()(std::filesystem::path const &dir) const override
Tests whether path is writable.
Definition: validators.hpp:779
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:311
A validator that checks whether a number is inside a given range.
Definition: validators.hpp:108
regex_validator(std::string const &pattern_)
Constructing from a vector.
Definition: validators.hpp:845
T create_directory(T... args)
The std::constructible_from concept specifies that a variable of type T can be initialized with the g...
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:68
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:168
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:657
void validate_filename(std::filesystem::path const &path) const
Validates the given filename path based on the specified extensions.
Definition: validators.hpp:361
Provides various type traits on generic types.
auto operator|(validator1_type &&vali1, validator2_type &&vali2)
Enables the chaining of validators.
Definition: validators.hpp:1023
void operator()(range_type const &range) const
Tests whether every element in range lies inside [min, max].
Definition: validators.hpp:142
The concept std::convertible_to<From, To> specifies that an expression of the type and value category...
Adaptations of algorithms from the Ranges TS.
Provides seqan3::views::to_lower.
A validator that checks whether a value is inside a list of valid values.
Definition: validators.hpp:179
void operator()(option_value_type const &cmp) const
Tests whether cmp lies inside values.
Definition: validators.hpp:229
void validate_writeability(std::filesystem::path const &path) const
Checks if the given path is writable.
Definition: validators.hpp:425
value_list_validator(range_type rng)
Constructing from a range.
Definition: validators.hpp:204
Subsumes std::movable, std::copy_constructible, and requires that the type be std::assignable_from bo...
std::string get_help_page_message() const
Returns a message that can be appended to the (positional) options help page info.
Definition: validators.hpp:876
void operator()(range_type const &range) const
Tests whether every element in range lies inside values.
Definition: validators.hpp:244
Provides seqan3::detail::safe_filesystem_entry.
T rethrow_exception(T... args)
Provides seqan3::views::drop.
Adaptations of concepts from the standard library.
void validate_readability(std::filesystem::path const &path) const
Checks if the given path is readable.
Definition: validators.hpp:397
The concept std::same_as<T, U> is satisfied if and only if T and U denote the same type...
void operator()(option_value_type const &cmp) const
Tests whether cmp lies inside [min, max].
Definition: validators.hpp:126
This header includes C++17 filesystem support and imports it into namespace seqan3::filesystem (indep...
T is_directory(T... args)