From e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 9 May 2021 19:01:59 -0400 Subject: Code refactoring --- src/defines.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/defines.h (limited to 'src/defines.h') diff --git a/src/defines.h b/src/defines.h new file mode 100644 index 0000000..587656a --- /dev/null +++ b/src/defines.h @@ -0,0 +1,4 @@ +#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Super, Derived, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Derived& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Derived& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } \ + virtual nlohmann::json serialize(void) const override { nlohmann::json ret; to_json(ret, *this); return ret; } -- cgit v1.2.3