|
BDE 4.39.x Production Release
|
#include <bdlbb_blob.h>
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.
See bdlbb_blob
Friends | |
| bool | operator== (const Blob &, const Blob &) |
| bool | operator!= (const Blob &, const Blob &) |
|
explicit |
Create an empty blob having no factory to allocate blob buffers. Since there is no factory, the behavior is undefined if the length of the blob is set beyond the total size. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
|
explicit |
Create an empty blob using the specified factory to allocate blob buffers. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
| bdlbb::Blob::Blob | ( | const BlobBuffer * | buffers, |
| int | numBuffers, | ||
| BlobBufferFactory * | factory, | ||
| bslma::Allocator * | basicAllocator = 0 |
||
| ) |
Create a blob that initially holds the specified numBuffers buffers referenced by the specified buffers, and uses the specified factory to allocate blob buffers. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
| bdlbb::Blob::Blob | ( | const Blob & | original, |
| BlobBufferFactory * | factory, | ||
| bslma::Allocator * | basicAllocator = 0 |
||
| ) |
Create a blob that holds the same buffers as the specified original blob, and uses the specified factory to allocate blob buffers. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
| bdlbb::Blob::Blob | ( | const Blob & | original, |
| bslma::Allocator * | basicAllocator = 0 |
||
| ) |
Create a blob that holds the same buffers as the specified original blob, and has no factory to allocate blob buffers. Since there is no factory, the behavior is undefined if the length of the blob is set beyond the total size. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
| bdlbb::Blob::Blob | ( | bslmf::MovableRef< Blob > | original | ) |
Create a blob object having the same value as the specified original object by moving the contents of original to the newly-created object. The allocator associated with original is propagated for use in the newly-created object. original is left in a valid but unspecified state.
| bdlbb::Blob::Blob | ( | bslmf::MovableRef< Blob > | original, |
| bslma::Allocator * | basicAllocator | ||
| ) |
Create a blob object having the same value as the specified original object that uses the specified basicAllocator to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The contents of original are moved to the newly-created object. original is left in a valid but unspecified state.
| bdlbb::Blob::~Blob | ( | ) |
Destroy this blob.
|
inline |
Return the allocator used by this object to supply memory.
| void bdlbb::Blob::appendBuffer | ( | bslmf::MovableRef< BlobBuffer > | buffer | ) |
Append the specified move-insertable buffer after the last buffer of this blob. The buffer is left in a valid but unspecified state. The length of this blob is unaffected.
INT_MAX. insertBuffer(numBuffers(), buffer), but is more efficient.
|
inline |
Append the specified buffer after the last buffer of this blob. The length of this blob is unaffected.
INT_MAX. insertBuffer(numBuffers(), buffer), but is more efficient. | void bdlbb::Blob::appendDataBuffer | ( | bslmf::MovableRef< BlobBuffer > | buffer | ) |
Append the specified move-insertable buffer after the last data buffer of this blob; the last data buffer is trimmed, if necessary. The buffer is left in a valid but unspecified state. The length of this blob is incremented by the size of buffer.
INT_MAX.
|
inline |
Append the specified buffer after the last data buffer of this blob; the last data buffer is trimmed, if necessary. The length of this blob is incremented by the size of buffer.
INT_MAX.
|
inline |
Return a reference to the non-modifiable blob buffer at the specified index in this blob.
0 <= index < numBuffers().
|
inline |
Return the factory used by this object.
| void bdlbb::Blob::insertBuffer | ( | int | index, |
| bslmf::MovableRef< BlobBuffer > | buffer | ||
| ) |
Insert the specified move-insertable buffer at the specified index in this blob. Increment the length of this blob by the size of buffer if buffer is inserted before the logical end of this blob. The length of this blob is unchanged if inserting at a position following all data buffers (e.g., inserting into an empty blob or inserting a buffer to increase capacity); in that case, the blob length must be changed by an explicit call to setLength. Buffers at index and higher positions (if any) are shifted up by one index position. The buffer is left in a valid but unspecified state.
0 <= index <= numBuffers() and neither the total size of the resulting blob nor its total number of buffers exceeds INT_MAX.
|
inline |
Insert the specified buffer at the specified index in this blob. Increment the length of this blob by the size of buffer if buffer is inserted before the logical end of this blob. The length of this blob is unchanged if inserting at a position following all data buffers (e.g., inserting into an empty blob or inserting a buffer to increase capacity); in that case, the blob length must be changed by an explicit call to setLength. Buffers at index and higher positions (if any) are shifted up by one index position.
0 <= index <= numBuffers() and neither the total size of the resulting blob nor its total number of buffers exceeds INT_MAX.
|
inline |
Return the length of the last blob buffer in this blob, or 0 if this blob is of 0 length.
|
inline |
Return the length of this blob.
| void bdlbb::Blob::moveAndAppendDataBuffers | ( | Blob * | srcBlob | ) |
Move the data buffers held by the specified srcBlob to this blob appending them to the current data buffers of this blob.
INT_MAX. | void bdlbb::Blob::moveBuffers | ( | Blob * | srcBlob | ) |
Remove all blob buffers from this blob and move the buffers held by the specified srcBlob to this blob.
| void bdlbb::Blob::moveDataBuffers | ( | Blob * | srcBlob | ) |
Remove all blob buffers from this blob and move the data buffers held by the specified srcBlob to this blob.
|
inline |
Return the number of blob buffers held by this blob.
|
inline |
Return the number of blob buffers containing data in this blob.
| Blob & bdlbb::Blob::operator= | ( | bslmf::MovableRef< Blob > | rhs | ) |
Assign to this object the value of the specified rhs, and return a reference providing modifiable access to this object. The contents of rhs are move-assigned to this object. rhs is left in a valid but unspecified state.
Assign to this blob the value of the specified rhs blob, and return a reference to this modifiable blob.
| void bdlbb::Blob::prependDataBuffer | ( | bslmf::MovableRef< BlobBuffer > | buffer | ) |
Insert the specified move-insertable buffer before the beginning of this blob. The length of this blob is incremented by the length of the prepended buffer. The buffer is left in a valid but unspecified state.
INT_MAX.
|
inline |
Insert the specified buffer before the beginning of this blob. The length of this blob is incremented by the length of the prepended buffer.
INT_MAX. | void bdlbb::Blob::removeAll | ( | ) |
Remove all blob buffers from this blob, and set its length to 0.
| void bdlbb::Blob::removeBuffer | ( | int | index | ) |
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.
0 <= index < numBuffers(). | void bdlbb::Blob::removeBuffers | ( | int | index, |
| int | numBuffers | ||
| ) |
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.
0 <= index, 0 <= numBuffers, and index + numBuffers <= numBuffers(). | void bdlbb::Blob::removeUnusedBuffers | ( | ) |
Remove any unused capacity buffers from this blob.
totalSize will be length plus any unused capacity in the last buffer having data. | void bdlbb::Blob::replaceDataBuffer | ( | int | index, |
| const BlobBuffer & | buffer | ||
| ) |
Replace the data buffer at the specified index with the specified buffer.
0 <= index < numDataBuffers() and the total size of the resulting blob does not exceed INT_MAX.
|
inline |
Allocate sufficient capacity to store at least the specified numBuffers buffers.
0 <= numBuffers. | void bdlbb::Blob::setLength | ( | int | length | ) |
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.
length is a negative value, or if the new length requires growing the blob and this blob has no underlying factory. | void bdlbb::Blob::swap | ( | Blob & | other | ) |
Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee.
other. | void bdlbb::Blob::swapBufferRaw | ( | int | index, |
| BlobBuffer * | srcBuffer | ||
| ) |
Swap the blob buffer at the specified index with the specified srcBuffer.
0 <= index < numBuffers() and srcBuffer->size() == buffer(index).size().
|
inline |
Return the sum of the sizes of all blob buffers in this blob (i.e., the capacity of this blob).
| BlobBuffer bdlbb::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.
numDataBuffers() and higher) are not removed. 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.
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.