Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
json-impls.hh
Go to the documentation of this file.
1#pragma once
3
4#include <nlohmann/json_fwd.hpp>
5
7
8// Following https://github.com/nlohmann/json#how-can-i-use-get-for-non-default-constructiblenon-copyable-types
9#define JSON_IMPL_INNER_TO(TYPE) \
10 struct adl_serializer<TYPE> \
11 { \
12 static void to_json(json & json, const TYPE & t); \
13 }
14
15#define JSON_IMPL_INNER_FROM(TYPE) \
16 struct adl_serializer<TYPE> \
17 { \
18 static TYPE from_json(const json & json); \
19 }
20
21#define JSON_IMPL_INNER(TYPE) \
22 struct adl_serializer<TYPE> \
23 { \
24 static TYPE from_json(const json & json); \
25 static void to_json(json & json, const TYPE & t); \
26 }
27
28#define JSON_IMPL(TYPE) \
29 namespace nlohmann { \
30 template<> \
31 JSON_IMPL_INNER(TYPE); \
32 }
33
34#define JSON_IMPL_WITH_XP_FEATURES_INNER(TYPE) \
35 struct adl_serializer<TYPE> \
36 { \
37 static TYPE from_json( \
38 const json & json, \
39 const nix::ExperimentalFeatureSettings & xpSettings = nix::experimentalFeatureSettings); \
40 static void to_json(json & json, const TYPE & t); \
41 }
42
43#define JSON_IMPL_WITH_XP_FEATURES(TYPE) \
44 namespace nlohmann { \
45 template<> \
46 JSON_IMPL_WITH_XP_FEATURES_INNER(TYPE); \
47 }