diff --git a/AthenaCore.pri b/AthenaCore.pri index 9eeef50..c94feee 100644 --- a/AthenaCore.pri +++ b/AthenaCore.pri @@ -11,8 +11,8 @@ SOURCES += \ $$PWD/src/Athena/Utility.cpp \ $$PWD/src/Athena/FileReader.cpp \ $$PWD/src/Athena/FileWriter.cpp \ - $$PWD/src/Athena/BinaryReader.cpp \ - $$PWD/src/Athena/BinaryWriter.cpp \ + $$PWD/src/Athena/MemoryReader.cpp \ + $$PWD/src/Athena/MemoryWriter.cpp \ $$PWD/src/Athena/Global.cpp \ $$PWD/src/Athena/Checksums.cpp \ $$PWD/src/Athena/Compression.cpp \ @@ -24,7 +24,9 @@ SOURCES += \ win32:SOURCES += $$PWD/src/win32_largefilewrapper.c HEADERS += \ - $$PWD/include/Athena/Stream.hpp \ + $$PWD/include/Athena/IStream.hpp \ + $$PWD/include/Athena/IStreamReader.hpp \ + $$PWD/include/Athena/IStreamWriter.hpp \ $$PWD/include/Athena/Types.hpp \ $$PWD/include/Athena/Utility.hpp \ $$PWD/include/Athena/Global.hpp \ @@ -35,8 +37,8 @@ HEADERS += \ $$PWD/include/Athena/InvalidOperationException.hpp \ $$PWD/include/Athena/FileReader.hpp \ $$PWD/include/Athena/FileWriter.hpp \ - $$PWD/include/Athena/BinaryReader.hpp \ - $$PWD/include/Athena/BinaryWriter.hpp \ + $$PWD/include/Athena/MemoryReader.hpp \ + $$PWD/include/Athena/MemoryWriter.hpp \ $$PWD/include/Athena/NotImplementedException.hpp \ $$PWD/include/Athena/Checksums.hpp \ $$PWD/include/Athena/Compression.hpp \ diff --git a/include/Athena/ALTTPEnums.hpp b/include/Athena/ALTTPEnums.hpp index 9bdb74b..6d5ae41 100644 --- a/include/Athena/ALTTPEnums.hpp +++ b/include/Athena/ALTTPEnums.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __ALTTP_ENUMS_HPP__ -#define __ALTTP_ENUMS_HPP__ +#ifndef ALTTP_ENUMS_HPP +#define ALTTP_ENUMS_HPP #ifndef __DOXYGEN_IGNORE__ @@ -110,4 +110,4 @@ enum ALTTPTagAlong } // zelda #endif // __DOXYGEN_IGNORE__ -#endif // __ALTTP_ENUMS_HPP__ +#endif // ALTTP_ENUMS_HPP diff --git a/include/Athena/ALTTPFile.hpp b/include/Athena/ALTTPFile.hpp index 4a1f067..977df7f 100644 --- a/include/Athena/ALTTPFile.hpp +++ b/include/Athena/ALTTPFile.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __ALTTP_FILE_HPP__ -#define __ALTTP_FILE_HPP__ +#ifndef ALTTP_FILE_HPP +#define ALTTP_FILE_HPP #include "Athena/Types.hpp" #include @@ -89,5 +89,5 @@ private: }; } // zelda -#endif // __ALTTP_FILE_HPP__ +#endif // ALTTP_FILE_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPFileReader.hpp b/include/Athena/ALTTPFileReader.hpp index 01ff2a7..44716c8 100644 --- a/include/Athena/ALTTPFileReader.hpp +++ b/include/Athena/ALTTPFileReader.hpp @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __ALTTP_FILE_READER_HPP__ -#define __ALTTP_FILE_READER_HPP__ +#ifndef ALTTP_FILE_READER_HPP +#define ALTTP_FILE_READER_HPP #include #include "Athena/Types.hpp" -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" #include "Athena/ALTTPQuest.hpp" namespace Athena @@ -35,9 +35,9 @@ namespace io * all work is done using a memory buffer, and not read directly from the disk. * \sa BinaryReader */ -class ALTTPFileReader : protected BinaryReader +class ALTTPFileReader : protected MemoryReader { - BINARYREADER_BASE(); + MEMORYREADER_BASE(); public: /*! \brief This constructor takes an existing buffer to read from. @@ -66,5 +66,5 @@ private: } // io } // zelda -#endif // __ALTTP_FILE_READER_HPP__ +#endif // ALTTP_FILE_READER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPFileWriter.hpp b/include/Athena/ALTTPFileWriter.hpp index e9e36a0..600f200 100644 --- a/include/Athena/ALTTPFileWriter.hpp +++ b/include/Athena/ALTTPFileWriter.hpp @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __ALTTP_FILE_WRITER_HPP__ -#define __ALTTP_FILE_WRITER_HPP__ +#ifndef ALTTP_FILE_WRITER_HPP +#define ALTTP_FILE_WRITER_HPP #include -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" #include "Athena/ALTTPQuest.hpp" namespace Athena @@ -34,9 +34,9 @@ namespace io * all work is done using a memory buffer, and not written directly to the disk. * \sa BinaryReader */ -class ALTTPFileWriter : protected BinaryWriter +class ALTTPFileWriter : protected MemoryWriter { - BINARYWRITER_BASE(); + MEMORYWRITER_BASE(); public: /*! \brief This constructor takes an existing buffer to write to. @@ -68,5 +68,5 @@ private: } // io } // zelda -#endif // __ALTTP_FILE_WRITER_HPP__ +#endif // ALTTP_FILE_WRITER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPQuest.hpp b/include/Athena/ALTTPQuest.hpp index dc84d7f..5a46ec9 100644 --- a/include/Athena/ALTTPQuest.hpp +++ b/include/Athena/ALTTPQuest.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __ALTTP_QUEST_HPP__ -#define __ALTTP_QUEST_HPP__ +#ifndef ALTTP_QUEST_HPP +#define ALTTP_QUEST_HPP #include "Types.hpp" #include @@ -684,5 +684,5 @@ private: } // zelda -#endif // __ALTTP_QUEST_HPP__ +#endif // ALTTP_QUEST_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPStructs.hpp b/include/Athena/ALTTPStructs.hpp index 744cb53..5f6183e 100644 --- a/include/Athena/ALTTPStructs.hpp +++ b/include/Athena/ALTTPStructs.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __ALTTP_STRUCTS_HPP__ -#define __ALTTP_STRUCTS_HPP__ +#ifndef ALTTP_STRUCTS_HPP +#define ALTTP_STRUCTS_HPP #ifndef __DOXYGEN_IGNORE__ @@ -215,4 +215,4 @@ struct ALTTPProgressFlags2 } #endif // __DOXYGEN_IGNORE__ -#endif // __ALTTP_STRUCTS_HPP__ +#endif // ALTTP_STRUCTS_HPP diff --git a/include/Athena/Exception.hpp b/include/Athena/Exception.hpp index d3fd4a7..8fc7e1c 100644 --- a/include/Athena/Exception.hpp +++ b/include/Athena/Exception.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __EXCEPTION_HPP__ -#define __EXCEPTION_HPP__ +#ifndef EXCEPTION_HPP +#define EXCEPTION_HPP #include #include @@ -93,4 +93,4 @@ protected: } while(0) #endif -#endif +#endif // EXCEPTION_HPP diff --git a/include/Athena/FileNotFoundException.hpp b/include/Athena/FileNotFoundException.hpp index 1d600a6..6345415 100644 --- a/include/Athena/FileNotFoundException.hpp +++ b/include/Athena/FileNotFoundException.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __FILENOTFOUNDEXCEPTION_HPP__ -#define __FILENOTFOUNDEXCEPTION_HPP__ +#ifndef FILENOTFOUNDEXCEPTION_HPP +#define FILENOTFOUNDEXCEPTION_HPP #include "Athena/Exception.hpp" @@ -54,4 +54,4 @@ private: #define THROW_FILE_NOT_FOUND_EXCEPTION(msg) \ do { throw Athena::error::FileNotFoundException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); } while(0) -#endif +#endif // FILENOTFOUNDEXCEPTION_HPP diff --git a/include/Athena/FileReader.hpp b/include/Athena/FileReader.hpp index ddc2125..cdd7703 100644 --- a/include/Athena/FileReader.hpp +++ b/include/Athena/FileReader.hpp @@ -16,7 +16,7 @@ #ifndef FILESTREAM_HPP #define FILESTREAM_HPP -#include "Athena/Stream.hpp" +#include "Athena/IStreamReader.hpp" #include #include @@ -24,7 +24,7 @@ namespace Athena { namespace io { -class FileReader : public Stream +class FileReader : public IStreamReader { public: FileReader(const std::string& filename); diff --git a/include/Athena/FileWriter.hpp b/include/Athena/FileWriter.hpp index d63a3af..a5d43e4 100644 --- a/include/Athena/FileWriter.hpp +++ b/include/Athena/FileWriter.hpp @@ -16,13 +16,13 @@ #ifndef FILEWRITER_HPP #define FILEWRITER_HPP -#include "Athena/Stream.hpp" +#include "Athena/IStreamWriter.hpp" namespace Athena { namespace io { -class FileWriter : public Stream +class FileWriter : public IStreamWriter { public: FileWriter(const std::string& filename); @@ -71,7 +71,7 @@ private: } // Athena #ifndef FILEWRITER_BASE -#define FILEWRITER_BASE \ +#define FILEWRITER_BASE() \ private: \ typedef Athena::io::FileWriter base; diff --git a/include/Athena/IOException.hpp b/include/Athena/IOException.hpp index 6ff5d32..db7f656 100644 --- a/include/Athena/IOException.hpp +++ b/include/Athena/IOException.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __IOEXCEPTION_HPP__ -#define __IOEXCEPTION_HPP__ +#ifndef IOEXCEPTION_HPP +#define IOEXCEPTION_HPP #include "Athena/Exception.hpp" @@ -60,4 +60,5 @@ public: throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \ } while(0) #endif -#endif + +#endif // IOEXCEPTION_HPP diff --git a/include/Athena/IStream.hpp b/include/Athena/IStream.hpp new file mode 100644 index 0000000..95207cb --- /dev/null +++ b/include/Athena/IStream.hpp @@ -0,0 +1,46 @@ +// This file is part of libAthena. +// +// libAthena is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libAthena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libAthena. If not, see + +#ifndef STREAM_HPP +#define STREAM_HPP + +#include "Global.hpp" +#include "Athena/NotImplementedException.hpp" + +namespace Athena +{ +namespace io +{ +std::ostream& operator<<(std::ostream& os, Endian& endian); + +class IStream +{ +public: + virtual ~IStream() {} + + virtual void setEndian(Endian) = 0; + virtual Endian endian() const= 0; + virtual bool isBigEndian() const= 0; + virtual bool isLittleEndian()const= 0; + virtual bool isOpen() const= 0; + virtual void seek(atInt64, SeekOrigin)=0; + virtual bool atEnd() const= 0; + virtual atUint64 position() const= 0; + virtual atUint64 length() const= 0; + virtual void seekBit (int)=0; +}; +} +} +#endif // STREAM_HPP diff --git a/include/Athena/IStreamReader.hpp b/include/Athena/IStreamReader.hpp new file mode 100644 index 0000000..33b88d8 --- /dev/null +++ b/include/Athena/IStreamReader.hpp @@ -0,0 +1,44 @@ +#ifndef ISTREAMREADER_HPP +#define ISTREAMREADER_HPP + +#include "IStream.hpp" + +namespace Athena +{ +namespace io +{ +class IStreamReader : public IStream +{ +public: + virtual ~IStreamReader(); + virtual void setEndian(Endian) = 0; + virtual Endian endian() const= 0; + virtual bool isBigEndian() const= 0; + virtual bool isLittleEndian()const= 0; + virtual bool isOpen() const= 0; + virtual void seek(atInt64, SeekOrigin)=0; + virtual bool atEnd() const= 0; + virtual atUint64 position() const= 0; + virtual atUint64 length() const= 0; + virtual void seekBit (int)=0; + virtual bool readBit()=0; + virtual atUint8 readUByte()=0; + virtual atInt8 readByte()=0; + virtual atUint8* readUBytes(atUint64)=0; + virtual atInt8* readBytes(atUint64)=0; + virtual atUint16 readUint16()=0; + virtual atInt16 readInt16()=0; + virtual atUint32 readUint32()=0; + virtual atInt32 readInt32()=0; + virtual atUint64 readUint64()=0; + virtual atInt64 readInt64()=0; + virtual double readDouble()=0; + virtual float readFloat()=0; + virtual bool readBool()=0; + virtual std::string readUnicode(atInt32)=0; + virtual std::string readString(atInt32)=0; +}; +} +} +#endif // ISTREAMREADER + diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp new file mode 100644 index 0000000..7ec9a8b --- /dev/null +++ b/include/Athena/IStreamWriter.hpp @@ -0,0 +1,46 @@ +#ifndef ISTREAMWRITER_HPP +#define ISTREAMWRITER_HPP + +#include "IStream.hpp" + +namespace Athena +{ +namespace io +{ +class IStreamWriter : public IStream +{ +public: + virtual ~IStreamWriter(); + virtual void setEndian(Endian) = 0; + virtual Endian endian() const= 0; + virtual bool isBigEndian() const= 0; + virtual bool isLittleEndian()const= 0; + virtual bool isOpen() const= 0; + virtual void seek(atInt64, SeekOrigin)=0; + virtual bool atEnd() const= 0; + virtual atUint64 position() const= 0; + virtual atUint64 length() const= 0; + virtual void seekBit (int)=0; + virtual void writeBit (bool)=0; + virtual void writeUByte (atUint8)=0; + virtual void writeByte (atInt8)=0; + virtual void writeUBytes(atUint8*, atUint64)=0; + virtual void writeBytes (atInt8*, atUint64)=0; + virtual void writeUint16(atUint16)=0; + virtual void writeInt16 (atInt16)=0; + virtual void writeUint32(atUint32)=0; + virtual void writeInt32 (atInt32)=0; + virtual void writeUint64(atUint64)=0; + virtual void writeInt64 (atInt64)=0; + virtual void writeDouble(double)=0; + virtual void writeFloat (float)=0; + virtual void writeBool (bool)=0; + virtual void writeString(const std::string&)=0; + virtual void writeUnicode(const std::string&)=0; + virtual void fill(atUint8, atUint64)=0; + virtual void fill(atInt8, atUint64)=0; +}; +} +} +#endif // STREAMWRITER_HPP + diff --git a/include/Athena/InvalidOperationException.hpp b/include/Athena/InvalidOperationException.hpp index be05936..67c5643 100644 --- a/include/Athena/InvalidOperationException.hpp +++ b/include/Athena/InvalidOperationException.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __INVALID_OPERATION_EXCEPTION_HPP__ -#define __INVALID_OPERATION_EXCEPTION_HPP__ +#ifndef INVALID_OPERATION_EXCEPTION_HPP +#define INVALID_OPERATION_EXCEPTION_HPP #include #include @@ -60,4 +60,4 @@ public: throw Athena::error::InvalidOperationException(std::string("InvalidOperationException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \ } while(0) #endif -#endif // __INVALID_OPERATION_EXCEPTION_HPP__ +#endif // INVALID_OPERATION_EXCEPTION_HPP diff --git a/include/Athena/MCFile.hpp b/include/Athena/MCFile.hpp index 80c0db2..c03d88f 100644 --- a/include/Athena/MCFile.hpp +++ b/include/Athena/MCFile.hpp @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __MCFILE_HPP__ -#define __MCFILE_HPP__ +#ifndef MCFILE_HPP +#define MCFILE_HPP #include "Athena/Global.hpp" @@ -48,4 +48,4 @@ private: }; } // zelda -#endif // __MCFILE_HPP__ +#endif // MCFILE_HPP diff --git a/include/Athena/MCFileReader.hpp b/include/Athena/MCFileReader.hpp index 7cdc7e7..5df7e1f 100644 --- a/include/Athena/MCFileReader.hpp +++ b/include/Athena/MCFileReader.hpp @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __MCFILEREADER_HPP__ -#define __MCFILEREADER_HPP__ +#ifndef MCFILEREADER_HPP +#define MCFILEREADER_HPP -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" namespace Athena { @@ -34,9 +34,9 @@ namespace io * all work is done using a memory buffer, and not read directly from the disk. * \sa BinaryReader */ -class MCFileReader : public BinaryReader +class MCFileReader : public MemoryReader { - BINARYREADER_BASE(); + MEMORYREADER_BASE(); public: /*! * \brief This constructor takes an existing buffer to read from. @@ -64,5 +64,5 @@ public: } // io } // zelda -#endif // __MCFILEREADER_HPP__ +#endif // MCFILEREADER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/MCFileWriter.hpp b/include/Athena/MCFileWriter.hpp index 211f8e1..16065a6 100644 --- a/include/Athena/MCFileWriter.hpp +++ b/include/Athena/MCFileWriter.hpp @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __MCFILEWRITER_HPP__ -#define __MCFILEWRITER_HPP__ +#ifndef MCFILEWRITER_HPP +#define MCFILEWRITER_HPP #include "Athena/Types.hpp" -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" namespace Athena { @@ -35,9 +35,9 @@ namespace io * all work is done using a memory buffer, and not written directly from the disk. * \sa BinaryWriter */ -class MCFileWriter : protected BinaryWriter +class MCFileWriter : protected MemoryWriter { - BINARYWRITER_BASE(); + MEMORYWRITER_BASE(); public: /*! * \brief This constructor takes an existing buffer to write to. @@ -69,5 +69,5 @@ private: } // io } // zelda -#endif // __MCFILEWRITER_HPP__ +#endif // MCFILEWRITER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/BinaryReader.hpp b/include/Athena/MemoryReader.hpp similarity index 95% rename from include/Athena/BinaryReader.hpp rename to include/Athena/MemoryReader.hpp index c0688a0..90d23dd 100644 --- a/include/Athena/BinaryReader.hpp +++ b/include/Athena/MemoryReader.hpp @@ -13,10 +13,10 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __BINARYREADER_HPP__ -#define __BINARYREADER_HPP__ +#ifndef MEMORYREADER_HPP +#define MEMORYREADER_HPP -#include "Athena/Stream.hpp" +#include "Athena/IStreamReader.hpp" #include #include @@ -32,7 +32,7 @@ namespace io * this allows for fast, flexible code as well as the ability to quickly modify data * \sa Stream */ -class BinaryReader : public Stream +class MemoryReader : public IStreamReader { public: /*! \brief This constructor takes an existing buffer to read from. @@ -40,15 +40,15 @@ public: * \param data The existing buffer * \param length The length of the existing buffer */ - BinaryReader(const atUint8* data, atUint64 length); + MemoryReader(const atUint8* data, atUint64 length); /*! \brief This constructor creates an instance from a file on disk. * * \param filename The file to create the stream from */ - BinaryReader(const std::string& filename, std::function progressFun = nullptr); + MemoryReader(const std::string& filename, std::function progressFun = nullptr); - virtual ~BinaryReader(); + virtual ~MemoryReader(); /*! \brief Sets the Endianss of the stream * @@ -291,11 +291,11 @@ protected: } // io } // Athena -#ifndef BINARYREADER_BASE -#define BINARYREADER_BASE() \ +#ifndef MEMORYREADER_BASE +#define MEMORYREADER_BASE() \ private: \ - typedef Athena::io::BinaryReader base + typedef Athena::io::MemoryReader base -#endif // BINARYREADER_BASE +#endif // MEMORYREADER_BASE -#endif // __BINARYREADER_HPP__ +#endif // MEMORYREADER_HPP diff --git a/include/Athena/BinaryWriter.hpp b/include/Athena/MemoryWriter.hpp similarity index 95% rename from include/Athena/BinaryWriter.hpp rename to include/Athena/MemoryWriter.hpp index d464974..d04e10c 100644 --- a/include/Athena/BinaryWriter.hpp +++ b/include/Athena/MemoryWriter.hpp @@ -13,10 +13,10 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __BINARYWRITER_HPP__ -#define __BINARYWRITER_HPP__ +#ifndef MEMORYWRITER_HPP +#define MEMORYWRITER_HPP -#include "Athena/Stream.hpp" +#include "Athena/IStream.hpp" #include #include @@ -33,7 +33,7 @@ namespace io * this allows for fast, flexible code as well as the ability to quickly modify data * \sa Stream */ -class BinaryWriter : public Stream +class MemoryWriter : public IStream { public: /*! \brief This constructor takes an existing buffer to write to. @@ -41,15 +41,15 @@ public: * \param data The existing buffer * \param length The length of the existing buffer */ - explicit BinaryWriter(atUint8* data = nullptr, atUint64 length=0x10); + explicit MemoryWriter(atUint8* data = nullptr, atUint64 length=0x10); /*! \brief This constructor creates an instance from a file on disk. * * \param filename The file to create the stream from */ - BinaryWriter(const std::string& filename, std::function progressFun = nullptr); + MemoryWriter(const std::string& filename, std::function progressFun = nullptr); - virtual ~BinaryWriter(); + virtual ~MemoryWriter(); /*! \brief Sets the Endianss of the stream * @@ -291,9 +291,9 @@ private: } } -#ifndef BINARYWRITER_BASE -#define BINARYWRITER_BASE() \ +#ifndef MEMORYWRITER_BASE +#define MEMORYWRITER_BASE() \ private: \ - typedef Athena::io::BinaryWriter base + typedef Athena::io::MemoryWriter base #endif // BINARYWRITER_BASE -#endif // __BINARY_WRITER_HPP__ +#endif // MEMORYWRITER_HPP diff --git a/include/Athena/SkywardSwordFile.hpp b/include/Athena/SkywardSwordFile.hpp index f3bd962..48ab379 100644 --- a/include/Athena/SkywardSwordFile.hpp +++ b/include/Athena/SkywardSwordFile.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __SSFILE_HPP__ -#define __SSFILE_HPP__ +#ifndef SSFILE_HPP +#define SSFILE_HPP #include "Athena/Global.hpp" @@ -62,5 +62,5 @@ private: }; } -#endif // __SSFILE_HPP__ +#endif // SSFILE_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/SkywardSwordFileReader.hpp b/include/Athena/SkywardSwordFileReader.hpp index 498ffc2..bd16665 100644 --- a/include/Athena/SkywardSwordFileReader.hpp +++ b/include/Athena/SkywardSwordFileReader.hpp @@ -14,19 +14,19 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __SSFILEREADER_HPP__ -#define __SSFILEREADER_HPP__ +#ifndef SSFILEREADER_HPP +#define SSFILEREADER_HPP -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" namespace Athena { class SkywardSwordFile; namespace io { -class SkywardSwordFileReader : public BinaryReader +class SkywardSwordFileReader : public MemoryReader { - BINARYREADER_BASE(); + MEMORYREADER_BASE(); public: SkywardSwordFileReader(atUint8* data, atUint64 length); @@ -37,5 +37,5 @@ public: } // io } // zelda -#endif // __SSFILEREADER_HPP__ +#endif // SSFILEREADER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/SkywardSwordFileWriter.hpp b/include/Athena/SkywardSwordFileWriter.hpp index 80e8fa1..f65db48 100644 --- a/include/Athena/SkywardSwordFileWriter.hpp +++ b/include/Athena/SkywardSwordFileWriter.hpp @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __SSFILEWRITER_HPP__ -#define __SSFILEWRITER_HPP__ +#ifndef SSFILEWRITER_HPP +#define SSFILEWRITER_HPP -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" namespace Athena { @@ -26,9 +26,9 @@ class SkywardSwordFile; namespace io { -class SkywardSwordFileWriter : public BinaryWriter +class SkywardSwordFileWriter : public MemoryWriter { - BINARYWRITER_BASE(); + MEMORYWRITER_BASE(); public: SkywardSwordFileWriter(atUint8* data, atUint64 len); SkywardSwordFileWriter(const std::string& filename); @@ -37,5 +37,5 @@ public: }; } } -#endif // __SSFILEWRITER_HPP__ +#endif // SSFILEWRITER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/SpriteFileReader.hpp b/include/Athena/SpriteFileReader.hpp index f599eaa..267ca7e 100644 --- a/include/Athena/SpriteFileReader.hpp +++ b/include/Athena/SpriteFileReader.hpp @@ -17,7 +17,7 @@ #ifndef SSPRITEFILEREADER_HPP #define SSPRITEFILEREADER_HPP -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" namespace Athena { @@ -29,9 +29,9 @@ class SpriteFile; namespace io { -class SpriteFileReader : public BinaryReader +class SpriteFileReader : public MemoryReader { - BINARYREADER_BASE(); + MEMORYREADER_BASE(); public: SpriteFileReader(atUint8* data, atUint64 length); SpriteFileReader(const std::string& filepath); diff --git a/include/Athena/SpriteFileWriter.hpp b/include/Athena/SpriteFileWriter.hpp index be2edd8..9689ade 100644 --- a/include/Athena/SpriteFileWriter.hpp +++ b/include/Athena/SpriteFileWriter.hpp @@ -17,7 +17,7 @@ #ifndef SSPRITEFILEWRITER_HPP #define SSPRITEFILEWRITER_HPP -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" namespace Athena { @@ -29,9 +29,9 @@ class SpriteFile; namespace io { -class SpriteFileWriter : public BinaryWriter +class SpriteFileWriter : public MemoryWriter { - BINARYWRITER_BASE(); + MEMORYWRITER_BASE(); public: SpriteFileWriter(atUint8* data, atUint64 length); diff --git a/include/Athena/Stream.hpp b/include/Athena/Stream.hpp deleted file mode 100644 index 95e6715..0000000 --- a/include/Athena/Stream.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// This file is part of libAthena. -// -// libAthena is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// libAthena is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with libAthena. If not, see - -#ifndef STREAM_HPP -#define STREAM_HPP - -#include "Global.hpp" -#include "Athena/NotImplementedException.hpp" - -namespace Athena -{ -namespace io -{ -std::ostream& operator<<(std::ostream& os, Endian& endian); - -class Stream -{ -public: - virtual ~Stream() {} - - virtual void setEndian(Endian) = 0; - virtual Endian endian() const= 0; - virtual bool isBigEndian() const= 0; - virtual bool isLittleEndian()const= 0; - virtual bool isOpen() const= 0; - virtual void seek(atInt64, SeekOrigin)=0; - virtual bool atEnd() const= 0; - virtual atUint64 position() const= 0; - virtual atUint64 length() const= 0; -public: - virtual void seekBit (int){THROW_NOT_IMPLEMENTED_EXCEPTION();} - // Reading - virtual bool readBit() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atUint8 readUByte() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atInt8 readByte() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atUint8* readUBytes(atUint64){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atInt8* readBytes(atUint64) {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atUint16 readUint16() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atInt16 readInt16() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atUint32 readUint32() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atInt32 readInt32() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atUint64 readUint64() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual atInt64 readInt64() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual double readDouble() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual float readFloat() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual bool readBool() {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual std::string readUnicode(atInt32){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual std::string readString(atInt32) {THROW_NOT_IMPLEMENTED_EXCEPTION();} - // Writing - virtual void writeBit (bool){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeUByte (atUint8){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeByte (atInt8){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeUBytes(atUint8*, atUint64){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeBytes (atInt8*, atUint64){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeUint16(atUint16){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeInt16 (atInt16){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeUint32(atUint32){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeInt32 (atInt32){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeUint64(atUint64){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeInt64 (atInt64){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeDouble(double){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeFloat (float){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeBool (bool){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeString(const std::string&){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void writeUnicode(const std::string&){THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void fill(atUint8, atUint64) {THROW_NOT_IMPLEMENTED_EXCEPTION();} - virtual void fill(atInt8, atUint64) {THROW_NOT_IMPLEMENTED_EXCEPTION();} -}; -} -} -#endif // STREAM_HPP diff --git a/include/Athena/WiiImage.hpp b/include/Athena/WiiImage.hpp index 87a1a66..fb11997 100644 --- a/include/Athena/WiiImage.hpp +++ b/include/Athena/WiiImage.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __WIIIMAGE_HPP__ -#define __WIIIMAGE_HPP__ +#ifndef WIIIMAGE_HPP +#define WIIIMAGE_HPP #include "Athena/Types.hpp" diff --git a/include/Athena/WiiSave.hpp b/include/Athena/WiiSave.hpp index c88d1ad..55648a1 100644 --- a/include/Athena/WiiSave.hpp +++ b/include/Athena/WiiSave.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __WII__SAVE_HPP__ -#define __WII__SAVE_HPP__ +#ifndef WIISAVE_HPP +#define WIISAVE_HPP #include #include @@ -97,6 +97,6 @@ private: }; } // zelda -#endif // __WII__SAVE_HPP__ +#endif // WIISAVE_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/WiiSaveReader.hpp b/include/Athena/WiiSaveReader.hpp index 3ae72d6..542d1dd 100644 --- a/include/Athena/WiiSaveReader.hpp +++ b/include/Athena/WiiSaveReader.hpp @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __WII_SAVE_READER_HPP__ -#define __WII_SAVE_READER_HPP__ +#ifndef WIISAVEREADER_HPP +#define WIISAVEREADER_HPP #include "Athena/Global.hpp" -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" namespace Athena { @@ -37,9 +37,9 @@ namespace io * all work is done using a memory buffer, and not read directly from the disk. * \sa BinaryReader */ -class WiiSaveReader : protected BinaryReader +class WiiSaveReader : protected MemoryReader { - BINARYREADER_BASE(); + MEMORYREADER_BASE(); public: /*! \brief This constructor takes an existing buffer to read from. * @@ -69,5 +69,5 @@ private: } // io } // zelda -#endif // __WII_SAVE_READER_HPP__ +#endif // WIISAVEREADER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/WiiSaveWriter.hpp b/include/Athena/WiiSaveWriter.hpp index 3397482..070e330 100644 --- a/include/Athena/WiiSaveWriter.hpp +++ b/include/Athena/WiiSaveWriter.hpp @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#ifndef __WII_SAVE_WRITER_HPP__ -#define __WII_SAVE_WRITER_HPP__ +#ifndef WIISAVEWRITER_HPP +#define WIISAVEWRITER_HPP -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" namespace Athena { @@ -36,9 +36,9 @@ namespace io * all work is done using a memory buffer, and not written directly to the disk. * \sa BinaryReader */ -class WiiSaveWriter : protected BinaryWriter +class WiiSaveWriter : protected MemoryWriter { - BINARYWRITER_BASE(); + MEMORYWRITER_BASE(); public: /*! \brief This constructor creates an instance from a file on disk. * @@ -68,5 +68,5 @@ private: } // io } // zelda -#endif // __WII_SAVE_WRITER_HPP__ +#endif // WIISAVEWRITER_HPP #endif // ATHENA_NO_SAVES diff --git a/include/Athena/ZQuestFileReader.hpp b/include/Athena/ZQuestFileReader.hpp index 52c58e2..efe1cd8 100644 --- a/include/Athena/ZQuestFileReader.hpp +++ b/include/Athena/ZQuestFileReader.hpp @@ -17,7 +17,7 @@ #ifndef __ZQUESTFILEREADER_HPP__ #define __ZQUESTFILEREADER_HPP__ -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" namespace Athena { @@ -29,9 +29,9 @@ namespace io /*! * \brief The ZQuestFileReader class */ -class ZQuestFileReader : protected BinaryReader +class ZQuestFileReader : protected MemoryReader { - BINARYREADER_BASE(); + MEMORYREADER_BASE(); public: /*! diff --git a/include/Athena/ZQuestFileWriter.hpp b/include/Athena/ZQuestFileWriter.hpp index 90ca638..004e382 100644 --- a/include/Athena/ZQuestFileWriter.hpp +++ b/include/Athena/ZQuestFileWriter.hpp @@ -17,7 +17,7 @@ #ifndef __ZQUESTFILEWRITER_HPP__ #define __ZQUESTFILEWRITER_HPP__ -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" namespace Athena { @@ -29,9 +29,9 @@ namespace io /*! * \brief The ZQuestFileWriter class */ -class ZQuestFileWriter : protected BinaryWriter +class ZQuestFileWriter : protected MemoryWriter { - BINARYWRITER_BASE(); + MEMORYWRITER_BASE(); public: /*! diff --git a/src/Athena/BinaryReader.cpp b/src/Athena/MemoryReader.cpp similarity index 85% rename from src/Athena/BinaryReader.cpp rename to src/Athena/MemoryReader.cpp index 76f155c..6e86efd 100644 --- a/src/Athena/BinaryReader.cpp +++ b/src/Athena/MemoryReader.cpp @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#include "Athena/BinaryReader.hpp" +#include "Athena/MemoryReader.hpp" #include "Athena/IOException.hpp" #include "Athena/FileNotFoundException.hpp" #include "Athena/InvalidDataException.hpp" @@ -34,7 +34,7 @@ namespace Athena { namespace io { -BinaryReader::BinaryReader(const atUint8* data, atUint64 length) +MemoryReader::MemoryReader(const atUint8* data, atUint64 length) : m_length(length), m_position(0), m_bitPosition(0), @@ -50,7 +50,7 @@ BinaryReader::BinaryReader(const atUint8* data, atUint64 length) memcpy(m_data, data, m_length); } -BinaryReader::BinaryReader(const std::string& filename, std::function progFun) +MemoryReader::MemoryReader(const std::string& filename, std::function progFun) : m_data(NULL), m_length(0), m_filepath(filename), @@ -62,38 +62,38 @@ BinaryReader::BinaryReader(const std::string& filename, std::function loadData(); } -BinaryReader::~BinaryReader() +MemoryReader::~MemoryReader() { delete[] m_data; m_data = NULL; } -void BinaryReader::setEndian(Endian endian) +void MemoryReader::setEndian(Endian endian) { m_endian = endian; } -Endian BinaryReader::endian() const +Endian MemoryReader::endian() const { return m_endian; } -bool BinaryReader::isBigEndian() const +bool MemoryReader::isBigEndian() const { return (m_endian == Endian::BigEndian); } -bool BinaryReader::isLittleEndian() const +bool MemoryReader::isLittleEndian() const { return (m_endian == Endian::LittleEndian); } -bool BinaryReader::isOpen() const +bool MemoryReader::isOpen() const { return m_data != nullptr; } -void BinaryReader::seek(atInt64 position, SeekOrigin origin) +void MemoryReader::seek(atInt64 position, SeekOrigin origin) { switch (origin) { @@ -115,22 +115,22 @@ void BinaryReader::seek(atInt64 position, SeekOrigin origin) } } -bool BinaryReader::atEnd() const +bool MemoryReader::atEnd() const { return m_position >= m_length; } -atUint64 BinaryReader::position() const +atUint64 MemoryReader::position() const { return m_position; } -atUint64 BinaryReader::length() const +atUint64 MemoryReader::length() const { return m_length; } -void BinaryReader::setData(const atUint8* data, atUint64 length) +void MemoryReader::setData(const atUint8* data, atUint64 length) { if (m_data) delete[] m_data; @@ -141,7 +141,7 @@ void BinaryReader::setData(const atUint8* data, atUint64 length) m_bitPosition = 0; } -atUint8* BinaryReader::data() const +atUint8* MemoryReader::data() const { atUint8* ret = new atUint8[m_length]; memset(ret, 0, m_length); @@ -149,17 +149,17 @@ atUint8* BinaryReader::data() const return ret; } -void BinaryReader::setFilepath(const std::string& filepath) +void MemoryReader::setFilepath(const std::string& filepath) { m_filepath = filepath; } -std::string BinaryReader::filepath() const +std::string MemoryReader::filepath() const { return m_filepath; } -void BinaryReader::seekBit(int bit) +void MemoryReader::seekBit(int bit) { if (!m_data) loadData(); @@ -170,7 +170,7 @@ void BinaryReader::seekBit(int bit) m_bitPosition = bit; } -bool BinaryReader::readBit() +bool MemoryReader::readBit() { if (!m_data) loadData(); @@ -189,7 +189,7 @@ bool BinaryReader::readBit() return ret; } -atInt8 BinaryReader::readByte() +atInt8 MemoryReader::readByte() { if (!m_data) loadData(); @@ -205,7 +205,7 @@ atInt8 BinaryReader::readByte() return *(atInt8*)(m_data + m_position++); } -atUint8 BinaryReader::readUByte() +atUint8 MemoryReader::readUByte() { if (!m_data) loadData(); @@ -224,12 +224,12 @@ atUint8 BinaryReader::readUByte() return *(atUint8*)(m_data + m_position++); } -atInt8* BinaryReader::readBytes(atUint64 length) +atInt8* MemoryReader::readBytes(atUint64 length) { return (atInt8*)readUBytes(length); } -atUint8* BinaryReader::readUBytes(atUint64 length) +atUint8* MemoryReader::readUBytes(atUint64 length) { if (!m_data) loadData(); @@ -251,7 +251,7 @@ atUint8* BinaryReader::readUBytes(atUint64 length) return ret; } -atInt16 BinaryReader::readInt16() +atInt16 MemoryReader::readInt16() { if (!m_data) loadData(); @@ -275,12 +275,12 @@ atInt16 BinaryReader::readInt16() return ret; } -atUint16 BinaryReader::readUint16() +atUint16 MemoryReader::readUint16() { return readInt16(); } -atInt32 BinaryReader::readInt32() +atInt32 MemoryReader::readInt32() { if (!m_data) loadData(); @@ -304,12 +304,12 @@ atInt32 BinaryReader::readInt32() return ret; } -atUint32 BinaryReader::readUint32() +atUint32 MemoryReader::readUint32() { return readInt32(); } -atInt64 BinaryReader::readInt64() +atInt64 MemoryReader::readInt64() { if (!m_data) loadData(); @@ -333,12 +333,12 @@ atInt64 BinaryReader::readInt64() return ret; } -atUint64 BinaryReader::readUint64() +atUint64 MemoryReader::readUint64() { return readInt64(); } -float BinaryReader::readFloat() +float MemoryReader::readFloat() { if (!m_data) loadData(); @@ -362,7 +362,7 @@ float BinaryReader::readFloat() return ret; } -double BinaryReader::readDouble() +double MemoryReader::readDouble() { if (!m_data) loadData(); @@ -385,7 +385,7 @@ double BinaryReader::readDouble() return ret; } -bool BinaryReader::readBool() +bool MemoryReader::readBool() { if (!m_data) loadData(); @@ -403,7 +403,7 @@ bool BinaryReader::readBool() return ret; } -std::string BinaryReader::readUnicode(atInt32 maxlen) +std::string MemoryReader::readUnicode(atInt32 maxlen) { if (!m_data) loadData(); @@ -428,7 +428,7 @@ std::string BinaryReader::readUnicode(atInt32 maxlen) return ret; } -std::string BinaryReader::readString(atInt32 maxlen) +std::string MemoryReader::readString(atInt32 maxlen) { std::string ret = ""; atUint8 chr = readByte(); @@ -447,12 +447,12 @@ std::string BinaryReader::readString(atInt32 maxlen) return ret; } -void BinaryReader::setProgressCallback(std::function cb) +void MemoryReader::setProgressCallback(std::function cb) { m_progressCallback = cb; } -void BinaryReader::loadData() +void MemoryReader::loadData() { FILE* in; atUint64 length; diff --git a/src/Athena/BinaryWriter.cpp b/src/Athena/MemoryWriter.cpp similarity index 84% rename from src/Athena/BinaryWriter.cpp rename to src/Athena/MemoryWriter.cpp index 9fed6e5..b898b1f 100644 --- a/src/Athena/BinaryWriter.cpp +++ b/src/Athena/MemoryWriter.cpp @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with libAthena. If not, see -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" #include "Athena/IOException.hpp" #include "Athena/InvalidOperationException.hpp" #include "Athena/InvalidDataException.hpp" @@ -34,7 +34,7 @@ namespace Athena namespace io { -BinaryWriter::BinaryWriter(atUint8* data, atUint64 length) +MemoryWriter::MemoryWriter(atUint8* data, atUint64 length) : m_data((atUint8*)data), m_length(length), m_position(0), @@ -46,7 +46,7 @@ BinaryWriter::BinaryWriter(atUint8* data, atUint64 length) m_data = new atUint8[m_length]; } -BinaryWriter::BinaryWriter(const std::string& filename, std::function progressFun) +MemoryWriter::MemoryWriter(const std::string& filename, std::function progressFun) : m_length(0), m_filepath(filename), m_position(0), @@ -65,38 +65,38 @@ BinaryWriter::BinaryWriter(const std::string& filename, std::function memset(m_data, 0, m_length); } -BinaryWriter::~BinaryWriter() +MemoryWriter::~MemoryWriter() { delete[] m_data; m_data = nullptr; } -void BinaryWriter::setEndian(Endian endian) +void MemoryWriter::setEndian(Endian endian) { m_endian = endian; } -Endian BinaryWriter::endian() const +Endian MemoryWriter::endian() const { return m_endian; } -bool BinaryWriter::isBigEndian() const +bool MemoryWriter::isBigEndian() const { return (m_endian == Endian::BigEndian); } -bool BinaryWriter::isLittleEndian() const +bool MemoryWriter::isLittleEndian() const { return (m_endian == Endian::LittleEndian); } -bool BinaryWriter::isOpen() const +bool MemoryWriter::isOpen() const { return m_data != nullptr; } -void BinaryWriter::seek(atInt64 position, SeekOrigin origin) +void MemoryWriter::seek(atInt64 position, SeekOrigin origin) { switch (origin) { @@ -128,32 +128,32 @@ void BinaryWriter::seek(atInt64 position, SeekOrigin origin) } } -bool BinaryWriter::atEnd() const +bool MemoryWriter::atEnd() const { return m_position >= m_length; } -atUint64 BinaryWriter::position() const +atUint64 MemoryWriter::position() const { return m_position; } -atUint64 BinaryWriter::length() const +atUint64 MemoryWriter::length() const { return m_length; } -void BinaryWriter::setFilepath(const std::string& filepath) +void MemoryWriter::setFilepath(const std::string& filepath) { m_filepath = filepath; } -std::string BinaryWriter::filepath() const +std::string MemoryWriter::filepath() const { return m_filepath; } -void BinaryWriter::setData(const atUint8* data, atUint64 length) +void MemoryWriter::setData(const atUint8* data, atUint64 length) { if (m_data) delete[] m_data; @@ -164,7 +164,7 @@ void BinaryWriter::setData(const atUint8* data, atUint64 length) m_bitPosition = 0; } -atUint8* BinaryWriter::data() const +atUint8* MemoryWriter::data() const { atUint8* ret = new atUint8[m_length]; memset(ret, 0, m_length); @@ -173,7 +173,7 @@ atUint8* BinaryWriter::data() const } -void BinaryWriter::save(const std::string& filename) +void MemoryWriter::save(const std::string& filename) { if (filename.empty() && m_filepath.empty()) THROW_INVALID_OPERATION_EXCEPTION("No file specified, cannot save."); @@ -205,7 +205,7 @@ void BinaryWriter::save(const std::string& filename) fclose(out); } -void BinaryWriter::seekBit(int bit) +void MemoryWriter::seekBit(int bit) { if (bit < 0 || bit > 7) THROW_INVALID_OPERATION_EXCEPTION("bit out of range"); @@ -213,7 +213,7 @@ void BinaryWriter::seekBit(int bit) m_bitPosition = bit; } -void BinaryWriter::writeBit(bool val) +void MemoryWriter::writeBit(bool val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -233,7 +233,7 @@ void BinaryWriter::writeBit(bool val) } } -void BinaryWriter::writeUByte(atUint8 val) +void MemoryWriter::writeUByte(atUint8 val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -251,7 +251,7 @@ void BinaryWriter::writeUByte(atUint8 val) m_position++; } -void BinaryWriter::writeByte(atInt8 val) +void MemoryWriter::writeByte(atInt8 val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -259,7 +259,7 @@ void BinaryWriter::writeByte(atInt8 val) writeUByte(val); } -void BinaryWriter::writeUBytes(atUint8* data, atUint64 length) +void MemoryWriter::writeUBytes(atUint8* data, atUint64 length) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -280,7 +280,7 @@ void BinaryWriter::writeUBytes(atUint8* data, atUint64 length) m_position += length; } -void BinaryWriter::writeBytes(atInt8* data, atUint64 length) +void MemoryWriter::writeBytes(atInt8* data, atUint64 length) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -288,7 +288,7 @@ void BinaryWriter::writeBytes(atInt8* data, atUint64 length) writeUBytes((atUint8*)data, length); } -void BinaryWriter::writeInt16(atInt16 val) +void MemoryWriter::writeInt16(atInt16 val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -311,7 +311,7 @@ void BinaryWriter::writeInt16(atInt16 val) m_position += sizeof(atInt16); } -void BinaryWriter::writeUint16(atUint16 val) +void MemoryWriter::writeUint16(atUint16 val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -319,7 +319,7 @@ void BinaryWriter::writeUint16(atUint16 val) writeInt16(val); } -void BinaryWriter::writeInt32(atInt32 val) +void MemoryWriter::writeInt32(atInt32 val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -342,7 +342,7 @@ void BinaryWriter::writeInt32(atInt32 val) m_position += sizeof(atInt32); } -void BinaryWriter::writeUint32(atUint32 val) +void MemoryWriter::writeUint32(atUint32 val) { if (!isOpen()) THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); @@ -350,7 +350,7 @@ void BinaryWriter::writeUint32(atUint32 val) writeInt32(val); } -void BinaryWriter::writeInt64(atInt64 val) +void MemoryWriter::writeInt64(atInt64 val) { if (m_bitPosition > 0) { @@ -371,7 +371,7 @@ void BinaryWriter::writeInt64(atInt64 val) m_position += sizeof(atInt64); } -void BinaryWriter::writeUint64(atUint64 val) +void MemoryWriter::writeUint64(atUint64 val) { if (m_bitPosition > 0) { @@ -392,7 +392,7 @@ void BinaryWriter::writeUint64(atUint64 val) m_position += sizeof(atUint64); } -void BinaryWriter::writeFloat(float val) +void MemoryWriter::writeFloat(float val) { if (m_bitPosition > 0) { @@ -413,7 +413,7 @@ void BinaryWriter::writeFloat(float val) m_position += sizeof(float); } -void BinaryWriter::writeDouble(double val) +void MemoryWriter::writeDouble(double val) { if (m_bitPosition > 0) { @@ -433,7 +433,7 @@ void BinaryWriter::writeDouble(double val) m_position += sizeof(double); } -void BinaryWriter::writeBool(bool val) +void MemoryWriter::writeBool(bool val) { if (m_bitPosition > 0) { @@ -448,7 +448,7 @@ void BinaryWriter::writeBool(bool val) m_position += sizeof(bool); } -void BinaryWriter::writeUnicode(const std::string& str) +void MemoryWriter::writeUnicode(const std::string& str) { std::string tmpStr = "\xEF\xBB\xBF" + str; @@ -464,7 +464,7 @@ void BinaryWriter::writeUnicode(const std::string& str) writeInt16(0); } -void BinaryWriter::writeString(const std::string& str) +void MemoryWriter::writeString(const std::string& str) { for (atUint8 c : str) { @@ -475,23 +475,23 @@ void BinaryWriter::writeString(const std::string& str) writeUByte(0); } -void BinaryWriter::fill(atUint8 val, atUint64 length) +void MemoryWriter::fill(atUint8 val, atUint64 length) { while ((length--) > 0) writeUByte(val); } -void BinaryWriter::fill(atInt8 val, atUint64 length) +void MemoryWriter::fill(atInt8 val, atUint64 length) { fill((atUint8)val, length); } -void BinaryWriter::setProgressCallback(std::function cb) +void MemoryWriter::setProgressCallback(std::function cb) { m_progressCallback = cb; } -void BinaryWriter::resize(atUint64 newSize) +void MemoryWriter::resize(atUint64 newSize) { if (newSize < m_length) THROW_INVALID_OPERATION_EXCEPTION("Stream::resize() -> New size cannot be less to the old size."); diff --git a/src/Athena/WiiSave.cpp b/src/Athena/WiiSave.cpp index 3daed4b..65f1490 100644 --- a/src/Athena/WiiSave.cpp +++ b/src/Athena/WiiSave.cpp @@ -17,8 +17,8 @@ #include "Athena/WiiSave.hpp" #include "Athena/WiiFile.hpp" #include "Athena/WiiBanner.hpp" -#include "Athena/BinaryReader.hpp" -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryReader.hpp" +#include "Athena/MemoryWriter.hpp" #include "Athena/Utility.hpp" #include "aes.h" #include "ec.h" diff --git a/src/Athena/WiiSaveReader.cpp b/src/Athena/WiiSaveReader.cpp index 616c796..e78e873 100644 --- a/src/Athena/WiiSaveReader.cpp +++ b/src/Athena/WiiSaveReader.cpp @@ -68,13 +68,10 @@ WiiSave* WiiSaveReader::readSave() THROW_INVALID_DATA_EXCEPTION("Invalid BacKup header size"); atUint32 bkMagic = base::readUint32(); - bkMagic = bkMagic; if (bkMagic != 0x426B0001) THROW_INVALID_DATA_EXCEPTION("Invalid BacKup header magic"); atUint32 ngId = base::readUint32(); - ngId = ngId; - atUint32 numFiles = base::readUint32(); /*int fileSize =*/ base::readUint32(); diff --git a/src/Athena/WiiSaveWriter.cpp b/src/Athena/WiiSaveWriter.cpp index 03dd969..72784c4 100644 --- a/src/Athena/WiiSaveWriter.cpp +++ b/src/Athena/WiiSaveWriter.cpp @@ -22,7 +22,7 @@ #include "Athena/WiiSave.hpp" #include "Athena/WiiFile.hpp" #include "Athena/WiiBanner.hpp" -#include "Athena/BinaryWriter.hpp" +#include "Athena/MemoryWriter.hpp" #include "Athena/Utility.hpp" #include "Athena/InvalidOperationException.hpp" #include "Athena/InvalidDataException.hpp" diff --git a/src/LZ77/LZType10.cpp b/src/LZ77/LZType10.cpp index c42493b..bcabf96 100644 --- a/src/LZ77/LZType10.cpp +++ b/src/LZ77/LZType10.cpp @@ -1,6 +1,6 @@ #include "LZ77/LZLookupTable.hpp" #include "LZ77/LZType10.hpp" -#include +#include #include LZType10::LZType10(atInt32 MinimumOffset, atInt32 SlidingWindow, atInt32 MinimumMatch, atInt32 BlockSize) @@ -16,7 +16,7 @@ atUint32 LZType10::compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLe atUint32 encodeSize=(srcLength<<8)|(0x10); encodeSize = Athena::utility::LittleUint32(encodeSize); //File size needs to be written as little endian always - Athena::io::BinaryWriter outbuf("tmp"); + Athena::io::MemoryWriter outbuf("tmp"); outbuf.writeUint32(encodeSize); atUint8* ptrStart=(atUint8*)src; diff --git a/src/LZ77/LZType11.cpp b/src/LZ77/LZType11.cpp index 2e0a214..81b760b 100644 --- a/src/LZ77/LZType11.cpp +++ b/src/LZ77/LZType11.cpp @@ -1,6 +1,6 @@ #include "LZ77/LZLookupTable.hpp" #include "LZ77/LZType11.hpp" -#include +#include #include @@ -13,7 +13,7 @@ LZType11::LZType11(atInt32 minimumOffset, atInt32 slidingWindow, atInt32 minimum atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLength) { - Athena::io::BinaryWriter outbuff("tmp"); + Athena::io::MemoryWriter outbuff("tmp"); if (srcLength>0xFFFFFF){// If length is greater than 24 bits or 16 Megs atUint32 encodeFlag=0x11; Athena::utility::LittleUint32(encodeFlag);