33
44#pragma once
55
6- #ifndef SCHEMAGENERATOR_H
7- #define SCHEMAGENERATOR_H
6+ #ifndef CLIENTGENERATOR_H
7+ #define CLIENTGENERATOR_H
88
99#include " graphqlservice/GraphQLGrammar.h"
1010#include " graphqlservice/GraphQLParse.h"
1515#include < unordered_map>
1616#include < unordered_set>
1717
18- namespace graphql ::schema {
18+ namespace graphql ::client {
1919
2020// These are the set of built-in types in GraphQL.
2121enum class BuiltinType
@@ -210,7 +210,7 @@ struct ObjectType
210210
211211using ObjectTypeList = std::vector<ObjectType>;
212212
213- // The schema maps operation types to named types.
213+ // The client maps operation types to named types.
214214struct OperationType
215215{
216216 std::string_view type;
@@ -220,11 +220,11 @@ struct OperationType
220220
221221using OperationTypeList = std::vector<OperationType>;
222222
223- struct GeneratorSchema
223+ struct GeneratorClient
224224{
225- const std::string schemaFilename ;
225+ const std::string clientFilename ;
226226 const std::string filenamePrefix;
227- const std::string schemaNamespace ;
227+ const std::string clientNamespace ;
228228};
229229
230230struct GeneratorPaths
@@ -235,63 +235,18 @@ struct GeneratorPaths
235235
236236struct GeneratorOptions
237237{
238- const std::optional<GeneratorSchema> customSchema ;
238+ const std::optional<GeneratorClient> customClient ;
239239 const std::optional<GeneratorPaths> paths;
240240 const bool verbose = false ;
241241 const bool separateFiles = false ;
242242 const bool noStubs = false ;
243243 const bool noIntrospection = false ;
244244};
245245
246- // RAII object to help with emitting matching include guard begin and end statements
247- class IncludeGuardScope
248- {
249- public:
250- explicit IncludeGuardScope (std::ostream& outputFile, std::string_view headerFileName) noexcept ;
251- ~IncludeGuardScope () noexcept ;
252-
253- private:
254- std::ostream& _outputFile;
255- std::string _includeGuardName;
256- };
257-
258- // RAII object to help with emitting matching namespace begin and end statements
259- class NamespaceScope
260- {
261- public:
262- explicit NamespaceScope (
263- std::ostream& outputFile, std::string_view cppNamespace, bool deferred = false ) noexcept ;
264- NamespaceScope (NamespaceScope&& other) noexcept ;
265- ~NamespaceScope () noexcept ;
266-
267- bool enter () noexcept ;
268- bool exit () noexcept ;
269-
270- private:
271- bool _inside = false ;
272- std::ostream& _outputFile;
273- std::string_view _cppNamespace;
274- };
275-
276- // Keep track of whether we want to add a blank separator line once some additional content is about
277- // to be output.
278- class PendingBlankLine
279- {
280- public:
281- explicit PendingBlankLine (std::ostream& outputFile) noexcept ;
282-
283- void add () noexcept ;
284- bool reset () noexcept ;
285-
286- private:
287- bool _pending = true ;
288- std::ostream& _outputFile;
289- };
290-
291246class Generator
292247{
293248public:
294- // Initialize the generator with the introspection schema or a custom GraphQL schema .
249+ // Initialize the generator with the introspection client or a custom GraphQL client .
295250 explicit Generator (GeneratorOptions&& options);
296251
297252 // Run the generator and return a list of filenames that were output.
@@ -306,8 +261,8 @@ class Generator
306261
307262 void visitDefinition (const peg::ast_node& definition);
308263
309- void visitSchemaDefinition (const peg::ast_node& schemaDefinition );
310- void visitSchemaExtension (const peg::ast_node& schemaExtension );
264+ void visitClientDefinition (const peg::ast_node& clientDefinition );
265+ void visitClientExtension (const peg::ast_node& clientExtension );
311266 void visitScalarTypeDefinition (const peg::ast_node& scalarTypeDefinition);
312267 void visitEnumTypeDefinition (const peg::ast_node& enumTypeDefinition);
313268 void visitEnumTypeExtension (const peg::ast_node& enumTypeExtension);
@@ -366,7 +321,7 @@ class Generator
366321 response::Value _value;
367322 };
368323
369- void validateSchema ();
324+ void validateClient ();
370325 void fixupOutputFieldList (OutputFieldList& fields,
371326 const std::optional<std::unordered_set<std::string_view>>& interfaceFields,
372327 const std::optional<std::string_view>& accessor);
@@ -407,15 +362,15 @@ class Generator
407362
408363 const GeneratorOptions _options;
409364 const bool _isIntrospection;
410- std::string_view _schemaNamespace ;
365+ std::string_view _clientNamespace ;
411366 const std::string _headerDir;
412367 const std::string _sourceDir;
413368 const std::string _headerPath;
414369 const std::string _objectHeaderPath;
415370 const std::string _sourcePath;
416371 peg::ast _ast;
417372
418- SchemaTypeMap _schemaTypes ;
373+ SchemaTypeMap _clientTypes ;
419374 PositionMap _typePositions;
420375 TypeNameMap _scalarNames;
421376 ScalarTypeList _scalarTypes;
@@ -434,6 +389,6 @@ class Generator
434389 OperationTypeList _operationTypes;
435390};
436391
437- } /* namespace graphql::schema */
392+ } /* namespace graphql::client */
438393
439- #endif // SCHEMAGENERATOR_H
394+ #endif // CLIENTGENERATOR_H
0 commit comments