CPP-AP 2.7.0
Command-line argument parser for C++20
|
Classes | |
class | argument_base |
Argument class interface. More... | |
class | argument_descriptor |
A structure used to represent an argument's description. More... | |
struct | argument_name |
Structure holding the argument's name. More... | |
struct | argument_token |
Structure representing a single command-line argument token. More... | |
struct | parameter_descriptor |
A structure used to represent an argument's parameter description. More... | |
Concepts | |
concept | c_readable |
The concept is satisfied when T overloads the std::istream operator >> . | |
concept | c_trivially_readable |
The concept is satisfied when T can be constructed from const std::string& . | |
concept | c_writable |
The concept is satisfied when T overloads the std::ostream operator << . | |
concept | c_arithmetic |
The concept is satisfied when T is an arithmetic type. | |
concept | c_argument_value_type |
The concept is used to verify the validity of the arguments' value types. | |
concept | c_one_of |
Validates that T is the same as one of the types defined by Types . | |
concept | c_valid_type |
Concept that enforces is_valid_type_v . | |
concept | c_range_of |
Validates that R is a range of type T (ignoring the cvref attributes). | |
concept | c_sized_range_of |
Validates that R is a sized range of type T (ignoring the cvref attributes). | |
Typedefs | |
template<typename T > | |
using | uptr_opt_t = std::optional< std::reference_wrapper< std::unique_ptr< T > > > |
Enumerations | |
enum class | argument_name_discriminator : bool { n_primary , n_secondary } |
Argument name member discriminator. More... | |
enum class | type_validator : bool { same , convertible } |
Specifies the type validation rule. More... | |
Functions | |
void | add_default_argument (const argument::default_positional arg_discriminator, argument_parser &arg_parser) noexcept |
Adds a predefined/default positional argument to the parser. | |
void | add_default_argument (const argument::default_optional arg_discriminator, argument_parser &arg_parser) noexcept |
Adds a predefined/default optional argument to the parser. | |
template<c_argument_value_type T> | |
bool | is_valid_choice (const T &value, const std::vector< T > &choices) noexcept |
Checks if the provided choice is valid for the given set of choices. | |
template<c_writable T> | |
std::string | as_string (const T &value) noexcept |
Converts a value to std::string . | |
bool | contains_whitespaces (std::string_view str) noexcept |
Checks whether a string contains any whitespace characters. | |
template<std::ranges::range R> requires (c_writable<std::ranges::range_value_t<R>>) | |
std::string | join (const R &range, const std::string_view delimiter=", ") |
Joins elements of a range into a single string with a delimiter. | |
template<typename T > | |
constexpr std::string_view | get_demangled_type_name () |
Variables | |
template<typename T , typename U , type_validator TV> | |
constexpr bool | is_valid_type_v = false |
Checks if two types satisfy a given type_validator rule. | |
using ap::detail::uptr_opt_t = typedef std::optional<std::reference_wrapper<std::unique_ptr<T> >> |
Definition at line 16 of file typing_utility.hpp.
|
strong |
Argument name member discriminator.
This discriminator type is used in the argument initializing methods of the argument_parser
class.
Enumerator | |
---|---|
n_primary | Represents the primary name (used with a long flag prefix –). |
n_secondary | Represents the secondary name (used with a short flag prefix –). |
Definition at line 144 of file argument_name.hpp.
|
strong |
Specifies the type validation rule.
Enumerator | |
---|---|
same | Exact type match. |
convertible | Implicit conversion allowed. |
Definition at line 63 of file concepts.hpp.
|
inlinenoexcept |
Adds a predefined/default optional argument to the parser.
arg_discriminator | The default argument discriminator. |
arg_parser | The argument parser to which the argument will be added. |
Definition at line 1145 of file argument_parser.hpp.
|
inlinenoexcept |
Adds a predefined/default positional argument to the parser.
arg_discriminator | The default argument discriminator. |
arg_parser | The argument parser to which the argument will be added. |
Definition at line 1124 of file argument_parser.hpp.
|
noexcept |
Converts a value to std::string
.
T | The value type (must satisfy the ap::detail::c_writable concept). |
value | The value to convert. |
Definition at line 26 of file str_utility.hpp.
|
inlinenoexcept |
Checks whether a string contains any whitespace characters.
Definition at line 33 of file str_utility.hpp.
|
constexpr |
Definition at line 19 of file typing_utility.hpp.
|
noexcept |
Checks if the provided choice is valid for the given set of choices.
value | A value, the validity of which is to be checked. |
choices | The set against which the choice validity will be checked. |
true
if the choice is valid, false
otherwise. std::ranges::contains
after transition to C++23 Definition at line 120 of file argument_base.hpp.
std::string ap::detail::join | ( | const R & | range, |
const std::string_view | delimiter = ", " |
||
) |
Joins elements of a range into a single string with a delimiter.
R | The type of the value range. The value type of R must satisfy the c_writable concept. |
range | The input range to join. |
delimiter | The separator string to insert between elements. |
Definition at line 47 of file str_utility.hpp.
|
inlineconstexpr |
Checks if two types satisfy a given type_validator
rule.
The primary template of the is_valid_type_v
helper variable, which does not perform any logic and defaults to false
.
T | The type to check. |
U | The type to check agains. |
TV | The validation rule. |
Definition at line 79 of file concepts.hpp.