From beda2e1c472e8bdc77bbd03ac133fb7ced112b2d Mon Sep 17 00:00:00 2001 From: lilinchao Date: Wed, 10 Jul 2019 16:36:46 +0800 Subject: [PATCH 1/6] delete JSONCPP_DEPRECATED, use [[deprecated]] --- include/json/config.h | 17 ----------------- include/json/reader.h | 6 +++--- include/json/value.h | 4 ++-- include/json/writer.h | 8 ++++---- src/lib_json/json_value.cpp | 3 +-- src/test_lib_json/jsontest.cpp | 4 ++-- src/test_lib_json/main.cpp | 11 +++++++---- 7 files changed, 19 insertions(+), 34 deletions(-) diff --git a/include/json/config.h b/include/json/config.h index cba610293..3d1f67b42 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -99,23 +99,6 @@ msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...); #define JSONCPP_OP_EXPLICIT #endif -#ifdef __clang__ -#if __has_extension(attribute_deprecated_with_message) -#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message))) -#endif -#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) -#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message))) -#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__)) -#endif // GNUC version -#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates MSVC) -#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message)) -#endif // __clang__ || __GNUC__ || _MSC_VER - -#if !defined(JSONCPP_DEPRECATED) -#define JSONCPP_DEPRECATED(message) -#endif // if !defined(JSONCPP_DEPRECATED) #if __GNUC__ >= 6 #define JSON_USE_INT64_DOUBLE_CONVERSION 1 diff --git a/include/json/reader.h b/include/json/reader.h index 111e5dd98..231ee2b34 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -52,13 +52,13 @@ class JSON_API Reader { /** \brief Constructs a Reader allowing all features * for parsing. */ - JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") + [[deprecated("Use CharReader and CharReaderBuilder instead")]] Reader(); /** \brief Constructs a Reader allowing the specified feature set * for parsing. */ - JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") + [[deprecated("Use CharReader and CharReaderBuilder instead")]] Reader(const Features& features); /** \brief Read a Value from a JSON @@ -114,7 +114,7 @@ class JSON_API Reader { * during parsing. * \deprecated Use getFormattedErrorMessages() instead (typo fix). */ - JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.") + [[deprecated("Use getFormattedErrorMessages() instead.")]] String getFormatedErrorMessages() const; /** \brief Returns a user friendly string that list errors in the parsed diff --git a/include/json/value.h b/include/json/value.h index 5f8d21444..be566c5cd 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -580,7 +580,7 @@ Json::Value obj_value(Json::objectValue); // {} //# endif /// \deprecated Always pass len. - JSONCPP_DEPRECATED("Use setComment(String const&) instead.") + [[deprecated("Use setComment(String const&) instead.")]] void setComment(const char* comment, CommentPlacement placement) { setComment(String(comment, strlen(comment)), placement); } @@ -764,7 +764,7 @@ class JSON_API ValueIteratorBase { /// objectValue. /// \deprecated This cannot be used for UTF-8 strings, since there can be /// embedded nulls. - JSONCPP_DEPRECATED("Use `key = name();` instead.") + [[deprecated("Use `key = name();` instead.")]] char const* memberName() const; /// Return the member name of the referenced Value, or NULL if it is not an /// objectValue. diff --git a/include/json/writer.h b/include/json/writer.h index 12fd36a7a..328014166 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -145,7 +145,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory { /** \brief Abstract class for writers. * \deprecated Use StreamWriter. (And really, this is an implementation detail.) */ -class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer { +class [[deprecated("Use StreamWriter instead")]] JSON_API Writer { public: virtual ~Writer(); @@ -165,7 +165,7 @@ class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer { #pragma warning(push) #pragma warning(disable : 4996) // Deriving from deprecated class #endif -class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter +class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter : public Writer { public: FastWriter(); @@ -225,7 +225,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter #pragma warning(push) #pragma warning(disable : 4996) // Deriving from deprecated class #endif -class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API +class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter : public Writer { public: StyledWriter(); @@ -294,7 +294,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API #pragma warning(push) #pragma warning(disable : 4996) // Deriving from deprecated class #endif -class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API +class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledStreamWriter { public: /** diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index b046c1939..89b38faf9 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -1436,8 +1436,7 @@ bool Value::isObject() const { return type() == objectValue; } Value::Comments::Comments(const Comments& that) : ptr_{cloneUnique(that.ptr_)} {} -Value::Comments::Comments(Comments&& that) - : ptr_{std::move(that.ptr_)} {} +Value::Comments::Comments(Comments&& that) : ptr_{std::move(that.ptr_)} {} Value::Comments& Value::Comments::operator=(const Comments& that) { ptr_ = cloneUnique(that.ptr_); diff --git a/src/test_lib_json/jsontest.cpp b/src/test_lib_json/jsontest.cpp index c0b5296d9..4c59d07b5 100644 --- a/src/test_lib_json/jsontest.cpp +++ b/src/test_lib_json/jsontest.cpp @@ -378,8 +378,8 @@ void Runner::preventDialogOnCrash() { _CrtSetReportHook(&msvcrtSilentReportHook); #endif // if defined(_MSC_VER) - // @todo investigate this handler (for buffer overflow) - // _set_security_error_handler +// @todo investigate this handler (for buffer overflow) +// _set_security_error_handler #if defined(_WIN32) // Prevents the system from popping a dialog for debugging if the diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 280f7eac6..0487c0f97 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -211,14 +211,17 @@ JSONTEST_FIXTURE(ValueTest, objects) { JSONTEST_ASSERT_EQUAL(Json::Value(1234), *foundId); const char unknownIdKey[] = "unknown id"; - const Json::Value* foundUnknownId = object1_.find(unknownIdKey, unknownIdKey + strlen(unknownIdKey)); + const Json::Value* foundUnknownId = + object1_.find(unknownIdKey, unknownIdKey + strlen(unknownIdKey)); JSONTEST_ASSERT_EQUAL(nullptr, foundUnknownId); // Access through demand() const char yetAnotherIdKey[] = "yet another id"; - const Json::Value* foundYetAnotherId = object1_.find(yetAnotherIdKey, yetAnotherIdKey + strlen(yetAnotherIdKey)); + const Json::Value* foundYetAnotherId = + object1_.find(yetAnotherIdKey, yetAnotherIdKey + strlen(yetAnotherIdKey)); JSONTEST_ASSERT_EQUAL(nullptr, foundYetAnotherId); - Json::Value* demandedYetAnotherId = object1_.demand(yetAnotherIdKey, yetAnotherIdKey + strlen(yetAnotherIdKey)); + Json::Value* demandedYetAnotherId = object1_.demand( + yetAnotherIdKey, yetAnotherIdKey + strlen(yetAnotherIdKey)); JSONTEST_ASSERT(demandedYetAnotherId != nullptr); *demandedYetAnotherId = "baz"; @@ -2495,7 +2498,7 @@ JSONTEST_FIXTURE(IteratorTest, const) { Json::Value const v; JSONTEST_ASSERT_THROWS( Json::Value::iterator it(v.begin()) // Compile, but throw. - ); + ); Json::Value value; From 11658e31b03b6c769abf0744787e535d6fe3eb44 Mon Sep 17 00:00:00 2001 From: lilinchao Date: Wed, 10 Jul 2019 19:57:22 +0800 Subject: [PATCH 2/6] add pragma warning(disable:4996) --- include/json/reader.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/json/reader.h b/include/json/reader.h index 231ee2b34..d6684f236 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -25,6 +25,10 @@ #pragma pack(push, 8) +#if defined(_MSC_VER) +#pragma warning(disable : 4996) +#endif + namespace Json { /** \brief Unserialize a JSON document into a From 43c86b5dcaae8643b9f5c298b90133de3584e374 Mon Sep 17 00:00:00 2001 From: lilinchao Date: Wed, 10 Jul 2019 20:19:18 +0800 Subject: [PATCH 3/6] add error C2416 --- include/json/reader.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/json/reader.h b/include/json/reader.h index d6684f236..455002eb1 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -27,6 +27,7 @@ #if defined(_MSC_VER) #pragma warning(disable : 4996) +#pragma warning(disable : 2416) #endif namespace Json { From 4e25f5a91f6f95d1ac04e19fa963c7a485e482f5 Mon Sep 17 00:00:00 2001 From: lilinchao Date: Wed, 10 Jul 2019 20:34:49 +0800 Subject: [PATCH 4/6] update --- include/json/reader.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/json/reader.h b/include/json/reader.h index 455002eb1..6dc4927b8 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -37,7 +37,7 @@ namespace Json { * * \deprecated Use CharReader and CharReaderBuilder. */ -class JSON_API Reader { +class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader { public: typedef char Char; typedef const Char* Location; @@ -57,13 +57,11 @@ class JSON_API Reader { /** \brief Constructs a Reader allowing all features * for parsing. */ - [[deprecated("Use CharReader and CharReaderBuilder instead")]] Reader(); /** \brief Constructs a Reader allowing the specified feature set * for parsing. */ - [[deprecated("Use CharReader and CharReaderBuilder instead")]] Reader(const Features& features); /** \brief Read a Value from a JSON From a1759fb663ca4446a0ac03aafe139433c47006b0 Mon Sep 17 00:00:00 2001 From: lilinchao Date: Wed, 10 Jul 2019 21:08:25 +0800 Subject: [PATCH 5/6] update --- include/json/reader.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/json/reader.h b/include/json/reader.h index 6dc4927b8..06fd492f2 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -27,7 +27,6 @@ #if defined(_MSC_VER) #pragma warning(disable : 4996) -#pragma warning(disable : 2416) #endif namespace Json { From a35b44f21bcf4dd1de2a6f210550133e0935e270 Mon Sep 17 00:00:00 2001 From: lilinchao Date: Wed, 10 Jul 2019 21:08:25 +0800 Subject: [PATCH 6/6] update --- include/json/reader.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/json/reader.h b/include/json/reader.h index 6dc4927b8..06fd492f2 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -27,7 +27,6 @@ #if defined(_MSC_VER) #pragma warning(disable : 4996) -#pragma warning(disable : 2416) #endif namespace Json {