VGServer::ByteInBuffer Class Reference

ByteInBuffer is a cursor class to ByteBuffer implementing extraction functions used in the graph client parser to securely access the byte blob returned by the server. More...

#include <ByteInBuffer.h>

List of all members.

Public Member Functions

 ByteInBuffer (const ByteInBuffer &o)
 copy constructor: create a new duplicate object.
 ByteInBuffer (const ByteBuffer &_buff)
 create a new cursor object
void check_available (unsigned int n) const
 throws a std::underflow_error unless n bytes are available at the cursor
size_t cursor () const
 return the current cursor position
bool cursor_available (unsigned int n) const
 check that n bytes are available after the cursor
template<typename Tp>
Tp fetch ()
 fetch a single item of the template type Tp from the buffer, advancing the cursor.
unsigned char fetch_unsigned_char ()
unsigned int fetch_unsigned_int ()
unsigned short fetch_unsigned_short ()
void fetchAnyType (class AnyType &v)
 fetch an AnyType value at the current position, the type to fetch must be set previously.
void fetchBytes (ByteBuffer &dest, unsigned int len)
 fetch a number of bytes from the buffer
void fetchBytes (char *dest, unsigned int len)
 fetch a number of bytes from the buffer
std::string fetchLongString ()
 fetch a long string prefixed by an unsigned int.
std::string fetchString ()
 fetch a short string prefixed by an unsigned char.
size_t remaining () const
 return the number of bytes remaining after the cursor
void rewind ()
 reset the cursor


Detailed Description

ByteInBuffer is a cursor class to ByteBuffer implementing extraction functions used in the graph client parser to securely access the byte blob returned by the server.

Definition at line 21 of file ByteInBuffer.h.


Constructor & Destructor Documentation

VGServer::ByteInBuffer::ByteInBuffer ( const ByteBuffer _buff  )  [inline]

create a new cursor object

Definition at line 39 of file ByteInBuffer.h.

VGServer::ByteInBuffer::ByteInBuffer ( const ByteInBuffer o  )  [inline]

copy constructor: create a new duplicate object.

Definition at line 46 of file ByteInBuffer.h.


Member Function Documentation

void VGServer::ByteInBuffer::check_available ( unsigned int  n  )  const [inline]

throws a std::underflow_error unless n bytes are available at the cursor

Definition at line 70 of file ByteInBuffer.h.

References cursor_available().

Referenced by fetch(), fetchBytes(), fetchLongString(), and fetchString().

size_t VGServer::ByteInBuffer::cursor (  )  const [inline]

return the current cursor position

Definition at line 58 of file ByteInBuffer.h.

bool VGServer::ByteInBuffer::cursor_available ( unsigned int  n  )  const [inline]

check that n bytes are available after the cursor

Definition at line 66 of file ByteInBuffer.h.

References VGServer::ByteBuffer::size().

Referenced by check_available().

template<typename Tp>
Tp VGServer::ByteInBuffer::fetch (  )  [inline]

fetch a single item of the template type Tp from the buffer, advancing the cursor.

Be careful with implicit type conversions!

Definition at line 76 of file ByteInBuffer.h.

References check_available(), and VGServer::ByteBuffer::data().

unsigned char VGServer::ByteInBuffer::fetch_unsigned_char (  )  [inline]

Definition at line 89 of file ByteInBuffer.h.

Referenced by VGServer::GraphParser< Callback >::parse().

unsigned int VGServer::ByteInBuffer::fetch_unsigned_int (  )  [inline]

Definition at line 95 of file ByteInBuffer.h.

Referenced by VGServer::GraphParser< Callback >::parse().

unsigned short VGServer::ByteInBuffer::fetch_unsigned_short (  )  [inline]

Definition at line 92 of file ByteInBuffer.h.

void VGServer::ByteInBuffer::fetchAnyType ( class AnyType v  ) 

fetch an AnyType value at the current position, the type to fetch must be set previously.

Definition at line 11 of file ByteInBuffer.cc.

References VGServer::ATTRTYPE_BOOL, VGServer::ATTRTYPE_BYTE, VGServer::ATTRTYPE_CHAR, VGServer::ATTRTYPE_DOUBLE, VGServer::ATTRTYPE_DWORD, VGServer::ATTRTYPE_FLOAT, VGServer::ATTRTYPE_INTEGER, VGServer::ATTRTYPE_INVALID, VGServer::ATTRTYPE_LONG, VGServer::ATTRTYPE_LONGSTRING, VGServer::ATTRTYPE_QWORD, VGServer::ATTRTYPE_SHORT, VGServer::ATTRTYPE_STRING, VGServer::ATTRTYPE_WORD, fetchLongString(), and fetchString().

void VGServer::ByteInBuffer::fetchBytes ( ByteBuffer dest,
unsigned int  len 
) [inline]

fetch a number of bytes from the buffer

Definition at line 132 of file ByteInBuffer.h.

References VGServer::ByteBuffer::assign_copy(), check_available(), and VGServer::ByteBuffer::data().

void VGServer::ByteInBuffer::fetchBytes ( char *  dest,
unsigned int  len 
) [inline]

fetch a number of bytes from the buffer

Definition at line 123 of file ByteInBuffer.h.

References check_available(), and VGServer::ByteBuffer::data().

std::string VGServer::ByteInBuffer::fetchLongString (  )  [inline]

fetch a long string prefixed by an unsigned int.

Definition at line 111 of file ByteInBuffer.h.

References check_available(), and VGServer::ByteBuffer::data().

Referenced by fetchAnyType().

std::string VGServer::ByteInBuffer::fetchString (  )  [inline]

fetch a short string prefixed by an unsigned char.

Definition at line 99 of file ByteInBuffer.h.

References check_available(), and VGServer::ByteBuffer::data().

Referenced by fetchAnyType(), and VGServer::GraphParser< Callback >::parse().

size_t VGServer::ByteInBuffer::remaining (  )  const [inline]

return the number of bytes remaining after the cursor

Definition at line 62 of file ByteInBuffer.h.

References VGServer::ByteBuffer::size().

Referenced by VGServer::GraphParser< Callback >::parse().

void VGServer::ByteInBuffer::rewind (  )  [inline]

reset the cursor

Definition at line 54 of file ByteInBuffer.h.


The documentation for this class was generated from the following files:
Generated on Wed Sep 27 14:34:01 2006 for VGServer by  doxygen 1.4.7