1 #ifndef MEMORYREADER_HPP 2 #define MEMORYREADER_HPP 7 #include "athena/IStreamReader.hpp" 41 void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
68 void setData(
const atUint8* data, atUint64 length,
bool takeOwnership=
false);
78 atUint8*
data()
const;
88 const void* m_data =
nullptr;
89 atUint64 m_length = 0;
90 atUint64 m_position = 0;
92 bool m_globalErr =
true;
110 : m_filepath(filename)
113 void setData(
const atUint8* data, atUint64 length);
117 std::unique_ptr<atUint8[]> m_dataCopy;
124 #ifndef MEMORYREADER_BASE 125 #define MEMORYREADER_BASE() \ 127 typedef athena::io::MemoryReader base 129 #endif // MEMORYREADER_BASE 131 #ifndef MEMORYCOPYREADER_BASE 132 #define MEMORYCOPYREADER_BASE() \ 134 typedef athena::io::MemoryCopyReader base 136 #endif // MEMORYCOPYREADER_BASE 138 #endif // MEMORYREADER_HPP void setData(const atUint8 *data, atUint64 length, bool takeOwnership=false)
Sets the buffer to the given one, deleting the current one. BEWARE: As this deletes the current buff...
atUint64 readUBytesToBuf(void *buf, atUint64 len)
Reads a specified number of bytes to user-allocated buffer.
The IStreamReader class defines a basic API for reading from streams, Implementors are provided with ...
void seek(atInt64 pos, SeekOrigin origin=SeekOrigin::Current)
Sets the buffers position relative to the specified position. It seeks relative to the current posit...
std::string m_filepath
Path to the target file.
atUint64 position() const
Returns the current position in the stream.
atUint8 * data() const
Returns a copy of the current buffer. Changes to the copy do not affect the buffer so it's perfectly...
atUint64 length() const
Returns whether or not the stream is at the end.
A Stream class for reading data from a memory position.
MemoryCopyReader(const std::string &filename)
This constructor creates an instance from a file on disk.