| 95 | } |
| 96 | |
| 97 | void ConfigManager::SaveToFile(FILE *f) const |
| 98 | { |
| 99 | static constexpr std::string_view COMMENT = "// See https://TranslucentTB.github.io/config for more information\n"; |
| 100 | static constexpr std::wstring_view SCHEMA = L"https://TranslucentTB.github.io/settings.schema.json"; |
| 101 | |
| 102 | char buffer[1024]; |
| 103 | rj::FileWriteStream filestream(f, buffer, std::size(buffer)); |
| 104 | |
| 105 | using OutputStream = rj::EncodedOutputStream<rj::UTF8<>, rj::FileWriteStream>; |
| 106 | OutputStream out(filestream, true); |
| 107 | |
| 108 | for (const char c : COMMENT) |
| 109 | { |
| 110 | out.Put(c); |
| 111 | } |
| 112 | |
| 113 | rj::PrettyWriter<OutputStream, rj::UTF16LE<>> writer(out); |
| 114 | writer.SetIndent(' ', 2); |
| 115 | |
| 116 | writer.StartObject(); |
| 117 | rjh::Serialize(writer, SCHEMA, SCHEMA_KEY); |
| 118 | m_Config.Serialize(writer); |
| 119 | writer.EndObject(); |
| 120 | |
| 121 | writer.Flush(); |
| 122 | } |
| 123 | |
| 124 | bool ConfigManager::LoadFromFile(FILE *f) |
| 125 | { |