Quick Links: |
#include <balcl_commandline.h>
Public Member Functions | |
int | index (const bsl::string_view &name) const |
const char * | name (bsl::size_t index) const |
bsl::size_t | numOptions () const |
OptionType::Enum | type (bsl::size_t index) const |
OptionType::Enum | type (const bsl::string_view &name) const |
const OptionValue & | value (bsl::size_t index) const |
const OptionValue & | value (const bsl::string_view &name) const |
template<class TYPE > | |
const TYPE & | the (bsl::size_t index) const |
template<class TYPE > | |
const TYPE & | the (const bsl::string_view &name) const |
bool | theBool (const bsl::string_view &name) const |
char | theChar (const bsl::string_view &name) const |
int | theInt (const bsl::string_view &name) const |
bsls::Types::Int64 | theInt64 (const bsl::string_view &name) const |
double | theDouble (const bsl::string_view &name) const |
const bsl::string & | theString (const bsl::string_view &name) const |
const bdlt::Datetime & | theDatetime (const bsl::string_view &name) const |
const bdlt::Date & | theDate (const bsl::string_view &name) const |
const bdlt::Time & | theTime (const bsl::string_view &name) const |
const bsl::vector< char > & | theCharArray (const bsl::string_view &name) const |
const bsl::vector< int > & | theIntArray (const bsl::string_view &name) const |
const bsl::vector < bsls::Types::Int64 > & | theInt64Array (const bsl::string_view &name) const |
const bsl::vector< double > & | theDoubleArray (const bsl::string_view &name) const |
const bsl::vector< bsl::string > & | theStringArray (const bsl::string_view &name) const |
const bsl::vector < bdlt::Datetime > & | theDatetimeArray (const bsl::string_view &name) const |
const bsl::vector< bdlt::Date > & | theDateArray (const bsl::string_view &name) const |
const bsl::vector< bdlt::Time > & | theTimeArray (const bsl::string_view &name) const |
Friends | |
class | CommandLine |
bool | operator== (const CommandLineOptionsHandle &, const CommandLineOptionsHandle &) |
bool | operator!= (const CommandLineOptionsHandle &, const CommandLineOptionsHandle &) |
This class provides access to the parsed options (if any) of its creating CommandLine
object. The behavior is undefined if any of the methods of this class (accessors all) are invoked after a subsequent invocation of the parse
method of the creating object or after the destruction of the creating object.
See Component balcl_commandline
int balcl::CommandLineOptionsHandle::index | ( | const bsl::string_view & | name | ) | const |
Return the position in this handle object of the option having the specified name
, and -1 if the handle has no option of that name. Note that, on success, the return values are in the range [0 .. numOptions() - 1]
.
const char* balcl::CommandLineOptionsHandle::name | ( | bsl::size_t | index | ) | const |
Return the name of the option at the specified index
. The behavior is undefined unless index < numOptions()
.
bsl::size_t balcl::CommandLineOptionsHandle::numOptions | ( | ) | const |
Return the number of parsed options.
OptionType::Enum balcl::CommandLineOptionsHandle::type | ( | bsl::size_t | index | ) | const |
Return the type of the option at the specified index
in this handle object. The behavior is undefined unless index < numOptions()
.
OptionType::Enum balcl::CommandLineOptionsHandle::type | ( | const bsl::string_view & | name | ) | const |
Return the type of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
).
const OptionValue& balcl::CommandLineOptionsHandle::value | ( | bsl::size_t | index | ) | const |
Return a const
reference to the value (possibly in a null state) of the option at the specified index
in this handle object. The behavior is undefined unless index < numOptions()
.
const OptionValue& balcl::CommandLineOptionsHandle::value | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value (possibly in a null state) of this handle object's option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
).
const TYPE& balcl::CommandLineOptionsHandle::the | ( | bsl::size_t | index | ) | const |
Return a const
reference to the value of the option at the specified index
. Template parameter TYPE
must be one of the supported types (see Supported Types). The behavior is undefined unless index < numOptions()
, the option has the (template parameter) TYPE
(i.e., OptionType::TypeToEnum<TYPE>value == type(index)
), and the option has a value (i.e., false == value(index).isNull()
).
const TYPE& balcl::CommandLineOptionsHandle::the | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. Template parameter TYPE
must be one of the supported types (see Supported Types). The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has (template parameter) TYPE
(i.e., OptionType::TypeToEnum<TYPE>value == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
bool balcl::CommandLineOptionsHandle::theBool | ( | const bsl::string_view & | name | ) | const |
Return the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bool
(i.e., OptionType::e_BOOL == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
char balcl::CommandLineOptionsHandle::theChar | ( | const bsl::string_view & | name | ) | const |
Return the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type char
(i.e., OptionType::e_CHAR == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
int balcl::CommandLineOptionsHandle::theInt | ( | const bsl::string_view & | name | ) | const |
Return the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type int
(i.e., OptionType::e_INT == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
bsls::Types::Int64 balcl::CommandLineOptionsHandle::theInt64 | ( | const bsl::string_view & | name | ) | const |
Return the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsls::Types::Int64
(i.e., OptionType::e_INT64 == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
double balcl::CommandLineOptionsHandle::theDouble | ( | const bsl::string_view & | name | ) | const |
Return the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type double
(i.e., OptionType::e_DOUBLE == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::string& balcl::CommandLineOptionsHandle::theString | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::string
(i.e., OptionType::e_STRING == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bdlt::Datetime& balcl::CommandLineOptionsHandle::theDatetime | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bdlt::Datetime
(i.e., OptionType::e_DATETIME == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bdlt::Date& balcl::CommandLineOptionsHandle::theDate | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bdlt::Date
(i.e., OptionType::e_DATE == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bdlt::Time& balcl::CommandLineOptionsHandle::theTime | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bdlt::Time
(i.e., OptionType::e_TIME == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<char>& balcl::CommandLineOptionsHandle::theCharArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<char>
(i.e., OptionType::e_CHAR_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<int>& balcl::CommandLineOptionsHandle::theIntArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<int>
(i.e., OptionType::e_INT_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<bsls::Types::Int64>& balcl::CommandLineOptionsHandle::theInt64Array | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<bsls::Types::Int64>
(i.e., OptionType::e_INT64_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<double>& balcl::CommandLineOptionsHandle::theDoubleArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<double>
(i.e., OptionType::e_DOUBLE_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<bsl::string>& balcl::CommandLineOptionsHandle::theStringArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<bsl::string>
(i.e., OptionType::e_STRING_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<bdlt::Datetime>& balcl::CommandLineOptionsHandle::theDatetimeArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<bdlt::Datetime>
(i.e., OptionType::e_DATETIME_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<bdlt::Date>& balcl::CommandLineOptionsHandle::theDateArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<bdlt::Date>
(i.e., OptionType::e_DATE_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
const bsl::vector<bdlt::Time>& balcl::CommandLineOptionsHandle::theTimeArray | ( | const bsl::string_view & | name | ) | const |
Return a const
reference to the value of the option having the specified name
. The behavior is undefined unless this handle object has a name
option (i.e., 0 <= index(name)
), the option has type bsl::vector<bdlt::TIME>
(i.e., OptionType::e_TIME_ARRAY == type(name)
), and the option has a value (i.e., false == value(name).isNull()
).
friend class CommandLine [friend] |
bool operator== | ( | const CommandLineOptionsHandle & | , | |
const CommandLineOptionsHandle & | ||||
) | [friend] |
Return true
if the specified lhs
and rhs
have the same value, and false
otherwise. Two CommandLineOptionsHandle
objects have the same value if they have the same numOptions
and each of those options have the same name
, type
, and value
or are in the null state.
bool operator!= | ( | const CommandLineOptionsHandle & | , | |
const CommandLineOptionsHandle & | ||||
) | [friend] |
Return true
if the specified lhs
and rhs
do not have the same value, and false
otherwise. Two CommandLineOptionsHandle
objects do not have the same value if they do not have the same numOptions
or if any of their options differ in name
, type
, or 'value (or null state).