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:
[legend]
Collaboration diagram for wibble::sys::NetBuffer:
[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 ()
NetBuffer & | operator= (const Buffer &buf)
NetBuffer & | operator= (const NetBuffer &buf)
const void * | data (size_t ofs=0) const throw ()
| Return a pointer to the buffer. More...
void * | data (size_t ofs=0) throw ()
| Return a pointer to the buffer. More...
size_t | size () const throw ()
| Return the buffer size. More...
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. More...
template<class T >
const T * | cast (size_t ofs=0) const throw (wibble::exception::Consistency)
| Access the buffer contents as a structure T at the given offset. More...
NetBuffer | operator+ (size_t ofs) throw (wibble::exception::Consistency)
| Return another NetBuffer starting ofs bytes from the beginning of this one. More...
const NetBuffer | after (size_t ofs) const throw (wibble::exception::Consistency)
| Return another NetBuffer starting ofs bytes from the beginning of this one. More...
template<class T >
const NetBuffer | after () const throw (wibble::exception::Consistency)
| Return another NetBuffer starting just after sizeof(T) from the beginning of this one. More...
NetBuffer & | operator+= (size_t ofs) throw (wibble::exception::Consistency)
| Move the starting point of this buffer ofs bytes from the beginning. More...
template<class T >
void | skip () throw (wibble::exception::Consistency)
| Move the starting point of this buffer sizeof(T) bytes from the beginning. More...
void | skip (size_t t) throw (wibble::exception::Consistency)
| Move the starting point of this buffer ofs bytes from the beginning. More...
Public Member Functions inherited from wibble::sys::Buffer
| Buffer () throw ()
| Create a 0-lenght buffer. More...
| Buffer (size_t size)
| Create a buffer with the specified size. More...
| Buffer (void *buf, size_t size, bool own=true)
| Create a buffer from existing data. More...
| Buffer (const void *buf, size_t size)
| Create a buffer with a copy of the given data. More...
| Buffer (const Buffer &buf) throw ()
| ~Buffer ()
Buffer & | operator= (const Buffer &buf)
void * | data () throw ()
| Return a pointer to the buffer. More...
const void * | data () const throw ()
| Return a pointer to the buffer. More...
size_t | size () const throw ()
| Return the buffer size. More...
void | resize (size_t newSize)
| Resize the buffer to hold exactly the specified amount of bytes. More...
bool | operator== (const Buffer &buf) const throw ()
| Compare the contents of two buffers. More...
bool | operator!= (const Buffer &buf) const throw ()
bool | operator< (const Buffer &buf) const throw ()
| Compare the contents of two buffers. More...
std::string | print_preview (unsigned size) const
| Render a c-string escaped print preview of maximum size buffer bytes. More...

## Public Attributes

size_t | cursor
| Offset in bytes of the NetBuffer start, from the beginning of the memory area we manage. More...
Public Attributes inherited from wibble::sys::Buffer
Data * | item

## Detailed Description

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

## Constructor & Destructor Documentation

wibble::sys::NetBuffer::NetBuffer | ( |  | ) |
throw | ( |
| ) |  |

inline

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

inline

wibble::sys::NetBuffer::NetBuffer | ( | void * | buf,
|  | size_t | size,
|  | bool | own = `true`
| ) |  |

inline

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

inline

wibble::sys::NetBuffer::NetBuffer | ( | const Buffer & | buf | ) |
throw | ( |
| ) |  |

inline

wibble::sys::NetBuffer::NetBuffer | ( | const NetBuffer & | buf | ) |
throw | ( |
| ) |  |

inline

## Member Function Documentation

const NetBuffer wibble::sys::NetBuffer::after | ( | size_t | ofs | ) | const
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

References skip().

Referenced by TestNetBuffer::skipBytes().

template<class T >

const NetBuffer wibble::sys::NetBuffer::after | ( |  | ) | const
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

References skip().

Referenced by operator+().

template<class T >

const T* wibble::sys::NetBuffer::cast | ( | size_t | ofs = `0` | ) | const
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

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

Referenced by TestNetBuffer::skipBytes(), and TestNetBuffer::startAtBeginning().

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

inline

Return a pointer to the buffer.

References wibble::sys::Buffer::data().

Referenced by TestNetBuffer::skipBytes(), and TestNetBuffer::startAtBeginning().

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

inline

Return a pointer to the buffer.

References wibble::sys::Buffer::data().

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 size().

Referenced by TestNetBuffer::startAtBeginning().

NetBuffer wibble::sys::NetBuffer::operator+ | ( | size_t | ofs | ) |
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

References after().

NetBuffer& wibble::sys::NetBuffer::operator+= | ( | size_t | ofs | ) |
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

References skip().

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

inline

References wibble::sys::Buffer::operator=().

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

inline

References cursor, and wibble::sys::Buffer::operator=().

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(), TestNetBuffer::skipBytes(), and TestNetBuffer::startAtBeginning().

template<class T >

void wibble::sys::NetBuffer::skip | ( |  | ) |
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

Referenced by after(), operator+=(), and TestNetBuffer::skipBytes().

void wibble::sys::NetBuffer::skip | ( | size_t | t | ) |
throw | ( | wibble::exception::Consistency
| ) |  |

inline

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

References size().

## Member Data Documentation

size_t wibble::sys::NetBuffer::cursor

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

Referenced by operator=(), and size().

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

- netbuffer.h