BDE 4.14.0 Production release
|
#include <balcl_typeinfo.h>
Public Types | |
enum | ParseInputSource { e_COMMAND_LINE , e_ENVIRONMENT_VARIABLE } |
Public Attributes | |
OptionType::Enum | d_elemType |
void * | d_linkedVariable_p |
bool | d_isOptionalLinkedVariable |
bsl::shared_ptr< TypeInfoConstraint > | d_constraint_p |
bslma::Allocator * | d_allocator_p |
This class
is a attribute class that describes the type, the variable to be linked, and the constraint on an option. Note that the constraint type is opaque, but it is possible to apply the constraint to an element of the same type as the option and see whether it is valid (using the satisfiesConstraint
methods of TypeInfoUtil
).
See balcl_typeinfo
This enumeration differentiates the source of input when parsing an option type. Note that boolean options, in particular, are treated differently when supplied on the command line from how they are treated when supplied by an environment variable (see balcl_commandline ).
Enumerator | |
---|---|
e_COMMAND_LINE | |
e_ENVIRONMENT_VARIABLE |
|
inline |
Construct an object having string
type for the associated option that uses the currently installed default allocator to supply memory. No variable is linked and no constraint is put on the value.
|
explicit |
Construct an object having string
type for the associated option, and the specified basicAllocator
to supply memory. No variable is linked and no constraint is put on the value. Note that, atypically, 0 is disallowed for basicAllocator
.
|
explicit |
Construct a flag accepting bool
as the type for the associated option (i.e., for the linked variable). If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. No constraint can be put on the option.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | char * | variable, |
const Constraint::CharConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having char
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | int * | variable, |
const Constraint::IntConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having int
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsls::Types::Int64 * | variable, |
const Constraint::Int64Constraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsls::Types::Int64
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | double * | variable, |
const Constraint::DoubleConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having double
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::string * | variable, |
const Constraint::StringConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::string
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bdlt::Datetime * | variable, |
const Constraint::DatetimeConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bdlt::Datetime
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bdlt::Date * | variable, |
const Constraint::DateConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bdlt::Date
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bdlt::Time * | variable, |
const Constraint::TimeConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bdlt::Time
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< char > * | variable, |
const Constraint::CharConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<char>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< int > * | variable, |
const Constraint::IntConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<int>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< bsls::Types::Int64 > * | variable, |
const Constraint::Int64Constraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<bsls::Types::Int64>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< double > * | variable, |
const Constraint::DoubleConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<double>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< bsl::string > * | variable, |
const Constraint::StringConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<bsl::string>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< bdlt::Datetime > * | variable, |
const Constraint::DatetimeConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<bdlt::Datetime>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< bdlt::Date > * | variable, |
const Constraint::DateConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<bdlt::Date>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::vector< bdlt::Time > * | variable, |
const Constraint::TimeConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::vector<bdlt::Time>
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< char > * | variable, |
const Constraint::CharConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having char
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< int > * | variable, |
const Constraint::IntConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having int
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< bsls::Types::Int64 > * | variable, |
const Constraint::Int64Constraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsls::Types::Int64
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< double > * | variable, |
const Constraint::DoubleConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having double
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< bsl::string > * | variable, |
const Constraint::StringConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bsl::string
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< bdlt::Datetime > * | variable, |
const Constraint::DatetimeConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bdlt::Datetime
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< bdlt::Date > * | variable, |
const Constraint::DateConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bdlt::Date
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
|
explicit |
balcl::TypeInfo::TypeInfo | ( | bsl::optional< bdlt::Time > * | variable, |
const Constraint::TimeConstraint & | constraint, | ||
bslma::Allocator * | basicAllocator = 0 |
||
) |
Construct an object having bdlt::Time
type for the associated option. If the specified variable
is not 0, then link it with the option. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Optionally specify a constraint
to put on the option. If constraint
is not specified, the option has no constraint.
balcl::TypeInfo::TypeInfo | ( | const TypeInfo & | original, |
bslma::Allocator * | basicAllocator = 0 |
||
) |
Create an object having the value of the specified original
object. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Note that this object shares the same constraint as the original
object.
balcl::TypeInfo::~TypeInfo | ( | ) |
bslma::Allocator * balcl::TypeInfo::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.
balcl::TypeInfo::BSLMF_NESTED_TRAIT_DECLARATION | ( | TypeInfo | , |
bdlb::HasPrintMethod | |||
) |
balcl::TypeInfo::BSLMF_NESTED_TRAIT_DECLARATION | ( | TypeInfo | , |
bslma::UsesBslmaAllocator | |||
) |
bsl::shared_ptr< TypeInfoConstraint > balcl::TypeInfo::constraint | ( | ) | const |
Return a shared pointer to the (opaque) object storing the constraint associated with the described option. If this object has no constraint an empty shared pointer is returned. The lifetime of any shared reference to this object's constraint must not exceed that of this object's allocator.
bool balcl::TypeInfo::isOptionalLinkedVariable | ( | ) | const |
Return true
if the described option has a linked variable and that variable is a bsl::optional
object, and false
otherwise.
void * balcl::TypeInfo::linkedVariable | ( | ) | const |
Return the address of the modifiable variable linked to the described option, or 0 if no variable is linked.
Assign to this object the value of the specified rhs
object and return a reference providing modifiable access to this object.
bsl::ostream & balcl::TypeInfo::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. Note that the precondition on spacesPerLevel
is atypical for the print
aspect; a negative spacesPerLevel
typically indicates that the entire output should be formatted on one line.
void balcl::TypeInfo::resetConstraint | ( | ) |
Reset this object so that it no longer has a constraint. This method has no effect if the object has no constraint. Note that neither the type attribute nor the linked variable, if any, are changed.
void balcl::TypeInfo::resetLinkedVariableAndConstraint | ( | ) |
Reset this object so that it has neither a linked variable nor a constraint. This method has no effect if the object has no linked variable or constraint. Note that the type attribute is not changed.
void balcl::TypeInfo::setConstraint | ( | const bsl::shared_ptr< TypeInfoConstraint > & | constraint | ) |
Set the constraint of the described option to the specified constraint
. The behavior is undefined unless the option associated with constraint
has the same type as the option associated with this object. Note that the linked variable, if any, is unchanged by this method.
void balcl::TypeInfo::setConstraint | ( | const Constraint::CharConstraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::DateConstraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::DatetimeConstraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::DoubleConstraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::Int64Constraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::IntConstraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::StringConstraint & | constraint | ) |
void balcl::TypeInfo::setConstraint | ( | const Constraint::TimeConstraint & | constraint | ) |
Put the specified constraint
on the value of the described option, replacing any constraint that had been in effect (if any). The behavior is undefined unless the described option is not a flag and the balcl::OptionValue
type of the described option corresponds to the type of constraint
. Note that two distinct objects that have the same constraint
put on them will compare unequal unless the constraint is shared among them, which can be done by:
void balcl::TypeInfo::setLinkedVariable | ( | bdlt::Date * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bdlt::Datetime * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bdlt::Time * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bool * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< bdlt::Date > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< bdlt::Datetime > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< bdlt::Time > * | variable | ) |
Set this object to have the type indicated by the specified variable
, and reset this object so that it no longer has a constraint associated with it. If variable
is not 0, then link it with the described option. If variable
is of type bsl::optional<Type>
, then the type of this object is set to Type
.
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< bsl::string > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< bsls::Types::Int64 > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< char > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< double > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::optional< int > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::string * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< bdlt::Date > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< bdlt::Datetime > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< bdlt::Time > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< bsl::string > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< bsls::Types::Int64 > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< char > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< double > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsl::vector< int > * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | bsls::Types::Int64 * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | char * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | double * | variable | ) |
void balcl::TypeInfo::setLinkedVariable | ( | int * | variable | ) |
OptionType::Enum balcl::TypeInfo::type | ( | ) | const |
Return the type of the described option. Note that the option is a flag if it is of type OptionType::e_BOOL
.
bslma::Allocator* balcl::TypeInfo::d_allocator_p |
bsl::shared_ptr<TypeInfoConstraint> balcl::TypeInfo::d_constraint_p |
OptionType::Enum balcl::TypeInfo::d_elemType |
bool balcl::TypeInfo::d_isOptionalLinkedVariable |
void* balcl::TypeInfo::d_linkedVariable_p |