BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdld::DatumMapOwningKeysBuilder Class Reference

#include <bdld_datummapowningkeysbuilder.h>

Public Types

typedef Datum::SizeType SizeType
 
typedef bsl::allocator< char > allocator_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (DatumMapOwningKeysBuilder, bslma::UsesBslmaAllocator)
 DatumMapOwningKeysBuilder is allocator-aware.
 
 DatumMapOwningKeysBuilder (const allocator_type &allocator)
 
 DatumMapOwningKeysBuilder (SizeType initialCapacity, SizeType initialKeysCapacity, const allocator_type &allocator)
 
 ~DatumMapOwningKeysBuilder ()
 
void append (const DatumMapEntry *entries, SizeType size)
 
Datum commit ()
 
void pushBack (const bslstl::StringRef &key, const Datum &value)
 
void setSorted (bool value)
 
Datum sortAndCommit ()
 
SizeType capacity () const
 
SizeType keysCapacity () const
 
SizeType size () const
 
bslma::Allocatorallocator () const
 
allocator_type get_allocator () const
 

Detailed Description

This class provides a mechanism to build a Datum object having a map (owning keys) value in an exception-safe manner.

See bdld_datummapowningkeysbuilder

Member Typedef Documentation

◆ allocator_type

◆ SizeType

SizeType is an alias for a signed value, representing the capacity, keys-capacity, size or keys-size of a datum-key-owning map.

Constructor & Destructor Documentation

◆ DatumMapOwningKeysBuilder() [1/2]

bdld::DatumMapOwningKeysBuilder::DatumMapOwningKeysBuilder ( const allocator_type allocator)
explicit

Create a DatumMapOwningKeysBuilder object that will administer the process of building a Datum map (owning keys) using the specified allocator (e.g., the address of a bslma::Allocator object) to supply memory. Note that no memory is allocated until append or pushBack methods are called on this object.

◆ DatumMapOwningKeysBuilder() [2/2]

bdld::DatumMapOwningKeysBuilder::DatumMapOwningKeysBuilder ( SizeType  initialCapacity,
SizeType  initialKeysCapacity,
const allocator_type allocator 
)

Create a DatumMapBuilder object managing the ownership of Datum map (owning keys) having the specified initialCapacity and initialKeysCapacity (in bytes) using the specified allocator (e.g., the address of a bslma::Allocator object) to supply memory.

◆ ~DatumMapOwningKeysBuilder()

bdld::DatumMapOwningKeysBuilder::~DatumMapOwningKeysBuilder ( )

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

Member Function Documentation

◆ allocator()

bslma::Allocator * bdld::DatumMapOwningKeysBuilder::allocator ( ) const
inline
Deprecated:
Use get_allocator() instead.

Return get_allocator().mechanism().

◆ append()

void bdld::DatumMapOwningKeysBuilder::append ( const DatumMapEntry entries,
SizeType  size 
)

Append the specified array entries having the specified size to the Datum map (owning keys) being build by this object. The behavior is undefined unless and 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.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ capacity()

DatumMapOwningKeysBuilder::SizeType bdld::DatumMapOwningKeysBuilder::capacity ( ) const
inline

Return the capacity of the held Datum map (owning keys). 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 map being built.

◆ commit()

Datum bdld::DatumMapOwningKeysBuilder::commit ( )

Return a Datum map (owning keys) 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 map (owning keys) 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.

◆ get_allocator()

DatumMapOwningKeysBuilder::allocator_type bdld::DatumMapOwningKeysBuilder::get_allocator ( ) const
inline

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.

◆ keysCapacity()

DatumMapOwningKeysBuilder::SizeType bdld::DatumMapOwningKeysBuilder::keysCapacity ( ) const
inline

Return the keys-capacity of the held Datum map (owning keys). 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 map being built.

◆ pushBack()

void bdld::DatumMapOwningKeysBuilder::pushBack ( const bslstl::StringRef key,
const Datum value 
)

Append the entry with the specified key and the specified value to the Datum 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.

◆ setSorted()

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

Mark the Datum map (owning keys) being built by this object as sorted if the specified value is true and mark it unsorted otherwise. This function does not sort the 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 map being constructed is marked sorted, but the entries are not appended in sorted order. Note also that the map being constructed is marked unsorted by default.

◆ size()

DatumMapOwningKeysBuilder::SizeType bdld::DatumMapOwningKeysBuilder::size ( ) const
inline

Return the size of the held Datum map (owning keys). The behavior is undefined if commit or sortAndCommit has already been called on this object.

◆ sortAndCommit()

Datum bdld::DatumMapOwningKeysBuilder::sortAndCommit ( )

Return a Datum map (owning keys) 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 map (owning keys) 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.


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