16 #ifndef MEMORYWRITER_HPP
17 #define MEMORYWRITER_HPP
19 #include "Athena/IStreamWriter.hpp"
50 MemoryWriter(
const std::string& filename, std::function<
void(
int)> progressFun =
nullptr);
89 void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
134 atUint8*
data()
const;
151 void save(
const std::string& filename =
"");
279 void fill(atUint8 val, atUint64
length);
280 void fill(atInt8 val, atUint64
length);
282 void setProgressCallback(std::function<
void(
int)> cb);
289 atUint64 m_bitPosition;
291 std::function<void(int)> m_progressCallback;
293 void resize(atUint64 newSize);
298 #ifndef MEMORYWRITER_BASE
299 #define MEMORYWRITER_BASE() \
301 typedef Athena::io::MemoryWriter base
302 #endif // BINARYWRITER_BASE
303 #endif // MEMORYWRITER_HPP
void writeBool(bool)
Writes an bool to the buffer and advances the buffer. It also swaps the bytes depending on the platfo...
void setEndian(Endian endian)
Sets the Endianss of the stream.
void setData(const atUint8 *data, atUint64 length)
Sets the buffer to the given one, deleting the current one. BEWARE: As this deletes the current buff...
bool atEnd() const
Returns whether or not the stream is at the end.
Endian endian() const
Returns the current Endianness of the stream.
std::string filepath() const
Returns the target file.
void save(const std::string &filename="")
Saves the file to the specified file.
bool isBigEndian() const
Returns whether the stream is BigEndian.
void writeUint64(atUint64)
Writes an Uint64 to the buffer and advances the buffer. It also swaps the bytes depending on the plat...
void seekAlign32()
Sets the buffers position relative to the next 32-byte aligned position.
void setFilepath(const std::string &filepath)
Sets the target file.
void writeUnicode(const std::string &str)
Writes an unicode string to the buffer and advances the buffer. It also swaps the bytes depending on ...
void writeInt32(atInt32)
Writes an Int32 to the buffer and advances the buffer. It also swaps the bytes depending on the platf...
bool isLittleEndian() const
Returns whether the stream is LittleEndian.
void seek(atInt64 pos, SeekOrigin origin=SeekOrigin::Current)
Sets the buffers position relative to the specified position. It seeks relative to the current posit...
void writeBytes(atInt8 *data, atUint64 len)
Writes the given buffer with the specified length, buffers can be bigger than the length however it's...
void writeUByte(atUint8 val)
Writes a byte at the current position and advances the position by one byte.
atUint64 length() const
Returns whether or not the stream is at the end.
void writeUBytes(atUint8 *data, atUint64 len)
Writes the given buffer with the specified length, buffers can be bigger than the length however it's...
void writeInt16(atInt16 val)
Writes an Int16 to the buffer and advances the buffer. It also swaps the bytes depending on the platf...
void writeFloat(float)
Writes an float to the buffer and advances the buffer. It also swaps the bytes depending on the platf...
void writeInt64(atInt64)
Writes an Int64 to the buffer and advances the buffer. It also swaps the bytes depending on the platf...
void writeUint32(atUint32)
Writes an Uint32 to the buffer and advances the buffer. It also swaps the bytes depending on the plat...
bool isOpen() const
Retuns whether or not the Stream is open.
atUint64 position() const
Returns the current position in the stream.
void writeBit(bool val)
Writes a bit at the current position and advances the position by one bit.
atUint8 * data() const
Returns a copy of the current buffer. Changes to the copy do not affect the buffer so it's perfectly...
void writeUint16(atUint16)
Writes an Uint16 to the buffer and advances the buffer. It also swaps the bytes depending on the plat...
void writeString(const std::string &str)
Writes an string to the buffer and advances the buffer.
void seekBit(int bit)
Seeks to the specified bit within the current byte.
void writeDouble(double)
Writes an double to the buffer and advances the buffer. It also swaps the bytes depending on the plat...
MemoryWriter(atUint8 *data=nullptr, atUint64 length=0x10)
This constructor takes an existing buffer to write to.
void writeByte(atInt8 val)
Writes a byte at the current position and advances the position by one byte.
std::string m_filepath
Path to the target file.