diff --git a/doc/diagram/move1.dot b/doc/diagram/move1.dot index e280212..a7c1464 100644 --- a/doc/diagram/move1.dot +++ b/doc/diagram/move1.dot @@ -5,7 +5,6 @@ digraph { margin="0,0" ranksep=0.2 penwidth=0.5 - forcelabels=true node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5] edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal] @@ -19,10 +18,13 @@ digraph { node [shape=Mrecord, style=filled, colorscheme=spectral7] - b1 [label="{b:number|456}", fillcolor=6] - a1 [label="{a:number|123}", fillcolor=6] + { + rank = same + b1 [label="{b:number|456}", fillcolor=6] + a1 [label="{a:number|123}", fillcolor=6] + } - b1 -> a1 [style="dashed", constraint=false, label="Move"] + a1 -> b1 [style="dashed", label="Move", dir=back] } subgraph cluster2 { @@ -34,7 +36,12 @@ digraph { node [shape=Mrecord, style=filled, colorscheme=spectral7] - b2 [label="{b:null|}", fillcolor=1] - a2 [label="{a:number|456}", fillcolor=6] + { + rank = same + b2 [label="{b:null|}", fillcolor=1] + a2 [label="{a:number|456}", fillcolor=6] + } + a2 -> b2 [style=invis, dir=back] } + b1 -> b2 [style=invis] } \ No newline at end of file diff --git a/doc/diagram/move1.png b/doc/diagram/move1.png index 5405393..bf4938d 100644 Binary files a/doc/diagram/move1.png and b/doc/diagram/move1.png differ diff --git a/doc/diagram/move2.dot b/doc/diagram/move2.dot index 9c63162..7037ea6 100644 --- a/doc/diagram/move2.dot +++ b/doc/diagram/move2.dot @@ -5,7 +5,6 @@ digraph { margin="0,0" ranksep=0.2 penwidth=0.5 - forcelabels=true node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5] edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal] @@ -13,7 +12,7 @@ digraph { subgraph cluster1 { margin="10,10" labeljust="left" - label = "Before Copying" + label = "Before Copying (Hypothetic)" style=filled fillcolor=gray95 @@ -24,27 +23,26 @@ digraph { c12 [label="{|}"] c13 [shape="none", label="...", style="solid"] o1 [label="{o:object|}", fillcolor=3] + ghost [label="{o:object|}", style=invis] - c1 -> o1 [style="dashed", constraint=false, label="AddMember"] + c1 -> o1 [style="dashed", label="AddMember", constraint=false] edge [arrowhead=vee] c1 -> { c11; c12; c13 } + o1 -> ghost [style=invis] } subgraph cluster2 { margin="10,10" labeljust="left" - label = "After Copying" + label = "After Copying (Hypothetic)" style=filled fillcolor=gray95 node [shape=Mrecord, style=filled, colorscheme=spectral7] - { - rank = same - c2 [label="{contact:array|}", fillcolor=4] - c3 [label="{array|}", fillcolor=4] - } + c2 [label="{contact:array|}", fillcolor=4] + c3 [label="{array|}", fillcolor=4] c21 [label="{|}"] c22 [label="{|}"] c23 [shape=none, label="...", style="solid"] @@ -60,4 +58,5 @@ digraph { cs -> c3 [arrowhead=none] c3 -> { c31; c32; c33 } } + ghost -> o2 [style=invis] } \ No newline at end of file diff --git a/doc/diagram/move2.png b/doc/diagram/move2.png index a65966e..1d1f0bf 100644 Binary files a/doc/diagram/move2.png and b/doc/diagram/move2.png differ diff --git a/doc/diagram/move3.dot b/doc/diagram/move3.dot index 4c2177d..c197b99 100644 --- a/doc/diagram/move3.dot +++ b/doc/diagram/move3.dot @@ -22,13 +22,15 @@ digraph { c1 [label="{contact:array|}", fillcolor=4] c11 [label="{|}"] c12 [label="{|}"] - c13 [shape=none, label="...", style="none"] + c13 [shape=none, label="...", style="solid"] o1 [label="{o:object|}", fillcolor=3] + ghost [label="{o:object|}", style=invis] c1 -> o1 [style="dashed", constraint=false, label="AddMember"] edge [arrowhead=vee] c1 -> { c11; c12; c13 } + o1 -> ghost [style=invis] } subgraph cluster2 { @@ -40,7 +42,6 @@ digraph { node [shape=Mrecord, style=filled, colorscheme=spectral7] - rank = same c2 [label="{contact:null|}", fillcolor=1] c3 [label="{array|}", fillcolor=4] c21 [label="{|}"] @@ -48,10 +49,12 @@ digraph { c23 [shape="none", label="...", style="solid"] o2 [label="{o:object|}", fillcolor=3] cs [label="{string|\"contact\"}", fillcolor=5] + c2 -> o2 [style="dashed", constraint=false, label="AddMember", style=invis] edge [arrowhead=vee] c3 -> { c21; c22; c23 } o2 -> cs cs -> c3 [arrowhead=none] } + ghost -> o2 [style=invis] } \ No newline at end of file diff --git a/doc/diagram/move3.png b/doc/diagram/move3.png index f666aca..a52ad46 100644 Binary files a/doc/diagram/move3.png and b/doc/diagram/move3.png differ diff --git a/doc/features.md b/doc/features.md index 51f7016..f5d9355 100644 --- a/doc/features.md +++ b/doc/features.md @@ -19,7 +19,7 @@ ## Standard compliance * RapidJSON should be fully RFC4627/ECMA-404 compliance. -* Support unicode surrogate. +* Support Unicode surrogate. * Support null character (`"\u0000"`) * For example, `["Hello\u0000World"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string. @@ -46,7 +46,7 @@ ## DOM (Document) -* Support insitu parsing. +* Support *in situ* parsing. * Parse JSON string values in-place at the source JSON, and then the DOM points to addresses of those strings. * Faster than convention parsing: no allocation for strings, no copy (if string does not contain escapes), cache-friendly. * Support 32-bit/64-bit signed/unsigned integer and `double` for JSON number type. @@ -55,7 +55,7 @@ ## SAX (Reader) * Support comprehensive error code if parsing failed. -* Support localizable error message. +* Support error message localization. ## SAX (Writer) diff --git a/doc/tutorial.md b/doc/tutorial.md index dcad7f2..5753b34 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2,7 +2,7 @@ This tutorial introduces the basics of the Document Object Model(DOM) API. -As shown in [Usage at a glance](../readme.md#usage-at-a-glance), a JSON text can be parsed into DOM, and then the DOM can be queried and modfied easily, and finally be converted back to JSON text. +As shown in [Usage at a glance](../readme.md#usage-at-a-glance), a JSON text can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON text. ## Value & Document @@ -119,7 +119,7 @@ In the following, details about querying individual types are discussed. By default, `SizeType` is typedef of `unsigned`. In most systems, array is limited to store up to 2^32-1 elements. -You may access the elements in array by integer literal, for example, `a[1]`, `a[2]`. However, `a[0]` will generate a compiler error. It is because two overloaded operators `operator[](SizeType)` and `operator[](const char*)` is avaliable, and C++ can treat `0` as a null pointer. Workarounds: +You may access the elements in array by integer literal, for example, `a[1]`, `a[2]`. However, `a[0]` will generate a compiler error. It is because two overloaded operators `operator[](SizeType)` and `operator[](const char*)` is available, and C++ can treat `0` as a null pointer. Workarounds: * `a[SizeType(0)]` * `a[0u]` @@ -129,11 +129,11 @@ for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) printf("%d ", itr->GetInt()); ``` -And other familar query functions: +And other familiar query functions: * `SizeType Capacity() const` * `bool Empty() const` -### Quering Object +### Query Object Similar to array, we can iterate object members by iterator: @@ -196,7 +196,7 @@ Checking | Obtaining `bool IsInt64()` | `int64_t GetInt64()` `bool IsDouble()` | `double GetDouble()` -Note that, an integer value may be obtained in various ways without conversion. For example, A value `x` containing 123 will make `x.IsInt() == x.IsUint() == x.IsInt64() == x.IsUint64() == ture`. But a value `y` containing -3000000000 will only makes `x.IsInt64() == true`. +Note that, an integer value may be obtained in various ways without conversion. For example, A value `x` containing 123 will make `x.IsInt() == x.IsUint() == x.IsInt64() == x.IsUint64() == true`. But a value `y` containing -3000000000 will only makes `x.IsInt64() == true`. When obtaining the numeric values, `GetDouble()` will convert internal integer representation to a `double`. Note that, `int` and `uint` can be safely convert to `double`, but `int64_t` and `uint64_t` may lose precision (since mantissa of `double` is only 52-bits). @@ -204,7 +204,7 @@ When obtaining the numeric values, `GetDouble()` will convert internal integer r In addition to `GetString()`, the `Value` class also contains `GetStringLength()`. Here explains why. -According to RFC 4627, JSON strings can contain unicode character `U+0000`, which must be escaped as `"\u0000"`. The problem is that, C/C++ often uses null-terminated string, which treats ``\0'` as the terminator symbol. +According to RFC 4627, JSON strings can contain Unicode character `U+0000`, which must be escaped as `"\u0000"`. The problem is that, C/C++ often uses null-terminated string, which treats ``\0'` as the terminator symbol. To conform RFC 4627, RapidJSON supports string containing `U+0000`. If you need to handle this, you can use `GetStringLength()` API to obtain the correct length of string. @@ -337,7 +337,7 @@ In this example, we get the allocator from a `Document` instance. This is a comm Besides, the above `SetString()` requires length. This can handle null characters within a string. There is another `SetString()` overloaded function without the length parameter. And it assumes the input is null-terminated and calls a `strlen()`-like function to obtain the length. -Finally, for literal string or string with safe life-cycle can use const-string version of `SetString()`, which lacks alloactor parameter: +Finally, for literal string or string with safe life-cycle can use const-string version of `SetString()`, which lacks allocator parameter: ```cpp Value s; @@ -426,11 +426,11 @@ Swapping two DOM trees is fast (constant time), despite the complexity of the tr This tutorial shows the basics of DOM tree query and manipulation. There are several important concepts in RapidJSON: -1. [Streams](stream.md) are channels for reading/writing JSON, which can be a in-memory string, or file stream, etc. Uesr can also create their streams. +1. [Streams](stream.md) are channels for reading/writing JSON, which can be a in-memory string, or file stream, etc. User can also create their streams. 2. [Encoding](encoding.md) defines which character set is used in streams and memory. RapidJSON also provide Unicode conversion/validation internally. -3. [DOM](dom.md)'s basics are already covered in this tutorial. Uncover more advanced features such as insitu-parsing, other parsing options and advanced usages. +3. [DOM](dom.md)'s basics are already covered in this tutorial. Uncover more advanced features such as *in situ* parsing, other parsing options and advanced usages. 4. [SAX](sax.md) is the foundation of parsing/generating facility in RapidJSON. Learn how to use `Reader`/`Writer` to implement even faster applications. Also try `PrettyWriter` to format the JSON. -5. [Performance](performance.md) shows some in-house and thirdparty benchmarks. +5. [Performance](performance.md) shows some in-house and third-party benchmarks. 6. [Implementation](implementation.md) describes some internal designs and techniques of RapidJSON. You may also refer to the FAQ, API documentation, examples and unit tests.