Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

bdld::DatumIntMapBuilder Class Reference

#include <bdld_datumintmapbuilder.h>

List of all members.

Public Types

typedef bsls::Types::size_type SizeType
typedef bsl::allocator< char > allocator_type

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (DatumIntMapBuilder, bslma::UsesBslmaAllocator)
 DatumIntMapBuilder ()
 DatumIntMapBuilder (const allocator_type &allocator)
 DatumIntMapBuilder (SizeType initialCapacity, const allocator_type &allocator=allocator_type())
 ~DatumIntMapBuilder ()
void append (const DatumIntMapEntry *entries, SizeType size)
Datum commit ()
void pushBack (int key, const Datum &value)
void setSorted (bool value)
Datum sortAndCommit ()
SizeType capacity () const
allocator_type get_allocator () const
SizeType size () const

Detailed Description

This class provides a mechanism to build a Datum object having an int-map value in an exception-safe manner. See bdld_datum for more information about integer maps.

See Component bdld_datumintmapbuilder


Member Typedef Documentation


Constructor & Destructor Documentation

bdld::DatumIntMapBuilder::DatumIntMapBuilder (  ) 
bdld::DatumIntMapBuilder::DatumIntMapBuilder ( const allocator_type allocator  )  [explicit]
bdld::DatumIntMapBuilder::DatumIntMapBuilder ( SizeType  initialCapacity,
const allocator_type allocator = allocator_type() 
) [explicit]

Create a DatumIntMapBuilder object that will administer the process of building a Datum int-map. Optionally specify an initialCapacity for the int-map. If initialCapacity is not supplied, the initial capacity of the int-map is 0. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used.

bdld::DatumIntMapBuilder::~DatumIntMapBuilder (  ) 

Destroy this object. If this object is holding a datum int-map that has not been adopted, then the datum int-map is disposed after destroying each of its elements.


Member Function Documentation

bdld::DatumIntMapBuilder::BSLMF_NESTED_TRAIT_DECLARATION ( DatumIntMapBuilder  ,
bslma::UsesBslmaAllocator   
)

DatumIntMapBuilder is allocator-aware.

void bdld::DatumIntMapBuilder::append ( const DatumIntMapEntry entries,
SizeType  size 
)

Append the specified array entries having the specified size to the Datum int-map being build by this object. The behavior is undefined unless 0 != entries && 0 != size and each element in entries that needs dynamic memory is allocated with the same allocator that was used to construct this object. The behavior is undefined if commit or sortAndCommit has already been called on this object.

Datum bdld::DatumIntMapBuilder::commit (  ) 

Return a Datum int-map value holding the elements supplied to pushBack or append. The caller is responsible for releasing the resources of the returned Datum object. Calling this method indicates that the caller is finished building the Datum int-map and no further values shall be appended. The behavior is undefined if any method of this object, other than its destructor, is called after commit invocation.

void bdld::DatumIntMapBuilder::pushBack ( int  key,
const Datum value 
)

Append the entry with the specified key and the specified value to the Datum int-map being build by this object. The behavior is undefined if value needs dynamic memory and was allocated using a different allocator than the one used to construct this object. The behavior is also undefined if commit or sortAndCommit has already been called on this object.

void bdld::DatumIntMapBuilder::setSorted ( bool  value  ) 

Mark the Datum int-map being built by this object as sorted if the specified value is true and mark it unsorted otherwise. This function does not sort the int-map entries, or mark them to be sorted later; the function should be used to indicate if the entries are being appended in sorted order. The behavior is undefined if commit or sortAndCommit has already been called on this object. The behavior is also undefined if the int-map being constructed is marked sorted, but the entries are not appended in sorted order. Note also that the int-map being constructed is marked unsorted by default.

Datum bdld::DatumIntMapBuilder::sortAndCommit (  ) 

Return a Datum int-map value holding the elements supplied to pushBack or append sorted by their keys. The caller is responsible for releasing the resources of the returned Datum object. Calling this method indicates that the caller is finished building the Datum int-map and no further values shall be appended. The behavior is undefined if any method of this object, other than its destructor, is called after sortAndCommit invocation.

SizeType bdld::DatumIntMapBuilder::capacity (  )  const

Return the capacity of the held Datum int-map. The behavior is undefined if commit or sortAndCommit has already been called on this object. Note that similar to the capacity of a vector, the returned capacity has no bearing on the value of the Datum being constructed, but does indicate at which point additional memory will be required to grow the Datum int-map being built.

allocator_type bdld::DatumIntMapBuilder::get_allocator (  )  const

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

SizeType bdld::DatumIntMapBuilder::size (  )  const

Return the size of the held Datum int-map. The behavior is undefined if commit or sortAndCommit has already been called on this object.


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