STXXL
1.4-dev
|
binary_buffer represents a dynamically growable area of memory, which can be modified by appending integral data types via put() and other basic operations.
Definition at line 41 of file binary_buffer.h.
Public Member Functions | |
binary_buffer () | |
Create a new empty object. More... | |
binary_buffer (const binary_buffer &other) | |
Copy-Constructor, duplicates memory content. More... | |
binary_buffer (const void *data, size_t n) | |
Constructor, copy memory area. More... | |
binary_buffer (size_t n) | |
Constructor, create object with n bytes pre-allocated. More... | |
binary_buffer (const std::string &str) | |
Constructor from std::string, copies string content. More... | |
~binary_buffer () | |
Destroys the memory space. More... | |
binary_buffer & | align (size_t n) |
Align the size of the buffer to a multiple of n. Fills up with 0s. More... | |
binary_buffer & | alloc (size_t n) |
Make sure that at least n bytes are allocated. More... | |
binary_buffer & | append (const void *data, size_t len) |
Append a memory range to the buffer. More... | |
binary_buffer & | append (const class binary_buffer &bb) |
Append the contents of a different buffer object to this one. More... | |
binary_buffer & | append (const std::string &s) |
Append to contents of a std::string, excluding the null (which isn't contained in the string size anyway). More... | |
binary_buffer & | assign (const void *data, size_t len) |
Copy a memory range into the buffer, overwrites all current data. Roughly equivalent to clear() followed by append(). More... | |
binary_buffer & | assign (const binary_buffer &other) |
Copy the contents of another buffer object into this buffer, overwrites all current data. Roughly equivalent to clear() followed by append(). More... | |
size_t | capacity () const |
Return the currently allocated buffer capacity. More... | |
binary_buffer & | clear () |
Clears the memory contents, does not deallocate the memory. More... | |
const char * | data () const |
Return a pointer to the currently kept memory area. More... | |
char * | data () |
Return a writeable pointer to the currently kept memory area. More... | |
binary_buffer & | dealloc () |
Deallocates the kept memory space (we use dealloc() instead of free() as a name, because sometimes "free" is replaced by the preprocessor) More... | |
const char * | detach () |
Detach the memory from the object, returns the memory pointer. More... | |
binary_buffer & | dynalloc (size_t n) |
Dynamically allocate more memory. At least n bytes will be available, probably more to compensate future growth. More... | |
binary_buffer & | operator= (const binary_buffer &other) |
Assignment operator: copy other's memory range into buffer. More... | |
template<typename Type > | |
binary_buffer & | put (const Type item) |
Put (append) a single item of the template type T to the buffer. Be careful with implicit type conversions! More... | |
binary_buffer & | put_string (const char *data, size_t len) |
Put a string by saving it's length followed by the data itself. More... | |
binary_buffer & | put_string (const std::string &str) |
Put a string by saving it's length followed by the data itself. More... | |
binary_buffer & | put_string (const binary_buffer &bb) |
Put a binary_buffer by saving it's length followed by the data itself. More... | |
binary_buffer & | put_varint (uint32 v) |
Append a varint to the buffer. More... | |
binary_buffer & | put_varint (int v) |
Append a varint to the buffer. More... | |
binary_buffer & | put_varint (uint64 v) |
Append a varint to the buffer. More... | |
binary_buffer & | set_size (size_t n) |
Set the valid bytes in the buffer, use if the buffer is filled directly. More... | |
size_t | size () const |
Return the currently used length in bytes. More... | |
std::string | str () const |
Explicit conversion to std::string (copies memory of course). More... | |
Protected Attributes | |
size_t | m_capacity |
Total capacity of buffer. More... | |
char * | m_data |
Allocated buffer pointer. More... | |
size_t | m_size |
Size of valid data. More... | |
|
inline |
Create a new empty object.
Definition at line 55 of file binary_buffer.h.
|
inline |
Copy-Constructor, duplicates memory content.
Definition at line 60 of file binary_buffer.h.
|
inline |
Constructor, copy memory area.
Definition at line 67 of file binary_buffer.h.
|
inline |
Constructor, create object with n bytes pre-allocated.
Definition at line 74 of file binary_buffer.h.
|
inline |
Constructor from std::string, copies string content.
Definition at line 81 of file binary_buffer.h.
|
inline |
Destroys the memory space.
Definition at line 88 of file binary_buffer.h.
|
inline |
Align the size of the buffer to a multiple of n. Fills up with 0s.
Definition at line 204 of file binary_buffer.h.
|
inline |
Make sure that at least n bytes are allocated.
Definition at line 134 of file binary_buffer.h.
References realloc().
|
inline |
Append a memory range to the buffer.
Definition at line 244 of file binary_buffer.h.
Referenced by put_string().
|
inline |
Append the contents of a different buffer object to this one.
Definition at line 255 of file binary_buffer.h.
|
inline |
Append to contents of a std::string, excluding the null (which isn't contained in the string size anyway).
Definition at line 262 of file binary_buffer.h.
|
inline |
Copy a memory range into the buffer, overwrites all current data. Roughly equivalent to clear() followed by append().
Definition at line 174 of file binary_buffer.h.
|
inline |
|
inline |
Return the currently allocated buffer capacity.
Definition at line 112 of file binary_buffer.h.
|
inline |
Clears the memory contents, does not deallocate the memory.
Definition at line 166 of file binary_buffer.h.
|
inline |
Return a pointer to the currently kept memory area.
Definition at line 94 of file binary_buffer.h.
Referenced by append(), assign(), operator=(), and put_string().
|
inline |
Return a writeable pointer to the currently kept memory area.
Definition at line 100 of file binary_buffer.h.
|
inline |
Deallocates the kept memory space (we use dealloc() instead of free() as a name, because sometimes "free" is replaced by the preprocessor)
Definition at line 147 of file binary_buffer.h.
References free().
|
inline |
Detach the memory from the object, returns the memory pointer.
Definition at line 157 of file binary_buffer.h.
|
inline |
Dynamically allocate more memory. At least n bytes will be available, probably more to compensate future growth.
Definition at line 222 of file binary_buffer.h.
|
inline |
Assignment operator: copy other's memory range into buffer.
Definition at line 195 of file binary_buffer.h.
|
inline |
Put (append) a single item of the template type T to the buffer. Be careful with implicit type conversions!
Definition at line 270 of file binary_buffer.h.
|
inline |
Put a string by saving it's length followed by the data itself.
Definition at line 401 of file binary_buffer.h.
References append().
|
inline |
Put a string by saving it's length followed by the data itself.
Definition at line 407 of file binary_buffer.h.
|
inline |
Put a binary_buffer by saving it's length followed by the data itself.
Definition at line 413 of file binary_buffer.h.
|
inline |
Append a varint to the buffer.
Definition at line 281 of file binary_buffer.h.
|
inline |
Append a varint to the buffer.
Definition at line 313 of file binary_buffer.h.
|
inline |
Append a varint to the buffer.
Definition at line 319 of file binary_buffer.h.
|
inline |
Set the valid bytes in the buffer, use if the buffer is filled directly.
Definition at line 125 of file binary_buffer.h.
|
inline |
Return the currently used length in bytes.
Definition at line 106 of file binary_buffer.h.
Referenced by append(), assign(), operator=(), and put_string().
|
inline |
Explicit conversion to std::string (copies memory of course).
Definition at line 118 of file binary_buffer.h.
|
protected |
Total capacity of buffer.
Definition at line 51 of file binary_buffer.h.
|
protected |
Allocated buffer pointer.
Definition at line 45 of file binary_buffer.h.
|
protected |
Size of valid data.
Definition at line 48 of file binary_buffer.h.