|
6 | 6 | #ifndef GRAPHQLRESPONSE_H
|
7 | 7 | #define GRAPHQLRESPONSE_H
|
8 | 8 |
|
| 9 | +#ifdef GRAPHQL_DLLEXPORTS |
| 10 | + #ifdef IMPL_GRAPHQLRESPONSE_DLL |
| 11 | + #define GRAPHQLRESPONSE_EXPORT __declspec(dllexport) |
| 12 | + #else // !IMPL_GRAPHQLRESPONSE_DLL |
| 13 | + #define GRAPHQLRESPONSE_EXPORT __declspec(dllimport) |
| 14 | + #endif // !IMPL_GRAPHQLRESPONSE_DLL |
| 15 | +#else // !GRAPHQL_DLLEXPORTS |
| 16 | + #define GRAPHQLRESPONSE_EXPORT |
| 17 | +#endif // !GRAPHQL_DLLEXPORTS |
| 18 | + |
9 | 19 | #include <memory>
|
10 | 20 | #include <string>
|
11 | 21 | #include <vector>
|
@@ -102,47 +112,47 @@ struct TypedData;
|
102 | 112 | // Represent a discriminated union of GraphQL response value types.
|
103 | 113 | struct Value
|
104 | 114 | {
|
105 |
| - Value(Type type = Type::Null); |
106 |
| - ~Value(); |
| 115 | + GRAPHQLRESPONSE_EXPORT Value(Type type = Type::Null); |
| 116 | + GRAPHQLRESPONSE_EXPORT ~Value(); |
107 | 117 |
|
108 |
| - explicit Value(const char* value); |
109 |
| - explicit Value(StringType&& value); |
110 |
| - explicit Value(BooleanType value); |
111 |
| - explicit Value(IntType value); |
112 |
| - explicit Value(FloatType value); |
| 118 | + GRAPHQLRESPONSE_EXPORT explicit Value(const char* value); |
| 119 | + GRAPHQLRESPONSE_EXPORT explicit Value(StringType&& value); |
| 120 | + GRAPHQLRESPONSE_EXPORT explicit Value(BooleanType value); |
| 121 | + GRAPHQLRESPONSE_EXPORT explicit Value(IntType value); |
| 122 | + GRAPHQLRESPONSE_EXPORT explicit Value(FloatType value); |
113 | 123 |
|
114 |
| - Value(Value&& other) noexcept; |
115 |
| - explicit Value(const Value& other); |
| 124 | + GRAPHQLRESPONSE_EXPORT Value(Value&& other) noexcept; |
| 125 | + GRAPHQLRESPONSE_EXPORT explicit Value(const Value& other); |
116 | 126 |
|
117 |
| - Value& operator=(Value&& rhs) noexcept; |
118 |
| - Value& operator=(const Value& rhs) = delete; |
| 127 | + GRAPHQLRESPONSE_EXPORT Value& operator=(Value&& rhs) noexcept; |
| 128 | + GRAPHQLRESPONSE_EXPORT Value& operator=(const Value& rhs) = delete; |
119 | 129 |
|
120 | 130 | // Comparison
|
121 |
| - bool operator==(const Value& rhs) const noexcept; |
122 |
| - bool operator!=(const Value& rhs) const noexcept; |
| 131 | + GRAPHQLRESPONSE_EXPORT bool operator==(const Value& rhs) const noexcept; |
| 132 | + GRAPHQLRESPONSE_EXPORT bool operator!=(const Value& rhs) const noexcept; |
123 | 133 |
|
124 | 134 | // Check the Type
|
125 |
| - Type type() const noexcept; |
| 135 | + GRAPHQLRESPONSE_EXPORT Type type() const noexcept; |
126 | 136 |
|
127 | 137 | // JSON doesn't distinguish between Type::String and Type::EnumValue, so if this value comes
|
128 | 138 | // from JSON and it's a string we need to track the fact that it can be interpreted as either.
|
129 |
| - Value&& from_json() noexcept; |
130 |
| - bool maybe_enum() const noexcept; |
| 139 | + GRAPHQLRESPONSE_EXPORT Value&& from_json() noexcept; |
| 140 | + GRAPHQLRESPONSE_EXPORT bool maybe_enum() const noexcept; |
131 | 141 |
|
132 | 142 | // Valid for Type::Map or Type::List
|
133 |
| - void reserve(size_t count); |
134 |
| - size_t size() const; |
| 143 | + GRAPHQLRESPONSE_EXPORT void reserve(size_t count); |
| 144 | + GRAPHQLRESPONSE_EXPORT size_t size() const; |
135 | 145 |
|
136 | 146 | // Valid for Type::Map
|
137 |
| - void emplace_back(std::string&& name, Value&& value); |
138 |
| - MapType::const_iterator find(const std::string& name) const; |
139 |
| - MapType::const_iterator begin() const; |
140 |
| - MapType::const_iterator end() const; |
141 |
| - const Value& operator[](const std::string& name) const; |
| 147 | + GRAPHQLRESPONSE_EXPORT void emplace_back(std::string&& name, Value&& value); |
| 148 | + GRAPHQLRESPONSE_EXPORT MapType::const_iterator find(const std::string& name) const; |
| 149 | + GRAPHQLRESPONSE_EXPORT MapType::const_iterator begin() const; |
| 150 | + GRAPHQLRESPONSE_EXPORT MapType::const_iterator end() const; |
| 151 | + GRAPHQLRESPONSE_EXPORT const Value& operator[](const std::string& name) const; |
142 | 152 |
|
143 | 153 | // Valid for Type::List
|
144 |
| - void emplace_back(Value&& value); |
145 |
| - const Value& operator[](size_t index) const; |
| 154 | + GRAPHQLRESPONSE_EXPORT void emplace_back(Value&& value); |
| 155 | + GRAPHQLRESPONSE_EXPORT const Value& operator[](size_t index) const; |
146 | 156 |
|
147 | 157 | // Specialized for all single-value Types.
|
148 | 158 | template <typename ValueType>
|
@@ -178,6 +188,26 @@ struct Value
|
178 | 188 | std::unique_ptr<TypedData> _data;
|
179 | 189 | };
|
180 | 190 |
|
| 191 | +#ifdef GRAPHQL_DLLEXPORTS |
| 192 | +// 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>(); |
| 209 | +#endif // GRAPHQL_DLLEXPORTS |
| 210 | + |
181 | 211 | } /* namespace graphql::response */
|
182 | 212 |
|
183 | 213 | #endif // GRAPHQLRESPONSE_H
|
0 commit comments