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

Parses command line arguments into strongly-typed values. More...

#include <ookii/command_line_parser.h>

Public Types

using argument_base_type = command_line_argument_base< CharType, Traits, Alloc >
 The specialized type of command_line_argument_base used.
 
template<typename T >
using argument_type = command_line_argument< T, CharType, Traits, Alloc >
 The specialized type of command_line_argument used. More...
 
template<typename T >
using converter_type = typename argument_type< T >::typed_storage_type::converter_type
 The specialized type of the custom command line converter function used. More...
 
using creation_options_type = details::creation_options< CharType, Traits, Alloc >
 The specialized type of parser creation options used. For internal use.
 
using on_parsed_callback = std::function< on_parsed_action(argument_base_type &, std::optional< string_view_type > value)>
 The callback function type for on_parsed().
 
using result_type = parse_result< CharType, Traits, Alloc >
 The specialized type of parse_result used.
 
using storage_type = details::parser_storage< CharType, Traits, Alloc >
 The specialized type of parser parameter storage used. For internal use.
 
using string_provider_type = basic_localized_string_provider< CharType, Traits, Alloc >
 The specialized type of basic_localized_string_provider used.
 
using string_type = typename argument_base_type::string_type
 The specialized type of std::basic_string used.
 
using string_view_type = std::basic_string_view< CharType, Traits >
 The specialized type of std::basic_string_view used.
 
using usage_writer_type = basic_usage_writer< CharType, Traits, Alloc >
 The specialized type of basic_usage_writer used.
 

Public Member Functions

template<typename Range >
 basic_command_line_parser (const Range &arguments, storage_type &&storage, creation_options_type &options)
 Creates a new instance of the basic_command_line_parser class. More...
 
bool allow_duplicate_arguments () const noexcept
 Indicates whether duplicate arguments are allowed. More...
 
bool allow_white_space_separator () const noexcept
 Indicates whether argument names and values can be separated by white space. More...
 
auto argument_comparer () const
 Gets the comparer used for argument names. More...
 
size_t argument_count () const
 Gets the total number of arguments.
 
CharType argument_value_separator () const noexcept
 
auto arguments () const
 Gets a view of all the arguments defined by the parser. More...
 
const string_typecommand_name () const noexcept
 Returns the command name used when generating usage help. More...
 
const string_typedescription () const noexcept
 Returns the description used when generating usage help. More...
 
argument_base_typeget_argument (size_t pos)
 Gets an argument by position. More...
 
const argument_base_typeget_argument (size_t pos) const
 Gets an argument by position. More...
 
const argument_base_typeget_argument (string_view_type name) const noexcept
 Gets an argument by name. More...
 
argument_base_typeget_argument (string_view_type name) noexcept
 Gets an argument by name. More...
 
const argument_base_typeget_help_argument () const noexcept
 Gets the help argument, if there is one. More...
 
const argument_base_typeget_short_argument (CharType name) const noexcept
 Gets an argument by short name. More...
 
argument_base_typeget_short_argument (CharType name) noexcept
 Gets an argument by short name. More...
 
bool help_requested () const noexcept
 Gets a value that indicates help should be shown if parse() returns a parse_result with parse_error::parsing_cancelled. More...
 
void help_requested (bool help_requested) noexcept
 Sets a value that indicates help should be shown if parse() returns a parse_result with parse_error::parsing_cancelled. More...
 
const std::locale & locale () const noexcept
 Gets the locale used to parse argument values and to format strings. More...
 
const string_typelong_prefix () const noexcept
 Gets the long argument prefix. More...
 
parsing_mode mode () const noexcept
 Gets the parsing mode used by this parser. More...
 
void on_parsed (on_parsed_callback callback)
 Sets a callback that will be invoked every time an argument is parsed. More...
 
template<typename Range >
result_type parse (const Range &range)
 Parses the arguments in the specified range. More...
 
result_type parse (int argc, const CharType *const argv[])
 Parses the provided arguments. More...
 
result_type parse (int argc, const CharType *const argv[], usage_writer_type *usage)
 Parses the provided arguments, and writes error and usage information to the console if a parsing error occurs. More...
 
template<typename Iterator >
result_type parse (Iterator begin, Iterator end)
 Parses the arguments in the range specified by the iterators. More...
 
template<typename Iterator >
result_type parse (Iterator begin, Iterator end, usage_writer_type *usage)
 Parses the arguments in the range specified by the iterators, and writes error and usage information to the console if a parsing error occurs. More...
 
template<typename Range >
result_type parse (Range range, usage_writer_type *usage)
 Parses the arguments in the specified range, and writes error and usage information to the console if a parsing error occurs. More...
 
template<typename T >
result_type parse (std::initializer_list< T > args)
 Parses the arguments in the specified initializer list. More...
 
template<typename T >
result_type parse (std::initializer_list< T > args, usage_writer_type *usage)
 Parses the arguments in the specified initializer list, and writes error and usage information to the console if a parsing error occurs. More...
 
size_t positional_argument_count () const
 Gets the number of positional arguments. More...
 
const std::vector< string_type > & prefixes () const noexcept
 Gets a list of all the argument name prefixes accepted by the parser. More...
 
auto short_argument_comparer () const
 Gets the comparer used for short argument names. More...
 
const string_provider_typestring_provider () const noexcept
 Gets the basic_localized_string_provider implementation used to get strings for error messages etc. More...
 
void write_usage (usage_writer_type *usage=nullptr, usage_help_request request=usage_help_request::full)
 Writes usage help for this parser's arguments. More...
 

Static Public Member Functions

static constexpr std::vector< string_typeget_default_prefixes ()
 Gets the default prefixes accepted by the parser. More...
 
static string_type get_executable_name (int argc, const CharType *const argv[], bool include_extension=false)
 Extracts the executable name from the application's arguments. More...
 

Detailed Description

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

Parses command line arguments into strongly-typed values.

The basic_command_line_parser class can parse a set of command line arguments in string form into a set of typed values. Which arguments are accepted and where their values will be stored is defined by the basic_parser_builder that created the basic_command_line_parser instance.

In addition, this class can generate detailed usage help for the defined arguments, which can be shown to the user in case an argument parsing error happens or help is requested.

To parse arguments, call one of the overloads of the parse() method. Those overloads taking a basic_usage_writer will handle any errors and print the error as well as usage information to the console. Most commonly, the overload you'll want to use is parse(int argc, const CharType *const argv[], usage_writer_type *usage).

Two typedefs for common character types are provided:

Type Definition
ookii::command_line_parser ookii::basic_command_line_parser<char>
ookii::wcommand_line_parser ookii::basic_command_line_parser<wchar_t>
Template Parameters
CharTypeThe character type used for arguments and other strings. Only char and wchar_t are supported. Defaults to wchar_t if _UNICODE is defined, otherwise to char.
TraitsThe character traits to use for strings. Defaults to std::char_traits<CharType>.
AllocThe allocator to use for strings. Defaults to std::allocator<CharType>.

Member Typedef Documentation

◆ argument_type

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
using ookii::basic_command_line_parser< CharType, Traits, Alloc >::argument_type = command_line_argument<T, CharType, Traits, Alloc>

The specialized type of command_line_argument used.

Template Parameters
TThe type of the argument.

◆ converter_type

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
using ookii::basic_command_line_parser< CharType, Traits, Alloc >::converter_type = typename argument_type<T>::typed_storage_type::converter_type

The specialized type of the custom command line converter function used.

Template Parameters
TThe type of the argument.

Constructor & Destructor Documentation

◆ basic_command_line_parser()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename Range >
ookii::basic_command_line_parser< CharType, Traits, Alloc >::basic_command_line_parser ( const Range &  arguments,
storage_type &&  storage,
creation_options_type options 
)
inline

Creates a new instance of the basic_command_line_parser class.

Warning
This constructor should not be used directly; instead, use the basic_parser_builder class to create instances.
Template Parameters
RangeThe type of a range containing basic_parser_builder::argument_builder instances.
Parameters
argumentsA range containing basic_parser_builder::argument_builder instances.
storageParameters for the basic_command_line_parser.
optionsCreation options provided by the basic_parser_builder.

Member Function Documentation

◆ allow_duplicate_arguments()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
bool ookii::basic_command_line_parser< CharType, Traits, Alloc >::allow_duplicate_arguments ( ) const
inlinenoexcept

Indicates whether duplicate arguments are allowed.

This value is set by basic_parser_builder::allow_duplicate_arguments()

◆ allow_white_space_separator()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
bool ookii::basic_command_line_parser< CharType, Traits, Alloc >::allow_white_space_separator ( ) const
inlinenoexcept

Indicates whether argument names and values can be separated by white space.

This value is set by basic_parser_builder::allow_white_space_separator()

◆ argument_comparer()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
auto ookii::basic_command_line_parser< CharType, Traits, Alloc >::argument_comparer ( ) const
inline

Gets the comparer used for argument names.

If the mode() method returns parsing_mode::long_short, this is the argument comparer for short names.

◆ argument_value_separator()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
CharType ookii::basic_command_line_parser< CharType, Traits, Alloc >::argument_value_separator ( ) const
inlinenoexcept

Indicates the non-whitespace separator used to separaet argument names and values.

This value is set by basic_parser_builder::argument_value_separator()

◆ arguments()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
auto ookii::basic_command_line_parser< CharType, Traits, Alloc >::arguments ( ) const
inline

Gets a view of all the arguments defined by the parser.

The arguments will be returned in alphabetical order.

◆ command_name()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const string_type& ookii::basic_command_line_parser< CharType, Traits, Alloc >::command_name ( ) const
inlinenoexcept

Returns the command name used when generating usage help.

This value is set by the basic_parser_builder::basic_parser_builder() constructor.

◆ description()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const string_type& ookii::basic_command_line_parser< CharType, Traits, Alloc >::description ( ) const
inlinenoexcept

Returns the description used when generating usage help.

This value is set by basic_parser_builder::description().

◆ get_argument() [1/4]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
argument_base_type& ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_argument ( size_t  pos)
inline

Gets an argument by position.

Parameters
posThe argument's position.

Only positional arguments can be retrieved using this method.

Positional arguments are created using basic_parser_builder::argument_builder_common::positional().

Exceptions
std::out_of_rangeThere is no argument at the specified position.

◆ get_argument() [2/4]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const argument_base_type& ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_argument ( size_t  pos) const
inline

Gets an argument by position.

Parameters
posThe argument's position.

Only positional arguments can be retrieved using this method.

Positional arguments are created using basic_parser_builder::argument_builder_common::positional().

Exceptions
std::out_of_rangeThere is no argument at the specified position.

◆ get_argument() [3/4]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const argument_base_type* ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_argument ( string_view_type  name) const
inlinenoexcept

Gets an argument by name.

Both the argument's main name and any of its aliases can be used.

Parameters
nameThe argument's name or alias.
Returns
A pointer to the argument, or nullptr if the argument was not found.

◆ get_argument() [4/4]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
argument_base_type* ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_argument ( string_view_type  name)
inlinenoexcept

Gets an argument by name.

Both the argument's main name and any of its aliases can be used.

Parameters
nameThe argument's name or alias.
Returns
A pointer to the argument, or nullptr if the argument was not found.

◆ get_default_prefixes()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
static constexpr std::vector<string_type> ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_default_prefixes ( )
inlinestaticconstexpr

Gets the default prefixes accepted by the parser.

By default, the parser accepts '/' and '-' on Windows, and only '-' on other systems.

Which prefixes are accepted can be changed using basic_parser_builder::prefixes().

◆ get_executable_name()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
static string_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_executable_name ( int  argc,
const CharType *const  argv[],
bool  include_extension = false 
)
inlinestatic

Extracts the executable name from the application's arguments.

This can be used to get the command name for the basic_parser_builder's constructor.

Parameters
argcThe number of arguments.
argvAn array containing the arguments.
include_extensiontrue to include the file's extension; otherwise, false.
Returns
The name of the executable, or an empty string if argc was zero.

◆ get_help_argument()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const argument_base_type* ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_help_argument ( ) const
inlinenoexcept

Gets the help argument, if there is one.

Returns
If the automatic help argument is enabled, this will return either the created help argument, or the manually defined argument which had a conflicting name. If the automatic help argument is disabled, this always returns nullptr.

◆ get_short_argument() [1/2]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const argument_base_type* ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_short_argument ( CharType  name) const
inlinenoexcept

Gets an argument by short name.

Both the argument's main short name and any of its short aliases can be used.

Parameters
nameThe argument's short name or alias.
Returns
A pointer to the argument, or nullptr if the argument was not found.

◆ get_short_argument() [2/2]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
argument_base_type* ookii::basic_command_line_parser< CharType, Traits, Alloc >::get_short_argument ( CharType  name)
inlinenoexcept

Gets an argument by short name.

Both the argument's main short name and any of its short aliases can be used.

Parameters
nameThe argument's short name or alias.
Returns
A pointer to the argument, or nullptr if the argument was not found.

◆ help_requested() [1/2]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
bool ookii::basic_command_line_parser< CharType, Traits, Alloc >::help_requested ( ) const
inlinenoexcept

Gets a value that indicates help should be shown if parse() returns a parse_result with parse_error::parsing_cancelled.

After calling parse(), if the result was parse_error::none, this method always returns false. If the result was an error other than parse_error::parsing_cancelled, it always returns true.

Arguments cancelled using basic_parser_builder::argument_builder_common::cancel_parsing() automatically set this value to true. Action arguments that cancelled parsing must explicitly do so.

◆ help_requested() [2/2]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
void ookii::basic_command_line_parser< CharType, Traits, Alloc >::help_requested ( bool  help_requested)
inlinenoexcept

Sets a value that indicates help should be shown if parse() returns a parse_result with parse_error::parsing_cancelled.

Parameters
help_requestedThe new value.

◆ locale()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const std::locale& ookii::basic_command_line_parser< CharType, Traits, Alloc >::locale ( ) const
inlinenoexcept

Gets the locale used to parse argument values and to format strings.

This value is set by basic_parser_builder::locale()

◆ long_prefix()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const string_type& ookii::basic_command_line_parser< CharType, Traits, Alloc >::long_prefix ( ) const
inlinenoexcept

Gets the long argument prefix.

By default, the parser accepts '–' for long argument names.

If not using parsing_mode::long_short, this value is not used and is always empty.

◆ mode()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
parsing_mode ookii::basic_command_line_parser< CharType, Traits, Alloc >::mode ( ) const
inlinenoexcept

Gets the parsing mode used by this parser.

This value is set by the basic_parser_builder::mode() function.

◆ on_parsed()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
void ookii::basic_command_line_parser< CharType, Traits, Alloc >::on_parsed ( on_parsed_callback  callback)
inline

Sets a callback that will be invoked every time an argument is parsed.

Parameters
callbackThe callback to be invoked.

The callback must have the signature on_parsed_action(argument_base_type &arg, string_view_type value).

The callback will be invoked after the argument's value has been set. If the argument's value was invalid, it will not be invoked. The value may be an empty string if this is a switch argument.

The callback can control whether parsing continues with the returned on_parsed_action value.

Only one callback can be registered. Calling this function again will replace the previous callback.

◆ parse() [1/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename Range >
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( const Range &  range)
inline

Parses the arguments in the specified range.

Warning
The range should not include the application name.
Template Parameters
RangeThe type of the range. This type must define global begin() and end() functions.
Parameters
rangeA range containing the arguments.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [2/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( int  argc,
const CharType *const  argv[] 
)
inline

Parses the provided arguments.

Warning
It's assumed that argv[0] contains the application name, so this value is skipped when parsing.
Parameters
argcThe number of arguments.
argvAn array containing the arguments.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [3/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( int  argc,
const CharType *const  argv[],
usage_writer_type usage 
)
inline

Parses the provided arguments, and writes error and usage information to the console if a parsing error occurs.

Warning
It's assumed that argv[0] contains the application name, so this value is skipped when parsing.
Parameters
argcThe number of arguments.
argvAn array containing the arguments.
usageThe basic_usage_writer used for writing errors and usage help in the case of an error. Use {} to specify a default usage writer.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [4/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename Iterator >
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( Iterator  begin,
Iterator  end 
)
inline

Parses the arguments in the range specified by the iterators.

Warning
The range indicated by begin, end should not include the application name.
Template Parameters
IteratorThe type of the iterator. This type must meet the requirements of a forward_iterator.
Parameters
beginAn iterator pointing to the first argument.
endAn iterator pointing to directly after the last argument.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [5/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename Iterator >
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( Iterator  begin,
Iterator  end,
usage_writer_type usage 
)
inline

Parses the arguments in the range specified by the iterators, and writes error and usage information to the console if a parsing error occurs.

Warning
The range indicated by begin, end should not include the application name.
Template Parameters
IteratorThe type of the iterator. This type must meet the requirements of a forward_iterator.
Parameters
beginAn iterator pointing to the first argument.
endAn iterator pointing to directly after the last argument.
usageThe basic_usage_writer used for writing errors and usage help in the case of an error. Use {} to specify a default usage writer.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [6/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename Range >
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( Range  range,
usage_writer_type usage 
)
inline

Parses the arguments in the specified range, and writes error and usage information to the console if a parsing error occurs.

Warning
The range should not include the application name.
Template Parameters
RangeThe type of the range. This type must define global begin() and end() functions.
Parameters
rangeA range containing the arguments.
usageThe basic_usage_writer used for writing errors and usage help in the case of an error. Use {} to specify a default usage writer.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [7/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( std::initializer_list< T >  args)
inline

Parses the arguments in the specified initializer list.

Warning
The list should not include the application name.
Template Parameters
TThe type of the elements in the initializer list. This must be a string type that can be converted to std::basic_string<CharType, Traits, Alloc>.
Parameters
argsThe arguments.
Returns
A parse_result that indicates whether the operation was successful.

◆ parse() [8/8]

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename T >
result_type ookii::basic_command_line_parser< CharType, Traits, Alloc >::parse ( std::initializer_list< T >  args,
usage_writer_type usage 
)
inline

Parses the arguments in the specified initializer list, and writes error and usage information to the console if a parsing error occurs.

Warning
The list should not include the application name.
Template Parameters
TThe type of the elements in the initializer list. This must be a string type that can be converted to std::basic_string<CharType, Traits, Alloc>.
Parameters
argsThe arguments.
usageThe basic_usage_writer used for writing errors and usage help in the case of an error. Use {} to specify a default usage writer.
Returns
A parse_result that indicates whether the operation was successful.

◆ positional_argument_count()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
size_t ookii::basic_command_line_parser< CharType, Traits, Alloc >::positional_argument_count ( ) const
inline

Gets the number of positional arguments.

Positional arguments are created using basic_parser_builder::argument_builder_common::positional().

◆ prefixes()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const std::vector<string_type>& ookii::basic_command_line_parser< CharType, Traits, Alloc >::prefixes ( ) const
inlinenoexcept

Gets a list of all the argument name prefixes accepted by the parser.

By default, the parser accepts '-' and '/' on Windows, and only '-' on other systems.

Which prefixes are accepted can be changed using basic_parser_builder::prefixes().

◆ short_argument_comparer()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
auto ookii::basic_command_line_parser< CharType, Traits, Alloc >::short_argument_comparer ( ) const
inline

Gets the comparer used for short argument names.

If the mode() method does not return parsing_mode::long_short, this will never be used.

◆ string_provider()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
const string_provider_type& ookii::basic_command_line_parser< CharType, Traits, Alloc >::string_provider ( ) const
inlinenoexcept

Gets the basic_localized_string_provider implementation used to get strings for error messages etc.

Returns
An instance of a class derived from the basic_localized_string_provider class.

◆ write_usage()

template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
void ookii::basic_command_line_parser< CharType, Traits, Alloc >::write_usage ( usage_writer_type usage = nullptr,
usage_help_request  request = usage_help_request::full 
)
inline

Writes usage help for this parser's arguments.

Usage will be written to basic_usage_writer::output. In the default basic_usage_writer, this is a basic_line_wrapping_ostream for the standard output stream.

Parameters
usageThe basic_usage_writer used for creating the usage help.
requestThe parts of usage to write.

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