Skip to content

Commit 57faadb

Browse files
authored
Merge pull request #264 from ursfassler/more-std-c++
Using C++ standard library where possible instead of boost
2 parents c7ad59e + d4b943f commit 57faadb

35 files changed

+227
-299
lines changed

.clang-format

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ BreakBeforeBinaryOperators: All
1010
BreakBeforeBraces: Attach
1111
ColumnLimit: 100
1212
ConstructorInitializerAllOnOneLineOrOnePerLine: true
13-
ForEachMacros: [ BOOST_FOREACH ]
1413
IncludeCategories:
1514
# The autodetect header should always be included last
1615
- Regex: '^<cucumber-cpp/autodetect\.hpp>$'

.github/workflows/run-all.yml

-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ jobs:
2222
g++ \
2323
gcovr \
2424
git \
25-
libboost-date-time-dev \
26-
libboost-filesystem-dev \
2725
libboost-program-options-dev \
2826
libboost-regex-dev \
2927
libboost-system-dev \
3028
libboost-test-dev \
31-
libboost-thread-dev \
3229
make \
3330
ninja-build \
3431
qtbase5-dev \

CMakeLists.txt

+4-26
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ set(GMOCK_SRC_DIR "" CACHE STRING "Google Mock framework sources path (otherwise
3030
set(GMOCK_VER "1.11.0" CACHE STRING "Google Mock framework version to be used")
3131

3232
if(NOT DEFINED CMAKE_CXX_STANDARD)
33-
set(CMAKE_CXX_STANDARD 14)
33+
set(CMAKE_CXX_STANDARD 17)
3434
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3535
set(CMAKE_CXX_EXTENSIONS OFF)
36-
elseif(CMAKE_CXX_STANDARD LESS 14)
37-
message(FATAL_ERROR "C++14 (above) is required")
36+
elseif(CMAKE_CXX_STANDARD LESS 17)
37+
message(FATAL_ERROR "C++17 (above) is required")
3838
endif()
3939

4040
if(CUKE_CODE_COVERAGE)
@@ -122,7 +122,7 @@ else()
122122
endif()
123123

124124
set(Boost_USE_STATIC_RUNTIME OFF)
125-
set(CUKE_CORE_BOOST_LIBS thread system regex date_time program_options filesystem)
125+
set(CUKE_CORE_BOOST_LIBS system regex program_options)
126126
if(CUKE_ENABLE_BOOST_TEST)
127127
# "An external test runner utility is required to link with dynamic library" (Boost User's Guide)
128128
set(Boost_USE_STATIC_LIBS OFF)
@@ -151,14 +151,6 @@ if(Boost_INCLUDE_DIRS AND NOT TARGET Boost::boost)
151151
set_target_properties(Boost::boost PROPERTIES
152152
"INTERFACE_INCLUDE_DIRECTORIES" "${Boost_INCLUDE_DIRS}")
153153
endif()
154-
if(Boost_THREAD_LIBRARY AND NOT TARGET Boost::thread)
155-
find_package(Threads REQUIRED)
156-
add_library(Boost::thread ${LIBRARY_TYPE} IMPORTED)
157-
set_target_properties(Boost::thread PROPERTIES
158-
"IMPORTED_LOCATION" "${Boost_THREAD_LIBRARY}"
159-
"INTERFACE_LINK_LIBRARIES" "Threads::Threads;Boost::boost"
160-
)
161-
endif()
162154
if(Boost_SYSTEM_LIBRARY AND NOT TARGET Boost::system)
163155
add_library(Boost::system ${LIBRARY_TYPE} IMPORTED)
164156
set_target_properties(Boost::system PROPERTIES
@@ -171,27 +163,13 @@ if(Boost_SYSTEM_LIBRARY AND NOT TARGET Boost::system)
171163
)
172164
endif()
173165
endif()
174-
if(Boost_FILESYSTEM_LIBRARY AND NOT TARGET Boost::filesystem)
175-
add_library(Boost::filesystem ${LIBRARY_TYPE} IMPORTED)
176-
set_target_properties(Boost::filesystem PROPERTIES
177-
"IMPORTED_LOCATION" "${Boost_FILESYSTEM_LIBRARY}"
178-
"INTERFACE_LINK_LIBRARIES" "Boost::system;Boost::boost"
179-
)
180-
endif()
181166
if(Boost_REGEX_LIBRARY AND NOT TARGET Boost::regex)
182167
add_library(Boost::regex ${LIBRARY_TYPE} IMPORTED)
183168
set_target_properties(Boost::regex PROPERTIES
184169
"IMPORTED_LOCATION" "${Boost_REGEX_LIBRARY}"
185170
"INTERFACE_LINK_LIBRARIES" "Boost::boost"
186171
)
187172
endif()
188-
if(Boost_DATE_TIME_LIBRARY AND NOT TARGET Boost::date_time)
189-
add_library(Boost::date_time ${LIBRARY_TYPE} IMPORTED)
190-
set_target_properties(Boost::date_time PROPERTIES
191-
"IMPORTED_LOCATION" "${Boost_DATE_TIME_LIBRARY}"
192-
"INTERFACE_LINK_LIBRARIES" "Boost::boost"
193-
)
194-
endif()
195173
if(Boost_PROGRAM_OPTIONS_LIBRARY AND NOT TARGET Boost::program_options)
196174
add_library(Boost::program_options ${LIBRARY_TYPE} IMPORTED)
197175
set_target_properties(Boost::program_options PROPERTIES

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ It relies on a few executables:
2525
It relies on a few libraries:
2626

2727
* [Boost](http://www.boost.org/) 1.46 or later (1.51+ on Windows).
28-
Required libraries: *thread*, *system*, *regex*, *date_time* and *program_options*.
28+
Required libraries: *system*, *regex* and *program_options*.
2929
Optional library for Boost Test driver: *test*.
3030
* [GTest](http://code.google.com/p/googletest/) 1.6 or later.
3131
Optional for the GTest driver. By default downloaded and built by CMake.

include/cucumber-cpp/internal/ContextManager.hpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,28 @@
55

66
#include <vector>
77

8-
#include <boost/make_shared.hpp>
9-
#include <boost/shared_ptr.hpp>
10-
#include <boost/weak_ptr.hpp>
8+
#include <memory>
119

1210
namespace cucumber {
1311

1412
namespace internal {
1513

16-
typedef std::vector<boost::shared_ptr<void> > contexts_type;
14+
typedef std::vector<std::shared_ptr<void> > contexts_type;
1715

1816
class CUCUMBER_CPP_EXPORT ContextManager {
1917
public:
2018
void purgeContexts();
21-
template<class T> boost::weak_ptr<T> addContext();
19+
template<class T> std::weak_ptr<T> addContext();
2220

2321
protected:
2422
static contexts_type contexts;
2523
};
2624

2725
template<class T>
28-
boost::weak_ptr<T> ContextManager::addContext() {
29-
boost::shared_ptr<T> shared(boost::make_shared<T>());
26+
std::weak_ptr<T> ContextManager::addContext() {
27+
std::shared_ptr<T> shared(std::make_shared<T>());
3028
contexts.push_back(shared);
31-
return boost::weak_ptr<T> (shared);
29+
return std::weak_ptr<T> (shared);
3230
}
3331

3432
}
@@ -44,12 +42,12 @@ class ScenarioScope {
4442

4543
private:
4644
internal::ContextManager contextManager;
47-
boost::shared_ptr<T> context;
48-
static boost::weak_ptr<T> contextReference;
45+
std::shared_ptr<T> context;
46+
static std::weak_ptr<T> contextReference;
4947
};
5048

5149
template<class T>
52-
boost::weak_ptr<T> ScenarioScope<T>::contextReference;
50+
std::weak_ptr<T> ScenarioScope<T>::contextReference;
5351

5452
template<class T>
5553
ScenarioScope<T>::ScenarioScope() {

include/cucumber-cpp/internal/CukeCommands.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
#include <string>
1212
#include <sstream>
1313

14-
#include <boost/shared_ptr.hpp>
14+
#include <memory>
1515

1616
namespace cucumber {
1717
namespace internal {
1818

19-
using boost::shared_ptr;
20-
2119
/**
2220
* Legacy class to be removed when feature #31 is complete, substituted by CukeEngineImpl.
2321
*/
@@ -41,7 +39,7 @@ class CUCUMBER_CPP_EXPORT CukeCommands {
4139
bool hasStarted;
4240

4341
private:
44-
static shared_ptr<Scenario> currentScenario;
42+
static std::shared_ptr<Scenario> currentScenario;
4543
};
4644

4745
}

include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "ProtocolHandler.hpp"
66
#include "../../CukeEngine.hpp"
77

8-
#include <boost/shared_ptr.hpp>
8+
#include <memory>
99

1010
namespace cucumber {
1111
namespace internal {
@@ -102,7 +102,7 @@ class CUCUMBER_CPP_EXPORT WireCommand {
102102
*
103103
* @return The command response (ownership passed to the caller)
104104
*/
105-
virtual boost::shared_ptr<WireResponse> run(CukeEngine& engine) const = 0;
105+
virtual std::shared_ptr<WireResponse> run(CukeEngine& engine) const = 0;
106106

107107
virtual ~WireCommand() {};
108108
};
@@ -136,7 +136,7 @@ class CUCUMBER_CPP_EXPORT WireMessageCodec {
136136
*
137137
* @throws WireMessageCodecException
138138
*/
139-
virtual boost::shared_ptr<WireCommand> decode(const std::string &request) const = 0;
139+
virtual std::shared_ptr<WireCommand> decode(const std::string &request) const = 0;
140140

141141
/**
142142
* Encodes a response to wire format.
@@ -156,7 +156,7 @@ class CUCUMBER_CPP_EXPORT WireMessageCodec {
156156
class CUCUMBER_CPP_EXPORT JsonSpiritWireMessageCodec : public WireMessageCodec {
157157
public:
158158
JsonSpiritWireMessageCodec();
159-
boost::shared_ptr<WireCommand> decode(const std::string &request) const;
159+
std::shared_ptr<WireCommand> decode(const std::string &request) const;
160160
const std::string encode(const WireResponse& response) const;
161161
};
162162

include/cucumber-cpp/internal/connectors/wire/WireProtocolCommands.hpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define CUKE_WIREPROTOCOL_COMMANDS_HPP_
33

44
#include "WireProtocol.hpp"
5-
#include <boost/shared_ptr.hpp>
5+
#include <memory>
66

77
namespace cucumber {
88
namespace internal {
@@ -19,15 +19,15 @@ class BeginScenarioCommand : public ScenarioCommand {
1919
public:
2020
BeginScenarioCommand(const CukeEngine::tags_type& tags);
2121

22-
boost::shared_ptr<WireResponse> run(CukeEngine& engine) const;
22+
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
2323
};
2424

2525

2626
class EndScenarioCommand : public ScenarioCommand {
2727
public:
2828
EndScenarioCommand(const CukeEngine::tags_type& tags);
2929

30-
boost::shared_ptr<WireResponse> run(CukeEngine& engine) const;
30+
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
3131
};
3232

3333

@@ -38,7 +38,7 @@ class StepMatchesCommand : public WireCommand {
3838
public:
3939
StepMatchesCommand(const std::string & stepName);
4040

41-
boost::shared_ptr<WireResponse> run(CukeEngine& engine) const;
41+
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
4242
};
4343

4444

@@ -53,7 +53,7 @@ class InvokeCommand : public WireCommand {
5353
const CukeEngine::invoke_args_type& args,
5454
const CukeEngine::invoke_table_type& tableArg);
5555

56-
boost::shared_ptr<WireResponse> run(CukeEngine& engine) const;
56+
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
5757
};
5858

5959

@@ -66,13 +66,13 @@ class SnippetTextCommand : public WireCommand {
6666
const std::string & name,
6767
const std::string & multilineArgClass);
6868

69-
boost::shared_ptr<WireResponse> run(CukeEngine& engine) const;
69+
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
7070
};
7171

7272

7373
class FailingCommand : public WireCommand {
7474
public:
75-
boost::shared_ptr<WireResponse> run(CukeEngine& engine) const;
75+
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
7676
};
7777

7878
}

include/cucumber-cpp/internal/hook/HookRegistrar.hpp

+15-16
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#include "../step/StepManager.hpp"
88

99
#include <boost/config.hpp>
10-
#include <boost/make_shared.hpp>
11-
#include <boost/shared_ptr.hpp>
10+
#include <memory>
1211

1312
#include <list>
1413

@@ -64,25 +63,25 @@ class CUCUMBER_CPP_EXPORT AfterAllHook : public UnconditionalHook {};
6463

6564
class CUCUMBER_CPP_EXPORT HookRegistrar {
6665
public:
67-
typedef std::list< boost::shared_ptr<Hook> > hook_list_type;
68-
typedef std::list< boost::shared_ptr<AroundStepHook> > aroundhook_list_type;
66+
typedef std::list< std::shared_ptr<Hook> > hook_list_type;
67+
typedef std::list< std::shared_ptr<AroundStepHook> > aroundhook_list_type;
6968

70-
static void addBeforeHook(boost::shared_ptr<BeforeHook> afterHook);
69+
static void addBeforeHook(std::shared_ptr<BeforeHook> afterHook);
7170
static void execBeforeHooks(Scenario *scenario);
7271

73-
static void addAroundStepHook(boost::shared_ptr<AroundStepHook> aroundStepHook);
72+
static void addAroundStepHook(std::shared_ptr<AroundStepHook> aroundStepHook);
7473
static InvokeResult execStepChain(Scenario *scenario, const StepInfo* stepInfo, const InvokeArgs *pArgs);
7574

76-
static void addAfterStepHook(boost::shared_ptr<AfterStepHook> afterStepHook);
75+
static void addAfterStepHook(std::shared_ptr<AfterStepHook> afterStepHook);
7776
static void execAfterStepHooks(Scenario *scenario);
7877

79-
static void addAfterHook(boost::shared_ptr<AfterHook> afterHook);
78+
static void addAfterHook(std::shared_ptr<AfterHook> afterHook);
8079
static void execAfterHooks(Scenario *scenario);
8180

82-
static void addBeforeAllHook(boost::shared_ptr<BeforeAllHook> beforeAllHook);
81+
static void addBeforeAllHook(std::shared_ptr<BeforeAllHook> beforeAllHook);
8382
static void execBeforeAllHooks();
8483

85-
static void addAfterAllHook(boost::shared_ptr<AfterAllHook> afterAllHook);
84+
static void addAfterAllHook(std::shared_ptr<AfterAllHook> afterAllHook);
8685
static void execAfterAllHooks();
8786

8887
private:
@@ -133,45 +132,45 @@ class CUCUMBER_CPP_EXPORT CallableStepChain : public CallableStep {
133132

134133
template<class T>
135134
static int registerBeforeHook(const std::string &csvTagNotation) {
136-
boost::shared_ptr<T> hook(boost::make_shared<T>());
135+
std::shared_ptr<T> hook(std::make_shared<T>());
137136
hook->setTags(csvTagNotation);
138137
HookRegistrar::addBeforeHook(hook);
139138
return 0; // We are not interested in the ID at this time
140139
}
141140

142141
template<class T>
143142
static int registerAroundStepHook(const std::string &csvTagNotation) {
144-
boost::shared_ptr<T> hook(boost::make_shared<T>());
143+
std::shared_ptr<T> hook(std::make_shared<T>());
145144
hook->setTags(csvTagNotation);
146145
HookRegistrar::addAroundStepHook(hook);
147146
return 0;
148147
}
149148

150149
template<class T>
151150
static int registerAfterStepHook(const std::string &csvTagNotation) {
152-
boost::shared_ptr<T> hook(boost::make_shared<T>());
151+
std::shared_ptr<T> hook(std::make_shared<T>());
153152
hook->setTags(csvTagNotation);
154153
HookRegistrar::addAfterStepHook(hook);
155154
return 0;
156155
}
157156

158157
template<class T>
159158
static int registerAfterHook(const std::string &csvTagNotation) {
160-
boost::shared_ptr<T> hook(boost::make_shared<T>());
159+
std::shared_ptr<T> hook(std::make_shared<T>());
161160
hook->setTags(csvTagNotation);
162161
HookRegistrar::addAfterHook(hook);
163162
return 0;
164163
}
165164

166165
template<class T>
167166
static int registerBeforeAllHook() {
168-
HookRegistrar::addBeforeAllHook(boost::make_shared<T>());
167+
HookRegistrar::addBeforeAllHook(std::make_shared<T>());
169168
return 0;
170169
}
171170

172171
template<class T>
173172
static int registerAfterAllHook() {
174-
HookRegistrar::addAfterAllHook(boost::make_shared<T>());
173+
HookRegistrar::addAfterAllHook(std::make_shared<T>());
175174
return 0;
176175
}
177176

0 commit comments

Comments
 (0)