1 #ifndef WIBBLE_SYS_BUFFER_H
2 #define WIBBLE_SYS_BUFFER_H
47 Data(
void* buf,
size_t size,
bool own =
true);
154 if (
size() == newSize)
172 if (
item == 0 && buf.item == 0)
174 if (
item == 0 || buf.item == 0)
176 return *
item == *buf.item;
187 if (
item == 0 && buf.item == 0)
193 return *
item < *buf.item;
205 std::ostream&
operator<<(std::ostream& o,
const Buffer& b);
Data()
Definition: buffer.h:44
int _ref
Definition: buffer.h:39
void ref() const
Increment the reference count for this object.
Definition: buffer.h:52
size_t _size
Definition: buffer.h:40
~Data()
Definition: buffer.cpp:54
bool unref() const
Decrement the reference count for this object, returning true when it reaches 0.
Definition: buffer.h:56
bool operator<(const Data &d) const
Compare the contents of two buffers.
Definition: buffer.cpp:91
void * _data
Definition: buffer.h:41
bool operator==(const Data &d) const
Compare the contents of two buffers.
Definition: buffer.cpp:79
void resize(size_t size)
Resize (enlarging or shrinking it) the buffer to ‘size’ bytes.
Definition: buffer.cpp:61
Variable-size, reference-counted memory buffer.
Definition: buffer.h:34
void resize(size_t newSize)
Resize the buffer to hold exactly the specified amount of bytes.
Definition: buffer.h:152
size_t size() const
Return the buffer size.
Definition: buffer.h:149
Buffer()
Create a 0-lenght buffer.
Definition: buffer.h:74
~Buffer()
Definition: buffer.h:127
Buffer(size_t size)
Create a buffer with the specified size.
Definition: buffer.h:77
Data * item
Definition: buffer.h:70
Buffer & operator=(const Buffer &buf)
Definition: buffer.h:132
bool operator<(const Buffer &buf) const
Compare the contents of two buffers.
Definition: buffer.h:185
Buffer(const void *buf, size_t size)
Create a buffer with a copy of the given data.
Definition: buffer.h:112
std::string print_preview(unsigned size) const
Render a c-string escaped print preview of maximum size buffer bytes.
Definition: buffer.cpp:106
void * data()
Return a pointer to the buffer.
Definition: buffer.h:143
bool operator==(const Buffer &buf) const
Compare the contents of two buffers.
Definition: buffer.h:170
const void * data() const
Return a pointer to the buffer.
Definition: buffer.h:146
bool operator!=(const Buffer &buf) const
Definition: buffer.h:179
Buffer(const Buffer &buf)
Definition: buffer.h:121
Buffer(void *buf, size_t size, bool own=true)
Create a buffer from existing data.
Definition: buffer.h:98
std::ostream & operator<<(std::ostream &o, const Buffer &b)
Definition: buffer.cpp:118