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

#include <bdld_manageddatum.h>

Public Types

typedef bsl::allocator allocator_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (ManagedDatum, bslmf::IsBitwiseMoveable)
 'ManagedDatum' objects are allocator-aware and bitwise movable.
 
 ManagedDatum ()
 
 ManagedDatum (const allocator_type &allocator)
 
 ManagedDatum (const Datum &datum, const allocator_type &allocator=allocator_type())
 
 ManagedDatum (const ManagedDatum &original, const allocator_type &allocator=allocator_type())
 
 ~ManagedDatum ()
 
ManagedDatumoperator= (const ManagedDatum &rhs)
 
void adopt (const Datum &obj)
 
void clone (const Datum &value)
 
void makeNull ()
 
Datum release ()
 
void swap (ManagedDatum &other)
 
const Datumoperator-> () const
 
const Datumoperator* () const
 
const Datumdatum () const
 
bslma::Allocatorallocator () const
 
allocator_type get_allocator () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Detailed Description

This class implements a smart-pointer-like resource manager for a Datum object.

See bdld_manageddatum

Member Typedef Documentation

◆ allocator_type

Constructor & Destructor Documentation

◆ ManagedDatum() [1/4]

bdld::ManagedDatum::ManagedDatum ( )
inline

◆ ManagedDatum() [2/4]

bdld::ManagedDatum::ManagedDatum ( const allocator_type allocator)
inlineexplicit

Create a ManagedDatum object having the default (null) value, and the specified allocator (e.g., the address of a bslma::Allocator object) to supply memory. Calling isNull on the resulting managed Datum object returns true.

◆ ManagedDatum() [3/4]

bdld::ManagedDatum::ManagedDatum ( const Datum datum,
const allocator_type allocator = allocator_type() 
)
inlineexplicit

Create a ManagedDatum object that assumes ownership of the specified datum. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. The behavior is undefined unless datum was allocated using the indicated allocator and is not subsequently destroyed externally using Datum::destroy.

◆ ManagedDatum() [4/4]

bdld::ManagedDatum::ManagedDatum ( const ManagedDatum original,
const allocator_type allocator = allocator_type() 
)
inline

Create a ManagedDatum object having the same value as the specified original object. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) used to supply memory; otherwise, the default allocator is used. This operation performs a clone of the underlying Datum, see {Value Semantics} for more detail.

◆ ~ManagedDatum()

bdld::ManagedDatum::~ManagedDatum ( )
inline

Destroy this object and release all dynamically allocated memory managed by this object.

Member Function Documentation

◆ adopt()

void bdld::ManagedDatum::adopt ( const Datum obj)
inline

Take ownership of the specified obj and destroy the Datum object previously managed by this object. The behavior is undefined unless obj was allocated using the same allocator used by this object and is not subsequently destroyed externally using Datum::destroy.

◆ allocator()

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

Return get_allocator().mechanism().

◆ BSLMF_NESTED_TRAIT_DECLARATION()

bdld::ManagedDatum::BSLMF_NESTED_TRAIT_DECLARATION ( ManagedDatum  ,
bslmf::IsBitwiseMoveable   
)

◆ clone()

void bdld::ManagedDatum::clone ( const Datum value)
inline

Assign to this object the specified value by making a "deep copy" of value, so that any dynamically allocated memory managed by value is cloned and not shared with value.

◆ datum()

const Datum & bdld::ManagedDatum::datum ( ) const
inline

Return a const reference to the Datum object managed by this object.

◆ get_allocator()

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

◆ makeNull()

void bdld::ManagedDatum::makeNull ( )
inline

Make the Datum object managed by this object null and release all dynamically allocated memory managed by this object.

◆ operator*()

const Datum & bdld::ManagedDatum::operator* ( ) const
inline

Return a const reference to the Datum object managed by this object.

◆ operator->()

const Datum * bdld::ManagedDatum::operator-> ( ) const
inline

Return an address providing non-modifiable access to the Datum object managed by this object.

◆ operator=()

ManagedDatum & bdld::ManagedDatum::operator= ( const ManagedDatum rhs)
inline

Assign to this object the value of the specified rhs object, and return a non-const reference to this object. This operation performs a clone of the underlying Datum, see {Value Semantics} for more detail.

◆ print()

bsl::ostream & bdld::ManagedDatum::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const
inline

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to the modifiable 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.

◆ release()

Datum bdld::ManagedDatum::release ( )
inline

Return, by value, the Datum object managed by this object and set the managed object to null. Ownership of the previously managed Datum object is transferred to the caller.

◆ swap()

void bdld::ManagedDatum::swap ( ManagedDatum other)
inline

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.


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