diff options
Diffstat (limited to 'src/defines.h')
-rw-r--r-- | src/defines.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/defines.h b/src/defines.h index 587656a..78ab770 100644 --- a/src/defines.h +++ b/src/defines.h @@ -2,3 +2,12 @@ friend void to_json(nlohmann::json& nlohmann_json_j, const Derived& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<Super>(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<Super&>(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; } + +#define NLOHMANN_FRIEND_DECLARES(Type) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t); \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t); \ + virtual nlohmann::json serialize(void) const override { nlohmann::json ret; to_json(ret, *this); return ret; } + +#define NLOHMANN_FRIEND_DEFS(Super, Derived, PImpl) \ + void to_json(nlohmann::json& nlohmann_json_j, const Derived& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<Super>(nlohmann_json_t)); nlohmann::to_json(nlohmann_json_j, *nlohmann_json_t.PImpl); } \ + void from_json(const nlohmann::json& nlohmann_json_j, Derived& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<Super&>(nlohmann_json_t)); nlohmann::from_json(nlohmann_json_j, *nlohmann_json_t.PImpl); } |