Ookii.CommandLine for C++  2.0.0
Public Types | Public Member Functions | List of all members
ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T > Class Template Reference

Specifies options for an action argument. More...

#include <ookii/command_line_builder.h>

Inheritance diagram for ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T >:
Inheritance graph
[legend]
Collaboration diagram for ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T >:
Collaboration graph
[legend]

Public Types

using function_type = typename argument_type::function_type
 The type of function used for the action.
 

Public Member Functions

 action_argument_builder (basic_parser_builder &parser_builder, CharType short_name, function_type action)
 Initializes a new instance of the argument_builder class. More...
 
 action_argument_builder (basic_parser_builder &parser_builder, string_type name, function_type action)
 Initializes a new instance of the argument_builder class. More...
 
action_argument_builderconverter (converter_type converter)
 Supplies a custom function to convert strings to the argument's type. More...
 
- Public Member Functions inherited from ookii::basic_parser_builder< CharType, Traits, Alloc >::argument_builder_common< action_argument_builder< T > >
action_argument_builder< T > & alias (string_type alias)
 Adds an alias to the argument. More...
 
 argument_builder_base (argument_builder_base &)=delete
 Deleted copy constructor.
 
 argument_builder_base (basic_parser_builder &basic_parser_builder, CharType short_name)
 Initializes a new instance of the argument_builder_base class. More...
 
 argument_builder_base (basic_parser_builder &basic_parser_builder, string_type name)
 Initializes a new instance of the argument_builder_base class. More...
 
action_argument_builder< T > & cancel_parsing ()
 Indicates that supplying this argument will cancel parsing. More...
 
action_argument_builder< T > & description (string_type description)
 Sets the long description for the argument. More...
 
const string_typename () const noexcept
 Returns the name of the argument. More...
 
action_argument_builder< T > & name (string_type name)
 Changes the name of the argument. More...
 
action_argument_builder< T > & positional ()
 Indicates that the argument can be specified by position. More...
 
action_argument_builder< T > & required ()
 Indicates that the argument is required. More...
 
action_argument_builder< T > & short_alias (CharType alias)
 Adds a short alias to the argument. More...
 
action_argument_builder< T > & short_name ()
 Sets a short name for the argument that matches the first character of the long name. More...
 
const CharType & short_name () const noexcept
 Returns the short name of the argument. More...
 
action_argument_builder< T > & short_name (CharType short_name)
 Sets an explicit short name for an argument. More...
 
action_argument_builder< T > & value_description (string_type value_description)
 Sets the value description for the argument. More...
 
- Public Member Functions inherited from ookii::basic_parser_builder< CharType, Traits, Alloc >::argument_builder_base
 argument_builder_base (argument_builder_base &)=delete
 Deleted copy constructor.
 
virtual ~argument_builder_base ()=default
 Default destructor.
 
template<typename Action >
action_argument_builder< details::first_argument_type< Action > > & add_action_argument (Action action, CharType short_name)
 Adds a new action argument. More...
 
template<typename Action >
action_argument_builder< details::first_argument_type< Action > > & add_action_argument (Action action, string_type name)
 Adds a new action argument. More...
 
template<typename T >
argument_builder< T > & add_argument (T &value, CharType short_name)
 Adds a new argument, and returns an argument_builder that can be used to further customize it. More...
 
template<typename T >
argument_builder< T > & add_argument (T &value, string_type name)
 Adds a new argument, and returns an argument_builder that can be used to further customize it. More...
 
template<typename T >
multi_value_argument_builder< T > & add_multi_value_argument (T &value, CharType short_name)
 Adds a new multi-value argument. More...
 
template<typename T >
multi_value_argument_builder< T > & add_multi_value_argument (T &value, string_type name)
 Adds a new multi-value argument. More...
 
action_argument_builder< bool > & add_version_argument (version_function function)
 Adds the standard version argument. More...
 
action_argument_builder< bool > & add_win32_version_argument ()
 Adds the standard version argument, using version information from the VERSIONINFO resource. More...
 
parser_type build ()
 Creates a basic_command_line_parser using the current options and arguments. More...
 
const string_typename () const noexcept
 Returns the name of the argument.
 
argument_builder_baseoperator= (argument_builder_base &)=delete
 
const CharType & short_name () const noexcept
 Returns the short name of the argument.
 

Additional Inherited Members

- Protected Member Functions inherited from ookii::basic_parser_builder< CharType, Traits, Alloc >::argument_builder_base
 argument_builder_base (basic_parser_builder &basic_parser_builder, CharType short_name)
 Initializes a new instance of the argument_builder_base class. More...
 
 argument_builder_base (basic_parser_builder &basic_parser_builder, string_type name)
 Initializes a new instance of the argument_builder_base class. More...
 
size_t get_next_position ()
 Gets the next position for a positional argument.
 
storage_type & storage ()
 Provides access to the argument's options storage.
 

Detailed Description

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T>
class ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T >

Specifies options for an action argument.

Template Parameters
TThe type of the argument's values.

Constructor & Destructor Documentation

◆ action_argument_builder() [1/2]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T >::action_argument_builder ( basic_parser_builder parser_builder,
string_type  name,
function_type  action 
)
inline

Initializes a new instance of the argument_builder class.

Parameters
parser_builderA reference to the basic_parser_builder used to build this argument.
nameThe name of the argument.
actionThe action to invoke when the argument is supplied.

◆ action_argument_builder() [2/2]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T >::action_argument_builder ( basic_parser_builder parser_builder,
CharType  short_name,
function_type  action 
)
inline

Initializes a new instance of the argument_builder class.

Parameters
parser_builderA reference to the basic_parser_builder used to build this argument.
short_nameThe short name of the argument.
actionThe action to invoke when the argument is supplied.

Member Function Documentation

◆ converter()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
action_argument_builder& ookii::basic_parser_builder< CharType, Traits, Alloc >::action_argument_builder< T >::converter ( converter_type  converter)
inline

Supplies a custom function to convert strings to the argument's type.

Parameters
converterThe function used for conversions.

A conversion function must have the signature std::optional<T>(std::basic_string_view<CharType> value, const std::locale &loc). It should return std::nullopt if the conversion failed.

Even if a custom converter is used, conversion using the default method (stream extraction or a specialized lexical_convert template) must still be possible in order to avoid compiler errors. Use this method if a default conversion exists, but you wish to deviate from it for a specific argument.


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