[#BloombergLP-balcl-OptionValue]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balcl.adoc[balcl]::OptionValue
:relfileprefix: ../../
:mrdocs:

This class implements a special&hyphen;use value&hyphen;semantic variant type used to represent values parsed from process command lines&period; Accordingly, this class can represent values of any of the types defined in `balcl&lowbar;optiontype`&period; 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&hyphen;line arguments (and for which no default value has been configured)&period;

== Synopsis

Declared in `&lt;balcl&lowbar;optionvalue&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class OptionValue;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balcl/OptionValue/2constructor-09.adoc[`OptionValue`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/balcl/OptionValue/operator_assign.adoc[`operator&equals;`] 
| Assign to this object the value of the specified `rhs` object, and return a reference providing modifiable access to this object&period;
| xref:BloombergLP/balcl/OptionValue/allocator.adoc[`allocator`] 
| Return the allocator used by this object to supply memory&period; Note that if no allocator was supplied at construction the currently installed default allocator is used&period;
| xref:BloombergLP/balcl/OptionValue/hasNonVoidType.adoc[`hasNonVoidType`] 
| Return `true` if this object is in the unset state, and `false` otherwise&period; Note that if `false &equals;&equals; hasNonVoidType()` then `OptionType&colon;&colon;e&lowbar;VOID &equals;&equals; type()`&period;
| xref:BloombergLP/balcl/OptionValue/isNull.adoc[`isNull`] 
| Return `true` if the value of this object (irrespective of non&hyphen;`void` type) is null&period; The behavior is undefined unless `true &equals;&equals; hasNonVoidType()`&period;
| xref:BloombergLP/balcl/OptionValue/print.adoc[`print`] 
| Write the value of this object to the specified output `stream` in a human&hyphen;readable format, and return a reference to `stream`&period; Optionally specify an initial indentation `level`, whose absolute value is incremented recursively for nested objects&period; 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&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period; Note that the format is not fully specified, and can change without notice&period;
| xref:BloombergLP/balcl/OptionValue/reset.adoc[`reset`] 
| Reset this object to its default constructed (unset) state&period; The existing value, if any, is destroyed&period; Note that on return `OptionType&colon;&colon;e&lowbar;VOID &equals;&equals; type()`&period;
| xref:BloombergLP/balcl/OptionValue/set.adoc[`set`] 
| Set the value of this object to the specified `value`&period; The behavior is undefined unless `OptionType&colon;&colon;TypeToEnum&lt;TYPE&gt;&colon;&colon;value &equals;&equals; type()` for the (template parameter) `TYPE` and `OptionType&colon;&colon;e&lowbar;VOID !&equals; type()`&period;
| xref:BloombergLP/balcl/OptionValue/setNull.adoc[`setNull`] 
| Set the value of this object, irrespective of that value&apos;s type, to its null state&period; The behavior is undefined unless `true &equals;&equals; hasNonVoidType()`&period; Note that `type()` is not changed&period;
| xref:BloombergLP/balcl/OptionValue/setType.adoc[`setType`] 
| Set the type of this object to the specified `type` and the value to the default value of that type&period;
| xref:BloombergLP/balcl/OptionValue/swap.adoc[`swap`] 
| Efficiently exchange the value of this object with the value of the specified `other` object&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if either `type()` is the same as `other&period;type()`, or neither `type()` nor `other&period;type()` is a type that requires allocation&semi; otherwise, it provides the basic guarantee&period; The behavior is undefined unless this object was created with the same allocator as `other`&period;
| xref:BloombergLP/balcl/OptionValue/the-06.adoc[`the`] 
| `the` overloads
| xref:BloombergLP/balcl/OptionValue/type.adoc[`type`] 
| Return the type of this command&hyphen;line&hyphen;option value&period; The type `OptionType&colon;&colon;e&lowbar;VOID` represents the unset state&period;
| xref:BloombergLP/balcl/OptionValue/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;OptionValue, HasPrintMethod&gt;`] 
| Nested trait declaration for `bslma&colon;&colon;UsesBslmaAllocator`&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/balcl/swap.adoc[BloombergLP::balcl::swap]`
| Swap the value of the specified `a` object with the value of the specified `b` object&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if either `a&period;type()` is the same as `b&period;type()` and `a` and `b` were created with the same allocator, or neither `a&period;type()` nor `b&period;type()` is a type that requires allocation&semi; otherwise, it provides the basic guarantee&period;
| `xref:BloombergLP/balcl/operator_eq-0d.adoc[BloombergLP::balcl::operator&equals;&equals;]`
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `OptionValue` objects have the same value if they have the same type, and (if the type is not `e&lowbar;VOID`) the value of that type (as accessed through `the&ast;` methods) is the same&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balcl/operator_not_eq-001.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise&period; Two `OptionValue` objects do not have the same value if their type is not the same, or (if their type is not `e&lowbar;VOID`) the value of that type (as accessed through `the&ast;` methods) is not the same&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
