Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | List of all members
databuf< T > Struct Template Reference

template implementation of buffers (networking e.g.). More...

#include <buffer_types.hpp>

Inheritance diagram for databuf< T >:
packetbuf

Public Types

enum  { OVERREAD = 1<<0, OVERWROTE = 1<<1 }
 buffer missuse flags. More...
 

Public Member Functions

 databuf ()
 
template<class U >
 databuf (T *buf, U maxlen)
 
void reset ()
 
void reset (T *buf_, int maxlen_)
 
const T & get ()
 get one byte from the buffer and More...
 
databuf subbuf (int sz)
 create a sub buffer copy from this buffer (from the current position) More...
 
T * pad (int numvals)
 
void put (const T &val)
 put one element at the end of the buffer. More...
 
void put (const T *vals, int numvals)
 put a given number of elements at the end of the buffer. More...
 
int get (T *vals, int numvals)
 receive the given amount of elements from the buffer to given array. More...
 
void offset (int n)
 skip the first n elemnts of the buffer. More...
 
T * getbuf () const
 
bool empty () const
 
int length () const
 receive amount of values in buffer. More...
 
int remaining () const
 receive remaining space in buffer. More...
 
bool overread () const
 did we try to read too much? More...
 
bool overwrote () const
 did we try to write too much into the buffer? More...
 
bool check (int n)
 
void forceoverread ()
 force buffer to skip all free memory space More...
 

Public Attributes

T * buf
 the pointer to the data. More...
 
int len
 
int maxlen
 
uchar flags
 

Detailed Description

template<class T>
struct databuf< T >

template implementation of buffers (networking e.g.).

work like streams: you put stuff at the end, you get stuff from the end

Member Enumeration Documentation

template<class T>
anonymous enum

buffer missuse flags.

Enumerator
OVERREAD 
OVERWROTE 

Constructor & Destructor Documentation

template<class T>
databuf< T >::databuf ( )
inline

Referenced by databuf< T >::subbuf().

template<class T>
template<class U >
databuf< T >::databuf ( T *  buf,
maxlen 
)
inline

Member Function Documentation

template<class T>
bool databuf< T >::check ( int  n)
inline

References databuf< T >::remaining().

Referenced by gle::attrib().

template<class T>
bool databuf< T >::empty ( ) const
inline
template<class T>
void databuf< T >::forceoverread ( )
inline

force buffer to skip all free memory space

References databuf< T >::flags, databuf< T >::len, databuf< T >::maxlen, and databuf< T >::OVERREAD.

template<class T>
const T& databuf< T >::get ( )
inline
template<class T>
int databuf< T >::get ( T *  vals,
int  numvals 
)
inline

receive the given amount of elements from the buffer to given array.

References databuf< T >::buf, databuf< T >::flags, databuf< T >::len, databuf< T >::maxlen, inexor::rpc::min(), and databuf< T >::OVERREAD.

template<class T>
T* databuf< T >::getbuf ( ) const
inline

References databuf< T >::buf.

Referenced by gle::end().

template<class T>
int databuf< T >::length ( ) const
inline
template<class T>
void databuf< T >::offset ( int  n)
inline
template<class T>
bool databuf< T >::overread ( ) const
inline
template<class T>
bool databuf< T >::overwrote ( ) const
inline

did we try to write too much into the buffer?

References databuf< T >::flags, and databuf< T >::OVERWROTE.

template<class T>
T* databuf< T >::pad ( int  numvals)
inline
template<class T>
void databuf< T >::put ( const T &  val)
inline
template<class T>
void databuf< T >::put ( const T *  vals,
int  numvals 
)
inline

put a given number of elements at the end of the buffer.

References databuf< T >::buf, databuf< T >::flags, databuf< T >::len, databuf< T >::maxlen, inexor::rpc::min(), and databuf< T >::OVERWROTE.

template<class T>
int databuf< T >::remaining ( ) const
inline
template<class T>
void databuf< T >::reset ( )
inline
template<class T>
void databuf< T >::reset ( T *  buf_,
int  maxlen_ 
)
inline
template<class T>
databuf databuf< T >::subbuf ( int  sz)
inline

create a sub buffer copy from this buffer (from the current position)

References databuf< T >::buf, databuf< T >::databuf(), databuf< T >::len, and databuf< T >::maxlen.

Referenced by game::parsemessages(), and packetbuf::subbuf().

Member Data Documentation

template<class T>
T* databuf< T >::buf
template<class T>
uchar databuf< T >::flags
template<class T>
int databuf< T >::len
template<class T>
int databuf< T >::maxlen

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