@@ -22,63 +22,63 @@ namespace sourcemeta::core {
22
22
23
23
// / @ingroup json
24
24
template <typename , typename = void >
25
- struct to_json_has_mapped_type : std::false_type {};
25
+ struct json_auto_has_mapped_type : std::false_type {};
26
26
template <typename T>
27
- struct to_json_has_mapped_type <T, std::void_t <typename T::mapped_type>>
27
+ struct json_auto_has_mapped_type <T, std::void_t <typename T::mapped_type>>
28
28
: std::true_type {};
29
29
30
30
// / @ingroup json
31
- template <typename T> struct to_json_is_basic_string : std::false_type {};
31
+ template <typename T> struct json_auto_is_basic_string : std::false_type {};
32
32
template <typename CharT, typename Traits, typename Alloc>
33
- struct to_json_is_basic_string <std::basic_string<CharT, Traits, Alloc>>
33
+ struct json_auto_is_basic_string <std::basic_string<CharT, Traits, Alloc>>
34
34
: std::true_type {};
35
35
36
36
// / @ingroup json
37
37
template <typename T>
38
- concept to_json_has_method = requires (const T value) {
38
+ concept json_auto_has_method = requires (const T value) {
39
39
{ value.to_json () } -> std::same_as<JSON>;
40
40
};
41
41
42
42
// / @ingroup json
43
43
// / Container-like classes can opt-out from automatic JSON
44
44
// / serialisation by setting `using json_auto = std::false_type;`
45
45
template <typename , typename = void >
46
- struct to_json_supports_auto_impl : std::true_type {};
46
+ struct json_auto_supports_auto_impl : std::true_type {};
47
47
template <typename T>
48
- struct to_json_supports_auto_impl <T, std::void_t <typename T::json_auto>>
48
+ struct json_auto_supports_auto_impl <T, std::void_t <typename T::json_auto>>
49
49
: std::bool_constant<
50
50
!std::is_same_v<typename T::json_auto, std::false_type>> {};
51
51
template <typename T>
52
- concept to_json_supports_auto = to_json_supports_auto_impl <T>::value;
52
+ concept json_auto_supports_auto = json_auto_supports_auto_impl <T>::value;
53
53
54
54
// / @ingroup json
55
55
template <typename T>
56
- concept to_json_list_like =
56
+ concept json_auto_list_like =
57
57
requires (T type) {
58
58
typename T::value_type;
59
59
typename T::const_iterator;
60
60
{ type.cbegin () } -> std::same_as<typename T::const_iterator>;
61
61
{ type.cend () } -> std::same_as<typename T::const_iterator>;
62
- } && to_json_supports_auto <T> && !to_json_has_mapped_type <T>::value &&
63
- !to_json_has_method <T> && !to_json_is_basic_string <T>::value;
62
+ } && json_auto_supports_auto <T> && !json_auto_has_mapped_type <T>::value &&
63
+ !json_auto_has_method <T> && !json_auto_is_basic_string <T>::value;
64
64
65
65
// / @ingroup json
66
66
template <typename T>
67
- concept to_json_map_like =
67
+ concept json_auto_map_like =
68
68
requires (T type) {
69
69
typename T::value_type;
70
70
typename T::const_iterator;
71
71
typename T::key_type;
72
72
{ type.cbegin () } -> std::same_as<typename T::const_iterator>;
73
73
{ type.cend () } -> std::same_as<typename T::const_iterator>;
74
- } && to_json_supports_auto <T> && to_json_has_mapped_type <T>::value &&
75
- !to_json_has_method <T> &&
74
+ } && json_auto_supports_auto <T> && json_auto_has_mapped_type <T>::value &&
75
+ !json_auto_has_method <T> &&
76
76
std::is_same_v<typename T::key_type, JSON::String>;
77
77
78
78
// / @ingroup json
79
79
// / If the value has a `.to_json()` method, always prefer that
80
80
template <typename T>
81
- requires (to_json_has_method <T>)
81
+ requires (json_auto_has_method <T>)
82
82
auto to_json (const T &value) -> JSON {
83
83
return value.to_json ();
84
84
}
@@ -124,7 +124,7 @@ template <typename T> auto to_json(const std::optional<T> &value) -> JSON {
124
124
}
125
125
126
126
// / @ingroup json
127
- template <to_json_list_like T>
127
+ template <json_auto_list_like T>
128
128
auto to_json (typename T::const_iterator begin, typename T::const_iterator end)
129
129
-> JSON {
130
130
// TODO: Extend `make_array` to optionally take iterators, etc
@@ -137,7 +137,7 @@ auto to_json(typename T::const_iterator begin, typename T::const_iterator end)
137
137
}
138
138
139
139
// / @ingroup json
140
- template <to_json_list_like T>
140
+ template <json_auto_list_like T>
141
141
auto to_json (
142
142
typename T::const_iterator begin, typename T::const_iterator end,
143
143
const std::function<JSON(const typename T::value_type &)> &callback)
@@ -152,12 +152,12 @@ auto to_json(
152
152
}
153
153
154
154
// / @ingroup json
155
- template <to_json_list_like T> auto to_json (const T &value) -> JSON {
155
+ template <json_auto_list_like T> auto to_json (const T &value) -> JSON {
156
156
return to_json<T>(value.cbegin (), value.cend ());
157
157
}
158
158
159
159
// / @ingroup json
160
- template <to_json_list_like T>
160
+ template <json_auto_list_like T>
161
161
auto to_json (
162
162
const T &value,
163
163
const std::function<JSON(const typename T::value_type &)> &callback)
@@ -166,7 +166,7 @@ auto to_json(
166
166
}
167
167
168
168
// / @ingroup json
169
- template <to_json_map_like T>
169
+ template <json_auto_map_like T>
170
170
auto to_json (typename T::const_iterator begin, typename T::const_iterator end)
171
171
-> JSON {
172
172
auto result{JSON::make_object ()};
@@ -178,12 +178,12 @@ auto to_json(typename T::const_iterator begin, typename T::const_iterator end)
178
178
}
179
179
180
180
// / @ingroup json
181
- template <to_json_map_like T> auto to_json (const T &value) -> JSON {
181
+ template <json_auto_map_like T> auto to_json (const T &value) -> JSON {
182
182
return to_json<T>(value.cbegin (), value.cend ());
183
183
}
184
184
185
185
// / @ingroup json
186
- template <to_json_map_like T>
186
+ template <json_auto_map_like T>
187
187
auto to_json (
188
188
typename T::const_iterator begin, typename T::const_iterator end,
189
189
const std::function<JSON(const typename T::mapped_type &)> &callback)
@@ -197,7 +197,7 @@ auto to_json(
197
197
}
198
198
199
199
// / @ingroup json
200
- template <to_json_map_like T>
200
+ template <json_auto_map_like T>
201
201
auto to_json (
202
202
const T &value,
203
203
const std::function<JSON(const typename T::mapped_type &)> &callback)
0 commit comments