1 /* 2 * This file is part of liblcf. Copyright (c) 2021 liblcf authors. 3 * https://github.com/EasyRPG/liblcf - https://easyrpg.org 4 * 5 * liblcf is Free/Libre Open Source Software, released under the MIT License. 6 * For the full copyright and license information, please view the COPYING 7 * file that was distributed with this source code. 8 */ 9 10 #ifndef LCF_LSD_READER_H 11 #define LCF_LSD_READER_H 12 13 #include <string> 14 #include <vector> 15 #include <memory> 16 #include <ctime> 17 #include <stdint.h> 18 #include "lcf/rpg/save.h" 19 #include "lcf/saveopt.h" 20 21 namespace lcf { 22 23 /** 24 * LSD Reader namespace. 25 */ 26 namespace LSD_Reader { 27 /** 28 * Converts from UNIX timestamp to Delphi's TDateTime format. 29 */ 30 double ToTDateTime(std::time_t t); 31 32 /** 33 * Converts from Delphi's TDateTime format to UNIX timestamp. 34 */ 35 std::time_t ToUnixTimestamp(double ms); 36 37 /** 38 * Returns current system time encoded in Delphi's TDateTime format. 39 */ 40 double GenerateTimestamp(std::time_t t = std::time(nullptr)); 41 42 /** 43 * Increment the save save_count and update the timestamp. 44 */ 45 void PrepareSave(rpg::Save& save, int32_t version = 0); 46 47 /** 48 * Loads Savegame. 49 */ 50 std::unique_ptr<rpg::Save> Load(StringView filename, StringView encoding = ""); 51 52 /** 53 * Saves Savegame. 54 */ 55 bool Save(StringView filename, const rpg::Save& save, EngineVersion engine, StringView encoding = ""); 56 57 /* 58 * Saves Savegame as XML. 59 */ 60 bool SaveXml(StringView filename, const rpg::Save& save, EngineVersion engine); 61 62 /** 63 * Loads Savegame as XML. 64 */ 65 std::unique_ptr<rpg::Save> LoadXml(StringView filename); 66 67 /** 68 * Loads Savegame. 69 */ 70 std::unique_ptr<rpg::Save> Load(std::istream& filestream, StringView encoding = ""); 71 72 /** 73 * Saves Savegame. 74 */ 75 bool Save(std::ostream& filestream, const rpg::Save& save, EngineVersion engine, StringView encoding = ""); 76 77 /* 78 * Saves Savegame as XML. 79 */ 80 bool SaveXml(std::ostream& filestream, const rpg::Save& save, EngineVersion engine); 81 82 /** 83 * Loads Savegame as XML. 84 */ 85 std::unique_ptr<rpg::Save> LoadXml(std::istream& filestream); 86 } 87 88 } //namespace lcf 89 90 #endif 91