4#include "../util/byte_array.h"
5#include "../util/endian.h"
16 Stream(
const ByteArray& data);
18 size_t read(ByteArray& buffer,
const size_t& len);
19 size_t write(ByteArray& buffer,
const size_t& len);
22 bool seek(
const size_t& pos);
48 data.reserve(
sizeof(T));
50 read(data,
sizeof(T));
52 T result = oe::util::convertFromByteArray<T>(data);
55 return oe::util::endian::convertLittleEndianToHost(result);
57 return oe::util::endian::convertBigEndianToHost(result);
67 _data.erase(_data.begin(), _cursor);
77 _data.insert(end(_data), begin(data), end(data));
80 const ByteArray getData()
const
98 ByteArray::iterator _cursor;
101 template<>
bool Stream::readValue<>(
bool little_endian);
102 template<> uint8_t Stream::readValue<>(
bool little_endian);
103 template<> int8_t Stream::readValue<>(
bool little_endian);
std::string readStringToNull(const size_t &maxLength=32767)
Read a string until either the null character '\0' is found or up to the maximum length.
std::string readString(const size_t &length)
Read a string of specified length.
void align(size_t alignment)
Move stream position to be aligned.
void trim()
Remove all data that are already already read.
Definition stream.h:65
void appendData(const ByteArray &data)
Add additional data at the end of the stream.
Definition stream.h:75
T readValue(bool little_endian=true)
read a value from the stream and move the cursor
Definition stream.h:45
Input/Output abstractions (Filesystem, Network, ...)
Definition file.h:10