cli11
Loading...
Searching...
No Matches
cli::is_member_t Class Referenceexport
module cli11

Requires the value to appear in a set. More...

Inheritance diagram for cli::is_member_t:
cli::validator_t

Public Types

using filter_fn_t = std::function<std::string(std::string)>
 A transformation applied to both sides of a comparison.

Public Member Functions

template<typename T, typename... args_t>
 is_member_t (std::initializer_list< T > values, args_t &&...args)
 Constructs from an initializer list.
template<typename T>
 is_member_t (T &&set)
 Constructs from a set, with no filtering.
template<typename T, typename F>
 is_member_t (T set, F filter_function)
 Constructs from a set and one filter function.
template<typename T, typename... args_t>
 is_member_t (T &&set, filter_fn_t filter_fn_1, filter_fn_t filter_fn_2, args_t &&...other)
 Constructs from a set and several filter functions, which nest.
Public Member Functions inherited from cli::validator_t
 validator_t (std::string validator_desc)
 Constructs a validator that only carries a description.
 validator_t (std::function< std::string(std::string &)> op, std::string validator_desc, std::string validator_name="")
 Constructs a named validator.
auto operation (std::function< std::string(std::string &)> op) -> validator_t &
 Replaces the check.
auto operator() (std::string &str) const -> std::string
 Runs the check, possibly rewriting str.
auto operator() (const std::string &str) const -> std::string
 Runs the check against a copy, leaving str untouched.
auto description (std::string validator_desc) -> validator_t &
 Sets the description in place.
auto description (std::string validator_desc) const -> validator_t
 Returns a copy carrying a different description.
auto get_description () const -> std::string
 Returns the description shown in help output.
auto name (std::string validator_name) -> validator_t &
 Sets the name in place.
auto name (std::string validator_name) const -> validator_t
 Returns a copy carrying a different name.
auto get_name () const -> const std::string &
 Returns the validator's name.
auto active (bool active_val=true) -> validator_t &
 Enables or disables the check in place.
auto active (bool active_val=true) const -> validator_t
 Returns a copy that is enabled or disabled.
auto get_active () const -> bool
 Reports whether the check runs.
auto non_modifying (bool no_modify=true) -> validator_t &
 Forbids or permits the check to rewrite its argument.
auto get_modifying () const -> bool
 Reports whether the check may rewrite its argument.
auto application_index (int app_index) -> validator_t &
 Sets which value the check applies to, in place.
auto application_index (int app_index) const -> validator_t
 Returns a copy applying to a different value.
auto get_application_index () const -> int
 Returns which value the check applies to.
auto operator& (const validator_t &other) const -> validator_t
 Combines two validators so that both must pass.
auto operator| (const validator_t &other) const -> validator_t
 Combines two validators so that either may pass.
auto operator! () const -> validator_t
 Inverts a validator, so that passing becomes failing.

Additional Inherited Members

Protected Member Functions inherited from cli::validator_t
 validator_t (std::string validator_desc, std::function< std::string(std::string &)> func)
 Constructs a validator with a fixed description.
Protected Attributes inherited from cli::validator_t
std::function< std::string()> desc_function_ {[] { return std::string {}; }}
 Produces the description shown in help output.
std::function< std::string(std::string &)> func_
 The check itself.
std::string name_ {}
 The validator's name, used to find and replace it on an option.
int application_index_ = -1
 Which value this applies to, or -1 for all of them.
bool active_ {true}
 Whether the check runs at all.
bool non_modifying_ {false}
 Whether the check is forbidden from rewriting its argument.

Detailed Description

Requires the value to appear in a set.

The set may be passed by value, as an initializer list, or as a pointer, in which case it is held and re-read on each check, so a set that changes after construction still validates correctly.

One or more filter functions may be supplied; each is applied to both sides of the comparison, so is_member_t{set, cli::ignore_case} matches case-insensitively. On a filtered match the value is rewritten to the spelling stored in the set.

Constructor & Destructor Documentation

◆ is_member_t() [1/4]

template<typename T, typename... args_t>
cli::is_member_t::is_member_t ( std::initializer_list< T > values,
args_t &&... args )
inline

Constructs from an initializer list.

Parameters
valuesThe permitted values.
argsAny filter functions.

◆ is_member_t() [2/4]

template<typename T>
cli::is_member_t::is_member_t ( T && set)
inlineexplicit

Constructs from a set, with no filtering.

Parameters
setThe permitted values, by value or by pointer.

◆ is_member_t() [3/4]

template<typename T, typename F>
cli::is_member_t::is_member_t ( T set,
F filter_function )
inlineexplicit

Constructs from a set and one filter function.

Parameters
setThe permitted values, by value or by pointer.
filter_functionApplied to both sides of each comparison.

◆ is_member_t() [4/4]

template<typename T, typename... args_t>
cli::is_member_t::is_member_t ( T && set,
filter_fn_t filter_fn_1,
filter_fn_t filter_fn_2,
args_t &&... other )
inline

Constructs from a set and several filter functions, which nest.

Parameters
setThe permitted values, by value or by pointer.
filter_fn_1The first filter, applied innermost.
filter_fn_2The second filter.
otherAny further filters.

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