@@ -73,6 +73,29 @@ bool NamespaceScope::exit() noexcept
73
73
}
74
74
75
75
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
+
76
99
const std::string Generator::s_introspectionNamespace = " introspection" ;
77
100
78
101
const BuiltinTypeMap Generator::s_builtinTypes = {
@@ -1507,6 +1530,7 @@ bool Generator::outputHeader() const noexcept
1507
1530
NamespaceScope introspectionNamespace{ headerFile, s_introspectionNamespace };
1508
1531
NamespaceScope schemaNamespace{ headerFile, _schemaNamespace, true };
1509
1532
NamespaceScope objectNamespace{ headerFile, " object" , true };
1533
+ PendingBlankLine pendingSeparator{ headerFile };
1510
1534
1511
1535
headerFile << R"cpp(
1512
1536
class Schema;
@@ -1536,11 +1560,13 @@ class Schema;
1536
1560
introspectionNamespace.exit ();
1537
1561
headerFile << std::endl;
1538
1562
schemaNamespace.enter ();
1539
- headerFile << std::endl ;
1563
+ pendingSeparator. add () ;
1540
1564
}
1541
1565
1542
1566
if (!_enumTypes.empty ())
1543
1567
{
1568
+ pendingSeparator.reset ();
1569
+
1544
1570
for (const auto & enumType : _enumTypes)
1545
1571
{
1546
1572
headerFile << R"cpp( enum class )cpp" << enumType.cppType << R"cpp(
@@ -1569,6 +1595,8 @@ class Schema;
1569
1595
1570
1596
if (!_inputTypes.empty ())
1571
1597
{
1598
+ pendingSeparator.reset ();
1599
+
1572
1600
// Forward declare all of the input types
1573
1601
if (_inputTypes.size () > 1 )
1574
1602
{
@@ -2006,8 +2034,7 @@ std::future<response::Value> ModifiedResult<)cpp" << _schemaNamespace << R"cpp(:
2006
2034
2007
2035
if (!inputType.fields .empty ())
2008
2036
{
2009
- sourceFile << R"cpp(
2010
- )cpp" ;
2037
+ sourceFile << std::endl;
2011
2038
}
2012
2039
2013
2040
sourceFile << R"cpp( return {
@@ -2237,8 +2264,7 @@ Operations::Operations()cpp";
2237
2264
2238
2265
if (!_enumTypes.empty ())
2239
2266
{
2240
- sourceFile << R"cpp(
2241
- )cpp" ;
2267
+ sourceFile << std::endl;
2242
2268
2243
2269
for (const auto & enumType : _enumTypes)
2244
2270
{
@@ -2286,8 +2312,7 @@ Operations::Operations()cpp";
2286
2312
2287
2313
if (!_inputTypes.empty ())
2288
2314
{
2289
- sourceFile << R"cpp(
2290
- )cpp" ;
2315
+ sourceFile << std::endl;
2291
2316
2292
2317
for (const auto & inputType : _inputTypes)
2293
2318
{
@@ -2324,8 +2349,7 @@ Operations::Operations()cpp";
2324
2349
2325
2350
if (!_unionTypes.empty ())
2326
2351
{
2327
- sourceFile << R"cpp(
2328
- )cpp" ;
2352
+ sourceFile << std::endl;
2329
2353
2330
2354
for (const auto & unionType : _unionTypes)
2331
2355
{
@@ -2359,8 +2383,7 @@ Operations::Operations()cpp";
2359
2383
2360
2384
if (!_interfaceTypes.empty ())
2361
2385
{
2362
- sourceFile << R"cpp(
2363
- )cpp" ;
2386
+ sourceFile << std::endl;
2364
2387
2365
2388
for (const auto & interfaceType : _interfaceTypes)
2366
2389
{
@@ -2438,8 +2461,7 @@ Operations::Operations()cpp";
2438
2461
2439
2462
if (!_objectTypes.empty ())
2440
2463
{
2441
- sourceFile << R"cpp(
2442
- )cpp" ;
2464
+ sourceFile << std::endl;
2443
2465
2444
2466
for (const auto & objectType : _objectTypes)
2445
2467
{
@@ -2459,8 +2481,7 @@ Operations::Operations()cpp";
2459
2481
2460
2482
if (!_directives.empty ())
2461
2483
{
2462
- sourceFile << R"cpp(
2463
- )cpp" ;
2484
+ sourceFile << std::endl;
2464
2485
2465
2486
for (const auto & directive : _directives)
2466
2487
{
@@ -2530,8 +2551,7 @@ Operations::Operations()cpp";
2530
2551
2531
2552
if (!_operationTypes.empty ())
2532
2553
{
2533
- sourceFile << R"cpp(
2534
- )cpp" ;
2554
+ sourceFile << std::endl;
2535
2555
2536
2556
for (const auto & operationType : _operationTypes)
2537
2557
{
0 commit comments