Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

paged_buffer Class Reference

high-performance resizable buffer of bytes More...

#include <common.h>

List of all members.

Public Member Functions

 paged_buffer (byte_allocator &data_allocator, byte_allocator &tmp_allocator, size_t page_size)
 constructor
 ~paged_buffer ()
paged_bufferoperator<< (ub1_t symbol)
 pushes symbol to buffer
paged_bufferoperator<< (const char *x)
 pushes string to buffer
paged_bufferappend (const ub1_t *x, size_t size)
 pushes bytes to buffer
const char * persist ()
 persists paged blocks into one permanent block
const ub1_tpersist (size_t &size_)
 persists paged blocks into one permanent block
void reset ()
 persists paged blocks into one permanent block (internal allocator) if internally only one block has been allocated then class dosn't make a copy - it simply returns the pointer
size_t size () const
 calculates the size of persisted chars
byte_allocatorget_tmp_allocator ()
 shares memory resource for a while
size_t get_page_size () const
 returns page size

Private Member Functions

void add_page ()
 adds page
const ub1_t_persist (size_t &size_)
 persists paged blocks into one permanent block
const char * _persist ()
 persists paged blocks into null terminated string

Private Attributes

byte_allocator_data_allocator
 internal allocator for depot
byte_allocator_tmp_allocator
 internal allocator for data
paged_store_t _buffer
 paged buffer
size_t _size
 size of the one page of buffer
size_t _pos
 current position inside the page
ub1_t_ptr
 pointer to current page
ub1_t_primary
 head of the pages


Detailed Description

high-performance resizable buffer of bytes

Definition at line 250 of file common.h.


Constructor & Destructor Documentation

paged_buffer::paged_buffer ( byte_allocator data_allocator,
byte_allocator tmp_allocator,
size_t  page_size 
)

constructor

Parameters:
data_allocator  allocator for internal data pages
tmp_allocator  allocator for temporary needs
page_size  page size

Definition at line 316 of file common.cpp.

References _data_allocator, _primary, _ptr, _size, and byte_allocator::allocate().

paged_buffer::~paged_buffer (  ) 

Definition at line 322 of file common.cpp.


Member Function Documentation

paged_buffer & paged_buffer::operator<< ( ub1_t  symbol  )  [inline]

pushes symbol to buffer

Parameters:
symbol  input symbol

Definition at line 658 of file common.hpp.

References _pos, _ptr, _size, and add_page().

paged_buffer & paged_buffer::operator<< ( const char *  x  )  [inline]

pushes string to buffer

Parameters:
x  input string

Definition at line 671 of file common.hpp.

References _pos, _ptr, _size, and add_page().

paged_buffer & paged_buffer::append ( const ub1_t x,
size_t  size 
) [inline]

pushes bytes to buffer

Parameters:
x  input byte buffer
size  size of buffer

Definition at line 686 of file common.hpp.

References _pos, _ptr, _size, and add_page().

Referenced by buffer_loader::load(), and byte_manager::parseCharRef().

const ub1_t * paged_buffer::persist ( size_t &  size_  )  [inline]

persists paged blocks into one permanent block

Parameters:
size_  [out] the size of buffer

Definition at line 725 of file common.hpp.

References _buffer, _persist(), _pos, _primary, and base_list< T >::empty().

void paged_buffer::reset (  )  [inline]

size_t paged_buffer::size (  )  const [inline]

calculates the size of persisted chars

Definition at line 752 of file common.hpp.

References _buffer, _pos, _size, base_list< T >::begin(), base_list< T >::empty(), and base_list< T >::end().

Referenced by xml_processor::_parseCharData(), _persist(), and tokenValues().

byte_allocator & paged_buffer::get_tmp_allocator (  )  [inline]

shares memory resource for a while

Definition at line 770 of file common.hpp.

References _tmp_allocator.

Referenced by buffer_loader::load().

size_t paged_buffer::get_page_size (  )  const [inline]

returns page size

Definition at line 777 of file common.hpp.

References _size.

void paged_buffer::add_page (  )  [private]

const ub1_t * paged_buffer::_persist ( size_t &  size_  )  [private]

persists paged blocks into one permanent block

Parameters:
size_  [out] size of the buffer

Definition at line 350 of file common.cpp.

References _buffer, _pos, _primary, _size, _tmp_allocator, byte_allocator::allocate(), base_list< T >::back(), base_list< T >::begin(), base_list< T >::end(), and size().

const char * paged_buffer::_persist (  )  [private]

persists paged blocks into null terminated string

Definition at line 327 of file common.cpp.

References _buffer, _pos, _primary, _size, _tmp_allocator, byte_allocator::allocate(), base_list< T >::back(), base_list< T >::begin(), base_list< T >::end(), and size().

Referenced by persist().


Member Data Documentation

internal allocator for depot

Definition at line 323 of file common.h.

Referenced by paged_buffer().

internal allocator for data

Definition at line 324 of file common.h.

Referenced by _persist(), add_page(), and get_tmp_allocator().

paged buffer

Definition at line 325 of file common.h.

Referenced by _persist(), add_page(), persist(), reset(), and size().

size_t paged_buffer::_size [private]

size of the one page of buffer

Definition at line 326 of file common.h.

Referenced by _persist(), add_page(), append(), get_page_size(), operator<<(), paged_buffer(), and size().

size_t paged_buffer::_pos [private]

current position inside the page

Definition at line 327 of file common.h.

Referenced by _persist(), add_page(), append(), operator<<(), persist(), reset(), and size().

pointer to current page

Definition at line 328 of file common.h.

Referenced by add_page(), append(), operator<<(), paged_buffer(), and reset().

head of the pages

Definition at line 329 of file common.h.

Referenced by _persist(), paged_buffer(), persist(), and reset().


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


© Copyright Terimber 2003-.