Namespace for command‐line parsing components.

Types

Name

Description

CommandLine

This value‐semantic class parses, validates, and provides access to command‐line arguments. The constructor takes the specification describing the command‐line arguments. Once created, printUsage can be invoked to print the usage syntax. The parse method takes command‐line arguments and validates them against the specification provided at creation, writing a suitable message to an optionally‐specified stream in case of a parsing error. Once parsed, options and values can be accessed using various accessors. The class has a set of theType methods (e.g., theString, theInt) that provide access, by name, to the value of the indicated option. It is also possible to link a variable with an option in the specification; doing so will cause the variable to be loaded with the option value once parse has been invoked. The options method returns a balcl::CommandLineOptionsHandle object referring to the option names and their values. A similar but different method, specifiedOptions, is suitable for overwriting other configuration parameters (possibly obtained from a configuration file).

CommandLineOptionsHandle

This class provides access to the parsed options (if any) of its creating CommandLine object. The behavior is undefined if any of the methods of this class (accessors all) are invoked after a subsequent invocation of the parse method of the creating object or after the destruction of the creating object.

CommandLine_SchemaData

This struct, a pure value‐semantic type, is used to manage option value type and name information in support of public interfaces to parsed options. See CommandLineOptionsHandle.

Constraint

This struct provides a namespace that defines the types used to impose user‐defined constraints on values associated with command‐line options. One type is defined for each scalar type defined in balcl::OptionType except for bool.

OccurrenceInfo

This class is a simple attribute class that describes a command‐line option occurrence requirement (i.e., required, optional, or optional but hidden) and default value, if any.

Option

This class, constructible from and implicitly convertible to OptionInfo, provides the same attributes, but also uses a bslma::Allocator and thus can be stored in a container. A minor subtlety arises in the name attribute, whereby any suffix starting with an = sign in the name attribute of a OptionInfo is removed in order to derive the name of the Option.

OptionInfo

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.

OptionType

This struct provides a namespace for enumerating types used for command‐line option values. See {Enumerators} for details.

OptionValue

This class implements a special‐use value‐semantic variant type used to represent values parsed from process command lines. Accordingly, this class can represent values of any of the types defined in balcl_optiontype. Furthermore, that value can also be in a null state (defined type but no defined value) to represent allowed options that do not appear among the command‐line arguments (and for which no default value has been configured).

OptionValue_NullOf

This single‐attribute class represents a null value of a given nullable balcl::OptionType. OptionValue uses this type to represent its state where there is a known type, but no value for it. Note that OptionType::e_VOID is not nullable, therefore not supported here. Note that: There is no swap member or namespace‐level function declared (and defined) for this class on purpose, the general swap works fast for such a simple type.

TypeInfo

This class is a attribute class that describes the type, the variable to be linked, and the constraint on an option. Note that the constraint type is opaque, but it is possible to apply the constraint to an element of the same type as the option and see whether it is valid (using the satisfiesConstraint methods of TypeInfoUtil).

TypeInfoConstraint

Component‐private protocol class for opaque option value constraints.

TypeInfoUtil

This utility struct provides a namespace for functions that perform non‐primitive operations using TypeInfo objects.

Functions

Name

Description

swap

Swap the value of the specified a object with the value of the specified b object. This method provides the no‐throw exception‐safety guarantee if either a.type() is the same as b.type() and a and b were created with the same allocator, or neither a.type() nor b.type() is a type that requires allocation; otherwise, it provides the basic guarantee.

operator<<

Stream insertion operators

operator==

Equality operators

operator!=

Inequality operators

Created with MrDocs