BloombergLP::bdlbb::Blob

Blob is an in-core container for BlobBuffer objects. This class is exception-neutral with no guarantee of rollback: if an exception is thrown during the invocation of a method on a pre-existing instance, the container is left in a valid state, but its value is undefined. In no event is memory leaked.

Synopsis

Declared in <bdlbb_blob.h>

class Blob;

Member Functions

NameDescription
Blob [constructor]Constructors
~Blob [destructor]Destroy this blob.
operator= Assignment operators
allocator Return the allocator used by this object to supply memory.
appendBuffer appendBuffer overloads
appendDataBuffer appendDataBuffer overloads
buffer Return a reference to the non-modifiable blob buffer at the specified index in this blob. The behavior is undefined unless 0 <= index < numBuffers().
factory Return the factory used by this object.
insertBuffer insertBuffer overloads
lastDataBufferLength Return the length of the last blob buffer in this blob, or 0 if this blob is of 0 length.
length Return the length of this blob.
moveAndAppendDataBuffers Move the data buffers held by the specified srcBlob to this blob appending them to the current data buffers of this blob. The behavior is undefined unless the total size of the resulting blob and the total number of buffers in this blob are less than or equal to INT_MAX.
moveBuffers Remove all blob buffers from this blob and move the buffers held by the specified srcBlob to this blob. Note that this method is logically equivalent to: ` *this = *srcBlob; srcBlob->removeAll(); ` but its implementation is more efficient.
moveDataBuffers Remove all blob buffers from this blob and move the data buffers held by the specified srcBlob to this blob.
numBuffers Return the number of blob buffers held by this blob.
numDataBuffers Return the number of blob buffers containing data in this blob.
prependDataBuffer prependDataBuffer overloads
removeAll Remove all blob buffers from this blob, and set its length to 0.
removeBuffer Remove the buffer at the specified index from this blob, and decrement the length of this blob by the size of buffer if the buffer at index contains data bytes (i.e., if the first byte of buffer occurs before the logical end of this blob). Buffers at positions higher than index (if any) are shifted down by one index position. The behavior is undefined unless 0 <= index < numBuffers().
removeBuffers Remove the specified numBuffers starting at the specified index from this blob. Buffers at positions higher than index (if any) are shifted down by numBuffers index positions. The behavior is undefined unless 0 <= index, 0 <= numBuffers, and index + numBuffers <= numBuffers().
removeUnusedBuffers Remove any unused capacity buffers from this blob. Note that this method does not trim the last data buffer, and that the resulting totalSize will be length plus any unused capacity in the last buffer having data.
replaceDataBuffer Replace the data buffer at the specified index with the specified buffer. The behavior is undefined unless 0 <= index < numDataBuffers() and the total size of the resulting blob does not exceed INT_MAX. Note that this operation is equivalent to: ` blob.removeBuffer(index); const int n = blob.length(); blob.insertBuffer(index, buffer); blob.setLength(n + buffer.size()); ` but is more efficient.
reserveBufferCapacity Allocate sufficient capacity to store at least the specified numBuffers buffers. The behavior is undefined unless 0 <= numBuffers. Note that this method does not change the length of this blob or add any buffers to it. Note also that the internal capacity will be increased to maintain a geometric growth factor.
setLength Set the length of this blob to the specified length and, if length is greater than its total size, grow this blob by appending buffers allocated using this object's underlying BlobBufferFactory. The behavior is undefined if length is a negative value, or if the new length requires growing the blob and this blob has no underlying factory.
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.
swapBufferRaw Swap the blob buffer at the specified index with the specified srcBuffer. The behavior is undefined unless 0 <= index < numBuffers() and srcBuffer->size() == buffer(index).size(). Note that other than the buffer swap the state of this object remains unchanged.
totalSize Return the sum of the sizes of all blob buffers in this blob (i.e., the capacity of this blob).
trimLastDataBuffer Set the size of the last data buffer to lastDataBufferLength(). If there are no data buffers, or if the last data buffer is full (i.e., its size is lastDataBufferLength()), then this method has no effect. Return the leftover of the trimmed buffer or default constructed BlobBuffer if nothing to trim. Note that the length of the blob is unchanged, and that capacity buffers (i.e., of indices numDataBuffers() and higher) are not removed.

Friends

NameDescription
BloombergLP::bdlbb::operator!=Return true if the specified lhs and rhs blobs do not have the same value, and false otherwise. Two blobs do not have the same value if they do not hold the same buffers, or do not have the same length.
BloombergLP::bdlbb::operator==Return true if the specified lhs and rhs blobs have the same value, and false otherwise. Two blobs have the same value if they hold the same buffers, and have the same length.

Non-Member Functions

NameDescription
swapEfficiently exchange the values of the specified a and b objects. This method provides the no-throw exception-safety guarantee if both objects were created with the same allocator.