From aadd0b1b637be3478e39ae5d7bbaa3804168300b Mon Sep 17 00:00:00 2001 From: Gaurav Date: Fri, 4 Sep 2015 14:04:43 +0530 Subject: [PATCH] C++11: override keyword Source : http://en.cppreference.com/w/cpp/language/override --- include/json/reader.h | 4 ++-- include/json/value.h | 4 ++-- include/json/writer.h | 12 ++++++------ src/lib_json/json_reader.cpp | 4 ++-- src/lib_json/json_writer.cpp | 2 +- src/test_lib_json/jsontest.h | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/json/reader.h b/include/json/reader.h index c07ce19..9a8a4e3 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -333,9 +333,9 @@ public: Json::Value settings_; CharReaderBuilder(); - virtual ~CharReaderBuilder(); + ~CharReaderBuilder() override; - virtual CharReader* newCharReader() const; + CharReader* newCharReader() const override; /** \return true if 'settings' are legal and consistent; * otherwise, indicate bad settings via 'invalid'. diff --git a/include/json/value.h b/include/json/value.h index 8e996ae..1ab22ef 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -40,8 +40,8 @@ namespace Json { class JSON_API Exception : public std::exception { public: Exception(std::string const& msg); - virtual ~Exception() throw(); - virtual char const* what() const throw(); + ~Exception() throw() override; + char const* what() const throw() override; protected: std::string const msg_; }; diff --git a/include/json/writer.h b/include/json/writer.h index 39bfa9b..f94aa1f 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -112,12 +112,12 @@ public: Json::Value settings_; StreamWriterBuilder(); - virtual ~StreamWriterBuilder(); + ~StreamWriterBuilder() override; /** * \throw std::exception if something goes wrong (e.g. invalid settings) */ - virtual StreamWriter* newStreamWriter() const; + StreamWriter* newStreamWriter() const override; /** \return true if 'settings' are legal and consistent; * otherwise, indicate bad settings via 'invalid'. @@ -158,7 +158,7 @@ class JSON_API FastWriter : public Writer { public: FastWriter(); - virtual ~FastWriter() {} + ~FastWriter() override {} void enableYAMLCompatibility(); @@ -172,7 +172,7 @@ public: void omitEndingLineFeed(); public: // overridden from Writer - virtual std::string write(const Value& root); + std::string write(const Value& root) override; private: void writeValue(const Value& value); @@ -210,14 +210,14 @@ private: class JSON_API StyledWriter : public Writer { public: StyledWriter(); - virtual ~StyledWriter() {} + ~StyledWriter() override {} public: // overridden from Writer /** \brief Serialize a Value in JSON format. * \param root Value to serialize. * \return String containing the JSON document that represents the root value. */ - virtual std::string write(const Value& root); + std::string write(const Value& root) override; private: void writeValue(const Value& value); diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 5b2f7b6..e0ba863 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -1903,9 +1903,9 @@ public: : collectComments_(collectComments) , reader_(features) {} - virtual bool parse( + bool parse( char const* beginDoc, char const* endDoc, - Value* root, std::string* errs) { + Value* root, std::string* errs) override { bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_); if (errs) { *errs = reader_.getFormattedErrorMessages(); diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index a38a5f2..aaeda7a 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -816,7 +816,7 @@ struct BuiltStyledStreamWriter : public StreamWriter std::string const& nullSymbol, std::string const& endingLineFeedSymbol, bool useSpecialFloats); - virtual int write(Value const& root, std::ostream* sout); + int write(Value const& root, std::ostream* sout) override; private: void writeValue(Value const& value); void writeArrayValue(Value const& value); diff --git a/src/test_lib_json/jsontest.h b/src/test_lib_json/jsontest.h index d6b7cf3..01b9c40 100644 --- a/src/test_lib_json/jsontest.h +++ b/src/test_lib_json/jsontest.h @@ -265,8 +265,8 @@ TestResult& checkStringEqual(TestResult& result, } \ \ public: /* overidden from TestCase */ \ - virtual const char* testName() const { return #FixtureType "/" #name; } \ - virtual void runTestCase(); \ + const char* testName() const override { return #FixtureType "/" #name; } \ + void runTestCase() override; \ }; \ \ void Test##FixtureType##name::runTestCase()