From 254fa86ed70ecceab3ed3b91470d15e672783ee4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Sat, 2 May 2015 18:42:05 +0200 Subject: [PATCH] Make code safer. --- include/argument.h | 2 +- include/option.h | 2 +- include/parameter.h | 2 +- tests/callable/invokes_provided_function.cpp | 1 - tests/parameter/TestParameter.h | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/argument.h b/include/argument.h index eee218f..3ac1d71 100644 --- a/include/argument.h +++ b/include/argument.h @@ -25,7 +25,7 @@ namespace command { * @param description Description of current Argument * @param function Function used to handle current Argument. */ - Argument(std::string description, void (*function)(ArgumentType)) + Argument(const std::string & description, void (*function)(ArgumentType)) : Parameter(description), Callable(function) { } virtual ~Argument() { } diff --git a/include/option.h b/include/option.h index be65e77..270bb76 100644 --- a/include/option.h +++ b/include/option.h @@ -30,7 +30,7 @@ namespace command { * @param description Description of current Option * @param function Function used to handle current Option. */ - Option(std::string name, std::string description, void (*function)(OptionType)) + Option(std::string name, const std::string & description, void (*function)(OptionType)) : Parameter(description), Callable(function), name(name) { } virtual ~Option() { } diff --git a/include/parameter.h b/include/parameter.h index ed79218..a96128c 100644 --- a/include/parameter.h +++ b/include/parameter.h @@ -21,7 +21,7 @@ namespace command { * * @param description Description of current Argument */ - Parameter(std::string description) + Parameter(const std::string & description) : Descriptive(description) { } virtual ~Parameter() {} diff --git a/tests/callable/invokes_provided_function.cpp b/tests/callable/invokes_provided_function.cpp index 7322da5..5defb08 100644 --- a/tests/callable/invokes_provided_function.cpp +++ b/tests/callable/invokes_provided_function.cpp @@ -14,7 +14,6 @@ void function(bool val) { }; int main() { - TestCallable callable(function); callable.callFunction(true); diff --git a/tests/parameter/TestParameter.h b/tests/parameter/TestParameter.h index 9736133..592c653 100644 --- a/tests/parameter/TestParameter.h +++ b/tests/parameter/TestParameter.h @@ -3,7 +3,7 @@ class TestParameter : public command::Parameter { public: - TestParameter(std::string description) : Parameter(description) { } + TestParameter(const std::string & description) : Parameter(description) { } virtual void handle() { } virtual bool understand(const std::string & argVal) { } -- 2.30.2