Merge pull request #17 from libAthena/opt

Various Header Optimizations
This commit is contained in:
Jack Andersen 2015-07-02 16:43:53 -07:00
commit 6ac88b37f4
10 changed files with 124 additions and 352 deletions

View File

@ -1,7 +1,7 @@
# PKGBUILD for libAthena # PKGBUILD for libAthena
_pkgname=libathena _pkgname=libathena
pkgname=$_pkgname-git pkgname=$_pkgname-git
pkgver=1.1.0.44.g071d91a pkgver=1.1.0.59.g582d2ce
pkgrel=1 pkgrel=1
pkgdesc="Basic cross platform IO library" pkgdesc="Basic cross platform IO library"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')

View File

@ -91,9 +91,9 @@ struct DNA
{ {
Delete expl; Delete expl;
inline void read(IStreamReader& reader) inline void read(IStreamReader& reader)
{*this = reader.readUTF8(sizeVar);} {*this = reader.readUnicode(sizeVar);}
inline void write(IStreamWriter& writer) const inline void write(IStreamWriter& writer) const
{writer.writeUTF8(*this, sizeVar);} {writer.writeUnicode(*this, sizeVar);}
inline std::string& operator=(const std::string& __str) inline std::string& operator=(const std::string& __str)
{return this->assign(__str);} {return this->assign(__str);}
inline std::string& operator=(std::string&& __str) inline std::string& operator=(std::string&& __str)

View File

@ -14,18 +14,26 @@ class FileReader : public IStreamReader
public: public:
FileReader(const std::string& filename); FileReader(const std::string& filename);
virtual ~FileReader(); 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 open();
void close(); void close();
bool isOpen() const; inline bool isOpen() const
{return m_fileHandle != NULL;}
bool save(); bool save();
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); 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; bool atEnd() const;
atUint64 position() const; atUint64 position() const;
atUint64 length() const; atUint64 length() const;
@ -34,20 +42,27 @@ public:
void seekBit(int); void seekBit(int);
bool readBit(); bool readBit();
atUint8 readUByte(); atUint8 readUByte();
atInt8 readByte(); inline atInt8 readByte()
{return (atInt8)FileReader::readUByte();}
atUint8* readUBytes(atUint64 len); atUint8* readUBytes(atUint64 len);
atInt8* readBytes(atUint64 len); inline atInt8* readBytes(atUint64 len)
atUint64 readBytesToBuf(void* buf, atUint64 len) {return readUBytesToBuf(buf, len);} {return (atInt8*)FileReader::readUBytes(len);}
atUint64 readBytesToBuf(void* buf, atUint64 len)
{return FileReader::readUBytesToBuf(buf, len);}
atUint64 readUBytesToBuf(void* buf, atUint64 len); atUint64 readUBytesToBuf(void* buf, atUint64 len);
atUint16 readUint16(); atUint16 readUint16();
atInt16 readInt16(); inline atInt16 readInt16()
{return (atInt16)FileReader::readUint16();}
atUint32 readUint32(); atUint32 readUint32();
atInt32 readInt32(); inline atInt32 readInt32()
{return (atInt32)FileReader::readUint32();}
atUint64 readUint64(); atUint64 readUint64();
atInt64 readInt64(); inline atInt64 readInt64()
{return (atInt64)FileReader::readUint64();}
double readDouble(); double readDouble();
float readFloat(); float readFloat();
bool readBool(); inline bool readBool()
{return (FileReader::readByte() != 0);}
atVec3f readVec3f(); atVec3f readVec3f();
atVec4f readVec4f(); atVec4f readVec4f();
std::string readString(atInt32 fixedLen = -1); std::string readString(atInt32 fixedLen = -1);

View File

@ -14,13 +14,19 @@ public:
FileWriter(const std::string& filename, bool overwrite = true); FileWriter(const std::string& filename, bool overwrite = true);
virtual ~FileWriter(); virtual ~FileWriter();
void setEndian(Endian endian); inline void setEndian(Endian endian)
Endian endian() const; {m_endian = endian;}
bool isBigEndian() const; inline Endian endian() const
bool isLittleEndian() 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 open(bool overwrite = true);
void close(); void close();
bool isOpen() const; inline bool isOpen() const
{return m_fileHandle != NULL;}
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);} inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);}
bool atEnd() const; bool atEnd() const;
@ -30,25 +36,32 @@ public:
void writeBit(bool val); void writeBit(bool val);
void seekBit(int bit); void seekBit(int bit);
void writeUByte(atUint8 val); void writeUByte(atUint8 val);
void writeByte(atInt8 val); inline void writeByte(atInt8 val)
{FileWriter::writeUByte(val);}
void writeUBytes(const atUint8* data, atUint64 len); 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 writeUint16(atUint16 val);
void writeInt16(atInt16 val); inline void writeInt16(atInt16 val)
{FileWriter::writeUint16(val);}
void writeUint32(atUint32 val); void writeUint32(atUint32 val);
void writeInt32(atInt32 val); inline void writeInt32(atInt32 val)
{FileWriter::writeUint32(val);}
void writeUint64(atUint64 val); void writeUint64(atUint64 val);
void writeInt64(atInt64 val); inline void writeInt64(atInt64 val)
{FileWriter::writeUint64(val);}
void writeDouble(double val); void writeDouble(double val);
void writeFloat(float val); void writeFloat(float val);
void writeBool(bool val); inline void writeBool(bool val)
{FileWriter::writeByte(val);}
void writeVec3f(atVec3f vec); void writeVec3f(atVec3f vec);
void writeVec4f(atVec4f vec); void writeVec4f(atVec4f vec);
void writeString(const std::string& val, atInt32 fixedLen = -1); void writeString(const std::string& val, atInt32 fixedLen = -1);
void writeWString(const std::wstring& str, atInt32 fixedLen = -1); void writeWString(const std::wstring& str, atInt32 fixedLen = -1);
void writeUnicode(const std::string& str, atInt32 fixedLen = -1); void writeUnicode(const std::string& str, atInt32 fixedLen = -1);
void fill(atInt8 byte, atUint64 len); 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: private:
std::string m_filename; std::string m_filename;
FILE* m_fileHandle; FILE* m_fileHandle;

View File

@ -39,31 +39,37 @@ public:
* *
* \param endian The Endianess to set \sa Endian * \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 /*! \brief Returns the current Endianness of the stream
* *
* \return Endian The current Stream Endianess * \return Endian The current Stream Endianess
*/ */
Endian endian() const; inline Endian endian() const
{return m_endian;}
/*! \brief Returns whether the stream is BigEndian /*! \brief Returns whether the stream is BigEndian
* *
* \return bool True for BigEndian; False for LittleEndian * \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 /*! \brief Returns whether the stream is LittleEndian
* *
* \return bool True for LittleEndian; False for BigEndian * \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. /*! \brief Retuns whether or not the Stream is open.
* *
* \return True if open; False otherwise. * \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.<br /> /*! \brief Sets the buffers position relative to the specified position.<br />
* It seeks relative to the current position by default. * It seeks relative to the current position by default.
@ -80,19 +86,23 @@ public:
* *
* \return bool True if at end; False otherwise. * \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. /*! \brief Returns the current position in the stream.
* *
* \return Int64 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. /*! \brief Returns whether or not the stream is at the end.
* *
* \return bool True if at end; False otherwise. * \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.<br /> /*! \brief Sets the buffer to the given one, deleting the current one.<br />
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data * <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
@ -120,12 +130,15 @@ public:
* \sa Endian * \sa Endian
* \param filepath The path to write to. * \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 /*! \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 * \brief Seeks to the specified bit within the current byte
@ -184,7 +197,8 @@ public:
* \return Uint16 The value at the current address * \return Uint16 The value at the current address
* \throw IOException when address is out of range * \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 /*! \brief Reads a Int32 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position * and Stream settings, and advances the current position
@ -204,7 +218,8 @@ public:
* \return Uint32 The value at the current address * \return Uint32 The value at the current address
* \throw IOException when address is out of range * \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 /*! \brief Reads a Int64 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position * and Stream settings, and advances the current position
@ -224,7 +239,8 @@ public:
* \return Uint64 The value at the current address * \return Uint64 The value at the current address
* \throw IOException when address is out of range * \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 /*! \brief Reads a float and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position * and Stream settings, and advances the current position
@ -291,7 +307,8 @@ public:
*/ */
std::wstring readWString(atInt32 fixedLen = -1); std::wstring readWString(atInt32 fixedLen = -1);
void setProgressCallback(std::function<void(int)> cb); inline void setProgressCallback(std::function<void(int)> cb)
{m_progressCallback = cb;}
protected: protected:
void loadData(); void loadData();
atUint8* m_data; atUint8* m_data;

View File

@ -40,31 +40,37 @@ public:
* *
* \param endian The Endianess to set \sa Endian * \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 /*! \brief Returns the current Endianness of the stream
* *
* \return Endian The current Stream Endianess * \return Endian The current Stream Endianess
*/ */
Endian endian() const; inline Endian endian() const
{return m_endian;}
/*! \brief Returns whether the stream is BigEndian /*! \brief Returns whether the stream is BigEndian
* *
* \return bool True for BigEndian; False for LittleEndian * \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 /*! \brief Returns whether the stream is LittleEndian
* *
* \return bool True for LittleEndian; False for BigEndian * \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. /*! \brief Retuns whether or not the Stream is open.
* *
* \return True if open; False otherwise. * \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.<br /> /*! \brief Sets the buffers position relative to the specified position.<br />
* It seeks relative to the current position by default. * It seeks relative to the current position by default.
@ -82,20 +88,23 @@ public:
* *
* \return bool True if at end; False otherwise. * \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. /*! \brief Returns the current position in the stream.
* *
* \return Int64 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. /*! \brief Returns whether or not the stream is at the end.
* *
* \return bool True if at end; False otherwise. * \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.<br /> /*! \brief Sets the buffer to the given one, deleting the current one.<br />
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data * <b>BEWARE:</b> 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. * \param filepath The path to write to.
*/ */
void setFilepath(const std::string& filepath); inline void setFilepath(const std::string& filepath)
{m_filepath = filepath;}
/*! \brief /*! \brief
* Returns the target file * Returns the target file
*/ */
std::string filepath() const; inline std::string filepath() const
{return m_filepath;}
/*! \brief Saves the file to the specified file. /*! \brief Saves the file to the specified file.
* *
@ -156,7 +168,8 @@ public:
* \param byte The value to write * \param byte The value to write
* \throw IOException * \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 /*! \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. * 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 data The buffer to write
* \param length The amount 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. /*! \brief Writes an Int16 to the buffer and advances the buffer.
* It also swaps the bytes depending on the platform and Stream settings. * It also swaps the bytes depending on the platform and Stream settings.
@ -188,7 +202,8 @@ public:
* \sa Endian * \sa Endian
* \param val The value to write to the buffer * \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. /*! \brief Writes an Int32 to the buffer and advances the buffer.
* It also swaps the bytes depending on the platform and Stream settings. * It also swaps the bytes depending on the platform and Stream settings.
@ -204,7 +219,8 @@ public:
* \sa Endian * \sa Endian
* \param val The value to write to the buffer * \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. /*! \brief Writes an Int64 to the buffer and advances the buffer.
* It also swaps the bytes depending on the platform and Stream settings. * It also swaps the bytes depending on the platform and Stream settings.
@ -220,7 +236,8 @@ public:
* \sa Endian * \sa Endian
* \param val The value to write to the buffer * \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. /*! \brief Writes an float to the buffer and advances the buffer.
* It also swaps the bytes depending on the platform and Stream settings. * 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(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<void(int)> cb); inline void setProgressCallback(std::function<void(int)> cb)
{m_progressCallback = cb;}
protected: protected:
void loadData(); void loadData();
atUint8* m_data; atUint8* m_data;

View File

@ -30,31 +30,6 @@ FileReader::~FileReader()
close(); 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() void FileReader::open()
{ {
m_fileHandle = fopen(m_filename.c_str(), "rb"); m_fileHandle = fopen(m_filename.c_str(), "rb");
@ -76,11 +51,6 @@ void FileReader::close()
return; return;
} }
bool FileReader::isOpen() const
{
return m_fileHandle != NULL;
}
void FileReader::seek(atInt64 pos, SeekOrigin origin) void FileReader::seek(atInt64 pos, SeekOrigin origin)
{ {
if (fseeko64(m_fileHandle, pos, (int)origin) != 0) if (fseeko64(m_fileHandle, pos, (int)origin) != 0)
@ -158,14 +128,6 @@ atUint8 FileReader::readUByte()
return val; 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) atUint8* FileReader::readUBytes(atUint64 len)
{ {
if (!isOpen()) if (!isOpen())
@ -186,14 +148,6 @@ atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len)
return fread(buf, 1, len, m_fileHandle); 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() atUint16 FileReader::readUint16()
{ {
if (!isOpen()) if (!isOpen())
@ -209,14 +163,6 @@ atUint16 FileReader::readUint16()
return val; return val;
} }
atInt16 FileReader::readInt16()
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading");
return (atInt16)readUint16();
}
atUint32 FileReader::readUint32() atUint32 FileReader::readUint32()
{ {
if (!isOpen()) if (!isOpen())
@ -232,14 +178,6 @@ atUint32 FileReader::readUint32()
return val; return val;
} }
atInt32 FileReader::readInt32()
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading");
return (atInt32)readUint32();
}
atUint64 FileReader::readUint64() atUint64 FileReader::readUint64()
{ {
if (!isOpen()) if (!isOpen())
@ -255,14 +193,6 @@ atUint64 FileReader::readUint64()
return val; return val;
} }
atInt64 FileReader::readInt64()
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading");
return (atInt64)readUint64();
}
double FileReader::readDouble() double FileReader::readDouble()
{ {
if (!isOpen()) if (!isOpen())
@ -293,14 +223,6 @@ float FileReader::readFloat()
return val; 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 FileReader::readVec3f()
{ {
atVec3f val = {}; atVec3f val = {};

View File

@ -33,26 +33,6 @@ FileWriter::~FileWriter()
close(); 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) void FileWriter::open(bool overwrite)
{ {
if (overwrite) if (overwrite)
@ -77,11 +57,6 @@ void FileWriter::close()
return; return;
} }
bool FileWriter::isOpen() const
{
return m_fileHandle != NULL;
}
void FileWriter::seek(atInt64 pos, SeekOrigin origin) void FileWriter::seek(atInt64 pos, SeekOrigin origin)
{ {
if (fseeko64(m_fileHandle, pos, (int)origin) != 0) 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"); THROW_IO_EXCEPTION("Unable to write to stream");
} }
void FileWriter::writeByte(atInt8 val)
{
writeUByte(val);
}
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) void FileWriter::writeUBytes(const atUint8* data, atUint64 len)
{ {
if (!isOpen()) if (!isOpen())
@ -166,11 +136,6 @@ void FileWriter::writeUBytes(const atUint8* data, atUint64 len)
THROW_IO_EXCEPTION("Unable to write to stream"); 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) void FileWriter::writeUint16(atUint16 val)
{ {
if (!isOpen()) if (!isOpen())
@ -185,11 +150,6 @@ void FileWriter::writeUint16(atUint16 val)
THROW_IO_EXCEPTION("Unable to write to stream"); THROW_IO_EXCEPTION("Unable to write to stream");
} }
void FileWriter::writeInt16(atInt16 val)
{
writeUint16(val);
}
void FileWriter::writeUint32(atUint32 val) void FileWriter::writeUint32(atUint32 val)
{ {
if (!isOpen()) if (!isOpen())
@ -204,11 +164,6 @@ void FileWriter::writeUint32(atUint32 val)
THROW_IO_EXCEPTION("Unable to write to stream"); THROW_IO_EXCEPTION("Unable to write to stream");
} }
void FileWriter::writeInt32(atInt32 val)
{
writeUint32(val);
}
void FileWriter::writeUint64(atUint64 val) void FileWriter::writeUint64(atUint64 val)
{ {
if (!isOpen()) if (!isOpen())
@ -223,11 +178,6 @@ void FileWriter::writeUint64(atUint64 val)
THROW_IO_EXCEPTION("Unable to write to stream"); THROW_IO_EXCEPTION("Unable to write to stream");
} }
void FileWriter::writeInt64(atInt64 val)
{
writeUint64(val);
}
void FileWriter::writeDouble(double val) void FileWriter::writeDouble(double val)
{ {
if (!isOpen()) if (!isOpen())
@ -256,11 +206,6 @@ void FileWriter::writeFloat(float val)
THROW_IO_EXCEPTION("Unable to write to stream"); THROW_IO_EXCEPTION("Unable to write to stream");
} }
void FileWriter::writeBool(bool val)
{
writeByte(val);
}
void FileWriter::writeVec3f(atVec3f vec) void FileWriter::writeVec3f(atVec3f vec)
{ {
if (!isOpen()) if (!isOpen())
@ -420,10 +365,5 @@ void FileWriter::fill(atInt8 byte, atUint64 len)
fwrite(&byte, 1, len, m_fileHandle); fwrite(&byte, 1, len, m_fileHandle);
} }
void FileWriter::fill(atUint8 byte, atUint64 len)
{
fill((atInt8)byte, len);
}
} }
} // Athena } // Athena

View File

@ -54,31 +54,6 @@ MemoryReader::~MemoryReader()
m_data = NULL; 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) void MemoryReader::seek(atInt64 position, SeekOrigin origin)
{ {
switch (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) void MemoryReader::setData(const atUint8* data, atUint64 length)
{ {
if (m_data) if (m_data)
@ -140,16 +100,6 @@ atUint8* MemoryReader::data() const
return ret; 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) void MemoryReader::seekBit(int bit)
{ {
if (!m_data) if (!m_data)
@ -285,11 +235,6 @@ atInt16 MemoryReader::readInt16()
return ret; return ret;
} }
atUint16 MemoryReader::readUint16()
{
return readInt16();
}
atInt32 MemoryReader::readInt32() atInt32 MemoryReader::readInt32()
{ {
if (!m_data) if (!m_data)
@ -315,10 +260,6 @@ atInt32 MemoryReader::readInt32()
return ret; return ret;
} }
atUint32 MemoryReader::readUint32()
{
return readInt32();
}
atInt64 MemoryReader::readInt64() atInt64 MemoryReader::readInt64()
{ {
@ -345,11 +286,6 @@ atInt64 MemoryReader::readInt64()
return ret; return ret;
} }
atUint64 MemoryReader::readUint64()
{
return readInt64();
}
float MemoryReader::readFloat() float MemoryReader::readFloat()
{ {
if (!m_data) if (!m_data)
@ -566,11 +502,6 @@ std::wstring MemoryReader::readWString(atInt32 fixedLen)
return ret; return ret;
} }
void MemoryReader::setProgressCallback(std::function<void (int)> cb)
{
m_progressCallback = cb;
}
void MemoryReader::loadData() void MemoryReader::loadData()
{ {
FILE* in; FILE* in;

View File

@ -56,31 +56,6 @@ MemoryWriter::~MemoryWriter()
m_data = nullptr; 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) void MemoryWriter::seek(atInt64 position, SeekOrigin origin)
{ {
switch (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) void MemoryWriter::setData(const atUint8* data, atUint64 length)
{ {
if (m_data) if (m_data)
@ -249,11 +199,6 @@ void MemoryWriter::writeUByte(atUint8 val)
m_position++; m_position++;
} }
void MemoryWriter::writeByte(atInt8 val)
{
writeUByte(val);
}
void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length)
{ {
if (!isOpen()) if (!isOpen())
@ -276,11 +221,6 @@ void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length)
m_position += length; m_position += length;
} }
void MemoryWriter::writeBytes(const atInt8* data, atUint64 length)
{
writeUBytes((atUint8*)data, length);
}
void MemoryWriter::writeInt16(atInt16 val) void MemoryWriter::writeInt16(atInt16 val)
{ {
if (!isOpen()) if (!isOpen())
@ -304,11 +244,6 @@ void MemoryWriter::writeInt16(atInt16 val)
m_position += sizeof(atInt16); m_position += sizeof(atInt16);
} }
void MemoryWriter::writeUint16(atUint16 val)
{
writeInt16(val);
}
void MemoryWriter::writeInt32(atInt32 val) void MemoryWriter::writeInt32(atInt32 val)
{ {
if (!isOpen()) if (!isOpen())
@ -332,11 +267,6 @@ void MemoryWriter::writeInt32(atInt32 val)
m_position += sizeof(atInt32); m_position += sizeof(atInt32);
} }
void MemoryWriter::writeUint32(atUint32 val)
{
writeInt32(val);
}
void MemoryWriter::writeInt64(atInt64 val) void MemoryWriter::writeInt64(atInt64 val)
{ {
if (!isOpen()) if (!isOpen())
@ -361,11 +291,6 @@ void MemoryWriter::writeInt64(atInt64 val)
m_position += sizeof(atInt64); m_position += sizeof(atInt64);
} }
void MemoryWriter::writeUint64(atUint64 val)
{
writeInt64(val);
}
void MemoryWriter::writeFloat(float val) void MemoryWriter::writeFloat(float val)
{ {
if (!isOpen()) if (!isOpen())
@ -599,16 +524,6 @@ void MemoryWriter::fill(atUint8 val, atUint64 length)
writeUByte(val); writeUByte(val);
} }
void MemoryWriter::fill(atInt8 val, atUint64 length)
{
fill((atUint8)val, length);
}
void MemoryWriter::setProgressCallback(std::function<void (int)> cb)
{
m_progressCallback = cb;
}
void MemoryWriter::resize(atUint64 newSize) void MemoryWriter::resize(atUint64 newSize)
{ {
if (newSize < m_length) if (newSize < m_length)