WvStreams
Public Member Functions | Protected Types | Protected Attributes | List of all members
WvInPlaceBufBase< T > Class Template Reference

A buffer that wraps a pre-allocated array and provides read-write access to its elements. More...

#include <wvbufbase.h>

Inheritance diagram for WvInPlaceBufBase< T >:
Inheritance graph
[legend]

Public Member Functions

 WvInPlaceBufBase (T *_data, size_t _avail, size_t _size, bool _autofree=false)
 Creates a new buffer backed by the supplied array. More...
 
 WvInPlaceBufBase (size_t _size)
 Creates a new empty buffer backed by a new array. More...
 
 WvInPlaceBufBase ()
 Creates a new empty buffer with no backing array.
 
virtual ~WvInPlaceBufBase ()
 Destroys the buffer. More...
 
T * ptr () const
 Returns the underlying array pointer. More...
 
size_t size () const
 Returns the total size of the buffer. More...
 
bool get_autofree () const
 Returns the autofree flag. More...
 
void set_autofree (bool _autofree)
 Sets or clears the autofree flag. More...
 
void reset (T *_data, size_t _avail, size_t _size, bool _autofree=false)
 Resets the underlying buffer pointer and properties. More...
 
void setavail (size_t _avail)
 Sets the amount of available data using the current buffer and resets the read index to the beginning of the buffer. More...
 

Protected Types

typedef T Elem
 

Protected Attributes

WvInPlaceBufStore mystore
 

Detailed Description

template<class T>
class WvInPlaceBufBase< T >

A buffer that wraps a pre-allocated array and provides read-write access to its elements.

"T" is the type of object to store, must be a primitive or a struct without special initialization, copy, or assignment semantics

Definition at line 603 of file wvbufbase.h.

Constructor & Destructor Documentation

◆ WvInPlaceBufBase() [1/2]

template<class T >
WvInPlaceBufBase< T >::WvInPlaceBufBase ( T *  _data,
size_t  _avail,
size_t  _size,
bool  _autofree = false 
)
inline

Creates a new buffer backed by the supplied array.

"_data" is the array of data to wrap "_avail" is the amount of data available for reading "_size" is the size of the array "_autofree" is if true, the array will be freed when discarded

Definition at line 619 of file wvbufbase.h.

◆ WvInPlaceBufBase() [2/2]

template<class T >
WvInPlaceBufBase< T >::WvInPlaceBufBase ( size_t  _size)
inlineexplicit

Creates a new empty buffer backed by a new array.

"_size" is the size of the array

Definition at line 630 of file wvbufbase.h.

◆ ~WvInPlaceBufBase()

template<class T >
virtual WvInPlaceBufBase< T >::~WvInPlaceBufBase ( )
inlinevirtual

Destroys the buffer.

Frees the underlying array if autofree().

Definition at line 645 of file wvbufbase.h.

Member Function Documentation

◆ ptr()

template<class T >
T* WvInPlaceBufBase< T >::ptr ( ) const
inline

Returns the underlying array pointer.

Returns: the element pointer

Definition at line 652 of file wvbufbase.h.

◆ size()

template<class T >
size_t WvInPlaceBufBase< T >::size ( ) const
inline

Returns the total size of the buffer.

Returns: the number of elements

Definition at line 662 of file wvbufbase.h.

◆ get_autofree()

template<class T >
bool WvInPlaceBufBase< T >::get_autofree ( ) const
inline

Returns the autofree flag.

Returns: the autofree flag

Definition at line 672 of file wvbufbase.h.

◆ set_autofree()

template<class T >
void WvInPlaceBufBase< T >::set_autofree ( bool  _autofree)
inline

Sets or clears the autofree flag.

"_autofree" is if true, the array will be freed when discarded

Definition at line 682 of file wvbufbase.h.

◆ reset()

template<class T >
void WvInPlaceBufBase< T >::reset ( T *  _data,
size_t  _avail,
size_t  _size,
bool  _autofree = false 
)
inline

Resets the underlying buffer pointer and properties.

If the old and new buffer pointers differ and the old buffer was specified as autofree, the old buffer is destroyed.

"_data" is the array of data to wrap "_avail" is the amount of data available for reading "_size" is the size of the array "_autofree" is if true, the array will be freed when discarded

Definition at line 698 of file wvbufbase.h.

◆ setavail()

template<class T >
void WvInPlaceBufBase< T >::setavail ( size_t  _avail)
inline

Sets the amount of available data using the current buffer and resets the read index to the beginning of the buffer.

"_avail" is the amount of data available for reading

Definition at line 711 of file wvbufbase.h.


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