jsoncpp: update to current version 1.8.3

This commit is contained in:
M. Liebmann
2017-09-21 09:05:06 +02:00
parent 6ee3e54741
commit 9f6e78974b
3 changed files with 217 additions and 82 deletions

View File

@@ -11,13 +11,13 @@ The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following tests and demonstration applications, are licensed under the following
conditions... conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions, jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain. this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
released under the terms of the MIT License (see below). The JsonCpp Authors, and is released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the software may choose to accept it either as 1) Public Domain, 2) under the
@@ -32,7 +32,7 @@ described in clear, concise terms at:
The full text of the MIT License follows: The full text of the MIT License follows:
======================================================================== ========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
@@ -83,7 +83,7 @@ license you like.
// Beginning of content of file: include/json/config.h // Beginning of content of file: include/json/config.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -94,6 +94,12 @@ license you like.
#include <string> //typedef String #include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t #include <stdint.h> //typedef int64_t, uint64_t
/* own assert() which does not abort... */
#define assert(x) do { \
if (x) \
fprintf(stderr, "JSONCPP:%s:%d assert(%s) failed\n", __func__, __LINE__, #x); \
} while (0)
/// If defined, indicates that json library is embedded in CppTL library. /// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1 //# define JSON_IN_CPPTL 1
@@ -205,6 +211,9 @@ license you like.
#endif #endif
#ifdef __clang__ #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) #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
@@ -281,7 +290,7 @@ typedef UInt64 LargestUInt;
// Beginning of content of file: include/json/forwards.h // Beginning of content of file: include/json/forwards.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -10,13 +10,13 @@ The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following tests and demonstration applications, are licensed under the following
conditions... conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions, jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain. this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
released under the terms of the MIT License (see below). The JsonCpp Authors, and is released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the software may choose to accept it either as 1) Public Domain, 2) under the
@@ -31,7 +31,7 @@ described in clear, concise terms at:
The full text of the MIT License follows: The full text of the MIT License follows:
======================================================================== ========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
@@ -87,10 +87,10 @@ license you like.
#ifndef JSON_VERSION_H_INCLUDED #ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "1.8.0" # define JSONCPP_VERSION_STRING "1.8.3"
# define JSONCPP_VERSION_MAJOR 1 # define JSONCPP_VERSION_MAJOR 1
# define JSONCPP_VERSION_MINOR 8 # define JSONCPP_VERSION_MINOR 8
# define JSONCPP_VERSION_PATCH 0 # define JSONCPP_VERSION_PATCH 3
# define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
@@ -116,7 +116,7 @@ license you like.
// Beginning of content of file: include/json/config.h // Beginning of content of file: include/json/config.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -127,6 +127,12 @@ license you like.
#include <string> //typedef String #include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t #include <stdint.h> //typedef int64_t, uint64_t
/* own assert() which does not abort... */
#define assert(x) do { \
if (x) \
fprintf(stderr, "JSONCPP:%s:%d assert(%s) failed\n", __func__, __LINE__, #x); \
} while (0)
/// If defined, indicates that json library is embedded in CppTL library. /// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1 //# define JSON_IN_CPPTL 1
@@ -238,6 +244,9 @@ license you like.
#endif #endif
#ifdef __clang__ #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) #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
@@ -314,7 +323,7 @@ typedef UInt64 LargestUInt;
// Beginning of content of file: include/json/forwards.h // Beginning of content of file: include/json/forwards.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -365,7 +374,7 @@ class ValueConstIterator;
// Beginning of content of file: include/json/features.h // Beginning of content of file: include/json/features.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -440,7 +449,7 @@ public:
// Beginning of content of file: include/json/value.h // Beginning of content of file: include/json/value.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -465,7 +474,7 @@ public:
#endif #endif
//Conditional NORETURN attribute on the throw functions would: //Conditional NORETURN attribute on the throw functions would:
// a) suppress false positives from static code analysis // a) suppress false positives from static code analysis
// b) possibly improve optimization opportunities. // b) possibly improve optimization opportunities.
#if !defined(JSONCPP_NORETURN) #if !defined(JSONCPP_NORETURN)
# if defined(_MSC_VER) # if defined(_MSC_VER)
@@ -506,7 +515,7 @@ protected:
/** Exceptions which the user cannot easily avoid. /** Exceptions which the user cannot easily avoid.
* *
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
* *
* \remark derived from Json::Exception * \remark derived from Json::Exception
*/ */
class JSON_API RuntimeError : public Exception { class JSON_API RuntimeError : public Exception {
@@ -517,7 +526,7 @@ public:
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. /** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
* *
* These are precondition-violations (user bugs) and internal errors (our bugs). * These are precondition-violations (user bugs) and internal errors (our bugs).
* *
* \remark derived from Json::Exception * \remark derived from Json::Exception
*/ */
class JSON_API LogicError : public Exception { class JSON_API LogicError : public Exception {
@@ -632,6 +641,9 @@ public:
typedef Json::LargestUInt LargestUInt; typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex; typedef Json::ArrayIndex ArrayIndex;
// Required for boost integration, e. g. BOOST_TEST
typedef std::string value_type;
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value(). static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
static Value const& nullSingleton(); ///< Prefer this to null or nullRef. static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
@@ -675,7 +687,12 @@ private:
CZString(CZString&& other); CZString(CZString&& other);
#endif #endif
~CZString(); ~CZString();
CZString& operator=(CZString other); CZString& operator=(const CZString& other);
#if JSON_HAS_RVALUE_REFERENCES
CZString& operator=(CZString&& other);
#endif
bool operator<(CZString const& other) const; bool operator<(CZString const& other) const;
bool operator==(CZString const& other) const; bool operator==(CZString const& other) const;
ArrayIndex index() const; ArrayIndex index() const;
@@ -765,11 +782,17 @@ Json::Value obj_value(Json::objectValue); // {}
/// Deep copy, then swap(other). /// Deep copy, then swap(other).
/// \note Over-write existing comments. To preserve comments, use #swapPayload(). /// \note Over-write existing comments. To preserve comments, use #swapPayload().
Value& operator=(Value other); Value& operator=(Value other);
/// Swap everything. /// Swap everything.
void swap(Value& other); void swap(Value& other);
/// Swap values but leave comments and source offsets in place. /// Swap values but leave comments and source offsets in place.
void swapPayload(Value& other); void swapPayload(Value& other);
/// copy everything.
void copy(const Value& other);
/// copy values but leave comments and source offsets in place.
void copyPayload(const Value& other);
ValueType type() const; ValueType type() const;
/// Compare payload only, not comments etc. /// Compare payload only, not comments etc.
@@ -880,6 +903,10 @@ Json::Value obj_value(Json::objectValue); // {}
/// Equivalent to jsonvalue[jsonvalue.size()] = value; /// Equivalent to jsonvalue[jsonvalue.size()] = value;
Value& append(const Value& value); Value& append(const Value& value);
#if JSON_HAS_RVALUE_REFERENCES
Value& append(Value&& value);
#endif
/// Access an object value by name, create a null member if it does not exist. /// Access an object value by name, create a null member if it does not exist.
/// \note Because of our implementation, keys are limited to 2^30 -1 chars. /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
/// Exceeding that will cause an exception. /// Exceeding that will cause an exception.
@@ -945,10 +972,12 @@ Json::Value obj_value(Json::objectValue); // {}
/// \pre type() is objectValue or nullValue /// \pre type() is objectValue or nullValue
/// \post type() is unchanged /// \post type() is unchanged
/// \deprecated /// \deprecated
JSONCPP_DEPRECATED("")
Value removeMember(const char* key); Value removeMember(const char* key);
/// Same as removeMember(const char*) /// Same as removeMember(const char*)
/// \param key may contain embedded nulls. /// \param key may contain embedded nulls.
/// \deprecated /// \deprecated
JSONCPP_DEPRECATED("")
Value removeMember(const JSONCPP_STRING& key); Value removeMember(const JSONCPP_STRING& key);
/// Same as removeMember(const char* begin, const char* end, Value* removed), /// Same as removeMember(const char* begin, const char* end, Value* removed),
/// but 'key' is null-terminated. /// but 'key' is null-terminated.
@@ -1324,7 +1353,7 @@ inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
// Beginning of content of file: include/json/reader.h // Beginning of content of file: include/json/reader.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -1358,7 +1387,7 @@ namespace Json {
* *
* \deprecated Use CharReader and CharReaderBuilder. * \deprecated Use CharReader and CharReaderBuilder.
*/ */
class JSON_API Reader { class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader {
public: public:
typedef char Char; typedef char Char;
typedef const Char* Location; typedef const Char* Location;
@@ -1556,6 +1585,9 @@ private:
void addComment(Location begin, Location end, CommentPlacement placement); void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token& token); void skipCommentTokens(Token& token);
static bool containsNewLine(Location begin, Location end);
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
typedef std::stack<Value*> Nodes; typedef std::stack<Value*> Nodes;
Nodes nodes_; Nodes nodes_;
Errors errors_; Errors errors_;
@@ -1746,7 +1778,7 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
// Beginning of content of file: include/json/writer.h // Beginning of content of file: include/json/writer.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -1763,7 +1795,7 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
// Disable warning C4251: <data member>: <type> needs to have dll-interface to // Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by... // be used by...
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4251) #pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
@@ -1888,7 +1920,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 JSON_API Writer { class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
public: public:
virtual ~Writer(); virtual ~Writer();
@@ -1904,8 +1936,11 @@ public:
* \sa Reader, Value * \sa Reader, Value
* \deprecated Use StreamWriterBuilder. * \deprecated Use StreamWriterBuilder.
*/ */
class JSON_API FastWriter : public Writer { #if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // Deriving from deprecated class
#endif
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer {
public: public:
FastWriter(); FastWriter();
~FastWriter() JSONCPP_OVERRIDE {} ~FastWriter() JSONCPP_OVERRIDE {}
@@ -1932,6 +1967,9 @@ private:
bool dropNullPlaceholders_; bool dropNullPlaceholders_;
bool omitEndingLineFeed_; bool omitEndingLineFeed_;
}; };
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
*human friendly way. *human friendly way.
@@ -1957,7 +1995,11 @@ private:
* \sa Reader, Value, Value::setComment() * \sa Reader, Value, Value::setComment()
* \deprecated Use StreamWriterBuilder. * \deprecated Use StreamWriterBuilder.
*/ */
class JSON_API StyledWriter : public Writer { #if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // Deriving from deprecated class
#endif
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer {
public: public:
StyledWriter(); StyledWriter();
~StyledWriter() JSONCPP_OVERRIDE {} ~StyledWriter() JSONCPP_OVERRIDE {}
@@ -1992,6 +2034,9 @@ private:
unsigned int indentSize_; unsigned int indentSize_;
bool addChildValues_; bool addChildValues_;
}; };
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
human friendly way, human friendly way,
@@ -2015,12 +2060,18 @@ private:
* If the Value have comments then they are outputed according to their * If the Value have comments then they are outputed according to their
#CommentPlacement. #CommentPlacement.
* *
* \param indentation Each level will be indented by this amount extra.
* \sa Reader, Value, Value::setComment() * \sa Reader, Value, Value::setComment()
* \deprecated Use StreamWriterBuilder. * \deprecated Use StreamWriterBuilder.
*/ */
class JSON_API StyledStreamWriter { #if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // Deriving from deprecated class
#endif
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
public: public:
/**
* \param indentation Each level will be indented by this amount extra.
*/
StyledStreamWriter(JSONCPP_STRING indentation = "\t"); StyledStreamWriter(JSONCPP_STRING indentation = "\t");
~StyledStreamWriter() {} ~StyledStreamWriter() {}
@@ -2057,6 +2108,9 @@ private:
bool addChildValues_ : 1; bool addChildValues_ : 1;
bool indented_ : 1; bool indented_ : 1;
}; };
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#if defined(JSON_HAS_INT64) #if defined(JSON_HAS_INT64)
JSONCPP_STRING JSON_API valueToString(Int value); JSONCPP_STRING JSON_API valueToString(Int value);
@@ -2095,7 +2149,7 @@ JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
// Beginning of content of file: include/json/assertions.h // Beginning of content of file: include/json/assertions.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -10,13 +10,13 @@ The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following tests and demonstration applications, are licensed under the following
conditions... conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions, jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain. this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
released under the terms of the MIT License (see below). The JsonCpp Authors, and is released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the software may choose to accept it either as 1) Public Domain, 2) under the
@@ -31,7 +31,7 @@ described in clear, concise terms at:
The full text of the MIT License follows: The full text of the MIT License follows:
======================================================================== ========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
@@ -84,7 +84,7 @@ license you like.
// Beginning of content of file: src/lib_json/json_tool.h // Beginning of content of file: src/lib_json/json_tool.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -215,7 +215,7 @@ static inline void fixNumericLocaleInput(char* begin, char* end) {
// Beginning of content of file: src/lib_json/json_reader.cpp // Beginning of content of file: src/lib_json/json_reader.cpp
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2011 Baptiste Lepilleur // Copyright 2007-2011 Baptiste Lepilleur and The JsonCpp Authors
// Copyright (C) 2016 InfoTeCS JSC. All rights reserved. // Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
@@ -229,7 +229,7 @@ static inline void fixNumericLocaleInput(char* begin, char* end) {
#endif // if !defined(JSON_IS_AMALGAMATION) #endif // if !defined(JSON_IS_AMALGAMATION)
#include <utility> #include <utility>
#include <cstdio> #include <cstdio>
#include <cassert> //#include <cassert>
#include <cstring> #include <cstring>
#include <istream> #include <istream>
#include <sstream> #include <sstream>
@@ -298,7 +298,7 @@ Features Features::strictMode() {
// Implementation of class Reader // Implementation of class Reader
// //////////////////////////////// // ////////////////////////////////
static bool containsNewLine(Reader::Location begin, Reader::Location end) { bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
for (; begin < end; ++begin) for (; begin < end; ++begin)
if (*begin == '\n' || *begin == '\r') if (*begin == '\n' || *begin == '\r')
return true; return true;
@@ -320,8 +320,7 @@ Reader::Reader(const Features& features)
bool bool
Reader::parse(const std::string& document, Value& root, bool collectComments) { Reader::parse(const std::string& document, Value& root, bool collectComments) {
JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity()); document_.assign(document.begin(), document.end());
std::swap(documentCopy, document_);
const char* begin = document_.c_str(); const char* begin = document_.c_str();
const char* end = begin + document_.length(); const char* end = begin + document_.length();
return parse(begin, end, root, collectComments); return parse(begin, end, root, collectComments);
@@ -354,7 +353,7 @@ bool Reader::parse(const char* beginDoc,
current_ = begin_; current_ = begin_;
lastValueEnd_ = 0; lastValueEnd_ = 0;
lastValue_ = 0; lastValue_ = 0;
commentsBefore_ = ""; commentsBefore_.clear();
errors_.clear(); errors_.clear();
while (!nodes_.empty()) while (!nodes_.empty())
nodes_.pop(); nodes_.pop();
@@ -393,7 +392,7 @@ bool Reader::readValue() {
if (collectComments_ && !commentsBefore_.empty()) { if (collectComments_ && !commentsBefore_.empty()) {
currentValue().setComment(commentsBefore_, commentBefore); currentValue().setComment(commentsBefore_, commentBefore);
commentsBefore_ = ""; commentsBefore_.clear();
} }
switch (token.type_) { switch (token.type_) {
@@ -587,7 +586,7 @@ bool Reader::readComment() {
return true; return true;
} }
static JSONCPP_STRING normalizeEOL(Reader::Location begin, Reader::Location end) { JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin, Reader::Location end) {
JSONCPP_STRING normalized; JSONCPP_STRING normalized;
normalized.reserve(static_cast<size_t>(end - begin)); normalized.reserve(static_cast<size_t>(end - begin));
Reader::Location current = begin; Reader::Location current = begin;
@@ -691,7 +690,7 @@ bool Reader::readObject(Token& tokenStart) {
break; break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true; return true;
name = ""; name.clear();
if (tokenName.type_ == tokenString) { if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name)) if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd); return recoverFromError(tokenObjectEnd);
@@ -1236,6 +1235,9 @@ private:
void addComment(Location begin, Location end, CommentPlacement placement); void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token& token); void skipCommentTokens(Token& token);
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
static bool containsNewLine(Location begin, Location end);
typedef std::stack<Value*> Nodes; typedef std::stack<Value*> Nodes;
Nodes nodes_; Nodes nodes_;
Errors errors_; Errors errors_;
@@ -1253,6 +1255,13 @@ private:
// complete copy of Read impl, for OurReader // complete copy of Read impl, for OurReader
bool OurReader::containsNewLine(OurReader::Location begin, OurReader::Location end) {
for (; begin < end; ++begin)
if (*begin == '\n' || *begin == '\r')
return true;
return false;
}
OurReader::OurReader(OurFeatures const& features) OurReader::OurReader(OurFeatures const& features)
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
lastValue_(), commentsBefore_(), lastValue_(), commentsBefore_(),
@@ -1273,7 +1282,7 @@ bool OurReader::parse(const char* beginDoc,
current_ = begin_; current_ = begin_;
lastValueEnd_ = 0; lastValueEnd_ = 0;
lastValue_ = 0; lastValue_ = 0;
commentsBefore_ = ""; commentsBefore_.clear();
errors_.clear(); errors_.clear();
while (!nodes_.empty()) while (!nodes_.empty())
nodes_.pop(); nodes_.pop();
@@ -1315,7 +1324,7 @@ bool OurReader::readValue() {
if (collectComments_ && !commentsBefore_.empty()) { if (collectComments_ && !commentsBefore_.empty()) {
currentValue().setComment(commentsBefore_, commentBefore); currentValue().setComment(commentsBefore_, commentBefore);
commentsBefore_ = ""; commentsBefore_.clear();
} }
switch (token.type_) { switch (token.type_) {
@@ -1562,6 +1571,25 @@ bool OurReader::readComment() {
return true; return true;
} }
JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin, OurReader::Location end) {
JSONCPP_STRING normalized;
normalized.reserve(static_cast<size_t>(end - begin));
OurReader::Location current = begin;
while (current != end) {
char c = *current++;
if (c == '\r') {
if (current != end && *current == '\n')
// convert dos EOL
++current;
// convert Mac EOL
normalized += '\n';
} else {
normalized += c;
}
}
return normalized;
}
void void
OurReader::addComment(Location begin, Location end, CommentPlacement placement) { OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
assert(collectComments_); assert(collectComments_);
@@ -1664,7 +1692,7 @@ bool OurReader::readObject(Token& tokenStart) {
break; break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true; return true;
name = ""; name.clear();
if (tokenName.type_ == tokenString) { if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name)) if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd); return recoverFromError(tokenObjectEnd);
@@ -2241,10 +2269,6 @@ JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
JSONCPP_STRING errs; JSONCPP_STRING errs;
bool ok = parseFromStream(b, sin, &root, &errs); bool ok = parseFromStream(b, sin, &root, &errs);
if (!ok) { if (!ok) {
fprintf(stderr,
"Error from reader: %s",
errs.c_str());
throwRuntimeError(errs); throwRuntimeError(errs);
} }
return sin; return sin;
@@ -2265,7 +2289,7 @@ JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
// Beginning of content of file: src/lib_json/json_valueiterator.inl // Beginning of content of file: src/lib_json/json_valueiterator.inl
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -2446,7 +2470,7 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) {
// Beginning of content of file: src/lib_json/json_value.cpp // Beginning of content of file: src/lib_json/json_value.cpp
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2011 Baptiste Lepilleur // Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -2460,7 +2484,7 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) {
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#include <cstring> #include <cstring>
#include <cassert> //#include <cassert>
#ifdef JSON_USE_CPPTL #ifdef JSON_USE_CPPTL
#include <cpptl/conststring.h> #include <cpptl/conststring.h>
#endif #endif
@@ -2740,11 +2764,21 @@ void Value::CZString::swap(CZString& other) {
std::swap(index_, other.index_); std::swap(index_, other.index_);
} }
Value::CZString& Value::CZString::operator=(CZString other) { Value::CZString& Value::CZString::operator=(const CZString& other) {
swap(other); cstr_ = other.cstr_;
index_ = other.index_;
return *this; return *this;
} }
#if JSON_HAS_RVALUE_REFERENCES
Value::CZString& Value::CZString::operator=(CZString&& other) {
cstr_ = other.cstr_;
index_ = other.index_;
other.cstr_ = nullptr;
return *this;
}
#endif
bool Value::CZString::operator<(const CZString& other) const { bool Value::CZString::operator<(const CZString& other) const {
if (!cstr_) return index_ < other.index_; if (!cstr_) return index_ < other.index_;
//return strcmp(cstr_, other.cstr_) < 0; //return strcmp(cstr_, other.cstr_) < 0;
@@ -2846,7 +2880,7 @@ Value::Value(double value) {
Value::Value(const char* value) { Value::Value(const char* value) {
initBasic(stringValue, true); initBasic(stringValue, true);
JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor"); JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor");
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value))); value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
} }
@@ -2971,6 +3005,12 @@ void Value::swapPayload(Value& other) {
other.allocated_ = temp2 & 0x1; other.allocated_ = temp2 & 0x1;
} }
void Value::copyPayload(const Value& other) {
type_ = other.type_;
value_ = other.value_;
allocated_ = other.allocated_;
}
void Value::swap(Value& other) { void Value::swap(Value& other) {
swapPayload(other); swapPayload(other);
std::swap(comments_, other.comments_); std::swap(comments_, other.comments_);
@@ -2978,6 +3018,13 @@ void Value::swap(Value& other) {
std::swap(limit_, other.limit_); std::swap(limit_, other.limit_);
} }
void Value::copy(const Value& other) {
copyPayload(other);
comments_ = other.comments_;
start_ = other.start_;
limit_ = other.limit_;
}
ValueType Value::type() const { return type_; } ValueType Value::type() const { return type_; }
int Value::compare(const Value& other) const { int Value::compare(const Value& other) const {
@@ -3328,7 +3375,7 @@ bool Value::isConvertibleTo(ValueType other) const {
case nullValue: case nullValue:
return (isNumeric() && asDouble() == 0.0) || return (isNumeric() && asDouble() == 0.0) ||
(type_ == booleanValue && value_.bool_ == false) || (type_ == booleanValue && value_.bool_ == false) ||
(type_ == stringValue && asString() == "") || (type_ == stringValue && asString().empty()) ||
(type_ == arrayValue && value_.map_->size() == 0) || (type_ == arrayValue && value_.map_->size() == 0) ||
(type_ == objectValue && value_.map_->size() == 0) || (type_ == objectValue && value_.map_->size() == 0) ||
type_ == nullValue; type_ == nullValue;
@@ -3572,6 +3619,10 @@ Value const& Value::operator[](CppTL::ConstString const& key) const
Value& Value::append(const Value& value) { return (*this)[size()] = value; } Value& Value::append(const Value& value) { return (*this)[size()] = value; }
#if JSON_HAS_RVALUE_REFERENCES
Value& Value::append(Value&& value) { return (*this)[size()] = std::move(value); }
#endif
Value Value::get(char const* key, char const* cend, Value const& defaultValue) const Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
{ {
Value const* found = find(key, cend); Value const* found = find(key, cend);
@@ -3608,6 +3659,9 @@ bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
{ {
return removeMember(key.data(), key.data() + key.length(), removed); return removeMember(key.data(), key.data() + key.length(), removed);
} }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Value Value::removeMember(const char* key) Value Value::removeMember(const char* key)
{ {
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue, JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
@@ -3623,6 +3677,7 @@ Value Value::removeMember(const JSONCPP_STRING& key)
{ {
return removeMember(key.c_str()); return removeMember(key.c_str());
} }
#pragma GCC diagnostic pop
bool Value::removeIndex(ArrayIndex index, Value* removed) { bool Value::removeIndex(ArrayIndex index, Value* removed) {
if (type_ != arrayValue) { if (type_ != arrayValue) {
@@ -3808,11 +3863,23 @@ bool Value::isUInt64() const {
} }
bool Value::isIntegral() const { bool Value::isIntegral() const {
switch (type_) {
case intValue:
case uintValue:
return true;
case realValue:
#if defined(JSON_HAS_INT64) #if defined(JSON_HAS_INT64)
return isInt64() || isUInt64(); // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
// double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
// require the value to be strictly less than the limit.
return value_.real_ >= double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
#else #else
return isInt() || isUInt(); return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_);
#endif #endif // JSON_HAS_INT64
default:
break;
}
return false;
} }
bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; } bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
@@ -3862,8 +3929,13 @@ ptrdiff_t Value::getOffsetStart() const { return start_; }
ptrdiff_t Value::getOffsetLimit() const { return limit_; } ptrdiff_t Value::getOffsetLimit() const { return limit_; }
JSONCPP_STRING Value::toStyledString() const { JSONCPP_STRING Value::toStyledString() const {
StyledWriter writer; StreamWriterBuilder builder;
return writer.write(*this);
JSONCPP_STRING out = this->hasComment(commentBefore) ? "\n" : "";
out += Json::writeString(builder, *this);
out += "\n";
return out;
} }
Value::const_iterator Value::begin() const { Value::const_iterator Value::begin() const {
@@ -3942,6 +4014,7 @@ Path::Path(const JSONCPP_STRING& path,
const PathArgument& a4, const PathArgument& a4,
const PathArgument& a5) { const PathArgument& a5) {
InArgs in; InArgs in;
in.reserve(5);
in.push_back(&a1); in.push_back(&a1);
in.push_back(&a2); in.push_back(&a2);
in.push_back(&a3); in.push_back(&a3);
@@ -4077,7 +4150,7 @@ Value& Path::make(Value& root) const {
// Beginning of content of file: src/lib_json/json_writer.cpp // Beginning of content of file: src/lib_json/json_writer.cpp
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// Copyright 2011 Baptiste Lepilleur // Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -4091,7 +4164,7 @@ Value& Path::make(Value& root) const {
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#include <set> #include <set>
#include <cassert> //#include <cassert>
#include <cstring> #include <cstring>
#include <cstdio> #include <cstdio>
@@ -4221,17 +4294,18 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
char buffer[36]; char buffer[36];
int len = -1; int len = -1;
char formatString[6]; char formatString[15];
sprintf(formatString, "%%.%dg", precision); snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
// Print into the buffer. We need not request the alternative representation // Print into the buffer. We need not request the alternative representation
// that always has a decimal point because JSON doesn't distingish the // that always has a decimal point because JSON doesn't distingish the
// concepts of reals and integers. // concepts of reals and integers.
if (isfinite(value)) { if (isfinite(value)) {
len = snprintf(buffer, sizeof(buffer), formatString, value); len = snprintf(buffer, sizeof(buffer), formatString, value);
fixNumericLocale(buffer, buffer + len);
// try to ensure we preserve the fact that this was given to us as a double on input // try to ensure we preserve the fact that this was given to us as a double on input
if (!strstr(buffer, ".") && !strstr(buffer, "e")) { if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
strcat(buffer, ".0"); strcat(buffer, ".0");
} }
@@ -4244,10 +4318,8 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
} else { } else {
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999"); len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
} }
// For those, we do not need to call fixNumLoc, but it is fast.
} }
assert(len >= 0); assert(len >= 0);
fixNumericLocale(buffer, buffer + len);
return buffer; return buffer;
} }
} }
@@ -4414,7 +4486,7 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; } void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
JSONCPP_STRING FastWriter::write(const Value& root) { JSONCPP_STRING FastWriter::write(const Value& root) {
document_ = ""; document_.clear();
writeValue(root); writeValue(root);
if (!omitEndingLineFeed_) if (!omitEndingLineFeed_)
document_ += "\n"; document_ += "\n";
@@ -4482,9 +4554,9 @@ StyledWriter::StyledWriter()
: rightMargin_(74), indentSize_(3), addChildValues_() {} : rightMargin_(74), indentSize_(3), addChildValues_() {}
JSONCPP_STRING StyledWriter::write(const Value& root) { JSONCPP_STRING StyledWriter::write(const Value& root) {
document_ = ""; document_.clear();
addChildValues_ = false; addChildValues_ = false;
indentString_ = ""; indentString_.clear();
writeCommentBeforeValue(root); writeCommentBeforeValue(root);
writeValue(root); writeValue(root);
writeCommentAfterValueOnSameLine(root); writeCommentAfterValueOnSameLine(root);
@@ -4662,7 +4734,7 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
while (iter != comment.end()) { while (iter != comment.end()) {
document_ += *iter; document_ += *iter;
if (*iter == '\n' && if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/')) ((iter+1) != comment.end() && *(iter + 1) == '/'))
writeIndent(); writeIndent();
++iter; ++iter;
} }
@@ -4698,7 +4770,7 @@ StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) { void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
document_ = &out; document_ = &out;
addChildValues_ = false; addChildValues_ = false;
indentString_ = ""; indentString_.clear();
indented_ = true; indented_ = true;
writeCommentBeforeValue(root); writeCommentBeforeValue(root);
if (!indented_) writeIndent(); if (!indented_) writeIndent();
@@ -4878,7 +4950,7 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
while (iter != comment.end()) { while (iter != comment.end()) {
*document_ << *iter; *document_ << *iter;
if (*iter == '\n' && if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/')) ((iter+1) != comment.end() && *(iter + 1) == '/'))
// writeIndent(); // would include newline // writeIndent(); // would include newline
*document_ << indentString_; *document_ << indentString_;
++iter; ++iter;
@@ -4980,7 +5052,7 @@ int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
sout_ = sout; sout_ = sout;
addChildValues_ = false; addChildValues_ = false;
indented_ = true; indented_ = true;
indentString_ = ""; indentString_.clear();
writeCommentBeforeValue(root); writeCommentBeforeValue(root);
if (!indented_) writeIndent(); if (!indented_) writeIndent();
indented_ = true; indented_ = true;
@@ -5166,7 +5238,7 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
while (iter != comment.end()) { while (iter != comment.end()) {
*sout_ << *iter; *sout_ << *iter;
if (*iter == '\n' && if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/')) ((iter+1) != comment.end() && *(iter + 1) == '/'))
// writeIndent(); // would write extra newline // writeIndent(); // would write extra newline
*sout_ << indentString_; *sout_ << indentString_;
++iter; ++iter;
@@ -5234,10 +5306,10 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
} }
JSONCPP_STRING nullSymbol = "null"; JSONCPP_STRING nullSymbol = "null";
if (dnp) { if (dnp) {
nullSymbol = ""; nullSymbol.clear();
} }
if (pre > 17) pre = 17; if (pre > 17) pre = 17;
JSONCPP_STRING endingLineFeedSymbol = ""; JSONCPP_STRING endingLineFeedSymbol;
return new BuiltStyledStreamWriter( return new BuiltStyledStreamWriter(
indentation, cs, indentation, cs,
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre); colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);