wibble 1.1
Public Member Functions | Public Attributes | List of all members
wibble::sys::NetBuffer Class Reference

Buffer whose starting can be moved back and forth, useful to decapsulate stacked network packets. More...

#include <netbuffer.h>

Inheritance diagram for wibble::sys::NetBuffer:
Inheritance graph
[legend]
Collaboration diagram for wibble::sys::NetBuffer:
Collaboration graph
[legend]

Public Member Functions

 NetBuffer () throw ()
 
 NetBuffer (size_t size)
 
 NetBuffer (void *buf, size_t size, bool own=true)
 
 NetBuffer (const void *buf, size_t size)
 
 NetBuffer (const Buffer &buf) throw ()
 
 NetBuffer (const NetBuffer &buf) throw ()
 
NetBufferoperator= (const Buffer &buf)
 
NetBufferoperator= (const NetBuffer &buf)
 
const voiddata (size_t ofs=0) const throw ()
 Return a pointer to the buffer.
 
voiddata (size_t ofs=0) throw ()
 Return a pointer to the buffer.
 
size_t size () const throw ()
 Return the buffer size.
 
template<class T >
bool fits (size_t ofs=0) const throw ()
 Check if the buffer is long enough to contain a structure T at the given offset.
 
template<class T >
const T * cast (size_t ofs=0) const
 Access the buffer contents as a structure T at the given offset.
 
NetBuffer operator+ (size_t ofs)
 Return another NetBuffer starting ofs bytes from the beginning of this one.
 
const NetBuffer after (size_t ofs) const
 Return another NetBuffer starting ofs bytes from the beginning of this one.
 
template<class T >
const NetBuffer after () const
 Return another NetBuffer starting just after sizeof(T) from the beginning of this one.
 
NetBufferoperator+= (size_t ofs)
 Move the starting point of this buffer ofs bytes from the beginning.
 
template<class T >
void skip ()
 Move the starting point of this buffer sizeof(T) bytes from the beginning.
 
void skip (size_t t)
 Move the starting point of this buffer ofs bytes from the beginning.
 
- Public Member Functions inherited from wibble::sys::Buffer
 Buffer () throw ()
 Create a 0-lenght buffer.
 
 Buffer (size_t size)
 Create a buffer with the specified size.
 
 Buffer (void *buf, size_t size, bool own=true)
 Create a buffer from existing data.
 
 Buffer (const void *buf, size_t size)
 Create a buffer with a copy of the given data.
 
 Buffer (const Buffer &buf) throw ()
 
 ~Buffer ()
 
Bufferoperator= (const Buffer &buf)
 
voiddata () throw ()
 Return a pointer to the buffer.
 
const voiddata () const throw ()
 Return a pointer to the buffer.
 
size_t size () const throw ()
 Return the buffer size.
 
void resize (size_t newSize)
 Resize the buffer to hold exactly the specified amount of bytes.
 
bool operator== (const Buffer &buf) const throw ()
 Compare the contents of two buffers.
 
bool operator!= (const Buffer &buf) const throw ()
 
bool operator< (const Buffer &buf) const throw ()
 Compare the contents of two buffers.
 
std::string print_preview (unsigned size) const
 Render a c-string escaped print preview of maximum size buffer bytes.
 

Public Attributes

size_t cursor
 Offset in bytes of the NetBuffer start, from the beginning of the memory area we manage.
 
- Public Attributes inherited from wibble::sys::Buffer
Dataitem
 

Detailed Description

Buffer whose starting can be moved back and forth, useful to decapsulate stacked network packets.

Constructor & Destructor Documentation

◆ NetBuffer() [1/6]

wibble::sys::NetBuffer::NetBuffer ( )
throw (
)
inline

◆ NetBuffer() [2/6]

wibble::sys::NetBuffer::NetBuffer ( size_t  size)
inline

◆ NetBuffer() [3/6]

wibble::sys::NetBuffer::NetBuffer ( void buf,
size_t  size,
bool  own = true 
)
inline

◆ NetBuffer() [4/6]

wibble::sys::NetBuffer::NetBuffer ( const void buf,
size_t  size 
)
inline

◆ NetBuffer() [5/6]

wibble::sys::NetBuffer::NetBuffer ( const Buffer buf)
throw (
)
inline

◆ NetBuffer() [6/6]

wibble::sys::NetBuffer::NetBuffer ( const NetBuffer buf)
throw (
)
inline

Member Function Documentation

◆ after() [1/2]

template<class T >
const NetBuffer wibble::sys::NetBuffer::after ( ) const
inline

Return another NetBuffer starting just after sizeof(T) from the beginning of this one.

References skip().

Referenced by operator+().

◆ after() [2/2]

const NetBuffer wibble::sys::NetBuffer::after ( size_t  ofs) const
inline

Return another NetBuffer starting ofs bytes from the beginning of this one.

References skip().

Referenced by TestNetBuffer::skipBytes().

◆ cast()

template<class T >
const T * wibble::sys::NetBuffer::cast ( size_t  ofs = 0) const
inline

Access the buffer contents as a structure T at the given offset.

References cursor, wibble::sys::Buffer::data(), and size().

Referenced by TestNetBuffer::startAtBeginning().

◆ data() [1/2]

void * wibble::sys::NetBuffer::data ( size_t  ofs = 0)
throw (
)
inline

Return a pointer to the buffer.

References cursor, and wibble::sys::Buffer::data().

◆ data() [2/2]

const void * wibble::sys::NetBuffer::data ( size_t  ofs = 0) const
throw (
)
inline

Return a pointer to the buffer.

References cursor, and wibble::sys::Buffer::data().

Referenced by TestNetBuffer::startAtBeginning().

◆ fits()

template<class T >
bool wibble::sys::NetBuffer::fits ( size_t  ofs = 0) const
throw (
)
inline

Check if the buffer is long enough to contain a structure T at the given offset.

References cursor, and size().

Referenced by TestNetBuffer::startAtBeginning().

◆ operator+()

NetBuffer wibble::sys::NetBuffer::operator+ ( size_t  ofs)
inline

Return another NetBuffer starting ofs bytes from the beginning of this one.

References after().

◆ operator+=()

NetBuffer & wibble::sys::NetBuffer::operator+= ( size_t  ofs)
inline

Move the starting point of this buffer ofs bytes from the beginning.

References skip().

◆ operator=() [1/2]

NetBuffer & wibble::sys::NetBuffer::operator= ( const Buffer buf)
inline

◆ operator=() [2/2]

NetBuffer & wibble::sys::NetBuffer::operator= ( const NetBuffer buf)
inline

◆ size()

size_t wibble::sys::NetBuffer::size ( ) const
throw (
)
inline

Return the buffer size.

References cursor, and wibble::sys::Buffer::size().

Referenced by cast(), fits(), skip(), and TestNetBuffer::startAtBeginning().

◆ skip() [1/2]

template<class T >
void wibble::sys::NetBuffer::skip ( )
inline

Move the starting point of this buffer sizeof(T) bytes from the beginning.

References skip().

Referenced by after(), after(), operator+=(), and skip().

◆ skip() [2/2]

void wibble::sys::NetBuffer::skip ( size_t  t)
inline

Move the starting point of this buffer ofs bytes from the beginning.

References cursor, and size().

Member Data Documentation

◆ cursor

size_t wibble::sys::NetBuffer::cursor

Offset in bytes of the NetBuffer start, from the beginning of the memory area we manage.

Referenced by cast(), data(), data(), fits(), operator=(), operator=(), size(), and skip().


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