Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Friends

bdlbb::BlobBuffer Class Reference

#include <bdlbb_blob.h>

List of all members.

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 ()
BlobBufferoperator= (const BlobBuffer &rhs)
BlobBufferoperator= (bslmf::MovableRef< BlobBuffer > rhs)
void reset ()
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
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 Component bdlbb_blob


Constructor & Destructor Documentation

bdlbb::BlobBuffer::BlobBuffer (  ) 

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

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

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.

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

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.

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

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

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

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.

bdlbb::BlobBuffer::~BlobBuffer (  ) 

Destroy this blob buffer.


Member Function Documentation

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.

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.

void bdlbb::BlobBuffer::reset (  ) 

Reset this blob buffer to its default-constructed state.

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.

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.

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

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

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

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.

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.

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()'.

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

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

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

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

int bdlbb::BlobBuffer::size (  )  const

Return the size of the buffer represented by this object.

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.


Friends And Related Function Documentation

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.

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.


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