CPP-AP 2.7.0
Command-line argument parser for C++20
|
The optioanl argument class. More...
#include <optional.hpp>
Public Types | |
using | value_type = T |
The argument's value type. | |
using | count_type = nargs::range::count_type |
The argument's value count type. | |
Public Member Functions | |
optional ()=delete | |
optional (const detail::argument_name &name) | |
Constructor for optional argument with the name identifier. | |
~optional ()=default | |
bool | operator== (const optional &other) const noexcept |
Equality comparison operator for optional argument. | |
optional & | help (std::string_view help_msg) noexcept |
Set the help message for the optional argument. | |
optional & | hidden (const bool h=true) noexcept |
Set the hidden attribute for the positional argument. | |
optional & | required (const bool r=true) noexcept |
Set the required attribute of the optional argument. | |
optional & | bypass_required (const bool br=true) noexcept |
Enable/disable bypassing the required attribute for the optional argument. | |
optional & | nargs (const nargs::range &range) noexcept |
Set the nargs range for the optional argument. | |
optional & | nargs (const count_type n) noexcept |
Set the nargs range for the optional argument. | |
optional & | nargs (const count_type lower_bound, const count_type upper_bound) noexcept |
Set the nargs range for the optional argument. | |
template<action::detail::c_action_specifier AS, typename F > | |
optional & | action (F &&action) noexcept |
Set the action for the optional argument. | |
template<detail::c_range_of< value_type, detail::type_validator::convertible > CR> requires (std::equality_comparable<value_type>) | |
optional & | choices (const CR &choices) noexcept |
Set the choices for the optional argument. | |
optional & | choices (std::initializer_list< value_type > choices) noexcept |
Set the choices for the optional argument. | |
optional & | default_value (const std::convertible_to< value_type > auto &default_value) noexcept |
Set the default value for the optional argument. | |
optional & | implicit_value (const std::convertible_to< value_type > auto &implicit_value) noexcept |
Set the implicit value for the optional argument. | |
![]() | |
virtual | ~argument_base ()=default |
Private Types | |
using | value_action_type = action::detail::value_action_variant_type< T > |
The argument's value action type. | |
using | flag_action_type = typename action_type::on_flag::type |
Private Member Functions | |
detail::argument_descriptor | desc (const bool verbose) const noexcept override |
bool | mark_used () override |
Mark the optional argument as used. | |
bool | is_used () const noexcept override |
std::size_t | count () const noexcept override |
bool | set_value (const std::string &str_value) override |
Set the value for the optional argument. | |
bool | has_value () const noexcept override |
bool | has_parsed_values () const noexcept override |
std::weak_ordering | nvalues_ordering () const noexcept override |
const std::any & | value () const override |
const std::vector< std::any > & | values () const override |
bool | _has_predefined_value () const noexcept |
const std::any & | _predefined_value () const |
bool | _accepts_further_values () const noexcept |
Private Attributes | |
nargs::range | _nargs_range = nargs::any() |
std::any | _default_value |
std::any | _implicit_value |
std::vector< value_type > | _choices |
std::vector< flag_action_type > | _flag_actions |
std::vector< value_action_type > | _value_actions |
std::size_t | _count = 0ull |
std::vector< std::any > | _values |
Friends | |
class | ::ap::argument_parser |
Friend class declaration for access by argument_parser. | |
Additional Inherited Members | |
![]() | |
argument_base (const argument_name &name, const bool required=false) | |
const ap::detail::argument_name & | name () const noexcept |
const std::optional< std::string > & | help () const noexcept |
bool | is_hidden () const noexcept |
bool | is_required () const noexcept |
bool | bypass_required_enabled () const noexcept |
![]() | |
const ap::detail::argument_name | _name |
std::optional< std::string > | _help_msg |
bool | _required: 1 |
bool | _bypass_required: 1 = false |
bool | _hidden: 1 = false |
The optioanl argument class.
T | The argument's value type. |
Definition at line 31 of file optional.hpp.
using ap::argument::optional< T >::count_type = nargs::range::count_type |
The argument's value count type.
Definition at line 34 of file optional.hpp.
|
private |
Definition at line 216 of file optional.hpp.
|
private |
The argument's value action type.
Definition at line 214 of file optional.hpp.
using ap::argument::optional< T >::value_type = T |
The argument's value type.
Definition at line 33 of file optional.hpp.
|
delete |
|
inline |
Constructor for optional argument with the name
identifier.
name | The name identifier of the optional argument. |
Definition at line 42 of file optional.hpp.
|
default |
|
inlineprivatenoexcept |
Definition at line 351 of file optional.hpp.
|
inlineprivatenoexcept |
Definition at line 324 of file optional.hpp.
|
inlineprivate |
std::logic_error |
Definition at line 333 of file optional.hpp.
|
inlinenoexcept |
Set the action for the optional argument.
AS | The action specifier type (see ap/action/specifiers.hpp). |
F | The type of the action function. |
action | The action function to set. |
Definition at line 140 of file optional.hpp.
|
inlinenoexcept |
Enable/disable bypassing the required
attribute for the optional argument.
br | The attribute value. |
bypass_required
option to true disables the required
attribute. Definition at line 94 of file optional.hpp.
|
inlinenoexcept |
Set the choices for the optional argument.
CR | The choices range type. |
choices | The range of valid choices for the argument. |
value_type
must be equality comparable. CR
must be a range such that its value type is convertible to value_type
. Definition at line 161 of file optional.hpp.
|
inlinenoexcept |
Set the choices for the optional argument.
choices | The list of valid choices for the argument. |
value_type
must be equality comparable. Definition at line 175 of file optional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 261 of file optional.hpp.
|
inlinenoexcept |
Set the default value for the optional argument.
default_value | The default value to set. |
required
attribute. Definition at line 187 of file optional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
verbose | The verbosity mode value. |
Implements ap::detail::argument_base.
Definition at line 222 of file optional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 301 of file optional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 296 of file optional.hpp.
|
inlinenoexcept |
Set the help message for the optional argument.
help_msg | The help message to set. |
Definition at line 60 of file optional.hpp.
|
inlinenoexcept |
Set the hidden
attribute for the positional argument.
h | The attribute value. |
Definition at line 70 of file optional.hpp.
|
inlinenoexcept |
Set the implicit value for the optional argument.
implicit_value | The implicit value to set. |
Definition at line 198 of file optional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 256 of file optional.hpp.
|
inlineoverrideprivatevirtual |
Mark the optional argument as used.
Implements ap::detail::argument_base.
Definition at line 248 of file optional.hpp.
|
inlinenoexcept |
Set the nargs range for the optional argument.
lower_bound | The lower bound for nargs range. |
upper_bound | The upper bound for nargs range. |
Definition at line 127 of file optional.hpp.
|
inlinenoexcept |
Set the nargs range for the optional argument.
n | The exact bound for nargs range. |
Definition at line 116 of file optional.hpp.
|
inlinenoexcept |
Set the nargs range for the optional argument.
range | The nargs range to set. |
Definition at line 106 of file optional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 306 of file optional.hpp.
|
inlinenoexcept |
Equality comparison operator for optional argument.
other | The optional argument to compare with. |
Definition at line 51 of file optional.hpp.
|
inlinenoexcept |
Set the required
attribute of the optional argument.
r | The attribute value. |
required
attribute to true disables the bypass_required
attribute. Definition at line 81 of file optional.hpp.
|
inlineoverrideprivatevirtual |
Set the value for the optional argument.
str_value | The string value to set. |
ap::parsing_failure |
Implements ap::detail::argument_base.
Definition at line 271 of file optional.hpp.
|
inlineoverrideprivatevirtual |
Implements ap::detail::argument_base.
Definition at line 314 of file optional.hpp.
|
inlineoverrideprivatevirtual |
Implements ap::detail::argument_base.
Definition at line 319 of file optional.hpp.
|
friend |
Friend class declaration for access by argument_parser.
Definition at line 204 of file optional.hpp.
|
private |
Definition at line 358 of file optional.hpp.
|
private |
Definition at line 362 of file optional.hpp.
|
private |
Definition at line 356 of file optional.hpp.
|
private |
Definition at line 359 of file optional.hpp.
|
private |
Definition at line 357 of file optional.hpp.
|
private |
Definition at line 355 of file optional.hpp.
|
private |
Definition at line 360 of file optional.hpp.
|
private |
Definition at line 363 of file optional.hpp.