Variable-size, reference-counted memory buffer. More...
#include <buffer.h>
Classes | |
| class | Data |
Public Member Functions | |
| 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 () | |
| Buffer & | operator= (const Buffer &buf) |
| void * | data () throw () |
| Return a pointer to the buffer. | |
| const void * | data () 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. | |
Public Attributes | |
| Data * | item |
Variable-size, reference-counted memory buffer.
| wibble::sys::Buffer::Buffer | ( | ) | throw () [inline] |
Create a 0-lenght buffer.
| wibble::sys::Buffer::Buffer | ( | size_t | size | ) | [inline] |
Create a buffer with the specified size.
References item, and wibble::sys::Buffer::Data::ref().
| wibble::sys::Buffer::Buffer | ( | void * | buf, | |
| size_t | size, | |||
| bool | own = true | |||
| ) | [inline] |
Create a buffer from existing data.
| buf | The data to put in this buffer | |
| size | The dimension of buf | |
| own | If true, take ownership of buf, else make a copy of it. |
References item, and wibble::sys::Buffer::Data::ref().
| wibble::sys::Buffer::Buffer | ( | const void * | buf, | |
| size_t | size | |||
| ) | [inline] |
Create a buffer with a copy of the given data.
It will always make a copy of the contents of buf.
References item, and wibble::sys::Buffer::Data::ref().
| wibble::sys::Buffer::~Buffer | ( | ) | [inline] |
References item, and wibble::sys::Buffer::Data::unref().
| const void* wibble::sys::Buffer::data | ( | ) | const throw () [inline] |
Return a pointer to the buffer.
References wibble::sys::Buffer::Data::_data, and item.
| void* wibble::sys::Buffer::data | ( | ) | throw () [inline] |
Return a pointer to the buffer.
References wibble::sys::Buffer::Data::_data, and item.
Referenced by wibble::sys::NetBuffer::cast(), TestBuffer::copy(), wibble::sys::NetBuffer::data(), TestBuffer::emptiness(), TestBuffer::nonemptiness(), TestBuffer::resize(), and TestBuffer::takeover().
| bool wibble::sys::Buffer::operator!= | ( | const Buffer & | buf | ) | const throw () [inline] |
References operator==().
| bool wibble::sys::Buffer::operator< | ( | const Buffer & | buf | ) | const throw () [inline] |
Compare the contents of two buffers.
References item.
Reimplemented in wibble::sys::NetBuffer.
References item, wibble::sys::Buffer::Data::ref(), and wibble::sys::Buffer::Data::unref().
| bool wibble::sys::Buffer::operator== | ( | const Buffer & | buf | ) | const throw () [inline] |
| void wibble::sys::Buffer::resize | ( | size_t | newSize | ) | [inline] |
Resize the buffer to hold exactly the specified amount of bytes.
References item, wibble::sys::Buffer::Data::ref(), wibble::sys::Buffer::Data::resize(), size(), and wibble::sys::Buffer::Data::unref().
Referenced by TestBuffer::resize().
| size_t wibble::sys::Buffer::size | ( | ) | const throw () [inline] |
Return the buffer size.
Reimplemented in wibble::sys::NetBuffer.
References wibble::sys::Buffer::Data::_size, and item.
Referenced by TestBuffer::copy(), TestBuffer::emptiness(), TestBuffer::nonemptiness(), TestBuffer::resize(), resize(), and TestBuffer::takeover().
Referenced by Buffer(), data(), operator<(), operator=(), operator==(), resize(), size(), and ~Buffer().
1.6.3