Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

balcl::Option Class Reference

#include <balcl_option.h>

List of all members.

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (Option, bslma::UsesBslmaAllocator)
 BSLMF_NESTED_TRAIT_DECLARATION (Option, bdlb::HasPrintMethod)
 Option ()
 Option (bslma::Allocator *basicAllocator)
 Option (const OptionInfo &optionInfo, bslma::Allocator *basicAllocator=0)
 Option (const Option &original, bslma::Allocator *basicAllocator=0)
 ~Option ()
Optionoperator= (const Option &rhs)
Optionoperator= (const OptionInfo &rhs)
 operator const OptionInfo & () const
OptionInfo::ArgType argType () const
const bsl::stringdescription () const
bool isArray () const
const char * longTag () const
const bsl::stringname () const
const OccurrenceInfooccurrenceInfo () const
char shortTag () const
const bsl::stringtagString () const
const TypeInfotypeInfo () const
bool isDescriptionValid (bsl::ostream &stream) const
bool isLongTagValid (const char *longTag, bsl::ostream &stream) const
bool isNameValid (bsl::ostream &stream) const
bool isTagValid (bsl::ostream &stream) const
bslma::Allocatorallocator () const
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const

Detailed Description

This class, constructible from and implicitly convertible to OptionInfo, provides the same attributes, but also uses a bslma::Allocator and thus can be stored in a container. A minor subtlety arises in the name attribute, whereby any suffix starting with an = sign in the name attribute of a OptionInfo is removed in order to derive the name of the Option.

See Component balcl_option


Constructor & Destructor Documentation

balcl::Option::Option (  ) 
balcl::Option::Option ( bslma::Allocator basicAllocator  )  [explicit]

Create a default (empty) command-line option. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

balcl::Option::Option ( const OptionInfo optionInfo,
bslma::Allocator basicAllocator = 0 
) [explicit]

Create a command-line option containing the value of the specified optionInfo. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

balcl::Option::Option ( const Option original,
bslma::Allocator basicAllocator = 0 
)

Create a Option object having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

balcl::Option::~Option (  ) 

Destroy this command-line option object.


Member Function Documentation

balcl::Option::BSLMF_NESTED_TRAIT_DECLARATION ( Option  ,
bslma::UsesBslmaAllocator   
)
balcl::Option::BSLMF_NESTED_TRAIT_DECLARATION ( Option  ,
bdlb::HasPrintMethod   
)
Option& balcl::Option::operator= ( const Option rhs  ) 
Option& balcl::Option::operator= ( const OptionInfo rhs  ) 

Assign to this object the value of the specified rhs object and return a reference providing modifiable access to this object.

balcl::Option::operator const OptionInfo & (  )  const

Return a const reference to the OptionInfo object having the value of this option.

OptionInfo::ArgType balcl::Option::argType (  )  const

Return the ArgType enumerator identifying whether this option is a flag (i.e., a tag not followed by a value), or whether it is an option (i.e., a tag followed by a value), or a non-option argument (i.e., a value not preceded by a short or long tag).

const bsl::string& balcl::Option::description (  )  const

Return the description of this option.

bool balcl::Option::isArray (  )  const

Return true if the value of this option is of array type, and false otherwise.

const char* balcl::Option::longTag (  )  const

Return the string used to identify this option on a command line preceded with --, or 0 if there is no long tag associated with this option. The behavior is undefined if this option is a non-option argument (i.e., has no tag).

const bsl::string& balcl::Option::name (  )  const

Return the name of this option.

const OccurrenceInfo& balcl::Option::occurrenceInfo (  )  const

Return a const reference to the occurrence info for this option (i.e., whether the option is required, optional, or hidden, and its default value, if any).

char balcl::Option::shortTag (  )  const

Return the single character used to identify this option on a command line preceded with a single -, or 0 if this option only has a long tag. The behavior is undefined if this option is a non-option argument (i.e., has no tag).

const bsl::string& balcl::Option::tagString (  )  const

Return the tag string provided to this object at construction. Note that this string is empty if this is a non-option argument.

const TypeInfo& balcl::Option::typeInfo (  )  const

Return a const reference to the type info for this option (i.e., the type of the option, whether the option is linked to a variable, and whether it has a constraint).

bool balcl::Option::isDescriptionValid ( bsl::ostream &  stream  )  const

Return true if the description is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.

bool balcl::Option::isLongTagValid ( const char *  longTag,
bsl::ostream &  stream 
) const

Return true if the specified longTag is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.

bool balcl::Option::isNameValid ( bsl::ostream &  stream  )  const

Return true if the name is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.

bool balcl::Option::isTagValid ( bsl::ostream &  stream  )  const

Return true if the tag is valid for this option, leaving the specified stream unaffected; otherwise, write a diagnostic message to stream and return false.

bslma::Allocator* balcl::Option::allocator (  )  const

Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the currently installed default allocator at construction is used.

bsl::ostream& balcl::Option::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this object. If level is negative, suppress indentation of the first line. If stream is not valid on entry, this operation has no effect. The behavior is undefined if spacesPerLevel is negative.


The documentation for this class was generated from the following file: