Rewrite and revert some code to build in pre-C++11

Rewerite and revert some code that this library can be built in pre-C++11 and C++11 env.
Main Change List:
1. using -> typedef
2. not using auto & decltype
3. not using raw string literals
4. ..., other c++11 features will be chosen to compile, depending on env.
This commit is contained in:
chenguoping
2020-04-30 11:24:36 +08:00
parent a4fb5db543
commit d2c205206d
22 changed files with 688 additions and 511 deletions

View File

@@ -58,4 +58,10 @@
} \
} while (0)
#if JSONCPP_CXX_STD_11
#define JSONCPP_STATIC_ASSERT static_assert
#else
#define JSONCPP_STATIC_ASSERT JSON_ASSERT_MESSAGE
#endif
#endif // JSON_ASSERTIONS_H_INCLUDED

View File

@@ -5,14 +5,20 @@
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
#include <cstddef>
#include <cstdint>
#include <istream>
#include <memory>
#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>
#if JSONCPP_CXX_STD_11
#include <cstddef> // typedef ptrdiff_t
#include <cstdint> // typedef int64_t, uint64_t
#else
#include <stddef.h>
#include <stdint.h>
#endif
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
@@ -50,11 +56,6 @@
#define JSON_API
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
#error \
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
#endif
#if defined(_MSC_VER) && _MSC_VER < 1900
// As recommended at
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
@@ -70,10 +71,41 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
// C++11 should be used directly in JSONCPP.
#define JSONCPP_OVERRIDE override
#if __cplusplus >= 201103L || defined(_MSC_VER)
#define JSONCPP_OP_EXPLICIT explicit
#else
#define JSONCPP_OP_EXPLICIT
#endif
// These Macros are maintained for backwards compatibility of external tools.
#if (defined(_MSC_VER) && _MSC_VER >= 1900) || \
(defined(__GNUC__) && __cplusplus >= 201103L) || \
(defined(__clang__) && __clang_major__ == 3 && __clang_minor__ >= 3)
#define JSONCPP_CXX_STD_11 1
#else
#define JSONCPP_CXX_STD_11 0
#endif
#if JSONCPP_CXX_STD_11
#define JSONCPP_NULL nullptr
#define JSONCPP_CONST constexpr
#define JSONCPP_CTOR_DELETE = delete
#define JSONCPP_NOEXCEPT noexcept
#define JSONCPP_OVERRIDE override
#define JSONCPP_MOVE(value) std::move(value)
#else
#define JSONCPP_NULL NULL
#define JSONCPP_CONST const
#define JSONCPP_CTOR_DELETE
#define JSONCPP_NOEXCEPT throw()
#define JSONCPP_OVERRIDE
#define JSONCPP_MOVE(value) value
#endif
// Define *deprecated* attribute
// [[deprecated]] is in C++14 or in Visual Studio 2015 and later
// For compatibility, [[deprecated]] is not used
#ifdef __clang__
#if __has_extension(attribute_deprecated_with_message)
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
@@ -98,33 +130,36 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
#endif
#if !defined(JSON_IS_AMALGAMATION)
#if JSONCPP_CXX_STD_11
#include "allocator.h"
#endif
#include "version.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
using Int = int;
using UInt = unsigned int;
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
using LargestInt = int;
using LargestUInt = unsigned int;
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
using Int64 = __int64;
using UInt64 = unsigned __int64;
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
using Int64 = int64_t;
using UInt64 = uint64_t;
typedef int64_t Int64;
typedef uint64_t UInt64;
#endif // if defined(_MSC_VER)
using LargestInt = Int64;
using LargestUInt = UInt64;
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
#if JSONCPP_CXX_STD_11
template <typename T>
using Allocator =
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
@@ -138,13 +173,20 @@ using OStringStream =
String::allocator_type>;
using IStream = std::istream;
using OStream = std::ostream;
#else
typedef std::string String;
typedef std::istringstream IStringStream;
typedef std::ostringstream OStringStream;
typedef std::istream IStream;
typedef std::ostream OStream;
#endif // JSONCPP_CXX_STD_11
} // namespace Json
// Legacy names (formerly macros).
using JSONCPP_STRING = Json::String;
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
using JSONCPP_ISTREAM = Json::IStream;
using JSONCPP_OSTREAM = Json::OStream;
typedef Json::String JSONCPP_STRING;
typedef Json::IStringStream JSONCPP_ISTRINGSTREAM;
typedef Json::OStringStream JSONCPP_OSTRINGSTREAM;
typedef Json::IStream JSONCPP_ISTREAM;
typedef Json::OStream JSONCPP_OSTREAM;
#endif // JSON_CONFIG_H_INCLUDED

View File

@@ -29,7 +29,7 @@ class CharReaderBuilder;
class Features;
// value.h
using ArrayIndex = unsigned int;
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;

View File

@@ -41,17 +41,17 @@ public:
Features();
/// \c true if comments are allowed. Default: \c true.
bool allowComments_{true};
bool allowComments_;
/// \c true if root must be either an array or an object value. Default: \c
/// false.
bool strictRoot_{false};
bool strictRoot_;
/// \c true if dropped null placeholders are allowed. Default: \c false.
bool allowDroppedNullPlaceholders_{false};
bool allowDroppedNullPlaceholders_;
/// \c true if numeric object key are allowed. Default: \c false.
bool allowNumericKeys_{false};
bool allowNumericKeys_;
};
} // namespace Json

View File

@@ -36,8 +36,8 @@ namespace Json {
class JSONCPP_DEPRECATED(
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
public:
using Char = char;
using Location = const Char*;
typedef char Char;
typedef const Char* Location;
/** \brief An error tagged with where in the JSON text it was encountered.
*
@@ -187,7 +187,7 @@ private:
Location extra_;
};
using Errors = std::deque<ErrorInfo>;
typedef std::deque<ErrorInfo> Errors;
bool readToken(Token& token);
void skipSpaces();
@@ -210,7 +210,8 @@ private:
unsigned int& unicode);
bool decodeUnicodeEscapeSequence(Token& token, Location& current,
Location end, unsigned int& unicode);
bool addError(const String& message, Token& token, Location extra = nullptr);
bool addError(const String& message, Token& token,
Location extra = JSONCPP_NULL);
bool recoverFromError(TokenType skipUntilToken);
bool addErrorAndRecover(const String& message, Token& token,
TokenType skipUntilToken);
@@ -226,25 +227,25 @@ private:
static bool containsNewLine(Location begin, Location end);
static String normalizeEOL(Location begin, Location end);
using Nodes = std::stack<Value*>;
typedef std::stack<Value*> Nodes;
Nodes nodes_;
Errors errors_;
String document_;
Location begin_{};
Location end_{};
Location current_{};
Location lastValueEnd_{};
Value* lastValue_{};
Location begin_;
Location end_;
Location current_;
Location lastValueEnd_;
Value* lastValue_;
String commentsBefore_;
Features features_;
bool collectComments_{};
bool collectComments_;
}; // Reader
/** Interface for reading JSON from a char array.
*/
class JSON_API CharReader {
public:
virtual ~CharReader() = default;
virtual ~CharReader() {}
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
* document. The document must be a UTF-8 encoded string containing the
* document to read.
@@ -266,7 +267,7 @@ public:
class JSON_API Factory {
public:
virtual ~Factory() = default;
virtual ~Factory() {}
/** \brief Allocate a CharReader via operator new().
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
@@ -332,9 +333,9 @@ public:
Json::Value settings_;
CharReaderBuilder();
~CharReaderBuilder() override;
~CharReaderBuilder() JSONCPP_OVERRIDE;
CharReader* newCharReader() const override;
CharReader* newCharReader() const JSONCPP_OVERRIDE;
/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.

View File

@@ -13,13 +13,16 @@
// Conditional NORETURN attribute on the throw functions would:
// a) suppress false positives from static code analysis
// b) possibly improve optimization opportunities.
// For compatibility, [[noreturn]] is not used
#if !defined(JSONCPP_NORETURN)
#if defined(_MSC_VER) && _MSC_VER == 1800
#if defined(_MSC_VER)
#define JSONCPP_NORETURN __declspec(noreturn)
#elif defined(__GNUC__) || defined(__clang__)
#define JSONCPP_NORETURN __attribute__((noreturn))
#else
#define JSONCPP_NORETURN [[noreturn]]
#endif
#define JSONCPP_NORETURN
#endif
#endif // if !defined(JSONCPP_NORETURN)
// Support for '= delete' with template declarations was a late addition
// to the c++11 standard and is rejected by clang 3.8 and Apple clang 8.2
@@ -39,10 +42,15 @@
#endif
#endif
#include <array>
#if JSONCPP_CXX_STD_11
#else
#undef JSONCPP_TEMPLATE_DELETE
#define JSONCPP_TEMPLATE_DELETE
#include <string.h>
#endif
#include <exception>
#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -67,8 +75,8 @@ namespace Json {
class JSON_API Exception : public std::exception {
public:
Exception(String msg);
~Exception() noexcept override;
char const* what() const noexcept override;
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
protected:
String msg_;
@@ -146,7 +154,7 @@ enum PrecisionType {
*/
class JSON_API StaticString {
public:
explicit StaticString(const char* czstring) : c_str_(czstring) {}
JSONCPP_OP_EXPLICIT StaticString(const char* czstring) : c_str_(czstring) {}
operator const char*() const { return c_str_; }
@@ -194,21 +202,21 @@ class JSON_API Value {
friend class ValueIteratorBase;
public:
using Members = std::vector<String>;
using iterator = ValueIterator;
using const_iterator = ValueConstIterator;
using UInt = Json::UInt;
using Int = Json::Int;
typedef std::vector<String> Members;
typedef ValueIterator iterator;
typedef ValueConstIterator const_iterator;
typedef Json::UInt UInt;
typedef Json::Int Int;
#if defined(JSON_HAS_INT64)
using UInt64 = Json::UInt64;
using Int64 = Json::Int64;
typedef Json::UInt64 UInt64;
typedef Json::Int64 Int64;
#endif // defined(JSON_HAS_INT64)
using LargestInt = Json::LargestInt;
using LargestUInt = Json::LargestUInt;
using ArrayIndex = Json::ArrayIndex;
typedef Json::LargestInt LargestInt;
typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex;
// Required for boost integration, e. g. BOOST_TEST
using value_type = std::string;
typedef std::string value_type;
#if JSON_USE_NULLREF
// Binary compatibility kludges, do not use.
@@ -220,34 +228,35 @@ public:
static Value const& nullSingleton();
/// Minimum signed integer value that can be stored in a Json::Value.
static constexpr LargestInt minLargestInt =
static JSONCPP_CONST LargestInt minLargestInt =
LargestInt(~(LargestUInt(-1) / 2));
/// Maximum signed integer value that can be stored in a Json::Value.
static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
static JSONCPP_CONST LargestInt maxLargestInt =
LargestInt(LargestUInt(-1) / 2);
/// Maximum unsigned integer value that can be stored in a Json::Value.
static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
static JSONCPP_CONST LargestUInt maxLargestUInt = LargestUInt(-1);
/// Minimum signed int value that can be stored in a Json::Value.
static constexpr Int minInt = Int(~(UInt(-1) / 2));
static JSONCPP_CONST Int minInt = Int(~(UInt(-1) / 2));
/// Maximum signed int value that can be stored in a Json::Value.
static constexpr Int maxInt = Int(UInt(-1) / 2);
static JSONCPP_CONST Int maxInt = Int(UInt(-1) / 2);
/// Maximum unsigned int value that can be stored in a Json::Value.
static constexpr UInt maxUInt = UInt(-1);
static JSONCPP_CONST UInt maxUInt = UInt(-1);
#if defined(JSON_HAS_INT64)
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
static JSONCPP_CONST Int64 minInt64 = Int64(~(UInt64(-1) / 2));
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
static JSONCPP_CONST Int64 maxInt64 = Int64(UInt64(-1) / 2);
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
static constexpr UInt64 maxUInt64 = UInt64(-1);
static JSONCPP_CONST UInt64 maxUInt64 = UInt64(-1);
#endif // defined(JSON_HAS_INT64)
/// Default precision for real value for string representation.
static constexpr UInt defaultRealPrecision = 17;
static JSONCPP_CONST UInt defaultRealPrecision = 17;
// The constant is hard-coded because some compiler have trouble
// converting Value::maxUInt64 to a double correctly (AIX/xlC).
// Assumes that UInt64 is a 64 bits integer.
static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
static JSONCPP_CONST double maxUInt64AsDouble = 18446744073709551615.0;
// Workaround for bug in the NVIDIAs CUDA 9.1 nvcc compiler
// when using gcc and clang backend compilers. CZString
// cannot be defined as private. See issue #486
@@ -263,11 +272,14 @@ private:
CZString(ArrayIndex index);
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
CZString(CZString const& other);
#if JSONCPP_CXX_STD_11
CZString(CZString&& other);
#endif
~CZString();
CZString& operator=(const CZString& other);
#if JSONCPP_CXX_STD_11
CZString& operator=(CZString&& other);
#endif
bool operator<(CZString const& other) const;
bool operator==(CZString const& other) const;
ArrayIndex index() const;
@@ -343,13 +355,17 @@ public:
Value(const String& value);
Value(bool value);
Value(const Value& other);
#if JSONCPP_CXX_STD_11
Value(Value&& other);
#endif
~Value();
/// \note Overwrite existing comments. To preserve comments, use
/// #swapPayload().
Value& operator=(const Value& other);
#if JSONCPP_CXX_STD_11
Value& operator=(Value&& other);
#endif
/// Swap everything.
void swap(Value& other);
@@ -421,7 +437,7 @@ public:
bool empty() const;
/// Return !isNull()
explicit operator bool() const;
JSONCPP_OP_EXPLICIT operator bool() const;
/// Remove all object members and array elements.
/// \pre type() is arrayValue, objectValue, or nullValue
@@ -462,11 +478,15 @@ public:
///
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
Value& append(const Value& value);
#if JSONCPP_CXX_STD_11
Value& append(Value&& value);
#endif
/// \brief Insert value in array at specific index
bool insert(ArrayIndex index, const Value& newValue);
#if JSONCPP_CXX_STD_11
bool insert(ArrayIndex index, Value&& newValue);
#endif
/// 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.
@@ -562,15 +582,11 @@ public:
/// \deprecated Always pass len.
JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
void setComment(const char* comment, CommentPlacement placement) {
setComment(String(comment, strlen(comment)), placement);
}
void setComment(const char* comment, CommentPlacement placement);
/// Comments must be //... or /* ... */
void setComment(const char* comment, size_t len, CommentPlacement placement) {
setComment(String(comment, len), placement);
}
void setComment(const char* comment, size_t len, CommentPlacement placement);
/// Comments must be //... or /* ... */
void setComment(String comment, CommentPlacement placement);
void setComment(const String& comment, CommentPlacement placement);
bool hasComment(CommentPlacement placement) const;
/// Include delimiters and embedded newlines.
String getComment(CommentPlacement placement) const;
@@ -632,18 +648,15 @@ private:
class Comments {
public:
Comments() = default;
Comments() {}
Comments(const Comments& that);
Comments(Comments&& that);
Comments& operator=(const Comments& that);
Comments& operator=(Comments&& that);
bool has(CommentPlacement slot) const;
String get(CommentPlacement slot) const;
void set(CommentPlacement slot, String comment);
void set(CommentPlacement slot, String s);
private:
using Array = std::array<String, numberOfCommentPlacement>;
std::unique_ptr<Array> ptr_;
String ptr_[numberOfCommentPlacement];
};
Comments comments_;
@@ -698,8 +711,8 @@ public:
private:
enum Kind { kindNone = 0, kindIndex, kindKey };
String key_;
ArrayIndex index_{};
Kind kind_{kindNone};
ArrayIndex index_;
Kind kind_;
};
/** \brief Experimental and untested: represents a "path" to access a node.
@@ -728,8 +741,8 @@ public:
Value& make(Value& root) const;
private:
using InArgs = std::vector<const PathArgument*>;
using Args = std::vector<PathArgument>;
typedef std::vector<const PathArgument*> InArgs;
typedef std::vector<PathArgument> Args;
void makePath(const String& path, const InArgs& in);
void addPathInArg(const String& path, const InArgs& in,
@@ -744,10 +757,10 @@ private:
*/
class JSON_API ValueIteratorBase {
public:
using iterator_category = std::bidirectional_iterator_tag;
using size_t = unsigned int;
using difference_type = int;
using SelfType = ValueIteratorBase;
typedef std::bidirectional_iterator_tag iterator_category;
typedef unsigned int size_t;
typedef int difference_type;
typedef ValueIteratorBase SelfType;
bool operator==(const SelfType& other) const { return isEqual(other); }
@@ -804,13 +817,14 @@ protected:
private:
Value::ObjectValues::iterator current_;
// Indicates that iterator is for a null value.
bool isNull_{true};
bool isNull_;
public:
// For some reason, BORLAND needs these at the end, rather
// than earlier. No idea why.
ValueIteratorBase();
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
JSONCPP_OP_EXPLICIT
ValueIteratorBase(const Value::ObjectValues::iterator& current);
};
/** \brief const iterator for object and array value.
@@ -820,12 +834,12 @@ class JSON_API ValueConstIterator : public ValueIteratorBase {
friend class Value;
public:
using value_type = const Value;
typedef const Value value_type;
// typedef unsigned int size_t;
// typedef int difference_type;
using reference = const Value&;
using pointer = const Value*;
using SelfType = ValueConstIterator;
typedef const Value& reference;
typedef const Value* pointer;
typedef ValueConstIterator SelfType;
ValueConstIterator();
ValueConstIterator(ValueIterator const& other);
@@ -833,7 +847,8 @@ public:
private:
/*! \internal Use by Value to create an iterator.
*/
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
JSONCPP_OP_EXPLICIT
ValueConstIterator(const Value::ObjectValues::iterator& current);
public:
SelfType& operator=(const ValueIteratorBase& other);
@@ -871,21 +886,22 @@ class JSON_API ValueIterator : public ValueIteratorBase {
friend class Value;
public:
using value_type = Value;
using size_t = unsigned int;
using difference_type = int;
using reference = Value&;
using pointer = Value*;
using SelfType = ValueIterator;
typedef Value value_type;
typedef unsigned int size_t;
typedef int difference_type;
typedef Value& reference;
typedef Value* pointer;
typedef ValueIterator SelfType;
ValueIterator();
explicit ValueIterator(const ValueConstIterator& other);
JSONCPP_OP_EXPLICIT ValueIterator(const ValueConstIterator& other);
ValueIterator(const ValueIterator& other);
private:
/*! \internal Use by Value to create an iterator.
*/
explicit ValueIterator(const Value::ObjectValues::iterator& current);
JSONCPP_OP_EXPLICIT
ValueIterator(const Value::ObjectValues::iterator& current);
public:
SelfType& operator=(const SelfType& other);

View File

@@ -9,10 +9,10 @@
// 3. /CMakeLists.txt
// IMPORTANT: also update the SOVERSION!!
#define JSONCPP_VERSION_STRING "1.9.3"
#define JSONCPP_VERSION_MAJOR 1
#define JSONCPP_VERSION_MINOR 9
#define JSONCPP_VERSION_PATCH 3
#define JSONCPP_VERSION_STRING "00.11.0"
#define JSONCPP_VERSION_MAJOR 00
#define JSONCPP_VERSION_MINOR 11
#define JSONCPP_VERSION_PATCH 0
#define JSONCPP_VERSION_QUALIFIER
#define JSONCPP_VERSION_HEXA \
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \

View File

@@ -119,12 +119,12 @@ public:
Json::Value settings_;
StreamWriterBuilder();
~StreamWriterBuilder() override;
~StreamWriterBuilder() JSONCPP_OVERRIDE;
/**
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
StreamWriter* newStreamWriter() const override;
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.
@@ -169,7 +169,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
: public Writer {
public:
FastWriter();
~FastWriter() override = default;
~FastWriter() JSONCPP_OVERRIDE {}
void enableYAMLCompatibility();
@@ -183,15 +183,15 @@ public:
void omitEndingLineFeed();
public: // overridden from Writer
String write(const Value& root) override;
String write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
String document_;
bool yamlCompatibilityEnabled_{false};
bool dropNullPlaceholders_{false};
bool omitEndingLineFeed_{false};
bool yamlCompatibilityEnabled_;
bool dropNullPlaceholders_;
bool omitEndingLineFeed_;
};
#if defined(_MSC_VER)
#pragma warning(pop)
@@ -229,14 +229,14 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
StyledWriter : public Writer {
public:
StyledWriter();
~StyledWriter() override = default;
~StyledWriter() JSONCPP_OVERRIDE {}
public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize.
* \return String containing the JSON document that represents the root value.
*/
String write(const Value& root) override;
String write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
@@ -252,14 +252,14 @@ private:
static bool hasCommentForValue(const Value& value);
static String normalizeEOL(const String& text);
using ChildValues = std::vector<String>;
typedef std::vector<String> ChildValues;
ChildValues childValues_;
String document_;
String indentString_;
unsigned int rightMargin_{74};
unsigned int indentSize_{3};
bool addChildValues_{false};
unsigned int rightMargin_;
unsigned int indentSize_;
bool addChildValues_;
};
#if defined(_MSC_VER)
#pragma warning(pop)
@@ -301,7 +301,7 @@ public:
* \param indentation Each level will be indented by this amount extra.
*/
StyledStreamWriter(String indentation = "\t");
~StyledStreamWriter() = default;
~StyledStreamWriter() {}
public:
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
@@ -326,12 +326,12 @@ private:
static bool hasCommentForValue(const Value& value);
static String normalizeEOL(const String& text);
using ChildValues = std::vector<String>;
typedef std::vector<String> ChildValues;
ChildValues childValues_;
OStream* document_;
String indentString_;
unsigned int rightMargin_{74};
unsigned int rightMargin_;
String indentation_;
bool addChildValues_ : 1;
bool indented_ : 1;
@@ -348,7 +348,7 @@ String JSON_API valueToString(LargestInt value);
String JSON_API valueToString(LargestUInt value);
String JSON_API valueToString(
double value, unsigned int precision = Value::defaultRealPrecision,
PrecisionType precisionType = PrecisionType::significantDigits);
PrecisionType precisionType = significantDigits);
String JSON_API valueToString(bool value);
String JSON_API valueToQuotedString(const char* value);