@@ -73,6 +73,29 @@ bool NamespaceScope::exit() noexcept
7373}
7474
7575
76+ PendingBlankLine::PendingBlankLine (std::ostream& outputFile) noexcept
77+ : _outputFile(outputFile)
78+ {
79+ }
80+
81+ void PendingBlankLine::add () noexcept
82+ {
83+ _pending = true ;
84+ }
85+
86+ bool PendingBlankLine::reset () noexcept
87+ {
88+ if (_pending)
89+ {
90+ _outputFile << std::endl;
91+ _pending = false ;
92+ return true ;
93+ }
94+
95+ return false ;
96+ }
97+
98+
7699const std::string Generator::s_introspectionNamespace = " introspection" ;
77100
78101const BuiltinTypeMap Generator::s_builtinTypes = {
@@ -1507,6 +1530,7 @@ bool Generator::outputHeader() const noexcept
15071530 NamespaceScope introspectionNamespace{ headerFile, s_introspectionNamespace };
15081531 NamespaceScope schemaNamespace{ headerFile, _schemaNamespace, true };
15091532 NamespaceScope objectNamespace{ headerFile, " object" , true };
1533+ PendingBlankLine pendingSeparator{ headerFile };
15101534
15111535 headerFile << R"cpp(
15121536class Schema;
@@ -1536,11 +1560,13 @@ class Schema;
15361560 introspectionNamespace.exit ();
15371561 headerFile << std::endl;
15381562 schemaNamespace.enter ();
1539- headerFile << std::endl ;
1563+ pendingSeparator. add () ;
15401564 }
15411565
15421566 if (!_enumTypes.empty ())
15431567 {
1568+ pendingSeparator.reset ();
1569+
15441570 for (const auto & enumType : _enumTypes)
15451571 {
15461572 headerFile << R"cpp( enum class )cpp" << enumType.cppType << R"cpp(
@@ -1569,6 +1595,8 @@ class Schema;
15691595
15701596 if (!_inputTypes.empty ())
15711597 {
1598+ pendingSeparator.reset ();
1599+
15721600 // Forward declare all of the input types
15731601 if (_inputTypes.size () > 1 )
15741602 {
@@ -2006,8 +2034,7 @@ std::future<response::Value> ModifiedResult<)cpp" << _schemaNamespace << R"cpp(:
20062034
20072035 if (!inputType.fields .empty ())
20082036 {
2009- sourceFile << R"cpp(
2010- )cpp" ;
2037+ sourceFile << std::endl;
20112038 }
20122039
20132040 sourceFile << R"cpp( return {
@@ -2237,8 +2264,7 @@ Operations::Operations()cpp";
22372264
22382265 if (!_enumTypes.empty ())
22392266 {
2240- sourceFile << R"cpp(
2241- )cpp" ;
2267+ sourceFile << std::endl;
22422268
22432269 for (const auto & enumType : _enumTypes)
22442270 {
@@ -2286,8 +2312,7 @@ Operations::Operations()cpp";
22862312
22872313 if (!_inputTypes.empty ())
22882314 {
2289- sourceFile << R"cpp(
2290- )cpp" ;
2315+ sourceFile << std::endl;
22912316
22922317 for (const auto & inputType : _inputTypes)
22932318 {
@@ -2324,8 +2349,7 @@ Operations::Operations()cpp";
23242349
23252350 if (!_unionTypes.empty ())
23262351 {
2327- sourceFile << R"cpp(
2328- )cpp" ;
2352+ sourceFile << std::endl;
23292353
23302354 for (const auto & unionType : _unionTypes)
23312355 {
@@ -2359,8 +2383,7 @@ Operations::Operations()cpp";
23592383
23602384 if (!_interfaceTypes.empty ())
23612385 {
2362- sourceFile << R"cpp(
2363- )cpp" ;
2386+ sourceFile << std::endl;
23642387
23652388 for (const auto & interfaceType : _interfaceTypes)
23662389 {
@@ -2438,8 +2461,7 @@ Operations::Operations()cpp";
24382461
24392462 if (!_objectTypes.empty ())
24402463 {
2441- sourceFile << R"cpp(
2442- )cpp" ;
2464+ sourceFile << std::endl;
24432465
24442466 for (const auto & objectType : _objectTypes)
24452467 {
@@ -2459,8 +2481,7 @@ Operations::Operations()cpp";
24592481
24602482 if (!_directives.empty ())
24612483 {
2462- sourceFile << R"cpp(
2463- )cpp" ;
2484+ sourceFile << std::endl;
24642485
24652486 for (const auto & directive : _directives)
24662487 {
@@ -2530,8 +2551,7 @@ Operations::Operations()cpp";
25302551
25312552 if (!_operationTypes.empty ())
25322553 {
2533- sourceFile << R"cpp(
2534- )cpp" ;
2554+ sourceFile << std::endl;
25352555
25362556 for (const auto & operationType : _operationTypes)
25372557 {
0 commit comments