Quick Links: |
#include <balcl_optioninfo.h>
Public Types | |
enum | ArgType { e_FLAG = 0, e_OPTION = 1, e_NON_OPTION = 2 } |
Enumerate the categories of command-line arguments. More... | |
Public Attributes | |
bsl::string | d_tag |
bsl::string | d_name |
bsl::string | d_description |
TypeInfo | d_typeInfo |
OccurrenceInfo | d_defaultInfo |
This struct
is a simple attribute class that describes the information associated with an option, namely the associated tag (as a string, from which the short and long tags are extracted), the option name, the description used in printing usage, and optional associated TypeInfo
and OccurrenceInfo
objects.
By design, this struct
does not have any user-defined constructors, so there is no provision for passing an allocator to its data members (all of which take an allocator). Consequently, all instances of this class use the default allocator. If proper allocator propagation is desired (e.g., for storage within an allocator-aware container for which the use of the default allocator is counter-indicated), one may use Option
, which is both allocator-aware and constructible from OptionInfo
.
The main purpose of this struct
is to provide a type whose values can be statically-initialized. For example:
const balcl::OptionInfo OPTIONS[] = { { "s|longTag", // s(hortTag) "optionName", "option description", balcl::TypeInfo(/* . . . */), // optional balcl::OccurrenceInfo(/* . . . */) // optional }, // ... };
Note that each of the first three fields can be default-constructed, and thus omitted in such a declaration; however, such an object will be of limited use because, to avoid undefined behavior, the constructor of balcl::CommandLine
requires that each of these fields be acceptable to the isDescriptionValid
, isNameValid
, and isTagValid
methods of balcl::Option
. The default string value is not acceptable to any of those methods. See the Usage section for an example of such initialization.
See Component balcl_optioninfo
tags (or "" for non-option argument)
accessing name
description used in printing usage
(optional) type/variable to be linked,
indicates if the option is required, and