Quick Links:

bal | bbl | bdl | bsl

Static Public Member Functions

bdlbb::BlobUtil Struct Reference

#include <bdlbb_blobutil.h>

List of all members.

Static Public Member Functions

static void append (Blob *dest, const Blob &source, int offset, int length)
static void append (Blob *dest, const Blob &source, int offset)
static void append (Blob *dest, const Blob &source)
static void append (Blob *dest, const char *source, int offset, int length)
static void append (Blob *dest, const char *source, int length)
static void appendWithCapacityBuffer (Blob *dest, BlobBuffer *buffer, const char *source, int length)
static void erase (Blob *blob, int offset, int length)
static void insert (Blob *dest, int destOffset, const Blob &source, int sourceOffset, int sourceLength)
static void insert (Blob *dest, int destOffset, const Blob &source, int sourceOffset)
static void insert (Blob *dest, int destOffset, const Blob &source)
static bsl::pair< int, int > findBufferIndexAndOffset (const Blob &blob, int position)
static void copy (char *dstBuffer, const Blob &srcBlob, int position, int length)
static void copy (Blob *dst, int dstOffset, const char *src, int length)
static void copy (Blob *dst, int dstOffset, const Blob &src, int srcOffset, int length)
static char * getContiguousRangeOrCopy (char *dstBuffer, const Blob &srcBlob, int position, int length, int alignment=1)
static char * getContiguousDataBuffer (Blob *blob, int addLength, BlobBufferFactory *factory)
static bsl::ostream & asciiDump (bsl::ostream &stream, const Blob &source)
static bsl::ostream & hexDump (bsl::ostream &stream, const Blob &source)
static bsl::ostream & hexDump (bsl::ostream &stream, const Blob &source, int offset, int length)
static void padToAlignment (Blob *dest, int alignment, char fillChar= '\0')
static void prependWithCapacityBuffer (Blob *dest, BlobBuffer *buffer, const char *source, int length)
template<class STREAM >
static STREAM & read (STREAM &stream, Blob *dest, int numBytes)
template<class STREAM >
static STREAM & write (STREAM &stream, const Blob &source)
template<class STREAM >
static int write (STREAM &stream, const Blob &source, int sourcePosition, int numBytes)
static int compare (const Blob &a, const Blob &b)
static int appendBufferIfValid (Blob *dest, const BlobBuffer &buffer)
static int appendBufferIfValid (Blob *dest, bslmf::MovableRef< BlobBuffer > buffer)
static int appendDataBufferIfValid (Blob *dest, const BlobBuffer &buffer)
static int appendDataBufferIfValid (Blob *dest, bslmf::MovableRef< BlobBuffer > buffer)
static int insertBufferIfValid (Blob *dest, int index, const BlobBuffer &buffer)
static int insertBufferIfValid (Blob *dest, int index, bslmf::MovableRef< BlobBuffer > buffer)
static int prependDataBufferIfValid (Blob *dest, const BlobBuffer &buffer)
static int prependDataBufferIfValid (Blob *dest, bslmf::MovableRef< BlobBuffer > buffer)
static void append (Blob *dest, const Blob &source, int offset, int length, bslma::Allocator *)
static void append (Blob *dest, const Blob &source, int offset, bslma::Allocator *)
static void append (Blob *dest, const Blob &source, bslma::Allocator *)

Detailed Description

This struct is a namespace for a collection of static methods used for manipulating and accessing Blob objects.

See Component bdlbb_blobutil


Member Function Documentation

static void bdlbb::BlobUtil::append ( Blob dest,
const Blob source,
int  offset,
int  length 
) [static]

Append the specified length bytes from the specified offset in the specified source to the specified dest.

static void bdlbb::BlobUtil::append ( Blob dest,
const Blob source,
int  offset 
) [static]

Append from the specified offset in the specified source to the specified dest.

static void bdlbb::BlobUtil::append ( Blob dest,
const Blob source 
) [static]

Append the specified source to the specified dest.

static void bdlbb::BlobUtil::append ( Blob dest,
const char *  source,
int  offset,
int  length 
) [static]

Append the specified length bytes starting from the specified offset from the specified source address to the specified dest. The behavior of this function is undefined unless the range [source + offset, source + offset + length) represents a readable sequence of memory.

static void bdlbb::BlobUtil::append ( Blob dest,
const char *  source,
int  length 
) [static]

Append the specified length bytes starting from the specified source address to the specified dest. The behavior is undefined unless the range [source, source + length) is valid memory.

static void bdlbb::BlobUtil::appendWithCapacityBuffer ( Blob dest,
BlobBuffer buffer,
const char *  source,
int  length 
) [static]

Append the specified length bytes from the specified source address to the specified dest. Use the existing capacity in dest first, followed by that in the buffer, and finally allocate from the blob buffer factory associated with the dest. Load any unused space into the specified buffer. The behavior is undefined unless the range [source, source + length) represents a readable sequence of memory.

static void bdlbb::BlobUtil::erase ( Blob blob,
int  offset,
int  length 
) [static]

Erase the specified length bytes starting at the specified offset from the specified blob. The behavior is undefined unless offset >= 0, length >= 0, and offset + length <= blob->length().

static void bdlbb::BlobUtil::insert ( Blob dest,
int  destOffset,
const Blob source,
int  sourceOffset,
int  sourceLength 
) [static]

Insert the specified sourceLength bytes from the specified sourceOffset in the specified source to the specified destOffset in the specified dest.

static void bdlbb::BlobUtil::insert ( Blob dest,
int  destOffset,
const Blob source,
int  sourceOffset 
) [static]

Insert from the specified sourceOffset in the specified source to the specified destOffset in the specified dest.

static void bdlbb::BlobUtil::insert ( Blob dest,
int  destOffset,
const Blob source 
) [static]

Insert the specified source to the specified destOffset in the specified dest.

static bsl::pair<int, int> bdlbb::BlobUtil::findBufferIndexAndOffset ( const Blob blob,
int  position 
) [static]

Return a value, designated here as p, such that for the specified blob, blob.buffer(p.first) is the buffer that contains the byte at the specified position in blob, and p.second is the offset corresponding to position within said buffer. The behavior of this function is undefined unless 0 <= position, 0 < blob.totalSize(), and position < blob.totalSize(). Note that (1) subsequent changes to blob may invalidate the result of this function, and (2) p.first never indicates a zero-size buffer.

static void bdlbb::BlobUtil::copy ( char *  dstBuffer,
const Blob srcBlob,
int  position,
int  length 
) [static]

Copy the specified length bytes starting at the specified position in the specified srcBlob to the specified dstBuffer. The behavior of this function is undefined unless 0 <= length, 0 <= position, position <= srcBlob.totalSize() - length, and dstBuffer has room for length bytes. Note that this function does not set dstBuffer[length] to 0.

static void bdlbb::BlobUtil::copy ( Blob dst,
int  dstOffset,
const char *  src,
int  length 
) [static]

Copy into the specified dst starting at the specified dstOffset the specified length bytes from the specified src. The behavior is undefined unless 0 <= dstOffset, 0 <= length, dst || 0 == length, src || 0 == length, !dst || dstOffset <= dst->length() - length, and src refers to a buffer with at least length bytes.

static void bdlbb::BlobUtil::copy ( Blob dst,
int  dstOffset,
const Blob src,
int  srcOffset,
int  length 
) [static]

Copy into the specified dst starting at the specified dstOffset the specified length bytes starting at the specified srcOffset in the specified src. The behavior is undefined unless 0 <= dstOffset, 0 <= srcOffset, 0 <= length, dst || 0 == length, !dst || dstOffset <= dst->length() - length, and srcOffset <= src->length() - length.

static char* bdlbb::BlobUtil::getContiguousRangeOrCopy ( char *  dstBuffer,
const Blob srcBlob,
int  position,
int  length,
int  alignment = 1 
) [static]

Return the address of the byte at the specified position in the specified srcBlob, if that address is aligned to the optionally specified alignment and the specified length bytes are stored contiguously; otherwise, copy length bytes to the specified buffer dstBuffer, and return dstBuffer. If alignment is not specified, none is enforced. (An address is aligned to A if, when converted to an integral value a, a & (A - 1) is 0.) The behavior of this function is undefined unless 0 < length, 0 <= position, alignment is a power of two, dstBuffer is aligned as required, dstBuffer has room for length bytes, and position <= srcBlob.totalSize() - length.

static char* bdlbb::BlobUtil::getContiguousDataBuffer ( Blob blob,
int  addLength,
BlobBufferFactory factory 
) [static]

Obtain contiguous storage for at least the specified addLength bytes in the specified blob at position blob->length(), and then grow blob->length() by addLength. If, upon entry, such storage does not exist in blob, first trim the final data buffer, if any, and insert a new buffer obtained from the specified factory. Return a pointer to the beginning of the storage obtained. The behavior of this function is undefined unless 0 < addLength, and factory->allocate(), if called, yields a block of memory of a size at least as large as addLength.

static bsl::ostream& bdlbb::BlobUtil::asciiDump ( bsl::ostream &  stream,
const Blob source 
) [static]

Write to the specified stream an ascii dump of the specified source, and return a reference to the modifiable stream.

static bsl::ostream& bdlbb::BlobUtil::hexDump ( bsl::ostream &  stream,
const Blob source 
) [static]

Write to the specified stream a hexdump of the specified source, and return a reference to the modifiable stream.

static bsl::ostream& bdlbb::BlobUtil::hexDump ( bsl::ostream &  stream,
const Blob source,
int  offset,
int  length 
) [static]

Write to the specified stream a hexdump of the specified length bytes of the specified source starting at the specified offset, and return a reference to the modifiable stream.

static void bdlbb::BlobUtil::padToAlignment ( Blob dest,
int  alignment,
char  fillChar = '\0' 
) [static]

Append padding bytes to the specified dest so that its resulting length is an integer multiple of the specified alignment. Optionally specify fillChar with which the padding is to be filled. If fillChar is not specified, a 0 byte will be used. The behavior is undefined unless alignment is a power of 2, and less than or equal to 64.

static void bdlbb::BlobUtil::prependWithCapacityBuffer ( Blob dest,
BlobBuffer buffer,
const char *  source,
int  length 
) [static]

Prepend the specified length bytes from the specified source address to the specified dest. Use the existing capacity in dest first if 0 == dest->length(), followed by that in the buffer, and finally allocate from the blob buffer factory associated with the dest. Load any unused space into the specified buffer. The behavior is undefined unless the range [source, source + length) represents a readable sequence of memory.

template<class STREAM >
static STREAM& bdlbb::BlobUtil::read ( STREAM &  stream,
Blob dest,
int  numBytes 
) [static]

Read the specified numBytes from the specified stream and load it into the specified dest, and return a reference to the modifiable stream.

template<class STREAM >
static STREAM& bdlbb::BlobUtil::write ( STREAM &  stream,
const Blob source 
) [static]

Write the specified source to the specified stream, and return a reference to the modifiable stream.

template<class STREAM >
static int bdlbb::BlobUtil::write ( STREAM &  stream,
const Blob source,
int  sourcePosition,
int  numBytes 
) [static]

Write to the specified stream the specified numBytes starting at the specified sourcePosition in the specified source blob. Return 0 on success or a non-zero value otherwise. Note that this function will fail (immediately) if the length of source is less than numBytes; or if there is any error writing to stream.

static int bdlbb::BlobUtil::compare ( const Blob a,
const Blob b 
) [static]

Compare, lexicographically, the data (data length and character data values at each index position) stored by the specified a and b blobs. Return 0 if the data stored by a is lexicographically equal to the data stored by b, a negative value if a is lexicographically less than b, and a positive value if a is lexicographically greater than b.

static int bdlbb::BlobUtil::appendBufferIfValid ( Blob dest,
const BlobBuffer buffer 
) [static]

Append the specified buffer after the last buffer of the specified dest if neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. The length of the dest is unaffected.

static int bdlbb::BlobUtil::appendBufferIfValid ( Blob dest,
bslmf::MovableRef< BlobBuffer buffer 
) [static]

Append the specified move-insertable buffer after the last buffer of the specified dest if neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. The length of the dest is unaffected. In case of success the buffer is left in a valid but unspecified state.

static int bdlbb::BlobUtil::appendDataBufferIfValid ( Blob dest,
const BlobBuffer buffer 
) [static]

Append the specified buffer after the last data buffer of the specified dest if neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. The last data buffer of the dest is trimmed, if necessary. The length of the dest is incremented by the size of buffer.

static int bdlbb::BlobUtil::appendDataBufferIfValid ( Blob dest,
bslmf::MovableRef< BlobBuffer buffer 
) [static]

Append the specified move-insertable buffer after the last data buffer of the specified dest if neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. The last data buffer of the dest is trimmed, if necessary. The length of the dest is incremented by the size of buffer. In case of success the buffer is left in a valid but unspecified state.

static int bdlbb::BlobUtil::insertBufferIfValid ( Blob dest,
int  index,
const BlobBuffer buffer 
) [static]

Insert the specified buffer at the specified index in the specified dest if 0 <= index <= dest->numBuffers() and neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. Increment the length of the 'dest by the size of the buffer if buffer is inserted before the logical end of the dest. The length of the dest 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.

static int bdlbb::BlobUtil::insertBufferIfValid ( Blob dest,
int  index,
bslmf::MovableRef< BlobBuffer buffer 
) [static]

Insert the specified move-insertable buffer at the specified index in the specified dest if 0 <= index <= dest->numBuffers() and neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. Increment the length of the 'dest by the size of the buffer if buffer is inserted before the logical end of the dest. The length of the dest 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. In case of success the buffer is left in a valid but unspecified state.

static int bdlbb::BlobUtil::prependDataBufferIfValid ( Blob dest,
const BlobBuffer buffer 
) [static]

Insert the specified buffer before the beginning of the specified dest if neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. The length of the dest is incremented by the length of the prepended buffer.

static int bdlbb::BlobUtil::prependDataBufferIfValid ( Blob dest,
bslmf::MovableRef< BlobBuffer buffer 
) [static]

Insert the specified move-insertable buffer before the beginning of the specified dest if neither the resulting total size of dest nor its resulting total number of buffers exceeds INT_MAX. Return 0 on success, and a non-zero value (with no effect) otherwise. The length of the dest is incremented by the length of the prepended buffer. In case of success the buffer is left in a valid but unspecified state.

static void bdlbb::BlobUtil::append ( Blob dest,
const Blob source,
int  offset,
int  length,
bslma::Allocator  
) [static]
static void bdlbb::BlobUtil::append ( Blob dest,
const Blob source,
int  offset,
bslma::Allocator  
) [static]
static void bdlbb::BlobUtil::append ( Blob dest,
const Blob source,
bslma::Allocator  
) [static]

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