diff options
author | 2016-09-03 14:37:09 +0200 | |
---|---|---|
committer | 2016-09-03 14:37:09 +0200 | |
commit | ff9c4b5acb76cde0246f48c44f531989c1e7c7cb (patch) | |
tree | 1319c4838a69e76ae8a099b82d026bf8add86797 /3rdparty/rapidjson/doc/tutorial.md | |
parent | a6409d692ef748e6b8f7980d6bcb74a0a466d9cb (diff) |
Update RapidJson to latest (nw)
Diffstat (limited to '3rdparty/rapidjson/doc/tutorial.md')
-rw-r--r-- | 3rdparty/rapidjson/doc/tutorial.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/3rdparty/rapidjson/doc/tutorial.md b/3rdparty/rapidjson/doc/tutorial.md index 0da07dc5d91..cb76b4b0b78 100644 --- a/3rdparty/rapidjson/doc/tutorial.md +++ b/3rdparty/rapidjson/doc/tutorial.md @@ -133,6 +133,15 @@ And other familiar query functions: * `SizeType Capacity() const` * `bool Empty() const` +### Range-based For Loop (New in v1.1.0) + +When C++11 is enabled, you can use range-based for loop to access all elements in an array. + +~~~~~~~~~~cpp +for (auto& v : a.GetArray()) + printf("%d ", v.GetInt()); +~~~~~~~~~~ + ## Query Object {#QueryObject} Similar to array, we can access all object members by iterator: @@ -169,6 +178,16 @@ if (itr != document.MemberEnd()) printf("%s\n", itr->value.GetString()); ~~~~~~~~~~ +### Range-based For Loop (New in v1.1.0) + +When C++11 is enabled, you can use range-based for loop to access all members in an object. + +~~~~~~~~~~cpp +for (auto& m : document.GetObject()) + printf("Type of member %s is %s\n", + m.name.GetString(), kTypeNames[m.value.GetType()]); +~~~~~~~~~~ + ## Querying Number {#QueryNumber} JSON provide a single numerical type called Number. Number can be integer or real numbers. RFC 4627 says the range of Number is specified by parser. |