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

Provides options for how to format usage help. More...

#include <ookii/usage_options.h>

Collaboration diagram for ookii::basic_usage_options< CharType, Traits, Alloc >:
Collaboration graph
[legend]

Classes

struct  defaults
 Provides default values for the fields of basic_usage_options. More...
 

Public Types

using stream_type = std::basic_ostream< CharType, Traits >
 The concrete stream type used.
 
using string_type = std::basic_string< CharType, Traits, Alloc >
 The concrete string type used.
 

Public Member Functions

 basic_usage_options ()
 Initializes a new instance of the basic_usage_options class. More...
 
 basic_usage_options (stream_type &output)
 Initializes a new instance of the basic_usage_options class with the specified stream. More...
 
 basic_usage_options (stream_type &output, stream_type &error)
 Initializes a new instance of the basic_usage_options class with the specified output and error streams. More...
 

Public Attributes

string_type alias_format {defaults::alias_format.data()}
 The format to use for the aliases of an argument. More...
 
string_type alias_separator {defaults::alias_separator.data()}
 The separator to use if the argument has more than one alias.
 
string_type argument_description_format {defaults::argument_description_format.data()}
 The format to use for the description of an argument. More...
 
size_t argument_description_indent {defaults::argument_description_indent}
 The level of indentation to use when writing argument descriptions. More...
 
string_type default_value_format {defaults::default_value_format.data()}
 The format to use for the default value of an argument. More...
 
stream_typeerror
 The stream used to write errors to.
 
bool include_aliases_in_description {true}
 Indicates whether to include the aliases of arguments in the description. More...
 
bool include_default_value_in_description {true}
 Indicates whether to include the default value of arguments in the description. More...
 
string_type multi_value_suffix {defaults::multi_value_suffix.data()}
 Suffix to add to the syntax of multi-value arguments.
 
string_type optional_argument_format {defaults::optional_argument_format.data()}
 The format to use for the syntax of an optional argument. More...
 
stream_typeoutput
 The stream used to write usage help to.
 
size_t syntax_indent {defaults::syntax_indent}
 The level of indentation to use when writing the usage syntax. More...
 
string_type usage_prefix_format {defaults::usage_prefix_format.data()}
 The format to use for the prefix to the usage syntax. More...
 
bool use_white_space_value_separator {true}
 Indicates whether to use white space as the argument name separator in the usage syntax. More...
 
string_type value_description_format {defaults::value_description_format.data()}
 The format to use for the value description of an argument. More...
 

Detailed Description

template<typename CharType, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
class ookii::basic_usage_options< CharType, Traits, Alloc >

Provides options for how to format usage help.

This type is used by the basic_command_line_parser to determine how to show errors or usage help.

Two typedefs for common character types are provided:

Type Definition
ookii::usage_options ookii::basic_usage_options<char>
ookii::wusage_options ookii::basic_usage_options<wchar_t>
Template Parameters
CharTypeThe character type to use for arguments and other strings.
TraitsThe character traits to use for strings. Defaults to std::char_traits<CharType>.
AllocThe allocator to use for strings. Defaults to std::allocator<CharType>.

Constructor & Destructor Documentation

◆ basic_usage_options() [1/3]

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
ookii::basic_usage_options< CharType, Traits, Alloc >::basic_usage_options ( )
inline

Initializes a new instance of the basic_usage_options class.

This instance will write to a line_wrapping_ostream for the standard output stream and the standard input stream.

◆ basic_usage_options() [2/3]

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
ookii::basic_usage_options< CharType, Traits, Alloc >::basic_usage_options ( stream_type output)
inline

Initializes a new instance of the basic_usage_options class with the specified stream.

This instance will write both errors and usage to the same stream.

Parameters
outputThe stream used for usage help and errors.

◆ basic_usage_options() [3/3]

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
ookii::basic_usage_options< CharType, Traits, Alloc >::basic_usage_options ( stream_type output,
stream_type error 
)
inline

Initializes a new instance of the basic_usage_options class with the specified output and error streams.

Parameters
outputThe stream used for usage help.
errorThe stream used for errors.

Member Data Documentation

◆ alias_format

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
string_type ookii::basic_usage_options< CharType, Traits, Alloc >::alias_format {defaults::alias_format.data()}

The format to use for the aliases of an argument.

This value must contain a {} placeholder for the aliases.

◆ argument_description_format

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
string_type ookii::basic_usage_options< CharType, Traits, Alloc >::argument_description_format {defaults::argument_description_format.data()}

The format to use for the description of an argument.

This value must contain {} placeholders for the argument name prefix, the argument name, the value description, the aliases, the description, and the default value of the argument.

The placeholder for the aliases is set to a blank string if the argument has no aliases, or if include_aliases_in_description is false.

The placeholder for the default value is set to a blank string if the argument has no default value, or if include_default_value_in_description is false.

◆ argument_description_indent

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
size_t ookii::basic_usage_options< CharType, Traits, Alloc >::argument_description_indent {defaults::argument_description_indent}

The level of indentation to use when writing argument descriptions.

Note that the first line of each argument is not indented.

This value has no effect if the output stream is not using a line_wrapping_streambuf.

◆ default_value_format

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
string_type ookii::basic_usage_options< CharType, Traits, Alloc >::default_value_format {defaults::default_value_format.data()}

The format to use for the default value of an argument.

This value must contain a {} placeholder for the default value.

◆ include_aliases_in_description

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
bool ookii::basic_usage_options< CharType, Traits, Alloc >::include_aliases_in_description {true}

Indicates whether to include the aliases of arguments in the description.

The default value is true.

◆ include_default_value_in_description

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
bool ookii::basic_usage_options< CharType, Traits, Alloc >::include_default_value_in_description {true}

Indicates whether to include the default value of arguments in the description.

The default value is true.

◆ optional_argument_format

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
string_type ookii::basic_usage_options< CharType, Traits, Alloc >::optional_argument_format {defaults::optional_argument_format.data()}

The format to use for the syntax of an optional argument.

This value must contain a {} placeholder for the argument name.

◆ syntax_indent

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
size_t ookii::basic_usage_options< CharType, Traits, Alloc >::syntax_indent {defaults::syntax_indent}

The level of indentation to use when writing the usage syntax.

Note that the first line of the syntax is not indented.

This value has no effect if the output stream is not using a line_wrapping_streambuf.

◆ usage_prefix_format

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
string_type ookii::basic_usage_options< CharType, Traits, Alloc >::usage_prefix_format {defaults::usage_prefix_format.data()}

The format to use for the prefix to the usage syntax.

This value must contain a {} placeholder for the application name.

◆ use_white_space_value_separator

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
bool ookii::basic_usage_options< CharType, Traits, Alloc >::use_white_space_value_separator {true}

Indicates whether to use white space as the argument name separator in the usage syntax.

If false, the separator specified in basic_parser_builder::argument_name_separator() is used instead. The default value is true.

If basic_parser_builder::allow_white_space_separator() is set to false, this value has no effect and the basic_parser_builder::argument_name_separator() is always used.

◆ value_description_format

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
string_type ookii::basic_usage_options< CharType, Traits, Alloc >::value_description_format {defaults::value_description_format.data()}

The format to use for the value description of an argument.

This value must contain a {} placeholder for the value description.


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