[#BloombergLP-bdlbb-BlobUtil] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlbb.adoc[bdlbb]::BlobUtil :relfileprefix: ../../ :mrdocs: This `struct` is a namespace for a collection of static methods used for manipulating and accessing `Blob` objects. == Synopsis Declared in `<bdlbb_blobutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- struct BlobUtil; ---- == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlbb/BlobUtil/append-09.adoc[`append`] | `append` overloads | xref:BloombergLP/bdlbb/BlobUtil/appendBufferIfValid-07.adoc[`appendBufferIfValid`] | `appendBufferIfValid` overloads | xref:BloombergLP/bdlbb/BlobUtil/appendDataBufferIfValid-0c.adoc[`appendDataBufferIfValid`] | `appendDataBufferIfValid` overloads | xref:BloombergLP/bdlbb/BlobUtil/appendWithCapacityBuffer.adoc[`appendWithCapacityBuffer`] | 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. | xref:BloombergLP/bdlbb/BlobUtil/asciiDump-0a.adoc[`asciiDump`] | `asciiDump` overloads | xref:BloombergLP/bdlbb/BlobUtil/compare.adoc[`compare`] | 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`. | xref:BloombergLP/bdlbb/BlobUtil/copy-06.adoc[`copy`] | `copy` overloads | xref:BloombergLP/bdlbb/BlobUtil/erase.adoc[`erase`] | 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()`. | xref:BloombergLP/bdlbb/BlobUtil/findBufferIndexAndOffset.adoc[`findBufferIndexAndOffset`] | 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. | xref:BloombergLP/bdlbb/BlobUtil/getContiguousDataBuffer.adoc[`getContiguousDataBuffer`] | 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`. | xref:BloombergLP/bdlbb/BlobUtil/getContiguousRangeOrCopy.adoc[`getContiguousRangeOrCopy`] | 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`. | xref:BloombergLP/bdlbb/BlobUtil/hexDump-0f.adoc[`hexDump`] | `hexDump` overloads | xref:BloombergLP/bdlbb/BlobUtil/insert-0e.adoc[`insert`] | `insert` overloads | xref:BloombergLP/bdlbb/BlobUtil/insertBufferIfValid-0f.adoc[`insertBufferIfValid`] | `insertBufferIfValid` overloads | xref:BloombergLP/bdlbb/BlobUtil/padToAlignment.adoc[`padToAlignment`] | 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. | xref:BloombergLP/bdlbb/BlobUtil/prependDataBufferIfValid-0b.adoc[`prependDataBufferIfValid`] | `prependDataBufferIfValid` overloads | xref:BloombergLP/bdlbb/BlobUtil/prependWithCapacityBuffer.adoc[`prependWithCapacityBuffer`] | 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. | xref:BloombergLP/bdlbb/BlobUtil/read.adoc[`read`] | Read the specified `numBytes` from the specified `stream` and load it into the specified `dest`, and return a reference to the modifiable `stream`. | xref:BloombergLP/bdlbb/BlobUtil/write-0cc.adoc[`write`] | `write` overloads |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#