ASL
Loading...
Searching...
No Matches
StreamBufferReader Class Reference

Detailed Description

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.

ByteArray data = File("data.bin").content();
StreamBufferReader buffer (data, ENDIAN_BIG);
int n = buffer.read<int>();
double x, y, z;
buffer >> x >> y >> z;
Class File represents a file in the filesystem.
Definition File.h:63
ByteArray content()
Returns the binary content of the file as an array of bytes.
This class allows reading a memory buffer as a binary stream.
Definition StreamBuffer.h:60

#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)
 
StreamBufferReaderskip (int n)
 Skips a number of bytes.
 
StreamBufferReaderoperator>> (char &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (byte &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (short &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (unsigned short &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (int &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (unsigned &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (float &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (Long &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (ULong &x)
 Read one value from the buffer.
 
StreamBufferReaderoperator>> (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)
 

The documentation for this class was generated from the following file: