Bond
 
Loading...
Searching...
No Matches
bond::blob Class Reference

Memory blob. More...

Public Member Functions

 blob () BOND_NOEXCEPT
 Default constructor. More...
 
 blob (const void *content, uint32_t length)
 Construct from a raw pointer to memory buffer. More...
 
 blob (const boost::shared_ptr< const char[]> &buffer, uint32_t length)
 Construct from a boost::shared_ptr to const memory buffer. More...
 
 blob (const boost::shared_ptr< const char[]> &buffer, uint32_t offset, uint32_t length)
 Construct from a boost::shared_ptr to const memory buffer. More...
 
 blob (const boost::shared_ptr< char[]> &buffer, uint32_t length)
 Construct from a boost::shared_ptr to memory buffer. More...
 
 blob (const boost::shared_ptr< char[]> &buffer, uint32_t offset, uint32_t length)
 Construct from a boost::shared_ptr to memory buffer. More...
 
template<typename T , template< typename U > class SmartPtr>
 blob (const SmartPtr< T > &buffer, uint32_t length)
 Construct from a smart pointer other than boost::shared_ptr. More...
 
template<typename T , template< typename U > class SmartPtr>
 blob (const SmartPtr< T > &buffer, uint32_t offset, uint32_t length)
 Construct from a smart pointer other than boost::shared_ptr. More...
 
 blob (blob &&that) BOND_NOEXCEPT_IF(std
 Move constructor. More...
 
void assign (const blob &from, uint32_t offset, uint32_t length)
 Assign a new value from another blob object or its part. More...
 
template<typename T >
void assign (const T &buffer, uint32_t length)
 Assign a new value from a raw or smart pointer. More...
 
template<typename T >
void assign (const T &buffer, uint32_t offset, uint32_t length)
 Assign a new value from a raw or smart pointer. More...
 
blob range (uint32_t offset, uint32_t length) const
 Return a blob object for a range of this object. More...
 
blob range (uint32_t offset) const
 Return a blob object for a range from the specified offset to the end of the buffer. More...
 
void swap (blob &src) BOND_NOEXCEPT
 Swap with another blob. More...
 
void clear () BOND_NOEXCEPT
 Clear reference to the underlying memory buffer and reset the blob to empty. More...
 
const char * content () const BOND_NOEXCEPT
 Pointer to the content. More...
 
const void * data () const BOND_NOEXCEPT
 Void pointer to the content. More...
 
uint32_t length () const BOND_NOEXCEPT
 Length of the content. More...
 
uint32_t size () const BOND_NOEXCEPT
 Length of the content. More...
 
bool empty () const BOND_NOEXCEPT
 Check if the blob is empty (i.e. lenght == 0) More...
 
const_iterator begin () const BOND_NOEXCEPT
 Iterator for the beginning of the blob. More...
 
const_iterator end () const BOND_NOEXCEPT
 Iterator for the end of the blob. More...
 

Friends

template<typename A >
blob blob_prolong (blob src, const A &allocator)
 Returns a blob with a copy of the data if the original one does not own the memory (i.e. constructed using raw memory), and the same blob otherwise. More...
 

Detailed Description

Memory blob.

Constructor & Destructor Documentation

◆ blob() [1/9]

bond::blob::blob ( )

Default constructor.

◆ blob() [2/9]

bond::blob::blob ( const void *  content,
uint32_t  length 
)

Construct from a raw pointer to memory buffer.

Not recommended because of buffer lifetime management.

◆ blob() [3/9]

bond::blob::blob ( const boost::shared_ptr< const char[]> &  buffer,
uint32_t  length 
)

Construct from a boost::shared_ptr to const memory buffer.

◆ blob() [4/9]

bond::blob::blob ( const boost::shared_ptr< const char[]> &  buffer,
uint32_t  offset,
uint32_t  length 
)

Construct from a boost::shared_ptr to const memory buffer.

◆ blob() [5/9]

bond::blob::blob ( const boost::shared_ptr< char[]> &  buffer,
uint32_t  length 
)

Construct from a boost::shared_ptr to memory buffer.

◆ blob() [6/9]

bond::blob::blob ( const boost::shared_ptr< char[]> &  buffer,
uint32_t  offset,
uint32_t  length 
)

Construct from a boost::shared_ptr to memory buffer.

◆ blob() [7/9]

template<typename T , template< typename U > class SmartPtr>
bond::blob::blob ( const SmartPtr< T > &  buffer,
uint32_t  length 
)

Construct from a smart pointer other than boost::shared_ptr.

Not recommended for performance reasons. Use boost::shared_ptr whenever possible.

◆ blob() [8/9]

template<typename T , template< typename U > class SmartPtr>
bond::blob::blob ( const SmartPtr< T > &  buffer,
uint32_t  offset,
uint32_t  length 
)

Construct from a smart pointer other than boost::shared_ptr.

Not recommended for performance reasons. Use boost::shared_ptr whenever possible.

◆ blob() [9/9]

bond::blob::blob ( blob &&  that)

Move constructor.

Member Function Documentation

◆ assign() [1/3]

void bond::blob::assign ( const blob from,
uint32_t  offset,
uint32_t  length 
)

Assign a new value from another blob object or its part.

◆ assign() [2/3]

template<typename T >
void bond::blob::assign ( const T &  buffer,
uint32_t  length 
)

Assign a new value from a raw or smart pointer.

◆ assign() [3/3]

template<typename T >
void bond::blob::assign ( const T &  buffer,
uint32_t  offset,
uint32_t  length 
)

Assign a new value from a raw or smart pointer.

◆ begin()

const_iterator bond::blob::begin ( ) const

Iterator for the beginning of the blob.

◆ clear()

void bond::blob::clear ( )

Clear reference to the underlying memory buffer and reset the blob to empty.

◆ content()

const char * bond::blob::content ( ) const

Pointer to the content.

◆ data()

const void * bond::blob::data ( ) const

Void pointer to the content.

◆ empty()

bool bond::blob::empty ( ) const

Check if the blob is empty (i.e. lenght == 0)

◆ end()

const_iterator bond::blob::end ( ) const

Iterator for the end of the blob.

◆ length()

uint32_t bond::blob::length ( ) const

Length of the content.

◆ range() [1/2]

blob bond::blob::range ( uint32_t  offset) const

Return a blob object for a range from the specified offset to the end of the buffer.

◆ range() [2/2]

blob bond::blob::range ( uint32_t  offset,
uint32_t  length 
) const

Return a blob object for a range of this object.

◆ size()

uint32_t bond::blob::size ( ) const

Length of the content.

◆ swap()

void bond::blob::swap ( blob src)

Swap with another blob.

Friends And Related Function Documentation

◆ blob_prolong

template<typename A >
blob blob_prolong ( blob  src,
const A &  allocator 
)
friend

Returns a blob with a copy of the data if the original one does not own the memory (i.e. constructed using raw memory), and the same blob otherwise.