ASL
|
This class allows reading a memory buffer as a binary stream.
It can read bytes, integers of different sizes and floating point numbers in big-endian or little-endian byte order. You have to make sure you don't read past the bounds of the buffer.
#include <StreamBuffer.h>
Public Member Functions | |
StreamBufferReader (const ByteArray &data, Endian e=ENDIAN_LITTLE) | |
Constructs a buffer reader from a byte array. | |
StreamBufferReader (const byte *data, int n, Endian e=ENDIAN_LITTLE) | |
Constructs a buffer reader from a raw byte array. | |
void | setEndian (Endian e) |
Sets the endianness for reading (can be changed on the fly) | |
StreamBufferReader & | skip (int n) |
Skips a number of bytes. | |
StreamBufferReader & | operator>> (char &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (byte &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (short &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (unsigned short &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (int &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (unsigned &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (float &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (Long &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (ULong &x) |
Read one value from the buffer. | |
StreamBufferReader & | operator>> (double &x) |
Read one value from the buffer. | |
template<class T > | |
T | read () |
Read one value from the buffer: float x = buffer.read<float>() | |
ByteArray | read (int n=-1) |
Reads n bytes into an Array (or all remaining bytes by default) | |