wibble 1.1
|
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. | |
std::string | print_preview (unsigned size) const |
Render a c-string escaped print preview of maximum size buffer bytes. | |
Public Attributes | |
Data * | item |
Variable-size, reference-counted memory buffer.
|
inline |
Create a 0-lenght buffer.
|
inline |
Create a buffer with the specified size.
References item, wibble::sys::Buffer::Data::ref(), and size().
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. If we take ownership, then buf must have been allocated with malloc, since we will call free() to deallocate it. |
References item, wibble::sys::Buffer::Data::ref(), and size().
Create a buffer with a copy of the given data.
It will always make a copy of the contents of buf.
References item, wibble::sys::Buffer::Data::ref(), and size().
|
inline |
References item, and wibble::sys::Buffer::Data::unref().
|
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(), wibble::sys::NetBuffer::data(), TestBuffer::emptiness(), TestBuffer::nonemptiness(), print_preview(), TestBuffer::resize(), and TestBuffer::takeover().
Return a pointer to the buffer.
References wibble::sys::Buffer::Data::_data, and item.
References operator==().
Compare the contents of two buffers.
References item.
References item, wibble::sys::Buffer::Data::ref(), and wibble::sys::Buffer::Data::unref().
Referenced by wibble::sys::NetBuffer::operator=(), and wibble::sys::NetBuffer::operator=().
std::string wibble::sys::Buffer::print_preview | ( | unsigned | size | ) | const |
Render a c-string escaped print preview of maximum size buffer bytes.
If the buffer is longer than size, "[...]" will be appended to the result.
References wibble::str::c_escape(), data(), and size().
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().
|
inline |
Return the buffer size.
References wibble::sys::Buffer::Data::_size, and item.
Referenced by Buffer(), Buffer(), Buffer(), TestBuffer::copy(), wibble::sys::Buffer::Data::Data(), wibble::sys::Buffer::Data::Data(), wibble::sys::Buffer::Data::Data(), TestBuffer::emptiness(), TestBuffer::nonemptiness(), print_preview(), TestBuffer::resize(), resize(), wibble::sys::Buffer::Data::resize(), wibble::sys::NetBuffer::size(), and TestBuffer::takeover().
Data* wibble::sys::Buffer::item |
Referenced by Buffer(), Buffer(), Buffer(), Buffer(), data(), data(), operator<(), operator=(), operator==(), resize(), size(), and ~Buffer().