Wildmeshing Toolkit
Loading...
Searching...
No Matches
json_macros.hpp
Go to the documentation of this file.
1#pragma once
2#include <nlohmann/json_fwd.hpp>
3
4
5// place these in the class for which serialization is desired
6#define WMTK_NLOHMANN_JSON_FRIEND_DECLARATION(Type)\
7 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t);\
8 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t);
9
10// place these in the class for which serialization is desired
11#define WMTK_NLOHMANN_JSON_DECLARATION(Type)\
12 void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t);\
13 void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t);
14
15
16// place this to define the prototype of the to_json function
17#define WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE(Type)\
18 void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t)
19// place this to define the prototype of the from_json function
20#define WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE(Type)\
21 void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t)
22
23#define WMTK_NLOHMANN_ASSIGN_TYPE_TO_JSON(...) \
24 { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
25
26#define WMTK_NLOHMANN_ASSIGN_TYPE_FROM_JSON(...) \
27 { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
28
29
30