BloombergLP::balcl::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.

Synopsis

Declared in <balcl_option.h>

class Option;

Member Functions

NameDescription
Option [constructor]Constructors
~Option [destructor]Destroy this command-line option object.
operator= Assignment operators
allocator Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the currently installed default allocator at construction is used.
argType Return the ArgType enumerator identifying whether this option is a flag (i.e., a tag not followed by a value), or whether it is an option (i.e., a tag followed by a value), or a non-option argument (i.e., a value not preceded by a short or long tag).
description Return the description of this option.
environmentVariableName Return the environment variable name of this option.
isArray Return true if the value of this option is of array type, and false otherwise.
isDescriptionValid Return true if the description is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.
isLongTagValid Return true if the specified longTag is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.
isNameValid Return true if the name is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.
isTagValid Return true if the tag is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.
longTag Return the string used to identify this option on a command line preceded with --, or 0 if there is no long tag associated with this option. The behavior is undefined if this option is a non-option argument (i.e., has no tag).
name Return the name of this option.
occurrenceInfo Return a const reference to the occurrence info for this option (i.e., whether the option is required, optional, or hidden, and its default value, if any).
print Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this object. If level is negative, suppress indentation of the first line. If stream is not valid on entry, this operation has no effect. The behavior is undefined if spacesPerLevel is negative.
shortTag Return the single character used to identify this option on a command line preceded with a single -, or 0 if this option only has a long tag. The behavior is undefined if this option is a non-option argument (i.e., has no tag).
tagString Return the tag string provided to this object at construction. Note that this string is empty if this is a non-option argument.
typeInfo Return a const reference to the type info for this option (i.e., the type of the option, whether the option is linked to a variable, and whether it has a constraint).
operator BloombergLP::bslmf::NestedTraitDeclaration<Option, HasPrintMethod> Nested trait declaration for bslma::UsesBslmaAllocator.
operator OptionInfo const& Return a const reference to the OptionInfo object having the value of this option.

Non-Member Functions

NameDescription
operator!=Return true if the specified lhs command-line option has a different value from the specified rhs command-line option, and false otherwise. Two Option objects do not have the same value if their underlying OptionInfo objects do not have the same value.
operator==Return true if the specified lhs and rhs have the same value, and false otherwise. Two Option objects have the same value if their underlying OptionInfo objects have the same value.