Wildmeshing Toolkit
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 
11 // place this to define the prototype of the to_json function
12 #define WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE(Type)\
13  void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t)
14 // place this to define the prototype of the from_json function
15 #define WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE(Type)\
16  void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t)
17 
18 #define WMTK_NLOHMANN_ASSIGN_TYPE_TO_JSON(...) \
19  { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
20 
21 #define WMTK_NLOHMANN_ASSIGN_TYPE_FROM_JSON(...) \
22  { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
23 
24