CPP-AP 2.2.6
Command-line argument parser for C++20
Loading...
Searching...
No Matches
ap::argument::positional< T > Class Template Reference

The positional argument class. More...

#include <positional.hpp>

Inheritance diagram for ap::argument::positional< T >:
ap::detail::argument_base

Public Types

using value_type = T
 The argument's value type.
 

Public Member Functions

 positional (const detail::argument_name &name)
 Constructor for positional argument with the name identifier.
 
bool operator== (const positional &other) const noexcept
 Equality operator for positional argument.
 
positionalhelp (std::string_view help_msg) noexcept
 Set the help message for the positional argument.
 
template<detail::c_range_of< value_type, detail::type_validator::convertible > CR>
requires (std::equality_comparable<value_type>)
positionalchoices (const CR &choices) noexcept
 Set the choices for the positional argument.
 
positionalchoices (std::initializer_list< value_type > choices) noexcept
 Set the choices for the positional argument.
 
template<action::detail::c_value_action_specifier AS, std::invocable< value_type & > F>
positionalaction (F &&action) noexcept
 Set the action for the positional argument.
 

Friends

class ::ap::argument_parser
 Friend class declaration for access by argument_parser.
 

Additional Inherited Members

- Protected Member Functions inherited from ap::detail::argument_base
 argument_base (const argument_name &name)
 
const ap::detail::argument_namename () const noexcept
 
const std::optional< std::string > & help () const noexcept
 
- Protected Attributes inherited from ap::detail::argument_base
const ap::detail::argument_name _name
 
std::optional< std::string > _help_msg
 

Detailed Description

template<detail::c_argument_value_type T = std::string>
class ap::argument::positional< T >

The positional argument class.

Template Parameters
TThe argument's value type.

Definition at line 29 of file positional.hpp.

Member Typedef Documentation

◆ value_type

template<detail::c_argument_value_type T = std::string>
using ap::argument::positional< T >::value_type = T

The argument's value type.

Definition at line 31 of file positional.hpp.

Constructor & Destructor Documentation

◆ positional()

template<detail::c_argument_value_type T = std::string>
ap::argument::positional< T >::positional ( const detail::argument_name name)
inline

Constructor for positional argument with the name identifier.

Parameters
nameThe name identifier of the positional argument.

Definition at line 39 of file positional.hpp.

Member Function Documentation

◆ action()

template<detail::c_argument_value_type T = std::string>
template<action::detail::c_value_action_specifier AS, std::invocable< value_type & > F>
positional & ap::argument::positional< T >::action ( F &&  action)
inlinenoexcept

Set the action for the positional argument.

Template Parameters
ASThe value action specifier type (valued_action or void_action).
FThe type of the action function.
Parameters
actionThe action function to set.
Returns
Reference to the positional argument.

Definition at line 99 of file positional.hpp.

◆ choices() [1/2]

template<detail::c_argument_value_type T = std::string>
template<detail::c_range_of< value_type, detail::type_validator::convertible > CR>
requires (std::equality_comparable<value_type>)
positional & ap::argument::positional< T >::choices ( const CR &  choices)
inlinenoexcept

Set the choices for the positional argument.

Template Parameters
CRThe choices range type.
Parameters
choicesThe range of valid choices for the argument.
Returns
Reference to the positional argument.
Note
value_type must be equality comparable.
CR must be a range such that its value type is convertible to value_type.

Definition at line 71 of file positional.hpp.

◆ choices() [2/2]

template<detail::c_argument_value_type T = std::string>
positional & ap::argument::positional< T >::choices ( std::initializer_list< value_type choices)
inlinenoexcept

Set the choices for the positional argument.

Parameters
choicesThe list of valid choices for the argument.
Returns
Reference to the positional argument.
Note
value_type must be equality comparable.

Definition at line 85 of file positional.hpp.

◆ help()

template<detail::c_argument_value_type T = std::string>
positional & ap::argument::positional< T >::help ( std::string_view  help_msg)
inlinenoexcept

Set the help message for the positional argument.

Parameters
help_msgThe help message to set.
Returns
Reference to the positional argument.

Definition at line 57 of file positional.hpp.

◆ operator==()

template<detail::c_argument_value_type T = std::string>
bool ap::argument::positional< T >::operator== ( const positional< T > &  other) const
inlinenoexcept

Equality operator for positional argument.

Parameters
otherAnother positional argument for comparison.
Returns
Result of equality

Definition at line 48 of file positional.hpp.

Friends And Related Symbol Documentation

◆ ::ap::argument_parser

template<detail::c_argument_value_type T = std::string>
friend class ::ap::argument_parser
friend

Friend class declaration for access by argument_parser.

Definition at line 106 of file positional.hpp.


The documentation for this class was generated from the following file: