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

This value&hyphen;semantic `class` parses, validates, and provides access to command&hyphen;line arguments&period;

== Synopsis

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

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

== Description

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balcl/CommandLine/2constructor-03.adoc[`CommandLine`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/balcl/CommandLine/2destructor.adoc[`&#126;CommandLine`] [.small]#[destructor]#
| Destroy this command&hyphen;line object&period;
| xref:BloombergLP/balcl/CommandLine/operator_assign.adoc[`operator&equals;`] 
| Assign to this command&hyphen;line object the value of the specified `rhs`&period;
| xref:BloombergLP/balcl/CommandLine/allocator.adoc[`allocator`] 
| Return the allocator used by this object to supply memory&period;
| xref:BloombergLP/balcl/CommandLine/hasOption.adoc[`hasOption`] 
| Return `true` if this command&hyphen;line object is configured with an option having the specified `name`, and `false` otherwise&period;
| xref:BloombergLP/balcl/CommandLine/hasValue.adoc[`hasValue`] 
| Return `true` if the option having `name` has a defined value&period;
| xref:BloombergLP/balcl/CommandLine/isParsed.adoc[`isParsed`] 
| Return `true` if this object was parsed successfully, and `false` otherwise&period; Note that if `parse` was invoked but failed, this method returns `false`&period;
| xref:BloombergLP/balcl/CommandLine/isSpecified-02.adoc[`isSpecified`] 
| Return `true` if the option with `name` was entered on the command line&period;
| xref:BloombergLP/balcl/CommandLine/isValid.adoc[`isValid`] 
| Return `true` if this object is in a valid state, and `false` otherwise&period;
| xref:BloombergLP/balcl/CommandLine/numSpecified.adoc[`numSpecified`] 
| Return how many times the option with `name` was entered on the command line&period;
| xref:BloombergLP/balcl/CommandLine/options.adoc[`options`] 
| Return the command&hyphen;line options and their values&period;
| xref:BloombergLP/balcl/CommandLine/parse-05.adoc[`parse`] 
| Parse the command&hyphen;line arguments in `argv` of length `argc`&period;
| xref:BloombergLP/balcl/CommandLine/position.adoc[`position`] 
| Return the `argv` index where the option with `name` was first entered&period;
| xref:BloombergLP/balcl/CommandLine/positions.adoc[`positions`] 
| Return the `argv` offsets where the option with `name` was entered&period;
| xref:BloombergLP/balcl/CommandLine/print.adoc[`print`] 
| Format this command&hyphen;line object to the specified output `stream`&period;
| xref:BloombergLP/balcl/CommandLine/printUsage-0b.adoc[`printUsage`] 
| `printUsage` overloads
| xref:BloombergLP/balcl/CommandLine/specifiedOptions.adoc[`specifiedOptions`] 
| Return the options that were entered (or set via environment)&period;
| xref:BloombergLP/balcl/CommandLine/theBool.adoc[`theBool`] 
| Return the value of the option having the specified `name`&period;
| xref:BloombergLP/balcl/CommandLine/theChar.adoc[`theChar`] 
| Return the value of the option having the specified `name`&period;
| xref:BloombergLP/balcl/CommandLine/theCharArray.adoc[`theCharArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theDate.adoc[`theDate`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theDateArray.adoc[`theDateArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theDatetime.adoc[`theDatetime`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theDatetimeArray.adoc[`theDatetimeArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theDouble.adoc[`theDouble`] 
| Return the value of the option having the specified `name`&period;
| xref:BloombergLP/balcl/CommandLine/theDoubleArray.adoc[`theDoubleArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theInt.adoc[`theInt`] 
| Return the value of the option having the specified `name`&period;
| xref:BloombergLP/balcl/CommandLine/theInt64.adoc[`theInt64`] 
| Return the value of the option having the specified `name`&period;
| xref:BloombergLP/balcl/CommandLine/theInt64Array.adoc[`theInt64Array`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theIntArray.adoc[`theIntArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theString.adoc[`theString`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theStringArray.adoc[`theStringArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theTime.adoc[`theTime`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/theTimeArray.adoc[`theTimeArray`] 
| Return a `const` reference to the value of the option having `name`&period;
| xref:BloombergLP/balcl/CommandLine/type.adoc[`type`] 
| Return the type of the option having the specified `name`&period;
| xref:BloombergLP/balcl/CommandLine/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;CommandLine, HasPrintMethod&gt;`] 
| Nested trait declaration for `bslma&colon;&colon;UsesBslmaAllocator`&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balcl/CommandLine/isValidOptionSpecificationTable-09.adoc[`isValidOptionSpecificationTable`] 
| `isValidOptionSpecificationTable` overloads
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balcl/operator_not_eq-05.adoc[`operator!&equals;`]
| Return `false` if the specified `lhs` and `rhs` have the same value&period;
| xref:BloombergLP/balcl/operator_eq-01.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` have the same value&period;
|===


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