From a63da8db2f58b1e2967835fca137c955b75c5b61 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 30 Jun 2015 23:28:40 -1000 Subject: [PATCH] header-based read/write optimizations --- PKGBUILD | 2 +- include/Athena/DNA.hpp | 4 +- include/Athena/FileReader.hpp | 43 +++++++++++------ include/Athena/FileWriter.hpp | 37 +++++++++----- include/Athena/MemoryReader.hpp | 45 +++++++++++------ include/Athena/MemoryWriter.hpp | 53 +++++++++++++------- src/Athena/FileReader.cpp | 78 ------------------------------ src/Athena/FileWriter.cpp | 60 ----------------------- src/Athena/MemoryReader.cpp | 69 -------------------------- src/Athena/MemoryWriter.cpp | 85 --------------------------------- 10 files changed, 124 insertions(+), 352 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index b136094..5346e5f 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # PKGBUILD for libAthena _pkgname=libathena pkgname=$_pkgname-git -pkgver=1.1.0.44.g071d91a +pkgver=1.1.0.59.g582d2ce pkgrel=1 pkgdesc="Basic cross platform IO library" arch=('i686' 'x86_64') diff --git a/include/Athena/DNA.hpp b/include/Athena/DNA.hpp index 970d035..bc01083 100644 --- a/include/Athena/DNA.hpp +++ b/include/Athena/DNA.hpp @@ -91,9 +91,9 @@ struct DNA { Delete expl; inline void read(IStreamReader& reader) - {*this = reader.readUTF8(sizeVar);} + {*this = reader.readUnicode(sizeVar);} inline void write(IStreamWriter& writer) const - {writer.writeUTF8(*this, sizeVar);} + {writer.writeUnicode(*this, sizeVar);} inline std::string& operator=(const std::string& __str) {return this->assign(__str);} inline std::string& operator=(std::string&& __str) diff --git a/include/Athena/FileReader.hpp b/include/Athena/FileReader.hpp index 86a5aa0..211b7db 100644 --- a/include/Athena/FileReader.hpp +++ b/include/Athena/FileReader.hpp @@ -14,18 +14,26 @@ class FileReader : public IStreamReader public: FileReader(const std::string& filename); virtual ~FileReader(); - std::string filename() const; + inline const std::string& filename() const + {return m_filename;} + + inline void setEndian(Endian endian) + {m_endian = endian;} + inline Endian endian() const + {return m_endian;} + inline bool isBigEndian() const + {return (m_endian == Endian::BigEndian);} + inline bool isLittleEndian() const + {return (m_endian == Endian::LittleEndian);} - void setEndian(Endian endian); - Endian endian() const; - bool isBigEndian() const; - bool isLittleEndian() const; void open(); void close(); - bool isOpen() const; + inline bool isOpen() const + {return m_fileHandle != NULL;} bool save(); void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); - inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);} + inline void seekAlign32() + {FileReader::seek(ROUND_UP_32(FileReader::position()), SeekOrigin::Begin);} bool atEnd() const; atUint64 position() const; atUint64 length() const; @@ -34,20 +42,27 @@ public: void seekBit(int); bool readBit(); atUint8 readUByte(); - atInt8 readByte(); + inline atInt8 readByte() + {return (atInt8)FileReader::readUByte();} atUint8* readUBytes(atUint64 len); - atInt8* readBytes(atUint64 len); - atUint64 readBytesToBuf(void* buf, atUint64 len) {return readUBytesToBuf(buf, len);} + inline atInt8* readBytes(atUint64 len) + {return (atInt8*)FileReader::readUBytes(len);} + atUint64 readBytesToBuf(void* buf, atUint64 len) + {return FileReader::readUBytesToBuf(buf, len);} atUint64 readUBytesToBuf(void* buf, atUint64 len); atUint16 readUint16(); - atInt16 readInt16(); + inline atInt16 readInt16() + {return (atInt16)FileReader::readUint16();} atUint32 readUint32(); - atInt32 readInt32(); + inline atInt32 readInt32() + {return (atInt32)FileReader::readUint32();} atUint64 readUint64(); - atInt64 readInt64(); + inline atInt64 readInt64() + {return (atInt64)FileReader::readUint64();} double readDouble(); float readFloat(); - bool readBool(); + inline bool readBool() + {return (FileReader::readByte() != 0);} atVec3f readVec3f(); atVec4f readVec4f(); std::string readString(atInt32 fixedLen = -1); diff --git a/include/Athena/FileWriter.hpp b/include/Athena/FileWriter.hpp index 3f65cf0..a95709c 100644 --- a/include/Athena/FileWriter.hpp +++ b/include/Athena/FileWriter.hpp @@ -14,13 +14,19 @@ public: FileWriter(const std::string& filename, bool overwrite = true); virtual ~FileWriter(); - void setEndian(Endian endian); - Endian endian() const; - bool isBigEndian() const; - bool isLittleEndian() const; + inline void setEndian(Endian endian) + {m_endian = endian;} + inline Endian endian() const + {return m_endian;} + inline bool isBigEndian() const + {return (m_endian == Endian::BigEndian);} + inline bool isLittleEndian() const + {return (m_endian == Endian::LittleEndian);} + void open(bool overwrite = true); void close(); - bool isOpen() const; + inline bool isOpen() const + {return m_fileHandle != NULL;} void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);} bool atEnd() const; @@ -30,25 +36,32 @@ public: void writeBit(bool val); void seekBit(int bit); void writeUByte(atUint8 val); - void writeByte(atInt8 val); + inline void writeByte(atInt8 val) + {FileWriter::writeUByte(val);} void writeUBytes(const atUint8* data, atUint64 len); - void writeBytes(const atInt8* data, atUint64 len); + void writeBytes(const atInt8* data, atUint64 len) + {FileWriter::writeUBytes((atUint8*)data, len);} void writeUint16(atUint16 val); - void writeInt16(atInt16 val); + inline void writeInt16(atInt16 val) + {FileWriter::writeUint16(val);} void writeUint32(atUint32 val); - void writeInt32(atInt32 val); + inline void writeInt32(atInt32 val) + {FileWriter::writeUint32(val);} void writeUint64(atUint64 val); - void writeInt64(atInt64 val); + inline void writeInt64(atInt64 val) + {FileWriter::writeUint64(val);} void writeDouble(double val); void writeFloat(float val); - void writeBool(bool val); + inline void writeBool(bool val) + {FileWriter::writeByte(val);} void writeVec3f(atVec3f vec); void writeVec4f(atVec4f vec); void writeString(const std::string& val, atInt32 fixedLen = -1); void writeWString(const std::wstring& str, atInt32 fixedLen = -1); void writeUnicode(const std::string& str, atInt32 fixedLen = -1); void fill(atInt8 byte, atUint64 len); - void fill(atUint8 byte, atUint64 len); + inline void fill(atUint8 byte, atUint64 len) + {FileWriter::fill((atInt8)byte, len);} private: std::string m_filename; FILE* m_fileHandle; diff --git a/include/Athena/MemoryReader.hpp b/include/Athena/MemoryReader.hpp index 1ab81c1..74ca6ca 100644 --- a/include/Athena/MemoryReader.hpp +++ b/include/Athena/MemoryReader.hpp @@ -39,31 +39,37 @@ public: * * \param endian The Endianess to set \sa Endian */ - void setEndian(Endian endian); + inline void setEndian(Endian endian) + {m_endian = endian;} /*! \brief Returns the current Endianness of the stream * * \return Endian The current Stream Endianess */ - Endian endian() const; + inline Endian endian() const + {return m_endian;} /*! \brief Returns whether the stream is BigEndian * * \return bool True for BigEndian; False for LittleEndian */ - bool isBigEndian() const; + inline bool isBigEndian() const + {return (m_endian == Endian::BigEndian);} /*! \brief Returns whether the stream is LittleEndian * * \return bool True for LittleEndian; False for BigEndian */ - bool isLittleEndian()const; + inline bool isLittleEndian()const + {return (m_endian == Endian::LittleEndian);} /*! \brief Retuns whether or not the Stream is open. * * \return True if open; False otherwise. */ - bool isOpen() const; + inline bool isOpen() const + {return m_data != nullptr;} + /*! \brief Sets the buffers position relative to the specified position.
* It seeks relative to the current position by default. @@ -80,19 +86,23 @@ public: * * \return bool True if at end; False otherwise. */ - bool atEnd() const; + inline bool atEnd() const + {return m_position >= m_length;} /*! \brief Returns the current position in the stream. * * \return Int64 The current position in the stream. */ - atUint64 position() const; + inline atUint64 position() const + {return m_position;} /*! \brief Returns whether or not the stream is at the end. * * \return bool True if at end; False otherwise. */ - atUint64 length() const; + inline atUint64 length() const + {return m_length;} + /*! \brief Sets the buffer to the given one, deleting the current one.
* BEWARE: As this deletes the current buffer it WILL cause a loss of data @@ -120,12 +130,15 @@ public: * \sa Endian * \param filepath The path to write to. */ - void setFilepath(const std::string& filepath); + inline void setFilepath(const std::string& filepath) + {m_filepath = filepath;} /*! \brief Returns the target file * */ - std::string filepath() const; + inline std::string filepath() const + {return m_filepath;} + /*! * \brief Seeks to the specified bit within the current byte @@ -184,7 +197,8 @@ public: * \return Uint16 The value at the current address * \throw IOException when address is out of range */ - atUint16 readUint16(); + inline atUint16 readUint16() + {return MemoryReader::readInt16();} /*! \brief Reads a Int32 and swaps to proper endianness depending on platform * and Stream settings, and advances the current position @@ -204,7 +218,8 @@ public: * \return Uint32 The value at the current address * \throw IOException when address is out of range */ - atUint32 readUint32(); + inline atUint32 readUint32() + {return MemoryReader::readInt32();} /*! \brief Reads a Int64 and swaps to proper endianness depending on platform * and Stream settings, and advances the current position @@ -224,7 +239,8 @@ public: * \return Uint64 The value at the current address * \throw IOException when address is out of range */ - atUint64 readUint64(); + inline atUint64 readUint64() + {return MemoryReader::readInt64();} /*! \brief Reads a float and swaps to proper endianness depending on platform * and Stream settings, and advances the current position @@ -291,7 +307,8 @@ public: */ std::wstring readWString(atInt32 fixedLen = -1); - void setProgressCallback(std::function cb); + inline void setProgressCallback(std::function cb) + {m_progressCallback = cb;} protected: void loadData(); atUint8* m_data; diff --git a/include/Athena/MemoryWriter.hpp b/include/Athena/MemoryWriter.hpp index 5778aae..5681d04 100644 --- a/include/Athena/MemoryWriter.hpp +++ b/include/Athena/MemoryWriter.hpp @@ -40,31 +40,37 @@ public: * * \param endian The Endianess to set \sa Endian */ - void setEndian(Endian endian); + inline void setEndian(Endian endian) + {m_endian = endian;} /*! \brief Returns the current Endianness of the stream * * \return Endian The current Stream Endianess */ - Endian endian() const; + inline Endian endian() const + {return m_endian;} /*! \brief Returns whether the stream is BigEndian * * \return bool True for BigEndian; False for LittleEndian */ - bool isBigEndian() const; + inline bool isBigEndian() const + {return (m_endian == Endian::BigEndian);} /*! \brief Returns whether the stream is LittleEndian * * \return bool True for LittleEndian; False for BigEndian */ - bool isLittleEndian()const; + inline bool isLittleEndian() const + {return (m_endian == Endian::LittleEndian);} /*! \brief Retuns whether or not the Stream is open. * * \return True if open; False otherwise. */ - bool isOpen() const; + inline bool isOpen() const + {return m_data != nullptr;} + /*! \brief Sets the buffers position relative to the specified position.
* It seeks relative to the current position by default. @@ -82,20 +88,23 @@ public: * * \return bool True if at end; False otherwise. */ - bool atEnd() const; + inline bool atEnd() const + {return m_position >= m_length;} /*! \brief Returns the current position in the stream. * * \return Int64 The current position in the stream. */ - atUint64 position() const; + inline atUint64 position() const + {return m_position;} /*! \brief Returns whether or not the stream is at the end. * * \return bool True if at end; False otherwise. */ - atUint64 length() const; + inline atUint64 length() const + {return m_length;} /*! \brief Sets the buffer to the given one, deleting the current one.
* BEWARE: As this deletes the current buffer it WILL cause a loss of data @@ -122,12 +131,15 @@ public: * * \param filepath The path to write to. */ - void setFilepath(const std::string& filepath); + inline void setFilepath(const std::string& filepath) + {m_filepath = filepath;} /*! \brief * Returns the target file */ - std::string filepath() const; + inline std::string filepath() const + {return m_filepath;} + /*! \brief Saves the file to the specified file. * @@ -156,7 +168,8 @@ public: * \param byte The value to write * \throw IOException */ - void writeByte(atInt8 val); + inline void writeByte(atInt8 val) + {MemoryWriter::writeUByte(val);} /*! \brief Writes the given buffer with the specified length, buffers can be bigger than the length * however it's undefined behavior to try and write a buffer which is smaller than the given length. @@ -172,7 +185,8 @@ public: * \param data The buffer to write * \param length The amount to write */ - void writeBytes(const atInt8* data, atUint64 len); + inline void writeBytes(const atInt8* data, atUint64 len) + {MemoryWriter::writeUBytes((atUint8*)data, len);} /*! \brief Writes an Int16 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -188,7 +202,8 @@ public: * \sa Endian * \param val The value to write to the buffer */ - void writeUint16(atUint16); + inline void writeUint16(atUint16 val) + {MemoryWriter::writeInt16(val);} /*! \brief Writes an Int32 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -204,7 +219,8 @@ public: * \sa Endian * \param val The value to write to the buffer */ - void writeUint32(atUint32); + void writeUint32(atUint32 val) + {MemoryWriter::writeInt32(val);} /*! \brief Writes an Int64 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -220,7 +236,8 @@ public: * \sa Endian * \param val The value to write to the buffer */ - void writeUint64(atUint64); + inline void writeUint64(atUint64 val) + {MemoryWriter::writeInt64(val);} /*! \brief Writes an float to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -289,9 +306,11 @@ public: void fill(atUint8 val, atUint64 length); - void fill(atInt8 val, atUint64 length); + inline void fill(atInt8 val, atUint64 length) + {MemoryWriter::fill((atUint8)val, length);} - void setProgressCallback(std::function cb); + inline void setProgressCallback(std::function cb) + {m_progressCallback = cb;} protected: void loadData(); atUint8* m_data; diff --git a/src/Athena/FileReader.cpp b/src/Athena/FileReader.cpp index 97ca03b..044b5e5 100644 --- a/src/Athena/FileReader.cpp +++ b/src/Athena/FileReader.cpp @@ -30,31 +30,6 @@ FileReader::~FileReader() close(); } -std::string FileReader::filename() const -{ - return m_filename; -} - -void FileReader::setEndian(Endian endian) -{ - m_endian = endian; -} - -Endian FileReader::endian() const -{ - return m_endian; -} - -bool FileReader::isBigEndian() const -{ - return (m_endian == Endian::BigEndian); -} - -bool FileReader::isLittleEndian() const -{ - return (m_endian == Endian::LittleEndian); -} - void FileReader::open() { m_fileHandle = fopen(m_filename.c_str(), "rb"); @@ -76,11 +51,6 @@ void FileReader::close() return; } -bool FileReader::isOpen() const -{ - return m_fileHandle != NULL; -} - void FileReader::seek(atInt64 pos, SeekOrigin origin) { if (fseeko64(m_fileHandle, pos, (int)origin) != 0) @@ -158,14 +128,6 @@ atUint8 FileReader::readUByte() return val; } -atInt8 FileReader::readByte() -{ - if (!isOpen()) - THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading"); - - return (atInt8)readUByte(); -} - atUint8* FileReader::readUBytes(atUint64 len) { if (!isOpen()) @@ -186,14 +148,6 @@ atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) return fread(buf, 1, len, m_fileHandle); } -atInt8* FileReader::readBytes(atUint64 len) -{ - if (!isOpen()) - THROW_INVALID_OPERATION_EXCEPTION_RETURN(nullptr, "File not open for reading"); - - return (atInt8*)readUBytes(len); -} - atUint16 FileReader::readUint16() { if (!isOpen()) @@ -209,14 +163,6 @@ atUint16 FileReader::readUint16() return val; } -atInt16 FileReader::readInt16() -{ - if (!isOpen()) - THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading"); - - return (atInt16)readUint16(); -} - atUint32 FileReader::readUint32() { if (!isOpen()) @@ -232,14 +178,6 @@ atUint32 FileReader::readUint32() return val; } -atInt32 FileReader::readInt32() -{ - if (!isOpen()) - THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading"); - - return (atInt32)readUint32(); -} - atUint64 FileReader::readUint64() { if (!isOpen()) @@ -255,14 +193,6 @@ atUint64 FileReader::readUint64() return val; } -atInt64 FileReader::readInt64() -{ - if (!isOpen()) - THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading"); - - return (atInt64)readUint64(); -} - double FileReader::readDouble() { if (!isOpen()) @@ -293,14 +223,6 @@ float FileReader::readFloat() return val; } -bool FileReader::readBool() -{ - if (!isOpen()) - THROW_INVALID_OPERATION_EXCEPTION_RETURN(false, "File not open for reading"); - - return (readByte() != 0); -} - atVec3f FileReader::readVec3f() { atVec3f val = {}; diff --git a/src/Athena/FileWriter.cpp b/src/Athena/FileWriter.cpp index cccce04..1fa7b8e 100644 --- a/src/Athena/FileWriter.cpp +++ b/src/Athena/FileWriter.cpp @@ -33,26 +33,6 @@ FileWriter::~FileWriter() close(); } -void FileWriter::setEndian(Endian endian) -{ - m_endian = endian; -} - -Endian FileWriter::endian() const -{ - return m_endian; -} - -bool FileWriter::isBigEndian() const -{ - return (m_endian == Endian::BigEndian); -} - -bool FileWriter::isLittleEndian() const -{ - return (m_endian == Endian::LittleEndian); -} - void FileWriter::open(bool overwrite) { if (overwrite) @@ -77,11 +57,6 @@ void FileWriter::close() return; } -bool FileWriter::isOpen() const -{ - return m_fileHandle != NULL; -} - void FileWriter::seek(atInt64 pos, SeekOrigin origin) { if (fseeko64(m_fileHandle, pos, (int)origin) != 0) @@ -150,11 +125,6 @@ void FileWriter::writeUByte(atUint8 val) THROW_IO_EXCEPTION("Unable to write to stream"); } -void FileWriter::writeByte(atInt8 val) -{ - writeUByte(val); -} - void FileWriter::writeUBytes(const atUint8* data, atUint64 len) { if (!isOpen()) @@ -166,11 +136,6 @@ void FileWriter::writeUBytes(const atUint8* data, atUint64 len) THROW_IO_EXCEPTION("Unable to write to stream"); } -void FileWriter::writeBytes(const atInt8* data, atUint64 len) -{ - writeUBytes((atUint8*)data, len); -} - void FileWriter::writeUint16(atUint16 val) { if (!isOpen()) @@ -185,11 +150,6 @@ void FileWriter::writeUint16(atUint16 val) THROW_IO_EXCEPTION("Unable to write to stream"); } -void FileWriter::writeInt16(atInt16 val) -{ - writeUint16(val); -} - void FileWriter::writeUint32(atUint32 val) { if (!isOpen()) @@ -204,11 +164,6 @@ void FileWriter::writeUint32(atUint32 val) THROW_IO_EXCEPTION("Unable to write to stream"); } -void FileWriter::writeInt32(atInt32 val) -{ - writeUint32(val); -} - void FileWriter::writeUint64(atUint64 val) { if (!isOpen()) @@ -223,11 +178,6 @@ void FileWriter::writeUint64(atUint64 val) THROW_IO_EXCEPTION("Unable to write to stream"); } -void FileWriter::writeInt64(atInt64 val) -{ - writeUint64(val); -} - void FileWriter::writeDouble(double val) { if (!isOpen()) @@ -256,11 +206,6 @@ void FileWriter::writeFloat(float val) THROW_IO_EXCEPTION("Unable to write to stream"); } -void FileWriter::writeBool(bool val) -{ - writeByte(val); -} - void FileWriter::writeVec3f(atVec3f vec) { if (!isOpen()) @@ -420,10 +365,5 @@ void FileWriter::fill(atInt8 byte, atUint64 len) fwrite(&byte, 1, len, m_fileHandle); } -void FileWriter::fill(atUint8 byte, atUint64 len) -{ - fill((atInt8)byte, len); -} - } } // Athena diff --git a/src/Athena/MemoryReader.cpp b/src/Athena/MemoryReader.cpp index 31c5603..7ebd3d1 100644 --- a/src/Athena/MemoryReader.cpp +++ b/src/Athena/MemoryReader.cpp @@ -54,31 +54,6 @@ MemoryReader::~MemoryReader() m_data = NULL; } -void MemoryReader::setEndian(Endian endian) -{ - m_endian = endian; -} - -Endian MemoryReader::endian() const -{ - return m_endian; -} - -bool MemoryReader::isBigEndian() const -{ - return (m_endian == Endian::BigEndian); -} - -bool MemoryReader::isLittleEndian() const -{ - return (m_endian == Endian::LittleEndian); -} - -bool MemoryReader::isOpen() const -{ - return m_data != nullptr; -} - void MemoryReader::seek(atInt64 position, SeekOrigin origin) { switch (origin) @@ -106,21 +81,6 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) } } -bool MemoryReader::atEnd() const -{ - return m_position >= m_length; -} - -atUint64 MemoryReader::position() const -{ - return m_position; -} - -atUint64 MemoryReader::length() const -{ - return m_length; -} - void MemoryReader::setData(const atUint8* data, atUint64 length) { if (m_data) @@ -140,16 +100,6 @@ atUint8* MemoryReader::data() const return ret; } -void MemoryReader::setFilepath(const std::string& filepath) -{ - m_filepath = filepath; -} - -std::string MemoryReader::filepath() const -{ - return m_filepath; -} - void MemoryReader::seekBit(int bit) { if (!m_data) @@ -285,11 +235,6 @@ atInt16 MemoryReader::readInt16() return ret; } -atUint16 MemoryReader::readUint16() -{ - return readInt16(); -} - atInt32 MemoryReader::readInt32() { if (!m_data) @@ -315,10 +260,6 @@ atInt32 MemoryReader::readInt32() return ret; } -atUint32 MemoryReader::readUint32() -{ - return readInt32(); -} atInt64 MemoryReader::readInt64() { @@ -345,11 +286,6 @@ atInt64 MemoryReader::readInt64() return ret; } -atUint64 MemoryReader::readUint64() -{ - return readInt64(); -} - float MemoryReader::readFloat() { if (!m_data) @@ -566,11 +502,6 @@ std::wstring MemoryReader::readWString(atInt32 fixedLen) return ret; } -void MemoryReader::setProgressCallback(std::function cb) -{ - m_progressCallback = cb; -} - void MemoryReader::loadData() { FILE* in; diff --git a/src/Athena/MemoryWriter.cpp b/src/Athena/MemoryWriter.cpp index cfb2c55..37de306 100644 --- a/src/Athena/MemoryWriter.cpp +++ b/src/Athena/MemoryWriter.cpp @@ -56,31 +56,6 @@ MemoryWriter::~MemoryWriter() m_data = nullptr; } -void MemoryWriter::setEndian(Endian endian) -{ - m_endian = endian; -} - -Endian MemoryWriter::endian() const -{ - return m_endian; -} - -bool MemoryWriter::isBigEndian() const -{ - return (m_endian == Endian::BigEndian); -} - -bool MemoryWriter::isLittleEndian() const -{ - return (m_endian == Endian::LittleEndian); -} - -bool MemoryWriter::isOpen() const -{ - return m_data != nullptr; -} - void MemoryWriter::seek(atInt64 position, SeekOrigin origin) { switch (origin) @@ -117,31 +92,6 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) } } -bool MemoryWriter::atEnd() const -{ - return m_position >= m_length; -} - -atUint64 MemoryWriter::position() const -{ - return m_position; -} - -atUint64 MemoryWriter::length() const -{ - return m_length; -} - -void MemoryWriter::setFilepath(const std::string& filepath) -{ - m_filepath = filepath; -} - -std::string MemoryWriter::filepath() const -{ - return m_filepath; -} - void MemoryWriter::setData(const atUint8* data, atUint64 length) { if (m_data) @@ -249,11 +199,6 @@ void MemoryWriter::writeUByte(atUint8 val) m_position++; } -void MemoryWriter::writeByte(atInt8 val) -{ - writeUByte(val); -} - void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) { if (!isOpen()) @@ -276,11 +221,6 @@ void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) m_position += length; } -void MemoryWriter::writeBytes(const atInt8* data, atUint64 length) -{ - writeUBytes((atUint8*)data, length); -} - void MemoryWriter::writeInt16(atInt16 val) { if (!isOpen()) @@ -304,11 +244,6 @@ void MemoryWriter::writeInt16(atInt16 val) m_position += sizeof(atInt16); } -void MemoryWriter::writeUint16(atUint16 val) -{ - writeInt16(val); -} - void MemoryWriter::writeInt32(atInt32 val) { if (!isOpen()) @@ -332,11 +267,6 @@ void MemoryWriter::writeInt32(atInt32 val) m_position += sizeof(atInt32); } -void MemoryWriter::writeUint32(atUint32 val) -{ - writeInt32(val); -} - void MemoryWriter::writeInt64(atInt64 val) { if (!isOpen()) @@ -361,11 +291,6 @@ void MemoryWriter::writeInt64(atInt64 val) m_position += sizeof(atInt64); } -void MemoryWriter::writeUint64(atUint64 val) -{ - writeInt64(val); -} - void MemoryWriter::writeFloat(float val) { if (!isOpen()) @@ -599,16 +524,6 @@ void MemoryWriter::fill(atUint8 val, atUint64 length) writeUByte(val); } -void MemoryWriter::fill(atInt8 val, atUint64 length) -{ - fill((atUint8)val, length); -} - -void MemoryWriter::setProgressCallback(std::function cb) -{ - m_progressCallback = cb; -} - void MemoryWriter::resize(atUint64 newSize) { if (newSize < m_length)