[#BloombergLP-balcl-CommandLine] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balcl.adoc[balcl]::CommandLine :relfileprefix: ../../ :mrdocs: This value‐semantic `class` parses, validates, and provides access to command‐line arguments. == Synopsis Declared in `<balcl_commandline.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CommandLine; ---- == Description 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). == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/balcl/CommandLine/2constructor-03.adoc[`CommandLine`] [.small]#[constructor]# | Constructors | xref:BloombergLP/balcl/CommandLine/2destructor.adoc[`~CommandLine`] [.small]#[destructor]# | Destroy this command‐line object. | xref:BloombergLP/balcl/CommandLine/operator_assign.adoc[`operator=`] | Assign to this command‐line object the value of the specified `rhs`. | xref:BloombergLP/balcl/CommandLine/allocator.adoc[`allocator`] | Return the allocator used by this object to supply memory. | xref:BloombergLP/balcl/CommandLine/hasOption.adoc[`hasOption`] | Return `true` if this command‐line object is configured with an option having the specified `name`, and `false` otherwise. | xref:BloombergLP/balcl/CommandLine/hasValue.adoc[`hasValue`] | Return `true` if the option having `name` has a defined value. | xref:BloombergLP/balcl/CommandLine/isParsed.adoc[`isParsed`] | Return `true` if this object was parsed successfully, and `false` otherwise. Note that if `parse` was invoked but failed, this method returns `false`. | xref:BloombergLP/balcl/CommandLine/isSpecified-02.adoc[`isSpecified`] | Return `true` if the option with `name` was entered on the command line. | xref:BloombergLP/balcl/CommandLine/isValid.adoc[`isValid`] | Return `true` if this object is in a valid state, and `false` otherwise. | xref:BloombergLP/balcl/CommandLine/numSpecified.adoc[`numSpecified`] | Return how many times the option with `name` was entered on the command line. | xref:BloombergLP/balcl/CommandLine/options.adoc[`options`] | Return the command‐line options and their values. | xref:BloombergLP/balcl/CommandLine/parse-05.adoc[`parse`] | Parse the command‐line arguments in `argv` of length `argc`. | xref:BloombergLP/balcl/CommandLine/position.adoc[`position`] | Return the `argv` index where the option with `name` was first entered. | xref:BloombergLP/balcl/CommandLine/positions.adoc[`positions`] | Return the `argv` offsets where the option with `name` was entered. | xref:BloombergLP/balcl/CommandLine/print.adoc[`print`] | Format this command‐line object to the specified output `stream`. | 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). | xref:BloombergLP/balcl/CommandLine/theBool.adoc[`theBool`] | Return the value of the option having the specified `name`. | xref:BloombergLP/balcl/CommandLine/theChar.adoc[`theChar`] | Return the value of the option having the specified `name`. | xref:BloombergLP/balcl/CommandLine/theCharArray.adoc[`theCharArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theDate.adoc[`theDate`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theDateArray.adoc[`theDateArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theDatetime.adoc[`theDatetime`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theDatetimeArray.adoc[`theDatetimeArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theDouble.adoc[`theDouble`] | Return the value of the option having the specified `name`. | xref:BloombergLP/balcl/CommandLine/theDoubleArray.adoc[`theDoubleArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theInt.adoc[`theInt`] | Return the value of the option having the specified `name`. | xref:BloombergLP/balcl/CommandLine/theInt64.adoc[`theInt64`] | Return the value of the option having the specified `name`. | xref:BloombergLP/balcl/CommandLine/theInt64Array.adoc[`theInt64Array`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theIntArray.adoc[`theIntArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theString.adoc[`theString`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theStringArray.adoc[`theStringArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theTime.adoc[`theTime`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/theTimeArray.adoc[`theTimeArray`] | Return a `const` reference to the value of the option having `name`. | xref:BloombergLP/balcl/CommandLine/type.adoc[`type`] | Return the type of the option having the specified `name`. | xref:BloombergLP/balcl/CommandLine/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<CommandLine, HasPrintMethod>`] | Nested trait declaration for `bslma::UsesBslmaAllocator`. |=== == 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!=`] | Return `false` if the specified `lhs` and `rhs` have the same value. | xref:BloombergLP/balcl/operator_eq-01.adoc[`operator==`] | Return `true` if the specified `lhs` and `rhs` have the same value. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#