peeve: guarantee toml order (#451)

This commit is contained in:
Ada 2024-03-08 16:08:41 +00:00 committed by GitHub
parent 498d19fa51
commit ff1eaed0a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
#include <map>
#include <string> #include <string>
#include "helpers.hpp" #include "helpers.hpp"
@ -99,13 +100,13 @@ void EmulatorConfig::load() {
} }
void EmulatorConfig::save() { void EmulatorConfig::save() {
toml::basic_value<toml::preserve_comments> data; toml::basic_value<toml::preserve_comments, std::map> data;
const std::filesystem::path& path = filePath; const std::filesystem::path& path = filePath;
std::error_code error; std::error_code error;
if (std::filesystem::exists(path, error)) { if (std::filesystem::exists(path, error)) {
try { try {
data = toml::parse<toml::preserve_comments>(path); data = toml::parse<toml::preserve_comments, std::map>(path);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Helpers::warn("Exception trying to parse config file. Exception: %s\n", ex.what()); Helpers::warn("Exception trying to parse config file. Exception: %s\n", ex.what());
return; return;