refactoring: use smart pointers from std instead from boost · cucumber/cucumber-cpp@99df11b · GitHub
Skip to content

Commit 99df11b

Browse files
committed
refactoring: use smart pointers from std instead from boost
1 parent 1a85bed commit 99df11b

24 files changed

Lines changed: 143 additions & 160 deletions

‎include/cucumber-cpp/internal/ContextManager.hpp‎

Lines changed: 9 additions & 11 deletions

‎include/cucumber-cpp/internal/CukeCommands.hpp‎

Lines changed: 2 additions & 4 deletions
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‎

Lines changed: 4 additions & 4 deletions
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‎

Lines changed: 7 additions & 7 deletions
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‎

Lines changed: 15 additions & 16 deletions
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

‎include/cucumber-cpp/internal/step/StepManager.hpp‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include <vector>
99

1010
#include <boost/config.hpp>
11-
#include <boost/enable_shared_from_this.hpp>
12-
#include <boost/make_shared.hpp>
13-
#include <boost/shared_ptr.hpp>
11+
#include <memory>
1412

1513
#ifndef BOOST_NO_VARIADIC_TEMPLATES
1614
#include <type_traits>
@@ -34,7 +32,7 @@ class CUCUMBER_CPP_EXPORT SingleStepMatch {
3432

3533
operator const void *() const;
3634

37-
boost::shared_ptr<const StepInfo> stepInfo;
35+
std::shared_ptr<const StepInfo> stepInfo;
3836
submatches_type submatches;
3937
};
4038

@@ -99,7 +97,7 @@ class CUCUMBER_CPP_EXPORT InvokeResult {
9997
const std::string &getDescription() const;
10098
};
10199

102-
class CUCUMBER_CPP_EXPORT StepInfo : public boost::enable_shared_from_this<StepInfo> {
100+
class CUCUMBER_CPP_EXPORT StepInfo : public std::enable_shared_from_this<StepInfo> {
103101
public:
104102
StepInfo(const std::string &stepMatcher, const std::string source);
105103

@@ -178,10 +176,10 @@ class StepInvoker : public StepInfo {
178176

179177
class CUCUMBER_CPP_EXPORT StepManager {
180178
protected:
181-
typedef std::map<step_id_type, boost::shared_ptr<const StepInfo> > steps_type;
179+
typedef std::map<step_id_type, std::shared_ptr<const StepInfo> > steps_type;
182180

183181
public:
184-
static step_id_type addStep(boost::shared_ptr<StepInfo> stepInfo);
182+
static step_id_type addStep(std::shared_ptr<StepInfo> stepInfo);
185183
static MatchResult stepMatches(const std::string &stepDescription);
186184
static const StepInfo* getStep(step_id_type id);
187185
protected:
@@ -213,7 +211,7 @@ static inline std::string toSourceString(const char *filePath, const int line) {
213211

214212
template<class T>
215213
static int registerStep(const std::string &stepMatcher, const char *file, const int line) {
216-
return StepManager::addStep(boost::make_shared< StepInvoker<T> >(stepMatcher, toSourceString(file, line)));
214+
return StepManager::addStep(std::make_shared< StepInvoker<T> >(stepMatcher, toSourceString(file, line)));
217215
}
218216

219217
template<typename T>

‎include/cucumber-cpp/internal/utils/Regex.hpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <cstddef>
55
#include <vector>
66

7-
#include <boost/shared_ptr.hpp>
87
#include <boost/regex.hpp>
98

109
namespace cucumber {
@@ -48,8 +47,8 @@ class Regex {
4847
public:
4948
Regex(std::string expr);
5049

51-
boost::shared_ptr<RegexMatch> find(const std::string &expression) const;
52-
boost::shared_ptr<RegexMatch> findAll(const std::string &expression) const;
50+
std::shared_ptr<RegexMatch> find(const std::string &expression) const;
51+
std::shared_ptr<RegexMatch> findAll(const std::string &expression) const;
5352

5453
std::string str() const;
5554
};

‎src/CukeCommands.cpp‎

Lines changed: 2 additions & 3 deletions

0 commit comments

Comments
 (0)