Commit 3e4e68b0 authored by Milo Yip's avatar Milo Yip

Rearrange diagrams and fix typos in tutorial

parent 23318f25
...@@ -5,7 +5,6 @@ digraph { ...@@ -5,7 +5,6 @@ digraph {
margin="0,0" margin="0,0"
ranksep=0.2 ranksep=0.2
penwidth=0.5 penwidth=0.5
forcelabels=true
node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5] node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5]
edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal] edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal]
...@@ -19,10 +18,13 @@ digraph { ...@@ -19,10 +18,13 @@ digraph {
node [shape=Mrecord, style=filled, colorscheme=spectral7] 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 { subgraph cluster2 {
...@@ -34,7 +36,12 @@ digraph { ...@@ -34,7 +36,12 @@ digraph {
node [shape=Mrecord, style=filled, colorscheme=spectral7] 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
doc/diagram/move1.png

6.36 KB | W: | H:

doc/diagram/move1.png

7.99 KB | W: | H:

doc/diagram/move1.png
doc/diagram/move1.png
doc/diagram/move1.png
doc/diagram/move1.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -5,7 +5,6 @@ digraph { ...@@ -5,7 +5,6 @@ digraph {
margin="0,0" margin="0,0"
ranksep=0.2 ranksep=0.2
penwidth=0.5 penwidth=0.5
forcelabels=true
node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5] node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5]
edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal] edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal]
...@@ -13,7 +12,7 @@ digraph { ...@@ -13,7 +12,7 @@ digraph {
subgraph cluster1 { subgraph cluster1 {
margin="10,10" margin="10,10"
labeljust="left" labeljust="left"
label = "Before Copying" label = "Before Copying (Hypothetic)"
style=filled style=filled
fillcolor=gray95 fillcolor=gray95
...@@ -24,27 +23,26 @@ digraph { ...@@ -24,27 +23,26 @@ digraph {
c12 [label="{|}"] c12 [label="{|}"]
c13 [shape="none", label="...", style="solid"] c13 [shape="none", label="...", style="solid"]
o1 [label="{o:object|}", fillcolor=3] 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] edge [arrowhead=vee]
c1 -> { c11; c12; c13 } c1 -> { c11; c12; c13 }
o1 -> ghost [style=invis]
} }
subgraph cluster2 { subgraph cluster2 {
margin="10,10" margin="10,10"
labeljust="left" labeljust="left"
label = "After Copying" label = "After Copying (Hypothetic)"
style=filled style=filled
fillcolor=gray95 fillcolor=gray95
node [shape=Mrecord, style=filled, colorscheme=spectral7] node [shape=Mrecord, style=filled, colorscheme=spectral7]
{ c2 [label="{contact:array|}", fillcolor=4]
rank = same c3 [label="{array|}", fillcolor=4]
c2 [label="{contact:array|}", fillcolor=4]
c3 [label="{array|}", fillcolor=4]
}
c21 [label="{|}"] c21 [label="{|}"]
c22 [label="{|}"] c22 [label="{|}"]
c23 [shape=none, label="...", style="solid"] c23 [shape=none, label="...", style="solid"]
...@@ -60,4 +58,5 @@ digraph { ...@@ -60,4 +58,5 @@ digraph {
cs -> c3 [arrowhead=none] cs -> c3 [arrowhead=none]
c3 -> { c31; c32; c33 } c3 -> { c31; c32; c33 }
} }
ghost -> o2 [style=invis]
} }
\ No newline at end of file
doc/diagram/move2.png

23 KB | W: | H:

doc/diagram/move2.png

26.1 KB | W: | H:

doc/diagram/move2.png
doc/diagram/move2.png
doc/diagram/move2.png
doc/diagram/move2.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -22,13 +22,15 @@ digraph { ...@@ -22,13 +22,15 @@ digraph {
c1 [label="{contact:array|}", fillcolor=4] c1 [label="{contact:array|}", fillcolor=4]
c11 [label="{|}"] c11 [label="{|}"]
c12 [label="{|}"] c12 [label="{|}"]
c13 [shape=none, label="...", style="none"] c13 [shape=none, label="...", style="solid"]
o1 [label="{o:object|}", fillcolor=3] o1 [label="{o:object|}", fillcolor=3]
ghost [label="{o:object|}", style=invis]
c1 -> o1 [style="dashed", constraint=false, label="AddMember"] c1 -> o1 [style="dashed", constraint=false, label="AddMember"]
edge [arrowhead=vee] edge [arrowhead=vee]
c1 -> { c11; c12; c13 } c1 -> { c11; c12; c13 }
o1 -> ghost [style=invis]
} }
subgraph cluster2 { subgraph cluster2 {
...@@ -40,7 +42,6 @@ digraph { ...@@ -40,7 +42,6 @@ digraph {
node [shape=Mrecord, style=filled, colorscheme=spectral7] node [shape=Mrecord, style=filled, colorscheme=spectral7]
rank = same
c2 [label="{contact:null|}", fillcolor=1] c2 [label="{contact:null|}", fillcolor=1]
c3 [label="{array|}", fillcolor=4] c3 [label="{array|}", fillcolor=4]
c21 [label="{|}"] c21 [label="{|}"]
...@@ -48,10 +49,12 @@ digraph { ...@@ -48,10 +49,12 @@ digraph {
c23 [shape="none", label="...", style="solid"] c23 [shape="none", label="...", style="solid"]
o2 [label="{o:object|}", fillcolor=3] o2 [label="{o:object|}", fillcolor=3]
cs [label="{string|\"contact\"}", fillcolor=5] cs [label="{string|\"contact\"}", fillcolor=5]
c2 -> o2 [style="dashed", constraint=false, label="AddMember", style=invis]
edge [arrowhead=vee] edge [arrowhead=vee]
c3 -> { c21; c22; c23 } c3 -> { c21; c22; c23 }
o2 -> cs o2 -> cs
cs -> c3 [arrowhead=none] cs -> c3 [arrowhead=none]
} }
ghost -> o2 [style=invis]
} }
\ No newline at end of file
doc/diagram/move3.png

22.4 KB | W: | H:

doc/diagram/move3.png

22.1 KB | W: | H:

doc/diagram/move3.png
doc/diagram/move3.png
doc/diagram/move3.png
doc/diagram/move3.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
## Standard compliance ## Standard compliance
* RapidJSON should be fully RFC4627/ECMA-404 compliance. * RapidJSON should be fully RFC4627/ECMA-404 compliance.
* Support unicode surrogate. * Support Unicode surrogate.
* Support null character (`"\u0000"`) * Support null character (`"\u0000"`)
* For example, `["Hello\u0000World"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string. * For example, `["Hello\u0000World"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string.
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
## DOM (Document) ## 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. * 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. * 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. * Support 32-bit/64-bit signed/unsigned integer and `double` for JSON number type.
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
## SAX (Reader) ## SAX (Reader)
* Support comprehensive error code if parsing failed. * Support comprehensive error code if parsing failed.
* Support localizable error message. * Support error message localization.
## SAX (Writer) ## SAX (Writer)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
This tutorial introduces the basics of the Document Object Model(DOM) API. 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 ## Value & Document
...@@ -119,7 +119,7 @@ In the following, details about querying individual types are discussed. ...@@ -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. 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[SizeType(0)]`
* `a[0u]` * `a[0u]`
...@@ -129,11 +129,11 @@ for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) ...@@ -129,11 +129,11 @@ for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr)
printf("%d ", itr->GetInt()); printf("%d ", itr->GetInt());
``` ```
And other familar query functions: And other familiar query functions:
* `SizeType Capacity() const` * `SizeType Capacity() const`
* `bool Empty() const` * `bool Empty() const`
### Quering Object ### Query Object
Similar to array, we can iterate object members by iterator: Similar to array, we can iterate object members by iterator:
...@@ -196,7 +196,7 @@ Checking | Obtaining ...@@ -196,7 +196,7 @@ Checking | Obtaining
`bool IsInt64()` | `int64_t GetInt64()` `bool IsInt64()` | `int64_t GetInt64()`
`bool IsDouble()` | `double GetDouble()` `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). 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 ...@@ -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. 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. 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 ...@@ -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. 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 ```cpp
Value s; Value s;
...@@ -426,11 +426,11 @@ Swapping two DOM trees is fast (constant time), despite the complexity of the tr ...@@ -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: 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. 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. 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. 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. You may also refer to the FAQ, API documentation, examples and unit tests.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment