Class RawData
#include <RawData.h >
Class to represent and manipulate arbitrary binary data. This class keeps the data in a data buffer.
const string& value |
the bytes to copy into the data buffer Default value: "" |
Constructor. Copy bytes of string into the data buffer.
If the provided value begins with 0x, then the string is interpreted as 2-digit hexadecimal byte values.
const char* data |
the char* source of the data |
unsigned int size |
the number of bytes of data to copy |
bool binary |
false if char* is a series of 2-digit hexedecimal byte values, true if raw data Default value: true |
Constructor. Copy bytes from char* into the data buffer.
Clear the data buffer so it's empty.
Return the size of the data buffer in bytes.
Return value: data buffer size (in bytes)
unsigned char c |
the new byte to add |
Add another byte to the data buffer (at the end)
bool raw |
true if data buffer directly copied to returned string; false if data buffer converted to a series of 2-digit hexadecimal byte values Default value: false |
Convert to a hex string, e.g. 0x12345... or raw buffer inside string. If a hex string, 0x is prepended.
Return value: the produced string
const string& value |
the string to copy into the data buffer. |
Convert from a hex string or normal string.
If the provided value begins with 0x, then the string is interpreted as 2-digit hexadecimal byte values.
Return value: true if data converetd successfully, false if it failed (e.g. invalid 2-digit hex codes)
const char* data |
a pointer to the data to copy into the data buffer |
unsigned int size |
the number of bytes to copy into the data buffer |
Copy data as binary from buffer.
Return value: true if successful, false if failed (because data==NULL and size >0)
unsigned int startPos |
Where to begin copying from the data buffer Default value: 0 |
int length |
How many bytes to copy (becomes 2 hex digits) Default value: -1 |
Convert the data buffer to a hex string without leading 0x.
Provided parameters allow for extracting subsets of the data buffer.
Return value: the binary data as a string
const char* rawdata |
A char* buffer to create a hex string for |
unsigned int size |
How many bytes to copy (becomes 2 hex digits) |
Convert the data buffer to a hex string without leading 0x.
Provided parameters allow for extracting subsets of the data buffer.
Return value: the binary data as a string
unsigned int rawdata |
An unsigned char* buffer to create a hex string for |
unsigned int size |
How many bytes to copy (becomes 2 hex digits) |
Convert the data buffer to a hex string without leading 0x.
Provided parameters allow for extracting subsets of the data buffer.
Return value: the binary data as a string
const char* hexdigits |
hexdigit text (with no leading 0x) to convert |
int size |
number of hex digits to convert (2 digits is size=1) Default value: -1 |
Convert a string of hex digits to binary data
Return value: true if data copies, false it error
const string& value |
the string to convert (a series of 2-digit hex numbers with no separator between them) |
Convert a string of hex digits to binary data
Return value: true if data copies, false it error
Return data as a buffer of binary data
Return value: char* to raw data
unsigned int pos |
byte offset (0+) from start of buffer |
Get a specific byte value at a specific location in the data buffer
Return value: the specific byte; return 0 if beyond buffer size
string rawdata |
Our buffer of raw data collected so far |