CPP-AP 2.7.0
Command-line argument parser for C++20
|
The positional argument class. More...
#include <positional.hpp>
Public Types | |
using | value_type = T |
The argument's value type. | |
Public Member Functions | |
positional ()=delete | |
positional (const detail::argument_name &name) | |
Constructor for positional argument with the name identifier. | |
~positional ()=default | |
bool | operator== (const positional &other) const noexcept |
Equality operator for positional argument. | |
positional & | help (std::string_view help_msg) noexcept |
Set the help message for the positional argument. | |
positional & | hidden (const bool h=true) noexcept |
Set the hidden attribute for the positional argument. | |
positional & | required (const bool r=true) noexcept |
Set the required attribute of the positional argument. | |
positional & | bypass_required (const bool br=true) noexcept |
Enable/disable bypassing the required attributeattribute for the positional argument. | |
template<detail::c_range_of< value_type, detail::type_validator::convertible > CR> requires (std::equality_comparable<value_type>) | |
positional & | choices (const CR &choices) noexcept |
Set the choices for the positional argument. | |
positional & | choices (std::initializer_list< value_type > choices) noexcept |
Set the choices for the positional argument. | |
positional & | default_value (const std::convertible_to< value_type > auto &default_value) noexcept |
Set the default value for the positional argument. | |
template<action::detail::c_value_action_specifier AS, std::invocable< value_type & > F> | |
positional & | action (F &&action) noexcept |
Set the action for the positional argument. | |
![]() | |
virtual | ~argument_base ()=default |
Private Types | |
using | value_action_type = action::detail::value_action_variant_type< T > |
The argument's value action type. | |
Private Member Functions | |
detail::argument_descriptor | desc (const bool verbose) const noexcept override |
bool | mark_used () override |
Mark the positional 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 positional 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 |
Get the stored value of the positional argument. | |
const std::vector< std::any > & | values () const override |
Private Attributes | |
std::any | _default_value |
std::vector< value_type > | _choices |
std::vector< value_action_type > | _value_actions |
std::any | _value |
Stored value of the positional argument. | |
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 positional argument class.
T | The argument's value type. |
Definition at line 29 of file positional.hpp.
|
private |
The argument's value action type.
Definition at line 164 of file positional.hpp.
using ap::argument::positional< T >::value_type = T |
The argument's value type.
Definition at line 31 of file positional.hpp.
|
delete |
|
inline |
Constructor for positional argument with the name
identifier.
name | The name identifier of the positional argument. |
Definition at line 39 of file positional.hpp.
|
default |
|
inlinenoexcept |
Set the action for the positional argument.
AS | The value action specifier type (valued_action or void_action). |
F | The type of the action function. |
action | The action function to set. |
Definition at line 147 of file positional.hpp.
|
inlinenoexcept |
Enable/disable bypassing the required
attributeattribute for the positional argument.
br | The attribute value. |
bypass_required
attribute to true disables the required
attribute. Definition at line 91 of file positional.hpp.
|
inlinenoexcept |
Set the choices for the positional 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 107 of file positional.hpp.
|
inlinenoexcept |
Set the choices for the positional argument.
choices | The list of valid choices for the argument. |
value_type
must be equality comparable. Definition at line 121 of file positional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 205 of file positional.hpp.
|
inlinenoexcept |
Set the default value for the positional argument.
default_value | The default value to set. |
required
attribute. Definition at line 133 of file positional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
verbose | The verbosity mode value. |
Implements ap::detail::argument_base.
Definition at line 171 of file positional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 245 of file positional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 240 of file positional.hpp.
|
inlinenoexcept |
Set the help message for the positional argument.
help_msg | The help message to set. |
Definition at line 57 of file positional.hpp.
|
inlinenoexcept |
Set the hidden
attribute for the positional argument.
h | The attribute value. |
Definition at line 67 of file positional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 200 of file positional.hpp.
|
inlineoverrideprivatevirtual |
Mark the positional argument as used.
Implements ap::detail::argument_base.
Definition at line 195 of file positional.hpp.
|
inlineoverrideprivatevirtualnoexcept |
Implements ap::detail::argument_base.
Definition at line 250 of file positional.hpp.
|
inlinenoexcept |
Equality operator for positional argument.
other | Another positional argument for comparison. |
Definition at line 48 of file positional.hpp.
|
inlinenoexcept |
Set the required
attribute of the positional argument.
r | The attribute value. |
required
attribute to true disables the bypass_required
attribute. Definition at line 78 of file positional.hpp.
|
inlineoverrideprivatevirtual |
Set the value for the positional argument.
str_value | The string representation of the value. |
ap::parsing_failure |
Implements ap::detail::argument_base.
Definition at line 215 of file positional.hpp.
|
inlineoverrideprivatevirtual |
Get the stored value of the positional argument.
std::logic_error |
Implements ap::detail::argument_base.
Definition at line 261 of file positional.hpp.
|
inlineoverrideprivatevirtual |
std::logic_error |
Implements ap::detail::argument_base.
Definition at line 277 of file positional.hpp.
|
friend |
Friend class declaration for access by argument_parser.
Definition at line 154 of file positional.hpp.
|
private |
Definition at line 284 of file positional.hpp.
|
private |
Definition at line 283 of file positional.hpp.
|
private |
Stored value of the positional argument.
Definition at line 287 of file positional.hpp.
|
private |
Definition at line 285 of file positional.hpp.