Skip to content

Issue #990: Remove unsupported C++14 features #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions include/json/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,26 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
#define JSONCPP_OP_EXPLICIT
#endif

#if defined(__clang__)
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
#elif defined(__GNUC__) && (__GNUC__ >= 6)
#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(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif

Expand Down
45 changes: 22 additions & 23 deletions include/json/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@

#pragma pack(push, 8)

#if defined(_MSC_VER)
#pragma warning(disable : 4996)
#endif

namespace Json {

/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
* Value.
*
* \deprecated Use CharReader and CharReaderBuilder.
*/
class [[deprecated(
"deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader {

class JSONCPP_DEPRECATED(
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
public:
typedef char Char;
typedef const Char* Location;
Expand All @@ -55,10 +52,12 @@ class [[deprecated(

/** \brief Constructs a Reader allowing all features for parsing.
*/
JSONCPP_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")
Reader(const Features& features);

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

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

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

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

typedef std::deque<ErrorInfo> Errors;

bool readToken(Token & token);
bool readToken(Token& token);
void skipSpaces();
bool match(const Char* pattern, int patternLength);
bool readComment();
Expand All @@ -199,17 +198,17 @@ class [[deprecated(
bool readString();
void readNumber();
bool readValue();
bool readObject(Token & token);
bool readArray(Token & token);
bool decodeNumber(Token & token);
bool decodeNumber(Token & token, Value & decoded);
bool decodeString(Token & token);
bool decodeString(Token & token, String & decoded);
bool decodeDouble(Token & token);
bool decodeDouble(Token & token, Value & decoded);
bool decodeUnicodeCodePoint(Token & token, Location & current, Location end,
bool readObject(Token& token);
bool readArray(Token& token);
bool decodeNumber(Token& token);
bool decodeNumber(Token& token, Value& decoded);
bool decodeString(Token& token);
bool decodeString(Token& token, String& decoded);
bool decodeDouble(Token& token);
bool decodeDouble(Token& token, Value& decoded);
bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
unsigned int& unicode);
bool decodeUnicodeEscapeSequence(Token & token, Location & current,
bool decodeUnicodeEscapeSequence(Token& token, Location& current,
Location end, unsigned int& unicode);
bool addError(const String& message, Token& token, Location extra = nullptr);
bool recoverFromError(TokenType skipUntilToken);
Expand All @@ -218,11 +217,11 @@ class [[deprecated(
void skipUntilSpace();
Value& currentValue();
Char getNextChar();
void getLocationLineAndColumn(Location location, int& line, int& column)
const;
void getLocationLineAndColumn(Location location, int& line,
int& column) const;
String getLocationLineAndColumn(Location location) const;
void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token & token);
void skipCommentTokens(Token& token);

static bool containsNewLine(Location begin, Location end);
static String normalizeEOL(Location begin, Location end);
Expand Down
7 changes: 4 additions & 3 deletions include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ class JSON_API Value {
//# endif

/// \deprecated Always pass len.
[[deprecated("Use setComment(String const&) instead.")]] void
setComment(const char* comment, CommentPlacement placement) {
JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
void setComment(const char* comment, CommentPlacement placement) {
setComment(String(comment, strlen(comment)), placement);
}
/// Comments must be //... or /* ... */
Expand Down Expand Up @@ -750,7 +750,8 @@ class JSON_API ValueIteratorBase {
/// objectValue.
/// \deprecated This cannot be used for UTF-8 strings, since there can be
/// embedded nulls.
[[deprecated("Use `key = name();` instead.")]] char const* memberName() const;
JSONCPP_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.
/// \note Better version than memberName(). Allows embedded nulls.
Expand Down
14 changes: 7 additions & 7 deletions include/json/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 [[deprecated("Use StreamWriter instead")]] JSON_API Writer {
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
public:
virtual ~Writer();

Expand All @@ -165,7 +165,7 @@ class [[deprecated("Use StreamWriter instead")]] JSON_API Writer {
#pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
: public Writer {
public:
FastWriter();
Expand Down Expand Up @@ -225,8 +225,8 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
#pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter
: public Writer {
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
StyledWriter : public Writer {
public:
StyledWriter();
~StyledWriter() override = default;
Expand Down Expand Up @@ -294,8 +294,8 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter
#pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
class [[deprecated(
"Use StreamWriterBuilder instead")]] JSON_API StyledStreamWriter {
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
StyledStreamWriter {
public:
/**
* \param indentation Each level will be indented by this amount extra.
Expand All @@ -310,7 +310,7 @@ class [[deprecated(
* \note There is no point in deriving from Writer, since write() should not
* return a value.
*/
void write(OStream & out, const Value& root);
void write(OStream& out, const Value& root);

private:
void writeValue(const Value& value);
Expand Down