- switch to JsonCpp:: namespace instead of Json::
This commit is contained in:
parent
b3bf17a5c5
commit
e7dedc90d4
|
|
@ -231,7 +231,7 @@ license you like.
|
||||||
|
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
typedef int Int;
|
typedef int Int;
|
||||||
typedef unsigned int UInt;
|
typedef unsigned int UInt;
|
||||||
#if defined(JSON_NO_INT64)
|
#if defined(JSON_NO_INT64)
|
||||||
|
|
@ -252,10 +252,10 @@ typedef UInt64 LargestUInt;
|
||||||
#define JSON_HAS_INT64
|
#define JSON_HAS_INT64
|
||||||
#endif // if defined(JSON_NO_INT64)
|
#endif // if defined(JSON_NO_INT64)
|
||||||
#if JSONCPP_USING_SECURE_MEMORY
|
#if JSONCPP_USING_SECURE_MEMORY
|
||||||
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, JsonCpp::SecureAllocator<char> >
|
||||||
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, JsonCpp::SecureAllocator<char> >
|
||||||
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
||||||
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, JsonCpp::SecureAllocator<char> >
|
||||||
#define JSONCPP_ISTREAM std::istream
|
#define JSONCPP_ISTREAM std::istream
|
||||||
#else
|
#else
|
||||||
#define JSONCPP_STRING std::string
|
#define JSONCPP_STRING std::string
|
||||||
|
|
@ -264,7 +264,7 @@ typedef UInt64 LargestUInt;
|
||||||
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
||||||
#define JSONCPP_ISTREAM std::istream
|
#define JSONCPP_ISTREAM std::istream
|
||||||
#endif // if JSONCPP_USING_SECURE_MEMORY
|
#endif // if JSONCPP_USING_SECURE_MEMORY
|
||||||
} // end namespace Json
|
} // end namespace JsonCpp
|
||||||
|
|
||||||
#endif // JSON_CONFIG_H_INCLUDED
|
#endif // JSON_CONFIG_H_INCLUDED
|
||||||
|
|
||||||
|
|
@ -293,7 +293,7 @@ typedef UInt64 LargestUInt;
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
// writer.h
|
// writer.h
|
||||||
class FastWriter;
|
class FastWriter;
|
||||||
|
|
@ -315,7 +315,7 @@ class ValueIteratorBase;
|
||||||
class ValueIterator;
|
class ValueIterator;
|
||||||
class ValueConstIterator;
|
class ValueConstIterator;
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace JsonCpp
|
||||||
|
|
||||||
#endif // JSON_FORWARDS_H_INCLUDED
|
#endif // JSON_FORWARDS_H_INCLUDED
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ license you like.
|
||||||
|
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
typedef int Int;
|
typedef int Int;
|
||||||
typedef unsigned int UInt;
|
typedef unsigned int UInt;
|
||||||
#if defined(JSON_NO_INT64)
|
#if defined(JSON_NO_INT64)
|
||||||
|
|
@ -326,7 +326,7 @@ typedef UInt64 LargestUInt;
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
// writer.h
|
// writer.h
|
||||||
class FastWriter;
|
class FastWriter;
|
||||||
|
|
@ -377,7 +377,7 @@ class ValueConstIterator;
|
||||||
#include "forwards.h"
|
#include "forwards.h"
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
/** \brief Configuration passed to reader and writer.
|
/** \brief Configuration passed to reader and writer.
|
||||||
* This configuration object can be used to force the Reader or Writer
|
* This configuration object can be used to force the Reader or Writer
|
||||||
|
|
@ -482,7 +482,7 @@ public:
|
||||||
|
|
||||||
/** \brief JSON (JavaScript Object Notation).
|
/** \brief JSON (JavaScript Object Notation).
|
||||||
*/
|
*/
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
/** Base class for all exceptions we throw.
|
/** Base class for all exceptions we throw.
|
||||||
*
|
*
|
||||||
|
|
@ -616,15 +616,15 @@ public:
|
||||||
typedef std::vector<JSONCPP_STRING> Members;
|
typedef std::vector<JSONCPP_STRING> Members;
|
||||||
typedef ValueIterator iterator;
|
typedef ValueIterator iterator;
|
||||||
typedef ValueConstIterator const_iterator;
|
typedef ValueConstIterator const_iterator;
|
||||||
typedef Json::UInt UInt;
|
typedef JsonCpp::UInt UInt;
|
||||||
typedef Json::Int Int;
|
typedef JsonCpp::Int Int;
|
||||||
#if defined(JSON_HAS_INT64)
|
#if defined(JSON_HAS_INT64)
|
||||||
typedef Json::UInt64 UInt64;
|
typedef JsonCpp::UInt64 UInt64;
|
||||||
typedef Json::Int64 Int64;
|
typedef JsonCpp::Int64 Int64;
|
||||||
#endif // defined(JSON_HAS_INT64)
|
#endif // defined(JSON_HAS_INT64)
|
||||||
typedef Json::LargestInt LargestInt;
|
typedef JsonCpp::LargestInt LargestInt;
|
||||||
typedef Json::LargestUInt LargestUInt;
|
typedef JsonCpp::LargestUInt LargestUInt;
|
||||||
typedef Json::ArrayIndex ArrayIndex;
|
typedef JsonCpp::ArrayIndex ArrayIndex;
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -1294,7 +1294,7 @@ public:
|
||||||
namespace std {
|
namespace std {
|
||||||
/// Specialize std::swap() for Json::Value.
|
/// Specialize std::swap() for Json::Value.
|
||||||
template<>
|
template<>
|
||||||
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
inline void swap(JsonCpp::Value& a, JsonCpp::Value& b) { a.swap(b); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1342,7 +1342,7 @@ inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
||||||
*Value.
|
*Value.
|
||||||
|
|
@ -1649,7 +1649,7 @@ public:
|
||||||
JSON Value.
|
JSON Value.
|
||||||
\sa setDefaults()
|
\sa setDefaults()
|
||||||
*/
|
*/
|
||||||
Json::Value settings_;
|
JsonCpp::Value settings_;
|
||||||
|
|
||||||
CharReaderBuilder();
|
CharReaderBuilder();
|
||||||
~CharReaderBuilder() JSONCPP_OVERRIDE;
|
~CharReaderBuilder() JSONCPP_OVERRIDE;
|
||||||
|
|
@ -1659,7 +1659,7 @@ public:
|
||||||
/** \return true if 'settings' are legal and consistent;
|
/** \return true if 'settings' are legal and consistent;
|
||||||
* otherwise, indicate bad settings via 'invalid'.
|
* otherwise, indicate bad settings via 'invalid'.
|
||||||
*/
|
*/
|
||||||
bool validate(Json::Value* invalid) const;
|
bool validate(JsonCpp::Value* invalid) const;
|
||||||
|
|
||||||
/** A simple way to update a specific setting.
|
/** A simple way to update a specific setting.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1670,13 +1670,13 @@ public:
|
||||||
* \remark Defaults:
|
* \remark Defaults:
|
||||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
||||||
*/
|
*/
|
||||||
static void setDefaults(Json::Value* settings);
|
static void setDefaults(JsonCpp::Value* settings);
|
||||||
/** Same as old Features::strictMode().
|
/** Same as old Features::strictMode().
|
||||||
* \pre 'settings' != NULL (but Json::null is fine)
|
* \pre 'settings' != NULL (but Json::null is fine)
|
||||||
* \remark Defaults:
|
* \remark Defaults:
|
||||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||||
*/
|
*/
|
||||||
static void strictMode(Json::Value* settings);
|
static void strictMode(JsonCpp::Value* settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Consume entire stream and use its begin/end.
|
/** Consume entire stream and use its begin/end.
|
||||||
|
|
@ -1757,7 +1757,7 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
|
||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
|
|
||||||
|
|
@ -1846,7 +1846,7 @@ public:
|
||||||
JSON Value.
|
JSON Value.
|
||||||
\sa setDefaults()
|
\sa setDefaults()
|
||||||
*/
|
*/
|
||||||
Json::Value settings_;
|
JsonCpp::Value settings_;
|
||||||
|
|
||||||
StreamWriterBuilder();
|
StreamWriterBuilder();
|
||||||
~StreamWriterBuilder() JSONCPP_OVERRIDE;
|
~StreamWriterBuilder() JSONCPP_OVERRIDE;
|
||||||
|
|
@ -1859,7 +1859,7 @@ public:
|
||||||
/** \return true if 'settings' are legal and consistent;
|
/** \return true if 'settings' are legal and consistent;
|
||||||
* otherwise, indicate bad settings via 'invalid'.
|
* otherwise, indicate bad settings via 'invalid'.
|
||||||
*/
|
*/
|
||||||
bool validate(Json::Value* invalid) const;
|
bool validate(JsonCpp::Value* invalid) const;
|
||||||
/** A simple way to update a specific setting.
|
/** A simple way to update a specific setting.
|
||||||
*/
|
*/
|
||||||
Value& operator[](JSONCPP_STRING key);
|
Value& operator[](JSONCPP_STRING key);
|
||||||
|
|
@ -1869,7 +1869,7 @@ public:
|
||||||
* \remark Defaults:
|
* \remark Defaults:
|
||||||
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
|
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
|
||||||
*/
|
*/
|
||||||
static void setDefaults(Json::Value* settings);
|
static void setDefaults(JsonCpp::Value* settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Abstract class for writers.
|
/** \brief Abstract class for writers.
|
||||||
|
|
@ -2064,7 +2064,7 @@ JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
|
||||||
/// \see Json::operator>>()
|
/// \see Json::operator>>()
|
||||||
JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace JsonCpp
|
||||||
|
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
@ -2108,12 +2108,12 @@ JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
||||||
|
|
||||||
// @todo <= add detail about condition in exception
|
// @todo <= add detail about condition in exception
|
||||||
# define JSON_ASSERT(condition) \
|
# define JSON_ASSERT(condition) \
|
||||||
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
|
{if (!(condition)) {JsonCpp::throwLogicError( "assert json failed" );}}
|
||||||
|
|
||||||
# define JSON_FAIL_MESSAGE(message) \
|
# define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||||
Json::throwLogicError(oss.str()); \
|
JsonCpp::throwLogicError(oss.str()); \
|
||||||
abort(); \
|
abort(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,7 @@ license you like.
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "json/json.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "json.h"
|
|
||||||
|
|
||||||
#ifndef JSON_IS_AMALGAMATION
|
#ifndef JSON_IS_AMALGAMATION
|
||||||
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
|
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
|
||||||
|
|
@ -108,7 +104,7 @@ license you like.
|
||||||
* It is an internal header that must not be exposed.
|
* It is an internal header that must not be exposed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
static char getDecimalPoint() {
|
static char getDecimalPoint() {
|
||||||
#ifdef JSONCPP_NO_LOCALE_SUPPORT
|
#ifdef JSONCPP_NO_LOCALE_SUPPORT
|
||||||
return '\0';
|
return '\0';
|
||||||
|
|
@ -198,7 +194,7 @@ static inline void fixNumericLocaleInput(char* begin, char* end) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Json {
|
} // namespace JsonCpp {
|
||||||
|
|
||||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
|
||||||
|
|
@ -268,12 +264,12 @@ static int const stackLimit_g = 1000;
|
||||||
static int stackDepth_g = 0; // see readValue()
|
static int stackDepth_g = 0; // see readValue()
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
||||||
typedef std::unique_ptr<CharReader> CharReaderPtr;
|
typedef std::unique_ptr<CharReader> CharReaderPtr;
|
||||||
#else
|
#else
|
||||||
typedef std::unique_ptr<CharReader> CharReaderPtr;
|
typedef std::auto_ptr<CharReader> CharReaderPtr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Implementation of class Features
|
// Implementation of class Features
|
||||||
|
|
@ -2173,11 +2169,11 @@ static void getValidReaderKeys(std::set<JSONCPP_STRING>* valid_keys)
|
||||||
valid_keys->insert("rejectDupKeys");
|
valid_keys->insert("rejectDupKeys");
|
||||||
valid_keys->insert("allowSpecialFloats");
|
valid_keys->insert("allowSpecialFloats");
|
||||||
}
|
}
|
||||||
bool CharReaderBuilder::validate(Json::Value* invalid) const
|
bool CharReaderBuilder::validate(JsonCpp::Value* invalid) const
|
||||||
{
|
{
|
||||||
Json::Value my_invalid;
|
JsonCpp::Value my_invalid;
|
||||||
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
||||||
Json::Value& inv = *invalid;
|
JsonCpp::Value& inv = *invalid;
|
||||||
std::set<JSONCPP_STRING> valid_keys;
|
std::set<JSONCPP_STRING> valid_keys;
|
||||||
getValidReaderKeys(&valid_keys);
|
getValidReaderKeys(&valid_keys);
|
||||||
Value::Members keys = settings_.getMemberNames();
|
Value::Members keys = settings_.getMemberNames();
|
||||||
|
|
@ -2195,7 +2191,7 @@ Value& CharReaderBuilder::operator[](JSONCPP_STRING key)
|
||||||
return settings_[key];
|
return settings_[key];
|
||||||
}
|
}
|
||||||
// static
|
// static
|
||||||
void CharReaderBuilder::strictMode(Json::Value* settings)
|
void CharReaderBuilder::strictMode(JsonCpp::Value* settings)
|
||||||
{
|
{
|
||||||
//! [CharReaderBuilderStrictMode]
|
//! [CharReaderBuilderStrictMode]
|
||||||
(*settings)["allowComments"] = false;
|
(*settings)["allowComments"] = false;
|
||||||
|
|
@ -2210,7 +2206,7 @@ void CharReaderBuilder::strictMode(Json::Value* settings)
|
||||||
//! [CharReaderBuilderStrictMode]
|
//! [CharReaderBuilderStrictMode]
|
||||||
}
|
}
|
||||||
// static
|
// static
|
||||||
void CharReaderBuilder::setDefaults(Json::Value* settings)
|
void CharReaderBuilder::setDefaults(JsonCpp::Value* settings)
|
||||||
{
|
{
|
||||||
//! [CharReaderBuilderDefaults]
|
//! [CharReaderBuilderDefaults]
|
||||||
(*settings)["collectComments"] = true;
|
(*settings)["collectComments"] = true;
|
||||||
|
|
@ -2279,7 +2275,7 @@ JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
|
||||||
|
|
||||||
// included by json_value.cpp
|
// included by json_value.cpp
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -2476,7 +2472,7 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) {
|
||||||
|
|
||||||
#define JSON_ASSERT_UNREACHABLE assert(false)
|
#define JSON_ASSERT_UNREACHABLE assert(false)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
// This is a walkaround to avoid the static initialization of Value::null.
|
// This is a walkaround to avoid the static initialization of Value::null.
|
||||||
// kNull must be word-aligned to avoid crashing on ARM. We use an alignment of
|
// kNull must be word-aligned to avoid crashing on ARM. We use an alignment of
|
||||||
|
|
@ -2528,7 +2524,7 @@ static inline bool InRange(double d, T min, U max) {
|
||||||
return d >= min && d <= max;
|
return d >= min && d <= max;
|
||||||
}
|
}
|
||||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
static inline double integerToDouble(Json::UInt64 value) {
|
static inline double integerToDouble(JsonCpp::UInt64 value) {
|
||||||
return static_cast<double>(Int64(value / 2)) * 2.0 + static_cast<double>(Int64(value & 1));
|
return static_cast<double>(Int64(value / 2)) * 2.0 + static_cast<double>(Int64(value & 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2560,7 +2556,7 @@ static inline char* duplicateStringValue(const char* value,
|
||||||
char* newString = static_cast<char*>(malloc(length + 1));
|
char* newString = static_cast<char*>(malloc(length + 1));
|
||||||
if (newString == NULL) {
|
if (newString == NULL) {
|
||||||
throwRuntimeError(
|
throwRuntimeError(
|
||||||
"in Json::Value::duplicateStringValue(): "
|
"in JsonCpp::Value::duplicateStringValue(): "
|
||||||
"Failed to allocate string value buffer");
|
"Failed to allocate string value buffer");
|
||||||
}
|
}
|
||||||
memcpy(newString, value, length);
|
memcpy(newString, value, length);
|
||||||
|
|
@ -2577,13 +2573,13 @@ static inline char* duplicateAndPrefixStringValue(
|
||||||
// Avoid an integer overflow in the call to malloc below by limiting length
|
// Avoid an integer overflow in the call to malloc below by limiting length
|
||||||
// to a sane value.
|
// to a sane value.
|
||||||
JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
|
JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
|
||||||
"in Json::Value::duplicateAndPrefixStringValue(): "
|
"in JsonCpp::Value::duplicateAndPrefixStringValue(): "
|
||||||
"length too big for prefixing");
|
"length too big for prefixing");
|
||||||
unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
|
unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
|
||||||
char* newString = static_cast<char*>(malloc(actualLength));
|
char* newString = static_cast<char*>(malloc(actualLength));
|
||||||
if (newString == 0) {
|
if (newString == 0) {
|
||||||
throwRuntimeError(
|
throwRuntimeError(
|
||||||
"in Json::Value::duplicateAndPrefixStringValue(): "
|
"in JsonCpp::Value::duplicateAndPrefixStringValue(): "
|
||||||
"Failed to allocate string value buffer");
|
"Failed to allocate string value buffer");
|
||||||
}
|
}
|
||||||
*reinterpret_cast<unsigned*>(newString) = length;
|
*reinterpret_cast<unsigned*>(newString) = length;
|
||||||
|
|
@ -2643,7 +2639,7 @@ static inline void releaseStringValue(char* value, unsigned) {
|
||||||
#include "json_valueiterator.inl"
|
#include "json_valueiterator.inl"
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
Exception::Exception(JSONCPP_STRING const& msg)
|
Exception::Exception(JSONCPP_STRING const& msg)
|
||||||
: msg_(msg)
|
: msg_(msg)
|
||||||
|
|
@ -2693,7 +2689,7 @@ void Value::CommentInfo::setComment(const char* text, size_t len) {
|
||||||
JSON_ASSERT(text != 0);
|
JSON_ASSERT(text != 0);
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
text[0] == '\0' || text[0] == '/',
|
text[0] == '\0' || text[0] == '/',
|
||||||
"in Json::Value::setComment(): Comments must start with /");
|
"in JsonCpp::Value::setComment(): Comments must start with /");
|
||||||
// It seems that /**/ style comments are acceptable as well.
|
// It seems that /**/ style comments are acceptable as well.
|
||||||
comment_ = duplicateStringValue(text, len);
|
comment_ = duplicateStringValue(text, len);
|
||||||
}
|
}
|
||||||
|
|
@ -3050,7 +3046,7 @@ bool Value::operator>(const Value& other) const { return other < *this; }
|
||||||
bool Value::operator==(const Value& other) const {
|
bool Value::operator==(const Value& other) const {
|
||||||
// if ( type_ != other.type_ )
|
// if ( type_ != other.type_ )
|
||||||
// GCC 2.95.3 says:
|
// GCC 2.95.3 says:
|
||||||
// attempt to take address of bit-field structure member `Json::Value::type_'
|
// attempt to take address of bit-field structure member `JsonCpp::Value::type_'
|
||||||
// Beats me, but a temp solves the problem.
|
// Beats me, but a temp solves the problem.
|
||||||
int temp = other.type_;
|
int temp = other.type_;
|
||||||
if (type_ != temp)
|
if (type_ != temp)
|
||||||
|
|
@ -3096,7 +3092,7 @@ bool Value::operator!=(const Value& other) const { return !(*this == other); }
|
||||||
|
|
||||||
const char* Value::asCString() const {
|
const char* Value::asCString() const {
|
||||||
JSON_ASSERT_MESSAGE(type_ == stringValue,
|
JSON_ASSERT_MESSAGE(type_ == stringValue,
|
||||||
"in Json::Value::asCString(): requires stringValue");
|
"in JsonCpp::Value::asCString(): requires stringValue");
|
||||||
if (value_.string_ == 0) return 0;
|
if (value_.string_ == 0) return 0;
|
||||||
unsigned this_len;
|
unsigned this_len;
|
||||||
char const* this_str;
|
char const* this_str;
|
||||||
|
|
@ -3107,7 +3103,7 @@ const char* Value::asCString() const {
|
||||||
#if JSONCPP_USING_SECURE_MEMORY
|
#if JSONCPP_USING_SECURE_MEMORY
|
||||||
unsigned Value::getCStringLength() const {
|
unsigned Value::getCStringLength() const {
|
||||||
JSON_ASSERT_MESSAGE(type_ == stringValue,
|
JSON_ASSERT_MESSAGE(type_ == stringValue,
|
||||||
"in Json::Value::asCString(): requires stringValue");
|
"in JsonCpp::Value::asCString(): requires stringValue");
|
||||||
if (value_.string_ == 0) return 0;
|
if (value_.string_ == 0) return 0;
|
||||||
unsigned this_len;
|
unsigned this_len;
|
||||||
char const* this_str;
|
char const* this_str;
|
||||||
|
|
@ -3398,7 +3394,7 @@ bool Value::operator!() const { return isNull(); }
|
||||||
void Value::clear() {
|
void Value::clear() {
|
||||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
|
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
|
||||||
type_ == objectValue,
|
type_ == objectValue,
|
||||||
"in Json::Value::clear(): requires complex value");
|
"in JsonCpp::Value::clear(): requires complex value");
|
||||||
start_ = 0;
|
start_ = 0;
|
||||||
limit_ = 0;
|
limit_ = 0;
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
|
|
@ -3413,7 +3409,7 @@ void Value::clear() {
|
||||||
|
|
||||||
void Value::resize(ArrayIndex newSize) {
|
void Value::resize(ArrayIndex newSize) {
|
||||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,
|
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,
|
||||||
"in Json::Value::resize(): requires arrayValue");
|
"in JsonCpp::Value::resize(): requires arrayValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(arrayValue);
|
*this = Value(arrayValue);
|
||||||
ArrayIndex oldSize = size();
|
ArrayIndex oldSize = size();
|
||||||
|
|
@ -3432,7 +3428,7 @@ void Value::resize(ArrayIndex newSize) {
|
||||||
Value& Value::operator[](ArrayIndex index) {
|
Value& Value::operator[](ArrayIndex index) {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == arrayValue,
|
type_ == nullValue || type_ == arrayValue,
|
||||||
"in Json::Value::operator[](ArrayIndex): requires arrayValue");
|
"in JsonCpp::Value::operator[](ArrayIndex): requires arrayValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(arrayValue);
|
*this = Value(arrayValue);
|
||||||
CZString key(index);
|
CZString key(index);
|
||||||
|
|
@ -3448,14 +3444,14 @@ Value& Value::operator[](ArrayIndex index) {
|
||||||
Value& Value::operator[](int index) {
|
Value& Value::operator[](int index) {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
index >= 0,
|
index >= 0,
|
||||||
"in Json::Value::operator[](int index): index cannot be negative");
|
"in JsonCpp::Value::operator[](int index): index cannot be negative");
|
||||||
return (*this)[ArrayIndex(index)];
|
return (*this)[ArrayIndex(index)];
|
||||||
}
|
}
|
||||||
|
|
||||||
const Value& Value::operator[](ArrayIndex index) const {
|
const Value& Value::operator[](ArrayIndex index) const {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == arrayValue,
|
type_ == nullValue || type_ == arrayValue,
|
||||||
"in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
|
"in JsonCpp::Value::operator[](ArrayIndex)const: requires arrayValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
return nullSingleton();
|
return nullSingleton();
|
||||||
CZString key(index);
|
CZString key(index);
|
||||||
|
|
@ -3468,7 +3464,7 @@ const Value& Value::operator[](ArrayIndex index) const {
|
||||||
const Value& Value::operator[](int index) const {
|
const Value& Value::operator[](int index) const {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
index >= 0,
|
index >= 0,
|
||||||
"in Json::Value::operator[](int index) const: index cannot be negative");
|
"in JsonCpp::Value::operator[](int index) const: index cannot be negative");
|
||||||
return (*this)[ArrayIndex(index)];
|
return (*this)[ArrayIndex(index)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3486,7 +3482,7 @@ void Value::initBasic(ValueType vtype, bool allocated) {
|
||||||
Value& Value::resolveReference(const char* key) {
|
Value& Value::resolveReference(const char* key) {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == objectValue,
|
type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::resolveReference(): requires objectValue");
|
"in JsonCpp::Value::resolveReference(): requires objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(objectValue);
|
*this = Value(objectValue);
|
||||||
CZString actualKey(
|
CZString actualKey(
|
||||||
|
|
@ -3506,7 +3502,7 @@ Value& Value::resolveReference(char const* key, char const* cend)
|
||||||
{
|
{
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == objectValue,
|
type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::resolveReference(key, end): requires objectValue");
|
"in JsonCpp::Value::resolveReference(key, end): requires objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(objectValue);
|
*this = Value(objectValue);
|
||||||
CZString actualKey(
|
CZString actualKey(
|
||||||
|
|
@ -3532,7 +3528,7 @@ Value const* Value::find(char const* key, char const* cend) const
|
||||||
{
|
{
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == objectValue,
|
type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::find(key, end, found): requires objectValue or nullValue");
|
"in JsonCpp::Value::find(key, end, found): requires objectValue or nullValue");
|
||||||
if (type_ == nullValue) return NULL;
|
if (type_ == nullValue) return NULL;
|
||||||
CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
|
CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
|
||||||
ObjectValues::const_iterator it = value_.map_->find(actualKey);
|
ObjectValues::const_iterator it = value_.map_->find(actualKey);
|
||||||
|
|
@ -3617,7 +3613,7 @@ bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
|
||||||
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,
|
||||||
"in Json::Value::removeMember(): requires objectValue");
|
"in JsonCpp::Value::removeMember(): requires objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
return nullSingleton();
|
return nullSingleton();
|
||||||
|
|
||||||
|
|
@ -3683,7 +3679,7 @@ bool Value::isMember(const CppTL::ConstString& key) const {
|
||||||
Value::Members Value::getMemberNames() const {
|
Value::Members Value::getMemberNames() const {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == objectValue,
|
type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::getMemberNames(), value must be objectValue");
|
"in JsonCpp::Value::getMemberNames(), value must be objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
return Value::Members();
|
return Value::Members();
|
||||||
Members members;
|
Members members;
|
||||||
|
|
@ -4146,12 +4142,12 @@ Value& Path::make(Value& root) const {
|
||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Json {
|
namespace JsonCpp {
|
||||||
|
|
||||||
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
||||||
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
||||||
#else
|
#else
|
||||||
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool containsControlCharacter(const char* str) {
|
static bool containsControlCharacter(const char* str) {
|
||||||
|
|
@ -5246,11 +5242,11 @@ static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
|
||||||
valid_keys->insert("useSpecialFloats");
|
valid_keys->insert("useSpecialFloats");
|
||||||
valid_keys->insert("precision");
|
valid_keys->insert("precision");
|
||||||
}
|
}
|
||||||
bool StreamWriterBuilder::validate(Json::Value* invalid) const
|
bool StreamWriterBuilder::validate(JsonCpp::Value* invalid) const
|
||||||
{
|
{
|
||||||
Json::Value my_invalid;
|
JsonCpp::Value my_invalid;
|
||||||
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
||||||
Json::Value& inv = *invalid;
|
JsonCpp::Value& inv = *invalid;
|
||||||
std::set<JSONCPP_STRING> valid_keys;
|
std::set<JSONCPP_STRING> valid_keys;
|
||||||
getValidWriterKeys(&valid_keys);
|
getValidWriterKeys(&valid_keys);
|
||||||
Value::Members keys = settings_.getMemberNames();
|
Value::Members keys = settings_.getMemberNames();
|
||||||
|
|
@ -5268,7 +5264,7 @@ Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
|
||||||
return settings_[key];
|
return settings_[key];
|
||||||
}
|
}
|
||||||
// static
|
// static
|
||||||
void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
void StreamWriterBuilder::setDefaults(JsonCpp::Value* settings)
|
||||||
{
|
{
|
||||||
//! [StreamWriterBuilderDefaults]
|
//! [StreamWriterBuilderDefaults]
|
||||||
(*settings)["commentStyle"] = "All";
|
(*settings)["commentStyle"] = "All";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue