31 #if defined CLI11_CPP17 && defined __has_include && !defined CLI11_HAS_FILESYSTEM 32 #if __has_include(<filesystem>) 34 #if defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 35 #define CLI11_HAS_FILESYSTEM 0 36 #elif defined(__wasi__) 38 #define CLI11_HAS_FILESYSTEM 0 41 #if defined __cpp_lib_filesystem && __cpp_lib_filesystem >= 201703 42 #if defined _GLIBCXX_RELEASE && _GLIBCXX_RELEASE >= 9 43 #define CLI11_HAS_FILESYSTEM 1 44 #elif defined(__GLIBCXX__) 46 #define CLI11_HAS_FILESYSTEM 0 48 #define CLI11_HAS_FILESYSTEM 1 51 #define CLI11_HAS_FILESYSTEM 0 57 #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0 61 #include <sys/types.h> 88 std::function<std::string(std::string &)>
func_{[](std::string &) {
return std::string{}; }};
98 Validator(std::string validator_desc, std::function<std::string(std::string &)> func)
106 Validator(std::function<std::string(std::string &)> op, std::string validator_desc, std::string validator_name =
"")
108 name_(std::move(validator_name)) {}
111 func_ = std::move(op);
116 std::string
operator()(std::string &str)
const;
121 std::string value = str;
138 return std::string{};
142 name_ = std::move(validator_name);
148 newval.
name_ = std::move(validator_name);
201 void _merge_description(
const Validator &val1,
const Validator &val2,
const std::string &merger);
272 :
Validator(validator_name, [](
std::string &input_string) {
274 auto val = DesiredType();
276 return std::string(
"Failed parsing ") + input_string +
" as a " + detail::type_name<DesiredType>();
278 return std::string();
284 const TypeValidator<double>
Number(
"NUMBER");
290 explicit FileOnDefaultPath(std::string default_path,
bool enableErrorReturn =
true);
300 template <
typename T>
301 Range(T min_val, T max_val,
const std::string &validator_name = std::string{}) :
Validator(validator_name) {
302 if(validator_name.empty()) {
303 std::stringstream out;
304 out << detail::type_name<T>() <<
" in [" << min_val <<
" - " << max_val <<
"]";
308 func_ = [min_val, max_val](std::string &input) {
312 if((!converted) || (val < min_val || val > max_val)) {
313 std::stringstream out;
314 out <<
"Value " << input <<
" not in range [";
315 out << min_val <<
" - " << max_val <<
"]";
318 return std::string{};
323 template <
typename T>
324 explicit Range(T max_val,
const std::string &validator_name = std::string{})
325 :
Range(static_cast<T>(0), max_val, validator_name) {}
329 const Range
NonNegativeNumber((std::numeric_limits<double>::max)(),
"NONNEGATIVE");
332 const Range
PositiveNumber((std::numeric_limits<double>::min)(), (std::numeric_limits<double>::max)(),
"POSITIVE");
341 template <
typename T>
Bound(T min_val, T max_val) {
342 std::stringstream out;
343 out << detail::type_name<T>() <<
" bounded to [" << min_val <<
" - " << max_val <<
"]";
346 func_ = [min_val, max_val](std::string &input) {
351 return std::string(
"Value ") + input +
" could not be converted";
355 else if(val > max_val)
358 return std::string{};
363 template <
typename T>
explicit Bound(T max_val) :
Bound(static_cast<T>(0), max_val) {}
367 template <
typename T,
383 std::string out(1,
'{');
393 template <
typename T> std::string
generate_map(
const T &map,
bool key_only =
false) {
396 std::string out(1,
'{');
399 [key_only](
const iteration_type_t &v) {
413 template <
typename C,
typename V>
struct has_find {
414 template <
typename CC,
typename VV>
415 static auto test(
int) -> decltype(std::declval<CC>().find(std::declval<VV>()), std::true_type());
416 template <
typename,
typename>
static auto test(...) -> decltype(std::false_type());
419 using type = std::integral_constant<bool, value>;
424 auto search(
const T &
set,
const V &val) -> std::pair<bool, decltype(std::begin(detail::smart_deref(set)))> {
427 auto it = std::find_if(std::begin(setref), std::end(setref), [&val](decltype(*std::begin(setref)) v) {
430 return {(it != std::end(setref)), it};
435 auto search(
const T &
set,
const V &val) -> std::pair<bool, decltype(std::begin(detail::smart_deref(set)))> {
437 auto it = setref.find(val);
438 return {(it != std::end(setref)), it};
442 template <
typename T,
typename V>
443 auto search(
const T &
set,
const V &val,
const std::function<V(V)> &filter_function)
444 -> std::pair<bool, decltype(std::begin(detail::smart_deref(set)))> {
447 auto res =
search(
set, val);
448 if((res.first) || (!(filter_function))) {
453 auto it = std::find_if(std::begin(setref), std::end(setref), [&](decltype(*std::begin(setref)) v) {
455 a = filter_function(a);
458 return {(it != std::end(setref)), it};
465 template <
typename T>
466 inline typename std::enable_if<std::is_signed<T>::value, T>::type
overflowCheck(
const T &a,
const T &b) {
467 if((a > 0) == (b > 0)) {
468 return ((std::numeric_limits<T>::max)() / (std::abs)(a) < (std::abs)(b));
470 return ((std::numeric_limits<T>::min)() / (std::abs)(a) > -(std::abs)(b));
473 template <
typename T>
474 inline typename std::enable_if<!std::is_signed<T>::value, T>::type
overflowCheck(
const T &a,
const T &b) {
475 return ((std::numeric_limits<T>::max)() / a < b);
479 template <
typename T>
typename std::enable_if<std::is_integral<T>::value,
bool>::type
checked_multiply(T &a, T b) {
480 if(a == 0 || b == 0 || a == 1 || b == 1) {
484 if(a == (std::numeric_limits<T>::min)() || b == (std::numeric_limits<T>::min)()) {
495 template <
typename T>
496 typename std::enable_if<std::is_floating_point<T>::value,
bool>::type
checked_multiply(T &a, T b) {
498 if(std::isinf(c) && !std::isinf(a) && !std::isinf(b)) {
512 template <
typename T,
typename... Args>
513 IsMember(std::initializer_list<T> values, Args &&...args)
514 :
IsMember(
std::vector<T>(values),
std::forward<Args>(args)...) {}
521 template <
typename T,
typename F>
explicit IsMember(T
set, F filter_function) {
532 std::function<local_item_t(local_item_t)> filter_fn = filter_function;
539 func_ = [
set, filter_fn](std::string &input) {
556 return std::string{};
565 template <
typename T,
typename... Args>
568 std::forward<T>(set),
569 [filter_fn_1, filter_fn_2](
std::string a) {
return filter_fn_2(filter_fn_1(a)); },
574 template <
typename T>
using TransformPairs = std::vector<std::pair<std::string, T>>;
582 template <
typename... Args>
583 Transformer(std::initializer_list<std::pair<std::string, std::string>> values, Args &&...args)
591 template <
typename T,
typename F>
explicit Transformer(T mapping, F filter_function) {
594 "mapping must produce value pairs");
603 std::function<local_item_t(local_item_t)> filter_fn = filter_function;
608 func_ = [mapping, filter_fn](std::string &input) {
612 return std::string();
622 return std::string{};
627 template <
typename T,
typename... Args>
630 std::forward<T>(mapping),
631 [filter_fn_1, filter_fn_2](
std::string a) {
return filter_fn_2(filter_fn_1(a)); },
641 template <
typename... Args>
642 CheckedTransformer(std::initializer_list<std::pair<std::string, std::string>> values, Args &&...args)
653 "mapping must produce value pairs");
663 std::function<local_item_t(local_item_t)> filter_fn = filter_function;
665 auto tfunc = [mapping]() {
666 std::string out(
"value in ");
678 func_ = [mapping, tfunc, filter_fn](std::string &input) {
689 return std::string{};
694 if(output_string == input) {
695 return std::string();
699 return "Check " + input +
" " + tfunc() +
" FAILED";
704 template <
typename T,
typename... Args>
707 std::forward<T>(mapping),
708 [filter_fn_1, filter_fn_2](
std::string a) {
return filter_fn_2(filter_fn_1(a)); },
720 item.erase(std::remove(std::begin(item), std::end(item),
' '), std::end(item));
721 item.erase(std::remove(std::begin(item), std::end(item),
'\t'), std::end(item));
750 template <
typename Number>
753 const std::string &unit_name =
"UNIT") {
754 description(generate_description<Number>(unit_name, opts));
755 validate_mapping(mapping, opts);
758 func_ = [mapping, opts](std::string &input) -> std::string {
767 auto unit_begin = input.end();
768 while(unit_begin > input.begin() &&
std::isalpha(*(unit_begin - 1), std::locale())) {
772 std::string unit{unit_begin, input.end()};
773 input.resize(static_cast<std::size_t>(std::distance(input.begin(), unit_begin)));
785 throw ValidationError(std::string(
"Value ") + input +
" could not be converted to " +
786 detail::type_name<Number>());
793 auto it = mapping.find(unit);
794 if(it == mapping.end()) {
796 " unit not recognized. " 805 throw ValidationError(std::string(
"Value ") + input +
" could not be converted to " +
806 detail::type_name<Number>());
812 " factor would cause number overflow. Use smaller value.");
815 num =
static_cast<Number>(it->second);
827 template <
typename Number>
static void validate_mapping(std::map<std::string, Number> &mapping,
Options opts) {
828 for(
auto &kv : mapping) {
829 if(kv.first.empty()) {
839 std::map<std::string, Number> lower_mapping;
840 for(
auto &kv : mapping) {
842 if(lower_mapping.count(s)) {
843 throw ValidationError(std::string(
"Several matching lowercase unit representations are found: ") +
848 mapping = std::move(lower_mapping);
853 template <
typename Number>
static std::string generate_description(
const std::string &
name,
Options opts) {
854 std::stringstream out;
855 out << detail::type_name<Number>() <<
' ';
859 out <<
'[' <<
name <<
']';
895 static std::map<std::string, result_t> init_mapping(
bool kb_is_1000);
898 static std::map<std::string, result_t> get_mapping(
bool kb_is_1000);
914 #ifndef CLI11_COMPILE 915 #include "impl/Validators_inl.hpp" CLI11_NODISCARD const std::string & get_name() const
Get the name of the Validator.
Definition: Validators.hpp:152
std::uint64_t result_t
Definition: Validators.hpp:882
Definition: Validators.hpp:736
path_type
CLI enumeration of different file types.
Definition: Validators.hpp:214
std::string name_
The name for search purposes of the Validator.
Definition: Validators.hpp:90
std::enable_if< std::is_signed< T >::value, T >::type overflowCheck(const T &a, const T &b)
Do a check for overflow on signed numbers.
Definition: Validators.hpp:466
TypeValidator(const std::string &validator_name)
Definition: Validators.hpp:271
Options
Definition: Validators.hpp:742
Validate the input as a particular type.
Definition: Validators.hpp:269
ExistingDirectoryValidator()
const detail::NonexistentPathValidator NonexistentPath
Check for an non-existing path.
Definition: Validators.hpp:263
Range(T max_val, const std::string &validator_name=std::string{})
Range of one value is 0 to value.
Definition: Validators.hpp:324
Adaptor for set-like structure: This just wraps a normal container in a few utilities that do almost ...
Definition: TypeTools.hpp:109
enabler
Simple empty scoped class.
Definition: TypeTools.hpp:32
Check for an existing directory (returns error message if check fails)
Definition: Validators.hpp:226
Validator(std::string validator_desc)
Construct a Validator with just the description string.
Definition: Validators.hpp:104
bool non_modifying_
specify that a validator should not modify the input
Definition: Validators.hpp:96
const TypeValidator< double > Number("NUMBER")
Check for a number.
std::string ignore_space(std::string item)
Helper function to allow checks to ignore spaces to be passed to IsMember or Transform.
Definition: Validators.hpp:719
Produce a bounded range (factory). Min and max are inclusive.
Definition: Validators.hpp:335
std::string generate_set(const T &set)
Generate a string representation of a set.
Definition: Validators.hpp:380
Class wrapping some of the accessors of Validator.
Definition: Validators.hpp:205
TypeValidator()
Definition: Validators.hpp:280
Definition: Validators.hpp:288
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size() { return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >);}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type > { static constexpr int value{tuple_type_size< T, 0 >)};};template< typename T > struct subtype_count { static constexpr int value{is_mutable_container< T >::value ? expected_max_vector_size :type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min { static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type > { static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type > { static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type > { static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min() { return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min() { return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >);}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type > { static constexpr int value{tuple_type_size_min< T, 0 >)};};template< typename T > struct subtype_count_min { static constexpr int value{is_mutable_container< T >::value ?((type_count< T >::value< expected_max_vector_size) ? type_count< T >::value :0) :type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count { static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type > { static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type > { static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type > { static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category :int { char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object { static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type > { static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type > { static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type > { static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type > { static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1) &&std::is_constructible< T, std::string >::value >::type > { static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type > { static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type { using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type > { static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type > { static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type > { static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name() { return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >);}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name() { return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name() { auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >)}+','+tuple_name< T, I+1 >);if(str.back()==',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
Definition: TypeTools.hpp:799
std::function< std::string(std::string)> filter_fn_t
Definition: Validators.hpp:509
AsNumberWithUnit(std::map< std::string, Number > mapping, Options opts=DEFAULT, const std::string &unit_name="UNIT")
Definition: Validators.hpp:751
Validator operator|(const Validator &other) const
std::string ignore_case(std::string item)
Helper function to allow ignore_case to be passed to IsMember or Transform.
Definition: Validators.hpp:713
Check for an non-existing path.
Definition: Validators.hpp:238
AsSizeValue(bool kb_is_1000)
std::function< std::string(std::string &)> func_
Definition: Validators.hpp:88
auto smart_deref(T value) -> decltype(*value)
Definition: Validators.hpp:369
typename std::remove_const< value_type >::type first_type
Definition: TypeTools.hpp:111
Validate the given string is a legal ipv4 address.
Definition: Validators.hpp:244
bool lexical_cast(const std::string &input, T &output)
Integer conversion.
Definition: TypeTools.hpp:913
constexpr enabler dummy
An instance to use in EnableIf.
Definition: TypeTools.hpp:35
Definition: Validators.hpp:880
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)
Definition: TypeTools.hpp:281
std::integral_constant< bool, value > type
Definition: Validators.hpp:419
Definition: Validators.hpp:745
int application_index_
A Validator will only apply to an indexed value (-1 is all elements)
Definition: Validators.hpp:92
static const auto value
Definition: Validators.hpp:418
Definition: Validators.hpp:413
FileOnDefaultPath(std::string default_path, bool enableErrorReturn=true)
IsMember(T set, F filter_function)
Definition: Validators.hpp:521
CLI11_INLINE path_type check_path(const char *file) noexcept
get the type of the path from a file name
Validator operator &(const Validator &other) const
CLI11_NODISCARD Validator active(bool active_val=true) const
Specify whether the Validator is active or not.
Definition: Validators.hpp:159
#define CLI11_INLINE
Definition: Macros.hpp:73
const detail::IPV4Validator ValidIPV4
Check for an IP4 address.
Definition: Validators.hpp:266
Bound(T max_val)
Range of one value is 0 to value.
Definition: Validators.hpp:363
const detail::ExistingFileValidator ExistingFile
Check for existing file (returns error message if check fails)
Definition: Validators.hpp:254
std::string ignore_underscore(std::string item)
Helper function to allow ignore_underscore to be passed to IsMember or Transform. ...
Definition: Validators.hpp:716
std::string join(const T &v, std::string delim=",")
Simple function to join a string.
Definition: StringTools.hpp:51
Produce a range (factory). Min and max are inclusive.
Definition: Validators.hpp:294
Check for an existing path.
Definition: Validators.hpp:232
static auto test(int) -> decltype(std::declval< CC >().find(std::declval< VV >()), std::true_type())
NonexistentPathValidator()
Bound(T min_val, T max_val)
Definition: Validators.hpp:341
auto search(const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
A search function.
Definition: Validators.hpp:424
CLI11_NODISCARD bool get_modifying() const
Get a boolean if the validator is allowed to modify the input returns true if it can modify the input...
Definition: Validators.hpp:187
const detail::ExistingPathValidator ExistingPath
Check for an existing path.
Definition: Validators.hpp:260
std::string & trim(std::string &str)
Trim whitespace from string.
Definition: StringTools.hpp:109
CLI11_INLINE std::string & rtrim(std::string &str)
Trim whitespace from right of string.
std::string remove_underscore(std::string str)
remove underscores from a string
Definition: StringTools.hpp:182
Validator(std::function< std::string(std::string &)> op, std::string validator_desc, std::string validator_name="")
Construct Validator from basic information.
Definition: Validators.hpp:106
Definition: Validators.hpp:743
Validator & name(std::string validator_name)
Specify the type string.
Definition: Validators.hpp:141
typename std::enable_if< B, T >::type enable_if_t
Definition: TypeTools.hpp:43
std::vector< std::pair< std::string, T > > TransformPairs
definition of the default transformation object
Definition: Validators.hpp:574
std::string operator()(std::string &str) const
IsMember(T &&set)
This checks to see if an item is in a set (empty function)
Definition: Validators.hpp:517
IsMember(std::initializer_list< T > values, Args &&...args)
This allows in-place construction using an initializer list.
Definition: Validators.hpp:513
Validator & application_index(int app_index)
Specify the application index of a validator.
Definition: Validators.hpp:171
Definition: Validators.hpp:747
IsMember(T &&set, filter_fn_t filter_fn_1, filter_fn_t filter_fn_2, Args &&...other)
You can pass in as many filter functions as you like, they nest (string only currently) ...
Definition: Validators.hpp:566
CLI11_INLINE std::pair< std::string, std::string > split_program_name(std::string commandline)
CLI11_NODISCARD int get_application_index() const
Get the current value of the application index.
Definition: Validators.hpp:182
std::string to_lower(std::string str)
Return a lower case version of a string.
Definition: StringTools.hpp:174
Verify items are in a set.
Definition: Validators.hpp:507
static auto first(Q &&pair_value) -> decltype(std::forward< Q >(pair_value))
Get the first value (really just the underlying value)
Definition: TypeTools.hpp:115
#define CLI11_NODISCARD
Definition: Macros.hpp:47
Some validators that are provided.
Definition: Validators.hpp:81
Validator(std::string validator_desc, std::function< std::string(std::string &)> func)
Definition: Validators.hpp:98
Definition: Validators.hpp:744
bool active_
Enable for Validator to allow it to be disabled if need be.
Definition: Validators.hpp:94
CLI11_NODISCARD Validator application_index(int app_index) const
Specify the application index of a validator.
Definition: Validators.hpp:176
const Range PositiveNumber((std::numeric_limits< double >::min)(),(std::numeric_limits< double >::max)(), "POSITIVE")
Check for a positive valued number (val>0.0), <double>::min here is the smallest positive number...
std::string value_string(const T &value)
get a string as a convertible value for arithmetic types
Definition: TypeTools.hpp:351
const detail::ExistingDirectoryValidator ExistingDirectory
Check for an existing directory (returns error message if check fails)
Definition: Validators.hpp:257
T type
Definition: TypeTools.hpp:78
Check for an existing file (returns error message if check fails)
Definition: Validators.hpp:220
Validator & active(bool active_val=true)
Specify whether the Validator is active or not.
Definition: Validators.hpp:154
CLI11_NODISCARD std::string get_description() const
Generate type description information for the Validator.
Definition: Validators.hpp:134
Validator & operation(std::function< std::string(std::string &)> op)
Set the Validator operation function.
Definition: Validators.hpp:110
std::function< std::string()> desc_function_
This is the description function, if empty the description_ will be used.
Definition: Validators.hpp:84
std::string operator()(const std::string &str) const
Definition: Validators.hpp:120
const Range NonNegativeNumber((std::numeric_limits< double >::max)(), "NONNEGATIVE")
Check for a non negative number.
std::enable_if< std::is_integral< T >::value, bool >::type checked_multiply(T &a, T b)
Performs a *= b; if it doesn't cause integer overflow. Returns false otherwise.
Definition: Validators.hpp:479
typename T::value_type value_type
Definition: TypeTools.hpp:110
Validator operator!() const
Create a validator that fails when a given validator succeeds.
Validator & non_modifying(bool no_modify=true)
Specify whether the Validator can be modifying or not.
Definition: Validators.hpp:166
Range(T min_val, T max_val, const std::string &validator_name=std::string{})
Definition: Validators.hpp:301
std::string generate_map(const T &map, bool key_only=false)
Generate a string representation of a map.
Definition: Validators.hpp:393
AsNumberWithUnit::Options operator|(const AsNumberWithUnit::Options &a, const AsNumberWithUnit::Options &b)
Definition: Validators.hpp:865
Definition: Validators.hpp:746
bool isalpha(const std::string &str)
Verify that str consists of letters only.
Definition: StringTools.hpp:169
T type
Definition: TypeTools.hpp:95
CLI11_NODISCARD bool get_active() const
Get a boolean if the validator is active.
Definition: Validators.hpp:184
Validator & description(std::string validator_desc)
Specify the type string.
Definition: Validators.hpp:126
CLI11_NODISCARD Validator name(std::string validator_name) const
Specify the type string.
Definition: Validators.hpp:146