55
66#include < boost/program_options.hpp>
77
8- #include < cctype>
8+ #ifdef USE_BOOST_FILESYSTEM
9+ #include < boost/filesystem.hpp>
10+ namespace fs = boost::filesystem;
11+ #else
912#include < filesystem>
13+ namespace fs = std::filesystem;
14+ #endif
15+
16+ #include < cctype>
1017#include < fstream>
1118#include < iostream>
1219#include < regex>
@@ -297,11 +304,11 @@ std::string Generator::getHeaderDir() const noexcept
297304{
298305 if (_isIntrospection)
299306 {
300- return (std::filesystem ::path { " include" } / " graphqlservice" ).string ();
307+ return (fs ::path { " include" } / " graphqlservice" ).string ();
301308 }
302309 else if (_options.paths )
303310 {
304- return std::filesystem ::path { _options.paths ->headerPath }.string ();
311+ return fs ::path { _options.paths ->headerPath }.string ();
305312 }
306313 else
307314 {
@@ -317,13 +324,13 @@ std::string Generator::getSourceDir() const noexcept
317324 }
318325 else
319326 {
320- return std::filesystem ::path (_options.paths ->sourcePath ).string ();
327+ return fs ::path (_options.paths ->sourcePath ).string ();
321328 }
322329}
323330
324331std::string Generator::getHeaderPath () const noexcept
325332{
326- std::filesystem ::path fullPath { _headerDir };
333+ fs ::path fullPath { _headerDir };
327334
328335 if (_isIntrospection)
329336 {
@@ -341,7 +348,7 @@ std::string Generator::getObjectHeaderPath() const noexcept
341348{
342349 if (_options.separateFiles )
343350 {
344- std::filesystem ::path fullPath { _headerDir };
351+ fs ::path fullPath { _headerDir };
345352
346353 fullPath /= (_options.customSchema ->filenamePrefix + " Objects.h" );
347354 return fullPath.string ();
@@ -352,7 +359,7 @@ std::string Generator::getObjectHeaderPath() const noexcept
352359
353360std::string Generator::getSourcePath () const noexcept
354361{
355- std::filesystem ::path fullPath { _sourceDir };
362+ fs ::path fullPath { _sourceDir };
356363
357364 if (_isIntrospection)
358365 {
@@ -1659,8 +1666,7 @@ std::string Generator::getOutputCppType(const OutputField& field) const noexcept
16591666bool Generator::outputHeader () const noexcept
16601667{
16611668 std::ofstream headerFile (_headerPath, std::ios_base::trunc);
1662- IncludeGuardScope includeGuard { headerFile,
1663- std::filesystem::path (_headerPath).filename ().string () };
1669+ IncludeGuardScope includeGuard { headerFile, fs::path (_headerPath).filename ().string () };
16641670
16651671 headerFile << R"cpp( #include "graphqlservice/GraphQLService.h"
16661672
@@ -2042,8 +2048,8 @@ bool Generator::outputSource() const noexcept
20422048)cpp" ;
20432049 if (!_isIntrospection)
20442050 {
2045- sourceFile << R"cpp( #include ")cpp"
2046- << std::filesystem::path (_objectHeaderPath). filename (). string () << R"cpp( "
2051+ sourceFile << R"cpp( #include ")cpp" << fs::path (_objectHeaderPath). filename (). string ()
2052+ << R"cpp( "
20472053
20482054)cpp" ;
20492055 }
@@ -3421,8 +3427,8 @@ std::string Generator::getIntrospectionType(
34213427std::vector<std::string> Generator::outputSeparateFiles () const noexcept
34223428{
34233429 std::vector<std::string> files;
3424- const std::filesystem ::path headerDir (_headerDir);
3425- const std::filesystem ::path sourceDir (_sourceDir);
3430+ const fs ::path headerDir (_headerDir);
3431+ const fs ::path sourceDir (_sourceDir);
34263432 std::string queryType;
34273433
34283434 for (const auto & operation : _operationTypes)
@@ -3437,10 +3443,10 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34373443 // Output a convenience header
34383444 std::ofstream objectHeaderFile (_objectHeaderPath, std::ios_base::trunc);
34393445 IncludeGuardScope includeGuard { objectHeaderFile,
3440- std::filesystem ::path (_objectHeaderPath).filename ().string () };
3446+ fs ::path (_objectHeaderPath).filename ().string () };
34413447
3442- objectHeaderFile << R"cpp( #include ")cpp"
3443- << std::filesystem::path (_headerPath). filename (). string () << R"cpp( "
3448+ objectHeaderFile << R"cpp( #include ")cpp" << fs::path (_headerPath). filename (). string ()
3449+ << R"cpp( "
34443450
34453451)cpp" ;
34463452
@@ -3474,8 +3480,7 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34743480 std::ofstream headerFile (headerPath, std::ios_base::trunc);
34753481 IncludeGuardScope includeGuard { headerFile, headerFilename };
34763482
3477- headerFile << R"cpp( #include ")cpp"
3478- << std::filesystem::path (_headerPath).filename ().string () << R"cpp( "
3483+ headerFile << R"cpp( #include ")cpp" << fs::path (_headerPath).filename ().string () << R"cpp( "
34793484
34803485)cpp" ;
34813486
@@ -3498,7 +3503,7 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34983503 sourceFile << R"cpp( // Copyright (c) Microsoft Corporation. All rights reserved.
34993504// Licensed under the MIT License.
35003505
3501- #include ")cpp" << std::filesystem ::path (_objectHeaderPath).filename ().string ()
3506+ #include ")cpp" << fs ::path (_objectHeaderPath).filename ().string ()
35023507 << R"cpp( "
35033508
35043509#include "graphqlservice/Introspection.h"
0 commit comments