diff options
author | Your Name <you@example.com> | 2021-05-09 19:01:59 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-09 19:01:59 -0400 |
commit | e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd (patch) | |
tree | 344c09421c5839a764a132fe9166f0e6e3f90e45 /src/jsonable.h | |
parent | d13358b71ec15085f2638fd9c3fc634df62dfc94 (diff) | |
download | dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.gz dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.bz2 dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.zip |
Code refactoring
Diffstat (limited to 'src/jsonable.h')
-rw-r--r-- | src/jsonable.h | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/src/jsonable.h b/src/jsonable.h deleted file mode 100644 index 01c720b..0000000 --- a/src/jsonable.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "json.hpp" -#include <memory> -#include <vector> - -class Jsonable { - public: - virtual nlohmann::json toJson(void) const = 0; - operator nlohmann::json() const {return toJson();} - virtual ~Jsonable() {} -}; - -namespace nlohmann { - template <typename T> struct adl_serializer<std::shared_ptr<T>> { - static void to_json(json& j, const std::shared_ptr<T>& opt) { - if(opt) { - j = *opt; - } else { - j = nullptr; - } - } - static void from_json(const json& j, std::shared_ptr<T>& opt) { - opt = std::shared_ptr<T>(T::create(j)); - } - }; -} |