55
66#include < boost/program_options.hpp>
77
8+ // clang-format off
9+ #ifdef USE_STD_FILESYSTEM
10+ #include < filesystem>
11+ namespace fs = std::filesystem;
12+ #else
13+ #ifdef USE_STD_EXPERIMENTAL_FILESYSTEM
14+ #include < experimental/filesystem>
15+ namespace fs = std::experimental::filesystem;
16+ #else
17+ #ifdef USE_BOOST_FILESYSTEM
18+ #include < boost/filesystem.hpp>
19+ namespace fs = boost::filesystem;
20+ #else
21+ #error "No std::filesystem implementation defined"
22+ #endif
23+ #endif
24+ #endif
25+ // clang-format on
26+
827#include < cctype>
9- #include < filesystem>
1028#include < fstream>
1129#include < iostream>
1230#include < regex>
@@ -297,11 +315,11 @@ std::string Generator::getHeaderDir() const noexcept
297315{
298316 if (_isIntrospection)
299317 {
300- return (std::filesystem ::path { " include" } / " graphqlservice" ).string ();
318+ return (fs ::path { " include" } / " graphqlservice" ).string ();
301319 }
302320 else if (_options.paths )
303321 {
304- return std::filesystem ::path { _options.paths ->headerPath }.string ();
322+ return fs ::path { _options.paths ->headerPath }.string ();
305323 }
306324 else
307325 {
@@ -317,13 +335,13 @@ std::string Generator::getSourceDir() const noexcept
317335 }
318336 else
319337 {
320- return std::filesystem ::path (_options.paths ->sourcePath ).string ();
338+ return fs ::path (_options.paths ->sourcePath ).string ();
321339 }
322340}
323341
324342std::string Generator::getHeaderPath () const noexcept
325343{
326- std::filesystem ::path fullPath { _headerDir };
344+ fs ::path fullPath { _headerDir };
327345
328346 if (_isIntrospection)
329347 {
@@ -341,7 +359,7 @@ std::string Generator::getObjectHeaderPath() const noexcept
341359{
342360 if (_options.separateFiles )
343361 {
344- std::filesystem ::path fullPath { _headerDir };
362+ fs ::path fullPath { _headerDir };
345363
346364 fullPath /= (_options.customSchema ->filenamePrefix + " Objects.h" );
347365 return fullPath.string ();
@@ -352,7 +370,7 @@ std::string Generator::getObjectHeaderPath() const noexcept
352370
353371std::string Generator::getSourcePath () const noexcept
354372{
355- std::filesystem ::path fullPath { _sourceDir };
373+ fs ::path fullPath { _sourceDir };
356374
357375 if (_isIntrospection)
358376 {
@@ -1659,8 +1677,7 @@ std::string Generator::getOutputCppType(const OutputField& field) const noexcept
16591677bool Generator::outputHeader () const noexcept
16601678{
16611679 std::ofstream headerFile (_headerPath, std::ios_base::trunc);
1662- IncludeGuardScope includeGuard { headerFile,
1663- std::filesystem::path (_headerPath).filename ().string () };
1680+ IncludeGuardScope includeGuard { headerFile, fs::path (_headerPath).filename ().string () };
16641681
16651682 headerFile << R"cpp( #include "graphqlservice/GraphQLService.h"
16661683
@@ -2042,8 +2059,8 @@ bool Generator::outputSource() const noexcept
20422059)cpp" ;
20432060 if (!_isIntrospection)
20442061 {
2045- sourceFile << R"cpp( #include ")cpp"
2046- << std::filesystem::path (_objectHeaderPath). filename (). string () << R"cpp( "
2062+ sourceFile << R"cpp( #include ")cpp" << fs::path (_objectHeaderPath). filename (). string ()
2063+ << R"cpp( "
20472064
20482065)cpp" ;
20492066 }
@@ -3421,8 +3438,8 @@ std::string Generator::getIntrospectionType(
34213438std::vector<std::string> Generator::outputSeparateFiles () const noexcept
34223439{
34233440 std::vector<std::string> files;
3424- const std::filesystem ::path headerDir (_headerDir);
3425- const std::filesystem ::path sourceDir (_sourceDir);
3441+ const fs ::path headerDir (_headerDir);
3442+ const fs ::path sourceDir (_sourceDir);
34263443 std::string queryType;
34273444
34283445 for (const auto & operation : _operationTypes)
@@ -3437,10 +3454,10 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34373454 // Output a convenience header
34383455 std::ofstream objectHeaderFile (_objectHeaderPath, std::ios_base::trunc);
34393456 IncludeGuardScope includeGuard { objectHeaderFile,
3440- std::filesystem ::path (_objectHeaderPath).filename ().string () };
3457+ fs ::path (_objectHeaderPath).filename ().string () };
34413458
3442- objectHeaderFile << R"cpp( #include ")cpp"
3443- << std::filesystem::path (_headerPath). filename (). string () << R"cpp( "
3459+ objectHeaderFile << R"cpp( #include ")cpp" << fs::path (_headerPath). filename (). string ()
3460+ << R"cpp( "
34443461
34453462)cpp" ;
34463463
@@ -3474,8 +3491,7 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34743491 std::ofstream headerFile (headerPath, std::ios_base::trunc);
34753492 IncludeGuardScope includeGuard { headerFile, headerFilename };
34763493
3477- headerFile << R"cpp( #include ")cpp"
3478- << std::filesystem::path (_headerPath).filename ().string () << R"cpp( "
3494+ headerFile << R"cpp( #include ")cpp" << fs::path (_headerPath).filename ().string () << R"cpp( "
34793495
34803496)cpp" ;
34813497
@@ -3498,7 +3514,7 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34983514 sourceFile << R"cpp( // Copyright (c) Microsoft Corporation. All rights reserved.
34993515// Licensed under the MIT License.
35003516
3501- #include ")cpp" << std::filesystem ::path (_objectHeaderPath).filename ().string ()
3517+ #include ")cpp" << fs ::path (_objectHeaderPath).filename ().string ()
35023518 << R"cpp( "
35033519
35043520#include "graphqlservice/Introspection.h"
0 commit comments