1 #ifndef WIBBLE_SYS_NETBUFFER_H
2 #define WIBBLE_SYS_NETBUFFER_H
84 bool fits(
size_t ofs = 0)
const throw ()
93 const T*
cast(
size_t ofs = 0)
const
97 return static_cast<const T*
>(
data(ofs));
Exception thrown when some consistency check fails.
Definition: exception.h:255
Variable-size, reference-counted memory buffer.
Definition: buffer.h:34
size_t size() const
Return the buffer size.
Definition: buffer.h:149
Buffer()
Create a 0-lenght buffer.
Definition: buffer.h:74
Buffer & operator=(const Buffer &buf)
Definition: buffer.h:132
void * data()
Return a pointer to the buffer.
Definition: buffer.h:143
Buffer whose starting can be moved back and forth, useful to decapsulate stacked network packets.
Definition: netbuffer.h:36
NetBuffer operator+(size_t ofs)
Return another NetBuffer starting ofs bytes from the beginning of this one.
Definition: netbuffer.h:103
NetBuffer & operator=(const NetBuffer &buf)
Definition: netbuffer.h:63
NetBuffer()
Definition: netbuffer.h:45
NetBuffer & operator=(const Buffer &buf)
Definition: netbuffer.h:56
NetBuffer(const void *buf, size_t size)
Definition: netbuffer.h:49
void skip()
Move the starting point of this buffer sizeof(T) bytes from the beginning.
Definition: netbuffer.h:144
size_t cursor
Offset in bytes of the NetBuffer start, from the beginning of the memory area we manage.
Definition: netbuffer.h:42
size_t size() const
Return the buffer size.
Definition: netbuffer.h:77
NetBuffer(const Buffer &buf)
Definition: netbuffer.h:52
const T * cast(size_t ofs=0) const
Access the buffer contents as a structure T at the given offset.
Definition: netbuffer.h:93
NetBuffer(size_t size)
Definition: netbuffer.h:46
void skip(size_t t)
Move the starting point of this buffer ofs bytes from the beginning.
Definition: netbuffer.h:152
NetBuffer & operator+=(size_t ofs)
Move the starting point of this buffer ofs bytes from the beginning.
Definition: netbuffer.h:133
NetBuffer(void *buf, size_t size, bool own=true)
Definition: netbuffer.h:47
const void * data(size_t ofs=0) const
Return a pointer to the buffer.
Definition: netbuffer.h:71
const NetBuffer after(size_t ofs) const
Return another NetBuffer starting ofs bytes from the beginning of this one.
Definition: netbuffer.h:111
const NetBuffer after() const
Return another NetBuffer starting just after sizeof(T) from the beginning of this one.
Definition: netbuffer.h:123
bool fits(size_t ofs=0) const
Check if the buffer is long enough to contain a structure T at the given offset.
Definition: netbuffer.h:84
void * data(size_t ofs=0)
Return a pointer to the buffer.
Definition: netbuffer.h:74
NetBuffer(const NetBuffer &buf)
Definition: netbuffer.h:53