Delete JSONCPP_DEPRECATED, use [[deprecated]] instead. (#978)

* delete JSONCPP_DEPRECATED, use [[deprecated]]

* add pragma warning(disable:4996)

* add error C2416

* update

* update

* update
This commit is contained in:
dota17 2019-07-18 04:35:33 +08:00 committed by Jordan Bayles
parent 483eba84a7
commit b27c83f691
6 changed files with 15 additions and 32 deletions

View File

@ -104,25 +104,6 @@ msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
#define JSONCPP_OP_EXPLICIT #define JSONCPP_OP_EXPLICIT
#endif #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 defined(__GNUC__) && (__GNUC__ >= 6) #if defined(__GNUC__) && (__GNUC__ >= 6)
#define JSON_USE_INT64_DOUBLE_CONVERSION 1 #define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif #endif

View File

@ -25,6 +25,10 @@
#pragma pack(push, 8) #pragma pack(push, 8)
#if defined(_MSC_VER)
#pragma warning(disable : 4996)
#endif
namespace Json { namespace Json {
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
@ -32,7 +36,7 @@ namespace Json {
* *
* \deprecated Use CharReader and CharReaderBuilder. * \deprecated Use CharReader and CharReaderBuilder.
*/ */
class JSON_API Reader { class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader {
public: public:
typedef char Char; typedef char Char;
typedef const Char* Location; typedef const Char* Location;
@ -50,12 +54,10 @@ public:
/** \brief Constructs a Reader allowing all features for parsing. /** \brief Constructs a Reader allowing all features for parsing.
*/ */
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Reader(); Reader();
/** \brief Constructs a Reader allowing the specified feature set for parsing. /** \brief Constructs a Reader allowing the specified feature set for parsing.
*/ */
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Reader(const Features& features); Reader(const Features& features);
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
@ -108,7 +110,7 @@ public:
* occurred during parsing. * occurred during parsing.
* \deprecated Use getFormattedErrorMessages() instead (typo fix). * \deprecated Use getFormattedErrorMessages() instead (typo fix).
*/ */
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.") [[deprecated("Use getFormattedErrorMessages() instead.")]]
String getFormatedErrorMessages() const; String getFormatedErrorMessages() const;
/** \brief Returns a user friendly string that list errors in the parsed /** \brief Returns a user friendly string that list errors in the parsed

View File

@ -564,7 +564,7 @@ public:
//# endif //# endif
/// \deprecated Always pass len. /// \deprecated Always pass len.
JSONCPP_DEPRECATED("Use setComment(String const&) instead.") [[deprecated("Use setComment(String const&) instead.")]]
void setComment(const char* comment, CommentPlacement placement) { void setComment(const char* comment, CommentPlacement placement) {
setComment(String(comment, strlen(comment)), placement); setComment(String(comment, strlen(comment)), placement);
} }
@ -750,7 +750,7 @@ public:
/// objectValue. /// objectValue.
/// \deprecated This cannot be used for UTF-8 strings, since there can be /// \deprecated This cannot be used for UTF-8 strings, since there can be
/// embedded nulls. /// embedded nulls.
JSONCPP_DEPRECATED("Use `key = name();` instead.") [[deprecated("Use `key = name();` instead.")]]
char const* memberName() const; char const* memberName() const;
/// Return the member name of the referenced Value, or NULL if it is not an /// Return the member name of the referenced Value, or NULL if it is not an
/// objectValue. /// objectValue.

View File

@ -145,7 +145,7 @@ public:
/** \brief Abstract class for writers. /** \brief Abstract class for writers.
* \deprecated Use StreamWriter. (And really, this is an implementation detail.) * \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: public:
virtual ~Writer(); virtual ~Writer();
@ -165,7 +165,7 @@ public:
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class #pragma warning(disable : 4996) // Deriving from deprecated class
#endif #endif
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
: public Writer { : public Writer {
public: public:
FastWriter(); FastWriter();
@ -225,7 +225,7 @@ private:
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class #pragma warning(disable : 4996) // Deriving from deprecated class
#endif #endif
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
StyledWriter : public Writer { StyledWriter : public Writer {
public: public:
StyledWriter(); StyledWriter();
@ -294,7 +294,7 @@ private:
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class #pragma warning(disable : 4996) // Deriving from deprecated class
#endif #endif
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
StyledStreamWriter { StyledStreamWriter {
public: public:
/** /**

View File

@ -378,8 +378,8 @@ void Runner::preventDialogOnCrash() {
_CrtSetReportHook(&msvcrtSilentReportHook); _CrtSetReportHook(&msvcrtSilentReportHook);
#endif // if defined(_MSC_VER) #endif // if defined(_MSC_VER)
// @todo investigate this handler (for buffer overflow) // @todo investigate this handler (for buffer overflow)
// _set_security_error_handler // _set_security_error_handler
#if defined(_WIN32) #if defined(_WIN32)
// Prevents the system from popping a dialog for debugging if the // Prevents the system from popping a dialog for debugging if the

View File

@ -2522,7 +2522,7 @@ JSONTEST_FIXTURE(IteratorTest, const) {
Json::Value const v; Json::Value const v;
JSONTEST_ASSERT_THROWS( JSONTEST_ASSERT_THROWS(
Json::Value::iterator it(v.begin()) // Compile, but throw. Json::Value::iterator it(v.begin()) // Compile, but throw.
); );
Json::Value value; Json::Value value;