Skip to content

Commit

Permalink
Merge pull request #267 from ursfassler/modernize-overloading
Browse files Browse the repository at this point in the history
Modernize overloading
  • Loading branch information
ursfassler authored Dec 18, 2023
2 parents d0edbee + fe5a8c3 commit 735c02f
Show file tree
Hide file tree
Showing 36 changed files with 120 additions and 128 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ option_depr (VALGRIND_TESTS CUKE_TESTS_VALGRIND)
#

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Werror -Wall -Wextra ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Werror -Wall -Wextra -Wsuggest-override ${CMAKE_CXX_FLAGS}")
# TODO: A better fix should handle ld's --as-needed flag
if(UNIX AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'")
Expand Down
4 changes: 2 additions & 2 deletions examples/CalcQt/src/CalculatorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class CalculatorWidget : public QWidget {

protected:

virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;

private:

Expand Down
4 changes: 2 additions & 2 deletions include/cucumber-cpp/internal/CukeEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CUCUMBER_CPP_EXPORT InvokeException {

const std::string getMessage() const;

virtual ~InvokeException() {}
virtual ~InvokeException() = default;
};

class CUCUMBER_CPP_EXPORT InvokeFailureException : public InvokeException {
Expand Down Expand Up @@ -99,7 +99,7 @@ class CukeEngine {
virtual std::string snippetText(const std::string & keyword, const std::string & name, const std::string & multilineArgClass) const = 0;

CUCUMBER_CPP_EXPORT CukeEngine();
CUCUMBER_CPP_EXPORT virtual ~CukeEngine();
CUCUMBER_CPP_EXPORT virtual ~CukeEngine() = default;
};

}
Expand Down
10 changes: 5 additions & 5 deletions include/cucumber-cpp/internal/CukeEngineImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class CUCUMBER_CPP_EXPORT CukeEngineImpl : public CukeEngine {
CukeCommands cukeCommands;

public:
std::vector<StepMatch> stepMatches(const std::string & name) const;
void beginScenario(const tags_type & tags);
void invokeStep(const std::string & id, const invoke_args_type & args, const invoke_table_type & tableArg);
void endScenario(const tags_type & tags);
std::string snippetText(const std::string & keyword, const std::string & name, const std::string & multilineArgClass) const;
std::vector<StepMatch> stepMatches(const std::string & name) const override;
void beginScenario(const tags_type & tags) override;
void invokeStep(const std::string & id, const invoke_args_type & args, const invoke_table_type & tableArg) override;
void endScenario(const tags_type & tags) override;
std::string snippetText(const std::string & keyword, const std::string & name, const std::string & multilineArgClass) const override;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace internal {
class ProtocolHandler {
public:
virtual std::string handle(const std::string &request) const = 0;
virtual ~ProtocolHandler() {};
virtual ~ProtocolHandler() = default;
};

}
Expand Down
28 changes: 14 additions & 14 deletions include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class CUCUMBER_CPP_EXPORT WireResponse {

virtual void accept(WireResponseVisitor& visitor) const = 0;

virtual ~WireResponse() {};
virtual ~WireResponse() = default;
};

class CUCUMBER_CPP_EXPORT SuccessResponse : public WireResponse {
public:
void accept(WireResponseVisitor& visitor) const;
void accept(WireResponseVisitor& visitor) const override;
};

class CUCUMBER_CPP_EXPORT FailureResponse : public WireResponse {
Expand All @@ -40,7 +40,7 @@ class CUCUMBER_CPP_EXPORT FailureResponse : public WireResponse {
const std::string getMessage() const;
const std::string getExceptionType() const;

void accept(WireResponseVisitor& visitor) const;
void accept(WireResponseVisitor& visitor) const override;
};

class CUCUMBER_CPP_EXPORT PendingResponse : public WireResponse {
Expand All @@ -52,7 +52,7 @@ class CUCUMBER_CPP_EXPORT PendingResponse : public WireResponse {

const std::string getMessage() const;

void accept(WireResponseVisitor& visitor) const;
void accept(WireResponseVisitor& visitor) const override;
};

class CUCUMBER_CPP_EXPORT StepMatchesResponse : public WireResponse {
Expand All @@ -63,7 +63,7 @@ class CUCUMBER_CPP_EXPORT StepMatchesResponse : public WireResponse {
StepMatchesResponse(const std::vector<StepMatch> & matchingSteps);
const std::vector<StepMatch>& getMatchingSteps() const;

void accept(WireResponseVisitor& visitor) const;
void accept(WireResponseVisitor& visitor) const override;
};

class CUCUMBER_CPP_EXPORT SnippetTextResponse : public WireResponse {
Expand All @@ -75,7 +75,7 @@ class CUCUMBER_CPP_EXPORT SnippetTextResponse : public WireResponse {

const std::string getStepSnippet() const;

void accept(WireResponseVisitor& visitor) const;
void accept(WireResponseVisitor& visitor) const override;
};

class CUCUMBER_CPP_EXPORT WireResponseVisitor {
Expand All @@ -86,7 +86,7 @@ class CUCUMBER_CPP_EXPORT WireResponseVisitor {
virtual void visit(const StepMatchesResponse& response) = 0;
virtual void visit(const SnippetTextResponse& response) = 0;

virtual ~WireResponseVisitor() {};
virtual ~WireResponseVisitor() = default;
};


Expand All @@ -104,7 +104,7 @@ class CUCUMBER_CPP_EXPORT WireCommand {
*/
virtual std::shared_ptr<WireResponse> run(CukeEngine& engine) const = 0;

virtual ~WireCommand() {};
virtual ~WireCommand() = default;
};

class CUCUMBER_CPP_EXPORT WireMessageCodecException : public std::exception {
Expand All @@ -116,7 +116,7 @@ class CUCUMBER_CPP_EXPORT WireMessageCodecException : public std::exception {
description(description) {
}

const char* what() const throw() {
const char* what() const throw() override {
return description;
}
};
Expand Down Expand Up @@ -147,17 +147,17 @@ class CUCUMBER_CPP_EXPORT WireMessageCodec {
*/
virtual const std::string encode(const WireResponse& response) const = 0;

virtual ~WireMessageCodec() {};
virtual ~WireMessageCodec() = default;
};

/**
* WireMessageCodec implementation with JsonSpirit.
*/
class CUCUMBER_CPP_EXPORT JsonSpiritWireMessageCodec : public WireMessageCodec {
public:
JsonSpiritWireMessageCodec();
std::shared_ptr<WireCommand> decode(const std::string &request) const;
const std::string encode(const WireResponse& response) const;
JsonSpiritWireMessageCodec() = default;
std::shared_ptr<WireCommand> decode(const std::string &request) const override;
const std::string encode(const WireResponse& response) const override;
};

/**
Expand All @@ -172,7 +172,7 @@ class CUCUMBER_CPP_EXPORT WireProtocolHandler : public ProtocolHandler {
public:
WireProtocolHandler(const WireMessageCodec& codec, CukeEngine& engine);

std::string handle(const std::string &request) const;
std::string handle(const std::string &request) const override;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class BeginScenarioCommand : public ScenarioCommand {
public:
BeginScenarioCommand(const CukeEngine::tags_type& tags);

std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
std::shared_ptr<WireResponse> run(CukeEngine& engine) const override;
};


class EndScenarioCommand : public ScenarioCommand {
public:
EndScenarioCommand(const CukeEngine::tags_type& tags);

std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
std::shared_ptr<WireResponse> run(CukeEngine& engine) const override;
};


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

std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
std::shared_ptr<WireResponse> run(CukeEngine& engine) const override;
};


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

std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
std::shared_ptr<WireResponse> run(CukeEngine& engine) const override;
};


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

std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
std::shared_ptr<WireResponse> run(CukeEngine& engine) const override;
};


class FailingCommand : public WireCommand {
public:
std::shared_ptr<WireResponse> run(CukeEngine& engine) const;
std::shared_ptr<WireResponse> run(CukeEngine& engine) const override;
};

}
Expand Down
8 changes: 4 additions & 4 deletions include/cucumber-cpp/internal/connectors/wire/WireServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CUCUMBER_CPP_EXPORT SocketServer {
* Constructor for DI
*/
SocketServer(const ProtocolHandler *protocolHandler);
virtual ~SocketServer() {}
virtual ~SocketServer() = default;

/**
* Accept one connection
Expand Down Expand Up @@ -81,7 +81,7 @@ class CUCUMBER_CPP_EXPORT TCPSocketServer : public SocketServer {
*/
boost::asio::ip::tcp::endpoint listenEndpoint() const;

virtual void acceptOnce();
void acceptOnce() override;

private:
boost::asio::ip::tcp::acceptor acceptor;
Expand Down Expand Up @@ -111,9 +111,9 @@ class CUCUMBER_CPP_EXPORT UnixSocketServer : public SocketServer {
*/
boost::asio::local::stream_protocol::endpoint listenEndpoint() const;

virtual void acceptOnce();
void acceptOnce() override;

~UnixSocketServer();
~UnixSocketServer() override;

private:
boost::asio::local::stream_protocol::acceptor acceptor;
Expand Down
2 changes: 1 addition & 1 deletion include/cucumber-cpp/internal/drivers/BoostDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CukeBoostLogInterceptor;

class CUCUMBER_CPP_EXPORT BoostStep : public BasicStep {
protected:
const InvokeResult invokeStepBody();
const InvokeResult invokeStepBody() override;

private:
static void initBoostTest();
Expand Down
2 changes: 1 addition & 1 deletion include/cucumber-cpp/internal/drivers/GTestDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace internal {

class CUCUMBER_CPP_EXPORT GTestStep : public BasicStep {
protected:
const InvokeResult invokeStepBody();
const InvokeResult invokeStepBody() override;

private:
void initGTest();
Expand Down
2 changes: 1 addition & 1 deletion include/cucumber-cpp/internal/drivers/GenericDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace internal {

class CUCUMBER_CPP_EXPORT GenericStep : public BasicStep {
protected:
virtual const InvokeResult invokeStepBody();
const InvokeResult invokeStepBody() override;
};

#define STEP_INHERITANCE(step_name) virtual ::cucumber::internal::GenericStep
Expand Down
3 changes: 1 addition & 2 deletions include/cucumber-cpp/internal/drivers/QtTestDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CUCUMBER_CPP_EXPORT QtTestStep : public BasicStep {
QtTestStep() : BasicStep() {}

protected:
const InvokeResult invokeStepBody();
const InvokeResult invokeStepBody() override;
};

#define STEP_INHERITANCE(step_name) ::cucumber::internal::QtTestStep
Expand All @@ -24,7 +24,6 @@ class QtTestObject : public QObject {
Q_OBJECT
public:
QtTestObject(QtTestStep* qtTestStep) : step(qtTestStep) {}
virtual ~QtTestObject() {}

protected:
QtTestStep* step;
Expand Down
10 changes: 5 additions & 5 deletions include/cucumber-cpp/internal/hook/HookRegistrar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CUCUMBER_CPP_EXPORT CallableStep {

class CUCUMBER_CPP_EXPORT Hook {
public:
virtual ~Hook() {}
virtual ~Hook() = default;

void setTags(const std::string &csvTagNotation);
virtual void invokeHook(Scenario *scenario, CallableStep *step);
Expand All @@ -42,8 +42,8 @@ class CUCUMBER_CPP_EXPORT BeforeHook : public Hook {};

class CUCUMBER_CPP_EXPORT AroundStepHook : public Hook {
public:
virtual void invokeHook(Scenario *scenario, CallableStep *step);
virtual void skipHook();
void invokeHook(Scenario *scenario, CallableStep *step) override;
void skipHook() override;
protected:
CallableStep *step;
};
Expand All @@ -54,7 +54,7 @@ class CUCUMBER_CPP_EXPORT AfterHook : public Hook {};

class CUCUMBER_CPP_EXPORT UnconditionalHook : public Hook {
public:
virtual void invokeHook(Scenario *scenario, CallableStep *step);
void invokeHook(Scenario *scenario, CallableStep *step) override;
};

class CUCUMBER_CPP_EXPORT BeforeAllHook : public UnconditionalHook {};
Expand Down Expand Up @@ -124,7 +124,7 @@ class CUCUMBER_CPP_EXPORT StepCallChain {
class CUCUMBER_CPP_EXPORT CallableStepChain : public CallableStep {
public:
CallableStepChain(StepCallChain *scc);
void call();
void call() override;
private:
StepCallChain *scc;
};
Expand Down
8 changes: 4 additions & 4 deletions include/cucumber-cpp/internal/hook/Tag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class CUCUMBER_CPP_EXPORT TagExpression {
public:
typedef std::vector<std::string> tag_list;

virtual ~TagExpression() { }
virtual ~TagExpression() = default;
virtual bool matches(const tag_list &tags) const = 0;
};

class CUCUMBER_CPP_EXPORT OrTagExpression : public TagExpression {
public:
OrTagExpression(const std::string &csvTagNotation);
bool matches(const tag_list &tags) const;
bool matches(const tag_list &tags) const override;

private:
bool orTagMatchesTagList(const std::string &currentOrTag, const tag_list &tags) const;
Expand All @@ -33,9 +33,9 @@ class CUCUMBER_CPP_EXPORT OrTagExpression : public TagExpression {

class CUCUMBER_CPP_EXPORT AndTagExpression : public TagExpression {
public:
AndTagExpression();
AndTagExpression() = default;
AndTagExpression(const std::string &csvTagNotation);
bool matches(const tag_list &tags) const;
bool matches(const tag_list &tags) const override;

private:
typedef std::vector<OrTagExpression> or_expressions_type;
Expand Down
Loading

0 comments on commit 735c02f

Please sign in to comment.