#pragma once // MassBuilderSaveTool // Copyright (C) 2021-2023 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; namespace Gvas { class BinaryReader { public: explicit BinaryReader(Containers::StringView filename); ~BinaryReader(); bool open(); bool eof(); auto position() -> std::int64_t; bool seek(std::int64_t position); void closeFile(); bool readChar(char& value); bool readInt8(std::int8_t& value); bool readUint8(std::uint8_t& value); bool readInt16(std::int16_t& value); bool readUint16(std::uint16_t& value); bool readInt32(std::int32_t& value); bool readUint32(std::uint32_t& value); bool readInt64(std::int64_t& value); bool readUint64(std::uint64_t& value); bool readFloat(float& value); bool readDouble(double& value); bool readArray(Containers::Array& array, std::size_t count); template bool readValue(T& value) { return fread(&value, sizeof(T), 1, _file) == sizeof(T); } template bool readStaticArray(Containers::StaticArray& array) { return std::fread(array.data(), sizeof(char), S, _file) == S; } bool readUEString(Containers::String& str); auto peekChar() -> std::int32_t; private: std::FILE* _file = nullptr; }; }