mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 23:42:51 +02:00
jsoncpp: update to 0.10.5
Origin commit data
------------------
Commit: d74d85d1db
Author: gixxpunk <thomas.harfmann@gmail.com>
Date: 2016-01-16 (Sat, 16 Jan 2016)
Origin message was:
------------------
- jsoncpp: update to 0.10.5
This commit is contained in:
@@ -68,11 +68,6 @@ license you like.
|
|||||||
// End of content of file: LICENSE
|
// End of content of file: LICENSE
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/* 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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -87,16 +82,15 @@ license you like.
|
|||||||
// Beginning of content of file: include/json/version.h
|
// Beginning of content of file: include/json/version.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// DO NOT EDIT. This file is generated by CMake from "version"
|
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
||||||
// and "version.h.in" files.
|
|
||||||
// Run CMake configure step to update it.
|
// Run CMake configure step to update it.
|
||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
|
|
||||||
# define JSONCPP_VERSION_STRING "0.10.2"
|
# define JSONCPP_VERSION_STRING "0.10.5"
|
||||||
# define JSONCPP_VERSION_MAJOR 0
|
# define JSONCPP_VERSION_MAJOR 0
|
||||||
# define JSONCPP_VERSION_MINOR 10
|
# define JSONCPP_VERSION_MINOR 10
|
||||||
# define JSONCPP_VERSION_PATCH 2
|
# define JSONCPP_VERSION_PATCH 5
|
||||||
# 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))
|
||||||
|
|
||||||
@@ -393,21 +387,36 @@ namespace Json {
|
|||||||
*
|
*
|
||||||
* We use nothing but these internally. Of course, STL can throw others.
|
* We use nothing but these internally. Of course, STL can throw others.
|
||||||
*/
|
*/
|
||||||
class JSON_API Exception;
|
class JSON_API Exception : public std::exception {
|
||||||
|
public:
|
||||||
|
Exception(std::string const& msg);
|
||||||
|
virtual ~Exception() throw();
|
||||||
|
virtual char const* what() const throw();
|
||||||
|
protected:
|
||||||
|
std::string const msg_;
|
||||||
|
};
|
||||||
|
|
||||||
/** 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;
|
class JSON_API RuntimeError : public Exception {
|
||||||
|
public:
|
||||||
|
RuntimeError(std::string const& msg);
|
||||||
|
};
|
||||||
|
|
||||||
/** 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;
|
class JSON_API LogicError : public Exception {
|
||||||
|
public:
|
||||||
|
LogicError(std::string const& msg);
|
||||||
|
};
|
||||||
|
|
||||||
/// used internally
|
/// used internally
|
||||||
void throwRuntimeError(std::string const& msg);
|
void throwRuntimeError(std::string const& msg);
|
||||||
@@ -570,7 +579,7 @@ private:
|
|||||||
void swap(CZString& other);
|
void swap(CZString& other);
|
||||||
|
|
||||||
struct StringStorage {
|
struct StringStorage {
|
||||||
DuplicationPolicy policy_: 2;
|
unsigned policy_: 2;
|
||||||
unsigned length_: 30; // 1GB max
|
unsigned length_: 30; // 1GB max
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -614,7 +623,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
#endif // if defined(JSON_HAS_INT64)
|
#endif // if defined(JSON_HAS_INT64)
|
||||||
Value(double value);
|
Value(double value);
|
||||||
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
||||||
Value(const char* beginValue, const char* endValue); ///< Copy all, incl zeroes.
|
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
|
||||||
/** \brief Constructs a value from a static string.
|
/** \brief Constructs a value from a static string.
|
||||||
|
|
||||||
* Like other value string constructor but do not duplicate the string for
|
* Like other value string constructor but do not duplicate the string for
|
||||||
@@ -665,7 +674,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
* \return false if !string. (Seg-fault if str or end are NULL.)
|
* \return false if !string. (Seg-fault if str or end are NULL.)
|
||||||
*/
|
*/
|
||||||
bool getString(
|
bool getString(
|
||||||
char const** str, char const** end) const;
|
char const** begin, char const** end) const;
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
CppTL::ConstString asConstString() const;
|
CppTL::ConstString asConstString() const;
|
||||||
#endif
|
#endif
|
||||||
@@ -794,8 +803,8 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
Value get(const char* key, const Value& defaultValue) const;
|
Value get(const char* key, const Value& defaultValue) const;
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
/// \note deep copy
|
/// \note deep copy
|
||||||
/// \param key may contain embedded nulls.
|
/// \note key may contain embedded nulls.
|
||||||
Value get(const char* key, const char* end, const Value& defaultValue) const;
|
Value get(const char* begin, const char* end, const Value& defaultValue) const;
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
/// \note deep copy
|
/// \note deep copy
|
||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
@@ -807,12 +816,12 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
#endif
|
#endif
|
||||||
/// Most general and efficient version of isMember()const, get()const,
|
/// Most general and efficient version of isMember()const, get()const,
|
||||||
/// and operator[]const
|
/// and operator[]const
|
||||||
/// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30
|
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||||
Value const* find(char const* key, char const* end) const;
|
Value const* find(char const* begin, char const* end) const;
|
||||||
/// Most general and efficient version of object-mutators.
|
/// Most general and efficient version of object-mutators.
|
||||||
/// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30
|
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||||
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
||||||
Value const* demand(char const* key, char const* end);
|
Value const* demand(char const* begin, char const* end);
|
||||||
/// \brief Remove and return the named member.
|
/// \brief Remove and return the named member.
|
||||||
///
|
///
|
||||||
/// Do nothing if it did not exist.
|
/// Do nothing if it did not exist.
|
||||||
@@ -825,7 +834,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
Value removeMember(const std::string& key);
|
Value removeMember(const std::string& key);
|
||||||
/// Same as removeMember(const char* key, 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.
|
||||||
bool removeMember(const char* key, Value* removed);
|
bool removeMember(const char* key, Value* removed);
|
||||||
/** \brief Remove the named map member.
|
/** \brief Remove the named map member.
|
||||||
@@ -836,7 +845,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
*/
|
*/
|
||||||
bool removeMember(std::string const& key, Value* removed);
|
bool removeMember(std::string const& key, Value* removed);
|
||||||
/// Same as removeMember(std::string const& key, Value* removed)
|
/// Same as removeMember(std::string const& key, Value* removed)
|
||||||
bool removeMember(const char* key, const char* end, Value* removed);
|
bool removeMember(const char* begin, const char* end, Value* removed);
|
||||||
/** \brief Remove the indexed array element.
|
/** \brief Remove the indexed array element.
|
||||||
|
|
||||||
O(n) expensive operations.
|
O(n) expensive operations.
|
||||||
@@ -852,7 +861,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
bool isMember(const std::string& key) const;
|
bool isMember(const std::string& key) const;
|
||||||
/// Same as isMember(std::string const& key)const
|
/// Same as isMember(std::string const& key)const
|
||||||
bool isMember(const char* key, const char* end) const;
|
bool isMember(const char* begin, const char* end) const;
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
/// Return true if the object has a member named key.
|
/// Return true if the object has a member named key.
|
||||||
bool isMember(const CppTL::ConstString& key) const;
|
bool isMember(const CppTL::ConstString& key) const;
|
||||||
@@ -1000,9 +1009,6 @@ public:
|
|||||||
typedef int difference_type;
|
typedef int difference_type;
|
||||||
typedef ValueIteratorBase SelfType;
|
typedef ValueIteratorBase SelfType;
|
||||||
|
|
||||||
ValueIteratorBase();
|
|
||||||
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
|
||||||
|
|
||||||
bool operator==(const SelfType& other) const { return isEqual(other); }
|
bool operator==(const SelfType& other) const { return isEqual(other); }
|
||||||
|
|
||||||
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
||||||
@@ -1050,6 +1056,12 @@ private:
|
|||||||
Value::ObjectValues::iterator current_;
|
Value::ObjectValues::iterator current_;
|
||||||
// Indicates that iterator is for a null value.
|
// Indicates that iterator is for a null value.
|
||||||
bool isNull_;
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief const iterator for object and array value.
|
/** \brief const iterator for object and array value.
|
||||||
@@ -1486,13 +1498,13 @@ public:
|
|||||||
/** Called by ctor, but you can use this to reset settings_.
|
/** Called by ctor, but you can use this to reset settings_.
|
||||||
* \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 CharReaderBuilderDefaults
|
||||||
*/
|
*/
|
||||||
static void setDefaults(Json::Value* settings);
|
static void setDefaults(Json::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 CharReaderBuilderDefaults
|
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||||
*/
|
*/
|
||||||
static void strictMode(Json::Value* settings);
|
static void strictMode(Json::Value* settings);
|
||||||
};
|
};
|
||||||
|
@@ -116,8 +116,8 @@ static inline std::string codePointToUTF8(unsigned int cp) {
|
|||||||
} else if (cp <= 0xFFFF) {
|
} else if (cp <= 0xFFFF) {
|
||||||
result.resize(3);
|
result.resize(3);
|
||||||
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
|
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
||||||
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
|
result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
|
||||||
} else if (cp <= 0x10FFFF) {
|
} else if (cp <= 0x10FFFF) {
|
||||||
result.resize(4);
|
result.resize(4);
|
||||||
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
@@ -129,7 +129,7 @@ static inline std::string codePointToUTF8(unsigned int cp) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if ch is a control character (in range [0,32[).
|
/// Returns true if ch is a control character (in range [1,31]).
|
||||||
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
|
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -149,7 +149,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
|
|||||||
static inline void uintToString(LargestUInt value, char*& current) {
|
static inline void uintToString(LargestUInt value, char*& current) {
|
||||||
*--current = 0;
|
*--current = 0;
|
||||||
do {
|
do {
|
||||||
*--current = char(value % 10) + '0';
|
*--current = static_cast<signed char>(value % 10U + static_cast<unsigned>('0'));
|
||||||
value /= 10;
|
value /= 10;
|
||||||
} while (value != 0);
|
} while (value != 0);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ static inline void fixNumericLocale(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>
|
||||||
@@ -219,11 +219,7 @@ static int stackDepth_g = 0; // see readValue()
|
|||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
typedef std::unique_ptr<CharReader> CharReaderPtr;
|
|
||||||
#else
|
|
||||||
typedef std::auto_ptr<CharReader> CharReaderPtr;
|
typedef std::auto_ptr<CharReader> CharReaderPtr;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Implementation of class Features
|
// Implementation of class Features
|
||||||
// ////////////////////////////////
|
// ////////////////////////////////
|
||||||
@@ -748,33 +744,9 @@ bool Reader::decodeDouble(Token& token) {
|
|||||||
|
|
||||||
bool Reader::decodeDouble(Token& token, Value& decoded) {
|
bool Reader::decodeDouble(Token& token, Value& decoded) {
|
||||||
double value = 0;
|
double value = 0;
|
||||||
const int bufferSize = 32;
|
std::string buffer(token.start_, token.end_);
|
||||||
int count;
|
std::istringstream is(buffer);
|
||||||
int length = int(token.end_ - token.start_);
|
if (!(is >> value))
|
||||||
|
|
||||||
// Sanity check to avoid buffer overflow exploits.
|
|
||||||
if (length < 0) {
|
|
||||||
return addError("Unable to parse token length", token);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Avoid using a string constant for the format control string given to
|
|
||||||
// sscanf, as this can cause hard to debug crashes on OS X. See here for more
|
|
||||||
// info:
|
|
||||||
//
|
|
||||||
// http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
|
|
||||||
char format[] = "%lf";
|
|
||||||
|
|
||||||
if (length <= bufferSize) {
|
|
||||||
Char buffer[bufferSize + 1];
|
|
||||||
memcpy(buffer, token.start_, length);
|
|
||||||
buffer[length] = 0;
|
|
||||||
count = sscanf(buffer, format, &value);
|
|
||||||
} else {
|
|
||||||
std::string buffer(token.start_, token.end_);
|
|
||||||
count = sscanf(buffer.c_str(), format, &value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count != 1)
|
|
||||||
return addError("'" + std::string(token.start_, token.end_) +
|
return addError("'" + std::string(token.start_, token.end_) +
|
||||||
"' is not a number.",
|
"' is not a number.",
|
||||||
token);
|
token);
|
||||||
@@ -2128,26 +2100,26 @@ UInt ValueIteratorBase::index() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string ValueIteratorBase::name() const {
|
std::string ValueIteratorBase::name() const {
|
||||||
char const* mykey;
|
char const* keey;
|
||||||
char const* end;
|
char const* end;
|
||||||
mykey = memberName(&end);
|
keey = memberName(&end);
|
||||||
if (!mykey) return std::string();
|
if (!keey) return std::string();
|
||||||
return std::string(mykey, end);
|
return std::string(keey, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* ValueIteratorBase::memberName() const {
|
char const* ValueIteratorBase::memberName() const {
|
||||||
const char* myname = (*current_).first.data();
|
const char* cname = (*current_).first.data();
|
||||||
return myname ? myname : "";
|
return cname ? cname : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* ValueIteratorBase::memberName(char const** end) const {
|
char const* ValueIteratorBase::memberName(char const** end) const {
|
||||||
const char* myname = (*current_).first.data();
|
const char* cname = (*current_).first.data();
|
||||||
if (!myname) {
|
if (!cname) {
|
||||||
*end = NULL;
|
*end = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*end = myname + (*current_).first.length();
|
*end = cname + (*current_).first.length();
|
||||||
return myname;
|
return cname;
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
@@ -2223,7 +2195,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
|
||||||
@@ -2320,7 +2292,7 @@ static inline char* duplicateAndPrefixStringValue(
|
|||||||
JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U,
|
JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U,
|
||||||
"in Json::Value::duplicateAndPrefixStringValue(): "
|
"in Json::Value::duplicateAndPrefixStringValue(): "
|
||||||
"length too big for prefixing");
|
"length too big for prefixing");
|
||||||
unsigned actualLength = length + 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(
|
||||||
@@ -2337,7 +2309,7 @@ inline static void decodePrefixedString(
|
|||||||
unsigned* length, char const** value)
|
unsigned* length, char const** value)
|
||||||
{
|
{
|
||||||
if (!isPrefixed) {
|
if (!isPrefixed) {
|
||||||
*length = strlen(prefixed);
|
*length = static_cast<unsigned>(strlen(prefixed));
|
||||||
*value = prefixed;
|
*value = prefixed;
|
||||||
} else {
|
} else {
|
||||||
*length = *reinterpret_cast<unsigned const*>(prefixed);
|
*length = *reinterpret_cast<unsigned const*>(prefixed);
|
||||||
@@ -2364,23 +2336,6 @@ static inline void releaseStringValue(char* value) { free(value); }
|
|||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
class JSON_API Exception : public std::exception {
|
|
||||||
public:
|
|
||||||
Exception(std::string const& msg);
|
|
||||||
virtual ~Exception() throw();
|
|
||||||
virtual char const* what() const throw();
|
|
||||||
protected:
|
|
||||||
std::string const msg_;
|
|
||||||
};
|
|
||||||
class JSON_API RuntimeError : public Exception {
|
|
||||||
public:
|
|
||||||
RuntimeError(std::string const& msg);
|
|
||||||
};
|
|
||||||
class JSON_API LogicError : public Exception {
|
|
||||||
public:
|
|
||||||
LogicError(std::string const& msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
Exception::Exception(std::string const& msg)
|
Exception::Exception(std::string const& msg)
|
||||||
: msg_(msg)
|
: msg_(msg)
|
||||||
{}
|
{}
|
||||||
@@ -2450,8 +2405,8 @@ Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy a
|
|||||||
: cstr_(str)
|
: cstr_(str)
|
||||||
{
|
{
|
||||||
// allocate != duplicate
|
// allocate != duplicate
|
||||||
storage_.policy_ = allocate;
|
storage_.policy_ = allocate & 0x3;
|
||||||
storage_.length_ = ulength;
|
storage_.length_ = ulength & 0x3FFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::CZString::CZString(const CZString& other)
|
Value::CZString::CZString(const CZString& other)
|
||||||
@@ -2460,9 +2415,9 @@ Value::CZString::CZString(const CZString& other)
|
|||||||
: other.cstr_)
|
: other.cstr_)
|
||||||
{
|
{
|
||||||
storage_.policy_ = (other.cstr_
|
storage_.policy_ = (other.cstr_
|
||||||
? (other.storage_.policy_ == noDuplication
|
? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
|
||||||
? noDuplication : duplicate)
|
? noDuplication : duplicate)
|
||||||
: other.storage_.policy_);
|
: static_cast<DuplicationPolicy>(other.storage_.policy_));
|
||||||
storage_.length_ = other.storage_.length_;
|
storage_.length_ = other.storage_.length_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2691,7 +2646,7 @@ void Value::swapPayload(Value& other) {
|
|||||||
std::swap(value_, other.value_);
|
std::swap(value_, other.value_);
|
||||||
int temp2 = allocated_;
|
int temp2 = allocated_;
|
||||||
allocated_ = other.allocated_;
|
allocated_ = other.allocated_;
|
||||||
other.allocated_ = temp2;
|
other.allocated_ = temp2 & 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::swap(Value& other) {
|
void Value::swap(Value& other) {
|
||||||
@@ -2817,12 +2772,12 @@ const char* Value::asCString() const {
|
|||||||
return this_str;
|
return this_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::getString(char const** str, char const** myend) const {
|
bool Value::getString(char const** str, char const** cend) const {
|
||||||
if (type_ != stringValue) return false;
|
if (type_ != stringValue) return false;
|
||||||
if (value_.string_ == 0) return false;
|
if (value_.string_ == 0) return false;
|
||||||
unsigned length;
|
unsigned length;
|
||||||
decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
|
decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
|
||||||
*myend = *str + length;
|
*cend = *str + length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3021,7 +2976,8 @@ bool Value::asBool() const {
|
|||||||
case uintValue:
|
case uintValue:
|
||||||
return value_.uint_ ? true : false;
|
return value_.uint_ ? true : false;
|
||||||
case realValue:
|
case realValue:
|
||||||
return value_.real_ ? true : false;
|
// This is kind of strange. Not recommended.
|
||||||
|
return (value_.real_ != 0.0) ? true : false;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3197,15 +3153,15 @@ Value& Value::resolveReference(const char* key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @param key is not null-terminated.
|
// @param key is not null-terminated.
|
||||||
Value& Value::resolveReference(char const* key, char const* myend)
|
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, myend): requires objectValue");
|
"in Json::Value::resolveReference(key, end): requires objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(objectValue);
|
*this = Value(objectValue);
|
||||||
CZString actualKey(
|
CZString actualKey(
|
||||||
key, static_cast<unsigned>(myend-key), CZString::duplicateOnCopy);
|
key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);
|
||||||
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
|
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
|
||||||
if (it != value_.map_->end() && (*it).first == actualKey)
|
if (it != value_.map_->end() && (*it).first == actualKey)
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
@@ -3223,13 +3179,13 @@ Value Value::get(ArrayIndex index, const Value& defaultValue) const {
|
|||||||
|
|
||||||
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
|
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
|
||||||
|
|
||||||
Value const* Value::find(char const* key, char const* myend) const
|
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, myend, found): requires objectValue or nullValue");
|
"in Json::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>(myend-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);
|
||||||
if (it == value_.map_->end()) return NULL;
|
if (it == value_.map_->end()) return NULL;
|
||||||
return &(*it).second;
|
return &(*it).second;
|
||||||
@@ -3273,9 +3229,9 @@ 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; }
|
||||||
|
|
||||||
Value Value::get(char const* key, char const* myend, Value const& defaultValue) const
|
Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
|
||||||
{
|
{
|
||||||
Value const* found = find(key, myend);
|
Value const* found = find(key, cend);
|
||||||
return !found ? defaultValue : *found;
|
return !found ? defaultValue : *found;
|
||||||
}
|
}
|
||||||
Value Value::get(char const* key, Value const& defaultValue) const
|
Value Value::get(char const* key, Value const& defaultValue) const
|
||||||
@@ -3288,12 +3244,12 @@ Value Value::get(std::string const& key, Value const& defaultValue) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Value::removeMember(const char* key, const char* myend, Value* removed)
|
bool Value::removeMember(const char* key, const char* cend, Value* removed)
|
||||||
{
|
{
|
||||||
if (type_ != objectValue) {
|
if (type_ != objectValue) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CZString actualKey(key, static_cast<unsigned>(myend-key), CZString::noDuplication);
|
CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
|
||||||
ObjectValues::iterator it = value_.map_->find(actualKey);
|
ObjectValues::iterator it = value_.map_->find(actualKey);
|
||||||
if (it == value_.map_->end())
|
if (it == value_.map_->end())
|
||||||
return false;
|
return false;
|
||||||
@@ -3338,8 +3294,8 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
|||||||
ArrayIndex oldSize = size();
|
ArrayIndex oldSize = size();
|
||||||
// shift left all items left, into the place of the "removed"
|
// shift left all items left, into the place of the "removed"
|
||||||
for (ArrayIndex i = index; i < (oldSize - 1); ++i){
|
for (ArrayIndex i = index; i < (oldSize - 1); ++i){
|
||||||
CZString mykey(i);
|
CZString keey(i);
|
||||||
(*value_.map_)[mykey] = (*this)[i + 1];
|
(*value_.map_)[keey] = (*this)[i + 1];
|
||||||
}
|
}
|
||||||
// erase the last one ("leftover")
|
// erase the last one ("leftover")
|
||||||
CZString keyLast(oldSize - 1);
|
CZString keyLast(oldSize - 1);
|
||||||
@@ -3355,9 +3311,9 @@ Value Value::get(const CppTL::ConstString& key,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool Value::isMember(char const* key, char const* myend) const
|
bool Value::isMember(char const* key, char const* cend) const
|
||||||
{
|
{
|
||||||
Value const* value = find(key, myend);
|
Value const* value = find(key, cend);
|
||||||
return NULL != value;
|
return NULL != value;
|
||||||
}
|
}
|
||||||
bool Value::isMember(char const* key) const
|
bool Value::isMember(char const* key) const
|
||||||
@@ -3769,7 +3725,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>
|
||||||
|
|
||||||
@@ -3786,10 +3742,18 @@ Value& Path::make(Value& root) const {
|
|||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
|
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
|
#elif defined(__ANDROID__)
|
||||||
|
#define snprintf snprintf
|
||||||
#elif __cplusplus >= 201103L
|
#elif __cplusplus >= 201103L
|
||||||
#define snprintf std::snprintf
|
#define snprintf std::snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BORLANDC__)
|
||||||
|
#include <float.h>
|
||||||
|
#define isfinite _finite
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
|
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
|
||||||
// Disable warning about strdup being deprecated.
|
// Disable warning about strdup being deprecated.
|
||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
@@ -3797,11 +3761,7 @@ Value& Path::make(Value& root) const {
|
|||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
|
||||||
#else
|
|
||||||
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool containsControlCharacter(const char* str) {
|
static bool containsControlCharacter(const char* str) {
|
||||||
while (*str) {
|
while (*str) {
|
||||||
@@ -4096,7 +4056,7 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
const std::string& name = *it;
|
const std::string& name = *it;
|
||||||
if (it != members.begin())
|
if (it != members.begin())
|
||||||
document_ += ',';
|
document_ += ',';
|
||||||
document_ += valueToQuotedStringN(name.data(), name.length());
|
document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
|
||||||
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
|
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
|
||||||
writeValue(value[name]);
|
writeValue(value[name]);
|
||||||
}
|
}
|
||||||
@@ -4656,7 +4616,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|||||||
std::string const& name = *it;
|
std::string const& name = *it;
|
||||||
Value const& childValue = value[name];
|
Value const& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedStringN(name.data(), name.length()));
|
writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
|
||||||
*sout_ << colonSymbol_;
|
*sout_ << colonSymbol_;
|
||||||
writeValue(childValue);
|
writeValue(childValue);
|
||||||
if (++it == members.end()) {
|
if (++it == members.end()) {
|
||||||
|
Reference in New Issue
Block a user