BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlbb::BlobBuffer Class Reference

#include <bdlbb_blob.h>

Public Member Functions

 BlobBuffer ()
 
 BlobBuffer (const bsl::shared_ptr< char > &buffer, int size)
 
 BlobBuffer (bslmf::MovableRef< bsl::shared_ptr< char > > buffer, int size)
 
 BlobBuffer (const BlobBuffer &original)
 
 BlobBuffer (bslmf::MovableRef< BlobBuffer > original) BSLS_KEYWORD_NOEXCEPT
 
 ~BlobBuffer ()
 Destroy this blob buffer.
 
BlobBufferoperator= (const BlobBuffer &rhs)
 
BlobBufferoperator= (bslmf::MovableRef< BlobBuffer > rhs)
 
void reset ()
 Reset this blob buffer to its default-constructed state.
 
void reset (const bsl::shared_ptr< char > &buffer, int size)
 
void reset (bslmf::MovableRef< bsl::shared_ptr< char > > buffer, int size)
 
bsl::shared_ptr< char > & buffer ()
 
void setSize (int size)
 
void swap (BlobBuffer &other)
 
BlobBuffer trim (int toSize)
 
const bsl::shared_ptr< char > & buffer () const
 
char * data () const
 
int size () const
 Return the size of the buffer represented by this object.
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Friends

bool operator== (const BlobBuffer &, const BlobBuffer &)
 
bool operator!= (const BlobBuffer &, const BlobBuffer &)
 

Detailed Description

BlobBuffer is a simple in-core representation of a shared buffer. 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

Constructor & Destructor Documentation

◆ BlobBuffer() [1/5]

bdlbb::BlobBuffer::BlobBuffer ( )
inline

Create a blob buffer representing a null buffer. Note that the size and data methods of a default-constructed blob buffer both return 0.

◆ BlobBuffer() [2/5]

bdlbb::BlobBuffer::BlobBuffer ( const bsl::shared_ptr< char > &  buffer,
int  size 
)
inline

Create a blob buffer representing the specified buffer of the specified size. The behavior is undefined unless 0 <= size and the buffer refers to a continuous block of memory of at least size bytes.

◆ BlobBuffer() [3/5]

bdlbb::BlobBuffer::BlobBuffer ( bslmf::MovableRef< bsl::shared_ptr< char > >  buffer,
int  size 
)
inline

Create a blob buffer representing the specified moveable buffer of the specified size. The behavior is undefined unless 0 <= size and the buffer refers to a continuous block of memory of at least size bytes.

◆ BlobBuffer() [4/5]

bdlbb::BlobBuffer::BlobBuffer ( const BlobBuffer original)
inline

Create a blob buffer having the same value as the specified original blob buffer.

◆ BlobBuffer() [5/5]

bdlbb::BlobBuffer::BlobBuffer ( bslmf::MovableRef< BlobBuffer original)
inline

Create a blob buffer object having the same value as the specified original object by moving the contents of original to the newly-created object. original is left in a valid but unspecified state.

◆ ~BlobBuffer()

bdlbb::BlobBuffer::~BlobBuffer ( )
inline

Member Function Documentation

◆ buffer() [1/2]

bsl::shared_ptr< char > & bdlbb::BlobBuffer::buffer ( )
inline

Return a reference to the shared pointer to the modifiable buffer represented by this object.

◆ buffer() [2/2]

const bsl::shared_ptr< char > & bdlbb::BlobBuffer::buffer ( ) const
inline

Return a reference to the non-modifiable shared pointer to the buffer represented by this object.

◆ data()

char * bdlbb::BlobBuffer::data ( ) const
inline

Return the address of the modifiable buffer represented by this object.

◆ operator=() [1/2]

BlobBuffer & bdlbb::BlobBuffer::operator= ( bslmf::MovableRef< BlobBuffer 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.

◆ operator=() [2/2]

BlobBuffer & bdlbb::BlobBuffer::operator= ( const BlobBuffer rhs)

Assign to this blob buffer the value of the specified rhs blob buffer, and return a reference to this modifiable blob buffer.

◆ print()

bsl::ostream & bdlbb::BlobBuffer::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object as a hexadecimal dump on the specified stream, and return a reference to the modifiable stream. Note that the optionally specified level and spacesPerLevel arguments are specified for interface compatibility only and are effectively ignored.

◆ reset() [1/3]

void bdlbb::BlobBuffer::reset ( )

◆ reset() [2/3]

void bdlbb::BlobBuffer::reset ( bslmf::MovableRef< bsl::shared_ptr< char > >  buffer,
int  size 
)

Set the buffer represented by this object to the specified moveable buffer of the specified size. The behavior is undefined unless 0 <= size and the buffer refers to a continuous block of memory of at least size bytes.

◆ reset() [3/3]

void bdlbb::BlobBuffer::reset ( const bsl::shared_ptr< char > &  buffer,
int  size 
)

Set the buffer represented by this object to the specified buffer of the specified size. The behavior is undefined unless 0 <= size and the buffer refers to a continuous block of memory of at least size bytes.

◆ setSize()

void bdlbb::BlobBuffer::setSize ( int  size)
inline

Set the size of this blob buffer to the specified size. The behavior is undefined unless 0 <= size and the capacity of the buffer returned by the buffer method is at least size bytes.

◆ size()

int bdlbb::BlobBuffer::size ( ) const
inline

◆ swap()

void bdlbb::BlobBuffer::swap ( BlobBuffer 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.

◆ trim()

BlobBuffer bdlbb::BlobBuffer::trim ( int  toSize)

Reduce this buffer to the specified toSize and return the leftover. The behaviour is undefined unless '0 <= toSize && toSize <= size()'.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const BlobBuffer ,
const BlobBuffer  
)
friend

Return true if the specified lhs and rhs blob buffers do not have the same value, and false otherwise. Two blob buffers do not have the same value if they do not represent the same buffer of the same size.

◆ operator==

bool operator== ( const BlobBuffer ,
const BlobBuffer  
)
friend

Return true if the specified lhs and rhs blob buffers have the same value, and false otherwise. Two blob buffers have the same value if they represent the same buffer of the same size.


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