From c241158c7be8b06e71b6b4c7da2d8ac1a6f6db88 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 3 Sep 2015 12:37:45 -0700 Subject: [PATCH 01/13] Remove GPL comments from Athena codebase --- CMakeLists.txt | 1 + include/Athena/ALTTPEnums.hpp | 18 ---- include/Athena/ALTTPFile.hpp | 17 ---- include/Athena/ALTTPFileReader.hpp | 17 ---- include/Athena/ALTTPFileWriter.hpp | 17 ---- include/Athena/ALTTPQuest.hpp | 17 ---- include/Athena/ALTTPStructs.hpp | 18 ---- include/Athena/Global.hpp | 28 ------ include/Athena/MCFile.hpp | 15 --- include/Athena/MCFileReader.hpp | 17 ---- include/Athena/MCFileWriter.hpp | 17 ---- include/Athena/SakuraGlobal.hpp | 35 +++++++ include/Athena/SkywardSwordFile.hpp | 17 ---- include/Athena/SkywardSwordFileReader.hpp | 17 ---- include/Athena/SkywardSwordFileWriter.hpp | 17 ---- include/Athena/SkywardSwordQuest.hpp | 115 +++++++++------------- include/Athena/Sprite.hpp | 19 +--- include/Athena/SpriteFile.hpp | 23 +---- include/Athena/SpriteFileReader.hpp | 17 ---- include/Athena/SpriteFileWriter.hpp | 17 ---- include/Athena/SpriteFrame.hpp | 19 +--- include/Athena/SpritePart.hpp | 19 +--- include/Athena/WiiBanner.hpp | 18 ---- include/Athena/WiiFile.hpp | 17 ---- include/Athena/WiiImage.hpp | 17 ---- include/Athena/WiiSave.hpp | 18 ---- include/Athena/WiiSaveReader.hpp | 17 ---- include/Athena/WiiSaveWriter.hpp | 17 ---- src/Athena/ALTTPFile.cpp | 18 ---- src/Athena/ALTTPFileReader.cpp | 18 ---- src/Athena/ALTTPFileWriter.cpp | 17 ---- src/Athena/ALTTPQuest.cpp | 17 ---- src/Athena/MCFile.cpp | 15 --- src/Athena/MCFileReader.cpp | 17 ---- src/Athena/MCFileWriter.cpp | 17 ---- src/Athena/SkywardSwordFile.cpp | 17 ---- src/Athena/SkywardSwordFileReader.cpp | 17 ---- src/Athena/SkywardSwordFileWriter.cpp | 17 ---- src/Athena/SkywardSwordQuest.cpp | 17 ---- src/Athena/Sprite.cpp | 18 ---- src/Athena/SpriteFile.cpp | 18 ---- src/Athena/SpriteFileReader.cpp | 17 ---- src/Athena/SpriteFileWriter.cpp | 17 ---- src/Athena/SpriteFrame.cpp | 17 ---- src/Athena/SpritePart.cpp | 17 ---- src/Athena/WiiBanner.cpp | 17 ---- src/Athena/WiiFile.cpp | 17 ---- src/Athena/WiiImage.cpp | 17 ---- src/Athena/WiiSave.cpp | 18 ---- src/Athena/WiiSaveReader.cpp | 17 ---- src/Athena/WiiSaveWriter.cpp | 17 ---- src/Athena/ZQuestFile.cpp | 18 ---- src/Athena/ZQuestFileReader.cpp | 18 ---- src/Athena/ZQuestFileWriter.cpp | 18 ---- 54 files changed, 90 insertions(+), 959 deletions(-) create mode 100644 include/Athena/SakuraGlobal.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b870760..7c23b3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ add_library(AthenaSakura EXCLUDE_FROM_ALL src/Athena/SpriteFrame.cpp src/Athena/SpritePart.cpp + include/Athena/SakuraGlobal.hpp include/Athena/Sprite.hpp include/Athena/SpriteFile.hpp include/Athena/SpriteFileReader.hpp diff --git a/include/Athena/ALTTPEnums.hpp b/include/Athena/ALTTPEnums.hpp index 6d5ae41..c7cc0ef 100644 --- a/include/Athena/ALTTPEnums.hpp +++ b/include/Athena/ALTTPEnums.hpp @@ -1,23 +1,6 @@ -// 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 ALTTP_ENUMS_HPP #define ALTTP_ENUMS_HPP -#ifndef __DOXYGEN_IGNORE__ - #include "Types.hpp" namespace Athena @@ -109,5 +92,4 @@ enum ALTTPTagAlong }; } // zelda -#endif // __DOXYGEN_IGNORE__ #endif // ALTTP_ENUMS_HPP diff --git a/include/Athena/ALTTPFile.hpp b/include/Athena/ALTTPFile.hpp index 929a749..a9c8af3 100644 --- a/include/Athena/ALTTPFile.hpp +++ b/include/Athena/ALTTPFile.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 ALTTP_FILE_HPP #define ALTTP_FILE_HPP @@ -90,4 +74,3 @@ private: } // zelda #endif // ALTTP_FILE_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPFileReader.hpp b/include/Athena/ALTTPFileReader.hpp index aedd6f2..b6ddce5 100644 --- a/include/Athena/ALTTPFileReader.hpp +++ b/include/Athena/ALTTPFileReader.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 ALTTP_FILE_READER_HPP #define ALTTP_FILE_READER_HPP @@ -67,4 +51,3 @@ private: } // io } // zelda #endif // ALTTP_FILE_READER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPFileWriter.hpp b/include/Athena/ALTTPFileWriter.hpp index e95b1dc..501ae87 100644 --- a/include/Athena/ALTTPFileWriter.hpp +++ b/include/Athena/ALTTPFileWriter.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 ALTTP_FILE_WRITER_HPP #define ALTTP_FILE_WRITER_HPP @@ -69,4 +53,3 @@ private: } // zelda #endif // ALTTP_FILE_WRITER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPQuest.hpp b/include/Athena/ALTTPQuest.hpp index 3a11ce4..e5cd3ac 100644 --- a/include/Athena/ALTTPQuest.hpp +++ b/include/Athena/ALTTPQuest.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 ALTTP_QUEST_HPP #define ALTTP_QUEST_HPP @@ -686,4 +670,3 @@ private: } // zelda #endif // ALTTP_QUEST_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/ALTTPStructs.hpp b/include/Athena/ALTTPStructs.hpp index 5c30e99..58fc1c1 100644 --- a/include/Athena/ALTTPStructs.hpp +++ b/include/Athena/ALTTPStructs.hpp @@ -1,23 +1,6 @@ -// 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 ALTTP_STRUCTS_HPP #define ALTTP_STRUCTS_HPP -#ifndef __DOXYGEN_IGNORE__ - #include #include "Athena/Types.hpp" @@ -214,5 +197,4 @@ struct ALTTPProgressFlags2 } -#endif // __DOXYGEN_IGNORE__ #endif // ALTTP_STRUCTS_HPP diff --git a/include/Athena/Global.hpp b/include/Athena/Global.hpp index bba4a9e..ae9ca66 100644 --- a/include/Athena/Global.hpp +++ b/include/Athena/Global.hpp @@ -82,34 +82,6 @@ enum Endian LittleEndian, BigEndian }; - -#ifndef ATHENA_NO_SAKURA -namespace Sakura -{ -template -class Vector2D -{ -public: - T x; - T y; - - Vector2D() - : x(0), - y(0) - { - } - - Vector2D(T x, T y) - : x(x), - y(y) - { - } -}; - -typedef Vector2D Vector2Di; -typedef Vector2D Vector2Df; -} // Sakura -#endif // ATHENA_NO_SAKURA } // Athena typedef void (*atEXCEPTION_HANDLER)(const Athena::error::Level& level, const char* file, const char* function, int line, const char* fmt, ...); diff --git a/include/Athena/MCFile.hpp b/include/Athena/MCFile.hpp index c03d88f..c5fc93a 100644 --- a/include/Athena/MCFile.hpp +++ b/include/Athena/MCFile.hpp @@ -1,18 +1,3 @@ -// 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 MCFILE_HPP #define MCFILE_HPP diff --git a/include/Athena/MCFileReader.hpp b/include/Athena/MCFileReader.hpp index 38f15c7..739de6d 100644 --- a/include/Athena/MCFileReader.hpp +++ b/include/Athena/MCFileReader.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 MCFILEREADER_HPP #define MCFILEREADER_HPP @@ -65,4 +49,3 @@ public: } // zelda #endif // MCFILEREADER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/MCFileWriter.hpp b/include/Athena/MCFileWriter.hpp index d3dbc82..c2987cd 100644 --- a/include/Athena/MCFileWriter.hpp +++ b/include/Athena/MCFileWriter.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 MCFILEWRITER_HPP #define MCFILEWRITER_HPP @@ -70,4 +54,3 @@ private: } // zelda #endif // MCFILEWRITER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/SakuraGlobal.hpp b/include/Athena/SakuraGlobal.hpp new file mode 100644 index 0000000..51a7a76 --- /dev/null +++ b/include/Athena/SakuraGlobal.hpp @@ -0,0 +1,35 @@ +#ifndef SAKURAGLOBAL_HPP +#define SAKURAGLOBAL_HPP + +#include "Athena/Global.hpp" + +namespace Athena +{ +namespace Sakura +{ +template +class Vector2D +{ +public: + T x; + T y; + + Vector2D() + : x(0), + y(0) + { + } + + Vector2D(T x, T y) + : x(x), + y(y) + { + } +}; + +typedef Vector2D Vector2Di; +typedef Vector2D Vector2Df; +} // Sakura +} // Athena + +#endif // SAKURAGLOBAL_HPP diff --git a/include/Athena/SkywardSwordFile.hpp b/include/Athena/SkywardSwordFile.hpp index 48ab379..93a1a15 100644 --- a/include/Athena/SkywardSwordFile.hpp +++ b/include/Athena/SkywardSwordFile.hpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 SSFILE_HPP #define SSFILE_HPP @@ -63,4 +47,3 @@ private: } #endif // SSFILE_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/SkywardSwordFileReader.hpp b/include/Athena/SkywardSwordFileReader.hpp index fde16f6..8290f39 100644 --- a/include/Athena/SkywardSwordFileReader.hpp +++ b/include/Athena/SkywardSwordFileReader.hpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 SSFILEREADER_HPP #define SSFILEREADER_HPP @@ -38,4 +22,3 @@ public: } // zelda #endif // SSFILEREADER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/SkywardSwordFileWriter.hpp b/include/Athena/SkywardSwordFileWriter.hpp index 65f38ce..5af7f0c 100644 --- a/include/Athena/SkywardSwordFileWriter.hpp +++ b/include/Athena/SkywardSwordFileWriter.hpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 SSFILEWRITER_HPP #define SSFILEWRITER_HPP @@ -38,4 +22,3 @@ public: } } #endif // SSFILEWRITER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/SkywardSwordQuest.hpp b/include/Athena/SkywardSwordQuest.hpp index c7c4b8b..fb22434 100644 --- a/include/Athena/SkywardSwordQuest.hpp +++ b/include/Athena/SkywardSwordQuest.hpp @@ -1,76 +1,59 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) - // 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 SKYWARDSWORDQUEST_HPP +#ifndef SKYWARDSWORDQUEST_HPP #define SKYWARDSWORDQUEST_HPP #include "Athena/Global.hpp" #include "Athena/ZQuestFile.hpp" - namespace Athena +namespace Athena +{ + +// TODO: Handle game specific data +class SkywardSwordQuest : public ZQuestFile +{ +public: + enum AmmoType { - - // TODO: Handle game specific data - class SkywardSwordQuest : public ZQuestFile - { - public: - enum AmmoType - { - Arrows, - Bombs, - Seeds - }; - - SkywardSwordQuest(std::unique_ptr&& data, atUint32 len); - - void setPlayerName(const std::string& name); - std::string playerName() const; - - void setRupeeCount(atUint16 value); - atUint16 rupeeCount(); - void setAmmoCount(AmmoType type, atUint32 count); - atUint32 ammoCount(AmmoType type); - void setMaxHP(atUint16 val); - atUint16 maxHP(); - float maxHearts(); - void setSpawnHP(atUint16 val); - atUint16 spawnHP(); - float spawnHearts(); - void setCurrentHP(atUint16 val); - atUint16 currentHP(); - float currentHearts(); - std::string currentLocation(); - std::string currentArea(); - std::string currentLocationCopy(); - - void setSkipData(std::unique_ptr&& data); - atUint8* skipData() const; - - - atUint32 slotChecksum(); - atUint32 skipChecksum(); - void fixChecksums(); - - void setNew(bool isNew); - bool isNew() const; - private: - std::unique_ptr m_skipData; + Arrows, + Bombs, + Seeds }; + SkywardSwordQuest(std::unique_ptr&& data, atUint32 len); - } // zelda + void setPlayerName(const std::string& name); + std::string playerName() const; + + void setRupeeCount(atUint16 value); + atUint16 rupeeCount(); + void setAmmoCount(AmmoType type, atUint32 count); + atUint32 ammoCount(AmmoType type); + void setMaxHP(atUint16 val); + atUint16 maxHP(); + float maxHearts(); + void setSpawnHP(atUint16 val); + atUint16 spawnHP(); + float spawnHearts(); + void setCurrentHP(atUint16 val); + atUint16 currentHP(); + float currentHearts(); + std::string currentLocation(); + std::string currentArea(); + std::string currentLocationCopy(); + + void setSkipData(std::unique_ptr&& data); + atUint8* skipData() const; + + + atUint32 slotChecksum(); + atUint32 skipChecksum(); + void fixChecksums(); + + void setNew(bool isNew); + bool isNew() const; +private: + std::unique_ptr m_skipData; +}; + + +} // Athena #endif // SSQUEST_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/Sprite.hpp b/include/Athena/Sprite.hpp index baa39df..fefa07f 100644 --- a/include/Athena/Sprite.hpp +++ b/include/Athena/Sprite.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 SSPRITE_HPP #define SSPRITE_HPP @@ -26,7 +10,7 @@ #include #include #endif -#include "Athena/Global.hpp" +#include "Athena/SakuraGlobal.hpp" namespace Athena { @@ -144,4 +128,3 @@ Q_DECLARE_METATYPE(Athena::Sakura::Sprite*) #endif #endif // SSPRITE_HPP -#endif // ATHENA_NO_SAKURA diff --git a/include/Athena/SpriteFile.hpp b/include/Athena/SpriteFile.hpp index 23ae089..84f9308 100644 --- a/include/Athena/SpriteFile.hpp +++ b/include/Athena/SpriteFile.hpp @@ -1,20 +1,4 @@ -#ifndef ATHENA_NO_SAKURA -// 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 SSPRITEFILE_HPP +#ifndef SSPRITEFILE_HPP #define SSPRITEFILE_HPP #ifndef ATHENA_USE_QT @@ -29,7 +13,7 @@ #endif #include -#include "Athena/Global.hpp" +#include "Athena/SakuraGlobal.hpp" namespace Athena { @@ -279,6 +263,3 @@ Q_DECLARE_METATYPE(Athena::Sakura::SpriteFile*) Q_DECLARE_METATYPE(Athena::Sakura::STexture*) #endif #endif // SSPRITE_HPP - -#endif // ATHENA_NO_SAKURA - diff --git a/include/Athena/SpriteFileReader.hpp b/include/Athena/SpriteFileReader.hpp index 70f3fdc..7b2e6fd 100644 --- a/include/Athena/SpriteFileReader.hpp +++ b/include/Athena/SpriteFileReader.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 SSPRITEFILEREADER_HPP #define SSPRITEFILEREADER_HPP @@ -43,4 +27,3 @@ public: #endif // SSPRITEFILEREADER_HPP -#endif // ATHENA_NO_SAKURA diff --git a/include/Athena/SpriteFileWriter.hpp b/include/Athena/SpriteFileWriter.hpp index 36d0e46..eb138d7 100644 --- a/include/Athena/SpriteFileWriter.hpp +++ b/include/Athena/SpriteFileWriter.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 SSPRITEFILEWRITER_HPP #define SSPRITEFILEWRITER_HPP @@ -43,4 +27,3 @@ public: } // io } // zelda #endif // SSPRITEFILEWRITER_HPP -#endif // ATHENA_NO_SAKURA diff --git a/include/Athena/SpriteFrame.hpp b/include/Athena/SpriteFrame.hpp index adde8c4..7e46cac 100644 --- a/include/Athena/SpriteFrame.hpp +++ b/include/Athena/SpriteFrame.hpp @@ -1,24 +1,8 @@ -#ifndef ATHENA_NO_SAKURA -// 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 SSPRITEFRAME_HPP #define SSPRITEFRAME_HPP -#include "Athena/Global.hpp" +#include "Athena/SakuraGlobal.hpp" #ifndef ATHENA_USE_QT #include @@ -98,4 +82,3 @@ Q_DECLARE_METATYPE(Athena::Sakura::SpriteFrame*); #endif #endif // SSPRITEFRAME_HPP -#endif // ATHENA_NO_SAKURA diff --git a/include/Athena/SpritePart.hpp b/include/Athena/SpritePart.hpp index 9cb1b1f..02af17d 100644 --- a/include/Athena/SpritePart.hpp +++ b/include/Athena/SpritePart.hpp @@ -1,23 +1,7 @@ -#ifndef ATHENA_NO_SAKURA -// 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 SSPRITEPART_HPP #define SSPRITEPART_HPP -#include "Athena/Global.hpp" +#include "Athena/SakuraGlobal.hpp" #ifndef ATHENA_USE_QT # include #else @@ -214,4 +198,3 @@ Q_DECLARE_METATYPE(Athena::Sakura::SpritePart*) #endif #endif // SSPRITEPART_HPP -#endif // ATHENA_NO_SAKURA diff --git a/include/Athena/WiiBanner.hpp b/include/Athena/WiiBanner.hpp index d0ca84e..f96694f 100644 --- a/include/Athena/WiiBanner.hpp +++ b/include/Athena/WiiBanner.hpp @@ -1,23 +1,6 @@ -#ifndef ATHENA_NO_SAVES -// 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 WIIBANNER_H #define WIIBANNER_H - #include #include #include "Athena/Global.hpp" @@ -191,4 +174,3 @@ private: } // zelda #endif // WIIBANNER_H -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/WiiFile.hpp b/include/Athena/WiiFile.hpp index c029a6b..84612fa 100644 --- a/include/Athena/WiiFile.hpp +++ b/include/Athena/WiiFile.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 WIIFILE_H #define WIIFILE_H @@ -236,4 +220,3 @@ private: } // zelda #endif // WIIFILE_H -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/WiiImage.hpp b/include/Athena/WiiImage.hpp index 46dcaff..4343787 100644 --- a/include/Athena/WiiImage.hpp +++ b/include/Athena/WiiImage.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 WIIIMAGE_HPP #define WIIIMAGE_HPP @@ -92,4 +76,3 @@ private: } // zelda #endif // WIIIMAGE_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/WiiSave.hpp b/include/Athena/WiiSave.hpp index 55648a1..e86d6e0 100644 --- a/include/Athena/WiiSave.hpp +++ b/include/Athena/WiiSave.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 WIISAVE_HPP #define WIISAVE_HPP @@ -98,5 +82,3 @@ private: } // zelda #endif // WIISAVE_HPP -#endif // ATHENA_NO_SAVES - diff --git a/include/Athena/WiiSaveReader.hpp b/include/Athena/WiiSaveReader.hpp index bb819b7..b6cbb7a 100644 --- a/include/Athena/WiiSaveReader.hpp +++ b/include/Athena/WiiSaveReader.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 WIISAVEREADER_HPP #define WIISAVEREADER_HPP @@ -70,4 +54,3 @@ private: } // io } // zelda #endif // WIISAVEREADER_HPP -#endif // ATHENA_NO_SAVES diff --git a/include/Athena/WiiSaveWriter.hpp b/include/Athena/WiiSaveWriter.hpp index 93a381e..0621400 100644 --- a/include/Athena/WiiSaveWriter.hpp +++ b/include/Athena/WiiSaveWriter.hpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 WIISAVEWRITER_HPP #define WIISAVEWRITER_HPP @@ -69,4 +53,3 @@ private: } // io } // zelda #endif // WIISAVEWRITER_HPP -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/ALTTPFile.cpp b/src/Athena/ALTTPFile.cpp index c22921b..ea15555 100644 --- a/src/Athena/ALTTPFile.cpp +++ b/src/Athena/ALTTPFile.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/ALTTPFile.hpp" #include "Athena/ALTTPQuest.hpp" @@ -59,5 +43,3 @@ atUint32 ALTTPFile::questCount() const return (atUint32)m_quests.size(); } } // zelda - -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/ALTTPFileReader.cpp b/src/Athena/ALTTPFileReader.cpp index 51bd565..50cee9f 100644 --- a/src/Athena/ALTTPFileReader.cpp +++ b/src/Athena/ALTTPFileReader.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/ALTTPFileReader.hpp" #include "Athena/ALTTPFile.hpp" #include "Athena/ALTTPQuest.hpp" @@ -253,5 +237,3 @@ ALTTPDungeonItemFlags ALTTPFileReader::readDungeonFlags() } // io } // zelda - -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/ALTTPFileWriter.cpp b/src/Athena/ALTTPFileWriter.cpp index 11703d2..42c8d50 100644 --- a/src/Athena/ALTTPFileWriter.cpp +++ b/src/Athena/ALTTPFileWriter.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/ALTTPFileWriter.hpp" #include "Athena/ALTTPFile.hpp" #include "Athena/ALTTPQuest.hpp" @@ -237,4 +221,3 @@ atUint16 ALTTPFileWriter::calculateChecksum(atUint32 game) } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/ALTTPQuest.cpp b/src/Athena/ALTTPQuest.cpp index 1b72bdd..b45f3ba 100644 --- a/src/Athena/ALTTPQuest.cpp +++ b/src/Athena/ALTTPQuest.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/ALTTPQuest.hpp" #include @@ -761,4 +745,3 @@ atUint16 ALTTPQuest::checksum() const } } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/MCFile.cpp b/src/Athena/MCFile.cpp index 8839986..1ebf34e 100644 --- a/src/Athena/MCFile.cpp +++ b/src/Athena/MCFile.cpp @@ -1,18 +1,3 @@ -// 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 - #include "Athena/MCFile.hpp" namespace Athena diff --git a/src/Athena/MCFileReader.cpp b/src/Athena/MCFileReader.cpp index eb6fed3..df16207 100644 --- a/src/Athena/MCFileReader.cpp +++ b/src/Athena/MCFileReader.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/MCFileReader.hpp" #include "Athena/MCFile.hpp" namespace Athena @@ -47,4 +31,3 @@ MCFile* MCFileReader::readFile() } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/MCFileWriter.cpp b/src/Athena/MCFileWriter.cpp index 9eb89c9..21c5474 100644 --- a/src/Athena/MCFileWriter.cpp +++ b/src/Athena/MCFileWriter.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/MCFileWriter.hpp" namespace Athena @@ -66,4 +50,3 @@ atUint16 MCFileWriter::calculateChecksum(atUint8* data, atUint32 length) } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/SkywardSwordFile.cpp b/src/Athena/SkywardSwordFile.cpp index 4b15a5f..160808d 100644 --- a/src/Athena/SkywardSwordFile.cpp +++ b/src/Athena/SkywardSwordFile.cpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 - #include "Athena/SkywardSwordFile.hpp" #include "Athena/SkywardSwordQuest.hpp" @@ -72,4 +56,3 @@ Region SkywardSwordFile::region() const } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/SkywardSwordFileReader.cpp b/src/Athena/SkywardSwordFileReader.cpp index 795cdac..26c527d 100644 --- a/src/Athena/SkywardSwordFileReader.cpp +++ b/src/Athena/SkywardSwordFileReader.cpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 - #include "Athena/SkywardSwordFileReader.hpp" #include "Athena/SkywardSwordFile.hpp" #include "Athena/SkywardSwordQuest.hpp" @@ -83,4 +67,3 @@ SkywardSwordFile* SkywardSwordFileReader::read() } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/SkywardSwordFileWriter.cpp b/src/Athena/SkywardSwordFileWriter.cpp index 249b7e1..1506147 100644 --- a/src/Athena/SkywardSwordFileWriter.cpp +++ b/src/Athena/SkywardSwordFileWriter.cpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 - #include "Athena/SkywardSwordFileWriter.hpp" #include "Athena/SkywardSwordFile.hpp" #include "Athena/SkywardSwordQuest.hpp" @@ -80,4 +64,3 @@ void SkywardSwordFileWriter::write(SkywardSwordFile* file) } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/SkywardSwordQuest.cpp b/src/Athena/SkywardSwordQuest.cpp index fdabef1..2a0d4a8 100644 --- a/src/Athena/SkywardSwordQuest.cpp +++ b/src/Athena/SkywardSwordQuest.cpp @@ -1,19 +1,3 @@ -#if !defined(ATHENA_NO_SAVES) && !defined(ATHENA_NO_ZQUEST) -// 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 - #include "Athena/SkywardSwordQuest.hpp" #include "Athena/Checksums.hpp" #include "utf8proc.h" @@ -276,4 +260,3 @@ bool SkywardSwordQuest::isNew() const } } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/Sprite.cpp b/src/Athena/Sprite.cpp index df05171..203f51e 100644 --- a/src/Athena/Sprite.cpp +++ b/src/Athena/Sprite.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 - #include "Athena/Sprite.hpp" #include "Athena/SpriteFrame.hpp" #include "Athena/SpriteFile.hpp" @@ -316,5 +300,3 @@ SpriteFile* Sprite::root() const } } } - -#endif // ATHENA_NO_SAKURA diff --git a/src/Athena/SpriteFile.cpp b/src/Athena/SpriteFile.cpp index e5abf75..42f48c7 100644 --- a/src/Athena/SpriteFile.cpp +++ b/src/Athena/SpriteFile.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 - #include "Athena/SpriteFile.hpp" #include "Athena/Sprite.hpp" #include "Athena/Utility.hpp" @@ -342,5 +326,3 @@ void SpriteFile::setTextures(QList textures) #endif } // Sakura } // zelda - -#endif // ATHENA_NO_SAKURA diff --git a/src/Athena/SpriteFileReader.cpp b/src/Athena/SpriteFileReader.cpp index 57e2e75..6ed6be6 100644 --- a/src/Athena/SpriteFileReader.cpp +++ b/src/Athena/SpriteFileReader.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 - #include "Athena/SpriteFileReader.hpp" #include "Athena/SpriteFile.hpp" #include "Athena/Sprite.hpp" @@ -222,4 +206,3 @@ Sakura::SpriteFile* SpriteFileReader::readFile() } } // io } // zelda -#endif //ATHENA_NO_SAKURA diff --git a/src/Athena/SpriteFileWriter.cpp b/src/Athena/SpriteFileWriter.cpp index dd9c14d..a0cae2f 100644 --- a/src/Athena/SpriteFileWriter.cpp +++ b/src/Athena/SpriteFileWriter.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 - #include "Athena/SpriteFileWriter.hpp" #include "Athena/SpriteFile.hpp" #include "Athena/Sprite.hpp" @@ -118,4 +102,3 @@ void SpriteFileWriter::writeFile(Sakura::SpriteFile* file) } // io } // zelda -#endif // ATHENA_NO_SAKURA diff --git a/src/Athena/SpriteFrame.cpp b/src/Athena/SpriteFrame.cpp index 7d07dd6..2a7ad13 100644 --- a/src/Athena/SpriteFrame.cpp +++ b/src/Athena/SpriteFrame.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 - #include "Athena/SpriteFrame.hpp" #include "Athena/SpritePart.hpp" #include "Athena/Sprite.hpp" @@ -81,4 +65,3 @@ Sprite* SpriteFrame::root() const } // Sakura } // zelda -#endif // ATHENA_NO_SAKURA diff --git a/src/Athena/SpritePart.cpp b/src/Athena/SpritePart.cpp index e5af3fd..f4dae05 100644 --- a/src/Athena/SpritePart.cpp +++ b/src/Athena/SpritePart.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAKURA -// 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 - #include "Athena/SpritePart.hpp" #include "Athena/SpritePart.hpp" #include "Athena/Sprite.hpp" @@ -201,4 +185,3 @@ SpriteFrame* SpritePart::root() const } } } -#endif // ATHENA_NO_SAKURA diff --git a/src/Athena/WiiBanner.cpp b/src/Athena/WiiBanner.cpp index 66a38df..5a65e3b 100644 --- a/src/Athena/WiiBanner.cpp +++ b/src/Athena/WiiBanner.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/WiiBanner.hpp" #include "Athena/WiiImage.hpp" @@ -157,4 +141,3 @@ atUint32 WiiBanner::flags() const } } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/WiiFile.cpp b/src/Athena/WiiFile.cpp index 14acee3..906a398 100644 --- a/src/Athena/WiiFile.cpp +++ b/src/Athena/WiiFile.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/WiiFile.hpp" #include @@ -290,4 +274,3 @@ std::string WiiFile::fullpath() } } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/WiiImage.cpp b/src/Athena/WiiImage.cpp index 889a396..067997a 100644 --- a/src/Athena/WiiImage.cpp +++ b/src/Athena/WiiImage.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/WiiImage.hpp" #include "Athena/Utility.hpp" #include @@ -98,4 +82,3 @@ atUint8* WiiImage::toRGBA() } } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/WiiSave.cpp b/src/Athena/WiiSave.cpp index 690e16a..b46ce0a 100644 --- a/src/Athena/WiiSave.cpp +++ b/src/Athena/WiiSave.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/WiiSave.hpp" #include "Athena/WiiFile.hpp" #include "Athena/WiiBanner.hpp" @@ -103,5 +87,3 @@ std::vector WiiSave::allFiles() const } } // zelda - -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/WiiSaveReader.cpp b/src/Athena/WiiSaveReader.cpp index 0d9c84d..ad8c282 100644 --- a/src/Athena/WiiSaveReader.cpp +++ b/src/Athena/WiiSaveReader.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/WiiSaveReader.hpp" #include "Athena/WiiSave.hpp" #include "Athena/WiiFile.hpp" @@ -342,4 +326,3 @@ WiiFile* WiiSaveReader::buildTree(std::vector files) } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/WiiSaveWriter.cpp b/src/Athena/WiiSaveWriter.cpp index d19a7a4..bc65fd7 100644 --- a/src/Athena/WiiSaveWriter.cpp +++ b/src/Athena/WiiSaveWriter.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_SAVES -// 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 - #include "Athena/WiiSaveWriter.hpp" #include "Athena/WiiSave.hpp" #include "Athena/WiiFile.hpp" @@ -265,4 +249,3 @@ void WiiSaveWriter::writeCerts(atUint32 filesSize, atUint32 ngId, atUint8* ngPri } // io } // zelda -#endif // ATHENA_NO_SAVES diff --git a/src/Athena/ZQuestFile.cpp b/src/Athena/ZQuestFile.cpp index 78f52cf..67b2311 100644 --- a/src/Athena/ZQuestFile.cpp +++ b/src/Athena/ZQuestFile.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_ZQUEST -// 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 - #include "Athena/ZQuestFile.hpp" #include @@ -134,5 +118,3 @@ const std::vector ZQuestFile::gameStringList() return GameStrings; } } - -#endif // ATHENA_NO_ZQUEST diff --git a/src/Athena/ZQuestFileReader.cpp b/src/Athena/ZQuestFileReader.cpp index 7566d8f..a8442c4 100644 --- a/src/Athena/ZQuestFileReader.cpp +++ b/src/Athena/ZQuestFileReader.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_ZQUEST -// 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 - #include "Athena/ZQuestFileReader.hpp" #include "Athena/ZQuestFile.hpp" #include "Athena/Compression.hpp" @@ -125,5 +109,3 @@ ZQuestFile* ZQuestFileReader::read() } // io } // zelda - -#endif diff --git a/src/Athena/ZQuestFileWriter.cpp b/src/Athena/ZQuestFileWriter.cpp index d9a0fc3..7c0df19 100644 --- a/src/Athena/ZQuestFileWriter.cpp +++ b/src/Athena/ZQuestFileWriter.cpp @@ -1,19 +1,3 @@ -#ifndef ATHENA_NO_ZQUEST -// 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 - #include "Athena/ZQuestFileWriter.hpp" #include "Athena/ZQuestFile.hpp" #include "Athena/Compression.hpp" @@ -93,5 +77,3 @@ void ZQuestFileWriter::write(ZQuestFile* quest, bool compress) } // io } // zelda - -#endif // ATHENA_NO_ZQUEST From 89fa92308f6d2c8019a0e6202930aa721cba63bc Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 7 Sep 2015 17:02:58 -1000 Subject: [PATCH 02/13] Doc updates --- include/Athena/DNA.hpp | 62 ++++++ include/Athena/IStreamReader.hpp | 336 ++++++++++++++++++++++--------- include/Athena/IStreamWriter.hpp | 300 ++++++++++++++++++++------- 3 files changed, 523 insertions(+), 175 deletions(-) diff --git a/include/Athena/DNA.hpp b/include/Athena/DNA.hpp index 5383b99..85dd91f 100644 --- a/include/Athena/DNA.hpp +++ b/include/Athena/DNA.hpp @@ -34,6 +34,7 @@ struct WStringAsString; /** * @brief Base DNA class used against 'atdna' + * @tparam DNAE Default-endianness for contained DNA values * * Athena bundles a build-tool called 'atdna'. This tool functions * just like the 'clang' compiler, except it emits a full .cpp implementation @@ -43,36 +44,88 @@ struct WStringAsString; template struct DNA { + /** + * @brief Common virtual read function for all DNA types + */ virtual void read(IStreamReader&)=0; + /** + * @brief Common virtual write function for all DNA types + */ virtual void write(IStreamWriter&) const=0; + /** + * @brief Template type signaling atdna to capture the value where it's used + * @tparam T The type of the value. Can be any numeric type or atVec* type + * @tparam VE Endianness of the value + */ template using Value = T; + /** + * @brief Template type wrapping std::vector and signaling atdna to manipulate it where it's used + * @tparam T The type of contained elements. Can be any numeric type, atVec* type, or another DNA subclass + * @tparam cntVar C++ expression wrapped in DNA_COUNT macro to determine number of elements for vector + * @tparam VE Endianness of the contained values + */ template using Vector = std::vector; + /** + * @brief Template type wrapping std::unique_ptr and signaling atdna to read a + * raw byte-buffer where it's used + * @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of bytes for buffer + */ template using Buffer = struct Athena::io::Buffer; + /** + * @brief Template type wrapping std::string and signaling atdna to read string data where it's used + * @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for string + * -1 literal indicates null-terminated string + */ template using String = struct Athena::io::String; + /** + * @brief Template type wrapping std::wstring and signaling atdna to read wstring data where it's used + * @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for wstring + * -1 literal indicates null-terminated wstring + */ template using WString = struct Athena::io::WString; + /** + * @brief Template type wrapping std::string and signaling atdna to read wstring data where it's used + * @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for string + * -1 literal indicates null-terminated string + */ template using WStringAsString = struct Athena::io::WStringAsString; + /** + * @brief Meta Template signaling atdna to insert a stream seek where it's used + * @tparam offset C++ expression wrapped in DNA_COUNT macro to determine number of bytes to seek + * @tparam direction SeekOrigin to seek relative to + */ template struct Seek {}; + /** + * @brief Meta Template signaling atdna to insert an aligning stream seek where it's used + * @tparam align Number of bytes to align to + */ template struct Align {}; + /** + * @brief Meta Template preventing atdna from emitting read/write implementations + */ struct Delete {}; }; +/** + * @brief Concrete buffer type used by DNA::Buffer + */ template struct Buffer : public DNA, public std::unique_ptr { @@ -88,6 +141,9 @@ struct Buffer : public DNA, public std::unique_ptr } }; +/** + * @brief Concrete string type used by DNA::String + */ template struct String : public DNA, public std::string { @@ -102,6 +158,9 @@ struct String : public DNA, public std::string {this->swap(__str); return *this;} }; +/** + * @brief Concrete wstring type used by DNA::WString + */ template struct WString : public DNA, public std::wstring { @@ -122,6 +181,9 @@ struct WString : public DNA, public std::wstring {this->swap(__str); return *this;} }; +/** + * @brief Concrete converting-wstring type used by DNA::WStringAsString + */ template struct WStringAsString : public DNA, public std::string { diff --git a/include/Athena/IStreamReader.hpp b/include/Athena/IStreamReader.hpp index 2175244..21a74db 100644 --- a/include/Athena/IStreamReader.hpp +++ b/include/Athena/IStreamReader.hpp @@ -15,86 +15,86 @@ class IStreamReader : public IStream public: virtual ~IStreamReader() {} - /*! \brief Sets the Endianness of the stream + /** @brief Sets the Endianness of the stream * - * \param endian The Endianness to set \sa Endian + * @param endian The Endianness to set */ 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 Endianness + * @return The current Stream Endianness */ 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 */ 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 True for LittleEndian; False for BigEndian */ inline bool isLittleEndian()const {return (m_endian == Endian::LittleEndian);} - /*! \brief Sets the buffers position relative to the specified position.
+ /** @brief Sets the buffers position relative to the specified position.
* It seeks relative to the current position by default. - * \param position where in the buffer to seek - * \param origin The Origin to seek \sa SeekOrigin + * @param position where in the buffer to seek + * @param origin The Origin to seek relative to */ virtual void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current)=0; - /*! \brief Sets the buffers position relative to the next 32-byte aligned position.
+ /** @brief Sets the buffers position relative to the next 32-byte aligned position.
*/ inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);} - /*! \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 True if at end; False otherwise. */ inline bool atEnd() const {return position() >= 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 The current position in the stream. */ virtual atUint64 position() const=0; - /*! \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 True if at end; False otherwise. */ virtual atUint64 length() const=0; - /*! \brief Reads a byte at the current position and advances the current position + /** @brief Reads a byte at the current position and advances the current position * - * \return Int8 The value at the current position + * @return The value at the current position */ inline atInt8 readByte() {atInt8 val; readUBytesToBuf(&val, 1); return val;} template inline atInt8 readVal(typename std::enable_if::value>::type* = 0) {return readByte();} - /*! \brief Reads a byte at the current position and advances the current position + /** @brief Reads a byte at the current position and advances the current position * - * \return Uint8 The value at the current position + * @return The value at the current position */ inline atUint8 readUByte() {return readByte();} template inline atUint8 readVal(typename std::enable_if::value>::type* = 0) {return readUByte();} - /*! \brief Reads a byte at the current position and advances the current position. + /** @brief Reads a byte at the current position and advances the current position. * - * \return Uint8* The buffer at the current position from the given length. + * @return The buffer at the current position from the given length. */ inline std::unique_ptr readBytes(atUint64 length) { @@ -103,9 +103,9 @@ public: return std::unique_ptr(buf); } - /*! \brief Reads a byte at the current position and advances the current position. + /** @brief Reads a byte at the current position and advances the current position. * - * \return Int8* The buffer at the current position from the given length. + * @return The buffer at the current position from the given length. */ inline std::unique_ptr readUBytes(atUint64 length) { @@ -117,13 +117,10 @@ public: inline atUint64 readBytesToBuf(void* buf, atUint64 len) {return readUBytesToBuf(buf, len);} virtual atUint64 readUBytesToBuf(void* buf, atUint64 len)=0; - /*! \brief Reads a Int16 and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a Int16 and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return Int16 The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atInt16 readInt16() { @@ -135,6 +132,11 @@ public: inline atInt16 readVal(typename std::enable_if::value>::type* = 0) {return readInt16();} + /** @brief Reads a Int16 and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atInt16 readInt16Little() { atInt16 val; @@ -145,6 +147,11 @@ public: inline atInt16 readValLittle(typename std::enable_if::value>::type* = 0) {return readInt16Little();} + /** @brief Reads a Int16 and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atInt16 readInt16Big() { atInt16 val; @@ -155,13 +162,10 @@ public: inline atInt16 readValBig(typename std::enable_if::value>::type* = 0) {return readInt16Big();} - /*! \brief Reads a Uint16 and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a Uint16 and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return Uint16 The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atUint16 readUint16() {return readInt16();} @@ -169,6 +173,11 @@ public: inline atUint16 readVal(typename std::enable_if::value>::type* = 0) {return readUint16();} + /** @brief Reads a Uint16 and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atUint16 readUint16Little() { atUint16 val; @@ -179,6 +188,11 @@ public: inline atUint16 readValLittle(typename std::enable_if::value>::type* = 0) {return readUint16Little();} + /** @brief Reads a Uint16 and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atUint16 readUint16Big() { atUint16 val; @@ -189,13 +203,10 @@ public: inline atUint16 readValBig(typename std::enable_if::value>::type* = 0) {return readUint16Big();} - /*! \brief Reads a Int32 and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a Int32 and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return Int32 The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atInt32 readInt32() { @@ -207,6 +218,11 @@ public: inline atInt32 readVal(typename std::enable_if::value>::type* = 0) {return readInt32();} + /** @brief Reads a Int32 and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atInt32 readInt32Little() { atInt32 val; @@ -217,6 +233,11 @@ public: inline atInt32 readValLittle(typename std::enable_if::value>::type* = 0) {return readInt32Little();} + /** @brief Reads a Int32 and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atInt32 readInt32Big() { atInt32 val; @@ -227,13 +248,10 @@ public: inline atInt32 readValBig(typename std::enable_if::value>::type* = 0) {return readInt32Big();} - /*! \brief Reads a Uint32 and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a Uint32 and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return Uint32 The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atUint32 readUint32() {return readInt32();} @@ -241,6 +259,11 @@ public: inline atUint32 readVal(typename std::enable_if::value>::type* = 0) {return readUint32();} + /** @brief Reads a Uint32 and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atUint32 readUint32Little() { atUint32 val; @@ -251,6 +274,11 @@ public: inline atInt32 readValLittle(typename std::enable_if::value>::type* = 0) {return readUint32Little();} + /** @brief Reads a Uint32 and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atUint32 readUint32Big() { atUint32 val; @@ -261,13 +289,10 @@ public: inline atUint32 readValBig(typename std::enable_if::value>::type* = 0) {return readUint32Big();} - /*! \brief Reads a Int64 and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a Int64 and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return Int64 The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atInt64 readInt64() { @@ -279,6 +304,11 @@ public: inline atInt64 readVal(typename std::enable_if::value>::type* = 0) {return readInt64();} + /** @brief Reads a Int64 and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atInt64 readInt64Little() { atInt64 val; @@ -289,6 +319,11 @@ public: inline atInt64 readValLittle(typename std::enable_if::value>::type* = 0) {return readInt64Little();} + /** @brief Reads a Int64 and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atInt64 readInt64Big() { atInt64 val; @@ -299,13 +334,10 @@ public: inline atInt64 readValBig(typename std::enable_if::value>::type* = 0) {return readInt64Big();} - /*! \brief Reads a Uint64 and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a Uint64 and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return Uint64 The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atUint64 readUint64() {return readInt64();} @@ -313,6 +345,11 @@ public: inline atUint64 readVal(typename std::enable_if::value>::type* = 0) {return readUint64();} + /** @brief Reads a Uint64 and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atUint64 readUint64Little() { atUint64 val; @@ -323,6 +360,11 @@ public: inline atUint64 readValLittle(typename std::enable_if::value>::type* = 0) {return readUint64Little();} + /** @brief Reads a Uint64 and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atUint64 readUint64Big() { atUint64 val; @@ -333,13 +375,10 @@ public: inline atUint64 readValBig(typename std::enable_if::value>::type* = 0) {return readUint64Big();} - /*! \brief Reads a float and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a float and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return float The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline float readFloat() { @@ -351,6 +390,11 @@ public: inline float readVal(typename std::enable_if::value>::type* = 0) {return readFloat();} + /** @brief Reads a float and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline float readFloatLittle() { float val; @@ -361,6 +405,11 @@ public: inline float readValLittle(typename std::enable_if::value>::type* = 0) {return readFloatLittle();} + /** @brief Reads a float and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline float readFloatBig() { float val; @@ -371,13 +420,10 @@ public: inline float readValBig(typename std::enable_if::value>::type* = 0) {return readFloatBig();} - /*! \brief Reads a double and swaps to proper endianness depending on platform - * and Stream settings, and advances the current position + /** @brief Reads a double and swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \sa Endian - * - * \return double The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline double readDouble() { @@ -389,6 +435,11 @@ public: inline double readVal(typename std::enable_if::value>::type* = 0) {return readDouble();} + /** @brief Reads a double and swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline double readDoubleLittle() { double val; @@ -399,6 +450,11 @@ public: inline double readValLittle(typename std::enable_if::value>::type* = 0) {return readDoubleLittle();} + /** @brief Reads a double and swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline double readDoubleBig() { double val; @@ -409,10 +465,9 @@ public: inline double readValBig(typename std::enable_if::value>::type* = 0) {return readDoubleBig();} - /*! \brief Reads a bool and advances the current position + /** @brief Reads a bool and advances the current position * - * \return bool The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline bool readBool() { @@ -424,10 +479,10 @@ public: inline bool readVal(typename std::enable_if::value>::type* = 0) {return readBool();} - /*! \brief Reads an atVec2f (8 bytes) and advances the current position + /** @brief Reads an atVec2f (8 bytes), swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \return atVec2f The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atVec2f readVec2f() { @@ -449,6 +504,11 @@ public: inline atVec2f readVal(typename std::enable_if::value>::type* = 0) {return readVec2f();} + /** @brief Reads an atVec2f (8 bytes), swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atVec2f readVec2fLittle() { atVec2f val; @@ -461,6 +521,11 @@ public: inline atVec2f readValLittle(typename std::enable_if::value>::type* = 0) {return readVec2fLittle();} + /** @brief Reads an atVec2f (8 bytes), swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atVec2f readVec2fBig() { atVec2f val; @@ -473,10 +538,10 @@ public: inline atVec2f readValBig(typename std::enable_if::value>::type* = 0) {return readVec2fBig();} - /*! \brief Reads an atVec3f (12 bytes) and advances the current position + /** @brief Reads an atVec3f (12 bytes), swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \return atVec3f The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atVec3f readVec3f() { @@ -500,6 +565,11 @@ public: inline atVec3f readVal(typename std::enable_if::value>::type* = 0) {return readVec3f();} + /** @brief Reads an atVec3f (12 bytes), swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atVec3f readVec3fLittle() { atVec3f val; @@ -513,6 +583,11 @@ public: inline atVec3f readValLittle(typename std::enable_if::value>::type* = 0) {return readVec3fLittle();} + /** @brief Reads an atVec3f (12 bytes), swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atVec3f readVec3fBig() { atVec3f val; @@ -526,10 +601,10 @@ public: inline atVec3f readValBig(typename std::enable_if::value>::type* = 0) {return readVec3fBig();} - /*! \brief Reads an atVec4f (16 bytes) and advances the current position + /** @brief Reads an atVec4f (16 bytes), swaps to endianness specified by setEndian depending on platform + * and advances the current position * - * \return atVec4f The value at the current address - * \throw IOException when address is out of range + * @return The value at the current address */ inline atVec4f readVec4f() { @@ -555,6 +630,11 @@ public: inline atVec4f readVal(typename std::enable_if::value>::type* = 0) {return readVec4f();} + /** @brief Reads an atVec4f (16 bytes), swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atVec4f readVec4fLittle() { atVec4f val; @@ -569,6 +649,11 @@ public: inline atVec4f readValLittle(typename std::enable_if::value>::type* = 0) {return readVec4fLittle();} + /** @brief Reads an atVec4f (16 bytes), swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ inline atVec4f readVec4fBig() { atVec4f val; @@ -583,11 +668,11 @@ public: inline atVec4f readValBig(typename std::enable_if::value>::type* = 0) {return readVec4fBig();} - /*! \brief Reads a wide-char string, converts to UTF8 and advances the position in the file + /** @brief Reads a wide-char string (using endianness from setEndian), + * converts to UTF8 and advances the position in the file * - * \param fixedLen If non-negative, this is a fixed-length string read - * \return std::string The value at the current address - * \throw IOException when address is out of range + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read string */ inline std::string readWStringAsString(atInt32 fixedLen = -1) { @@ -621,6 +706,12 @@ public: return retval; } + /** @brief Reads a wide-char string (against little-endian), + * converts to UTF8 and advances the position in the file + * + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read string + */ inline std::string readWStringAsStringLittle(atInt32 fixedLen = -1) { std::string retval; @@ -653,6 +744,12 @@ public: return retval; } + /** @brief Reads a wide-char string (against big-endian), + * converts to UTF8 and advances the position in the file + * + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read string + */ inline std::string readWStringAsStringBig(atInt32 fixedLen = -1) { std::string retval; @@ -685,11 +782,10 @@ public: return retval; } - /*! \brief Reads a string and advances the position in the file + /** @brief Reads a string and advances the position in the file * - * \param fixedLen If non-negative, this is a fixed-length string read - * \return std::string The value at the current address - * \throw IOException when address is out of range + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read string */ inline std::string readString(atInt32 fixedLen = -1) { @@ -716,11 +812,10 @@ public: inline std::string readVal(typename std::enable_if::value>::type* = 0) {return readString();} - /*! \brief Reads a wstring and advances the position in the file + /** @brief Reads a wstring and advances the position in the file * - * \param fixedLen If non-negative, this is a fixed-length string read - * \return std::wstring The value at the current address - * \throw IOException when address is out of range + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read wstring */ inline std::wstring readWString(atInt32 fixedLen = -1) { @@ -747,6 +842,12 @@ public: inline std::wstring readVal(typename std::enable_if::value>::type* = 0) {return readWString();} + /** @brief Reads a wstring assuming little-endian characters + * and advances the position in the file + * + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read wstring + */ inline std::wstring readWStringLittle(atInt32 fixedLen = -1) { std::wstring ret; @@ -772,6 +873,12 @@ public: inline std::wstring readValLittle(typename std::enable_if::value>::type* = 0) {return readWStringLittle();} + /** @brief Reads a wstring assuming big-endian characters + * and advances the position in the file + * + * @param fixedLen If non-negative, this is a fixed-length string read + * @return The read wstring + */ inline std::wstring readWStringBig(atInt32 fixedLen = -1) { std::wstring ret; @@ -797,6 +904,13 @@ public: inline std::wstring readValBig(typename std::enable_if::value>::type* = 0) {return readWStringBig();} + /** @brief Performs automatic std::vector enumeration reads using numeric type T + * + * @param vector The std::vector to clear and populate using read data + * @param count The number of elements to read into vector + * + * Endianness is set with setEndian + */ template void enumerate(std::vector& vector, size_t count, typename std::enable_if::value || @@ -810,6 +924,13 @@ public: vector.emplace_back(readVal()); } + /** @brief Performs automatic std::vector enumeration reads using numeric type T + * + * @param vector The std::vector to clear and populate using read data + * @param count The number of elements to read into vector + * + * Endianness is little + */ template void enumerateLittle(std::vector& vector, size_t count, typename std::enable_if::value || @@ -823,6 +944,13 @@ public: vector.emplace_back(readValLittle()); } + /** @brief Performs automatic std::vector enumeration reads using numeric type T + * + * @param vector The std::vector to clear and populate using read data + * @param count The number of elements to read into vector + * + * Endianness is big + */ template void enumerateBig(std::vector& vector, size_t count, typename std::enable_if::value || @@ -836,6 +964,11 @@ public: vector.emplace_back(readValBig()); } + /** @brief Performs automatic std::vector enumeration reads using non-numeric type T + * + * @param vector The std::vector to clear and populate using read data + * @param count The number of elements to read into vector + */ template void enumerate(std::vector& vector, size_t count, typename std::enable_if::value && @@ -852,6 +985,13 @@ public: } } + /** @brief Performs lambda-assisted std::vector enumeration reads using type T + * + * @param vector The std::vector to clear and populate using read data + * @param count The number of elements to read into vector + * @param readf Function (e.g. a lambda) that reads *one* element and + * assigns the value through the second argument + */ template void enumerate(std::vector& vector, size_t count, std::function readf) { diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp index 133c892..05e9bdf 100644 --- a/include/Athena/IStreamWriter.hpp +++ b/include/Athena/IStreamWriter.hpp @@ -12,97 +12,95 @@ class IStreamWriter : public IStream { public: virtual ~IStreamWriter() {} - /*! \brief Sets the Endianness of the stream + /** @brief Sets the Endianness of the stream * - * \param endian The Endianness to set \sa Endian + * @param endian The Endianness to set */ 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 Endianness + * @return The current Stream Endianness */ 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 True for BigEndian; False for LittleEndian */ 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 True for LittleEndian; False for BigEndian */ inline bool isLittleEndian() const {return (m_endian == Endian::LittleEndian);} - /*! \brief Sets the buffers position relative to the specified position.
+ /** @brief Sets the buffers position relative to the specified position.
* It seeks relative to the current position by default. - * \param position where in the buffer to seek - * \param origin The Origin to seek \sa SeekOrigin + * @param position where in the buffer to seek + * @param origin The location to seek relative to */ virtual void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current)=0; - /*! \brief Sets the buffers position relative to the next 32-byte aligned position.
+ /** @brief Sets the buffers position relative to the next 32-byte aligned position.
*/ inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);} - /*! \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 True if at end; False otherwise. */ inline bool atEnd() const {return position() >= 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 The current position in the stream. */ virtual atUint64 position() const=0; - /*! \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 True if at end; False otherwise. */ virtual atUint64 length() const=0; - /*! \brief Writes a byte at the current position and advances the position by one byte. - * \param byte The value to write + /** @brief Writes a byte at the current position and advances the position by one byte. + * @param val The value to write */ inline void writeUByte(atUint8 val) {writeUBytes(&val, 1);} inline void writeVal(atUint8 val) {return writeUByte(val);} - /*! \brief Writes a byte at the current position and advances the position by one byte. - * \param byte The value to write - * \throw IOException + /** @brief Writes a byte at the current position and advances the position by one byte. + * @param val The value to write */ inline void writeByte(atInt8 val) {writeUByte(val);} inline void writeVal(atInt8 val) {return writeByte(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. * - * \param data The buffer to write - * \param length The amount to write + * @param data The buffer to write + * @param length The amount to write */ virtual void writeUBytes(const atUint8* data, atUint64 len)=0; - /*! \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. * - * \param data The buffer to write - * \param length The amount to write + * @param data The buffer to write + * @param length The amount to write */ inline void writeBytes(const atInt8* data, atUint64 len) {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. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeInt16(atInt16 val) { @@ -114,6 +112,11 @@ public: } inline void writeVal(atInt16 val) {return writeInt16(val);} + /** @brief Writes an Int16 to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeInt16Little(atInt16 val) { utility::LittleInt16(val); @@ -121,6 +124,11 @@ public: } inline void writeValLittle(atInt16 val) {return writeInt16Little(val);} + /** @brief Writes an Int16 to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeInt16Big(atInt16 val) { utility::BigInt16(val); @@ -128,26 +136,34 @@ public: } inline void writeValBig(atInt16 val) {return writeInt16Big(val);} - /*! \brief Writes an Uint16 to the buffer and advances the buffer. + /** @brief Writes an Uint16 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeUint16(atUint16 val) {writeInt16(val);} inline void writeVal(atUint16 val) {return writeUint16(val);} + /** @brief Writes an Uint16 to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform + * + * @param val The value to write to the buffer + */ inline void writeUint16Little(atUint16 val) {writeInt16Little(val);} inline void writeValLittle(atUint16 val) {return writeUint16Little(val);} + /** @brief Writes an Uint16 to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform + * + * @param val The value to write to the buffer + */ inline void writeUint16Big(atUint16 val) {writeInt16Big(val);} inline void writeValBig(atUint16 val) {return writeUint16Big(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. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeInt32(atInt32 val) { @@ -159,6 +175,11 @@ public: } inline void writeVal(atInt32 val) {return writeInt32(val);} + /** @brief Writes an Int32 to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeInt32Little(atInt32 val) { utility::LittleInt32(val); @@ -166,6 +187,11 @@ public: } inline void writeValLittle(atInt32 val) {return writeInt32Little(val);} + /** @brief Writes an Int32 to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeInt32Big(atInt32 val) { utility::BigInt32(val); @@ -173,26 +199,34 @@ public: } inline void writeValBig(atInt32 val) {return writeInt32Big(val);} - /*! \brief Writes an Uint32 to the buffer and advances the buffer. + /** @brief Writes an Uint32 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeUint32(atUint32 val) {writeInt32(val);} inline void writeVal(atUint32 val) {return writeUint32(val);} + /** @brief Writes an Uint32 to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeUint32Little(atUint32 val) {writeInt32Little(val);} inline void writeValLittle(atUint32 val) {return writeUint32Little(val);} + /** @brief Writes an Uint32 to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeUint32Big(atUint32 val) {writeInt32Big(val);} inline void writeValBig(atUint32 val) {return writeUint32Big(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. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeInt64(atInt64 val) { @@ -204,6 +238,11 @@ public: } inline void writeVal(atInt64 val) {return writeInt64(val);} + /** @brief Writes an Int64 to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeInt64Little(atInt64 val) { utility::LittleInt64(val); @@ -211,6 +250,11 @@ public: } inline void writeValLittle(atInt64 val) {return writeInt64Little(val);} + /** @brief Writes an Int64 to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeInt64Big(atInt64 val) { utility::BigInt64(val); @@ -218,26 +262,34 @@ public: } inline void writeValBig(atInt64 val) {return writeInt64Big(val);} - /*! \brief Writes an Uint64 to the buffer and advances the buffer. + /** @brief Writes an Uint64 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeUint64(atUint64 val) {writeInt64(val);} inline void writeVal(atUint64 val) {return writeUint64(val);} + /** @brief Writes an Uint64 to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeUint64Little(atUint64 val) {writeInt64Little(val);} inline void writeValLittle(atUint64 val) {return writeUint64Little(val);} + /** @brief Writes an Uint64 to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeUint64Big(atUint64 val) {writeInt64Big(val);} inline void writeValBig(atUint64 val) {return writeUint64Big(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. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeFloat(float val) { @@ -249,6 +301,11 @@ public: } inline void writeVal(float val) {return writeFloat(val);} + /** @brief Writes an float to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeFloatLittle(float val) { utility::LittleFloat(val); @@ -256,6 +313,11 @@ public: } inline void writeValLittle(float val) {return writeFloatLittle(val);} + /** @brief Writes an float to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeFloatBig(float val) { utility::BigFloat(val); @@ -263,11 +325,10 @@ public: } inline void writeValBig(float val) {return writeFloatBig(val);} - /*! \brief Writes an double to the buffer and advances the buffer. + /** @brief Writes an double to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeDouble(double val) { @@ -279,6 +340,11 @@ public: } inline void writeVal(double val) {return writeDouble(val);} + /** @brief Writes an double to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeDoubleLittle(double val) { utility::LittleDouble(val); @@ -286,6 +352,11 @@ public: } inline void writeValLittle(double val) {return writeDoubleLittle(val);} + /** @brief Writes an double to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param val The value to write to the buffer + */ inline void writeDoubleBig(double val) { utility::BigDouble(val); @@ -293,20 +364,18 @@ public: } inline void writeValBig(double val) {return writeDoubleBig(val);} - /*! \brief Writes an bool to the buffer and advances the buffer. + /** @brief Writes an bool to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param val The value to write to the buffer + * @param val The value to write to the buffer */ inline void writeBool(bool val) {writeUBytes((atUint8*)&val, 1);} inline void writeVal(bool val) {return writeBool(val);} - /*! \brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer. + /** @brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param vec The value to write to the buffer + * @param vec The value to write to the buffer */ inline void writeVec2f(atVec2f vec) { @@ -324,6 +393,11 @@ public: } inline void writeVal(atVec2f val) {return writeVec2f(val);} + /** @brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param vec The value to write to the buffer + */ inline void writeVec2fLittle(atVec2f vec) { utility::LittleFloat(vec.vec[0]); @@ -332,6 +406,11 @@ public: } inline void writeValLittle(atVec2f val) {return writeVec2fLittle(val);} + /** @brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param vec The value to write to the buffer + */ inline void writeVec2fBig(atVec2f vec) { utility::BigFloat(vec.vec[0]); @@ -340,11 +419,10 @@ public: } inline void writeValBig(atVec2f val) {return writeVec2fBig(val);} - /*! \brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer. + /** @brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param vec The value to write to the buffer + * @param vec The value to write to the buffer */ inline void writeVec3f(atVec3f vec) { @@ -364,6 +442,11 @@ public: } inline void writeVal(atVec3f val) {return writeVec3f(val);} + /** @brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param vec The value to write to the buffer + */ inline void writeVec3fLittle(atVec3f vec) { utility::LittleFloat(vec.vec[0]); @@ -373,6 +456,11 @@ public: } inline void writeValLittle(atVec3f val) {return writeVec3fLittle(val);} + /** @brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param vec The value to write to the buffer + */ inline void writeVec3fBig(atVec3f vec) { utility::BigFloat(vec.vec[0]); @@ -382,11 +470,10 @@ public: } inline void writeValBig(atVec3f val) {return writeVec3fBig(val);} - /*! \brief Writes an atVec4f (16 bytes) to the buffer and advances the buffer. + /** @brief Writes an atVec4f (16 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param vec The value to write to the buffer + * @param vec The value to write to the buffer */ inline void writeVec4f(atVec4f vec) { @@ -408,6 +495,11 @@ public: } inline void writeVal(atVec4f val) {return writeVec4f(val);} + /** @brief Writes an atVec4f (16 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param vec The value to write to the buffer + */ inline void writeVec4fLittle(atVec4f vec) { utility::LittleFloat(vec.vec[0]); @@ -418,6 +510,11 @@ public: } inline void writeValLittle(atVec4f val) {return writeVec4fLittle(val);} + /** @brief Writes an atVec4f (16 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param vec The value to write to the buffer + */ inline void writeVec4fBig(atVec4f vec) { utility::BigFloat(vec.vec[0]); @@ -428,12 +525,13 @@ public: } inline void writeValBig(atVec4f val) {return writeVec4fBig(val);} - /*! \brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer. + /** @brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * - * \sa Endian - * \param str The string to write to the buffer - * \param fixedLen If not -1, the number of characters to zero-fill string to + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to + * + * Endianness is set with setEndian */ inline void writeStringAsWString(const std::string& str, atInt32 fixedLen = -1) { @@ -483,6 +581,14 @@ public: } } + /** @brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer. + * It also swaps the bytes depending on the platform and Stream settings. + * + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to + * + * Endianness is little + */ inline void writeStringAsWStringLittle(const std::string& str, atInt32 fixedLen = -1) { std::string tmpStr = "\xEF\xBB\xBF" + str; @@ -531,6 +637,14 @@ public: } } + /** @brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer. + * It also swaps the bytes depending on the platform and Stream settings. + * + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to + * + * Endianness is big + */ inline void writeStringAsWStringBig(const std::string& str, atInt32 fixedLen = -1) { std::string tmpStr = "\xEF\xBB\xBF" + str; @@ -579,11 +693,10 @@ public: } } - /*! \brief Writes an string to the buffer and advances the buffer. + /** @brief Writes an string to the buffer and advances the buffer. * - * \sa Endian - * \param str The string to write to the buffer - * \param fixedLen If not -1, the number of characters to zero-fill string to + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to */ inline void writeString(const std::string& str, atInt32 fixedLen = -1) { @@ -614,11 +727,12 @@ public: } inline void writeVal(const std::string& val) {return writeString(val);} - /*! \brief Writes an wstring to the buffer and advances the buffer. + /** @brief Writes an wstring to the buffer and advances the buffer. * - * \sa Endian - * \param str The string to write to the buffer - * \param fixedLen If not -1, the number of characters to zero-fill string to + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to + * + * Endianness is set with setEndian */ inline void writeWString(const std::wstring& str, atInt32 fixedLen = -1) { @@ -649,6 +763,13 @@ public: } inline void writeVal(const std::wstring& val) {return writeWString(val);} + /** @brief Writes an wstring to the buffer and advances the buffer. + * + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to + * + * Endianness is little + */ inline void writeWStringLittle(const std::wstring& str, atInt32 fixedLen = -1) { if (fixedLen < 0) @@ -678,6 +799,13 @@ public: } inline void writeValLittle(const std::wstring& val) {return writeWStringLittle(val);} + /** @brief Writes an wstring to the buffer and advances the buffer. + * + * @param str The string to write to the buffer + * @param fixedLen If not -1, the number of characters to zero-fill string to + * + * Endianness is big + */ inline void writeWStringBig(const std::wstring& str, atInt32 fixedLen = -1) { if (fixedLen < 0) @@ -712,6 +840,11 @@ public: inline void fill(atInt8 val, atUint64 length) {fill((atUint8)val, length);} + /** @brief Performs automatic std::vector enumeration writes using numeric type T + * @param vector The std::vector read from when writing data + * + * Endianness is set with setEndian + */ template void enumerate(const std::vector& vector, typename std::enable_if::value || @@ -723,6 +856,11 @@ public: writeVal(item); } + /** @brief Performs automatic std::vector enumeration writes using numeric type T + * @param vector The std::vector read from when writing data + * + * Endianness is little + */ template void enumerateLittle(const std::vector& vector, typename std::enable_if::value || @@ -734,6 +872,11 @@ public: writeValLittle(item); } + /** @brief Performs automatic std::vector enumeration writes using numeric type T + * @param vector The std::vector read from when writing data + * + * Endianness is big + */ template void enumerateBig(const std::vector& vector, typename std::enable_if::value || @@ -745,6 +888,9 @@ public: writeValBig(item); } + /** @brief Performs automatic std::vector enumeration writes using non-numeric type T + * @param vector The std::vector read from when writing data + */ template void enumerate(const std::vector& vector, typename std::enable_if::value && From 9535778932565c662bdafe488bc9de1dda00d47b Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 11 Sep 2015 13:27:28 -1000 Subject: [PATCH 03/13] added Little/Big suffix method for at[U]Int8 types for consistency --- include/Athena/IStreamReader.hpp | 12 +++++ include/Athena/IStreamWriter.hpp | 84 +++++++++++++++++--------------- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/include/Athena/IStreamReader.hpp b/include/Athena/IStreamReader.hpp index 2175244..0ad973c 100644 --- a/include/Athena/IStreamReader.hpp +++ b/include/Athena/IStreamReader.hpp @@ -82,6 +82,12 @@ public: template inline atInt8 readVal(typename std::enable_if::value>::type* = 0) {return readByte();} + template + inline atInt8 readValLittle(typename std::enable_if::value>::type* = 0) + {return readByte();} + template + inline atInt8 readValBig(typename std::enable_if::value>::type* = 0) + {return readByte();} /*! \brief Reads a byte at the current position and advances the current position * @@ -91,6 +97,12 @@ public: template inline atUint8 readVal(typename std::enable_if::value>::type* = 0) {return readUByte();} + template + inline atUint8 readValLittle(typename std::enable_if::value>::type* = 0) + {return readUByte();} + template + inline atUint8 readValBig(typename std::enable_if::value>::type* = 0) + {return readUByte();} /*! \brief Reads a byte at the current position and advances the current position. * diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp index 133c892..f7557f4 100644 --- a/include/Athena/IStreamWriter.hpp +++ b/include/Athena/IStreamWriter.hpp @@ -73,14 +73,18 @@ public: * \param byte The value to write */ inline void writeUByte(atUint8 val) {writeUBytes(&val, 1);} - inline void writeVal(atUint8 val) {return writeUByte(val);} + inline void writeVal(atUint8 val) {writeUByte(val);} + inline void writeValLittle(atUint8 val) {writeUByte(val);} + inline void writeValBig(atUint8 val) {writeUByte(val);} /*! \brief Writes a byte at the current position and advances the position by one byte. * \param byte The value to write * \throw IOException */ inline void writeByte(atInt8 val) {writeUByte(val);} - inline void writeVal(atInt8 val) {return writeByte(val);} + inline void writeVal(atInt8 val) {writeByte(val);} + inline void writeValLittle(atInt8 val) {writeByte(val);} + inline void writeValBig(atInt8 val) {writeByte(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. @@ -112,21 +116,21 @@ public: utility::LittleInt16(val); writeUBytes((atUint8*)&val, 2); } - inline void writeVal(atInt16 val) {return writeInt16(val);} + inline void writeVal(atInt16 val) {writeInt16(val);} inline void writeInt16Little(atInt16 val) { utility::LittleInt16(val); writeUBytes((atUint8*)&val, 2); } - inline void writeValLittle(atInt16 val) {return writeInt16Little(val);} + inline void writeValLittle(atInt16 val) {writeInt16Little(val);} inline void writeInt16Big(atInt16 val) { utility::BigInt16(val); writeUBytes((atUint8*)&val, 2); } - inline void writeValBig(atInt16 val) {return writeInt16Big(val);} + inline void writeValBig(atInt16 val) {writeInt16Big(val);} /*! \brief Writes an Uint16 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings @@ -135,13 +139,13 @@ public: * \param val The value to write to the buffer */ inline void writeUint16(atUint16 val) {writeInt16(val);} - inline void writeVal(atUint16 val) {return writeUint16(val);} + inline void writeVal(atUint16 val) {writeUint16(val);} inline void writeUint16Little(atUint16 val) {writeInt16Little(val);} - inline void writeValLittle(atUint16 val) {return writeUint16Little(val);} + inline void writeValLittle(atUint16 val) {writeUint16Little(val);} inline void writeUint16Big(atUint16 val) {writeInt16Big(val);} - inline void writeValBig(atUint16 val) {return writeUint16Big(val);} + inline void writeValBig(atUint16 val) {writeUint16Big(val);} /*! \brief Writes an Int32 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -157,21 +161,21 @@ public: utility::LittleInt32(val); writeUBytes((atUint8*)&val, 4); } - inline void writeVal(atInt32 val) {return writeInt32(val);} + inline void writeVal(atInt32 val) {writeInt32(val);} inline void writeInt32Little(atInt32 val) { utility::LittleInt32(val); writeUBytes((atUint8*)&val, 4); } - inline void writeValLittle(atInt32 val) {return writeInt32Little(val);} + inline void writeValLittle(atInt32 val) {writeInt32Little(val);} inline void writeInt32Big(atInt32 val) { utility::BigInt32(val); writeUBytes((atUint8*)&val, 4); } - inline void writeValBig(atInt32 val) {return writeInt32Big(val);} + inline void writeValBig(atInt32 val) {writeInt32Big(val);} /*! \brief Writes an Uint32 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -180,13 +184,13 @@ public: * \param val The value to write to the buffer */ inline void writeUint32(atUint32 val) {writeInt32(val);} - inline void writeVal(atUint32 val) {return writeUint32(val);} + inline void writeVal(atUint32 val) {writeUint32(val);} inline void writeUint32Little(atUint32 val) {writeInt32Little(val);} - inline void writeValLittle(atUint32 val) {return writeUint32Little(val);} + inline void writeValLittle(atUint32 val) {writeUint32Little(val);} inline void writeUint32Big(atUint32 val) {writeInt32Big(val);} - inline void writeValBig(atUint32 val) {return writeUint32Big(val);} + inline void writeValBig(atUint32 val) {writeUint32Big(val);} /*! \brief Writes an Int64 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -202,21 +206,21 @@ public: utility::LittleInt64(val); writeUBytes((atUint8*)&val, 8); } - inline void writeVal(atInt64 val) {return writeInt64(val);} + inline void writeVal(atInt64 val) {writeInt64(val);} inline void writeInt64Little(atInt64 val) { utility::LittleInt64(val); writeUBytes((atUint8*)&val, 8); } - inline void writeValLittle(atInt64 val) {return writeInt64Little(val);} + inline void writeValLittle(atInt64 val) {writeInt64Little(val);} inline void writeInt64Big(atInt64 val) { utility::BigInt64(val); writeUBytes((atUint8*)&val, 8); } - inline void writeValBig(atInt64 val) {return writeInt64Big(val);} + inline void writeValBig(atInt64 val) {writeInt64Big(val);} /*! \brief Writes an Uint64 to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -225,13 +229,13 @@ public: * \param val The value to write to the buffer */ inline void writeUint64(atUint64 val) {writeInt64(val);} - inline void writeVal(atUint64 val) {return writeUint64(val);} + inline void writeVal(atUint64 val) {writeUint64(val);} inline void writeUint64Little(atUint64 val) {writeInt64Little(val);} - inline void writeValLittle(atUint64 val) {return writeUint64Little(val);} + inline void writeValLittle(atUint64 val) {writeUint64Little(val);} inline void writeUint64Big(atUint64 val) {writeInt64Big(val);} - inline void writeValBig(atUint64 val) {return writeUint64Big(val);} + inline void writeValBig(atUint64 val) {writeUint64Big(val);} /*! \brief Writes an float to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -247,21 +251,21 @@ public: utility::LittleFloat(val); writeUBytes((atUint8*)&val, 4); } - inline void writeVal(float val) {return writeFloat(val);} + inline void writeVal(float val) {writeFloat(val);} inline void writeFloatLittle(float val) { utility::LittleFloat(val); writeUBytes((atUint8*)&val, 4); } - inline void writeValLittle(float val) {return writeFloatLittle(val);} + inline void writeValLittle(float val) {writeFloatLittle(val);} inline void writeFloatBig(float val) { utility::BigFloat(val); writeUBytes((atUint8*)&val, 4); } - inline void writeValBig(float val) {return writeFloatBig(val);} + inline void writeValBig(float val) {writeFloatBig(val);} /*! \brief Writes an double to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -277,21 +281,21 @@ public: utility::LittleDouble(val); writeUBytes((atUint8*)&val, 8); } - inline void writeVal(double val) {return writeDouble(val);} + inline void writeVal(double val) {writeDouble(val);} inline void writeDoubleLittle(double val) { utility::LittleDouble(val); writeUBytes((atUint8*)&val, 8); } - inline void writeValLittle(double val) {return writeDoubleLittle(val);} + inline void writeValLittle(double val) {writeDoubleLittle(val);} inline void writeDoubleBig(double val) { utility::BigDouble(val); writeUBytes((atUint8*)&val, 8); } - inline void writeValBig(double val) {return writeDoubleBig(val);} + inline void writeValBig(double val) {writeDoubleBig(val);} /*! \brief Writes an bool to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -300,7 +304,7 @@ public: * \param val The value to write to the buffer */ inline void writeBool(bool val) {writeUBytes((atUint8*)&val, 1);} - inline void writeVal(bool val) {return writeBool(val);} + inline void writeVal(bool val) {writeBool(val);} /*! \brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -322,7 +326,7 @@ public: } writeUBytes((atUint8*)&vec, 8); } - inline void writeVal(atVec2f val) {return writeVec2f(val);} + inline void writeVal(atVec2f val) {writeVec2f(val);} inline void writeVec2fLittle(atVec2f vec) { @@ -330,7 +334,7 @@ public: utility::LittleFloat(vec.vec[1]); writeUBytes((atUint8*)&vec, 8); } - inline void writeValLittle(atVec2f val) {return writeVec2fLittle(val);} + inline void writeValLittle(atVec2f val) {writeVec2fLittle(val);} inline void writeVec2fBig(atVec2f vec) { @@ -338,7 +342,7 @@ public: utility::BigFloat(vec.vec[1]); writeUBytes((atUint8*)&vec, 8); } - inline void writeValBig(atVec2f val) {return writeVec2fBig(val);} + inline void writeValBig(atVec2f val) {writeVec2fBig(val);} /*! \brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -362,7 +366,7 @@ public: } writeUBytes((atUint8*)&vec, 12); } - inline void writeVal(atVec3f val) {return writeVec3f(val);} + inline void writeVal(atVec3f val) {writeVec3f(val);} inline void writeVec3fLittle(atVec3f vec) { @@ -371,7 +375,7 @@ public: utility::LittleFloat(vec.vec[2]); writeUBytes((atUint8*)&vec, 12); } - inline void writeValLittle(atVec3f val) {return writeVec3fLittle(val);} + inline void writeValLittle(atVec3f val) {writeVec3fLittle(val);} inline void writeVec3fBig(atVec3f vec) { @@ -380,7 +384,7 @@ public: utility::BigFloat(vec.vec[2]); writeUBytes((atUint8*)&vec, 12); } - inline void writeValBig(atVec3f val) {return writeVec3fBig(val);} + inline void writeValBig(atVec3f val) {writeVec3fBig(val);} /*! \brief Writes an atVec4f (16 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -406,7 +410,7 @@ public: } writeUBytes((atUint8*)&vec, 16); } - inline void writeVal(atVec4f val) {return writeVec4f(val);} + inline void writeVal(atVec4f val) {writeVec4f(val);} inline void writeVec4fLittle(atVec4f vec) { @@ -416,7 +420,7 @@ public: utility::LittleFloat(vec.vec[3]); writeUBytes((atUint8*)&vec, 16); } - inline void writeValLittle(atVec4f val) {return writeVec4fLittle(val);} + inline void writeValLittle(atVec4f val) {writeVec4fLittle(val);} inline void writeVec4fBig(atVec4f vec) { @@ -426,7 +430,7 @@ public: utility::BigFloat(vec.vec[3]); writeUBytes((atUint8*)&vec, 16); } - inline void writeValBig(atVec4f val) {return writeVec4fBig(val);} + inline void writeValBig(atVec4f val) {writeVec4fBig(val);} /*! \brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. @@ -612,7 +616,7 @@ public: } } } - inline void writeVal(const std::string& val) {return writeString(val);} + inline void writeVal(const std::string& val) {writeString(val);} /*! \brief Writes an wstring to the buffer and advances the buffer. * @@ -647,7 +651,7 @@ public: } } } - inline void writeVal(const std::wstring& val) {return writeWString(val);} + inline void writeVal(const std::wstring& val) {writeWString(val);} inline void writeWStringLittle(const std::wstring& str, atInt32 fixedLen = -1) { @@ -676,7 +680,7 @@ public: } } } - inline void writeValLittle(const std::wstring& val) {return writeWStringLittle(val);} + inline void writeValLittle(const std::wstring& val) {writeWStringLittle(val);} inline void writeWStringBig(const std::wstring& str, atInt32 fixedLen = -1) { @@ -705,7 +709,7 @@ public: } } } - inline void writeValBig(const std::wstring& val) {return writeWStringBig(val);} + inline void writeValBig(const std::wstring& val) {writeWStringBig(val);} inline void fill(atUint8 val, atUint64 length) {for (atUint64 l=0 ; l Date: Sat, 12 Sep 2015 10:25:58 -0800 Subject: [PATCH 04/13] FreeBSD Fixes --- atdna/CMakeLists.txt | 7 ++++++- include/Athena/Global.hpp | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 844b2bd..0505308 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -34,7 +34,12 @@ set(CLANG_INCLUDE_DIR ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_STRING}/include CACHE PATH "Clang include dir" FORCE) if(UNIX) -list(APPEND PLAT_LIBS z pthread curses dl) +list(APPEND PLAT_LIBS z pthread curses) +if (APPLE) + list(APPEND PLAT_LIBS dl) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + list(APPEND PLAT_LIBS dl) +endif() endif() # Offer the user the choice of overriding the installation directories diff --git a/include/Athena/Global.hpp b/include/Athena/Global.hpp index ae9ca66..9659c12 100644 --- a/include/Athena/Global.hpp +++ b/include/Athena/Global.hpp @@ -47,6 +47,11 @@ typedef struct stat stat64_t; #define stat64 stat #elif _WIN32 typedef struct _stat64 stat64_t; +#elif __FreeBSD__ +typedef struct stat stat64_t; +#define stat64 stat +#define fseeko64 fseeko +#define ftello64 ftello #else typedef struct stat64 stat64_t; #endif From 3d90c14795d397dedd7adc404b37ed302adeca7b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 24 Sep 2015 00:43:59 -0700 Subject: [PATCH 05/13] Fix subrecord arrays --- atdna/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/atdna/main.cpp b/atdna/main.cpp index 5674d1d..c0c71d2 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -1328,7 +1328,6 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { fileOut << " /* " << fieldName << " */\n" " " << fieldName << (p ? ".write(" ATHENA_DNA_WRITER ");\n" : ".read(" ATHENA_DNA_READER ");\n"); - break; } } @@ -1649,7 +1648,6 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor fileOut << " /* " << fieldName << " */\n" " " ATHENA_YAML_WRITER ".enumerate(\"" << fieldNameBare << "\", " << fieldName << ");\n"; } - break; } } From 4eae90984823ca9bfb039e652194ec2d068a3ee2 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 24 Sep 2015 14:55:11 -1000 Subject: [PATCH 06/13] Extended bool with endian readers/writers --- include/Athena/IStreamReader.hpp | 6 ++++++ include/Athena/IStreamWriter.hpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/Athena/IStreamReader.hpp b/include/Athena/IStreamReader.hpp index 0864cf8..27f79dc 100644 --- a/include/Athena/IStreamReader.hpp +++ b/include/Athena/IStreamReader.hpp @@ -490,6 +490,12 @@ public: template inline bool readVal(typename std::enable_if::value>::type* = 0) {return readBool();} + template + inline bool readValLittle(typename std::enable_if::value>::type* = 0) + {return readBool();} + template + inline bool readValBig(typename std::enable_if::value>::type* = 0) + {return readBool();} /** @brief Reads an atVec2f (8 bytes), swaps to endianness specified by setEndian depending on platform * and advances the current position diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp index 34a8e6a..7468589 100644 --- a/include/Athena/IStreamWriter.hpp +++ b/include/Athena/IStreamWriter.hpp @@ -375,6 +375,8 @@ public: */ inline void writeBool(bool val) {writeUBytes((atUint8*)&val, 1);} inline void writeVal(bool val) {writeBool(val);} + inline void writeValLittle(bool val) {writeBool(val);} + inline void writeValBig(bool val) {writeBool(val);} /** @brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. From a999744ab6f22f09293db4b2680fa2c95f541e1d Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 27 Sep 2015 11:17:11 -1000 Subject: [PATCH 07/13] removed implementation-reliant use of emplace_back --- include/Athena/DNAYaml.hpp | 2 +- include/Athena/IStreamReader.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Athena/DNAYaml.hpp b/include/Athena/DNAYaml.hpp index a360bad..7ebf1a8 100644 --- a/include/Athena/DNAYaml.hpp +++ b/include/Athena/DNAYaml.hpp @@ -527,7 +527,7 @@ public: vector.reserve(count); enterSubVector(name); for (size_t i=0 ; i(name)); + vector.push_back(readVal(name)); leaveSubVector(); } diff --git a/include/Athena/IStreamReader.hpp b/include/Athena/IStreamReader.hpp index 27f79dc..b126f72 100644 --- a/include/Athena/IStreamReader.hpp +++ b/include/Athena/IStreamReader.hpp @@ -939,7 +939,7 @@ public: vector.clear(); vector.reserve(count); for (size_t i=0 ; i()); + vector.push_back(readVal()); } /** @brief Performs automatic std::vector enumeration reads using numeric type T @@ -959,7 +959,7 @@ public: vector.clear(); vector.reserve(count); for (size_t i=0 ; i()); + vector.push_back(readValLittle()); } /** @brief Performs automatic std::vector enumeration reads using numeric type T @@ -979,7 +979,7 @@ public: vector.clear(); vector.reserve(count); for (size_t i=0 ; i()); + vector.push_back(readValBig()); } /** @brief Performs automatic std::vector enumeration reads using non-numeric type T From f4716070dd33f910e4854997a91a249e40922229 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 30 Sep 2015 14:37:54 -1000 Subject: [PATCH 08/13] Added built-in DNAType field for YAML classification --- atdna/main.cpp | 1 + include/Athena/DNAYaml.hpp | 52 ++++++++++++++++++++++++++-- src/Athena/DNAYaml.cpp | 70 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 3 deletions(-) diff --git a/atdna/main.cpp b/atdna/main.cpp index c0c71d2..6f0044a 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -1665,6 +1665,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor fileOut << "}\n\n"; } + fileOut << "const char* " << decl->getQualifiedNameAsString() << "::DNAType()\n{\n return \"" << decl->getQualifiedNameAsString() << "\";\n}\n\n"; } public: diff --git a/include/Athena/DNAYaml.hpp b/include/Athena/DNAYaml.hpp index 7ebf1a8..ebeb2e0 100644 --- a/include/Athena/DNAYaml.hpp +++ b/include/Athena/DNAYaml.hpp @@ -426,6 +426,7 @@ class YAMLDocReader std::vector m_seqTrackerStack; static std::unique_ptr ParseEvents(yaml_parser_t* doc); public: + static bool ValidateClassType(yaml_parser_t* doc, const char* expectedType); inline const YAMLNode* getRootNode() const {return m_rootNode.get();} bool read(yaml_parser_t* doc) { @@ -671,9 +672,15 @@ class YAMLDocWriter std::vector m_subStack; static bool RecursiveFinish(yaml_emitter_t* doc, const YAMLNode& node); public: - YAMLDocWriter() : m_rootNode(YAML_MAPPING_NODE) + YAMLDocWriter(const char* classType) : m_rootNode(YAML_MAPPING_NODE) { m_subStack.emplace_back(&m_rootNode); + if (classType) + { + YAMLNode* classVal = new YAMLNode(YAML_SCALAR_NODE); + classVal->m_scalarString.assign(classType); + m_rootNode.m_mapChildren.emplace_back("DNAType", std::unique_ptr(classVal)); + } } void enterSubRecord(const char* name) @@ -936,6 +943,8 @@ struct DNAYaml : DNA { virtual void toYAML(YAMLDocWriter& out) const=0; virtual void fromYAML(YAMLDocReader& in)=0; + static const char* DNAType() {return nullptr;} + virtual const char* DNATypeV() const {return nullptr;} template using Buffer = struct Athena::io::BufferYaml; @@ -970,7 +979,7 @@ struct DNAYaml : DNA return std::string(); } { - YAMLDocWriter docWriter; + YAMLDocWriter docWriter(DNATypeV()); toYAML(docWriter); if (!docWriter.finish(&emitter)) { @@ -1013,6 +1022,22 @@ struct DNAYaml : DNA return true; } + template + static bool ValidateFromYAMLString(const std::string& str) + { + yaml_parser_t parser; + if (!yaml_parser_initialize(&parser)) + { + HandleYAMLParserError(&parser); + return false; + } + YAMLStdStringReaderState reader(str); + yaml_parser_set_input(&parser, (yaml_read_handler_t*)YAMLStdStringReader, &reader); + bool retval = YAMLDocReader::ValidateClassType(&parser, DNASubtype::DNAType()); + yaml_parser_delete(&parser); + return retval; + } + bool toYAMLFile(FILE* fout) const { yaml_emitter_t emitter; @@ -1033,7 +1058,7 @@ struct DNAYaml : DNA return false; } { - YAMLDocWriter docWriter; + YAMLDocWriter docWriter(DNATypeV()); toYAML(docWriter); if (!docWriter.finish(&emitter)) { @@ -1074,6 +1099,23 @@ struct DNAYaml : DNA yaml_parser_delete(&parser); return true; } + + template + static bool ValidateFromYAMLFile(FILE* fin) + { + yaml_parser_t parser; + if (!yaml_parser_initialize(&parser)) + { + HandleYAMLParserError(&parser); + return false; + } + long pos = ftell(fin); + yaml_parser_set_input_file(&parser, fin); + bool retval = YAMLDocReader::ValidateClassType(&parser, DNASubtype::DNAType()); + fseek(fin, pos, SEEK_SET); + yaml_parser_delete(&parser); + return retval; + } }; template @@ -1160,11 +1202,15 @@ struct WStringAsStringYaml : public DNAYaml, public std::string DECL_DNA \ void fromYAML(Athena::io::YAMLDocReader&); \ void toYAML(Athena::io::YAMLDocWriter&) const; \ + static const char* DNAType(); \ + const char* DNATypeV() const {return DNAType();} \ /** Macro to automatically declare YAML read/write methods with client-code's definition */ #define DECL_EXPLICIT_YAML \ void fromYAML(Athena::io::YAMLDocReader&); \ void toYAML(Athena::io::YAMLDocWriter&) const; \ + static const char* DNAType(); \ + const char* DNATypeV() const {return DNAType();} \ } } diff --git a/src/Athena/DNAYaml.cpp b/src/Athena/DNAYaml.cpp index 7b83a7d..48c1fb4 100644 --- a/src/Athena/DNAYaml.cpp +++ b/src/Athena/DNAYaml.cpp @@ -169,6 +169,76 @@ std::unique_ptr YAMLDocReader::ParseEvents(yaml_parser_t* doc) return std::unique_ptr(); } +bool YAMLDocReader::ValidateClassType(yaml_parser_t* doc, const char* expectedType) +{ + if (!expectedType) + return false; + + yaml_event_t event; + if (!yaml_parser_parse(doc, &event)) + { + HandleYAMLParserError(doc); + return false; + } + + int result; + int mappingLevel = 0; + bool inDNA = false; + for (result = yaml_parser_parse(doc, &event); + event.type != YAML_STREAM_END_EVENT; + result = yaml_parser_parse(doc, &event)) + { + if (!result) + { + HandleYAMLParserError(doc); + return false; + } + switch (event.type) + { + case YAML_SCALAR_EVENT: + { + if (mappingLevel == 1) + { + if (inDNA) + { + if (!strcmp(expectedType, reinterpret_cast(event.data.scalar.value))) + { + yaml_event_delete(&event); + return true; + } + yaml_event_delete(&event); + return false; + } + if (!strcmp("DNAType", reinterpret_cast(event.data.scalar.value))) + inDNA = true; + } + break; + } + case YAML_MAPPING_START_EVENT: + { + ++mappingLevel; + inDNA = false; + break; + } + case YAML_MAPPING_END_EVENT: + { + --mappingLevel; + inDNA = false; + break; + } + case YAML_DOCUMENT_END_EVENT: + { + yaml_event_delete(&event); + return false; + } + default: + break; + } + yaml_event_delete(&event); + } + return false; +} + static inline bool EmitKeyScalar(yaml_emitter_t* doc, const char* val) { yaml_event_t event; From e6dedd0e6cd72117cc3b06ec1b42aec0371d5790 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 7 Oct 2015 13:50:50 -1000 Subject: [PATCH 09/13] Added double vector types --- include/Athena/Types.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/Athena/Types.hpp b/include/Athena/Types.hpp index d7f26fe..1278acb 100644 --- a/include/Athena/Types.hpp +++ b/include/Athena/Types.hpp @@ -96,6 +96,33 @@ typedef union alignas(16) float vec[4]; } atVec4f; +typedef union alignas(16) +{ +#if __SSE__ + __m128d mVec128; + AT_ALIGNED_ALLOCATOR +#endif + double vec[2]; +} atVec2d; + +typedef union alignas(16) +{ +#if __SSE__ + __m128d mVec128[2]; + AT_ALIGNED_ALLOCATOR +#endif + double vec[3]; +} atVec3d; + +typedef union alignas(16) +{ +#if __SSE__ + __m128d mVec128[2]; + AT_ALIGNED_ALLOCATOR +#endif + double vec[4]; +} atVec4d; + #ifndef NULL #ifdef __cplusplus From 418f3e763fed8234ae1498c56dcd574bdd66b020 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 11 Oct 2015 19:17:39 -1000 Subject: [PATCH 10/13] OS X fixes --- atdna/CMakeLists.txt | 3 ++- atdna/atdnaConfig.cmake.in | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 0505308..ac53c7a 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -167,7 +167,8 @@ macro(atdna out) # OSX Extra elseif(APPLE) - list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot /) + list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot + ${CMAKE_OSX_SYSROOT}/../../../../../Toolchains/XcodeDefault.xctoolchain) endif() # Make target diff --git a/atdna/atdnaConfig.cmake.in b/atdna/atdnaConfig.cmake.in index 0acd5fb..d73e53c 100644 --- a/atdna/atdnaConfig.cmake.in +++ b/atdna/atdnaConfig.cmake.in @@ -45,7 +45,8 @@ macro(atdna out) # OSX Extra elseif(APPLE) - list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot /) + list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot + ${CMAKE_OSX_SYSROOT}/../../../../../Toolchains/XcodeDefault.xctoolchain) endif() # Make target From 069840a77e2fabd1becea5229245ea17f49f489b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 15 Oct 2015 14:54:42 -0700 Subject: [PATCH 11/13] Implement atVec*d for atdna --- atdna/main.cpp | 97 ++++++++++++--- include/Athena/DNAYaml.hpp | 116 +++++++++++++++++- include/Athena/IStreamReader.hpp | 195 +++++++++++++++++++++++++++++++ include/Athena/IStreamWriter.hpp | 153 ++++++++++++++++++++++++ 4 files changed, 541 insertions(+), 20 deletions(-) diff --git a/atdna/main.cpp b/atdna/main.cpp index 6f0044a..df27aa2 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -1,4 +1,5 @@ #include +#include #include "clang/AST/ASTConsumer.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Frontend/CompilerInstance.h" @@ -218,15 +219,31 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor if (vType->isVectorType()) { const clang::BuiltinType* eType = (clang::BuiltinType*)vType->getElementType().getTypePtr(); + const uint64_t width = context.getTypeInfo(eType).Width; if (!eType->isBuiltinType() || !eType->isFloatingPoint() || - context.getTypeInfo(eType).Width != 32) + (width != 32 && width != 64)) continue; if (vType->getNumElements() == 2) - return ATHENA_DNA_WRITER ".writeVec2f" + funcPrefix + "(" + fieldName + ");"; + { + if (width == 32) + return ATHENA_DNA_WRITER ".writeVec2f" + funcPrefix + "(" + fieldName + ");"; + else if (width == 64) + return ATHENA_DNA_WRITER ".writeVec2d" + funcPrefix + "(" + fieldName + ");"; + } else if (vType->getNumElements() == 3) - return ATHENA_DNA_WRITER ".writeVec3f" + funcPrefix + "(" + fieldName + ");"; + { + if (width == 32) + return ATHENA_DNA_WRITER ".writeVec3f" + funcPrefix + "(" + fieldName + ");"; + else if (width == 64) + return ATHENA_DNA_WRITER ".writeVec3d" + funcPrefix + "(" + fieldName + ");"; + } else if (vType->getNumElements() == 4) - return ATHENA_DNA_WRITER ".writeVec4f" + funcPrefix + "(" + fieldName + ");"; + { + if (width == 32) + return ATHENA_DNA_WRITER ".writeVec4f" + funcPrefix + "(" + fieldName + ");"; + else if (width == 64) + return ATHENA_DNA_WRITER ".writeVec4d" + funcPrefix + "(" + fieldName + ");"; + } } } } @@ -323,15 +340,31 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor if (vType->isVectorType()) { const clang::BuiltinType* eType = (clang::BuiltinType*)vType->getElementType().getTypePtr(); + const uint64_t width = context.getTypeInfo(eType).Width; if (!eType->isBuiltinType() || !eType->isFloatingPoint() || - context.getTypeInfo(eType).Width != 32) + (width != 32 && width != 64)) continue; if (vType->getNumElements() == 2) - return ATHENA_DNA_READER ".readVec2f" + funcPrefix + "()"; + { + if (width == 32) + return ATHENA_DNA_READER ".readVec2f" + funcPrefix + "()"; + else if (width == 64) + return ATHENA_DNA_READER ".readVec2d" + funcPrefix + "()"; + } else if (vType->getNumElements() == 3) - return ATHENA_DNA_READER ".readVec3f" + funcPrefix + "()"; + { + if (width == 32) + return ATHENA_DNA_READER ".readVec3f" + funcPrefix + "()"; + else if (width == 64) + return ATHENA_DNA_READER ".readVec3d" + funcPrefix + "()"; + } else if (vType->getNumElements() == 4) - return ATHENA_DNA_READER ".readVec4f" + funcPrefix + "()"; + { + if (width == 32) + return ATHENA_DNA_READER ".readVec4f" + funcPrefix + "()"; + else if (width == 64) + return ATHENA_DNA_READER ".readVec4d" + funcPrefix + "()"; + } } } } @@ -436,15 +469,31 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor if (vType->isVectorType()) { const clang::BuiltinType* eType = (clang::BuiltinType*)vType->getElementType().getTypePtr(); + const uint64_t width = context.getTypeInfo(eType).Width; if (!eType->isBuiltinType() || !eType->isFloatingPoint() || - context.getTypeInfo(eType).Width != 32) + (width != 32 && width != 64)) continue; if (vType->getNumElements() == 2) - return ATHENA_YAML_WRITER ".writeVec2f(\"" + bareFieldName + "\", " + fieldName + ");"; + { + if (width == 32) + return ATHENA_YAML_WRITER ".writeVec2f(\"" + bareFieldName + "\", " + fieldName + ");"; + else if (width == 64) + return ATHENA_YAML_WRITER ".writeVec2d(\"" + bareFieldName + "\", " + fieldName + ");"; + } else if (vType->getNumElements() == 3) - return ATHENA_YAML_WRITER ".writeVec3f(\"" + bareFieldName + "\", " + fieldName + ");"; + { + if (width == 32) + return ATHENA_YAML_WRITER ".writeVec3f(\"" + bareFieldName + "\", " + fieldName + ");"; + else if (width == 64) + return ATHENA_YAML_WRITER ".writeVec3d(\"" + bareFieldName + "\", " + fieldName + ");"; + } else if (vType->getNumElements() == 4) - return ATHENA_YAML_WRITER ".writeVec4f(\"" + bareFieldName + "\", " + fieldName + ");"; + { + if (width == 32) + return ATHENA_YAML_WRITER ".writeVec4f(\"" + bareFieldName + "\", " + fieldName + ");"; + else if (width == 64) + return ATHENA_YAML_WRITER ".writeVec4d(\"" + bareFieldName + "\", " + fieldName + ");"; + } } } } @@ -541,15 +590,31 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor if (vType->isVectorType()) { const clang::BuiltinType* eType = (clang::BuiltinType*)vType->getElementType().getTypePtr(); + const uint64_t width = context.getTypeInfo(eType).Width; if (!eType->isBuiltinType() || !eType->isFloatingPoint() || - context.getTypeInfo(eType).Width != 32) + (width != 32 && width != 64)) continue; if (vType->getNumElements() == 2) - return ATHENA_YAML_READER ".readVec2f(\"" + bareFieldName + "\")"; + { + if (width == 32) + return ATHENA_YAML_READER ".readVec2f(\"" + bareFieldName + "\")"; + else if (width == 64) + return ATHENA_YAML_READER ".readVec2d(\"" + bareFieldName + "\")"; + } else if (vType->getNumElements() == 3) - return ATHENA_YAML_READER ".readVec3f(\"" + bareFieldName + "\")"; + { + if (width == 32) + return ATHENA_YAML_READER ".readVec3f(\"" + bareFieldName + "\")"; + else if (width == 64) + return ATHENA_YAML_READER ".readVec3d(\"" + bareFieldName + "\")"; + } else if (vType->getNumElements() == 4) - return ATHENA_YAML_READER ".readVec4f(\"" + bareFieldName + "\")"; + { + if (width == 32) + return ATHENA_YAML_READER ".readVec4f(\"" + bareFieldName + "\")"; + else if (width == 64) + return ATHENA_YAML_READER ".readVec4d(\"" + bareFieldName + "\")"; + } } } } diff --git a/include/Athena/DNAYaml.hpp b/include/Athena/DNAYaml.hpp index ebeb2e0..6294ae3 100644 --- a/include/Athena/DNAYaml.hpp +++ b/include/Athena/DNAYaml.hpp @@ -263,7 +263,14 @@ inline RETURNTYPE NodeToVec(const YAMLNode* node) { YAMLNode* snode = it->get(); if (snode->m_type == YAML_SCALAR_NODE) - retval.vec[i] = NodeToVal(snode); + { + if (std::is_same::value || + std::is_same::value || + std::is_same::value) + retval.vec[i] = NodeToVal(snode); + else + retval.vec[i] = NodeToVal(snode); + } else retval.vec[i] = 0.0; } @@ -336,6 +343,72 @@ inline std::unique_ptr ValToNode(const atVec4f& val) return std::unique_ptr(ret); } +template <> +inline atVec2d NodeToVal(const YAMLNode* node) +{ + return NodeToVec(node); +} + +template <> +inline std::unique_ptr ValToNode(const atVec2d& val) +{ + YAMLNode* ret = new YAMLNode(YAML_SEQUENCE_NODE); + ret->m_seqChildren.reserve(2); + for (size_t i=0 ; i<2 ; ++i) + { + char str[64]; + snprintf(str, 64, "%f", val.vec[i]); + YAMLNode* comp = new YAMLNode(YAML_SCALAR_NODE); + comp->m_scalarString = str; + ret->m_seqChildren.emplace_back(comp); + } + return std::unique_ptr(ret); +} + +template <> +inline atVec3d NodeToVal(const YAMLNode* node) +{ + return NodeToVec(node); +} + +template <> +inline std::unique_ptr ValToNode(const atVec3d& val) +{ + YAMLNode* ret = new YAMLNode(YAML_SEQUENCE_NODE); + ret->m_seqChildren.reserve(3); + for (size_t i=0 ; i<3 ; ++i) + { + char str[64]; + snprintf(str, 64, "%f", val.vec[i]); + YAMLNode* comp = new YAMLNode(YAML_SCALAR_NODE); + comp->m_scalarString = str; + ret->m_seqChildren.emplace_back(comp); + } + return std::unique_ptr(ret); +} + +template <> +inline atVec4d NodeToVal(const YAMLNode* node) +{ + return NodeToVec(node); +} + +template <> +inline std::unique_ptr ValToNode(const atVec4d& val) +{ + YAMLNode* ret = new YAMLNode(YAML_SEQUENCE_NODE); + ret->m_seqChildren.reserve(4); + for (size_t i=0 ; i<4 ; ++i) + { + char str[64]; + snprintf(str, 64, "%f", val.vec[i]); + YAMLNode* comp = new YAMLNode(YAML_SCALAR_NODE); + comp->m_scalarString = str; + ret->m_seqChildren.emplace_back(comp); + } + return std::unique_ptr(ret); +} + template <> inline std::unique_ptr NodeToVal(const YAMLNode* node) { @@ -643,12 +716,26 @@ public: { return readVal(name); } - inline atVec4f readVec4f(const char* name) { return readVal(name); } + inline atVec2d readVec2d(const char* name) + { + return readVal(name); + } + + inline atVec3d readVec3d(const char* name) + { + return readVal(name); + } + + inline atVec4d readVec4d(const char* name) + { + return readVal(name); + } + inline std::unique_ptr readUBytes(const char* name) { return readVal>(name); @@ -751,7 +838,10 @@ public: typename std::enable_if::value && !std::is_same::value && !std::is_same::value && - !std::is_same::value>::type* = 0) + !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value>::type* = 0) { enterSubVector(name); for (const T& item : vector) @@ -768,7 +858,10 @@ public: typename std::enable_if::value || std::is_same::value || std::is_same::value || - std::is_same::value>::type* = 0) + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value>::type* = 0) { enterSubVector(name); for (T item : vector) @@ -898,6 +991,21 @@ public: writeVal(name, val); } + inline void writeVec2d(const char* name, const atVec2d& val) + { + writeVal(name, val); + } + + inline void writeVec3d(const char* name, const atVec3d& val) + { + writeVal(name, val); + } + + inline void writeVec4d(const char* name, const atVec4d& val) + { + writeVal(name, val); + } + inline void writeUBytes(const char* name, const std::unique_ptr& val, size_t byteCount) { writeVal&>(name, val, byteCount); diff --git a/include/Athena/IStreamReader.hpp b/include/Athena/IStreamReader.hpp index b126f72..b29801b 100644 --- a/include/Athena/IStreamReader.hpp +++ b/include/Athena/IStreamReader.hpp @@ -686,6 +686,195 @@ public: inline atVec4f readValBig(typename std::enable_if::value>::type* = 0) {return readVec4fBig();} + /** @brief Reads an atVec2d (16 bytes), swaps to endianness specified by setEndian depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec2d readVec2d() + { + atVec2d val; + readUBytesToBuf(&val, 16); + if (m_endian == BigEndian) + { + utility::BigDouble(val.vec[0]); + utility::BigDouble(val.vec[1]); + } + else + { + utility::LittleDouble(val.vec[0]); + utility::LittleDouble(val.vec[1]); + } + return val; + } + template + inline atVec2d readVal(typename std::enable_if::value>::type* = 0) + {return readVec2d();} + + /** @brief Reads an atVec2d (16 bytes), swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec2d readVec2dLittle() + { + atVec2d val; + readUBytesToBuf(&val, 16); + utility::LittleDouble(val.vec[0]); + utility::LittleDouble(val.vec[1]); + return val; + } + template + inline atVec2d readValLittle(typename std::enable_if::value>::type* = 0) + {return readVec2dLittle();} + + /** @brief Reads an atVec2d (16 bytes), swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec2d readVec2dBig() + { + atVec2d val; + readUBytesToBuf(&val, 16); + utility::BigDouble(val.vec[0]); + utility::BigDouble(val.vec[1]); + return val; + } + template + inline atVec2d readValBig(typename std::enable_if::value>::type* = 0) + {return readVec2dBig();} + + /** @brief Reads an atVec3d (24 bytes), swaps to endianness specified by setEndian depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec3d readVec3d() + { + atVec3d val; + readUBytesToBuf(&val, 24); + if (m_endian == BigEndian) + { + utility::BigDouble(val.vec[0]); + utility::BigDouble(val.vec[1]); + utility::BigDouble(val.vec[2]); + } + else + { + utility::LittleDouble(val.vec[0]); + utility::LittleDouble(val.vec[1]); + utility::LittleDouble(val.vec[2]); + } + return val; + } + template + inline atVec3d readVal(typename std::enable_if::value>::type* = 0) + {return readVec3d();} + + /** @brief Reads an atVec3d (24 bytes), swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec3d readVec3dLittle() + { + atVec3d val; + readUBytesToBuf(&val, 24); + utility::LittleDouble(val.vec[0]); + utility::LittleDouble(val.vec[1]); + utility::LittleDouble(val.vec[2]); + return val; + } + template + inline atVec3d readValLittle(typename std::enable_if::value>::type* = 0) + {return readVec3dLittle();} + + /** @brief Reads an atVec3d (24 bytes), swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec3d readVec3dBig() + { + atVec3d val; + readUBytesToBuf(&val, 24); + utility::BigDouble(val.vec[0]); + utility::BigDouble(val.vec[1]); + utility::BigDouble(val.vec[2]); + return val; + } + template + inline atVec3d readValBig(typename std::enable_if::value>::type* = 0) + {return readVec3dBig();} + + /** @brief Reads an atVec4d (32 bytes), swaps to endianness specified by setEndian depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec4d readVec4d() + { + atVec4d val; + readUBytesToBuf(&val, 32); + if (m_endian == BigEndian) + { + utility::BigDouble(val.vec[0]); + utility::BigDouble(val.vec[1]); + utility::BigDouble(val.vec[2]); + utility::BigDouble(val.vec[3]); + } + else + { + utility::LittleDouble(val.vec[0]); + utility::LittleDouble(val.vec[1]); + utility::LittleDouble(val.vec[2]); + utility::LittleDouble(val.vec[3]); + } + return val; + } + template + inline atVec4d readVal(typename std::enable_if::value>::type* = 0) + {return readVec4d();} + + /** @brief Reads an atVec4d (32 bytes), swaps against little endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec4d readVec4dLittle() + { + atVec4d val; + readUBytesToBuf(&val, 32); + utility::LittleDouble(val.vec[0]); + utility::LittleDouble(val.vec[1]); + utility::LittleDouble(val.vec[2]); + utility::LittleDouble(val.vec[3]); + return val; + } + template + inline atVec4d readValLittle(typename std::enable_if::value>::type* = 0) + {return readVec4dLittle();} + + /** @brief Reads an atVec4d (32 bytes), swaps against big endianness depending on platform + * and advances the current position + * + * @return The value at the current address + */ + inline atVec4d readVec4dBig() + { + atVec4d val; + readUBytesToBuf(&val, 32); + utility::BigDouble(val.vec[0]); + utility::BigDouble(val.vec[1]); + utility::BigDouble(val.vec[2]); + utility::BigDouble(val.vec[3]); + return val; + } + template + inline atVec4d readValBig(typename std::enable_if::value>::type* = 0) + {return readVec4dBig();} + /** @brief Reads a wide-char string (using endianness from setEndian), * converts to UTF8 and advances the position in the file * @@ -1025,6 +1214,12 @@ public: protected: Endian m_endian; }; +template +IStreamReader& operator>>(IStreamReader& lhs, T& rhs) +{ + rhs = lhs.readVal(rhs); + return lhs; +} } } #endif // ISTREAMREADER diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp index 7468589..ff1f214 100644 --- a/include/Athena/IStreamWriter.hpp +++ b/include/Athena/IStreamWriter.hpp @@ -531,6 +531,159 @@ public: } inline void writeValBig(atVec4f val) {writeVec4fBig(val);} + /** @brief Writes an atVec2d (16 bytes) to the buffer and advances the buffer. + * It also swaps the bytes depending on the platform and Stream settings. + * + * @param vec The value to write to the buffer + */ + inline void writeVec2d(atVec2d vec) + { + if (m_endian == BigEndian) + { + utility::BigDouble(vec.vec[0]); + utility::BigDouble(vec.vec[1]); + } + else + { + utility::LittleDouble(vec.vec[0]); + utility::LittleDouble(vec.vec[1]); + } + writeUBytes((atUint8*)&vec, 16); + } + inline void writeVal(atVec2d val) {writeVec2d(val);} + + /** @brief Writes an atVec2d (16 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param vec The value to write to the buffer + */ + inline void writeVec2dLittle(atVec2d vec) + { + utility::LittleDouble(vec.vec[0]); + utility::LittleDouble(vec.vec[1]); + writeUBytes((atUint8*)&vec, 16); + } + inline void writeValLittle(atVec2d val) {writeVec2dLittle(val);} + + /** @brief Writes an atVec2d (16 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param vec The value to write to the buffer + */ + inline void writeVec2dBig(atVec2d vec) + { + utility::BigDouble(vec.vec[0]); + utility::BigDouble(vec.vec[1]); + writeUBytes((atUint8*)&vec, 16); + } + inline void writeValBig(atVec2d val) {writeVec2dBig(val);} + + /** @brief Writes an atVec3d (24 bytes) to the buffer and advances the buffer. + * It also swaps the bytes depending on the platform and Stream settings. + * + * @param vec The value to write to the buffer + */ + inline void writeVec3d(atVec3d vec) + { + if (m_endian == BigEndian) + { + utility::BigDouble(vec.vec[0]); + utility::BigDouble(vec.vec[1]); + utility::BigDouble(vec.vec[2]); + } + else + { + utility::LittleDouble(vec.vec[0]); + utility::LittleDouble(vec.vec[1]); + utility::LittleDouble(vec.vec[2]); + } + writeUBytes((atUint8*)&vec, 24); + } + inline void writeVal(atVec3d val) {writeVec3d(val);} + + /** @brief Writes an atVec3d (24 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param vec The value to write to the buffer + */ + inline void writeVec3dLittle(atVec3d vec) + { + utility::LittleDouble(vec.vec[0]); + utility::LittleDouble(vec.vec[1]); + utility::LittleDouble(vec.vec[2]); + writeUBytes((atUint8*)&vec, 24); + } + inline void writeValLittle(atVec3d val) {writeVec3dLittle(val);} + + /** @brief Writes an atVec3d (24 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param vec The value to write to the buffer + */ + inline void writeVec3dBig(atVec3d vec) + { + utility::BigDouble(vec.vec[0]); + utility::BigDouble(vec.vec[1]); + utility::BigDouble(vec.vec[2]); + writeUBytes((atUint8*)&vec, 24); + } + inline void writeValBig(atVec3d val) {writeVec3dBig(val);} + + /** @brief Writes an atVec4d (32 bytes) to the buffer and advances the buffer. + * It also swaps the bytes depending on the platform and Stream settings. + * + * @param vec The value to write to the buffer + */ + inline void writeVec4d(atVec4d vec) + { + if (m_endian == BigEndian) + { + utility::BigDouble(vec.vec[0]); + utility::BigDouble(vec.vec[1]); + utility::BigDouble(vec.vec[2]); + utility::BigDouble(vec.vec[3]); + } + else + { + utility::LittleDouble(vec.vec[0]); + utility::LittleDouble(vec.vec[1]); + utility::LittleDouble(vec.vec[2]); + utility::LittleDouble(vec.vec[3]); + } + writeUBytes((atUint8*)&vec, 32); + } + inline void writeVal(atVec4d val) {writeVec4d(val);} + + /** @brief Writes an atVec4d (32 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against little depending on the platform. + * + * @param vec The value to write to the buffer + */ + inline void writeVec4dLittle(atVec4d vec) + { + utility::LittleDouble(vec.vec[0]); + utility::LittleDouble(vec.vec[1]); + utility::LittleDouble(vec.vec[2]); + utility::LittleDouble(vec.vec[3]); + writeUBytes((atUint8*)&vec, 32); + } + inline void writeValLittle(atVec4d val) {writeVec4dLittle(val);} + + /** @brief Writes an atVec4d (32 bytes) to the buffer and advances the buffer. + * It also swaps the bytes against big depending on the platform. + * + * @param vec The value to write to the buffer + */ + inline void writeVec4dBig(atVec4d vec) + { + utility::BigDouble(vec.vec[0]); + utility::BigDouble(vec.vec[1]); + utility::BigDouble(vec.vec[2]); + utility::BigDouble(vec.vec[3]); + writeUBytes((atUint8*)&vec, 32); + } + inline void writeValBig(atVec4d val) {writeVec4dBig(val);} + /** @brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer. * It also swaps the bytes depending on the platform and Stream settings. * From a753c2e38a0e3ec786ba9ea8b6994af8dec47540 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 15 Oct 2015 15:20:50 -0700 Subject: [PATCH 12/13] Add operator>> to IStreamWriter.hpp --- include/Athena/IStreamWriter.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp index ff1f214..dd85377 100644 --- a/include/Athena/IStreamWriter.hpp +++ b/include/Athena/IStreamWriter.hpp @@ -1064,6 +1064,13 @@ public: protected: Endian m_endian; }; + +template +IStreamWriter& operator<<(IStreamWriter& lhs, const T& rhs) +{ + lhs.writeVal(rhs); + return lhs; +} } } #endif // STREAMWRITER_HPP From ffca1f18974293e9c59ebd01546c9910a22e3679 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 15 Oct 2015 17:06:12 -1000 Subject: [PATCH 13/13] writeVal not a template function --- include/Athena/IStreamWriter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Athena/IStreamWriter.hpp b/include/Athena/IStreamWriter.hpp index dd85377..a4e9a2d 100644 --- a/include/Athena/IStreamWriter.hpp +++ b/include/Athena/IStreamWriter.hpp @@ -1068,7 +1068,7 @@ protected: template IStreamWriter& operator<<(IStreamWriter& lhs, const T& rhs) { - lhs.writeVal(rhs); + lhs.writeVal(rhs); return lhs; } }