Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
|
A datatype to allow an automatically growing buffer for appending data to. More...
#include <byte_buffer.h>
Public Member Functions | |
ByteBuffer * | AllocateByteBuffer (size_t initial_size) |
Allocate a ByteBuffer. More... | |
void | FreeByteBuffer (ByteBuffer *buffer_p) |
Free a ByteBuffer. More... | |
bool | ResizeByteBuffer (ByteBuffer *buffer_p, size_t new_size) |
Resize a ByteBuffer. More... | |
bool | ExtendByteBuffer (ByteBuffer *buffer_p, size_t increment) |
Increase the size of a ByteBuffer's data buffer. More... | |
bool | AppendToByteBuffer (ByteBuffer *buffer_p, const void *data_p, const size_t data_length) |
Append some data to a ByteBuffer's data buffer. More... | |
bool | AppendStringToByteBuffer (ByteBuffer *buffer_p, const char *const value_s) |
Append a string to a ByteBuffer's data buffer. More... | |
bool | AppendStringsToByteBuffer (ByteBuffer *buffer_p, const char *value_s,...) |
Append a varargs array of strings to a ByteBuffer's data buffer. More... | |
bool | AppendVarArgsToByteBuffer (ByteBuffer *buffer_p, const char *value_s, va_list args) |
Append a va_list of strings to a ByteBuffer's data buffer. More... | |
void | ResetByteBuffer (ByteBuffer *buffer_p) |
Clear any data stored in a ByteBuffer. More... | |
size_t | GetRemainingSpaceInByteBuffer (const ByteBuffer *const buffer_p) |
Get the remaining space in a ByteBuffer's data buffer. More... | |
size_t | GetByteBufferSize (const ByteBuffer *const buffer_p) |
Get the currently used size of a ByteBuffer's data buffer. More... | |
const char * | GetByteBufferData (const ByteBuffer *const buffer_p) |
Get the data stored in a ByteBuffer. More... | |
char * | DetachByteBufferData (ByteBuffer *const buffer_p) |
Get the data stored in a ByteBuffer and free a ByteBuffer. More... | |
void | RemoveFromByteBuffer (ByteBuffer *buffer_p, size_t size) |
Remove data from the end of a byte buffer. More... | |
void | ReplaceCharsInByteBuffer (ByteBuffer *buffer_p, char old_data, char new_data) |
Replace each instance of a character within a ByteBuffer with another. More... | |
A datatype to allow an automatically growing buffer for appending data to.
ByteBuffer * AllocateByteBuffer | ( | size_t | initial_size | ) |
Allocate a ByteBuffer.
initial_size | The initial size of the data buffer that this ByteBuffer will have. |
NULL
on error. void FreeByteBuffer | ( | ByteBuffer * | buffer_p | ) |
Free a ByteBuffer.
buffer_p | The ByteBuffer to free. |
bool ResizeByteBuffer | ( | ByteBuffer * | buffer_p, |
size_t | new_size | ||
) |
Resize a ByteBuffer.
The content of the data buffer will be preserved.
buffer_p | The ByteBuffer to resize. |
new_size | The new size of the ByteBuffer's data. |
true
if the resize was successful false
upon failure. If the call failed, the contents of the data buffer are preserved. bool ExtendByteBuffer | ( | ByteBuffer * | buffer_p, |
size_t | increment | ||
) |
Increase the size of a ByteBuffer's data buffer.
The content of the data buffer will be preserved.
buffer_p | The ByteBuffer to resize. |
increment | The amount to increase the ByteBuffer's data buffer. |
true
if the resize was successful false
upon failure. If the call failed, the contents of the data buffer are preserved. bool AppendToByteBuffer | ( | ByteBuffer * | buffer_p, |
const void * | data_p, | ||
const size_t | data_length | ||
) |
Append some data to a ByteBuffer's data buffer.
buffer_p | The ByteBuffer whose data buffer the new data will be appended to. |
data_p | The data to append. |
data_length | The length, in bytes, of the data to append. |
true
if the append was successful false
upon failure. If the call failed, the contents of the data buffer are preserved. bool AppendStringToByteBuffer | ( | ByteBuffer * | buffer_p, |
const char *const | value_s | ||
) |
Append a string to a ByteBuffer's data buffer.
buffer_p | The ByteBuffer whose data buffer the string will be appended to. |
value_s | The NULL terminated string to append. |
true
if the append was successful false
upon failure. If the call failed, the contents of the data buffer are preserved. bool AppendStringsToByteBuffer | ( | ByteBuffer * | buffer_p, |
const char * | value_s, | ||
... | |||
) |
Append a varargs array of strings to a ByteBuffer's data buffer.
buffer_p | The ByteBuffer whose data buffer the string will be appended to. |
value_s | The varags-style array of NULL terminated strings to append. The final entry in this varags-array must be a NULL . |
true
if the append was successful false
upon failure. If the call failed, the contents of the data buffer are preserved. bool AppendVarArgsToByteBuffer | ( | ByteBuffer * | buffer_p, |
const char * | value_s, | ||
va_list | args | ||
) |
Append a va_list of strings to a ByteBuffer's data buffer.
buffer_p | The ByteBuffer whose data buffer the string will be appended to. |
value_s | The varargs-style array of NULL terminated strings to append. The final entry in this varargs-array must be a NULL . |
args | The varargs list of arguments used by value_s. |
true
if the append was successful false
upon failure. If the call failed, the contents of the data buffer are preserved. void ResetByteBuffer | ( | ByteBuffer * | buffer_p | ) |
Clear any data stored in a ByteBuffer.
buffer_p | The ByteBuffer who will have all of its data emptied. |
size_t GetRemainingSpaceInByteBuffer | ( | const ByteBuffer *const | buffer_p | ) |
Get the remaining space in a ByteBuffer's data buffer.
buffer_p | The ByteBuffer to get the remaining space for. |
size_t GetByteBufferSize | ( | const ByteBuffer *const | buffer_p | ) |
Get the currently used size of a ByteBuffer's data buffer.
buffer_p | The ByteBuffer to get the space used for. |
const char * GetByteBufferData | ( | const ByteBuffer *const | buffer_p | ) |
Get the data stored in a ByteBuffer.
buffer_p | The ByteBuffer to get the data from. |
char * DetachByteBufferData | ( | ByteBuffer *const | buffer_p | ) |
Get the data stored in a ByteBuffer and free a ByteBuffer.
buffer_p | The ByteBuffer to get the data from which will be deallocated after this call. |
void RemoveFromByteBuffer | ( | ByteBuffer * | buffer_p, |
size_t | size | ||
) |
Remove data from the end of a byte buffer.
buffer_p | The ByteBuffer to remove the data from |
size | The number of bytes to remove. If this is greater than the size of the ByteBuffer, then the ByteBUffer will be reset. |
void ReplaceCharsInByteBuffer | ( | ByteBuffer * | buffer_p, |
char | old_data, | ||
char | new_data | ||
) |
Replace each instance of a character within a ByteBuffer with another.
buffer_p | The ByteBuffer to replace the character in. |
old_data | The character to be replaced. |
new_data | The replacement character. |