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).

Synopsis

Declared in <balcl_optionvalue.h>

class OptionValue;

Member Functions

Name

Description

OptionValue [constructor]

Constructors

operator=

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

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 is used.

hasNonVoidType

Return true if this object is in the unset state, and false otherwise. Note that if false == hasNonVoidType() then OptionType::e_VOID == type().

isNull

Return true if the value of this object (irrespective of non‐`void` type) is null. The behavior is undefined unless true == hasNonVoidType().

print

Write the value of this object to the specified output stream in a human‐readable format, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. Note that the format is not fully specified, and can change without notice.

reset

Reset this object to its default constructed (unset) state. The existing value, if any, is destroyed. Note that on return OptionType::e_VOID == type().

set

Set the value of this object to the specified value. The behavior is undefined unless OptionType::TypeToEnum<TYPE>::value == type() for the (template parameter) TYPE and OptionType::e_VOID != type().

setNull

Set the value of this object, irrespective of that value's type, to its null state. The behavior is undefined unless true == hasNonVoidType(). Note that type() is not changed.

setType

Set the type of this object to the specified type and the value to the default value of that type.

swap

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no‐throw exception‐safety guarantee if either type() is the same as other.type(), or neither type() nor other.type() is a type that requires allocation; otherwise, it provides the basic guarantee. The behavior is undefined unless this object was created with the same allocator as other.

the

the overloads

type

Return the type of this command‐line‐option value. The type OptionType::e_VOID represents the unset state.

operator BloombergLP::bslmf::NestedTraitDeclaration<OptionValue, HasPrintMethod>

Nested trait declaration for bslma::UsesBslmaAllocator.

Friends

Name

Description

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

BloombergLP::balcl::operator==

Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two OptionValue objects have the same value if they have the same type, and (if the type is not e_VOID) the value of that type (as accessed through the* methods) is the same.

Non-Member Functions

Name

Description

operator!=

Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. Two OptionValue objects do not have the same value if their type is not the same, or (if their type is not e_VOID) the value of that type (as accessed through the* methods) is not the same.

Created with MrDocs