6
6
#ifndef GRAPHQLRESPONSE_H
7
7
#define GRAPHQLRESPONSE_H
8
8
9
+ // clang-format off
9
10
#ifdef GRAPHQL_DLLEXPORTS
10
11
#ifdef IMPL_GRAPHQLRESPONSE_DLL
11
12
#define GRAPHQLRESPONSE_EXPORT __declspec (dllexport)
15
16
#else // !GRAPHQL_DLLEXPORTS
16
17
#define GRAPHQLRESPONSE_EXPORT
17
18
#endif // !GRAPHQL_DLLEXPORTS
19
+ // clang-format on
18
20
19
21
#include < memory>
20
22
#include < string>
@@ -28,15 +30,15 @@ namespace graphql::response {
28
30
// of the [June 2018 spec](https://facebook.github.io/graphql/June2018/#sec-Serialization-Format).
29
31
enum class Type : uint8_t
30
32
{
31
- Map, // JSON Object
32
- List, // JSON Array
33
- String, // JSON String
34
- Null, // JSON null
35
- Boolean, // JSON true or false
36
- Int, // JSON Number
37
- Float, // JSON Number
38
- EnumValue, // JSON String
39
- Scalar, // JSON any type
33
+ Map, // JSON Object
34
+ List, // JSON Array
35
+ String, // JSON String
36
+ Null, // JSON null
37
+ Boolean, // JSON true or false
38
+ Int, // JSON Number
39
+ Float, // JSON Number
40
+ EnumValue, // JSON String
41
+ Scalar, // JSON any type
40
42
};
41
43
42
44
struct Value ;
@@ -157,28 +159,36 @@ struct Value
157
159
// Specialized for all single-value Types.
158
160
template <typename ValueType>
159
161
void set (typename std::enable_if_t <std::is_same_v<std::decay_t <ValueType>, ValueType>,
160
- typename ValueTypeTraits<ValueType>::set_type> value);
162
+ typename ValueTypeTraits<ValueType>::set_type>
163
+ value);
161
164
162
165
// Specialized for all Types.
163
166
template <typename ValueType>
164
167
typename std::enable_if_t <std::is_same_v<std::decay_t <ValueType>, ValueType>,
165
- typename ValueTypeTraits<ValueType>::get_type> get () const ;
168
+ typename ValueTypeTraits<ValueType>::get_type>
169
+ get () const ;
166
170
167
171
// Specialized for all Types which allocate extra memory.
168
172
template <typename ValueType>
169
173
typename ValueTypeTraits<ValueType>::release_type release ();
170
174
171
175
// Compatibility wrappers
172
176
template <typename ReferenceType>
173
- [[deprecated(" Use the unqualified Value::set<> specialization instead of specializing on the r-value reference." )]]
174
- void set (typename std::enable_if_t <std::is_rvalue_reference_v<ReferenceType>, ReferenceType> value)
177
+ [[deprecated(" Use the unqualified Value::set<> specialization instead of specializing on the "
178
+ " r-value reference." )]] void
179
+ set (typename std::enable_if_t <std::is_rvalue_reference_v<ReferenceType>, ReferenceType> value)
175
180
{
176
181
set<std::decay_t <ReferenceType>>(std::move (value));
177
182
}
178
183
179
184
template <typename ReferenceType>
180
- [[deprecated(" Use the unqualified Value::get<> specialization instead of specializing on the const reference." )]]
181
- typename std::enable_if_t <std::is_lvalue_reference_v<ReferenceType> && std::is_const_v<typename std::remove_reference_t <ReferenceType>>, ReferenceType> get () const
185
+ [[deprecated(" Use the unqualified Value::get<> specialization instead of specializing on the "
186
+ " const reference." )]]
187
+ typename std::enable_if_t <
188
+ std::is_lvalue_reference_v<
189
+ ReferenceType> && std::is_const_v<typename std::remove_reference_t <ReferenceType>>,
190
+ ReferenceType>
191
+ get () const
182
192
{
183
193
return get<std::decay_t <ReferenceType>>();
184
194
}
@@ -190,22 +200,38 @@ struct Value
190
200
191
201
#ifdef GRAPHQL_DLLEXPORTS
192
202
// Export all of the specialized template methods
193
- template <> GRAPHQLRESPONSE_EXPORT void Value::set<StringType>(StringType&& value);
194
- template <> GRAPHQLRESPONSE_EXPORT void Value::set<BooleanType>(BooleanType value);
195
- template <> GRAPHQLRESPONSE_EXPORT void Value::set<IntType>(IntType value);
196
- template <> GRAPHQLRESPONSE_EXPORT void Value::set<FloatType>(FloatType value);
197
- template <> GRAPHQLRESPONSE_EXPORT void Value::set<ScalarType>(ScalarType&& value);
198
- template <> GRAPHQLRESPONSE_EXPORT const MapType& Value::get<MapType>() const ;
199
- template <> GRAPHQLRESPONSE_EXPORT const ListType& Value::get<ListType>() const ;
200
- template <> GRAPHQLRESPONSE_EXPORT const StringType& Value::get<StringType>() const ;
201
- template <> GRAPHQLRESPONSE_EXPORT BooleanType Value::get<BooleanType>() const ;
202
- template <> GRAPHQLRESPONSE_EXPORT IntType Value::get<IntType>() const ;
203
- template <> GRAPHQLRESPONSE_EXPORT FloatType Value::get<FloatType>() const ;
204
- template <> GRAPHQLRESPONSE_EXPORT const ScalarType& Value::get<ScalarType>() const ;
205
- template <> GRAPHQLRESPONSE_EXPORT MapType Value::release<MapType>();
206
- template <> GRAPHQLRESPONSE_EXPORT ListType Value::release<ListType>();
207
- template <> GRAPHQLRESPONSE_EXPORT StringType Value::release<StringType>();
208
- template <> GRAPHQLRESPONSE_EXPORT ScalarType Value::release<ScalarType>();
203
+ template <>
204
+ GRAPHQLRESPONSE_EXPORT void Value::set<StringType>(StringType&& value);
205
+ template <>
206
+ GRAPHQLRESPONSE_EXPORT void Value::set<BooleanType>(BooleanType value);
207
+ template <>
208
+ GRAPHQLRESPONSE_EXPORT void Value::set<IntType>(IntType value);
209
+ template <>
210
+ GRAPHQLRESPONSE_EXPORT void Value::set<FloatType>(FloatType value);
211
+ template <>
212
+ GRAPHQLRESPONSE_EXPORT void Value::set<ScalarType>(ScalarType&& value);
213
+ template <>
214
+ GRAPHQLRESPONSE_EXPORT const MapType& Value::get<MapType>() const ;
215
+ template <>
216
+ GRAPHQLRESPONSE_EXPORT const ListType& Value::get<ListType>() const ;
217
+ template <>
218
+ GRAPHQLRESPONSE_EXPORT const StringType& Value::get<StringType>() const ;
219
+ template <>
220
+ GRAPHQLRESPONSE_EXPORT BooleanType Value::get<BooleanType>() const ;
221
+ template <>
222
+ GRAPHQLRESPONSE_EXPORT IntType Value::get<IntType>() const ;
223
+ template <>
224
+ GRAPHQLRESPONSE_EXPORT FloatType Value::get<FloatType>() const ;
225
+ template <>
226
+ GRAPHQLRESPONSE_EXPORT const ScalarType& Value::get<ScalarType>() const ;
227
+ template <>
228
+ GRAPHQLRESPONSE_EXPORT MapType Value::release<MapType>();
229
+ template <>
230
+ GRAPHQLRESPONSE_EXPORT ListType Value::release<ListType>();
231
+ template <>
232
+ GRAPHQLRESPONSE_EXPORT StringType Value::release<StringType>();
233
+ template <>
234
+ GRAPHQLRESPONSE_EXPORT ScalarType Value::release<ScalarType>();
209
235
#endif // GRAPHQL_DLLEXPORTS
210
236
211
237
} /* namespace graphql::response */
0 commit comments