From 97dcd16492b4ce85138988461a85f6694fd7b264 Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 25 Feb 2023 19:49:02 -0800 Subject: Drop ryml Rapidyaml started refusing to parse config files so I dropped it. * Add ConfigMarshal clas to support very simple config marshalling * No versioning, no type indicators, nothing. * Supports int, bool, and string. * Bool are serialized as int. * Log no longer segfaults if given nullptr wxTextCtrl*. * Fix how whisper CPP GUI fields restore from config --- Designs/config_parser_design.md | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Designs/config_parser_design.md (limited to 'Designs/config_parser_design.md') diff --git a/Designs/config_parser_design.md b/Designs/config_parser_design.md new file mode 100644 index 0000000..84d160a --- /dev/null +++ b/Designs/config_parser_design.md @@ -0,0 +1,55 @@ +RYML has decided to stop working and I don't want to spend any more time trying +to figure out why. + +Let's make a parser that implements the small subset of YAML that +Config.{h,cpp} rely on. + +Config needs to serialize the following types: + +* std::string +* bool +* int + +Bool will be serialized like ints, with additional requirements on +deserialization. + +Serialization looks like this: +``` +ConfigMarshall cm(out_); +cm.Append("microphone", microphone_); // string +cm.Append("rows", rows_); // int +cm.Append("use_cpu", use_cpu_); // bool +cm.Write("config.yml"); +``` + +Deserialization looks like this: +``` +ConfigMarshall cm(out_); +cm.Load("config.yml"); +cm.Get("microphone", microphone_); // string +cm.Get("rows", rows_); // int +cm.Get("use_cpu", use_cpu_); // bool +``` + +Interface: +``` +class ConfigMarshal { +public: + ConfigMarshall(wxTextCtrl *out); + + bool Save(const std::filesystem::path& path); + bool Load(const std::filesystem::path& path); + + template + bool Append(const std::string& key, const T& value); + + template + bool Get(const std::string& key, T& value); + +private: + std::map kv_str_; + std::map kv_int_; + std::map kv_bool_; +} +``` + -- cgit v1.2.3