Represents a buffer capable of accumulating various kinds of values. More...
#include <bytebuffer.h>
Public Member Functions | |
ByteBuffer (void) | |
constructor; | |
~ByteBuffer (void) | |
destructor; | |
bool | isValid (void) const |
tell if the instance is valid or not | |
bool | isEmpty (void) const |
tell if there is any data in this buffer | |
unsigned | allocated (void) const |
number of allocated bytes in this buffer | |
unsigned | size (void) const |
number of used bytes; lenght of the content | |
unsigned | count (void) const |
number of used bytes; lenght of the content | |
unsigned | lenght (void) const |
number of used bytes; lenght of the content | |
void | seek (quint64 loc) |
resets the iterator to requested location | |
quint64 | position (void) const |
get the position of the iterator | |
void | reset (void) |
resets the buffer as if it was just allocated | |
bool | reinitFromFile (QFile &file) |
resets the buffer to the content of the file | |
bool | saveToFile (QFile &file) |
writes the content of the buffer to file | |
unsigned | getRaw (unsigned bytes) |
reserves and updates used count | |
Methods used to "fill" a buffer | |
void | append (int new_val) |
adds an integer value; | |
void | append (unsigned new_val) |
adds an unsigned value; | |
void | append (quint64 new_val) |
adds an integer value; | |
void | append (qint64 new_val) |
adds an integer value; | |
void | append (bool new_val) |
adds a boolean value; | |
void | append (double new_val) |
adds a double value; | |
void | append (const QString &new_val) |
adds a string value; | |
void | append (const char *new_val, int len=-1, bool uncounted=false) |
adds a byte array; | |
Methods used to read a buffer | |
bool | getValue (bool &out_val, quint64 offset) |
reads a boolean value; return false for errors More... | |
quint64 | getValue (char *out_val, int max_buf, quint64 offset) |
reads a counted array of bytes in a user provided buffer More... | |
bool | getValue (quint64 offset, int count, char *out_val) |
reads an uncounted array of characters More... | |
bool | getValue (char **out_val, quint64 offset) |
reads a counted array of bytes in an internally provided buffer More... | |
bool | getValue (double &out_val, quint64 offset) |
reads a double value More... | |
bool | getValue (int &out_val, quint64 offset) |
reads a signed value More... | |
bool | getValue (qint64 &out_val, quint64 offset) |
reads a signed value More... | |
bool | getValue (QString &out_val, quint64 offset) |
reads a string value More... | |
bool | getValue (quint64 &out_val, quint64 offset) |
reads an unsigned value More... | |
bool | getValue (unsigned &out_val, quint64 offset) |
reads an unsigned value More... | |
Methods used to sequentially read a buffer | |
bool | getValue (int &out_val) |
reads a signed value More... | |
bool | getValue (unsigned &out_val) |
reads an unsigned value More... | |
bool | getValue (qint64 &out_val) |
reads a signed value More... | |
bool | getValue (quint64 &out_val) |
reads an unsigned value More... | |
bool | getValue (bool &out_val) |
reads a boolean value More... | |
bool | getValue (double &out_val) |
reads a real value More... | |
bool | getValue (QString &out_val) |
reads a string value More... | |
bool | getValue (char **out_val) |
reads a counted array of bytes in an internally provided buffer More... | |
quint64 | getValue (char *out_val, int max_buf) |
reads a counted array of bytes in a user provided buffer More... | |
bool | getValue (int count, char *out_buf) |
reads an uncounted array of characters More... | |
bool | readUncountedBytes (int count, char *out_buf) |
reads an uncounted array of characters More... | |
Represents a buffer capable of accumulating various kinds of values.
bool ByteBuffer::getValue | ( | bool & | out_val, |
quint64 | offset | ||
) |
reads a boolean value; return false for errors
quint64 ByteBuffer::getValue | ( | char * | out_val, |
int | max_buf, | ||
quint64 | offset | ||
) |
reads a counted array of bytes in a user provided buffer
The user must provide a valid pointer and correct buffer size.
The buffer should contain the size of the array and the array itself.
bool ByteBuffer::getValue | ( | quint64 | offset, |
int | count, | ||
char * | out_val | ||
) |
reads an uncounted array of characters
Usable for fixed-lenght entries. The buffer is not expected to contain a counter. Used with signature bytes.
bool ByteBuffer::getValue | ( | char ** | out_val, |
quint64 | offset | ||
) |
reads a counted array of bytes in an internally provided buffer
The user will have the ovnership of the returned buffer.
The buffer should contain the size of the array and the array itself.
bool ByteBuffer::getValue | ( | double & | out_val, |
quint64 | offset | ||
) |
reads a double value
bool ByteBuffer::getValue | ( | int & | out_val, |
quint64 | offset | ||
) |
reads a signed value
bool ByteBuffer::getValue | ( | qint64 & | out_val, |
quint64 | offset | ||
) |
reads a signed value
bool ByteBuffer::getValue | ( | QString & | out_val, |
quint64 | offset | ||
) |
reads a string value
The entry is expected to be counted.
bool ByteBuffer::getValue | ( | quint64 & | out_val, |
quint64 | offset | ||
) |
reads an unsigned value
bool ByteBuffer::getValue | ( | unsigned & | out_val, |
quint64 | offset | ||
) |
reads an unsigned value
|
inline |
reads a signed value
|
inline |
reads an unsigned value
|
inline |
reads a signed value
|
inline |
reads an unsigned value
|
inline |
reads a boolean value
|
inline |
reads a real value
|
inline |
reads a string value
The entry is expected to be counted.
|
inline |
reads a counted array of bytes in an internally provided buffer
The user will have the ovnership of the returned buffer.
The buffer should contain the size of the array and the array itself.
|
inline |
reads a counted array of bytes in a user provided buffer
The user must provide a valid pointer and correct buffer size.
The buffer should contain the size of the array and the array itself.
|
inline |
reads an uncounted array of characters
Usable for fixed-lenght entries. The buffer is not expected to contain a counter. Used with signature bytes.
|
inline |
reads an uncounted array of characters
Usable for fixed-lenght entries. The buffer is not expected to contain a counter. Used with signature bytes.