summaryrefslogtreecommitdiff
path: root/state.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-11-04 01:48:13 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-11-04 01:48:13 -0400
commitc40b8a412272a7a407764166917cf3c61e7dc47f (patch)
tree23f8f32635f73401e0c3c2a4b04372f9e8fe7c41 /state.cpp
parent1f445742b4fbc185fe0e24d9ed2478e4f7495f53 (diff)
downloadabaddon-portaudio-c40b8a412272a7a407764166917cf3c61e7dc47f.tar.gz
abaddon-portaudio-c40b8a412272a7a407764166917cf3c61e7dc47f.zip
add files that should have been pushed with last commit
oops
Diffstat (limited to 'state.cpp')
-rw-r--r--state.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/state.cpp b/state.cpp
new file mode 100644
index 0000000..043d181
--- /dev/null
+++ b/state.cpp
@@ -0,0 +1,37 @@
+#include "state.hpp"
+
+void to_json(nlohmann::json &j, const ExpansionStateRoot &m) {
+ if (m.Children.empty()) {
+ j = nlohmann::json::object();
+ } else {
+ for (const auto &[id, state] : m.Children)
+ j[std::to_string(id)] = state;
+ }
+}
+
+void from_json(const nlohmann::json &j, ExpansionStateRoot &m) {
+ for (const auto &[key, value] : j.items())
+ m.Children[key] = value;
+}
+
+void to_json(nlohmann::json &j, const ExpansionState &m) {
+ j["e"] = m.IsExpanded;
+ j["c"] = m.Children;
+}
+
+void from_json(const nlohmann::json &j, ExpansionState &m) {
+ j.at("e").get_to(m.IsExpanded);
+ j.at("c").get_to(m.Children);
+}
+
+void to_json(nlohmann::json &j, const AbaddonApplicationState &m) {
+ j["active_channel"] = m.ActiveChannel;
+ j["expansion"] = m.Expansion;
+}
+
+void from_json(const nlohmann::json &j, AbaddonApplicationState &m) {
+ if (j.contains("active_channel"))
+ j.at("active_channel").get_to(m.ActiveChannel);
+ if (j.contains("expansion"))
+ j.at("expansion").get_to(m.Expansion);
+}