|
cli11
|
A composable check applied to one command-line value. More...
Public Member Functions | |
| 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. | |
Protected Member Functions | |
| validator_t (std::string validator_desc, std::function< std::string(std::string &)> func) | |
| Constructs a validator with a fixed description. | |
Protected Attributes | |
| 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. | |
A composable check applied to one command-line value.
|
inlineprotected |
Constructs a validator with a fixed description.
| validator_desc | The description shown in help output. |
| func | The check to run. |
|
inlineexplicit |
Constructs a validator that only carries a description.
| validator_desc | The description shown in help output. |
|
inline |
Constructs a named validator.
| op | The check to run. |
| validator_desc | The description shown in help output. |
| validator_name | The name used to find this validator later. |
|
inline |
Enables or disables the check in place.
| active_val | Whether the check should run. |
|
inlinenodiscard |
Returns a copy that is enabled or disabled.
| active_val | Whether the check should run. |
|
inline |
Sets which value the check applies to, in place.
| app_index | The value index, or -1 for all values. |
|
inlinenodiscard |
Returns a copy applying to a different value.
| app_index | The value index, or -1 for all values. |
|
inline |
Sets the description in place.
| validator_desc | The new description. |
|
inlinenodiscard |
Returns a copy carrying a different description.
| validator_desc | The new description. |
|
inlinenodiscard |
Reports whether the check runs.
|
inlinenodiscard |
Returns which value the check applies to.
|
inlinenodiscard |
Returns the description shown in help output.
|
inlinenodiscard |
Reports whether the check may rewrite its argument.
|
inlinenodiscard |
Returns the validator's name.
|
inline |
Sets the name in place.
| validator_name | The new name. |
|
inlinenodiscard |
Returns a copy carrying a different name.
| validator_name | The new name. |
|
inline |
Forbids or permits the check to rewrite its argument.
| no_modify | Whether to forbid rewriting. |
|
inline |
Replaces the check.
| op | The new check. |
|
inline |
Inverts a validator, so that passing becomes failing.
|
inline |
Combines two validators so that both must pass.
| other | The validator to combine with. |
|
inline |
Runs the check against a copy, leaving str untouched.
| str | The value to check. |
|
inline |
Runs the check, possibly rewriting str.
| [in,out] | str | The value to check. |
|
inline |
Combines two validators so that either may pass.
| other | The validator to combine with. |
|
protected |
Produces the description shown in help output.
A callable rather than a string so that a description can be built lazily from the descriptions of composed validators.
|
protected |
The check itself.
Returns an empty string on success, or a failure message. May rewrite its argument unless non_modifying_ is set.