A stream of bytes that is used to easily store and retrieve data
ByteStream( |
| ) |
Default constructor to create a ByteStream object
bigEndian bool | Whether this ByteStream contains floating point data in big endian (true) or little endian(false) (default of true) |
explicit ByteStream( |
| ) |
Constructor to create a ByteStream object, passing in the bytes to store in the stream
bytesToCopy | The vector of bytes to copy into the ByteStream |
bigEndian bool | Whether this ByteStream contains floating point data in big endian (true) or little endian(false) (default of true) |
Default destructor for the ByteStream object
Whether the ByteStream is big endian (true) or little endian (false)
Accesses a single byte of the ByteStream
index | The 0-based index into the ByteStream |
The single byte in the ByteStream located at the requested index
std::out_of_range: The index requested is out of range
Checks that two ByteStream objects are equal by comparing their data vectors
true if the two ByteStreams are identical, false otherwise
void append_uint8( |
| ) |
Appends a 1-byte unsigned integer to the byte stream
value uint8 | The 1-byte uint8 to be added to the byte stream |
void append_int16( |
| ) |
Appends a 2-byte signed integer to the byte stream
value int16 | The 2-byte int16 to be added to the byte stream |
void append_uint16( |
| ) |
Appends a 2-byte unsigned integer to the byte stream
value uint16 | The 2-byte uint16 to be added to the byte stream |
void append_uint32( |
| ) |
Appends a 4-byte unsigned integer to the byte stream
value uint32 | The 4-byte uint32 to be added to the byte stream |
void append_float( |
| ) |
Appends a 4-byte float to the byte stream
valye | The 4-byte float to be added to the byte stream |
void append_double( |
| ) |
Appends an 8-byte double to the byte stream
valye | The 8-byte double to be added to the byte stream |
void append_string( |
| ) |
Appends a string to the byte stream.
str const std::string& | The string to append to the byte stream. |
void appendBytes( |
| ) |
Appends a vector of bytes (uint8) to the end of the current ByteStream
bytes const Bytes& | The bytes to be appended to the byte stream |
void appendByteStream( |
| ) |
Appends the entire contents of a ByteStream to the end of the current ByteStream
otherStream const ByteStream& | The ByteStream to be appended to the current ByteStream |
int8 read_int8( |
| ) const |
Reads a 1-byte signed integer from the byte stream
position std::size_t | The 0-based position to read from |
The 1-byte int8 at the requested position
std::out_of_range: The index requested is out of range
uint8 read_uint8( |
| ) const |
Reads a 1-byte unsigned integer from the byte stream
position std::size_t | The 0-based position to read from |
The 1-byte uint8 at the requested position
std::out_of_range: The index requested is out of range
int16 read_int16( |
| ) const |
Reads a 2-byte signed integer from the byte stream
position std::size_t | The 0-based position to read from |
The int16 at the requested position
std::out_of_range: The index requested is out of range
uint16 read_uint16( |
| ) const |
Reads a 2-byte unsigned integer from the byte stream
position std::size_t | The 0-based position to read from |
The uint16 at the requested position
std::out_of_range: The index requested is out of range
uint32 read_uint32( |
| ) const |
Reads a 4-byte unsigned integer from the byte stream
position std::size_t | The 0-based position to read from |
The uint32 at the requested position
std::out_of_range: The index requested is out of range
float read_float( |
| ) const |
Reads a 4-byte float from the byte stream
position std::size_t | The 0-based position to read from |
The float at the requested position
std::out_of_range: The index requested is out of range
double read_double( |
| ) const |
Reads an 8-byte double from the byte stream
position std::size_t | The 0-based position to read from |
The double at the requested position
std::out_of_range: The index requested is out of range
std::string read_string( |
| ) const |
Reads a string of the specified length from the byte stream
position std::size_t | The 0-based position to start reading from |
length std::size_t | The size (number of characters) to read for |
The string at the requested position of the requested length
-std::out_of_range: The index + length requested is out of range
Gets the byte stream as a vector of bytes (Bytes)
The byte stream as a vector of bytes (Bytes)
Gets the byte stream as a vector of bytes (Bytes)
The byte stream as a vector of bytes (Bytes)
Gets the size of the byte stream (equivalent of std::vector.size())
The size of the byte stream (number of bytes)
Clears the byte stream (equivalent of std::vector.clear())
Checks whether the vector is empty. (equivalent of std::vector::empty())
true if the vector is empty (size is 0), false otherwise.
void resize( |
| ) |
Resizes the byte stream (equivalent of std::vector.resize())
Gets an iterator referring to the first element in the ByteStream (equivalent of std::vector::begin())
An iterator referring to the first element in the ByteStream
Gets an iterator referring to the "past-the-end" element in the ByteStream. (equivalent of std::vector::begin())
An iterator referring to the "past-the-end" element in the ByteStream
uint16 calculateSimpleChecksum( |
| ) const |
Calculates the simple checksum (simple addition of bytes)on the ByteStream
from std::size_t | The 0-based starting position in the bytes vector to start calculating the checksum (includes this byte) |
to std::size_t | The 0-based end position in the bytes vector to end calculating the checksum (includes this byte) |
The simple checksum (addition of bytes) of the ByteStream
std::out_of_range: The index requested is out of range
uint16 calculateFletcherChecksum( |
| ) const |
Calculates the Fletcher checksum (position dependent checksum) on the ByteStream
from std::size_t | The 0-based starting position in the bytes vector to start calculating the checksum (includes this byte) |
to std::size_t | The 0-based end position in the bytes vector to end calculating the checksum (includes this byte) |
The Fletcher checksum of the ByteStream
std::out_of_range: The index requested is out of range
void verifyBytesInStream( |
| ) const |
Checks that the current bytestream can read the requested data
position std::size_t | The 0-based start position that is desired to read data from |
length std::size_t | The amount of bytes desired to read |
std::out_of_range: The index requested is out of range