#pragma once // MassBuilderSaveTool // Copyright (C) 2021 Guillaume Jacquemin // // This program 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. // // This program 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 this program. If not, see . #include #include #include #include #include using namespace Corrade; using namespace Magnum; class BinaryReader { public: explicit BinaryReader(const std::string& filename); ~BinaryReader(); auto open() -> bool; auto eof() -> bool; auto position() -> Long; void closeFile(); auto readChar(char& value) -> bool; auto readByte(Byte& value) -> bool; auto readUnsignedByte(UnsignedByte& value) -> bool; auto readShort(Short& value) -> bool; auto readUnsignedShort(UnsignedShort& value) -> bool; auto readInt(Int& value) -> bool; auto readUnsignedInt(UnsignedInt& value) -> bool; auto readLong(Long& value) -> bool; auto readUnsignedLong(UnsignedLong& value) -> bool; auto readFloat(Float& value) -> bool; auto readDouble(Double& value) -> bool; auto readArray(Containers::Array& array, std::size_t count) -> bool; template auto readStaticArray(Containers::StaticArray& array) -> bool { return std::fread(array.data(), sizeof(char), S, _file) == S; } auto readUEString(std::string& str) -> bool; auto peekChar() -> Int; private: std::FILE* _file = nullptr; };