#include <bdld_manageddatum.h>
This class implements a smart-pointer-like resource manager for a Datum
object.
See bdld_manageddatum
◆ allocator_type
◆ ManagedDatum() [1/4]
bdld::ManagedDatum::ManagedDatum |
( |
| ) |
|
|
inline |
◆ ManagedDatum() [2/4]
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]
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]
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.
◆ 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()
◆ BSLMF_NESTED_TRAIT_DECLARATION()
◆ 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()
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=()
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()
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: