COMP: Use C++11 override directly

The override support in C++11 is required so avoid aliasing
this feature.  Compilers that do not support the override keyword
are no longer supported.
This commit is contained in:
Hans Johnson 2019-01-11 13:58:53 -06:00 committed by Hans Johnson
parent 8b31c6f0fd
commit 2853b1cdac
7 changed files with 15 additions and 18 deletions

View File

@ -89,12 +89,11 @@
// In c++11 the override keyword allows you to explicitly define that a function // In c++11 the override keyword allows you to explicitly define that a function
// is intended to override the base-class version. This makes the code more // is intended to override the base-class version. This makes the code more
// manageable and fixes a set of common hard-to-find bugs. // manageable and fixes a set of common hard-to-find bugs.
#define JSONCPP_OVERRIDE override // Define maintained for backwards compatibility of external tools. C++11 should be used directly in JSONCPP
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
#define JSONCPP_OVERRIDE override
#define JSONCPP_NOEXCEPT noexcept #define JSONCPP_NOEXCEPT noexcept
#define JSONCPP_OP_EXPLICIT explicit #define JSONCPP_OP_EXPLICIT explicit
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900 #elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
#define JSONCPP_OVERRIDE override
#define JSONCPP_NOEXCEPT throw() #define JSONCPP_NOEXCEPT throw()
#if _MSC_VER >= 1800 // MSVC 2013 #if _MSC_VER >= 1800 // MSVC 2013
#define JSONCPP_OP_EXPLICIT explicit #define JSONCPP_OP_EXPLICIT explicit
@ -102,11 +101,9 @@
#define JSONCPP_OP_EXPLICIT #define JSONCPP_OP_EXPLICIT
#endif #endif
#elif defined(_MSC_VER) && _MSC_VER >= 1900 #elif defined(_MSC_VER) && _MSC_VER >= 1900
#define JSONCPP_OVERRIDE override
#define JSONCPP_NOEXCEPT noexcept #define JSONCPP_NOEXCEPT noexcept
#define JSONCPP_OP_EXPLICIT explicit #define JSONCPP_OP_EXPLICIT explicit
#else #else
#define JSONCPP_OVERRIDE
#define JSONCPP_NOEXCEPT throw() #define JSONCPP_NOEXCEPT throw()
#define JSONCPP_OP_EXPLICIT #define JSONCPP_OP_EXPLICIT
#endif #endif

View File

@ -347,9 +347,9 @@ public:
Json::Value settings_; Json::Value settings_;
CharReaderBuilder(); CharReaderBuilder();
~CharReaderBuilder() JSONCPP_OVERRIDE; ~CharReaderBuilder() override;
CharReader* newCharReader() const JSONCPP_OVERRIDE; CharReader* newCharReader() const override;
/** \return true if 'settings' are legal and consistent; /** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'. * otherwise, indicate bad settings via 'invalid'.

View File

@ -55,8 +55,8 @@ namespace Json {
class JSON_API Exception : public std::exception { class JSON_API Exception : public std::exception {
public: public:
Exception(JSONCPP_STRING const& msg); Exception(JSONCPP_STRING const& msg);
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE; ~Exception() JSONCPP_NOEXCEPT override;
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE; char const* what() const JSONCPP_NOEXCEPT override;
protected: protected:
JSONCPP_STRING msg_; JSONCPP_STRING msg_;

View File

@ -119,12 +119,12 @@ public:
Json::Value settings_; Json::Value settings_;
StreamWriterBuilder(); StreamWriterBuilder();
~StreamWriterBuilder() JSONCPP_OVERRIDE; ~StreamWriterBuilder() override;
/** /**
* \throw std::exception if something goes wrong (e.g. invalid settings) * \throw std::exception if something goes wrong (e.g. invalid settings)
*/ */
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE; StreamWriter* newStreamWriter() const override;
/** \return true if 'settings' are legal and consistent; /** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'. * otherwise, indicate bad settings via 'invalid'.
@ -169,7 +169,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
: public Writer { : public Writer {
public: public:
FastWriter(); FastWriter();
~FastWriter() JSONCPP_OVERRIDE {} ~FastWriter() override {}
void enableYAMLCompatibility(); void enableYAMLCompatibility();
@ -183,7 +183,7 @@ public:
void omitEndingLineFeed(); void omitEndingLineFeed();
public: // overridden from Writer public: // overridden from Writer
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE; JSONCPP_STRING write(const Value& root) override;
private: private:
void writeValue(const Value& value); void writeValue(const Value& value);
@ -229,14 +229,14 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
StyledWriter : public Writer { StyledWriter : public Writer {
public: public:
StyledWriter(); StyledWriter();
~StyledWriter() JSONCPP_OVERRIDE {} ~StyledWriter() override {}
public: // overridden from Writer public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format. /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize. * \param root Value to serialize.
* \return String containing the JSON document that represents the root value. * \return String containing the JSON document that represents the root value.
*/ */
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE; JSONCPP_STRING write(const Value& root) override;
private: private:
void writeValue(const Value& value); void writeValue(const Value& value);

View File

@ -1907,7 +1907,7 @@ public:
bool parse(char const* beginDoc, bool parse(char const* beginDoc,
char const* endDoc, char const* endDoc,
Value* root, Value* root,
JSONCPP_STRING* errs) JSONCPP_OVERRIDE { JSONCPP_STRING* errs) override {
bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_); bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
if (errs) { if (errs) {
*errs = reader_.getFormattedErrorMessages(); *errs = reader_.getFormattedErrorMessages();

View File

@ -880,7 +880,7 @@ struct BuiltStyledStreamWriter : public StreamWriter {
bool useSpecialFloats, bool useSpecialFloats,
unsigned int precision, unsigned int precision,
PrecisionType precisionType); PrecisionType precisionType);
int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE; int write(Value const& root, JSONCPP_OSTREAM* sout) override;
private: private:
void writeValue(Value const& value); void writeValue(Value const& value);

View File

@ -262,10 +262,10 @@ TestResult& checkStringEqual(TestResult& result,
} \ } \
\ \
public: /* overridden from TestCase */ \ public: /* overridden from TestCase */ \
const char* testName() const JSONCPP_OVERRIDE { \ const char* testName() const override { \
return #FixtureType "/" #name; \ return #FixtureType "/" #name; \
} \ } \
void runTestCase() JSONCPP_OVERRIDE; \ void runTestCase() override; \
}; \ }; \
\ \
void Test##FixtureType##name::runTestCase() void Test##FixtureType##name::runTestCase()