Skip to content

Commit b84b530

Browse files
committed
Add include guards as backup for pragma once
1 parent 6418e4e commit b84b530

28 files changed

+186
-18
lines changed

include/SchemaGenerator.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef SCHEMAGENERATOR_H
7+
#define SCHEMAGENERATOR_H
8+
69
#include <graphqlservice/GraphQLService.h>
710
#include <graphqlservice/GraphQLGrammar.h>
811

@@ -235,6 +238,18 @@ struct GeneratorOptions
235238
const bool noStubs = false;
236239
};
237240

241+
// RAII object to help with emitting matching include guard begin and end statements
242+
class IncludeGuardScope
243+
{
244+
public:
245+
explicit IncludeGuardScope(std::ostream& outputFile, std::string_view headerFileName) noexcept;
246+
~IncludeGuardScope() noexcept;
247+
248+
private:
249+
std::ostream& _outputFile;
250+
std::string _includeGuardName;
251+
};
252+
238253
// RAII object to help with emitting matching namespace begin and end statements
239254
class NamespaceScope
240255
{
@@ -399,3 +414,5 @@ class Generator
399414
};
400415

401416
} /* namespace graphql::schema */
417+
418+
#endif // SCHEMAGENERATOR_H

include/graphqlservice/GraphQLGrammar.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#pragma once
88

9+
#ifndef GRAPHQLGRAMMAR_H
10+
#define GRAPHQLGRAMMAR_H
11+
912
#include <graphqlservice/GraphQLTree.h>
1013

1114
#define TAO_PEGTL_NAMESPACE tao::graphqlpeg
@@ -1316,3 +1319,5 @@ struct document
13161319
};
13171320

13181321
} /* namespace graphql::peg */
1322+
1323+
#endif // GRAPHQLGRAMMAR_H

include/graphqlservice/GraphQLParse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef GRAPHQLPARSE_H
7+
#define GRAPHQLPARSE_H
8+
69
#include <memory>
710
#include <string_view>
811

@@ -26,3 +29,5 @@ ast parseFile(std::string_view filename);
2629
peg::ast operator "" _graphql(const char* text, size_t size);
2730

2831
} /* namespace graphql */
32+
33+
#endif // GRAPHQLPARSE_H

include/graphqlservice/GraphQLResponse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef GRAPHQLRESPONSE_H
7+
#define GRAPHQLRESPONSE_H
8+
69
#include <memory>
710
#include <string>
811
#include <vector>
@@ -176,3 +179,5 @@ struct Value
176179
};
177180

178181
} /* namespace graphql::response */
182+
183+
#endif // GRAPHQLRESPONSE_H

include/graphqlservice/GraphQLService.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef GRAPHQLSERVICE_H
7+
#define GRAPHQLSERVICE_H
8+
69
#include <graphqlservice/GraphQLParse.h>
710
#include <graphqlservice/GraphQLResponse.h>
811

@@ -736,3 +739,5 @@ class Request : public std::enable_shared_from_this<Request>
736739
};
737740

738741
} /* namespace graphql::service */
742+
743+
#endif // GRAPHQLSERVICE_H

include/graphqlservice/GraphQLTree.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef GRAPHQLTREE_H
7+
#define GRAPHQLTREE_H
8+
69
#define TAO_PEGTL_NAMESPACE tao::graphqlpeg
710

811
#include <tao/pegtl.hpp>
@@ -27,3 +30,5 @@ struct ast_input
2730
};
2831

2932
} /* namespace graphql::peg */
33+
34+
#endif // GRAPHQLTREE_H

include/graphqlservice/Introspection.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef INTROSPECTION_H
7+
#define INTROSPECTION_H
8+
69
#include <graphqlservice/IntrospectionSchema.h>
710

811
namespace graphql::introspection {
@@ -273,3 +276,5 @@ class Directive : public object::Directive
273276
};
274277

275278
} /* namespace graphql::introspection */
279+
280+
#endif // INTROSPECTION_H

include/graphqlservice/JSONResponse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef JSONRESPONSE_H
7+
#define JSONRESPONSE_H
8+
69
#include <graphqlservice/GraphQLResponse.h>
710

811
namespace graphql::response {
@@ -12,3 +15,5 @@ std::string toJSON(Value&& response);
1215
Value parseJSON(const std::string& json);
1316

1417
} /* namespace graphql::response */
18+
19+
#endif // JSONRESPONSE_H

samples/introspection/IntrospectionSchema.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef INTROSPECTIONSCHEMA_H
7+
#define INTROSPECTIONSCHEMA_H
8+
69
#include <graphqlservice/GraphQLService.h>
710

811
#include <memory>
@@ -205,3 +208,5 @@ void AddTypesToSchema(std::shared_ptr<introspection::Schema> schema);
205208

206209
} /* namespace introspection */
207210
} /* namespace graphql */
211+
212+
#endif // INTROSPECTIONSCHEMA_H

samples/separate/AppointmentConnectionObject.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#ifndef APPOINTMENTCONNECTIONOBJECT_H
7+
#define APPOINTMENTCONNECTIONOBJECT_H
8+
69
#include "TodaySchema.h"
710

811
namespace graphql::today::object {
@@ -25,3 +28,5 @@ class AppointmentConnection
2528
};
2629

2730
} /* namespace graphql::today::object */
31+
32+
#endif // APPOINTMENTCONNECTIONOBJECT_H

0 commit comments

Comments
 (0)