[#BloombergLP-bdlbb-Blob] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlbb.adoc[bdlbb]::Blob :relfileprefix: ../../ :mrdocs: `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>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Blob; ---- == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlbb/Blob/2constructor-07.adoc[`Blob`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlbb/Blob/2destructor.adoc[`~Blob`] [.small]#[destructor]# | Destroy this blob. | xref:BloombergLP/bdlbb/Blob/operator_assign-0d.adoc[`operator=`] | Assignment operators | xref:BloombergLP/bdlbb/Blob/allocator.adoc[`allocator`] | Return the allocator used by this object to supply memory. | xref:BloombergLP/bdlbb/Blob/appendBuffer-00.adoc[`appendBuffer`] | `appendBuffer` overloads | xref:BloombergLP/bdlbb/Blob/appendDataBuffer-04.adoc[`appendDataBuffer`] | `appendDataBuffer` overloads | xref:BloombergLP/bdlbb/Blob/buffer.adoc[`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()`. | xref:BloombergLP/bdlbb/Blob/factory.adoc[`factory`] | Return the factory used by this object. | xref:BloombergLP/bdlbb/Blob/insertBuffer-0d.adoc[`insertBuffer`] | `insertBuffer` overloads | xref:BloombergLP/bdlbb/Blob/lastDataBufferLength.adoc[`lastDataBufferLength`] | Return the length of the last blob buffer in this blob, or 0 if this blob is of 0 length. | xref:BloombergLP/bdlbb/Blob/length.adoc[`length`] | Return the length of this blob. | xref:BloombergLP/bdlbb/Blob/moveAndAppendDataBuffers.adoc[`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`. | xref:BloombergLP/bdlbb/Blob/moveBuffers.adoc[`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. | xref:BloombergLP/bdlbb/Blob/moveDataBuffers.adoc[`moveDataBuffers`] | Remove all blob buffers from this blob and move the data buffers held by the specified `srcBlob` to this blob. | xref:BloombergLP/bdlbb/Blob/numBuffers.adoc[`numBuffers`] | Return the number of blob buffers held by this blob. | xref:BloombergLP/bdlbb/Blob/numDataBuffers.adoc[`numDataBuffers`] | Return the number of blob buffers containing data in this blob. | xref:BloombergLP/bdlbb/Blob/prependDataBuffer-0d.adoc[`prependDataBuffer`] | `prependDataBuffer` overloads | xref:BloombergLP/bdlbb/Blob/removeAll.adoc[`removeAll`] | Remove all blob buffers from this blob, and set its length to 0. | xref:BloombergLP/bdlbb/Blob/removeBuffer.adoc[`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()`. | xref:BloombergLP/bdlbb/Blob/removeBuffers.adoc[`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()`. | xref:BloombergLP/bdlbb/Blob/removeUnusedBuffers.adoc[`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. | xref:BloombergLP/bdlbb/Blob/replaceDataBuffer.adoc[`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. | xref:BloombergLP/bdlbb/Blob/reserveBufferCapacity.adoc[`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. | xref:BloombergLP/bdlbb/Blob/setLength.adoc[`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. | xref:BloombergLP/bdlbb/Blob/swap.adoc[`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`. | xref:BloombergLP/bdlbb/Blob/swapBufferRaw.adoc[`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. | xref:BloombergLP/bdlbb/Blob/totalSize.adoc[`totalSize`] | Return the sum of the sizes of all blob buffers in this blob (i.e., the capacity of this blob). | xref:BloombergLP/bdlbb/Blob/trimLastDataBuffer.adoc[`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 [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlbb/operator_not_eq-0f.adoc[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. | `xref:BloombergLP/bdlbb/operator_eq-06.adoc[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 [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlbb/swap-04.adoc[`swap`] | Efficiently 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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#