Specifies options common to all argument types, for an argument under construction.
More...
|
BuilderType & | 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...
|
|
BuilderType & | cancel_parsing () |
| Indicates that supplying this argument will cancel parsing. More...
|
|
BuilderType & | description (string_type description) |
| Sets the long description for the argument. More...
|
|
const string_type & | name () const noexcept |
| Returns the name of the argument. More...
|
|
BuilderType & | name (string_type name) |
| Changes the name of the argument. More...
|
|
BuilderType & | positional () |
| Indicates that the argument can be specified by position. More...
|
|
BuilderType & | required () |
| Indicates that the argument is required. More...
|
|
BuilderType & | short_alias (CharType alias) |
| Adds a short alias to the argument. More...
|
|
BuilderType & | 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...
|
|
BuilderType & | short_name (CharType short_name) |
| Sets an explicit short name for an argument. More...
|
|
BuilderType & | value_description (string_type value_description) |
| Sets the value description for the argument. More...
|
|
| 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_type & | name () const noexcept |
| Returns the name of the argument.
|
|
argument_builder_base & | operator= (argument_builder_base &)=delete |
|
const CharType & | short_name () const noexcept |
| Returns the short name of the argument.
|
|
virtual std::unique_ptr< argument_base_type > | to_argument (parser_type &parser)=0 |
| Converts the argument_builder_base into a command_line_argument_base that can be used by the basic_command_line_parser. More...
|
|
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType>
class ookii::basic_parser_builder< CharType, Traits, Alloc >::argument_builder_common< BuilderType >
Specifies options common to all argument types, for an argument under construction.
- Template Parameters
-
BuilderType | The type of the the argument builder that is deriving from this class. |
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Adds an alias to the argument.
- Parameters
-
An alias is an alternate, often shorter, name for an argument that can be used to specify it on the command line. For example, an argument -Verbose
might have the alias -v
.
An argument can have multiple aliases, which can be specified by invoking this method multiple times.
When using parsing_mode::long_short, this sets the long aliases. They are ignored if the argument does not have a long name.
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Indicates that supplying this argument will cancel parsing.
If set, if this argument is supplied, argument parsing will immediately return with parse_error::parsing_cancelled. Arguments after this one will not be evaluated.
This can be used, for example, to implement a -Help
argument where usage help should be shown when supplied even if the rest of the command line is valid.
Note that parsing will be cancelled regardless of the supplied value. So, e.g. for a switch argument, -Help:false
will still cancel parsing and display help. If you want to conditionally cancel parsing, you can do so by using a callback with the basic_command_line_parser::on_parsed() method.
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Sets the long description for the argument.
- Parameters
-
description | The new description. |
The description is used when generating usage help, and is included in the list of descriptions after the usage syntax.
An argument without a description will not be included in the list of descriptions (but will still be included in the syntax).
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Indicates that the argument can be specified by position.
Calling the positional() method will make the argument positional, assigning it the next available position. Therefore, you should define positional arguments in the order you want them to be specified.
A positional argument can still be specified by name, as well as by position.
If the argument is already positional, this method has no effect.
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Indicates that the argument is required.
A required argument must be provided, otherwise parsing is not successful. Typically, required arguments should also be positional, but this is not mandatory.
If the argument is already required, this method has no effect.
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Adds a short alias to the argument.
- Parameters
-
alias | The short alias to add. |
An argument can have multiple short aliases, which can be specified by invoking this method multiple times.
This is only used when using parsing_mode::long_short, and the argument has a short name.
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Sets an explicit short name for an argument.
- Parameters
-
short_name | The short name. |
Use short_name() to use the first character of the long name as the short name.
template<typename CharType = details::default_char_type, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
template<typename BuilderType >
Sets the value description for the argument.
- Parameters
-
- Returns
- The argument builder.
The value description is a brief, often one-word description of the type of values that the argument accepts. It's used as part of the usage help's syntax. An example of a value description could be "number", "string", "name", or someting similarly simple.
For longer descriptions of the argument's purpose, use the description() method instead.
If not specified explicitly, the value description defaults to the short type name (excluding namespace names) of the argument's type. The exact value may depend on your compiler.
The default value description for a type can also be overridden by specializing the value_description template.