tidy up after merge from master
This commit is contained in:
parent
794248ee62
commit
7cad78e236
@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
||||||
if(POLICY CMP0025)
|
if(POLICY CMP0025)
|
||||||
# detect Apple's Clang
|
# detect Apple's Clang
|
||||||
cmake_policy(SET CMP0025 NEW)
|
cmake_policy(SET CMP0025 NEW)
|
||||||
|
Binary file not shown.
@ -41,7 +41,8 @@ static std::string GetString(const ValueType& val) {
|
|||||||
s << "false";
|
s << "false";
|
||||||
else if (val.IsFloat())
|
else if (val.IsFloat())
|
||||||
s << val.GetFloat();
|
s << val.GetFloat();
|
||||||
return s.str();}
|
return s.str();
|
||||||
|
}
|
||||||
|
|
||||||
// Create the error message for a named error
|
// Create the error message for a named error
|
||||||
// The error object can either be empty or contain at least member properties:
|
// The error object can either be empty or contain at least member properties:
|
||||||
|
@ -57,10 +57,10 @@ static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an i
|
|||||||
supplied tokens eliminates these.
|
supplied tokens eliminates these.
|
||||||
|
|
||||||
GenericPointer depends on GenericDocument and GenericValue.
|
GenericPointer depends on GenericDocument and GenericValue.
|
||||||
|
|
||||||
\tparam ValueType The value type of the DOM tree. E.g. GenericValue<UTF8<> >
|
\tparam ValueType The value type of the DOM tree. E.g. GenericValue<UTF8<> >
|
||||||
\tparam Allocator The allocator type for allocating memory for internal representation.
|
\tparam Allocator The allocator type for allocating memory for internal representation.
|
||||||
|
|
||||||
\note GenericPointer uses same encoding of ValueType.
|
\note GenericPointer uses same encoding of ValueType.
|
||||||
However, Allocator of GenericPointer is independent of Allocator of Value.
|
However, Allocator of GenericPointer is independent of Allocator of Value.
|
||||||
*/
|
*/
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
typedef GenericUri<ValueType, Allocator> UriType;
|
typedef GenericUri<ValueType, Allocator> UriType;
|
||||||
|
|
||||||
|
|
||||||
//! A token is the basic units of internal representation.
|
//! A token is the basic units of internal representation.
|
||||||
/*!
|
/*!
|
||||||
A JSON pointer string representation "/foo/123" is parsed to two tokens:
|
A JSON pointer string representation "/foo/123" is parsed to two tokens:
|
||||||
"foo" and 123. 123 will be represented in both numeric form and string form.
|
"foo" and 123. 123 will be represented in both numeric form and string form.
|
||||||
@ -689,7 +689,7 @@ public:
|
|||||||
ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* defaultValue) const {
|
ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* defaultValue) const {
|
||||||
return GetWithDefault(document, defaultValue, document.GetAllocator());
|
return GetWithDefault(document, defaultValue, document.GetAllocator());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RAPIDJSON_HAS_STDSTRING
|
#if RAPIDJSON_HAS_STDSTRING
|
||||||
//! Query a value in a document with default std::basic_string.
|
//! Query a value in a document with default std::basic_string.
|
||||||
template <typename stackAllocator>
|
template <typename stackAllocator>
|
||||||
@ -983,7 +983,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// Escaping "~0" -> '~', "~1" -> '/'
|
// Escaping "~0" -> '~', "~1" -> '/'
|
||||||
if (c == '~') {
|
if (c == '~') {
|
||||||
if (i < length) {
|
if (i < length) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Tencent is pleased to support the open source community by making RapidJSON available.
|
// Tencent is pleased to support the open source community by making RapidJSON available.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
||||||
//
|
//
|
||||||
// Licensed under the MIT License (the "License"); you may not use this file except
|
// Licensed under the MIT License (the "License"); you may not use this file except
|
||||||
@ -7,9 +7,9 @@
|
|||||||
//
|
//
|
||||||
// http://opensource.org/licenses/MIT
|
// http://opensource.org/licenses/MIT
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software distributed
|
// Unless required by applicable law or agreed to in writing, software distributed
|
||||||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
// specific language governing permissions and limitations under the License.
|
// specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
#ifndef RAPIDJSON_RAPIDJSON_H_
|
#ifndef RAPIDJSON_RAPIDJSON_H_
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
/*!\file rapidjson.h
|
/*!\file rapidjson.h
|
||||||
\brief common definitions and configuration
|
\brief common definitions and configuration
|
||||||
|
|
||||||
\see RAPIDJSON_CONFIG
|
\see RAPIDJSON_CONFIG
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -195,7 +195,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef RAPIDJSON_NO_INT64DEFINE
|
#ifndef RAPIDJSON_NO_INT64DEFINE
|
||||||
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
|
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1800) // Visual Studio 2013
|
#if defined(_MSC_VER) && (_MSC_VER < 1800) // Visual Studio 2013
|
||||||
#include "msinttypes/stdint.h"
|
#include "msinttypes/stdint.h"
|
||||||
#include "msinttypes/inttypes.h"
|
#include "msinttypes/inttypes.h"
|
||||||
#else
|
#else
|
||||||
@ -277,7 +277,7 @@
|
|||||||
# elif defined(RAPIDJSON_DOXYGEN_RUNNING)
|
# elif defined(RAPIDJSON_DOXYGEN_RUNNING)
|
||||||
# define RAPIDJSON_ENDIAN
|
# define RAPIDJSON_ENDIAN
|
||||||
# else
|
# else
|
||||||
# error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
|
# error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
|
||||||
# endif
|
# endif
|
||||||
#endif // RAPIDJSON_ENDIAN
|
#endif // RAPIDJSON_ENDIAN
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ RAPIDJSON_NAMESPACE_END
|
|||||||
|
|
||||||
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
|
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
|
||||||
|
|
||||||
#define RAPIDJSON_MULTILINEMACRO_BEGIN do {
|
#define RAPIDJSON_MULTILINEMACRO_BEGIN do {
|
||||||
#define RAPIDJSON_MULTILINEMACRO_END \
|
#define RAPIDJSON_MULTILINEMACRO_END \
|
||||||
} while((void)0, 0)
|
} while((void)0, 0)
|
||||||
|
|
||||||
@ -731,7 +731,7 @@ enum Type {
|
|||||||
kFalseType = 1, //!< false
|
kFalseType = 1, //!< false
|
||||||
kTrueType = 2, //!< true
|
kTrueType = 2, //!< true
|
||||||
kObjectType = 3, //!< object
|
kObjectType = 3, //!< object
|
||||||
kArrayType = 4, //!< array
|
kArrayType = 4, //!< array
|
||||||
kStringType = 5, //!< string
|
kStringType = 5, //!< string
|
||||||
kNumberType = 6 //!< number
|
kNumberType = 6 //!< number
|
||||||
};
|
};
|
||||||
|
@ -50,10 +50,6 @@
|
|||||||
#define RAPIDJSON_SCHEMA_VERBOSE 0
|
#define RAPIDJSON_SCHEMA_VERBOSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if RAPIDJSON_SCHEMA_VERBOSE
|
|
||||||
#include "stringbuffer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RAPIDJSON_DIAG_PUSH
|
RAPIDJSON_DIAG_PUSH
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
@ -1309,6 +1305,8 @@ private:
|
|||||||
else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);
|
else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates parallel validators for allOf, anyOf, oneOf, not and schema dependencies, if required.
|
||||||
|
// Also creates a hasher for enums and array uniqueness, if required.
|
||||||
bool CreateParallelValidator(Context& context) const {
|
bool CreateParallelValidator(Context& context) const {
|
||||||
if (enum_ || context.arrayUniqueness)
|
if (enum_ || context.arrayUniqueness)
|
||||||
context.hasher = context.factory.CreateHasher();
|
context.hasher = context.factory.CreateHasher();
|
||||||
|
@ -77,7 +77,7 @@ static void TestFileStream() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen(filename, "r");
|
fp = fopen(filename, "r");
|
||||||
ASSERT_TRUE( fp != NULL );
|
ASSERT_TRUE( fp != NULL );
|
||||||
for (const char* p = s; *p; p++)
|
for (const char* p = s; *p; p++)
|
||||||
EXPECT_EQ(*p, static_cast<char>(fgetc(fp)));
|
EXPECT_EQ(*p, static_cast<char>(fgetc(fp)));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -475,7 +475,7 @@ TEST(Pointer, CopyConstructor) {
|
|||||||
EXPECT_EQ(1u, q.GetTokens()[1].length);
|
EXPECT_EQ(1u, q.GetTokens()[1].length);
|
||||||
EXPECT_STREQ("0", q.GetTokens()[1].name);
|
EXPECT_STREQ("0", q.GetTokens()[1].name);
|
||||||
EXPECT_EQ(0u, q.GetTokens()[1].index);
|
EXPECT_EQ(0u, q.GetTokens()[1].index);
|
||||||
|
|
||||||
// Copied pointer needs to have its own allocator
|
// Copied pointer needs to have its own allocator
|
||||||
EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
|
EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
|
||||||
}
|
}
|
||||||
@ -1727,4 +1727,4 @@ TEST(Pointer, Issue1899) {
|
|||||||
EXPECT_TRUE(PointerType("/foo/1234") == q);
|
EXPECT_TRUE(PointerType("/foo/1234") == q);
|
||||||
q = q.Append("");
|
q = q.Append("");
|
||||||
EXPECT_TRUE(PointerType("/foo/1234/") == q);
|
EXPECT_TRUE(PointerType("/foo/1234/") == q);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ TEST(Uri, Parse_UTF16) {
|
|||||||
#if RAPIDJSON_HAS_STDSTRING
|
#if RAPIDJSON_HAS_STDSTRING
|
||||||
typedef std::basic_string<Value16::Ch> String;
|
typedef std::basic_string<Value16::Ch> String;
|
||||||
String str = L"http://auth/path/xxx?query#frag";
|
String str = L"http://auth/path/xxx?query#frag";
|
||||||
const UriType uri = UriType(str);
|
const UriType uri = UriType(str, &allocator);
|
||||||
EXPECT_TRUE(UriType::GetScheme(uri) == L"http:");
|
EXPECT_TRUE(UriType::GetScheme(uri) == L"http:");
|
||||||
EXPECT_TRUE(UriType::GetAuth(uri) == L"//auth");
|
EXPECT_TRUE(UriType::GetAuth(uri) == L"//auth");
|
||||||
EXPECT_TRUE(UriType::GetPath(uri) == L"/path/xxx");
|
EXPECT_TRUE(UriType::GetPath(uri) == L"/path/xxx");
|
||||||
|
@ -1060,7 +1060,7 @@ static void TestArray(T& x, Allocator& allocator) {
|
|||||||
x.Clear();
|
x.Clear();
|
||||||
for (unsigned i = 0; i < n; i++)
|
for (unsigned i = 0; i < n; i++)
|
||||||
x.PushBack(Value(kArrayType).PushBack(i, allocator).Move(), allocator);
|
x.PushBack(Value(kArrayType).PushBack(i, allocator).Move(), allocator);
|
||||||
|
|
||||||
itr = x.Erase(x.Begin() + first, x.Begin() + last);
|
itr = x.Erase(x.Begin() + first, x.Begin() + last);
|
||||||
if (last == n)
|
if (last == n)
|
||||||
EXPECT_EQ(x.End(), itr);
|
EXPECT_EQ(x.End(), itr);
|
||||||
@ -1556,7 +1556,7 @@ TEST(Value, ObjectHelper) {
|
|||||||
EXPECT_STREQ("apple", y["a"].GetString());
|
EXPECT_STREQ("apple", y["a"].GetString());
|
||||||
EXPECT_TRUE(x.IsObject()); // Invariant
|
EXPECT_TRUE(x.IsObject()); // Invariant
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Value x(kObjectType);
|
Value x(kObjectType);
|
||||||
x.AddMember("a", "apple", allocator);
|
x.AddMember("a", "apple", allocator);
|
||||||
@ -1674,7 +1674,7 @@ TEST(Value, BigNestedObject) {
|
|||||||
for (SizeType i = 0; i < n; i++) {
|
for (SizeType i = 0; i < n; i++) {
|
||||||
char name1[10];
|
char name1[10];
|
||||||
sprintf(name1, "%d", i);
|
sprintf(name1, "%d", i);
|
||||||
|
|
||||||
for (SizeType j = 0; j < n; j++) {
|
for (SizeType j = 0; j < n; j++) {
|
||||||
char name2[10];
|
char name2[10];
|
||||||
sprintf(name2, "%d", j);
|
sprintf(name2, "%d", j);
|
||||||
@ -1689,8 +1689,8 @@ TEST(Value, BigNestedObject) {
|
|||||||
TEST(Value, RemoveLastElement) {
|
TEST(Value, RemoveLastElement) {
|
||||||
rapidjson::Document doc;
|
rapidjson::Document doc;
|
||||||
rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
||||||
rapidjson::Value objVal(rapidjson::kObjectType);
|
rapidjson::Value objVal(rapidjson::kObjectType);
|
||||||
objVal.AddMember("var1", 123, allocator);
|
objVal.AddMember("var1", 123, allocator);
|
||||||
objVal.AddMember("var2", "444", allocator);
|
objVal.AddMember("var2", "444", allocator);
|
||||||
objVal.AddMember("var3", 555, allocator);
|
objVal.AddMember("var3", 555, allocator);
|
||||||
EXPECT_TRUE(objVal.HasMember("var3"));
|
EXPECT_TRUE(objVal.HasMember("var3"));
|
||||||
@ -1712,22 +1712,22 @@ TEST(Document, CrtAllocator) {
|
|||||||
|
|
||||||
static void TestShortStringOptimization(const char* str) {
|
static void TestShortStringOptimization(const char* str) {
|
||||||
const rapidjson::SizeType len = static_cast<rapidjson::SizeType>(strlen(str));
|
const rapidjson::SizeType len = static_cast<rapidjson::SizeType>(strlen(str));
|
||||||
|
|
||||||
rapidjson::Document doc;
|
rapidjson::Document doc;
|
||||||
rapidjson::Value val;
|
rapidjson::Value val;
|
||||||
val.SetString(str, len, doc.GetAllocator());
|
val.SetString(str, len, doc.GetAllocator());
|
||||||
|
|
||||||
EXPECT_EQ(val.GetStringLength(), len);
|
EXPECT_EQ(val.GetStringLength(), len);
|
||||||
EXPECT_STREQ(val.GetString(), str);
|
EXPECT_STREQ(val.GetString(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Value, AllocateShortString) {
|
TEST(Value, AllocateShortString) {
|
||||||
TestShortStringOptimization(""); // edge case: empty string
|
TestShortStringOptimization(""); // edge case: empty string
|
||||||
TestShortStringOptimization("12345678"); // regular case for short strings: 8 chars
|
TestShortStringOptimization("12345678"); // regular case for short strings: 8 chars
|
||||||
TestShortStringOptimization("12345678901"); // edge case: 11 chars in 32-bit mode (=> short string)
|
TestShortStringOptimization("12345678901"); // edge case: 11 chars in 32-bit mode (=> short string)
|
||||||
TestShortStringOptimization("123456789012"); // edge case: 12 chars in 32-bit mode (=> regular string)
|
TestShortStringOptimization("123456789012"); // edge case: 12 chars in 32-bit mode (=> regular string)
|
||||||
TestShortStringOptimization("123456789012345"); // edge case: 15 chars in 64-bit mode (=> short string)
|
TestShortStringOptimization("123456789012345"); // edge case: 15 chars in 64-bit mode (=> short string)
|
||||||
TestShortStringOptimization("1234567890123456"); // edge case: 16 chars in 64-bit mode (=> regular string)
|
TestShortStringOptimization("1234567890123456"); // edge case: 16 chars in 64-bit mode (=> regular string)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int e>
|
template <int e>
|
||||||
@ -1802,7 +1802,7 @@ static void MergeDuplicateKey(Value& v, Value::AllocatorType& a) {
|
|||||||
// Convert all key:value into key:[value]
|
// Convert all key:value into key:[value]
|
||||||
for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)
|
for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)
|
||||||
itr->value = Value(kArrayType).Move().PushBack(itr->value, a);
|
itr->value = Value(kArrayType).Move().PushBack(itr->value, a);
|
||||||
|
|
||||||
// Merge arrays if key is duplicated
|
// Merge arrays if key is duplicated
|
||||||
for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd();) {
|
for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd();) {
|
||||||
Value::MemberIterator itr2 = v.FindMember(itr->name);
|
Value::MemberIterator itr2 = v.FindMember(itr->name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user