Keyword argument tags. More...
Variables | |
unspecified_keyword_type | name |
Argument name. More... | |
unspecified_keyword_type | description |
One-line argument description. More... | |
unspecified_keyword_type | default_value |
Argument default value. More... | |
unspecified_keyword_type | type_name |
Type name of this arguments type. More... | |
unspecified_keyword_type | default_doc |
String rep of default value. More... | |
unspecified_keyword_type | parser |
Argument parser. More... | |
Keyword argument tags.
The tags defined in this namespace are used as keyword arguments via the Boost.Parameter library.
For the keyword tags, the standard C++ scoping rules apply
The second alternative is preferred, the <tt>using namespace</tt> directive may be used as long as the keyword names do not clash with another visible symbol.
The keywords are used to set argument attributes. The keywords \ref default_value and \ref parser influence, how an argument is parsed/interpreted whereas \ref name, \ref description, \ref type_name and \ref default_doc are used to change the arguments documentation:
Will create the following documentation:
Usage: command [name:type_name] With: name description default: default_doc
unspecified_keyword_type senf::console::kw::default_doc |
String rep of default value.
By default, the default value is documented by converting the value to it's string representation using the corresponding return value formatter which by default uses boost::lexical_cast
/ iostreams
. The displayed value can be changed by setting this attribute.
Definition at line 362 of file ParsedCommand.hh.
unspecified_keyword_type senf::console::kw::default_value |
Argument default value.
If a default value is specified for an argument, that argument is optional. If an overload is called with fewer arguments than defined, optional values will be used beginning at the last optional argument and going forward until all arguments have values assigned. E.g., an overload with 5 parameters a - e with two defaults attached:
command a:int [b:int] c:int [d:int] e:int
When calling the overload, the arguments will be assigned in the following way:
command 1 2 | SyntaxErrorException: invalid number of arguments | ||||
command 1 2 3 | a = 1 | b = default | c = 2 | d = default | e = 3 |
command 1 2 3 4 | a = 1 | b = 2 | c = 3 | d = default | e = 4 |
command 1 2 3 4 5 | a = 1 | b = 2 | c = 3 | d = 4 | e = 5 |
command 1 2 3 4 5 6 | SyntaxErrorException: invalid number of arguments |
So, if you use default values as you are used to, assigning default values to consecutive trailing arguments, they work like they do in C++ and most other languages
Definition at line 316 of file ParsedCommand.hh.
unspecified_keyword_type senf::console::kw::description |
One-line argument description.
This description is shown in the argument reference. If several overloads have same-named arguments, only one of them should be documented. This documentation then applies to all arguments of that name.
Definition at line 310 of file ParsedCommand.hh.
unspecified_keyword_type senf::console::kw::name |
Argument name.
Sets the displayed name of the argument.
Definition at line 308 of file ParsedCommand.hh.
unspecified_keyword_type senf::console::kw::parser |
Argument parser.
The argument parser is used to convert the argument token list returned by the console/config parser into the appropriate value. If not set explicitly, this conversion is supplied by the ArgumentTraits class.
Setting the parser attribute allows to use a custom parser. The parser is an arbitrary callable object with the signature
where value_type
is the type of the overload parameter. The parser must read and parse the complete tokens range and return the parsed value in out. If the parser fails, it must raise a senf::console::SyntaxErrorException.
Definition at line 369 of file ParsedCommand.hh.
unspecified_keyword_type senf::console::kw::type_name |
Type name of this arguments type.
By default, the type of an argument is extracted from the C++ type name by taking the last component of the fully scoped name. This value can be changed by setting this attribute.
Definition at line 357 of file ParsedCommand.hh.