Describes an option, its help text (usage) and how it should be parsed.
The main input when constructing an option::Parser is an array of Descriptors.
Definition at line 326 of file OptionParser.h.
Public Attributes | |
const CheckArg | check_arg |
For each option that matches shortopt or longopt this function will be called to check a potential argument to the option. | |
const char * | help |
The usage text associated with the options in this Descriptor. | |
const unsigned | index |
Index of this option's linked list in the array filled in by the parser. | |
const char *const | longopt |
The long option name (without the leading -- ). | |
const char *const | shortopt |
Each char in this string will be accepted as a short option character. | |
const int | type |
Used to distinguish between options with the same index. | |
const CheckArg ROOT::option::Descriptor::check_arg |
For each option that matches shortopt or longopt this function will be called to check a potential argument to the option.
This function will be called even if there is no potential argument. In that case it will be passed NULL
as arg
parameter. Do not confuse this with the empty string.
See CheckArg for more information.
Definition at line 416 of file OptionParser.h.
const char* ROOT::option::Descriptor::help |
The usage text associated with the options in this Descriptor.
You can use option::printUsage() to format your usage message based on the help
texts. You can use dummy Descriptors where shortopt and longopt are both the empty string to add text to the usage that is not related to a specific option.
See option::printUsage() for special formatting characters you can use in help
to get a column layout.
Definition at line 433 of file OptionParser.h.
const unsigned ROOT::option::Descriptor::index |
Index of this option's linked list in the array filled in by the parser.
Command line options whose Descriptors have the same index will end up in the same linked list in the order in which they appear on the command line. If you have multiple long option aliases that refer to the same option, give their descriptors the same index
.
If you have options that mean exactly opposite things (e.g. --enable-foo
and --disable-foo
), you should also give them the same index
, but distinguish them through different values for type. That way they end up in the same list and you can just take the last element of the list and use its type. This way you get the usual behaviour where switches later on the command line override earlier ones without having to code it manually.
Definition at line 347 of file OptionParser.h.
const char* const ROOT::option::Descriptor::longopt |
The long option name (without the leading --
).
If this Descriptor should not have a long option name, use the empty string "". NULL is not permitted here!
While shortopt allows multiple short option characters, each Descriptor can have only a single long option name. If you have multiple long option names referring to the same option use separate Descriptors that have the same index and type. You may repeat short option characters in such an alias Descriptor but there's no need to.
'-'
but starts with a minus character and does not match any Descriptor's shortopt or longopt. Parser::error()==true
. check_arg
does not return ARG_ILLEGAL the descriptor's index will be used to pick the linked list into which to put the unknown option. Definition at line 404 of file OptionParser.h.
const char* const ROOT::option::Descriptor::shortopt |
Each char in this string will be accepted as a short option character.
The string must not include the minus character '-'
or you'll get undefined behaviour.
If this Descriptor should not have short option characters, use the empty string "". NULL is not permitted here!
See longopt for more information.
Definition at line 369 of file OptionParser.h.
const int ROOT::option::Descriptor::type |
Used to distinguish between options with the same index.
See index for details.
It is recommended that you use an enum rather than a plain int to make your code more readable.
Definition at line 356 of file OptionParser.h.