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

#include <bdld_datumarraybuilder.h>

Public Types

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

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (DatumArrayBuilder, bslma::UsesBslmaAllocator)
 
 DatumArrayBuilder ()
 
 DatumArrayBuilder (const allocator_type &allocator)
 
 DatumArrayBuilder (SizeType initialCapacity, const allocator_type &allocator=allocator_type())
 
 ~DatumArrayBuilder ()
 
void append (const Datum *values, SizeType length)
 
Datum commit ()
 
void pushBack (const Datum &value)
 
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 array value in an exception-safe manner.

See bdld_datumarraybuilder

Member Typedef Documentation

◆ allocator_type

◆ SizeType

SizeType is an alias for an unsigned integral value, representing the capacity or length of a datum array.

Constructor & Destructor Documentation

◆ DatumArrayBuilder() [1/3]

bdld::DatumArrayBuilder::DatumArrayBuilder ( )

◆ DatumArrayBuilder() [2/3]

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

◆ DatumArrayBuilder() [3/3]

bdld::DatumArrayBuilder::DatumArrayBuilder ( SizeType  initialCapacity,
const allocator_type allocator = allocator_type() 
)
explicit

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

◆ ~DatumArrayBuilder()

bdld::DatumArrayBuilder::~DatumArrayBuilder ( )

Destroy this object. If this object is holding a Datum array that has not been adopted, then the Datum array is disposed after destroying each of its elements.

Member Function Documentation

◆ append()

void bdld::DatumArrayBuilder::append ( const Datum values,
SizeType  length 
)

Append the specified array values having the specified length to the Datum array being built by this object. The behavior is undefined unless 0 != length && 0 != values and each element in values that needs dynamic memory, is allocated with the same allocator that was used to construct this object. The behavior is also undefined if commit has already been called on this object.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ capacity()

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

Return the capacity of the held Datum array. The behavior is undefined if commit 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 array being constructed, but does indicate at which point additional memory will be required to grow the Datum array being built.

◆ commit()

Datum bdld::DatumArrayBuilder::commit ( )

Return a Datum array 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 array and no further values shall be appended. It is undefined behavior to call any method of this object, other than the destructor, after commit has been called.

◆ get_allocator()

DatumArrayBuilder::allocator_type bdld::DatumArrayBuilder::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.

◆ pushBack()

void bdld::DatumArrayBuilder::pushBack ( const Datum value)

Append the specified value to the Datum array being built 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 has already been called on this object.

◆ size()

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

Return the size of the held Datum array. The behavior is undefined if commit has already been called on this object.


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