Skip to content

Commit e54aca7

Browse files
committed
Merge branch 'master' of https://github.com/Tencent/rapidjson
2 parents 02230fe + bb5f966 commit e54aca7

File tree

16 files changed

+81
-28
lines changed

16 files changed

+81
-28
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
before_install:
2121
- sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
2222
- sudo apt-get update -qq
23-
- sudo apt-get install -y cmake valgrind g++-multilib libc6-dbg:i386
23+
- sudo apt-get install -y cmake valgrind g++-multilib libc6-dbg:i386 --allow-unauthenticated
2424

2525
matrix:
2626
include:

doc/internals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The following tables show the data layout of each type. The 32-bit/64-bit column
7979
| `unsigned u` | 32-bit unsigned integer |4 |4 |
8080
| (zero padding) | 0 |4 |4 |
8181
| (unused) | |4 |8 |
82-
| `unsigned flags_` | `kNumberType kNumberFlag kUIntFlag kUInt64Flag ...` |4 |4 |
82+
| `unsigned flags_` | `kNumberType kNumberFlag kUintFlag kUint64Flag ...` |4 |4 |
8383

8484
| Number (Int64) | |32-bit|64-bit|
8585
|---------------------|-------------------------------------|:----:|:----:|

doc/internals.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ SAX 和 DOM API 都依赖于3个额外的概念:`Allocator`、`Encoding` 和 `
7979
| `unsigned u` | 32位无符号整数 |4 |4 |
8080
| (零填充) | 0 |4 |4 |
8181
| (未使用) | |4 |8 |
82-
| `unsigned flags_` | `kNumberType kNumberFlag kUIntFlag kUInt64Flag ...` |4 |4 |
82+
| `unsigned flags_` | `kNumberType kNumberFlag kUintFlag kUint64Flag ...` |4 |4 |
8383

8484
| Number (Int64) | | 32位 | 64位 |
8585
|---------------------|-------------------------------------|:----:|:----:|
@@ -248,7 +248,7 @@ void SkipWhitespace(InputStream& is) {
248248
249249
## 整数到字符串的转换 {#itoa}
250250
251-
整数到字符串转换的朴素算法需要对每一个十进制位进行一次处罚。我们实现了若干版本并在 [itoa-benchmark](https://github.com/miloyip/itoa-benchmark) 中对它们进行了评估。
251+
整数到字符串转换的朴素算法需要对每一个十进制位进行一次除法。我们实现了若干版本并在 [itoa-benchmark](https://github.com/miloyip/itoa-benchmark) 中对它们进行了评估。
252252
253253
虽然 SSE2 版本是最快的,但它和第二快的 `branchlut` 差距不大。而且 `branchlut` 是纯C++实现,所以我们在 RapidJSON 中使用了 `branchlut`。
254254

doc/sax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Bool(false)
3737
Key("n", 1, true)
3838
Null()
3939
Key("i")
40-
UInt(123)
40+
Uint(123)
4141
Key("pi")
4242
Double(3.1416)
4343
Key("a")

doc/sax.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Bool(false)
3737
Key("n", 1, true)
3838
Null()
3939
Key("i")
40-
UInt(123)
40+
Uint(123)
4141
Key("pi")
4242
Double(3.1416)
4343
Key("a")
@@ -91,7 +91,7 @@ void main() {
9191
}
9292
~~~~~~~~~~
9393
94-
注意 RapidJSON 使用模板去静态挷定 `Reader` 类型及处理器的类形,而不是使用含虚函数的类。这个范式可以通过把函数内联而改善性能。
94+
注意 RapidJSON 使用模板去静态挷定 `Reader` 类型及处理器的类型,而不是使用含虚函数的类。这个范式可以通过把函数内联而改善性能。
9595
9696
## 处理器 {#Handler}
9797

doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ JSON number type represents all numeric values. However, C++ needs more specific
8282
~~~~~~~~~~cpp
8383
assert(document["i"].IsNumber());
8484

85-
// In this case, IsUint()/IsInt64()/IsUInt64() also return true.
85+
// In this case, IsUint()/IsInt64()/IsUint64() also return true.
8686
assert(document["i"].IsInt());
8787
printf("i = %d\n", document["i"].GetInt());
8888
// Alternative (int)document["i"]

doc/tutorial.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ JSON Number 类型表示所有数值。然而,C++ 需要使用更专门的类
8282
~~~~~~~~~~cpp
8383
assert(document["i"].IsNumber());
8484

85-
// 在此情况下,IsUint()/IsInt64()/IsUInt64() 也会返回 true
85+
// 在此情况下,IsUint()/IsInt64()/IsUint64() 也会返回 true
8686
assert(document["i"].IsInt());
8787
printf("i = %d\n", document["i"].GetInt());
8888
// 另一种用法: (int)document["i"]
@@ -447,7 +447,7 @@ contact.PushBack(val, document.GetAllocator());
447447
~~~~~~~~~~
448448

449449
## 修改 Object {#ModifyObject}
450-
Object 是键值对的集合。每个键必须为 String。要修改 Object,方法是增加或移除成员。以下的 API 用来增加城员
450+
Object 是键值对的集合。每个键必须为 String。要修改 Object,方法是增加或移除成员。以下的 API 用来增加成员
451451

452452
* `Value& AddMember(Value&, Value&, Allocator& allocator)`
453453
* `Value& AddMember(StringRefType, Value&, Allocator&)`

example/tutorial/tutorial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int main(int, char*[]) {
5757
printf("n = %s\n", document["n"].IsNull() ? "null" : "?");
5858

5959
assert(document["i"].IsNumber()); // Number is a JSON type, but C++ needs more specific type.
60-
assert(document["i"].IsInt()); // In this case, IsUint()/IsInt64()/IsUInt64() also return true.
60+
assert(document["i"].IsInt()); // In this case, IsUint()/IsInt64()/IsUint64() also return true.
6161
printf("i = %d\n", document["i"].GetInt()); // Alternative (int)document["i"]
6262

6363
assert(document["pi"].IsNumber());

include/rapidjson/document.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,45 @@ class GenericDocument;
6363
https://code.google.com/p/rapidjson/issues/detail?id=64
6464
*/
6565
template <typename Encoding, typename Allocator>
66-
struct GenericMember {
66+
class GenericMember {
67+
public:
6768
GenericValue<Encoding, Allocator> name; //!< name of member (must be a string)
6869
GenericValue<Encoding, Allocator> value; //!< value of member.
6970

71+
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
72+
//! Move constructor in C++11
73+
GenericMember(GenericMember&& rhs) RAPIDJSON_NOEXCEPT
74+
: name(std::move(rhs.name)),
75+
value(std::move(rhs.value))
76+
{
77+
}
78+
79+
//! Move assignment in C++11
80+
GenericMember& operator=(GenericMember&& rhs) RAPIDJSON_NOEXCEPT {
81+
return *this = static_cast<GenericMember&>(rhs);
82+
}
83+
#endif
84+
85+
//! Assignment with move semantics.
86+
/*! \param rhs Source of the assignment. Its name and value will become a null value after assignment.
87+
*/
88+
GenericMember& operator=(GenericMember& rhs) RAPIDJSON_NOEXCEPT {
89+
if (RAPIDJSON_LIKELY(this != &rhs)) {
90+
name = rhs.name;
91+
value = rhs.value;
92+
}
93+
return *this;
94+
}
95+
7096
// swap() for std::sort() and other potential use in STL.
7197
friend inline void swap(GenericMember& a, GenericMember& b) RAPIDJSON_NOEXCEPT {
7298
a.name.Swap(b.name);
7399
a.value.Swap(b.value);
74100
}
101+
102+
private:
103+
//! Copy constructor is not permitted.
104+
GenericMember(const GenericMember& rhs);
75105
};
76106

77107
///////////////////////////////////////////////////////////////////////////////

include/rapidjson/fwd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class PrettyWriter;
102102
// document.h
103103

104104
template <typename Encoding, typename Allocator>
105-
struct GenericMember;
105+
class GenericMember;
106106

107107
template <bool Const, typename Encoding, typename Allocator>
108108
class GenericMemberIterator;

0 commit comments

Comments
 (0)