66#ifndef GRAPHQLRESPONSE_H
77#define GRAPHQLRESPONSE_H
88
9+ // clang-format off
910#ifdef GRAPHQL_DLLEXPORTS
1011 #ifdef IMPL_GRAPHQLRESPONSE_DLL
1112 #define GRAPHQLRESPONSE_EXPORT __declspec (dllexport)
1516#else // !GRAPHQL_DLLEXPORTS
1617 #define GRAPHQLRESPONSE_EXPORT
1718#endif // !GRAPHQL_DLLEXPORTS
19+ // clang-format on
1820
1921#include < memory>
2022#include < string>
@@ -28,15 +30,15 @@ namespace graphql::response {
2830// of the [June 2018 spec](https://facebook.github.io/graphql/June2018/#sec-Serialization-Format).
2931enum class Type : uint8_t
3032{
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
4042};
4143
4244struct Value ;
@@ -157,28 +159,36 @@ struct Value
157159 // Specialized for all single-value Types.
158160 template <typename ValueType>
159161 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);
161164
162165 // Specialized for all Types.
163166 template <typename ValueType>
164167 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 ;
166170
167171 // Specialized for all Types which allocate extra memory.
168172 template <typename ValueType>
169173 typename ValueTypeTraits<ValueType>::release_type release ();
170174
171175 // Compatibility wrappers
172176 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)
175180 {
176181 set<std::decay_t <ReferenceType>>(std::move (value));
177182 }
178183
179184 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
182192 {
183193 return get<std::decay_t <ReferenceType>>();
184194 }
@@ -190,22 +200,38 @@ struct Value
190200
191201#ifdef GRAPHQL_DLLEXPORTS
192202// 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>();
209235#endif // GRAPHQL_DLLEXPORTS
210236
211237} /* namespace graphql::response */
0 commit comments