Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

bdlb::NullableAllocatedValue< TYPE > Class Template Reference

#include <bdlb_nullableallocatedvalue.h>

List of all members.

Public Types

typedef TYPE ValueType

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (NullableAllocatedValue, bslma::UsesBslmaAllocator)
 BSLMF_NESTED_TRAIT_DECLARATION (NullableAllocatedValue, bslmf::IsBitwiseMoveable)
 BSLMF_NESTED_TRAIT_DECLARATION (NullableAllocatedValue, bdlb::HasPrintMethod)
 NullableAllocatedValue (bslma::Allocator *basicAllocator=0)
 NullableAllocatedValue (const NullableAllocatedValue &original, bslma::Allocator *basicAllocator=0)
 NullableAllocatedValue (const TYPE &value, bslma::Allocator *basicAllocator=0)
 ~NullableAllocatedValue ()
NullableAllocatedValue< TYPE > & operator= (const NullableAllocatedValue &rhs)
TYPE & operator= (const TYPE &rhs)
void swap (NullableAllocatedValue &other)
TYPE & makeValue (const TYPE &value)
TYPE & makeValue ()
template<class STREAM >
STREAM & bdexStreamIn (STREAM &stream, int version)
void reset ()
TYPE & value ()
template<class STREAM >
STREAM & bdexStreamOut (STREAM &stream, int version) const
bool isNull () const
int maxSupportedBdexVersion (int versionSelector) const
int maxSupportedBdexVersion () const
bslma::Allocatorallocator () const
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
const TYPE & value () const

Detailed Description

template<class TYPE>
class bdlb::NullableAllocatedValue< TYPE >

This template class extends the set of values of its value-semantic TYPE parameter to include the notion of a "null" value. If TYPE is fully value-semantic, then the augmented type NullableAllocatedValue<TYPE> will be as well. In addition to supporting all homogeneous value-semantic operations, conversions between comparable underlying value types is also supported. Two nullable objects with different underlying types compare equal if their underlying types are comparable and either (1) both objects are null or (2) the non-null values compare equal. Attempts to copy construct, copy assign, or compare incompatible values types will fail to compile. The NullableAllocatedValue template can be instantiated on an incomplete type, but it cannot be instantiated on a type that overloads operator&.

See Component bdlb_nullableallocatedvalue


Member Typedef Documentation

template<class TYPE>
typedef TYPE bdlb::NullableAllocatedValue< TYPE >::ValueType

Constructor & Destructor Documentation

template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::NullableAllocatedValue ( bslma::Allocator basicAllocator = 0  )  [explicit]

Create a nullable object having the null value. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::NullableAllocatedValue ( const NullableAllocatedValue< TYPE > &  original,
bslma::Allocator basicAllocator = 0 
)

Create a nullable 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.

template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::NullableAllocatedValue ( const TYPE &  value,
bslma::Allocator basicAllocator = 0 
)

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

template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::~NullableAllocatedValue (  ) 

Destroy this object.


Member Function Documentation

template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( NullableAllocatedValue< TYPE >  ,
bslma::UsesBslmaAllocator   
)
template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( NullableAllocatedValue< TYPE >  ,
bslmf::IsBitwiseMoveable   
)
template<class TYPE>
bdlb::NullableAllocatedValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( NullableAllocatedValue< TYPE >  ,
bdlb::HasPrintMethod   
)
template<class TYPE>
NullableAllocatedValue<TYPE>& bdlb::NullableAllocatedValue< TYPE >::operator= ( const NullableAllocatedValue< TYPE > &  rhs  ) 

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

template<class TYPE>
TYPE& bdlb::NullableAllocatedValue< TYPE >::operator= ( const TYPE &  rhs  ) 

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

template<class TYPE>
void bdlb::NullableAllocatedValue< TYPE >::swap ( NullableAllocatedValue< TYPE > &  other  ) 

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless this object was created with the same allocator as other.

template<class TYPE>
TYPE& bdlb::NullableAllocatedValue< TYPE >::makeValue ( const TYPE &  value  ) 

Assign to this object the specified value, and return a reference providing modifiable access to the underlying TYPE object.

template<class TYPE>
TYPE& bdlb::NullableAllocatedValue< TYPE >::makeValue (  ) 

Assign to this object the default value for TYPE, and return a reference providing modifiable access to the underlying TYPE object.

template<class TYPE>
template<class STREAM >
STREAM& bdlb::NullableAllocatedValue< TYPE >::bdexStreamIn ( STREAM &  stream,
int  version 
)

Assign to this object the value read from the specified input stream using the specified version format, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, this object is unaltered and stream is invalidated, but otherwise unmodified. If version is supported but stream becomes invalid during this operation, this object has an undefined, but valid, state. Note that no version is read from stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

template<class TYPE>
void bdlb::NullableAllocatedValue< TYPE >::reset (  ) 

Reset this object to the default constructed state (i.e., to have the null value).

template<class TYPE>
TYPE& bdlb::NullableAllocatedValue< TYPE >::value (  ) 

Return a reference providing modifiable access to the underlying TYPE object. The behavior is undefined unless this object is non-null.

template<class TYPE>
template<class STREAM >
STREAM& bdlb::NullableAllocatedValue< TYPE >::bdexStreamOut ( STREAM &  stream,
int  version 
) const

Write the value of this object, using the specified version format, to the specified output stream, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, stream is invalidated, but otherwise unmodified. Note that version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

template<class TYPE>
bool bdlb::NullableAllocatedValue< TYPE >::isNull (  )  const

Return true if this object is null, and false otherwise.

template<class TYPE>
int bdlb::NullableAllocatedValue< TYPE >::maxSupportedBdexVersion ( int  versionSelector  )  const

Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method. Note that it is highly recommended that versionSelector be formatted as "YYYYMMDD", a date representation. Also note that versionSelector should be a compile-time-chosen value that selects a format version supported by both externalizer and unexternalizer. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

template<class TYPE>
int bdlb::NullableAllocatedValue< TYPE >::maxSupportedBdexVersion (  )  const

Return the most current BDEX streaming version number supported by this class. (See the package-group-level documentation for more information on BDEX streaming of container types.)

template<class TYPE>
bslma::Allocator* bdlb::NullableAllocatedValue< TYPE >::allocator (  )  const

Return the allocator used by this object to supply memory.

template<class TYPE>
bsl::ostream& bdlb::NullableAllocatedValue< TYPE >::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 and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

template<class TYPE>
const TYPE& bdlb::NullableAllocatedValue< TYPE >::value (  )  const

Return a reference providing non-modifiable access to the underlying TYPE object. The behavior is undefined unless this object is non-null.


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