diff options
author | Your Name <you@example.com> | 2021-05-06 14:13:28 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-06 14:13:28 -0400 |
commit | 9f3802690f9dd9452e96d1d7a879291978d66e35 (patch) | |
tree | 6d6c17b39abdb9490119241bc4fc061744b46d7d /src/jsonable.h | |
parent | 2a9f262e6db5906db445d465e500d7ba8c90fab3 (diff) | |
download | dmtool-9f3802690f9dd9452e96d1d7a879291978d66e35.tar.gz dmtool-9f3802690f9dd9452e96d1d7a879291978d66e35.tar.bz2 dmtool-9f3802690f9dd9452e96d1d7a879291978d66e35.zip |
Refactoring
Diffstat (limited to 'src/jsonable.h')
-rw-r--r-- | src/jsonable.h | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/jsonable.h b/src/jsonable.h index 0385fb1..7411efa 100644 --- a/src/jsonable.h +++ b/src/jsonable.h @@ -1,8 +1,5 @@ #pragma once #include "json.hpp" -#include "utils.h" -#include <memory> -#include <vector> class Jsonable { public: @@ -10,33 +7,3 @@ class Jsonable { operator nlohmann::json() const {return toJson();} virtual ~Jsonable() {} }; - -template<typename T> std::vector<T> json2vec(const nlohmann::json& data) { - using std::begin; using std::end; - return std::vector<T>(begin(data), end(data)); -} - -template<typename T> std::vector<std::shared_ptr<T>> jsonList2ptrvec(const std::string& type, const std::vector<std::string>& names) { - std::vector<std::shared_ptr<T>> ret; - for(auto name : names) { - auto j = utils::loadJson(type, name); - ret.push_back(std::shared_ptr<T>(new T(j, j))); - } - return ret; -} - -template<typename T> std::vector<std::shared_ptr<T>> json2ptrvec(const nlohmann::json& data) { - std::vector<std::shared_ptr<T>> ret; - for(nlohmann::json d : data) { - ret.push_back(T::create(d)); - } - return ret; -} - -template<typename T> std::vector<nlohmann::json> ptrvec2json(std::vector<T> src) { - std::vector<nlohmann::json> ret; - for(T i : src) { - ret.push_back(i->toJson()); - } - return ret; -} |