NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
bm::byte_buffer< BVAlloc > Class Template Reference

Search Toolkit Book for bm::byte_buffer

Byte buffer template, extention of byte_buffer_ptr memory management. More...

#include <util/bitset/bmbuffer.h>

+ Inheritance diagram for bm::byte_buffer< BVAlloc >:
+ Collaboration diagram for bm::byte_buffer< BVAlloc >:

Public Types

typedef BVAlloc bv_allocator_type
 
typedef bv_allocator_type::block_allocator_type allocator_type
 
typedef size_t size_type
 

Public Member Functions

 byte_buffer () noexcept
 
 byte_buffer (size_t in_capacity)
 
 byte_buffer (const byte_buffer &lhs)
 
 byte_buffer (byte_buffer &&in_buf) noexcept
 Move constructor. More...
 
byte_bufferoperator= (byte_buffer &&lhs) noexcept
 Move assignment operator. More...
 
byte_bufferoperator= (const byte_buffer &lhs)
 
 ~byte_buffer ()
 
void swap (byte_buffer &other) noexcept
 swap content with another buffer More...
 
void move_from (byte_buffer &other) noexcept
 take/move content from another buffer More...
 
void release ()
 Free underlying memory. More...
 
void copy_from (const unsigned char *in_buf, size_t in_size)
 copy data from an external buffer More...
 
size_t capacity () const noexcept
 Get buffer capacity. More...
 
unsigned char * resize (size_t new_size, bool copy_content=true)
 adjust current size (buffer content preserved) More...
 
void resize_no_check (size_t new_size) noexcept
 adjust current size (no need to reallocate) More...
 
void reserve (size_t new_capacity)
 reserve new capacity (buffer content preserved) More...
 
void reinit (size_t new_capacity)
 reserve new capacity (buffer content NOT preserved, size set to 0) More...
 
void reallocate (size_t new_capacity)
 reserve new capacity (buffer content NOT preserved, size set to 0) More...
 
void optimize ()
 try to shrink the capacity to more optimal size More...
 
size_t mem_usage () const noexcept
 return memory consumtion More...
 
void free_buffer ()
 Free mmemory. More...
 
- Public Member Functions inherited from bm::byte_buffer_ptr
 byte_buffer_ptr () noexcept
 
 byte_buffer_ptr (unsigned char *in_buf, size_t in_size) noexcept
 construct byte buffer pointer More...
 
void set_buf (unsigned char *in_buf, size_t in_size) noexcept
 Set buffer pointer. More...
 
size_t size () const noexcept
 Get buffer size. More...
 
const unsigned char * buf () const noexcept
 Get read access to buffer memory. More...
 
unsigned char * data () noexcept
 Get write access to buffer memory. More...
 
const unsigned char * data () const noexcept
 const access to buffer memory More...
 
bool operator== (const byte_buffer_ptr &lhs) const noexcept
 
bool equal (const byte_buffer_ptr &lhs) const noexcept
 return true if content and size is the same More...
 

Private Member Functions

void set_buf (unsigned char *buf, size_t size)
 Override from the base class. More...
 
void allocate (size_t new_capacity)
 

Static Private Member Functions

static size_t compute_words (size_t capacity) noexcept
 compute number of words for the desired capacity More...
 

Private Attributes

size_t capacity_
 current capacity More...
 
size_t alloc_factor_
 number of blocks allocated for buffer More...
 

Additional Inherited Members

- Protected Attributes inherited from bm::byte_buffer_ptr
unsigned char * byte_buf_
 byte buffer pointer to hold data More...
 
size_t size_
 current buffer size More...
 

Detailed Description

template<typename BVAlloc>
class bm::byte_buffer< BVAlloc >

Byte buffer template, extention of byte_buffer_ptr memory management.

Definition at line 89 of file bmbuffer.h.

Member Typedef Documentation

◆ allocator_type

template<typename BVAlloc >
typedef bv_allocator_type::block_allocator_type bm::byte_buffer< BVAlloc >::allocator_type

Definition at line 93 of file bmbuffer.h.

◆ bv_allocator_type

template<typename BVAlloc >
typedef BVAlloc bm::byte_buffer< BVAlloc >::bv_allocator_type

Definition at line 92 of file bmbuffer.h.

◆ size_type

template<typename BVAlloc >
typedef size_t bm::byte_buffer< BVAlloc >::size_type

Definition at line 94 of file bmbuffer.h.

Constructor & Destructor Documentation

◆ byte_buffer() [1/4]

template<typename BVAlloc >
bm::byte_buffer< BVAlloc >::byte_buffer ( )
inlinenoexcept

Definition at line 97 of file bmbuffer.h.

◆ byte_buffer() [2/4]

template<typename BVAlloc >
bm::byte_buffer< BVAlloc >::byte_buffer ( size_t  in_capacity)
inline

Definition at line 100 of file bmbuffer.h.

◆ byte_buffer() [3/4]

template<typename BVAlloc >
bm::byte_buffer< BVAlloc >::byte_buffer ( const byte_buffer< BVAlloc > &  lhs)
inline

Definition at line 106 of file bmbuffer.h.

◆ byte_buffer() [4/4]

template<typename BVAlloc >
bm::byte_buffer< BVAlloc >::byte_buffer ( byte_buffer< BVAlloc > &&  in_buf)
inlinenoexcept

Move constructor.

Definition at line 117 of file bmbuffer.h.

◆ ~byte_buffer()

template<typename BVAlloc >
bm::byte_buffer< BVAlloc >::~byte_buffer ( )
inline

Definition at line 144 of file bmbuffer.h.

Member Function Documentation

◆ allocate()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::allocate ( size_t  new_capacity)
inlineprivate

◆ capacity()

template<typename BVAlloc >
size_t bm::byte_buffer< BVAlloc >::capacity ( void  ) const
inlinenoexcept

◆ compute_words()

template<typename BVAlloc >
static size_t bm::byte_buffer< BVAlloc >::compute_words ( size_t  capacity)
inlinestaticprivatenoexcept

compute number of words for the desired capacity

Definition at line 290 of file bmbuffer.h.

Referenced by bm::byte_buffer< bv_allocator_type >::allocate(), and bm::byte_buffer< bv_allocator_type >::optimize().

◆ copy_from()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::copy_from ( const unsigned char *  in_buf,
size_t  in_size 
)
inline

◆ free_buffer()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::free_buffer ( )
inline

◆ mem_usage()

template<typename BVAlloc >
size_t bm::byte_buffer< BVAlloc >::mem_usage ( ) const
inlinenoexcept

return memory consumtion

Definition at line 266 of file bmbuffer.h.

◆ move_from()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::move_from ( byte_buffer< BVAlloc > &  other)
inlinenoexcept

◆ operator=() [1/2]

template<typename BVAlloc >
byte_buffer& bm::byte_buffer< BVAlloc >::operator= ( byte_buffer< BVAlloc > &&  lhs)
inlinenoexcept

Move assignment operator.

Definition at line 128 of file bmbuffer.h.

◆ operator=() [2/2]

template<typename BVAlloc >
byte_buffer& bm::byte_buffer< BVAlloc >::operator= ( const byte_buffer< BVAlloc > &  lhs)
inline

Definition at line 135 of file bmbuffer.h.

◆ optimize()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::optimize ( )
inline

try to shrink the capacity to more optimal size

Definition at line 253 of file bmbuffer.h.

Referenced by SerializationBufferTest().

◆ reallocate()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::reallocate ( size_t  new_capacity)
inline

reserve new capacity (buffer content NOT preserved, size set to 0)

See also
reinit

Definition at line 247 of file bmbuffer.h.

◆ reinit()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::reinit ( size_t  new_capacity)
inline

reserve new capacity (buffer content NOT preserved, size set to 0)

Definition at line 239 of file bmbuffer.h.

Referenced by bm::byte_buffer< bv_allocator_type >::reallocate(), and SerializationBufferTest().

◆ release()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::release ( void  )
inline

Free underlying memory.

Definition at line 177 of file bmbuffer.h.

Referenced by TestCompressedCollection().

◆ reserve()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::reserve ( size_t  new_capacity)
inline

◆ resize()

template<typename BVAlloc >
unsigned char* bm::byte_buffer< BVAlloc >::resize ( size_t  new_size,
bool  copy_content = true 
)
inline

◆ resize_no_check()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::resize_no_check ( size_t  new_size)
inlinenoexcept

◆ set_buf()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::set_buf ( unsigned char *  buf,
size_t  size 
)
private

Override from the base class.

◆ swap()

template<typename BVAlloc >
void bm::byte_buffer< BVAlloc >::swap ( byte_buffer< BVAlloc > &  other)
inlinenoexcept

Member Data Documentation

◆ alloc_factor_

template<typename BVAlloc >
size_t bm::byte_buffer< BVAlloc >::alloc_factor_
private

◆ capacity_

template<typename BVAlloc >
size_t bm::byte_buffer< BVAlloc >::capacity_
private

The documentation for this class was generated from the following file:
Modified on Fri Sep 20 14:57:43 2024 by modify_doxy.py rev. 669887