Skip to content

Commit 2a8189e

Browse files
authored
Revert "Delete JSONCPP_DEPRECATED, use [[deprecated]] instead. (#978)" (#1029)
This reverts commit b27c83f.
1 parent ee80f6d commit 2a8189e

File tree

4 files changed

+53
-36
lines changed

4 files changed

+53
-36
lines changed

include/json/config.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,26 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
104104
#define JSONCPP_OP_EXPLICIT
105105
#endif
106106

107-
#if defined(__clang__)
108-
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
109-
#elif defined(__GNUC__) && (__GNUC__ >= 6)
107+
#ifdef __clang__
108+
#if __has_extension(attribute_deprecated_with_message)
109+
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
110+
#endif
111+
#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
112+
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
113+
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
114+
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
115+
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
116+
#endif // GNUC version
117+
#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
118+
// MSVC)
119+
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
120+
#endif // __clang__ || __GNUC__ || _MSC_VER
121+
122+
#if !defined(JSONCPP_DEPRECATED)
123+
#define JSONCPP_DEPRECATED(message)
124+
#endif // if !defined(JSONCPP_DEPRECATED)
125+
126+
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
110127
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
111128
#endif
112129

include/json/reader.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,16 @@
2525

2626
#pragma pack(push, 8)
2727

28-
#if defined(_MSC_VER)
29-
#pragma warning(disable : 4996)
30-
#endif
31-
3228
namespace Json {
3329

3430
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
3531
* Value.
3632
*
3733
* \deprecated Use CharReader and CharReaderBuilder.
3834
*/
39-
class [[deprecated(
40-
"deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader {
35+
36+
class JSONCPP_DEPRECATED(
37+
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
4138
public:
4239
typedef char Char;
4340
typedef const Char* Location;
@@ -55,10 +52,12 @@ class [[deprecated(
5552

5653
/** \brief Constructs a Reader allowing all features for parsing.
5754
*/
55+
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
5856
Reader();
5957

6058
/** \brief Constructs a Reader allowing the specified feature set for parsing.
6159
*/
60+
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
6261
Reader(const Features& features);
6362

6463
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
@@ -99,7 +98,7 @@ class [[deprecated(
9998

10099
/// \brief Parse from input stream.
101100
/// \see Json::operator>>(std::istream&, Json::Value&).
102-
bool parse(IStream & is, Value & root, bool collectComments = true);
101+
bool parse(IStream& is, Value& root, bool collectComments = true);
103102

104103
/** \brief Returns a user friendly string that list errors in the parsed
105104
* document.
@@ -109,8 +108,8 @@ class [[deprecated(
109108
* occurred during parsing.
110109
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
111110
*/
112-
[[deprecated("Use getFormattedErrorMessages() instead.")]] String
113-
getFormatedErrorMessages() const;
111+
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
112+
String getFormatedErrorMessages() const;
114113

115114
/** \brief Returns a user friendly string that list errors in the parsed
116115
* document.
@@ -190,7 +189,7 @@ class [[deprecated(
190189

191190
typedef std::deque<ErrorInfo> Errors;
192191

193-
bool readToken(Token & token);
192+
bool readToken(Token& token);
194193
void skipSpaces();
195194
bool match(const Char* pattern, int patternLength);
196195
bool readComment();
@@ -199,17 +198,17 @@ class [[deprecated(
199198
bool readString();
200199
void readNumber();
201200
bool readValue();
202-
bool readObject(Token & token);
203-
bool readArray(Token & token);
204-
bool decodeNumber(Token & token);
205-
bool decodeNumber(Token & token, Value & decoded);
206-
bool decodeString(Token & token);
207-
bool decodeString(Token & token, String & decoded);
208-
bool decodeDouble(Token & token);
209-
bool decodeDouble(Token & token, Value & decoded);
210-
bool decodeUnicodeCodePoint(Token & token, Location & current, Location end,
201+
bool readObject(Token& token);
202+
bool readArray(Token& token);
203+
bool decodeNumber(Token& token);
204+
bool decodeNumber(Token& token, Value& decoded);
205+
bool decodeString(Token& token);
206+
bool decodeString(Token& token, String& decoded);
207+
bool decodeDouble(Token& token);
208+
bool decodeDouble(Token& token, Value& decoded);
209+
bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
211210
unsigned int& unicode);
212-
bool decodeUnicodeEscapeSequence(Token & token, Location & current,
211+
bool decodeUnicodeEscapeSequence(Token& token, Location& current,
213212
Location end, unsigned int& unicode);
214213
bool addError(const String& message, Token& token, Location extra = nullptr);
215214
bool recoverFromError(TokenType skipUntilToken);
@@ -218,11 +217,11 @@ class [[deprecated(
218217
void skipUntilSpace();
219218
Value& currentValue();
220219
Char getNextChar();
221-
void getLocationLineAndColumn(Location location, int& line, int& column)
222-
const;
220+
void getLocationLineAndColumn(Location location, int& line,
221+
int& column) const;
223222
String getLocationLineAndColumn(Location location) const;
224223
void addComment(Location begin, Location end, CommentPlacement placement);
225-
void skipCommentTokens(Token & token);
224+
void skipCommentTokens(Token& token);
226225

227226
static bool containsNewLine(Location begin, Location end);
228227
static String normalizeEOL(Location begin, Location end);

include/json/value.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ class JSON_API Value {
567567
//# endif
568568

569569
/// \deprecated Always pass len.
570-
[[deprecated("Use setComment(String const&) instead.")]] void
571-
setComment(const char* comment, CommentPlacement placement) {
570+
JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
571+
void setComment(const char* comment, CommentPlacement placement) {
572572
setComment(String(comment, strlen(comment)), placement);
573573
}
574574
/// Comments must be //... or /* ... */
@@ -750,7 +750,8 @@ class JSON_API ValueIteratorBase {
750750
/// objectValue.
751751
/// \deprecated This cannot be used for UTF-8 strings, since there can be
752752
/// embedded nulls.
753-
[[deprecated("Use `key = name();` instead.")]] char const* memberName() const;
753+
JSONCPP_DEPRECATED("Use `key = name();` instead.")
754+
char const* memberName() const;
754755
/// Return the member name of the referenced Value, or NULL if it is not an
755756
/// objectValue.
756757
/// \note Better version than memberName(). Allows embedded nulls.

include/json/writer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
145145
/** \brief Abstract class for writers.
146146
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
147147
*/
148-
class [[deprecated("Use StreamWriter instead")]] JSON_API Writer {
148+
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
149149
public:
150150
virtual ~Writer();
151151

@@ -165,7 +165,7 @@ class [[deprecated("Use StreamWriter instead")]] JSON_API Writer {
165165
#pragma warning(push)
166166
#pragma warning(disable : 4996) // Deriving from deprecated class
167167
#endif
168-
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
168+
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
169169
: public Writer {
170170
public:
171171
FastWriter();
@@ -225,8 +225,8 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
225225
#pragma warning(push)
226226
#pragma warning(disable : 4996) // Deriving from deprecated class
227227
#endif
228-
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter
229-
: public Writer {
228+
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
229+
StyledWriter : public Writer {
230230
public:
231231
StyledWriter();
232232
~StyledWriter() override = default;
@@ -294,8 +294,8 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter
294294
#pragma warning(push)
295295
#pragma warning(disable : 4996) // Deriving from deprecated class
296296
#endif
297-
class [[deprecated(
298-
"Use StreamWriterBuilder instead")]] JSON_API StyledStreamWriter {
297+
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
298+
StyledStreamWriter {
299299
public:
300300
/**
301301
* \param indentation Each level will be indented by this amount extra.
@@ -310,7 +310,7 @@ class [[deprecated(
310310
* \note There is no point in deriving from Writer, since write() should not
311311
* return a value.
312312
*/
313-
void write(OStream & out, const Value& root);
313+
void write(OStream& out, const Value& root);
314314

315315
private:
316316
void writeValue(const Value& value);

0 commit comments

Comments
 (0)