WvStreams
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
WvCircularBufStore Class Reference

The WvCircularBuf storage class. More...

#include <wvbufstore.h>

Inheritance diagram for WvCircularBufStore:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 WvCircularBufStore (int _granularity, void *_data, size_t _avail, size_t _size, bool _autofree)
 WvCircularBufStore (int _granularity, size_t _size)
void * ptr () const
size_t size () const
bool get_autofree () const
void set_autofree (bool _autofree)
void reset (void *_data, size_t _avail, size_t _size, bool _autofree)
void setavail (size_t _avail)
void normalize ()
virtual size_t used () const
virtual size_t optgettable () const
virtual const void * get (size_t count)
virtual void unget (size_t count)
virtual size_t ungettable () const
virtual void zap ()
virtual size_t free () const
virtual size_t optallocable () const
virtual void * alloc (size_t count)
virtual void unalloc (size_t count)
virtual size_t unallocable () const
virtual void * mutablepeek (int offset, size_t count)
virtual bool isreadable () const
virtual void skip (size_t count)
virtual size_t peekable (int offset) const
virtual size_t optpeekable (int offset) const
virtual const void * peek (int offset, size_t count)
void move (void *buf, size_t count)
void copy (void *buf, int offset, size_t count)
virtual bool iswritable () const
void put (const void *data, size_t count)
void fastput (const void *data, size_t count)
void poke (const void *data, int offset, size_t count)
virtual void merge (WvBufStore &instore, size_t count)
void basicmerge (WvBufStore &instore, size_t count)

Protected Member Functions

size_t ensurecontiguous (int offset, size_t count, bool keephistory)
 Ensures that count new bytes can be read from or written to the buffer beginning at the specified offset as one large contiguous block.
virtual bool usessubbuffers () const
 Returns true if the buffer uses subbuffers for storage.
virtual size_t numsubbuffers () const
 Returns the number of subbuffers in the buffer.
virtual WvBufStorefirstsubbuffer () const
 Returns the first subbuffer.
virtual void appendsubbuffer (WvBufStore *buffer, bool autofree)
 Appends a subbuffer to the buffer.
virtual void prependsubbuffer (WvBufStore *buffer, bool autofree)
 Prepends a subbuffer to the buffer.
virtual bool unlinksubbuffer (WvBufStore *buffer, bool allowautofree)
 Unlinks the specified subbuffer.

Static Protected Member Functions

static void compact (void *data, size_t size, size_t head, size_t count)
 Compacts an array arranged as a circular buffer such that the specified region is moved to the beginning of the array.

Protected Attributes

void * data
size_t xsize
size_t head
size_t totalused
size_t totalinit
bool xautofree
int granularity

Detailed Description

The WvCircularBuf storage class.

Definition at line 320 of file wvbufstore.h.


Member Function Documentation

size_t WvCircularBufStore::ensurecontiguous ( int  offset,
size_t  count,
bool  keephistory 
) [protected]

Ensures that count new bytes can be read from or written to the buffer beginning at the specified offset as one large contiguous block.

"offset" is the offset "count" is the number of bytes "keephistory" is if true, does not purge unget history Returns: the offset of the first available byte

Definition at line 647 of file wvbufferstore.cc.

References compact().

void WvCircularBufStore::compact ( void *  data,
size_t  size,
size_t  head,
size_t  count 
) [static, protected]

Compacts an array arranged as a circular buffer such that the specified region is moved to the beginning of the array.

"data" is the array base "size" is the size of the array "head" is the beginning of the region to keep "count" is the number of bytes in the region to keep

Definition at line 684 of file wvbufferstore.cc.

References MemOps::deletearray(), MemOps::newarray(), MemOps::swap(), and MemOps::uninit_move().

Referenced by ensurecontiguous().

virtual bool WvBufStore::usessubbuffers ( ) const [inline, protected, virtual, inherited]

Returns true if the buffer uses subbuffers for storage.

Reimplemented in WvLinkedBufferStore.

Definition at line 96 of file wvbufstore.h.

virtual size_t WvBufStore::numsubbuffers ( ) const [inline, protected, virtual, inherited]

Returns the number of subbuffers in the buffer.

Reimplemented in WvLinkedBufferStore.

Definition at line 100 of file wvbufstore.h.

virtual WvBufStore* WvBufStore::firstsubbuffer ( ) const [inline, protected, virtual, inherited]

Returns the first subbuffer.

Returns: the buffer or NULL if none or not supported

Reimplemented in WvLinkedBufferStore.

Definition at line 107 of file wvbufstore.h.

virtual void WvBufStore::appendsubbuffer ( WvBufStore buffer,
bool  autofree 
) [inline, protected, virtual, inherited]

Appends a subbuffer to the buffer.

Reimplemented in WvLinkedBufferStore.

Definition at line 111 of file wvbufstore.h.

virtual void WvBufStore::prependsubbuffer ( WvBufStore buffer,
bool  autofree 
) [inline, protected, virtual, inherited]

Prepends a subbuffer to the buffer.

Reimplemented in WvLinkedBufferStore.

Definition at line 115 of file wvbufstore.h.

virtual bool WvBufStore::unlinksubbuffer ( WvBufStore buffer,
bool  allowautofree 
) [inline, protected, virtual, inherited]

Unlinks the specified subbuffer.

Only autofrees the buffer if allowautofree == true. Returns: the autofree flag for the buffer

Reimplemented in WvLinkedBufferStore.

Definition at line 123 of file wvbufstore.h.


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