8#ifndef INCLUDED_BALCL_COMMANDLINE
9#define INCLUDED_BALCL_COMMANDLINE
1333#include <balscm_version.h>
1350#include <bsl_cstddef.h>
1351#include <bsl_cstring.h>
1352#include <bsl_iosfwd.h>
1353#include <bsl_sstream.h>
1354#include <bsl_string.h>
1355#include <bsl_string_view.h>
1356#include <bsl_vector.h>
1486 mutable bool d_isBindin2Valid;
1492 bool d_envVarsPresent;
1507 void initArgs(
int argc,
const char *
const argv[]);
1514 int parseImp(bsl::ostream& errorStream);
1525 int postParseImp(bsl::ostream& errorStream);
1527 void validateAndInitialize();
1541 void validateAndInitialize(bsl::ostream& errorStream);
1559 int findTag(
char shortTag)
const;
1566 void location(bsl::ostream& errorStream,
1569 int end = -1)
const;
1573 int longestNonFlagNameSize()
const;
1577 int longestTagSize()
const;
1584 int missing(
bool checkAlsoNonOptions =
true)
const;
1600 template <
int LENGTH>
1603 template <
int LENGTH>
1606 template <
int LENGTH>
1609 bsl::ostream& errorStream);
1610 template <
int LENGTH>
1613 bsl::ostream& errorStream);
1627 bsl::ostream& errorStream);
1638 template <
int LENGTH>
1640 bsl::ostream& errorStream,
1642 template <
int LENGTH>
1644 bsl::ostream& errorStream,
1654 template <
int LENGTH>
1658 template <
int LENGTH>
1685 bsl::ostream& errorStream,
1711 int parse(
int argc,
const char *
const argv[]);
1732 int parse(
int argc,
const char *
const argv[], bsl::ostream& errorStream);
1961 bsl::ostream&
print(bsl::ostream& stream,
1963 int spacesPerLevel = 4)
const;
2039 const char *
name(bsl::size_t
index)
const;
2076 template <
class TYPE>
2077 const TYPE&
the(bsl::size_t
index)
const;
2086 template <
class TYPE>
2256 const CommandLine_SchemaData& rhs)
2258 return lhs.d_type == rhs.d_type
2259 && 0 == bsl::strcmp(lhs.d_name_p, rhs.d_name_p);
2264 const CommandLine_SchemaData& rhs)
2266 return lhs.d_type != rhs.d_type
2267 || 0 != bsl::strcmp(lhs.d_name_p, rhs.d_name_p);
2277template <
int LENGTH>
2285template <
int LENGTH>
2293template <
int LENGTH>
2297 bsl::ostream& errorStream)
2302template <
int LENGTH>
2306 bsl::ostream& errorStream)
2323template <
int LENGTH>
2325 bsl::ostream& errorStream,
2327: d_options(basicAllocator)
2328, d_positions(basicAllocator)
2329, d_nonOptionIndices(basicAllocator)
2331, d_arguments(basicAllocator)
2332, d_schema(basicAllocator)
2333, d_data(basicAllocator)
2334, d_dataFinal(basicAllocator)
2335, d_specifiedOptions(basicAllocator)
2336, d_isBindin2Valid(false)
2337, d_envVarsPresent(false)
2340 for (
int ii = 0; ii < LENGTH; ++ii) {
2343 validateAndInitialize(errorStream);
2344 d_state = e_NOT_PARSED;
2347template <
int LENGTH>
2349 bsl::ostream& errorStream,
2351: d_options(basicAllocator)
2352, d_positions(basicAllocator)
2353, d_nonOptionIndices(basicAllocator)
2355, d_arguments(basicAllocator)
2356, d_schema(basicAllocator)
2357, d_data(basicAllocator)
2358, d_dataFinal(basicAllocator)
2359, d_specifiedOptions(basicAllocator)
2360, d_isBindin2Valid(false)
2361, d_envVarsPresent(false)
2364 for (
int i = 0; i < LENGTH; ++i) {
2367 validateAndInitialize(errorStream);
2368 d_state = e_NOT_PARSED;
2371template <
int LENGTH>
2374: d_options(basicAllocator)
2375, d_positions(basicAllocator)
2376, d_nonOptionIndices(basicAllocator)
2378, d_arguments(basicAllocator)
2379, d_schema(basicAllocator)
2380, d_data(basicAllocator)
2381, d_dataFinal(basicAllocator)
2382, d_specifiedOptions(basicAllocator)
2383, d_isBindin2Valid(false)
2384, d_envVarsPresent(false)
2387 for (
int ii = 0; ii < LENGTH; ++ii) {
2390 validateAndInitialize();
2391 d_state = e_NOT_PARSED;
2394template <
int LENGTH>
2397: d_options(basicAllocator)
2398, d_positions(basicAllocator)
2399, d_nonOptionIndices(basicAllocator)
2401, d_arguments(basicAllocator)
2402, d_schema(basicAllocator)
2403, d_data(basicAllocator)
2404, d_dataFinal(basicAllocator)
2405, d_specifiedOptions(basicAllocator)
2406, d_isBindin2Valid(false)
2407, d_envVarsPresent(false)
2410 for (
int ii = 0; ii < LENGTH; ++ii) {
2413 validateAndInitialize();
2414 d_state = e_NOT_PARSED;
2423CommandLineOptionsHandle::CommandLineOptionsHandle(
2424 const OptionValueList *dataPtr,
2425 const CommandLine_Schema *schemaPtr)
2427, d_schema_p(schemaPtr)
2431 BSLS_ASSERT(dataPtr->size() == schemaPtr->size());
2440 return (*d_schema_p)[
index].d_name_p;
2446 return d_schema_p->
size();
2454 return (*d_schema_p)[
index].d_type;
2466 return (*d_schema_p)[
index].d_type;
2474 return (*d_data_p)[
index];
2486 return (*d_data_p)[
index];
2493template <
class TYPE>
2502template <
class TYPE>
2743 return *lhs.d_data_p == *rhs.d_data_p
2744 && *lhs.d_schema_p == *rhs.d_schema_p;
2754 return *lhs.d_data_p != *rhs.d_data_p
2755 || *lhs.d_schema_p != *rhs.d_schema_p;
Definition balcl_commandline.h:2003
const TYPE & the(bsl::size_t index) const
Definition balcl_commandline.h:2494
const bdlt::Time & theTime(const bsl::string_view &name) const
Definition balcl_commandline.h:2615
const bsl::string & theString(const bsl::string_view &name) const
Definition balcl_commandline.h:2577
char theChar(const bsl::string_view &name) const
Definition balcl_commandline.h:2527
const bsl::vector< bdlt::Time > & theTimeArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2720
bsls::Types::Int64 theInt64(const bsl::string_view &name) const
Definition balcl_commandline.h:2551
OptionType::Enum type(bsl::size_t index) const
Definition balcl_commandline.h:2450
const bsl::vector< bdlt::Datetime > & theDatetimeArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2694
const bdlt::Date & theDate(const bsl::string_view &name) const
Definition balcl_commandline.h:2603
bsl::size_t numOptions() const
Return the number of parsed options.
Definition balcl_commandline.h:2444
const bsl::vector< char > & theCharArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2629
bool theBool(const bsl::string_view &name) const
Definition balcl_commandline.h:2515
friend bool operator!=(const CommandLineOptionsHandle &, const CommandLineOptionsHandle &)
const OptionValue & value(bsl::size_t index) const
Definition balcl_commandline.h:2470
double theDouble(const bsl::string_view &name) const
Definition balcl_commandline.h:2564
const bsl::vector< bdlt::Date > & theDateArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2707
int index(const bsl::string_view &name) const
const bsl::vector< double > & theDoubleArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2668
const bsl::vector< int > & theIntArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2642
const char * name(bsl::size_t index) const
Definition balcl_commandline.h:2436
int theInt(const bsl::string_view &name) const
Definition balcl_commandline.h:2539
const bdlt::Datetime & theDatetime(const bsl::string_view &name) const
Definition balcl_commandline.h:2590
const bsl::vector< bsl::string > & theStringArray(const bsl::string_view &name) const
Definition balcl_commandline.h:2681
friend bool operator==(const CommandLineOptionsHandle &, const CommandLineOptionsHandle &)
const bsl::vector< bsls::Types::Int64 > & theInt64Array(const bsl::string_view &name) const
Definition balcl_commandline.h:2655
Definition balcl_commandline.h:1421
CommandLine(const OptionInfo(&specTable)[LENGTH], bsl::ostream &errorStream, bslma::Allocator *basicAllocator=0)
Definition balcl_commandline.h:2324
bool hasOption(const bsl::string_view &name) const
OptionType::Enum type(const bsl::string_view &name) const
int theInt(const bsl::string_view &name) const
const bdlt::Date & theDate(const bsl::string_view &name) const
BSLMF_NESTED_TRAIT_DECLARATION(CommandLine, bdlb::HasPrintMethod)
bool hasValue(const bsl::string_view &name) const
CommandLine(const OptionInfo *specTable, int length, bsl::ostream &errorStream, bslma::Allocator *basicAllocator=0)
static bool isValidOptionSpecificationTable(const OptionInfo *specTable, int length, bsl::ostream &errorStream)
bslma::Allocator * allocator() const
const bsl::vector< bdlt::Date > & theDateArray(const bsl::string_view &name) const
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
const bdlt::Time & theTime(const bsl::string_view &name) const
const bdlt::Datetime & theDatetime(const bsl::string_view &name) const
double theDouble(const bsl::string_view &name) const
~CommandLine()
Destroy this command-line object.
const bsl::vector< int > & positions(const bsl::string_view &name) const
CommandLineOptionsHandle specifiedOptions() const
const bsl::vector< bdlt::Time > & theTimeArray(const bsl::string_view &name) const
CommandLineOptionsHandle options() const
const bsl::vector< bdlt::Datetime > & theDatetimeArray(const bsl::string_view &name) const
BSLMF_NESTED_TRAIT_DECLARATION(CommandLine, bslma::UsesBslmaAllocator)
const bsl::vector< char > & theCharArray(const bsl::string_view &name) const
int numSpecified(const bsl::string_view &name) const
int parse(int argc, const char *const argv[], bsl::ostream &errorStream)
CommandLine & operator=(const CommandLine &rhs)
const bsl::vector< bsl::string > & theStringArray(const bsl::string_view &name) const
bool isSpecified(const bsl::string_view &name, int *count) const
static bool isValidOptionSpecificationTable(const OptionInfo(&specTable)[LENGTH])
Definition balcl_commandline.h:2279
void printUsage(const bsl::string_view &programName) const
bool theBool(const bsl::string_view &name) const
char theChar(const bsl::string_view &name) const
void printUsage(bsl::ostream &errorStream) const
bool isSpecified(const bsl::string_view &name) const
CommandLine(const OptionInfo *specTable, int length, bslma::Allocator *basicAllocator=0)
int position(const bsl::string_view &name) const
bsls::Types::Int64 theInt64(const bsl::string_view &name) const
const bsl::vector< double > & theDoubleArray(const bsl::string_view &name) const
CommandLine(const CommandLine &original, bslma::Allocator *basicAllocator=0)
const bsl::vector< bsls::Types::Int64 > & theInt64Array(const bsl::string_view &name) const
void printUsage(bsl::ostream &errorStream, const bsl::string_view &programName) const
const bsl::string & theString(const bsl::string_view &name) const
const bsl::vector< int > & theIntArray(const bsl::string_view &name) const
int parse(int argc, const char *const argv[])
Definition balcl_optionvalue.h:393
Definition balcl_option.h:132
Definition bdlt_date.h:294
Definition bdlt_datetime.h:331
Definition bdlt_time.h:196
Definition bslstl_ostringstream.h:175
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this vector.
Definition bslstl_vector.h:2664
Definition bslstl_vector.h:1025
void reserve(size_type newCapacity)
Definition bslstl_vector.h:3690
void push_back(const VALUE_TYPE &value)
Definition bslstl_vector.h:3760
Definition bslma_allocator.h:457
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balcl_commandline.h:1364
bool operator==(const CommandLine_SchemaData &lhs, const CommandLine_SchemaData &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const CommandLine &rhs)
bool operator!=(const CommandLine_SchemaData &lhs, const CommandLine_SchemaData &rhs)
Definition balcl_commandline.h:1373
const char * d_name_p
Definition balcl_commandline.h:1377
OptionType::Enum d_type
Definition balcl_commandline.h:1376
Definition balcl_optioninfo.h:132
Definition balcl_optiontype.h:282
Enum
Definition balcl_optiontype.h:248
@ e_DOUBLE
Definition balcl_optiontype.h:255
@ e_CHAR_ARRAY
Definition balcl_optiontype.h:260
@ e_STRING
Definition balcl_optiontype.h:256
@ e_INT
Definition balcl_optiontype.h:253
@ e_INT64
Definition balcl_optiontype.h:254
@ e_CHAR
Definition balcl_optiontype.h:252
@ e_DATE_ARRAY
Definition balcl_optiontype.h:266
@ e_DATE
Definition balcl_optiontype.h:258
@ e_BOOL
Definition balcl_optiontype.h:251
@ e_INT64_ARRAY
Definition balcl_optiontype.h:262
@ e_INT_ARRAY
Definition balcl_optiontype.h:261
@ e_STRING_ARRAY
Definition balcl_optiontype.h:264
@ e_TIME
Definition balcl_optiontype.h:259
@ e_DATETIME
Definition balcl_optiontype.h:257
@ e_TIME_ARRAY
Definition balcl_optiontype.h:267
@ e_DATETIME_ARRAY
Definition balcl_optiontype.h:265
@ e_DOUBLE_ARRAY
Definition balcl_optiontype.h:263
Definition bdlb_printmethods.h:306
Definition bslma_usesbslmaallocator.h:343
long long Int64
Definition bsls_types.h:132