/* * Copyright (C) 2022 The V-Gears Team * * This file is part of V-Gears * * V-Gears is free software: you can redistribute it and/or modify it under * terms of the GNU General Public License as published by the Free Software * Foundation, version 3.0 (GPLv3) of the License. * * V-Gears 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. */ #pragma once #include #include #include "common/TypeDefine.h" #include "common/Logger.h" /** * Handles the */ class FF7FieldTextWriter{ public: /** * Initializes the text file. * * Writes the XML text section opening tag. * * @param file_name[in] Path to the file to write te text to. */ void Begin(std::string file_name); /** * Writes text to the XML file. * * @param script_section_buffer[in] The text data to write. * @param field_name[in] The field of the text. * @param english[in] True if the language to write. */ void Write( const std::vector& script_section_buffer, std::string field_name, bool english = true ); /** * Finalizes the text file. * * Writes the XML text section closing tag. */ void End(); private: /** * Adds text. * * @param text[in] The text to add. */ void AddText(std::vector& text); /** * Reads 16 bytes of data from the data (little endian). * * @param offset[in] Offset at which to read. * @return 16 bytes of data at the specified offset. * @throws std::out_of_range If the offset is out of the data. */ u16 GetU16LE(u32 offset); /** * Reads 8 bytes of data from the data. * * @param offset[in] Offset at which to read. * @return 8 bytes of data at the specified offset. * @throws std::out_of_range If the offset is out of the data. */ u8 GetU8(u32 offset); /** * The logger used to write text. */ std::unique_ptr logger_; /** * The data being read. */ std::vector data_; /** * Indicates if the text XML tag has been openend and not closed. */ bool tag_open_ = false; };