summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2018-05-17 08:02:51 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2018-05-17 08:04:47 -0700
commite584ea337ede5b33d3e3f2165352a233b67b7fab (patch)
tree117ce1639892eab74b2458212b050ca19815311e /docs
parent51322cffa1b9c69a28b89a239ebe7133fa4cdda2 (diff)
docs: Mention that node is a container of children in ranged for sectionHEADmaster
This is implicitly true due to the following section, but that was written before C++11 so this does deserve a special mention in ranged for section as well. Fixes #210.
Diffstat (limited to 'docs')
-rw-r--r--docs/manual.adoc7
-rw-r--r--docs/manual.html10
2 files changed, 16 insertions, 1 deletions
diff --git a/docs/manual.adoc b/docs/manual.adoc
index ab06af9..7b75a23 100644
--- a/docs/manual.adoc
+++ b/docs/manual.adoc
@@ -1010,6 +1010,13 @@ This is an example of using these functions (link:samples/traverse_rangefor.cpp[
include::samples/traverse_rangefor.cpp[tags=code]
----
+While using `children()` makes the intent of the code clear, note that each node can be treated as a container of child nodes, since it provides `begin()`/`end()` member functions described in the next section. Because of this, you can iterate through node's children simply by using the node itself:
+
+[source]
+----
+for (pugi::xml_node child: tool)
+----
+
[[access.iterators]]
=== Traversing node/attribute lists via iterators
diff --git a/docs/manual.html b/docs/manual.html
index 3be4a2b..43bb197 100644
--- a/docs/manual.html
+++ b/docs/manual.html
@@ -2244,6 +2244,14 @@ If your C&#43;&#43; compiler supports range-based for-loop (this is a C&#43;&#43
<span class="tok-p">}</span></code></pre>
</div>
</div>
+<div class="paragraph">
+<p>While using <code>children()</code> makes the intent of the code clear, note that each node can be treated as a container of child nodes, since it provides <code>begin()</code>/<code>end()</code> member functions described in the next section. Because of this, you can iterate through node&#8217;s children simply by using the node itself:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-nl">child</span><span class="tok-p">:</span> <span class="tok-n">tool</span><span class="tok-p">)</span></code></pre>
+</div>
+</div>
</div>
<div class="sect2">
<h3 id="access.iterators"><a class="anchor" href="#access.iterators"></a><a class="link" href="#access.iterators">5.6. Traversing node/attribute lists via iterators</a></h3>
@@ -5759,7 +5767,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2018-04-04 08:26:07 DST
+Last updated 2018-05-17 08:04:31 DST
</div>
</div>
</body>