6#include "../util/byte_array.h"
7#include "../util/endian.h"
18 Stream(
const ByteArray& data);
20 size_t read(ByteArray& buffer,
const size_t& len);
21 size_t write(ByteArray& buffer,
const size_t& len);
24 bool seek(
const size_t& pos);
50 data.reserve(
sizeof(T));
52 read(data,
sizeof(T));
54 T result = oe::util::convertFromByteArray<T>(data);
57 return oe::util::endian::convertLittleEndianToHost(result);
59 return oe::util::endian::convertBigEndianToHost(result);
69 _data.erase(_data.begin(), _cursor);
79 _data.insert(end(_data), begin(data), end(data));
82 const ByteArray getData()
const
100 ByteArray::iterator _cursor;
103 template<>
bool Stream::readValue<>(
bool little_endian);
104 template<> uint8_t Stream::readValue<>(
bool little_endian);
105 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:67
void appendData(const ByteArray &data)
Add additional data at the end of the stream.
Definition stream.h:77
T readValue(bool little_endian=true)
read a value from the stream and move the cursor
Definition stream.h:47
Input/Output abstractions (Filesystem, Network, ...)
Definition file.h:14