|
cli11
|
The validator type and the built-in validators. More...
import cli11:encoding;import std;Classes | |
| class | cli::validator_t |
| A composable check applied to one command-line value. More... | |
| class | cli::file_on_default_path_t |
| Finds a file relative to a default directory when it is not found as given. More... | |
| class | cli::range_t |
| Requires the value to fall within a closed interval. More... | |
| struct | cli::detail::program_name_t |
| A command line split into the program and everything after it. More... | |
Typedefs | |
| using | cli::custom_validator_t = validator_t |
| A validator built from a user-supplied callable. | |
Enumerations | |
| enum class | cli::detail::path_type_t : std::uint8_t { nonexistent , file , directory } |
| What a path refers to on disk. More... | |
Functions | |
| auto | cli::detail::check_path (std::string_view file) noexcept -> path_type_t |
| Reports what a path refers to. | |
| template<typename T> requires std::is_signed_v<T> | |
| auto | cli::detail::overflow_check (const T &a, const T &b) -> bool |
| Reports whether multiplying two signed values would overflow. | |
| template<typename T> requires (!std::is_signed_v<T>) | |
| auto | cli::detail::overflow_check (const T &a, const T &b) -> bool |
| Reports whether multiplying two unsigned values would overflow. | |
| template<typename T> requires std::is_integral_v<T> | |
| auto | cli::detail::checked_multiply (T &a, T b) -> bool |
| Multiplies in place, refusing to overflow. | |
| template<typename T> requires std::is_floating_point_v<T> | |
| auto | cli::detail::checked_multiply (T &a, T b) -> bool |
| Multiplies in place, refusing to produce an infinity. | |
| auto | cli::detail::split_program_name (std::string commandline) -> program_name_t |
| Separates the program name from the rest of a command line. | |
Variables | |
| const validator_t | cli::existing_file |
| Requires the value to name an existing file. | |
| const validator_t | cli::existing_directory |
| Requires the value to name an existing directory. | |
| const validator_t | cli::existing_path |
| Requires the value to name something that exists. | |
| const validator_t | cli::nonexistent_path |
| Requires the value to name something that does not exist. | |
| const validator_t | cli::escaped_string |
| Resolves quoting and backslash escapes in the value. | |
| const range_t | cli::non_negative_number ((std::numeric_limits< double >::max)(), "NONNEGATIVE") |
| Requires the value to be zero or greater. | |
| const range_t | cli::positive_number ((std::numeric_limits< double >::min)(),(std::numeric_limits< double >::max)(), "POSITIVE") |
| Requires the value to be strictly greater than zero. | |
The validator type and the built-in validators.
A cli::validator_t wraps a callable that inspects — and may rewrite — one value, returning an empty string on success or a message on failure. Attach one with option->check(...) or option->transform(...).
Validators compose. & requires both to pass, | requires either, and ! inverts, with the descriptions combined to match:
The heavier validators — is_member, the transformers, and the unit parsers — live in the extra_validators partition.
|
exportstrong |
|
exportnoexcept |
Reports what a path refers to.
| file | The path to inspect. |
|
export |
Multiplies in place, refusing to produce an infinity.
| [in,out] | a | The value to multiply; left untouched on failure. |
| [in] | b | The multiplier. |
|
export |
Multiplies in place, refusing to overflow.
| [in,out] | a | The value to multiply; left untouched on failure. |
| [in] | b | The multiplier. |
|
export |
Reports whether multiplying two unsigned values would overflow.
| a | The left operand. |
| b | The right operand. |
|
export |
Reports whether multiplying two signed values would overflow.
| a | The left operand. |
| b | The right operand. |
|
export |
Separates the program name from the rest of a command line.
The program name may contain spaces, so candidate prefixes are tested against the filesystem until one names a file. Quoted program names are unquoted, and escaped quotes within them are resolved.
| commandline | The full command line. |
|
export |
Resolves quoting and backslash escapes in the value.
This rewrites its argument rather than only inspecting it.
|
export |
Requires the value to name an existing directory.
|
export |
Requires the value to name an existing file.
|
export |
Requires the value to name something that exists.
|
export |
Requires the value to name something that does not exist.