diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2014-02-28 06:01:16 +0000 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2014-02-28 06:01:16 +0000 |
commit | 2094a4fd3da85c1972f215cb5977f6157590ff79 (patch) | |
tree | 30af367b434ca0f1dc8de193796e923d12f1c8aa /docs/manual | |
parent | 6305ac11a88f4bd2ee9cbbabe8e71aaff075010e (diff) |
docs: Regenerate HTML documentation
git-svn-id: https://pugixml.googlecode.com/svn/trunk@993 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'docs/manual')
-rw-r--r-- | docs/manual/access.html | 327 | ||||
-rw-r--r-- | docs/manual/apiref.html | 240 | ||||
-rw-r--r-- | docs/manual/changes.html | 194 | ||||
-rw-r--r-- | docs/manual/dom.html | 220 | ||||
-rw-r--r-- | docs/manual/install.html | 123 | ||||
-rw-r--r-- | docs/manual/loading.html | 313 | ||||
-rw-r--r-- | docs/manual/modify.html | 274 | ||||
-rw-r--r-- | docs/manual/saving.html | 226 | ||||
-rw-r--r-- | docs/manual/toc.html | 160 | ||||
-rw-r--r-- | docs/manual/xpath.html | 362 |
10 files changed, 1338 insertions, 1101 deletions
diff --git a/docs/manual/access.html b/docs/manual/access.html index c6abd05..4d4e9c2 100644 --- a/docs/manual/access.html +++ b/docs/manual/access.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Accessing document data</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="loading.html" title="Loading document"> <link rel="next" href="modify.html" title="Modifying document data"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,27 +28,27 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.access"></a><a class="link" href="access.html" title="Accessing document data"> Accessing document data</a> +<a name="manual.access"></a><a class="link" href="access.html" title="Accessing document data">Accessing document data</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="access.html#manual.access.basic"> Basic traversal functions</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.nodedata"> Getting node data</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.attrdata"> Getting attribute data</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.contents"> Contents-based traversal functions</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.rangefor"> Range-based for-loop support</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.iterators"> Traversing node/attribute lists +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="access.html#manual.access.basic">Basic traversal functions</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.nodedata">Getting node data</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.attrdata">Getting attribute data</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.contents">Contents-based traversal functions</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.rangefor">Range-based for-loop support</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.iterators">Traversing node/attribute lists via iterators</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.walker"> Recursive traversal with xml_tree_walker</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.predicate"> Searching for nodes/attributes +<dt><span class="section"><a href="access.html#manual.access.walker">Recursive traversal with xml_tree_walker</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.predicate">Searching for nodes/attributes with predicates</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.text"> Working with text contents</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.misc"> Miscellaneous functions</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.text">Working with text contents</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.misc">Miscellaneous functions</a></span></dt> </dl></div> <p> pugixml features an extensive interface for getting various types of data from the document and for traversing the document. This section provides documentation for all such functions that do not modify the tree except for XPath-related - functions; see <a class="xref" href="xpath.html" title="XPath"> XPath</a> for XPath reference. As discussed in <a class="xref" href="dom.html#manual.dom.cpp" title="C++ interface"> C++ interface</a>, + functions; see <a class="xref" href="xpath.html" title="XPath">XPath</a> for XPath reference. As discussed in <a class="xref" href="dom.html#manual.dom.cpp" title="C++ interface">C++ interface</a>, there are two types of handles to tree data - <a class="link" href="dom.html#xml_node">xml_node</a> and <a class="link" href="dom.html#xml_attribute">xml_attribute</a>. The handles have special null (empty) values which propagate through various functions and thus are @@ -58,11 +58,12 @@ </p> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.basic"></a><a class="link" href="access.html#manual.access.basic" title="Basic traversal functions"> Basic traversal functions</a> +<a name="manual.access.basic"></a><a class="link" href="access.html#manual.access.basic" title="Basic traversal functions">Basic traversal functions</a> </h3></div></div></div> -<a name="xml_node::parent"></a><a name="xml_node::first_child"></a><a name="xml_node::last_child"></a><a name="xml_node::next_sibling"></a><a name="xml_node::previous_sibling"></a><a name="xml_node::first_attribute"></a><a name="xml_node::last_attribute"></a><a name="xml_attribute::next_attribute"></a><a name="xml_attribute::previous_attribute"></a><p> - The internal representation of the document is a tree, where each node has - a list of child nodes (the order of children corresponds to their order in +<p> + <a name="xml_node::parent"></a><a name="xml_node::first_child"></a><a name="xml_node::last_child"></a><a name="xml_node::next_sibling"></a><a name="xml_node::previous_sibling"></a><a name="xml_node::first_attribute"></a><a name="xml_node::last_attribute"></a><a name="xml_attribute::next_attribute"></a><a name="xml_attribute::previous_attribute"></a>The + internal representation of the document is a tree, where each node has a + list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond @@ -123,7 +124,6 @@ all attributes like this (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span> <span class="special">{</span> @@ -142,15 +142,15 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.nodedata"></a><a class="link" href="access.html#manual.access.nodedata" title="Getting node data"> Getting node data</a> +<a name="manual.access.nodedata"></a><a class="link" href="access.html#manual.access.nodedata" title="Getting node data">Getting node data</a> </h3></div></div></div> -<a name="xml_node::name"></a><a name="xml_node::value"></a><p> - Apart from structural information (parent, child nodes, attributes), nodes - can have name and value, both of which are strings. Depending on node type, - name or value may be absent. <a class="link" href="dom.html#node_document">node_document</a> - nodes do not have a name or value, <a class="link" href="dom.html#node_element">node_element</a> - and <a class="link" href="dom.html#node_declaration">node_declaration</a> nodes always - have a name but never have a value, <a class="link" href="dom.html#node_pcdata">node_pcdata</a>, +<p> + <a name="xml_node::name"></a><a name="xml_node::value"></a>Apart from structural + information (parent, child nodes, attributes), nodes can have name and value, + both of which are strings. Depending on node type, name or value may be absent. + <a class="link" href="dom.html#node_document">node_document</a> nodes do not have a name + or value, <a class="link" href="dom.html#node_element">node_element</a> and <a class="link" href="dom.html#node_declaration">node_declaration</a> + nodes always have a name but never have a value, <a class="link" href="dom.html#node_pcdata">node_pcdata</a>, <a class="link" href="dom.html#node_cdata">node_cdata</a>, <a class="link" href="dom.html#node_comment">node_comment</a> and <a class="link" href="dom.html#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a class="link" href="dom.html#node_pi">node_pi</a> @@ -164,8 +164,9 @@ In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers. </p> -<a name="xml_node::child_value"></a><p> - It is common to store data as text contents of some node - i.e. <code class="computeroutput"><span class="special"><</span><span class="identifier">node</span><span class="special">><</span><span class="identifier">description</span><span class="special">></span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special"></</span><span class="identifier">description</span><span class="special">></</span><span class="identifier">node</span><span class="special">></span></code>. +<p> + <a name="xml_node::child_value"></a>It is common to store data as text contents + of some node - i.e. <code class="computeroutput"><span class="special"><</span><span class="identifier">node</span><span class="special">><</span><span class="identifier">description</span><span class="special">></span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special"></</span><span class="identifier">description</span><span class="special">></</span><span class="identifier">node</span><span class="special">></span></code>. In this case, <code class="computeroutput"><span class="special"><</span><span class="identifier">description</span><span class="special">></span></code> node does not have a value, but instead has a child of type <a class="link" href="dom.html#node_pcdata">node_pcdata</a> with value <code class="computeroutput"><span class="string">"This is a node"</span></code>. pugixml @@ -188,7 +189,7 @@ <code class="computeroutput"><span class="identifier">text</span><span class="special">()</span></code> returns a special object that can be used for working with PCDATA contents in more complex cases than just retrieving the value; it is described in - <a class="xref" href="access.html#manual.access.text" title="Working with text contents"> Working with text contents</a> sections. + <a class="xref" href="access.html#manual.access.text" title="Working with text contents">Working with text contents</a> sections. </p> <p> There is an example of using some of these functions <a class="link" href="access.html#code_traverse_base_data">at @@ -197,11 +198,12 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.attrdata"></a><a class="link" href="access.html#manual.access.attrdata" title="Getting attribute data"> Getting attribute data</a> +<a name="manual.access.attrdata"></a><a class="link" href="access.html#manual.access.attrdata" title="Getting attribute data">Getting attribute data</a> </h3></div></div></div> -<a name="xml_attribute::name"></a><a name="xml_attribute::value"></a><p> - All attributes have name and value, both of which are strings (value may - be empty). There are two corresponding accessors, like for <code class="computeroutput"><span class="identifier">xml_node</span></code>: +<p> + <a name="xml_attribute::name"></a><a name="xml_attribute::value"></a>All + attributes have name and value, both of which are strings (value may be empty). + There are two corresponding accessors, like for <code class="computeroutput"><span class="identifier">xml_node</span></code>: </p> <pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> @@ -210,12 +212,12 @@ In case the attribute handle is null, both functions return empty strings - they never return null pointers. </p> -<a name="xml_attribute::as_string"></a><p> - If you need a non-empty string if the attribute handle is null (for example, - you need to get the option value from XML attribute, but if it is not specified, - you need it to default to <code class="computeroutput"><span class="string">"sorted"</span></code> - instead of <code class="computeroutput"><span class="string">""</span></code>), you - can use <code class="computeroutput"><span class="identifier">as_string</span></code> accessor: +<p> + <a name="xml_attribute::as_string"></a>If you need a non-empty string if + the attribute handle is null (for example, you need to get the option value + from XML attribute, but if it is not specified, you need it to default to + <code class="computeroutput"><span class="string">"sorted"</span></code> instead of + <code class="computeroutput"><span class="string">""</span></code>), you can use <code class="computeroutput"><span class="identifier">as_string</span></code> accessor: </p> <pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_string</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">def</span> <span class="special">=</span> <span class="string">""</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> </pre> @@ -224,29 +226,36 @@ the attribute handle is null. If you do not specify the argument, the function is equivalent to <code class="computeroutput"><span class="identifier">value</span><span class="special">()</span></code>. </p> -<a name="xml_attribute::as_int"></a><a name="xml_attribute::as_uint"></a><a name="xml_attribute::as_double"></a><a name="xml_attribute::as_float"></a><a name="xml_attribute::as_bool"></a><p> - In many cases attribute values have types that are not strings - i.e. an - attribute may always contain values that should be treated as integers, despite - the fact that they are represented as strings in XML. pugixml provides several - accessors that convert attribute value to some other type: +<p> + <a name="xml_attribute::as_int"></a><a name="xml_attribute::as_uint"></a><a name="xml_attribute::as_double"></a><a name="xml_attribute::as_float"></a><a name="xml_attribute::as_bool"></a><a name="xml_attribute::as_llong"></a><a name="xml_attribute::as_ullong"></a>In many cases attribute values have types + that are not strings - i.e. an attribute may always contain values that should + be treated as integers, despite the fact that they are represented as strings + in XML. pugixml provides several accessors that convert attribute value to + some other type: </p> <pre class="programlisting"><span class="keyword">int</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_int</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_uint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">double</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_double</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">float</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_float</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_bool</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_llong</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +<span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_ullong</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> </pre> <p> <code class="computeroutput"><span class="identifier">as_int</span></code>, <code class="computeroutput"><span class="identifier">as_uint</span></code>, + <code class="computeroutput"><span class="identifier">as_llong</span></code>, <code class="computeroutput"><span class="identifier">as_ullong</span></code>, <code class="computeroutput"><span class="identifier">as_double</span></code> and <code class="computeroutput"><span class="identifier">as_float</span></code> convert attribute values to numbers. If attribute handle is null or attribute value is empty, <code class="computeroutput"><span class="identifier">def</span></code> argument is returned (which is 0 by default). Otherwise, all leading whitespace - characters are truncated, and the remaining string is parsed as a decimal - number (<code class="computeroutput"><span class="identifier">as_int</span></code> or <code class="computeroutput"><span class="identifier">as_uint</span></code>) or as a floating point number - in either decimal or scientific form (<code class="computeroutput"><span class="identifier">as_double</span></code> - or <code class="computeroutput"><span class="identifier">as_float</span></code>). Any extra characters - are silently discarded, i.e. <code class="computeroutput"><span class="identifier">as_int</span></code> - will return <code class="computeroutput"><span class="number">1</span></code> for string <code class="computeroutput"><span class="string">"1abc"</span></code>. + characters are truncated, and the remaining string is parsed as an integer + number in either decimal or hexadecimal form (applicable to <code class="computeroutput"><span class="identifier">as_int</span></code>, <code class="computeroutput"><span class="identifier">as_uint</span></code>, + <code class="computeroutput"><span class="identifier">as_llong</span></code> and <code class="computeroutput"><span class="identifier">as_ullong</span></code>; hexadecimal format is used if + the number has <code class="computeroutput"><span class="number">0</span><span class="identifier">x</span></code> + or <code class="computeroutput"><span class="number">0</span><span class="identifier">X</span></code> + prefix) or as a floating point number in either decimal or scientific form + (<code class="computeroutput"><span class="identifier">as_double</span></code> or <code class="computeroutput"><span class="identifier">as_float</span></code>). Any extra characters are silently + discarded, i.e. <code class="computeroutput"><span class="identifier">as_int</span></code> will + return <code class="computeroutput"><span class="number">1</span></code> for string <code class="computeroutput"><span class="string">"1abc"</span></code>. </p> <p> In case the input string contains a number that is out of the target numeric @@ -282,17 +291,16 @@ <th align="left">Note</th> </tr> <tr><td align="left" valign="top"><p> - There are no portable 64-bit types in C++, so there is no corresponding - conversion function. If your platform has a 64-bit integer, you can easily - write a conversion function yourself. + <code class="computeroutput"><span class="identifier">as_llong</span></code> and <code class="computeroutput"><span class="identifier">as_ullong</span></code> are only available if your + platform has reliable support for the <code class="computeroutput"><span class="keyword">long</span> + <span class="keyword">long</span></code> type, including string conversions. </p></td></tr> </table></div> -<a name="code_traverse_base_data"></a><p> - This is an example of using these functions, along with node data retrieval - ones (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>): +<p> + <a name="code_traverse_base_data"></a>This is an example of using these functions, + along with node data retrieval ones (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span> <span class="special">{</span> @@ -307,11 +315,12 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.contents"></a><a class="link" href="access.html#manual.access.contents" title="Contents-based traversal functions"> Contents-based traversal functions</a> +<a name="manual.access.contents"></a><a class="link" href="access.html#manual.access.contents" title="Contents-based traversal functions">Contents-based traversal functions</a> </h3></div></div></div> -<a name="xml_node::child"></a><a name="xml_node::attribute"></a><a name="xml_node::next_sibling_name"></a><a name="xml_node::previous_sibling_name"></a><p> - Since a lot of document traversal consists of finding the node/attribute - with the correct name, there are special functions for that purpose: +<p> + <a name="xml_node::child"></a><a name="xml_node::attribute"></a><a name="xml_node::next_sibling_name"></a><a name="xml_node::previous_sibling_name"></a>Since a lot of document traversal consists + of finding the node/attribute with the correct name, there are special functions + for that purpose: </p> <pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">child</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -333,11 +342,15 @@ </p> <pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span> </pre> -<a name="xml_node::find_child_by_attribute"></a><p> - Occasionally the needed node is specified not by the unique name but instead - by the value of some attribute; for example, it is common to have node collections - with each node having a unique id: <code class="computeroutput"><span class="special"><</span><span class="identifier">group</span><span class="special">><</span><span class="identifier">item</span> <span class="identifier">id</span><span class="special">=</span><span class="string">"1"</span><span class="special">/></span> <span class="special"><</span><span class="identifier">item</span> <span class="identifier">id</span><span class="special">=</span><span class="string">"2"</span><span class="special">/></</span><span class="identifier">group</span><span class="special">></span></code>. There are two functions for finding - child nodes based on the attribute values: +<p> + <a name="xml_node::find_child_by_attribute"></a>Occasionally the needed node + is specified not by the unique name but instead by the value of some attribute; + for example, it is common to have node collections with each node having + a unique id: <code class="computeroutput"><span class="special"><</span><span class="identifier">group</span><span class="special">><</span><span class="identifier">item</span> + <span class="identifier">id</span><span class="special">=</span><span class="string">"1"</span><span class="special">/></span> + <span class="special"><</span><span class="identifier">item</span> + <span class="identifier">id</span><span class="special">=</span><span class="string">"2"</span><span class="special">/></</span><span class="identifier">group</span><span class="special">></span></code>. + There are two functions for finding child nodes based on the attribute values: </p> <pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -357,7 +370,6 @@ This is an example of using these functions (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Tool for *.dae generation: "</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">,</span> <span class="string">"OutputFileMasks"</span><span class="special">,</span> <span class="string">"*.dae"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"\n"</span><span class="special">;</span> @@ -371,12 +383,13 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.rangefor"></a><a class="link" href="access.html#manual.access.rangefor" title="Range-based for-loop support"> Range-based for-loop support</a> +<a name="manual.access.rangefor"></a><a class="link" href="access.html#manual.access.rangefor" title="Range-based for-loop support">Range-based for-loop support</a> </h3></div></div></div> -<a name="xml_node::children"></a><a name="xml_node::attributes"></a><p> - If your C++ compiler supports range-based for-loop (this is a C++11 feature, - at the time of writing it's supported by Microsoft Visual Studio 11 Beta, - GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional +<p> + <a name="xml_node::children"></a><a name="xml_node::attributes"></a>If your + C++ compiler supports range-based for-loop (this is a C++11 feature, at the + time of writing it's supported by Microsoft Visual Studio 11 Beta, GCC 4.6 + and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with <a href="http://www.boost.org/libs/foreach/" target="_top">Boost Foreach</a>, and possibly other pre-C++11 foreach facilities. @@ -397,7 +410,6 @@ This is an example of using these functions (<a href="../samples/traverse_rangefor.cpp" target="_top">samples/traverse_rangefor.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span><span class="special">:</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">children</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span> <span class="special">{</span> @@ -421,12 +433,12 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.iterators"></a><a class="link" href="access.html#manual.access.iterators" title="Traversing node/attribute lists via iterators"> Traversing node/attribute lists +<a name="manual.access.iterators"></a><a class="link" href="access.html#manual.access.iterators" title="Traversing node/attribute lists via iterators">Traversing node/attribute lists via iterators</a> </h3></div></div></div> -<a name="xml_node_iterator"></a><a name="xml_attribute_iterator"></a><a name="xml_node::begin"></a><a name="xml_node::end"></a><a name="xml_node::attributes_begin"></a><a name="xml_node::attributes_end"></a><p> - Child node lists and attribute lists are simply double-linked lists; while - you can use <code class="computeroutput"><span class="identifier">previous_sibling</span></code>/<code class="computeroutput"><span class="identifier">next_sibling</span></code> and other such functions for +<p> + <a name="xml_node_iterator"></a><a name="xml_attribute_iterator"></a><a name="xml_node::begin"></a><a name="xml_node::end"></a><a name="xml_node::attributes_begin"></a><a name="xml_node::attributes_end"></a>Child node lists and attribute lists are simply + double-linked lists; while you can use <code class="computeroutput"><span class="identifier">previous_sibling</span></code>/<code class="computeroutput"><span class="identifier">next_sibling</span></code> and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes: </p> @@ -474,7 +486,6 @@ Here is an example of using iterators for document traversal (<a href="../samples/traverse_iter.cpp" target="_top">samples/traverse_iter.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> <span class="special">{</span> @@ -507,14 +518,14 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.walker"></a><a class="link" href="access.html#manual.access.walker" title="Recursive traversal with xml_tree_walker"> Recursive traversal with xml_tree_walker</a> +<a name="manual.access.walker"></a><a class="link" href="access.html#manual.access.walker" title="Recursive traversal with xml_tree_walker">Recursive traversal with xml_tree_walker</a> </h3></div></div></div> -<a name="xml_tree_walker"></a><p> - The methods described above allow traversal of immediate children of some - node; if you want to do a deep tree traversal, you'll have to do it via a - recursive function or some equivalent method. However, pugixml provides a - helper for depth-first traversal of a subtree. In order to use it, you have - to implement <code class="computeroutput"><span class="identifier">xml_tree_walker</span></code> +<p> + <a name="xml_tree_walker"></a>The methods described above allow traversal + of immediate children of some node; if you want to do a deep tree traversal, + you'll have to do it via a recursive function or some equivalent method. + However, pugixml provides a helper for depth-first traversal of a subtree. + In order to use it, you have to implement <code class="computeroutput"><span class="identifier">xml_tree_walker</span></code> interface and to call <code class="computeroutput"><span class="identifier">traverse</span></code> function: </p> @@ -530,11 +541,12 @@ <span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">traverse</span><span class="special">(</span><span class="identifier">xml_tree_walker</span><span class="special">&</span> <span class="identifier">walker</span><span class="special">);</span> </pre> -<a name="xml_tree_walker::begin"></a><a name="xml_tree_walker::for_each"></a><a name="xml_tree_walker::end"></a><a name="xml_node::traverse"></a><p> - The traversal is launched by calling <code class="computeroutput"><span class="identifier">traverse</span></code> +<p> + <a name="xml_tree_walker::begin"></a><a name="xml_tree_walker::for_each"></a><a name="xml_tree_walker::end"></a><a name="xml_node::traverse"></a>The traversal + is launched by calling <code class="computeroutput"><span class="identifier">traverse</span></code> function on traversal root and proceeds as follows: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> First, <code class="computeroutput"><span class="identifier">begin</span></code> function is called with traversal root as its argument. @@ -558,10 +570,10 @@ <code class="computeroutput"><span class="identifier">begin</span></code> or <code class="computeroutput"><span class="identifier">end</span></code> functions; their default implementations return <code class="computeroutput"><span class="keyword">true</span></code>. </p> -<a name="xml_tree_walker::depth"></a><p> - You can get the node's depth relative to the traversal root at any point - by calling <code class="computeroutput"><span class="identifier">depth</span></code> function. - It returns <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code> +<p> + <a name="xml_tree_walker::depth"></a>You can get the node's depth relative + to the traversal root at any point by calling <code class="computeroutput"><span class="identifier">depth</span></code> + function. It returns <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code> if called from <code class="computeroutput"><span class="identifier">begin</span></code>/<code class="computeroutput"><span class="identifier">end</span></code>, and returns 0-based depth if called from <code class="computeroutput"><span class="identifier">for_each</span></code> - depth is 0 for all children of the traversal root, 1 for all grandchildren and so @@ -571,24 +583,22 @@ This is an example of traversing tree hierarchy with xml_tree_walker (<a href="../samples/traverse_walker.cpp" target="_top">samples/traverse_walker.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">simple_walker</span><span class="special">:</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_tree_walker</span> <span class="special">{</span> <span class="keyword">virtual</span> <span class="keyword">bool</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> - <span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">depth</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">" "</span><span class="special">;</span> <span class="comment">// indentation -</span> + <span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">depth</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">" "</span><span class="special">;</span> <span class="comment">// indentation</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">node_types</span><span class="special">[</span><span class="identifier">node</span><span class="special">.</span><span class="identifier">type</span><span class="special">()]</span> <span class="special"><<</span> <span class="string">": name='"</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"', value='"</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"'\n"</span><span class="special">;</span> - <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span> <span class="comment">// continue traversal -</span> <span class="special">}</span> + <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span> <span class="comment">// continue traversal</span> + <span class="special">}</span> <span class="special">};</span> </pre> <p> </p> <p> - </p> <pre class="programlisting"><span class="identifier">simple_walker</span> <span class="identifier">walker</span><span class="special">;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">traverse</span><span class="special">(</span><span class="identifier">walker</span><span class="special">);</span> @@ -598,15 +608,15 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.predicate"></a><a class="link" href="access.html#manual.access.predicate" title="Searching for nodes/attributes with predicates"> Searching for nodes/attributes +<a name="manual.access.predicate"></a><a class="link" href="access.html#manual.access.predicate" title="Searching for nodes/attributes with predicates">Searching for nodes/attributes with predicates</a> </h3></div></div></div> -<a name="xml_node::find_attribute"></a><a name="xml_node::find_child"></a><a name="xml_node::find_node"></a><p> - While there are existing functions for getting a node/attribute with known - contents, they are often not sufficient for simple queries. As an alternative - for manual iteration through nodes/attributes until the needed one is found, - you can make a predicate and call one of <code class="computeroutput"><span class="identifier">find_</span></code> - functions: +<p> + <a name="xml_node::find_attribute"></a><a name="xml_node::find_child"></a><a name="xml_node::find_node"></a>While there are existing functions for getting + a node/attribute with known contents, they are often not sufficient for simple + queries. As an alternative for manual iteration through nodes/attributes + until the needed one is found, you can make a predicate and call one of + <code class="computeroutput"><span class="identifier">find_</span></code> functions: </p> <pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">></span> <span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_attribute</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">></span> <span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -648,7 +658,6 @@ This is an example of using predicate-based functions (<a href="../samples/traverse_predicate.cpp" target="_top">samples/traverse_predicate.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">small_timeout</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> @@ -671,29 +680,29 @@ <p> </p> <p> - </p> -<pre class="programlisting"><span class="comment">// Find child via predicate (looks for direct children only) -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// Find child via predicate (looks for direct children only)</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// Find node via predicate (looks for all descendants in depth-first order) -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">find_node</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="comment">// Find node via predicate (looks for all descendants in depth-first order)</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">find_node</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// Find attribute via predicate -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">find_attribute</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="comment">// Find attribute via predicate</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">find_attribute</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// We can use simple functions instead of function objects -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">small_timeout</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="comment">// We can use simple functions instead of function objects</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">small_timeout</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.text"></a><a class="link" href="access.html#manual.access.text" title="Working with text contents"> Working with text contents</a> +<a name="manual.access.text"></a><a class="link" href="access.html#manual.access.text" title="Working with text contents">Working with text contents</a> </h3></div></div></div> -<a name="xml_text"></a><p> - It is common to store data as text contents of some node - i.e. <code class="computeroutput"><span class="special"><</span><span class="identifier">node</span><span class="special">><</span><span class="identifier">description</span><span class="special">></span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special"></</span><span class="identifier">description</span><span class="special">></</span><span class="identifier">node</span><span class="special">></span></code>. +<p> + <a name="xml_text"></a>It is common to store data as text contents of some + node - i.e. <code class="computeroutput"><span class="special"><</span><span class="identifier">node</span><span class="special">><</span><span class="identifier">description</span><span class="special">></span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special"></</span><span class="identifier">description</span><span class="special">></</span><span class="identifier">node</span><span class="special">></span></code>. In this case, <code class="computeroutput"><span class="special"><</span><span class="identifier">description</span><span class="special">></span></code> node does not have a value, but instead has a child of type <a class="link" href="dom.html#node_pcdata">node_pcdata</a> with value <code class="computeroutput"><span class="string">"This is a node"</span></code>. pugixml @@ -702,8 +711,10 @@ in <a class="link" href="modify.html#manual.modify.text" title="Working with text contents">the documentation for modifying document data</a>; this section describes the access interface of <code class="computeroutput"><span class="identifier">xml_text</span></code>. </p> -<a name="xml_node::text"></a><p> - You can get the text object from a node by using <code class="computeroutput"><span class="identifier">text</span><span class="special">()</span></code> method: +<p> + <a name="xml_node::text"></a>You can get the text object from a node by using + <code class="computeroutput"><span class="identifier">text</span><span class="special">()</span></code> + method: </p> <pre class="programlisting"><span class="identifier">xml_text</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">text</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> @@ -713,11 +724,11 @@ itself is used to return data; otherwise, a first child node of type <code class="computeroutput"><span class="identifier">node_pcdata</span></code> or <code class="computeroutput"><span class="identifier">node_cdata</span></code> is used. </p> -<a name="xml_text::empty"></a><a name="xml_text::unspecified_bool_type"></a><p> - You can check if the text object is bound to a valid PCDATA/CDATA node by - using it as a boolean value, i.e. <code class="computeroutput"><span class="keyword">if</span> - <span class="special">(</span><span class="identifier">text</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> - <span class="special">}</span></code> or <code class="computeroutput"><span class="keyword">if</span> +<p> + <a name="xml_text::empty"></a><a name="xml_text::unspecified_bool_type"></a>You + can check if the text object is bound to a valid PCDATA/CDATA node by using + it as a boolean value, i.e. <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">text</span><span class="special">)</span> + <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code> or <code class="computeroutput"><span class="keyword">if</span> <span class="special">(!</span><span class="identifier">text</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>. Alternatively you can check it by using the <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code> @@ -725,9 +736,9 @@ </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> -<a name="xml_text::get"></a><p> - Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA - node) by using the following function: +<p> + <a name="xml_text::get"></a>Given a text object, you can get the contents + (i.e. the value of PCDATA/CDATA node) by using the following function: </p> <pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> @@ -735,10 +746,11 @@ In case text object is empty, the function returns an empty string - it never returns a null pointer. </p> -<a name="xml_text::as_string"></a><a name="xml_text::as_int"></a><a name="xml_text::as_uint"></a><a name="xml_text::as_double"></a><a name="xml_text::as_float"></a><a name="xml_text::as_bool"></a><p> - If you need a non-empty string if the text object is empty, or if the text - contents is actually a number or a boolean that is stored as a string, you - can use the following accessors: +<p> + <a name="xml_text::as_string"></a><a name="xml_text::as_int"></a><a name="xml_text::as_uint"></a><a name="xml_text::as_double"></a><a name="xml_text::as_float"></a><a name="xml_text::as_bool"></a><a name="xml_text::as_llong"></a><a name="xml_text::as_ullong"></a>If + you need a non-empty string if the text object is empty, or if the text contents + is actually a number or a boolean that is stored as a string, you can use + the following accessors: </p> <pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_string</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">def</span> <span class="special">=</span> <span class="string">""</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">int</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_int</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -746,6 +758,8 @@ <span class="keyword">double</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_double</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">float</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_float</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_bool</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_llong</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +<span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_ullong</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> </pre> <p> All of the above functions have the same semantics as similar <code class="computeroutput"><span class="identifier">xml_attribute</span></code> members: they return the @@ -753,9 +767,9 @@ to a target type using the same rules and restrictions. You can <a class="link" href="access.html#xml_attribute::as_int">refer to documentation for the attribute functions</a> for details. </p> -<a name="xml_text::data"></a><p> - <code class="computeroutput"><span class="identifier">xml_text</span></code> is essentially a - helper class that operates on <code class="computeroutput"><span class="identifier">xml_node</span></code> +<p> + <a name="xml_text::data"></a><code class="computeroutput"><span class="identifier">xml_text</span></code> + is essentially a helper class that operates on <code class="computeroutput"><span class="identifier">xml_node</span></code> values. It is bound to a node of type <a class="link" href="dom.html#node_pcdata">node_pcdata</a> or <a class="link" href="dom.html#node_cdata">node_cdata</a>. You can use the following function to retrieve this node: @@ -773,7 +787,6 @@ object (<a href="../samples/text.cpp" target="_top">samples/text.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Project name: "</span> <span class="special"><<</span> <span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"name"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">get</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Project version: "</span> <span class="special"><<</span> <span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"version"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">as_double</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> @@ -785,11 +798,11 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.access.misc"></a><a class="link" href="access.html#manual.access.misc" title="Miscellaneous functions"> Miscellaneous functions</a> +<a name="manual.access.misc"></a><a class="link" href="access.html#manual.access.misc" title="Miscellaneous functions">Miscellaneous functions</a> </h3></div></div></div> -<a name="xml_node::root"></a><p> - If you need to get the document root of some node, you can use the following - function: +<p> + <a name="xml_node::root"></a>If you need to get the document root of some + node, you can use the following function: </p> <pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">root</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> @@ -798,10 +811,11 @@ which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned). </p> -<a name="xml_node::path"></a><a name="xml_node::first_element_by_path"></a><p> - While pugixml supports complex XPath expressions, sometimes a simple path - handling facility is needed. There are two functions, for getting node path - and for converting path to a node: +<p> + <a name="xml_node::path"></a><a name="xml_node::first_element_by_path"></a>While + pugixml supports complex XPath expressions, sometimes a simple path handling + facility is needed. There are two functions, for getting node path and for + converting path to a node: </p> <pre class="programlisting"><span class="identifier">string_t</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">path</span><span class="special">(</span><span class="identifier">char_t</span> <span class="identifier">delimiter</span> <span class="special">=</span> <span class="char">'/'</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">first_element_by_path</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="identifier">char_t</span> <span class="identifier">delimiter</span> <span class="special">=</span> <span class="char">'/'</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -846,12 +860,13 @@ is defined. </p></td></tr> </table></div> -<a name="xml_node::offset_debug"></a><p> - pugixml does not record row/column information for nodes upon parsing for - efficiency reasons. However, if the node has not changed in a significant - way since parsing (the name/value are not changed, and the node itself is - the original one, i.e. it was not deleted from the tree and re-added later), - it is possible to get the offset from the beginning of XML buffer: +<p> + <a name="xml_node::offset_debug"></a>pugixml does not record row/column information + for nodes upon parsing for efficiency reasons. However, if the node has not + changed in a significant way since parsing (the name/value are not changed, + and the node itself is the original one, i.e. it was not deleted from the + tree and re-added later), it is possible to get the offset from the beginning + of XML buffer: </p> <pre class="programlisting"><span class="identifier">ptrdiff_t</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">offset_debug</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> @@ -867,7 +882,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -875,7 +890,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/apiref.html b/docs/manual/apiref.html index cf1a137..80e59e8 100644 --- a/docs/manual/apiref.html +++ b/docs/manual/apiref.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>API Reference</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="changes.html" title="Changelog"> <link rel="next" href="toc.html" title="Table of Contents"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,7 +28,7 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.apiref"></a><a class="link" href="apiref.html" title="API Reference"> API Reference</a> +<a name="manual.apiref"></a><a class="link" href="apiref.html" title="API Reference">API Reference</a> </h2></div></div></div> <p> This is the reference for all macros, types, enumerations, classes and functions @@ -38,7 +38,7 @@ <p> Macros: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a> </li> @@ -72,11 +72,14 @@ <li class="listitem"> <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_HEADER_ONLY">PUGIXML_HEADER_ONLY</a> </li> +<li class="listitem"> + <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_HAS_LONG_LONG">PUGIXML_HAS_LONG_LONG</a> + </li> </ul></div> <p> Types: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">typedef</span> </code><span class="emphasis"><em>configuration-defined type</em></span><code class="computeroutput"> </code><a class="link" href="dom.html#char_t">char_t</a><code class="computeroutput"><span class="special">;</span></code> @@ -97,10 +100,10 @@ <p> Enumerations: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="dom.html#xml_node_type">xml_node_type</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="dom.html#node_null">node_null</a> </li> @@ -127,13 +130,12 @@ </li> <li class="listitem"> <a class="link" href="dom.html#node_doctype">node_doctype</a> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="loading.html#xml_parse_status">xml_parse_status</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="loading.html#status_ok">status_ok</a> </li> @@ -178,14 +180,19 @@ </li> <li class="listitem"> <a class="link" href="loading.html#status_end_element_mismatch">status_end_element_mismatch</a> + </li> +<li class="listitem"> + <a class="link" href="modify.html#status_append_invalid_root">status_append_invalid_root</a> + </li> +<li class="listitem"> + <a class="link" href="loading.html#status_no_document_element">status_no_document_element</a> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="loading.html#xml_encoding">xml_encoding</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="loading.html#encoding_auto">encoding_auto</a> </li> @@ -215,13 +222,12 @@ </li> <li class="listitem"> <a class="link" href="loading.html#encoding_latin1">encoding_latin1</a> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="xpath.html#xpath_value_type">xpath_value_type</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="xpath.html#xpath_type_none">xpath_type_none</a> </li> @@ -243,10 +249,10 @@ <p> Constants: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Formatting options bit flags: - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="saving.html#format_default">format_default</a> </li> @@ -267,13 +273,12 @@ </li> <li class="listitem"> <a class="link" href="saving.html#format_write_bom">format_write_bom</a> <br><br> - </li> </ul></div> </li> <li class="listitem"> Parsing options bit flags: - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="loading.html#parse_cdata">parse_cdata</a> </li> @@ -296,6 +301,9 @@ <a class="link" href="loading.html#parse_escapes">parse_escapes</a> </li> <li class="listitem"> + <a class="link" href="loading.html#parse_fragment">parse_fragment</a> + </li> +<li class="listitem"> <a class="link" href="loading.html#parse_full">parse_full</a> </li> <li class="listitem"> @@ -305,6 +313,9 @@ <a class="link" href="loading.html#parse_pi">parse_pi</a> </li> <li class="listitem"> + <a class="link" href="loading.html#parse_trim_pcdata">parse_trim_pcdata</a> + </li> +<li class="listitem"> <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a> </li> <li class="listitem"> @@ -322,20 +333,18 @@ <p> Classes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="dom.html#xml_attribute">xml_attribute</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="dom.html#xml_attribute::ctor">xml_attribute</a><code class="computeroutput"><span class="special">();</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="dom.html#xml_attribute::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator==</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> @@ -367,25 +376,21 @@ <span class="identifier">r</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">size_t</span> </code><a class="link" href="dom.html#xml_attribute::hash_value">hash_value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_attribute::next_attribute">next_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_attribute::previous_attribute">previous_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_attribute::name">name</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_attribute::value">value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_attribute::as_string">as_string</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -419,8 +424,20 @@ <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_attribute::as_bool">as_bool</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span> + </code><a class="link" href="access.html#xml_attribute::as_llong">as_llong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> + <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span> + <span class="keyword">long</span> </code><a class="link" href="access.html#xml_attribute::as_ullong">as_ullong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span> + <span class="keyword">long</span> <span class="keyword">long</span> + <span class="identifier">def</span> <span class="special">=</span> + <span class="number">0</span><span class="special">)</span> + <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_name">set_name</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -443,8 +460,15 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span> + <span class="keyword">long</span> <span class="keyword">long</span> + <span class="identifier">rhs</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&</span> @@ -468,25 +492,32 @@ <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&</span> </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&</span> + </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&</span> + </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="identifier">unsnigned</span> + <span class="keyword">long</span> <span class="keyword">long</span> + <span class="identifier">rhs</span><span class="special">);</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="dom.html#xml_node">xml_node</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="dom.html#xml_node::ctor">xml_node</a><code class="computeroutput"><span class="special">();</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="dom.html#xml_node::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator==</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&</span> @@ -518,24 +549,20 @@ <span class="identifier">r</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">size_t</span> </code><a class="link" href="dom.html#xml_node::hash_value">hash_value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node_type</span> </code><a class="link" href="dom.html#xml_node::type">type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::name">name</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::value">value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::parent">parent</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> @@ -551,14 +578,12 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::previous_sibling">previous_sibling</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_node::first_attribute">first_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_node::last_attribute">last_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <span class="emphasis"><em>implementation-defined type</em></span> <a class="link" href="access.html#xml_node::children">children</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> @@ -570,7 +595,6 @@ </li> <li class="listitem"> <span class="emphasis"><em>implementation-defined type</em></span> <a class="link" href="access.html#xml_node::attributes">attributes</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::child">child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -602,7 +626,6 @@ <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::find_child_by_attribute">find_child_by_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::child_value">child_value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> @@ -614,7 +637,6 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_text</span> </code><a class="link" href="access.html#xml_node::text">text</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">xml_node_iterator</span> @@ -625,7 +647,6 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">iterator</span> </code><a class="link" href="access.html#xml_node::end">end</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">xml_attribute_iterator</span> @@ -636,11 +657,9 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">attribute_iterator</span> </code><a class="link" href="access.html#xml_node::attributes_end">attributes_end</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_node::traverse">traverse</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_tree_walker</span><span class="special">&</span> <span class="identifier">walker</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">></span> <span class="identifier">xml_attribute</span> @@ -660,7 +679,6 @@ <span class="identifier">pred</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">string_t</span> </code><a class="link" href="access.html#xml_node::path">path</a><code class="computeroutput"><span class="special">(</span><span class="identifier">char_t</span> @@ -679,7 +697,6 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">ptrdiff_t</span> </code><a class="link" href="access.html#xml_node::offset_debug">offset_debug</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::set_name">set_name</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -689,7 +706,6 @@ <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::append_attribute">append_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -708,7 +724,6 @@ <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::insert_attribute_before">insert_attribute_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">attr</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_child">append_child</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node_type</span> @@ -729,7 +744,6 @@ <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_child_before">insert_child_before</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node_type</span> <span class="identifier">type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_child">append_child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -748,7 +762,6 @@ <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_child_before">insert_child_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::append_copy">append_copy</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">proto</span><span class="special">);</span></code> @@ -766,7 +779,6 @@ <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::insert_copy_before">insert_copy_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">proto</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">attr</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_copy">append_copy</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&</span> @@ -785,7 +797,6 @@ <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_copy_before">insert_copy_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">proto</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::remove_attribute">remove_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> @@ -803,7 +814,15 @@ <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::remove_child">remove_child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span></code> <br><br> - + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="modify.html#xml_node::append_buffer">append_buffer</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> + <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> + <span class="keyword">int</span> <span class="identifier">options</span> + <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> + <span class="identifier">encoding</span> <span class="special">=</span> + <span class="identifier">encoding_auto</span><span class="special">);</span></code> + <br><br> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_node::print">print</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_writer</span><span class="special">&</span> <span class="identifier">writer</span><span class="special">,</span> <span class="keyword">const</span> @@ -844,7 +863,6 @@ <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xpath_node</span> </code><a class="link" href="xpath.html#xml_node::select_single_node">select_single_node</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -872,19 +890,17 @@ <span class="identifier">query</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="dom.html#xml_document">xml_document</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="dom.html#xml_document::ctor">xml_document</a><code class="computeroutput"><span class="special">();</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="special">~</span></code><a class="link" href="dom.html#xml_document::dtor">xml_document</a><code class="computeroutput"><span class="special">();</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="dom.html#xml_document::reset">reset</a><code class="computeroutput"><span class="special">();</span></code> @@ -893,7 +909,6 @@ <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="dom.html#xml_document::reset">reset</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_document</span><span class="special">&</span> <span class="identifier">proto</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_stream">load</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span> @@ -911,13 +926,11 @@ <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_string">load</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_file">load_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">unsigned</span> @@ -934,7 +947,6 @@ <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_buffer">load_buffer</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> @@ -961,7 +973,6 @@ <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="saving.html#xml_document::save_file">save_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> @@ -984,7 +995,6 @@ <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_document::save_stream">save</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">const</span> @@ -1007,7 +1017,6 @@ <span class="identifier">format_default</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_document::save">save</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_writer</span><span class="special">&</span> <span class="identifier">writer</span><span class="special">,</span> <span class="keyword">const</span> @@ -1019,17 +1028,15 @@ <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="dom.html#xml_document::document_element">document_element</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">struct</span> </code><a class="link" href="loading.html#xml_parse_result">xml_parse_result</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_parse_status</span> </code><a class="link" href="loading.html#xml_parse_result::status">status</a><code class="computeroutput"><span class="special">;</span></code> </li> @@ -1038,14 +1045,12 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_encoding</span> </code><a class="link" href="loading.html#xml_parse_result::encoding">encoding</a><code class="computeroutput"><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="loading.html#xml_parse_result::bool">bool</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="loading.html#xml_parse_result::description">description</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> @@ -1055,11 +1060,10 @@ <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_attribute_iterator">xml_attribute_iterator</a> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_tree_walker">xml_tree_walker</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">bool</span> </code><a class="link" href="access.html#xml_tree_walker::begin">begin</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">node</span><span class="special">);</span></code> @@ -1071,27 +1075,23 @@ <li class="listitem"> <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">bool</span> </code><a class="link" href="access.html#xml_tree_walker::end">end</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">int</span> </code><a class="link" href="access.html#xml_tree_walker::depth">depth</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_text">xml_text</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_text::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="access.html#xml_text::unspecified_bool_type">xml_text::unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_text::get">xml_text::get</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_text::as_string">as_string</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -1125,14 +1125,25 @@ <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_text::as_bool">as_bool</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span> + </code><a class="link" href="access.html#xml_text::as_llong">as_llong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> + <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span> + <span class="keyword">long</span> </code><a class="link" href="access.html#xml_text::as_ullong">as_ullong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span> + <span class="keyword">long</span> <span class="keyword">long</span> + <span class="identifier">def</span> <span class="special">=</span> + <span class="number">0</span><span class="special">)</span> + <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code> @@ -1147,8 +1158,15 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span> + <span class="keyword">long</span> <span class="keyword">long</span> + <span class="identifier">rhs</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&</span> @@ -1172,47 +1190,52 @@ <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&</span> </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&</span> + </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&</span> + </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span> + <span class="keyword">long</span> <span class="keyword">long</span> + <span class="identifier">rhs</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_text::data">data</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="saving.html#xml_writer">xml_writer</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"> <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">void</span> </code><a class="link" href="saving.html#xml_writer::write">write</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">data</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span></code> <br><br> - </li></ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="saving.html#xml_writer_file">xml_writer_file</a><code class="computeroutput"><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">xml_writer</span></code> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"> <a class="link" href="saving.html#xml_writer_file">xml_writer_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">file</span><span class="special">);</span></code> <br><br> - </li></ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="saving.html#xml_writer_stream">xml_writer_stream</a><code class="computeroutput"><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">xml_writer</span></code> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="saving.html#xml_writer_stream">xml_writer_stream</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">);</span></code> </li> <li class="listitem"> <a class="link" href="saving.html#xml_writer_stream">xml_writer_stream</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wostream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">);</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">struct</span> </code><a class="link" href="xpath.html#xpath_parse_result">xpath_parse_result</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_parse_result::error">error</a><code class="computeroutput"><span class="special">;</span></code> </li> @@ -1224,13 +1247,12 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_parse_result::description">description</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_query">xpath_query</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">explicit</span> </code><a class="link" href="xpath.html#xpath_query::ctor">xpath_query</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> @@ -1238,7 +1260,6 @@ <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_boolean">evaluate_boolean</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&</span> @@ -1265,41 +1286,36 @@ <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xpath_value_type</span> </code><a class="link" href="xpath.html#xpath_query::return_type">return_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&</span> </code><a class="link" href="xpath.html#xpath_query::result">result</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="xpath.html#xpath_query::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_exception">xpath_exception</a><code class="computeroutput"><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span></code> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_exception::what">what</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">throw</span><span class="special">();</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&</span> </code><a class="link" href="xpath.html#xpath_exception::result">result</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_node">xpath_node</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="xpath.html#xpath_node::ctor">xpath_node</a><code class="computeroutput"><span class="special">();</span></code> </li> @@ -1311,7 +1327,6 @@ <span class="identifier">xml_node</span><span class="special">&</span> <span class="identifier">parent</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="xpath.html#xpath_node::node">node</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> @@ -1322,7 +1337,6 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="xpath.html#xpath_node::parent">parent</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="xpath.html#xpath_node::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> @@ -1337,13 +1351,12 @@ <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_node_set">xpath_node_set</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <a class="link" href="xpath.html#xpath_node_set::ctor">xpath_node_set</a><code class="computeroutput"><span class="special">();</span></code> </li> @@ -1354,7 +1367,6 @@ <span class="identifier">type</span> <span class="special">=</span> <span class="identifier">type_unsorted</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">typedef</span> <span class="keyword">const</span> @@ -1369,7 +1381,6 @@ <code class="computeroutput"><span class="identifier">const_iterator</span> </code><a class="link" href="xpath.html#xpath_node_set::end">end</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&</span> </code><a class="link" href="xpath.html#xpath_node_set::index">operator[]</a><code class="computeroutput"><span class="special">(</span><span class="identifier">size_t</span> @@ -1381,13 +1392,11 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_node_set::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xpath_node</span> </code><a class="link" href="xpath.html#xpath_node_set::first">first</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">enum</span> <span class="identifier">type_t</span> @@ -1402,13 +1411,12 @@ <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="xpath.html#xpath_node_set::sort">sort</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">reverse</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">);</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_variable">xpath_variable</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_variable::name">name</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> </li> @@ -1416,7 +1424,6 @@ <code class="computeroutput"><span class="identifier">xpath_value_type</span> </code><a class="link" href="xpath.html#xpath_variable::type">type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::get_boolean">get_boolean</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> @@ -1429,7 +1436,6 @@ </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&</span> </code><a class="link" href="xpath.html#xpath_variable::get_node_set">get_node_set</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span></code> @@ -1446,19 +1452,17 @@ <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&</span> <span class="identifier">value</span><span class="special">);</span></code> <br><br> - </li> </ul></div> </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_variable_set">xpath_variable_set</a> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> <code class="computeroutput"><span class="identifier">xpath_variable</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_variable_set::add">add</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">xpath_value_type</span> <span class="identifier">type</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable_set::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> @@ -1479,7 +1483,6 @@ <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable_set::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&</span> <span class="identifier">value</span><span class="special">);</span></code> <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">xpath_variable</span><span class="special">*</span> @@ -1491,7 +1494,6 @@ <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br> - </li> </ul></div> </li> @@ -1499,7 +1501,7 @@ <p> Functions: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> </code><a class="link" href="dom.html#as_utf8">as_utf8</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span></code> </li> @@ -1529,7 +1531,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -1537,7 +1539,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/changes.html b/docs/manual/changes.html index d119532..48644a3 100644 --- a/docs/manual/changes.html +++ b/docs/manual/changes.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Changelog</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="xpath.html" title="XPath"> <link rel="next" href="apiref.html" title="API Reference"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,18 +28,102 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.changes"></a><a class="link" href="changes.html" title="Changelog"> Changelog</a> +<a name="manual.changes"></a><a class="link" href="changes.html" title="Changelog">Changelog</a> </h2></div></div></div> -<a name="manual.changes.1_05_2012___version_1_2"></a><h6> - <a class="link" href="changes.html#manual.changes.1_05_2012___version_1_2">1.05.2012 - version - 1.2</a> +<h6> +<a name="manual.changes.h0"></a> + <span class="phrase"><a name="manual.changes.1_03_2014___version_1_4"></a></span><a class="link" href="changes.html#manual.changes.1_03_2014___version_1_4">1.03.2014 + - version 1.4</a> + </h6> +<p> + Major release, featuring various new features, bug fixes and compatibility + improvements. + </p> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> +<li class="listitem"> + Specification changes: + <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> + Documents without element nodes are now rejected with status_no_document_element + error, unless parse_fragment option is used + </li></ol></div> + </li> +<li class="listitem"> + New features: + <div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + Added XML fragment parsing (parse_fragment flag) + </li> +<li class="listitem"> + Added PCDATA whitespace trimming (parse_trim_pcdata flag) + </li> +<li class="listitem"> + Added long long support for xml_attribute and xml_text (as_llong, + as_ullong and set_value/set overloads) + </li> +<li class="listitem"> + Added hexadecimal integer parsing support for as_int/as_uint/as_llong/as_ullong + </li> +<li class="listitem"> + Added xml_node::append_buffer to improve performance of assembling + documents from fragments + </li> +<li class="listitem"> + xml_named_node_iterator is now bidirectional + </li> +<li class="listitem"> + Reduced XPath stack consumption during compilation and evaluation + (useful for embedded systems) + </li> +</ol></div> + </li> +<li class="listitem"> + Compatibility improvements: + <div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + Improved support for platforms without wchar_t support + </li> +<li class="listitem"> + Fixed several false positives in clang static analysis + </li> +<li class="listitem"> + Fixed several compilation warnings for various GCC versions + </li> +</ol></div> + </li> +<li class="listitem"> + Bug fixes: + <div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + Fixed undefined pointer arithmetic in XPath implementation + </li> +<li class="listitem"> + Fixed non-seekable iostream support for certain stream types, i.e. + boost file_source with pipe input + </li> +<li class="listitem"> + Fixed xpath_query::return_type() for some expressions + </li> +<li class="listitem"> + Fixed dllexport issues with xml_named_node_iterator + </li> +<li class="listitem"> + Fixed find_child_by_attribute assertion for attributes with null + name/value + </li> +</ol></div> + </li> +</ul></div> +<h6> +<a name="manual.changes.h1"></a> + <span class="phrase"><a name="manual.changes.1_05_2012___version_1_2"></a></span><a class="link" href="changes.html#manual.changes.1_05_2012___version_1_2">1.05.2012 + - version 1.2</a> </h6> <p> Major release, featuring header-only mode, various interface enhancements (i.e. PCDATA manipulation and C++11 iteration), many other features and compatibility improvements. </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> New features: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -124,15 +208,16 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.1_11_2010___version_1_0"></a><h6> - <a class="link" href="changes.html#manual.changes.1_11_2010___version_1_0">1.11.2010 - version - 1.0</a> +<h6> +<a name="manual.changes.h2"></a> + <span class="phrase"><a name="manual.changes.1_11_2010___version_1_0"></a></span><a class="link" href="changes.html#manual.changes.1_11_2010___version_1_0">1.11.2010 + - version 1.0</a> </h6> <p> Major release, featuring many XPath enhancements, wide character filename support, miscellaneous performance improvements, bug fixes and more. </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> XPath: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -342,15 +427,16 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.1_07_2010___version_0_9"></a><h6> - <a class="link" href="changes.html#manual.changes.1_07_2010___version_0_9">1.07.2010 - version - 0.9</a> +<h6> +<a name="manual.changes.h3"></a> + <span class="phrase"><a name="manual.changes.1_07_2010___version_0_9"></a></span><a class="link" href="changes.html#manual.changes.1_07_2010___version_0_9">1.07.2010 + - version 0.9</a> </h6> <p> Major release, featuring extended and improved Unicode support, miscellaneous performance improvements, bug fixes and more. </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Major Unicode improvements: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -463,14 +549,15 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.8_11_2009___version_0_5"></a><h6> - <a class="link" href="changes.html#manual.changes.8_11_2009___version_0_5">8.11.2009 - version - 0.5</a> +<h6> +<a name="manual.changes.h4"></a> + <span class="phrase"><a name="manual.changes.8_11_2009___version_0_5"></a></span><a class="link" href="changes.html#manual.changes.8_11_2009___version_0_5">8.11.2009 + - version 0.5</a> </h6> <p> Major bugfix release. Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> XPath bugfixes: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -574,14 +661,15 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.17_09_2009___version_0_42"></a><h6> - <a class="link" href="changes.html#manual.changes.17_09_2009___version_0_42">17.09.2009 - version - 0.42</a> +<h6> +<a name="manual.changes.h5"></a> + <span class="phrase"><a name="manual.changes.17_09_2009___version_0_42"></a></span><a class="link" href="changes.html#manual.changes.17_09_2009___version_0_42">17.09.2009 + - version 0.42</a> </h6> <p> Maintenance release. Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Bug fixes: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -619,28 +707,30 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.8_02_2009___version_0_41"></a><h6> - <a class="link" href="changes.html#manual.changes.8_02_2009___version_0_41">8.02.2009 - version - 0.41</a> +<h6> +<a name="manual.changes.h6"></a> + <span class="phrase"><a name="manual.changes.8_02_2009___version_0_41"></a></span><a class="link" href="changes.html#manual.changes.8_02_2009___version_0_41">8.02.2009 + - version 0.41</a> </h6> <p> Maintenance release. Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Bug fixes: <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> Fixed bug with node printing (occasionally some content was not written to output stream) </li></ol></div> </li></ul></div> -<a name="manual.changes.18_01_2009___version_0_4"></a><h6> - <a class="link" href="changes.html#manual.changes.18_01_2009___version_0_4">18.01.2009 - version - 0.4</a> +<h6> +<a name="manual.changes.h7"></a> + <span class="phrase"><a name="manual.changes.18_01_2009___version_0_4"></a></span><a class="link" href="changes.html#manual.changes.18_01_2009___version_0_4">18.01.2009 + - version 0.4</a> </h6> <p> Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Bug fixes: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -711,14 +801,15 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.31_10_2007___version_0_34"></a><h6> - <a class="link" href="changes.html#manual.changes.31_10_2007___version_0_34">31.10.2007 - version - 0.34</a> +<h6> +<a name="manual.changes.h8"></a> + <span class="phrase"><a name="manual.changes.31_10_2007___version_0_34"></a></span><a class="link" href="changes.html#manual.changes.31_10_2007___version_0_34">31.10.2007 + - version 0.34</a> </h6> <p> Maintenance release. Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Bug fixes: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -749,14 +840,15 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.21_02_2007___version_0_3"></a><h6> - <a class="link" href="changes.html#manual.changes.21_02_2007___version_0_3">21.02.2007 - version - 0.3</a> +<h6> +<a name="manual.changes.h9"></a> + <span class="phrase"><a name="manual.changes.21_02_2007___version_0_3"></a></span><a class="link" href="changes.html#manual.changes.21_02_2007___version_0_3">21.02.2007 + - version 0.3</a> </h6> <p> Refactored, reworked and improved version. Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Interface: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -810,14 +902,15 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.6_11_2006___version_0_2"></a><h6> - <a class="link" href="changes.html#manual.changes.6_11_2006___version_0_2">6.11.2006 - version - 0.2</a> +<h6> +<a name="manual.changes.h10"></a> + <span class="phrase"><a name="manual.changes.6_11_2006___version_0_2"></a></span><a class="link" href="changes.html#manual.changes.6_11_2006___version_0_2">6.11.2006 + - version 0.2</a> </h6> <p> First public release. Changes: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Bug fixes: <div class="orderedlist"><ol class="orderedlist" type="1"> @@ -844,9 +937,10 @@ </ol></div> </li> </ul></div> -<a name="manual.changes.15_07_2006___version_0_1"></a><h6> - <a class="link" href="changes.html#manual.changes.15_07_2006___version_0_1">15.07.2006 - version - 0.1</a> +<h6> +<a name="manual.changes.h11"></a> + <span class="phrase"><a name="manual.changes.15_07_2006___version_0_1"></a></span><a class="link" href="changes.html#manual.changes.15_07_2006___version_0_1">15.07.2006 + - version 0.1</a> </h6> <p> First private release for testing purposes @@ -854,7 +948,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -862,7 +956,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/dom.html b/docs/manual/dom.html index 22d8d83..57d3ea0 100644 --- a/docs/manual/dom.html +++ b/docs/manual/dom.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Document object model</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="install.html" title="Installation"> <link rel="next" href="loading.html" title="Loading document"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,20 +28,20 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.dom"></a><a class="link" href="dom.html" title="Document object model"> Document object model</a> +<a name="manual.dom"></a><a class="link" href="dom.html" title="Document object model">Document object model</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="dom.html#manual.dom.tree"> Tree structure</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.cpp"> C++ interface</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.unicode"> Unicode interface</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.thread"> Thread-safety guarantees</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.exception"> Exception guarantees</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.memory"> Memory management</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="dom.html#manual.dom.tree">Tree structure</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.cpp">C++ interface</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.unicode">Unicode interface</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.thread">Thread-safety guarantees</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.exception">Exception guarantees</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.memory">Memory management</a></span></dt> <dd><dl> -<dt><span class="section"><a href="dom.html#manual.dom.memory.custom"> Custom memory allocation/deallocation +<dt><span class="section"><a href="dom.html#manual.dom.memory.custom">Custom memory allocation/deallocation functions</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.memory.tuning"> Memory consumption tuning</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.memory.internals"> Document memory management +<dt><span class="section"><a href="dom.html#manual.dom.memory.tuning">Memory consumption tuning</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.memory.internals">Document memory management internals</a></span></dt> </dl></dd> </dl></div> @@ -56,7 +56,7 @@ </p> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.dom.tree"></a><a class="link" href="dom.html#manual.dom.tree" title="Tree structure"> Tree structure</a> +<a name="manual.dom.tree"></a><a class="link" href="dom.html#manual.dom.tree" title="Tree structure">Tree structure</a> </h3></div></div></div> <p> The XML document is represented with a tree data structure. The root of the @@ -66,11 +66,11 @@ which correspond to C++ type <a class="link" href="dom.html#xml_attribute">xml_attribute</a>, and some additional data (i.e. name). </p> -<a name="xml_node_type"></a><p> - The tree nodes can be of one of the following types (which together form - the enumeration <code class="computeroutput"><span class="identifier">xml_node_type</span></code>): +<p> + <a name="xml_node_type"></a>The tree nodes can be of one of the following + types (which together form the enumeration <code class="computeroutput"><span class="identifier">xml_node_type</span></code>): </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Document node (<a name="node_document"></a><code class="literal">node_document</code>) - this is the root of the tree, which consists of several child nodes. This @@ -81,7 +81,6 @@ several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation. <br><br> - </li> <li class="listitem"> Element/tag node (<a name="node_element"></a><code class="literal">node_element</code>) - this @@ -100,7 +99,7 @@ another has name <code class="computeroutput"><span class="string">"child"</span></code> and does not have any attributes or child nodes. </p></blockquote></div> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Plain character data nodes (<a name="node_pcdata"></a><code class="literal">node_pcdata</code>) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that <span class="bold"><strong>plain @@ -115,7 +114,7 @@ has three children, two of which are PCDATA nodes with values <code class="computeroutput"><span class="string">" text1 "</span></code> and <code class="computeroutput"><span class="string">" text2 "</span></code>. </p></blockquote></div> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Character data nodes (<a name="node_cdata"></a><code class="literal">node_cdata</code>) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example @@ -128,7 +127,7 @@ in plain text. CDATA value can not contain the character sequence ]]>, since it is used to determine the end of node contents. </p></blockquote></div> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Comment nodes (<a name="node_comment"></a><code class="literal">node_comment</code>) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node @@ -143,7 +142,7 @@ this behavior with <a class="link" href="loading.html#parse_comments">parse_comments</a> flag. </p></blockquote></div> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Processing instruction node (<a name="node_pi"></a><code class="literal">node_pi</code>) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation @@ -158,7 +157,7 @@ are not loaded during XML parsing. You can override this behavior with <a class="link" href="loading.html#parse_pi">parse_pi</a> flag. </p></blockquote></div> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Declaration node (<a name="node_declaration"></a><code class="literal">node_declaration</code>) represents document declarations in XML. Declaration nodes have a name (<code class="computeroutput"><span class="string">"xml"</span></code>) and an @@ -180,7 +179,7 @@ there is already a declaration in the document; you can disable this with <a class="link" href="saving.html#format_no_declaration">format_no_declaration</a> flag. </p></blockquote></div> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Document type declaration node (<a name="node_doctype"></a><code class="literal">node_doctype</code>) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; @@ -189,7 +188,7 @@ (its parent should be the document). The example XML representation of a document type declaration node is as follows: </li></ul></div> -<pre class="programlisting"><span class="special"><!</span><span class="identifier">DOCTYPE</span> <span class="identifier">greeting</span> <span class="special">[</span> <span class="special"><!</span><span class="identifier">ELEMENT</span> <span class="identifier">greeting</span> <span class="special">(</span><span class="preprocessor">#PCDATA</span><span class="special">)></span> <span class="special">]></span> +<pre class="programlisting"><span class="special"><!</span><span class="identifier">DOCTYPE</span> <span class="identifier">greeting</span> <span class="special">[</span> <span class="special"><!</span><span class="identifier">ELEMENT</span> <span class="identifier">greeting</span> <span class="special">(#</span><span class="identifier">PCDATA</span><span class="special">)></span> <span class="special">]></span> </pre> <div class="blockquote"><blockquote class="blockquote"><p> Here the node has value <code class="computeroutput"><span class="string">"greeting [ <!ELEMENT @@ -209,7 +208,6 @@ <tbody><tr> <td> <p> - </p> <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special"><?</span><span class="identifier">xml</span> <span class="identifier">version</span><span class="special">=</span><span class="string">"1.0"</span><span class="special">?></span> <span class="special"><</span><span class="identifier">mesh</span> <span class="identifier">name</span><span class="special">=</span><span class="string">"mesh_root"</span><span class="special">></span> @@ -237,7 +235,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.dom.cpp"></a><a class="link" href="dom.html#manual.dom.cpp" title="C++ interface"> C++ interface</a> +<a name="manual.dom.cpp"></a><a class="link" href="dom.html#manual.dom.cpp" title="C++ interface">C++ interface</a> </h3></div></div></div> <div class="note"><table border="0" summary="Note"> <tr> @@ -261,21 +259,18 @@ some operations on <code class="computeroutput"><span class="identifier">xml_node</span></code> are only valid for certain node types. The classes are described below. </p> -<a name="xml_document"></a><a name="xml_document::document_element"></a><p> - <code class="computeroutput"><span class="identifier">xml_document</span></code> is the owner - of the entire document structure; it is a non-copyable class. The interface - of <code class="computeroutput"><span class="identifier">xml_document</span></code> consists - of loading functions (see <a class="xref" href="loading.html" title="Loading document"> Loading document</a>), saving functions (see <a class="xref" href="saving.html" title="Saving document"> Saving document</a>) - and the entire interface of <code class="computeroutput"><span class="identifier">xml_node</span></code>, - which allows for document inspection and/or modification. Note that while - <code class="computeroutput"><span class="identifier">xml_document</span></code> is a sub-class - of <code class="computeroutput"><span class="identifier">xml_node</span></code>, <code class="computeroutput"><span class="identifier">xml_node</span></code> is not a polymorphic type; the - inheritance is present only to simplify usage. Alternatively you can use - the <code class="computeroutput"><span class="identifier">document_element</span></code> function - to get the element node that's the immediate child of the document. +<p> + <a name="xml_document"></a><a name="xml_document::document_element"></a><code class="computeroutput"><span class="identifier">xml_document</span></code> is the owner of the entire + document structure; it is a non-copyable class. The interface of <code class="computeroutput"><span class="identifier">xml_document</span></code> consists of loading functions + (see <a class="xref" href="loading.html" title="Loading document">Loading document</a>), saving functions (see <a class="xref" href="saving.html" title="Saving document">Saving document</a>) and the entire + interface of <code class="computeroutput"><span class="identifier">xml_node</span></code>, which + allows for document inspection and/or modification. Note that while <code class="computeroutput"><span class="identifier">xml_document</span></code> is a sub-class of <code class="computeroutput"><span class="identifier">xml_node</span></code>, <code class="computeroutput"><span class="identifier">xml_node</span></code> + is not a polymorphic type; the inheritance is present only to simplify usage. + Alternatively you can use the <code class="computeroutput"><span class="identifier">document_element</span></code> + function to get the element node that's the immediate child of the document. </p> -<a name="xml_document::ctor"></a><a name="xml_document::dtor"></a><a name="xml_document::reset"></a><p> - Default constructor of <code class="computeroutput"><span class="identifier">xml_document</span></code> +<p> + <a name="xml_document::ctor"></a><a name="xml_document::dtor"></a><a name="xml_document::reset"></a>Default constructor of <code class="computeroutput"><span class="identifier">xml_document</span></code> initializes the document to the tree with only a root node (document node). You can then populate it with data using either tree modification functions or loading functions; all loading functions destroy the previous tree with @@ -300,12 +295,12 @@ are destroyed. </p></td></tr> </table></div> -<a name="xml_node"></a><a name="xml_node::type"></a><p> - <code class="computeroutput"><span class="identifier">xml_node</span></code> is the handle to - document node; it can point to any node in the document, including the document - node itself. There is a common interface for nodes of all types; the actual - <a class="link" href="dom.html#xml_node_type">node type</a> can be queried via the <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span></code> - method. Note that <code class="computeroutput"><span class="identifier">xml_node</span></code> +<p> + <a name="xml_node"></a><a name="xml_node::type"></a><code class="computeroutput"><span class="identifier">xml_node</span></code> + is the handle to document node; it can point to any node in the document, + including the document node itself. There is a common interface for nodes + of all types; the actual <a class="link" href="dom.html#xml_node_type">node type</a> can + be queried via the <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span></code> method. Note that <code class="computeroutput"><span class="identifier">xml_node</span></code> is only a handle to the actual node, not the node itself - you can have several <code class="computeroutput"><span class="identifier">xml_node</span></code> handles pointing to the same underlying object. Destroying <code class="computeroutput"><span class="identifier">xml_node</span></code> @@ -315,8 +310,8 @@ a pointer; you can safely pass or return <code class="computeroutput"><span class="identifier">xml_node</span></code> objects by value without additional overhead. </p> -<a name="node_null"></a><p> - There is a special value of <code class="computeroutput"><span class="identifier">xml_node</span></code> +<p> + <a name="node_null"></a>There is a special value of <code class="computeroutput"><span class="identifier">xml_node</span></code> type, known as null node or empty node (such nodes have type <code class="computeroutput"><span class="identifier">node_null</span></code>). It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don't do anything and @@ -326,37 +321,40 @@ have a parent, the first <code class="computeroutput"><span class="identifier">parent</span><span class="special">()</span></code> call returns null node; the second <code class="computeroutput"><span class="identifier">parent</span><span class="special">()</span></code> call then also returns null node, which makes error handling easier. </p> -<a name="xml_attribute"></a><p> - <code class="computeroutput"><span class="identifier">xml_attribute</span></code> is the handle - to an XML attribute; it has the same semantics as <code class="computeroutput"><span class="identifier">xml_node</span></code>, - i.e. there can be several <code class="computeroutput"><span class="identifier">xml_attribute</span></code> - handles pointing to the same underlying object and there is a special null - attribute value, which propagates to function results. +<p> + <a name="xml_attribute"></a><code class="computeroutput"><span class="identifier">xml_attribute</span></code> + is the handle to an XML attribute; it has the same semantics as <code class="computeroutput"><span class="identifier">xml_node</span></code>, i.e. there can be several <code class="computeroutput"><span class="identifier">xml_attribute</span></code> handles pointing to the same + underlying object and there is a special null attribute value, which propagates + to function results. </p> -<a name="xml_attribute::ctor"></a><a name="xml_node::ctor"></a><p> - Both <code class="computeroutput"><span class="identifier">xml_node</span></code> and <code class="computeroutput"><span class="identifier">xml_attribute</span></code> have the default constructor - which initializes them to null objects. +<p> + <a name="xml_attribute::ctor"></a><a name="xml_node::ctor"></a>Both <code class="computeroutput"><span class="identifier">xml_node</span></code> and <code class="computeroutput"><span class="identifier">xml_attribute</span></code> + have the default constructor which initializes them to null objects. </p> -<a name="xml_attribute::comparison"></a><a name="xml_node::comparison"></a><p> - <code class="computeroutput"><span class="identifier">xml_node</span></code> and <code class="computeroutput"><span class="identifier">xml_attribute</span></code> try to behave like pointers, - that is, they can be compared with other objects of the same type, making - it possible to use them as keys in associative containers. All handles to - the same underlying object are equal, and any two handles to different underlying - objects are not equal. Null handles only compare as equal to themselves. - The result of relational comparison can not be reliably determined from the - order of nodes in file or in any other way. Do not use relational comparison - operators except for search optimization (i.e. associative container keys). +<p> + <a name="xml_attribute::comparison"></a><a name="xml_node::comparison"></a><code class="computeroutput"><span class="identifier">xml_node</span></code> and <code class="computeroutput"><span class="identifier">xml_attribute</span></code> + try to behave like pointers, that is, they can be compared with other objects + of the same type, making it possible to use them as keys in associative containers. + All handles to the same underlying object are equal, and any two handles + to different underlying objects are not equal. Null handles only compare + as equal to themselves. The result of relational comparison can not be reliably + determined from the order of nodes in file or in any other way. Do not use + relational comparison operators except for search optimization (i.e. associative + container keys). </p> -<a name="xml_attribute::hash_value"></a><a name="xml_node::hash_value"></a><p> - If you want to use <code class="computeroutput"><span class="identifier">xml_node</span></code> +<p> + <a name="xml_attribute::hash_value"></a><a name="xml_node::hash_value"></a>If + you want to use <code class="computeroutput"><span class="identifier">xml_node</span></code> or <code class="computeroutput"><span class="identifier">xml_attribute</span></code> objects as keys in hash-based associative containers, you can use the <code class="computeroutput"><span class="identifier">hash_value</span></code> member functions. They return the hash values that are guaranteed to be the same for all handles to the same underlying object. The hash value for null handles is 0. </p> -<a name="xml_attribute::unspecified_bool_type"></a><a name="xml_node::unspecified_bool_type"></a><a name="xml_attribute::empty"></a><a name="xml_node::empty"></a><p> - Finally handles can be implicitly cast to boolean-like objects, so that you - can test if the node/attribute is empty with the following code: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> +<p> + <a name="xml_attribute::unspecified_bool_type"></a><a name="xml_node::unspecified_bool_type"></a><a name="xml_attribute::empty"></a><a name="xml_node::empty"></a>Finally handles + can be implicitly cast to boolean-like objects, so that you can test if the + node/attribute is empty with the following code: <code class="computeroutput"><span class="keyword">if</span> + <span class="special">(</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code> or <code class="computeroutput"><span class="keyword">if</span> <span class="special">(!</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>. @@ -379,14 +377,14 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.dom.unicode"></a><a class="link" href="dom.html#manual.dom.unicode" title="Unicode interface"> Unicode interface</a> +<a name="manual.dom.unicode"></a><a class="link" href="dom.html#manual.dom.unicode" title="Unicode interface">Unicode interface</a> </h3></div></div></div> <p> There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via <a class="link" href="install.html#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a> define; you can set it via <code class="filename">pugiconfig.hpp</code> or via preprocessor options, as - discussed in <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration + discussed in <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options">Additional configuration options</a>. If this define is set, the wchar_t interface is used; otherwise (by default) the char interface is used. The exact wide character encoding is assumed to be either UTF-16 or UTF-32 and @@ -418,13 +416,13 @@ <pre class="programlisting"><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">value</span><span class="special">);</span> </pre> -<a name="char_t"></a><a name="string_t"></a><p> - There is a special type, <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">char_t</span></code>, - that is defined as the character type and depends on the library configuration; - it will be also used in the documentation hereafter. There is also a type - <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">string_t</span></code>, which is defined as the STL string - of the character type; it corresponds to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> - in char mode and to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span></code> in wchar_t mode. +<p> + <a name="char_t"></a><a name="string_t"></a>There is a special type, <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">char_t</span></code>, that is defined as the character + type and depends on the library configuration; it will be also used in the + documentation hereafter. There is also a type <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">string_t</span></code>, + which is defined as the STL string of the character type; it corresponds + to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> in char mode and to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span></code> + in wchar_t mode. </p> <p> In addition to the interface, the internal implementation changes to store @@ -436,9 +434,10 @@ inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice. </p> -<a name="as_utf8"></a><a name="as_wide"></a><p> - There are cases when you'll have to convert string data between UTF-8 and - wchar_t encodings; the following helper functions are provided for such purposes: +<p> + <a name="as_utf8"></a><a name="as_wide"></a>There are cases when you'll have + to convert string data between UTF-8 and wchar_t encodings; the following + helper functions are provided for such purposes: </p> <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">as_utf8</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span> <span class="identifier">as_wide</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span> @@ -485,12 +484,12 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.dom.thread"></a><a class="link" href="dom.html#manual.dom.thread" title="Thread-safety guarantees"> Thread-safety guarantees</a> +<a name="manual.dom.thread"></a><a class="link" href="dom.html#manual.dom.thread" title="Thread-safety guarantees">Thread-safety guarantees</a> </h3></div></div></div> <p> Almost all functions in pugixml have the following thread-safety guarantees: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> it is safe to call free (non-member) functions from multiple threads </li> @@ -511,13 +510,13 @@ <p> The only exception is <a class="link" href="dom.html#set_memory_management_functions">set_memory_management_functions</a>; it modifies global variables and as such is not thread-safe. Its usage policy - has more restrictions, see <a class="xref" href="dom.html#manual.dom.memory.custom" title="Custom memory allocation/deallocation functions"> Custom memory allocation/deallocation + has more restrictions, see <a class="xref" href="dom.html#manual.dom.memory.custom" title="Custom memory allocation/deallocation functions">Custom memory allocation/deallocation functions</a>. </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.dom.exception"></a><a class="link" href="dom.html#manual.dom.exception" title="Exception guarantees"> Exception guarantees</a> +<a name="manual.dom.exception"></a><a class="link" href="dom.html#manual.dom.exception" title="Exception guarantees">Exception guarantees</a> </h3></div></div></div> <p> With the exception of XPath, pugixml itself does not throw any exceptions. @@ -541,7 +540,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.dom.memory"></a><a class="link" href="dom.html#manual.dom.memory" title="Memory management"> Memory management</a> +<a name="manual.dom.memory"></a><a class="link" href="dom.html#manual.dom.memory" title="Memory management">Memory management</a> </h3></div></div></div> <p> pugixml requests the memory needed for document storage in big chunks, and @@ -550,21 +549,22 @@ </p> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.dom.memory.custom"></a><a class="link" href="dom.html#manual.dom.memory.custom" title="Custom memory allocation/deallocation functions"> Custom memory allocation/deallocation +<a name="manual.dom.memory.custom"></a><a class="link" href="dom.html#manual.dom.memory.custom" title="Custom memory allocation/deallocation functions">Custom memory allocation/deallocation functions</a> </h4></div></div></div> -<a name="allocation_function"></a><a name="deallocation_function"></a><p> - All memory for tree structure, tree data and XPath objects is allocated - via globally specified functions, which default to malloc/free. You can - set your own allocation functions with set_memory_management function. - The function interfaces are the same as that of malloc/free: +<p> + <a name="allocation_function"></a><a name="deallocation_function"></a>All + memory for tree structure, tree data and XPath objects is allocated via + globally specified functions, which default to malloc/free. You can set + your own allocation functions with set_memory_management function. The + function interfaces are the same as that of malloc/free: </p> <pre class="programlisting"><span class="keyword">typedef</span> <span class="keyword">void</span><span class="special">*</span> <span class="special">(*</span><span class="identifier">allocation_function</span><span class="special">)(</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">);</span> <span class="keyword">typedef</span> <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">deallocation_function</span><span class="special">)(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">ptr</span><span class="special">);</span> </pre> -<a name="set_memory_management_functions"></a><a name="get_memory_allocation_function"></a><a name="get_memory_deallocation_function"></a><p> - You can use the following accessor functions to change or get current memory - management functions: +<p> + <a name="set_memory_management_functions"></a><a name="get_memory_allocation_function"></a><a name="get_memory_deallocation_function"></a>You can use the following accessor + functions to change or get current memory management functions: </p> <pre class="programlisting"><span class="keyword">void</span> <span class="identifier">set_memory_management_functions</span><span class="special">(</span><span class="identifier">allocation_function</span> <span class="identifier">allocate</span><span class="special">,</span> <span class="identifier">deallocation_function</span> <span class="identifier">deallocate</span><span class="special">);</span> <span class="identifier">allocation_function</span> <span class="identifier">get_memory_allocation_function</span><span class="special">();</span> @@ -589,7 +589,6 @@ This is a simple example of custom memory management (<a href="../samples/custom_memory_management.cpp" target="_top">samples/custom_memory_management.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">void</span><span class="special">*</span> <span class="identifier">custom_allocate</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span> <span class="special">{</span> @@ -604,7 +603,6 @@ <p> </p> <p> - </p> <pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">set_memory_management_functions</span><span class="special">(</span><span class="identifier">custom_allocate</span><span class="special">,</span> <span class="identifier">custom_deallocate</span><span class="special">);</span> </pre> @@ -619,7 +617,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.dom.memory.tuning"></a><a class="link" href="dom.html#manual.dom.memory.tuning" title="Memory consumption tuning"> Memory consumption tuning</a> +<a name="manual.dom.memory.tuning"></a><a class="link" href="dom.html#manual.dom.memory.tuning" title="Memory consumption tuning">Memory consumption tuning</a> </h4></div></div></div> <p> There are several important buffering optimizations in pugixml that rely @@ -631,10 +629,10 @@ </p> <p> These constants can be tuned via configuration defines, as discussed in - <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration + <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options">Additional configuration options</a>; it is recommended to set them in <code class="filename">pugiconfig.hpp</code>. </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <code class="computeroutput"><span class="identifier">PUGIXML_MEMORY_PAGE_SIZE</span></code> controls the page size for document memory allocation. Memory for node/attribute @@ -642,7 +640,6 @@ is 32 Kb; for some applications the size is too large (i.e. embedded systems with little heap space or applications that keep lots of XML documents in memory). A minimum size of 1 Kb is recommended. <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">PUGIXML_MEMORY_OUTPUT_STACK</span></code> @@ -652,7 +649,6 @@ using node output from threads with little stack space, decreasing this value can prevent stack overflows. A minimum size of 1 Kb is recommended. <br><br> - </li> <li class="listitem"> <code class="computeroutput"><span class="identifier">PUGIXML_MEMORY_XPATH_PAGE_SIZE</span></code> @@ -667,7 +663,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.dom.memory.internals"></a><a class="link" href="dom.html#manual.dom.memory.internals" title="Document memory management internals"> Document memory management +<a name="manual.dom.memory.internals"></a><a class="link" href="dom.html#manual.dom.memory.internals" title="Document memory management internals">Document memory management internals</a> </h4></div></div></div> <p> @@ -677,7 +673,7 @@ </p> <p> When the document is loaded from file/buffer, unless an inplace loading - function is used (see <a class="xref" href="loading.html#manual.loading.memory" title="Loading document from memory"> Loading document from memory</a>), a complete copy of character + function is used (see <a class="xref" href="loading.html#manual.loading.memory" title="Loading document from memory">Loading document from memory</a>), a complete copy of character stream is made; all names/values of nodes and attributes are allocated in this buffer. This buffer is allocated via a single large allocation and is only freed when document memory is reclaimed (i.e. if the <a class="link" href="dom.html#xml_document">xml_document</a> object is destroyed or if another @@ -707,7 +703,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -715,7 +711,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/install.html b/docs/manual/install.html index df7b322..5675651 100644 --- a/docs/manual/install.html +++ b/docs/manual/install.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Installation</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> -<link rel="prev" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> +<link rel="prev" href="../manual.html" title="pugixml 1.4"> <link rel="next" href="dom.html" title="Document object model"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <b>Installation</b> | Document: @@ -28,32 +28,33 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.install"></a><a class="link" href="install.html" title="Installation"> Installation</a> +<a name="manual.install"></a><a class="link" href="install.html" title="Installation">Installation</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="install.html#manual.install.getting"> Getting pugixml</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="install.html#manual.install.getting">Getting pugixml</a></span></dt> <dd><dl> -<dt><span class="section"><a href="install.html#manual.install.getting.source"> Source distributions</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.getting.subversion"> Subversion repository</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting.source">Source distributions</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting.subversion">Subversion repository</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting.git">Git repository</a></span></dt> </dl></dd> -<dt><span class="section"><a href="install.html#manual.install.building"> Building pugixml</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.building">Building pugixml</a></span></dt> <dd><dl> -<dt><span class="section"><a href="install.html#manual.install.building.embed"> Building pugixml as +<dt><span class="section"><a href="install.html#manual.install.building.embed">Building pugixml as a part of another static library/executable</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.static"> Building pugixml as +<dt><span class="section"><a href="install.html#manual.install.building.static">Building pugixml as a standalone static library</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.shared"> Building pugixml as +<dt><span class="section"><a href="install.html#manual.install.building.shared">Building pugixml as a standalone shared library</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.header"> Using pugixml in header-only - mode</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.config"> Additional configuration +<dt><span class="section"><a href="install.html#manual.install.building.header">Using + pugixml in header-only mode</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.building.config">Additional configuration options</a></span></dt> </dl></dd> -<dt><span class="section"><a href="install.html#manual.install.portability"> Portability</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.portability">Portability</a></span></dt> </dl></div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.install.getting"></a><a class="link" href="install.html#manual.install.getting" title="Getting pugixml"> Getting pugixml</a> +<a name="manual.install.getting"></a><a class="link" href="install.html#manual.install.getting" title="Getting pugixml">Getting pugixml</a> </h3></div></div></div> <p> pugixml is distributed in source form. You can either download a source distribution @@ -61,14 +62,14 @@ </p> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.getting.source"></a><a class="link" href="install.html#manual.install.getting.source" title="Source distributions"> Source distributions</a> +<a name="manual.install.getting.source"></a><a class="link" href="install.html#manual.install.getting.source" title="Source distributions">Source distributions</a> </h4></div></div></div> <p> You can download the latest source distribution via one of the following links: </p> -<pre class="programlisting"><a href="http://pugixml.googlecode.com/files/pugixml-1.2.zip" target="_top">http://pugixml.googlecode.com/files/pugixml-1.2.zip</a> -<a href="http://pugixml.googlecode.com/files/pugixml-1.2.tar.gz" target="_top">http://pugixml.googlecode.com/files/pugixml-1.2.tar.gz</a> +<pre class="programlisting"><a href="https://github.com/zeux/pugixml/releases/download/v1.4/pugixml-1.4.zip" target="_top">https://github.com/zeux/pugixml/releases/download/v1.4/pugixml-1.4.zip</a> +<a href="https://github.com/zeux/pugixml/releases/download/v1.4/pugixml-1.4.tar.gz" target="_top">https://github.com/zeux/pugixml/releases/download/v1.4/pugixml-1.4.tar.gz</a> </pre> <p> The distribution contains library source, documentation (the manual you're @@ -85,7 +86,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.getting.subversion"></a><a class="link" href="install.html#manual.install.getting.subversion" title="Subversion repository"> Subversion repository</a> +<a name="manual.install.getting.subversion"></a><a class="link" href="install.html#manual.install.getting.subversion" title="Subversion repository">Subversion repository</a> </h4></div></div></div> <p> The Subversion repository is located at <a href="http://pugixml.googlecode.com/svn/" target="_top">http://pugixml.googlecode.com/svn/</a>. @@ -96,7 +97,7 @@ <p> For example, to checkout the current version, you can use this command: </p> -<pre class="programlisting">svn checkout http://pugixml.googlecode.com/svn/tags/release-1.2 pugixml</pre> +<pre class="programlisting">svn checkout http://pugixml.googlecode.com/svn/tags/release-1.4 pugixml</pre> <p> To checkout the latest version, you can use this command: </p> @@ -115,10 +116,20 @@ that occasionally the code can be broken in some configurations. </p> </div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="manual.install.getting.git"></a><a class="link" href="install.html#manual.install.getting.git" title="Git repository">Git repository</a> +</h4></div></div></div> +<p> + The Subversion repository is mirrored by a Git repository at <a href="https://github.com/zeux/pugixml" target="_top">https://github.com/zeux/pugixml</a>. + The mirror is frequently updated and has the same structure in terms of + tags and contents as Subversion repository. + </p> +</div> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.install.building"></a><a class="link" href="install.html#manual.install.building" title="Building pugixml"> Building pugixml</a> +<a name="manual.install.building"></a><a class="link" href="install.html#manual.install.building" title="Building pugixml">Building pugixml</a> </h3></div></div></div> <p> pugixml is distributed in source form without any pre-built binaries; you @@ -128,7 +139,7 @@ The complete pugixml source consists of three files - one source file, <code class="filename">pugixml.cpp</code>, and two header files, <code class="filename">pugixml.hpp</code> and <code class="filename">pugiconfig.hpp</code>. <code class="filename">pugixml.hpp</code> is the primary header which you need to include in order to use pugixml classes/functions; - <code class="filename">pugiconfig.hpp</code> is a supplementary configuration file (see <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration + <code class="filename">pugiconfig.hpp</code> is a supplementary configuration file (see <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options">Additional configuration options</a>). The rest of this guide assumes that <code class="filename">pugixml.hpp</code> is either in the current directory or in one of include directories of your projects, so that <code class="computeroutput"><span class="preprocessor">#include</span> <span class="string">"pugixml.hpp"</span></code> @@ -138,14 +149,14 @@ </p> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.building.embed"></a><a class="link" href="install.html#manual.install.building.embed" title="Building pugixml as a part of another static library/executable"> Building pugixml as +<a name="manual.install.building.embed"></a><a class="link" href="install.html#manual.install.building.embed" title="Building pugixml as a part of another static library/executable">Building pugixml as a part of another static library/executable</a> </h4></div></div></div> <p> The easiest way to build pugixml is to compile the source file, <code class="filename">pugixml.cpp</code>, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft - Visual Studio<sup>[<a name="trademarks" href="#ftn.trademarks" class="footnote">1</a>]</sup>, Apple Xcode, Code::Blocks or any other IDE, just add <code class="filename">pugixml.cpp</code> to + Visual Studio<a href="#ftn.trademarks" class="footnote" name="trademarks"><sup class="footnote">[1]</sup></a>, Apple Xcode, Code::Blocks or any other IDE, just add <code class="filename">pugixml.cpp</code> to one of your projects. </p> <p> @@ -173,7 +184,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.building.static"></a><a class="link" href="install.html#manual.install.building.static" title="Building pugixml as a standalone static library"> Building pugixml as +<a name="manual.install.building.static"></a><a class="link" href="install.html#manual.install.building.static" title="Building pugixml as a standalone static library">Building pugixml as a standalone static library</a> </h4></div></div></div> <p> @@ -183,7 +194,7 @@ are project files for Apple XCode3, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010, and configuration scripts for CMake and premake4. You're welcome to submit project files/build scripts for other software; - see <a class="xref" href="../manual.html#manual.overview.feedback" title="Feedback"> Feedback</a>. + see <a class="xref" href="../manual.html#manual.overview.feedback" title="Feedback">Feedback</a>. </p> <p> There are two projects for each version of Microsoft Visual Studio: one @@ -236,7 +247,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.building.shared"></a><a class="link" href="install.html#manual.install.building.shared" title="Building pugixml as a standalone shared library"> Building pugixml as +<a name="manual.install.building.shared"></a><a class="link" href="install.html#manual.install.building.shared" title="Building pugixml as a standalone shared library">Building pugixml as a standalone shared library</a> </h4></div></div></div> <p> @@ -271,10 +282,10 @@ </p></td></tr> </table></div> </div> -<a name="PUGIXML_HEADER_ONLY"></a><div class="section"> +<div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.building.header"></a><a class="link" href="install.html#manual.install.building.header" title="Using pugixml in header-only mode"> Using pugixml in header-only - mode</a> +<a name="manual.install.building.header"></a><a name="PUGIXML_HEADER_ONLY"></a><a class="link" href="install.html#manual.install.building.header" title="Using pugixml in header-only mode">Using + pugixml in header-only mode</a> </h4></div></div></div> <p> It's possible to use pugixml in header-only mode. This means that all source @@ -313,7 +324,7 @@ <p> Note that it is safe to compile <code class="filename">pugixml.cpp</code> if <code class="computeroutput"><span class="identifier">PUGIXML_HEADER_ONLY</span></code> is defined - so if you want to i.e. use header-only mode only in Release - configuration, you can include pugixml.cpp in your project (see <a class="xref" href="install.html#manual.install.building.embed" title="Building pugixml as a part of another static library/executable"> Building pugixml as + configuration, you can include pugixml.cpp in your project (see <a class="xref" href="install.html#manual.install.building.embed" title="Building pugixml as a part of another static library/executable">Building pugixml as a part of another static library/executable</a>), and conditionally enable header-only mode in <code class="filename">pugiconfig.hpp</code>, i.e.: </p> @@ -325,7 +336,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> -<a name="manual.install.building.config"></a><a class="link" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration +<a name="manual.install.building.config"></a><a class="link" href="install.html#manual.install.building.config" title="Additional configuration options">Additional configuration options</a> </h4></div></div></div> <p> @@ -347,7 +358,7 @@ as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on <code class="computeroutput"><span class="keyword">wchar_t</span></code> size, most functions use <code class="computeroutput"><span class="keyword">wchar_t</span></code> - as character type). See <a class="xref" href="dom.html#manual.dom.unicode" title="Unicode interface"> Unicode interface</a> for more details. + as character type). See <a class="xref" href="dom.html#manual.dom.unicode" title="Unicode interface">Unicode interface</a> for more details. </p> <p> <a name="PUGIXML_NO_XPATH"></a><code class="literal">PUGIXML_NO_XPATH</code> define disables XPath. @@ -377,7 +388,7 @@ is used instead. For example, to specify fixed calling convention, you can define <code class="computeroutput"><span class="identifier">PUGIXML_FUNCTION</span></code> to i.e. <code class="computeroutput"><span class="identifier">__fastcall</span></code>. Another - example is DLL import/export attributes in MSVC (see <a class="xref" href="install.html#manual.install.building.shared" title="Building pugixml as a standalone shared library"> Building pugixml as + example is DLL import/export attributes in MSVC (see <a class="xref" href="install.html#manual.install.building.shared" title="Building pugixml as a standalone shared library">Building pugixml as a standalone shared library</a>). </p> <div class="note"><table border="0" summary="Note"> @@ -395,24 +406,34 @@ <a name="PUGIXML_MEMORY_PAGE_SIZE"></a><code class="literal">PUGIXML_MEMORY_PAGE_SIZE</code>, <a name="PUGIXML_MEMORY_OUTPUT_STACK"></a><code class="literal">PUGIXML_MEMORY_OUTPUT_STACK</code> and <a name="PUGIXML_MEMORY_XPATH_PAGE_SIZE"></a><code class="literal">PUGIXML_MEMORY_XPATH_PAGE_SIZE</code> can be used to customize certain important sizes to optimize memory usage - for the application-specific patterns. For details see <a class="xref" href="dom.html#manual.dom.memory.tuning" title="Memory consumption tuning"> Memory consumption tuning</a>. + for the application-specific patterns. For details see <a class="xref" href="dom.html#manual.dom.memory.tuning" title="Memory consumption tuning">Memory consumption tuning</a>. + </p> +<p> + <a name="PUGIXML_HAS_LONG_LONG"></a><code class="literal">PUGIXML_HAS_LONG_LONG</code> define enables + support for <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code> + type in pugixml. This define is automatically enabled if your platform + is known to have <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code> + support (i.e. has C++-11 support or uses a reasonably modern version of + a known compiler); if pugixml does not recognize that your platform supports + <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code> + but in fact it does, you can enable the define manually. </p> </div> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.install.portability"></a><a class="link" href="install.html#manual.install.portability" title="Portability"> Portability</a> +<a name="manual.install.portability"></a><a class="link" href="install.html#manual.install.portability" title="Portability">Portability</a> </h3></div></div></div> <p> pugixml is written in standard-compliant C++ with some compiler-specific - workarounds where appropriate. pugixml is compatible with the upcoming C++0x - standard (verified using GCC 4.5). Each version is tested with a unit test + workarounds where appropriate. pugixml is compatible with the C++11 standard, + but does not require C++11 support. Each version is tested with a unit test suite (with code coverage about 99%) on the following platforms: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Microsoft Windows: - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> Borland C++ Compiler 5.82 </li> @@ -427,8 +448,8 @@ </li> <li class="listitem"> Microsoft Visual C++ 6.0, 7.0 (2002), 7.1 (2003), 8.0 (2005) x86/x64, - 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 x86/x64/ARM and some - CLR versions + 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 (2011) x86/x64/ARM, + 12.0 (2013) x86/x64/ARM and some CLR versions </li> <li class="listitem"> MinGW (GCC) 3.4, 4.4, 4.5, 4.6 x64 @@ -436,7 +457,7 @@ </ul></div> </li> <li class="listitem"> - Linux (GCC 4.4.3 x86/x64) + Linux (GCC 4.4.3 x86/x64, GCC 4.8.1 x64, Clang 3.2 x64) </li> <li class="listitem"> FreeBSD (GCC 4.2.1 x86/x64) @@ -466,14 +487,14 @@ </ul></div> </div> <div class="footnotes"> -<br><hr width="100" align="left"> -<div class="footnote"><p><sup>[<a name="ftn.trademarks" href="#trademarks" class="para">1</a>] </sup>All trademarks used are properties of their respective +<br><hr style="width:100; text-align:left;margin-left: 0"> +<div id="ftn.trademarks" class="footnote"><p><a href="#trademarks" class="para"><sup class="para">[1] </sup></a>All trademarks used are properties of their respective owners.</p></div> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -481,7 +502,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <b>Installation</b> | Document: diff --git a/docs/manual/loading.html b/docs/manual/loading.html index a26b62c..e18cde6 100644 --- a/docs/manual/loading.html +++ b/docs/manual/loading.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Loading document</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="dom.html" title="Document object model"> <link rel="next" href="access.html" title="Accessing document data"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,16 +28,16 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.loading"></a><a class="link" href="loading.html" title="Loading document"> Loading document</a> +<a name="manual.loading"></a><a class="link" href="loading.html" title="Loading document">Loading document</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="loading.html#manual.loading.file"> Loading document from file</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.memory"> Loading document from memory</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.stream"> Loading document from C++ IOstreams</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.errors"> Handling parsing errors</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.options"> Parsing options</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.encoding"> Encodings</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.w3c"> Conformance to W3C specification</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="loading.html#manual.loading.file">Loading document from file</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.memory">Loading document from memory</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.stream">Loading document from C++ IOstreams</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.errors">Handling parsing errors</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.options">Parsing options</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.encoding">Encodings</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.w3c">Conformance to W3C specification</a></span></dt> </dl></div> <p> pugixml provides several functions for loading XML data from various places @@ -49,25 +49,26 @@ EOL handling or attribute value normalization) can impact parsing speed and thus can be disabled. However for vast majority of XML documents there is no performance difference between different parsing options. Parsing options also - control whether certain XML nodes are parsed; see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a> for + control whether certain XML nodes are parsed; see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options">Parsing options</a> for more information. </p> <p> - XML data is always converted to internal character format (see <a class="xref" href="dom.html#manual.dom.unicode" title="Unicode interface"> Unicode interface</a>) + XML data is always converted to internal character format (see <a class="xref" href="dom.html#manual.dom.unicode" title="Unicode interface">Unicode interface</a>) before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions automatically. Unless explicit encoding is specified, loading functions perform automatic encoding detection based on first few characters of XML data, so in almost all cases you do not have to specify document encoding. Encoding - conversion is described in more detail in <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>. + conversion is described in more detail in <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings">Encodings</a>. </p> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.file"></a><a class="link" href="loading.html#manual.loading.file" title="Loading document from file"> Loading document from file</a> +<a name="manual.loading.file"></a><a class="link" href="loading.html#manual.loading.file" title="Loading document from file">Loading document from file</a> </h3></div></div></div> -<a name="xml_document::load_file"></a><a name="xml_document::load_file_wide"></a><p> - The most common source of XML data is files; pugixml provides dedicated functions +<p> + <a name="xml_document::load_file"></a><a name="xml_document::load_file_wide"></a>The + most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file: </p> <pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span> @@ -75,8 +76,8 @@ </pre> <p> These functions accept the file path as its first argument, and also two - optional arguments, which specify parsing options (see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a>) - and input data encoding (see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>). The path has the target + optional arguments, which specify parsing options (see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options">Parsing options</a>) + and input data encoding (see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc. @@ -94,13 +95,12 @@ The result of the operation is returned in an <a class="link" href="loading.html#xml_parse_result">xml_parse_result</a> object; this object contains the operation status and the related information (i.e. last successfully parsed position in the input file, if parsing fails). - See <a class="xref" href="loading.html#manual.loading.errors" title="Handling parsing errors"> Handling parsing errors</a> for error handling details. + See <a class="xref" href="loading.html#manual.loading.errors" title="Handling parsing errors">Handling parsing errors</a> for error handling details. </p> <p> This is an example of loading XML document from file (<a href="../samples/load_file.cpp" target="_top">samples/load_file.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> @@ -113,19 +113,19 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.memory"></a><a class="link" href="loading.html#manual.loading.memory" title="Loading document from memory"> Loading document from memory</a> +<a name="manual.loading.memory"></a><a class="link" href="loading.html#manual.loading.memory" title="Loading document from memory">Loading document from memory</a> </h3></div></div></div> -<a name="xml_document::load_buffer"></a><a name="xml_document::load_buffer_inplace"></a><a name="xml_document::load_buffer_inplace_own"></a><p> - Sometimes XML data should be loaded from some other source than a file, i.e. - HTTP URL; also you may want to load XML data from file using non-standard - functions, i.e. to use your virtual file system facilities or to load XML - from gzip-compressed files. All these scenarios require loading document - from memory. First you should prepare a contiguous memory block with all - XML data; then you have to invoke one of buffer loading functions. These - functions will handle the necessary encoding conversions, if any, and then - will parse the data into the corresponding XML tree. There are several buffer - loading functions, which differ in the behavior and thus in performance/memory - usage: +<p> + <a name="xml_document::load_buffer"></a><a name="xml_document::load_buffer_inplace"></a><a name="xml_document::load_buffer_inplace_own"></a>Sometimes XML data should be + loaded from some other source than a file, i.e. HTTP URL; also you may want + to load XML data from file using non-standard functions, i.e. to use your + virtual file system facilities or to load XML from gzip-compressed files. + All these scenarios require loading document from memory. First you should + prepare a contiguous memory block with all XML data; then you have to invoke + one of buffer loading functions. These functions will handle the necessary + encoding conversions, if any, and then will parse the data into the corresponding + XML tree. There are several buffer loading functions, which differ in the + behavior and thus in performance/memory usage: </p> <pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span> <span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span> @@ -135,7 +135,7 @@ All functions accept the buffer which is represented by a pointer to XML data, <code class="computeroutput"><span class="identifier">contents</span></code>, and data size in bytes. Also there are two optional arguments, which specify parsing - options (see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a>) and input data encoding (see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>). + options (see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options">Parsing options</a>) and input data encoding (see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings">Encodings</a>). The buffer does not have to be zero-terminated. </p> <p> @@ -163,9 +163,10 @@ is the recommended function if you have to load the document from memory and performance is critical. </p> -<a name="xml_document::load_string"></a><p> - There is also a simple helper function for cases when you want to load the - XML document from null-terminated character string: +<p> + <a name="xml_document::load_string"></a>There is also a simple helper function + for cases when you want to load the XML document from null-terminated character + string: </p> <pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">);</span> </pre> @@ -183,7 +184,6 @@ (<a href="../samples/load_memory.cpp" target="_top">samples/load_memory.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">const</span> <span class="keyword">char</span> <span class="identifier">source</span><span class="special">[]</span> <span class="special">=</span> <span class="string">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="special">;</span> <span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span> @@ -191,61 +191,57 @@ <p> </p> <p> - </p> -<pre class="programlisting"><span class="comment">// You can use load_buffer to load document from immutable memory block: -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> +<pre class="programlisting"><span class="comment">// You can use load_buffer to load document from immutable memory block:</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> </pre> <p> </p> <p> - </p> -<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document -</span><span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">char</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span> +<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document</span> +<span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">char</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span> <span class="identifier">memcpy</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> -<span class="comment">// The block can be allocated by any method; the block is modified during parsing -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> +<span class="comment">// The block can be allocated by any method; the block is modified during parsing</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> -<span class="comment">// You have to destroy the block yourself after the document is no longer used -</span><span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">buffer</span><span class="special">;</span> +<span class="comment">// You have to destroy the block yourself after the document is no longer used</span> +<span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">buffer</span><span class="special">;</span> </pre> <p> </p> <p> - </p> -<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block -</span><span class="comment">// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect -</span><span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="keyword">char</span><span class="special">*>(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">get_memory_allocation_function</span><span class="special">()(</span><span class="identifier">size</span><span class="special">));</span> +<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block</span> +<span class="comment">// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect</span> +<span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="keyword">char</span><span class="special">*>(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">get_memory_allocation_function</span><span class="special">()(</span><span class="identifier">size</span><span class="special">));</span> <span class="identifier">memcpy</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> -<span class="comment">// The block will be deleted by the document -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace_own</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> +<span class="comment">// The block will be deleted by the document</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace_own</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span> </pre> <p> </p> <p> - </p> -<pre class="programlisting"><span class="comment">// You can use load to load document from null-terminated strings, for example literals: -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="string">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="special">);</span> +<pre class="programlisting"><span class="comment">// You can use load to load document from null-terminated strings, for example literals:</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="string">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="special">);</span> </pre> <p> </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.stream"></a><a class="link" href="loading.html#manual.loading.stream" title="Loading document from C++ IOstreams"> Loading document from C++ IOstreams</a> +<a name="manual.loading.stream"></a><a class="link" href="loading.html#manual.loading.stream" title="Loading document from C++ IOstreams">Loading document from C++ IOstreams</a> </h3></div></div></div> -<a name="xml_document::load_stream"></a><p> - To enhance interoperability, pugixml provides functions for loading document - from any object which implements C++ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span></code> - interface. This allows you to load documents from any standard C++ stream - (i.e. file stream) or any third-party compliant implementation (i.e. Boost - Iostreams). There are two functions, one works with narrow character streams, - another handles wide character ones: +<p> + <a name="xml_document::load_stream"></a>To enhance interoperability, pugixml + provides functions for loading document from any object which implements + C++ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span></code> interface. This allows you to load + documents from any standard C++ stream (i.e. file stream) or any third-party + compliant implementation (i.e. Boost Iostreams). There are two functions, + one works with narrow character streams, another handles wide character ones: </p> <pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span> <span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wistream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">);</span> @@ -275,7 +271,6 @@ the sample code for more complex examples involving wide streams and locales: </p> <p> - </p> <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ifstream</span> <span class="identifier">stream</span><span class="special">(</span><span class="string">"weekly-utf-8.xml"</span><span class="special">);</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">stream</span><span class="special">);</span> @@ -285,12 +280,14 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.errors"></a><a class="link" href="loading.html#manual.loading.errors" title="Handling parsing errors"> Handling parsing errors</a> +<a name="manual.loading.errors"></a><a class="link" href="loading.html#manual.loading.errors" title="Handling parsing errors">Handling parsing errors</a> </h3></div></div></div> -<a name="xml_parse_result"></a><p> - All document loading functions return the parsing result via <code class="computeroutput"><span class="identifier">xml_parse_result</span></code> object. It contains parsing - status, the offset of last successfully parsed character from the beginning - of the source stream, and the encoding of the source stream: +<p> + <a name="xml_parse_result"></a>All document loading functions return the + parsing result via <code class="computeroutput"><span class="identifier">xml_parse_result</span></code> + object. It contains parsing status, the offset of last successfully parsed + character from the beginning of the source stream, and the encoding of the + source stream: </p> <pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xml_parse_result</span> <span class="special">{</span> @@ -302,16 +299,16 @@ <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">description</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="special">};</span> </pre> -<a name="xml_parse_status"></a><a name="xml_parse_result::status"></a><p> - Parsing status is represented as the <code class="computeroutput"><span class="identifier">xml_parse_status</span></code> +<p> + <a name="xml_parse_status"></a><a name="xml_parse_result::status"></a>Parsing + status is represented as the <code class="computeroutput"><span class="identifier">xml_parse_status</span></code> enumeration and can be one of the following: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="status_ok"></a><code class="literal">status_ok</code> means that no error was encountered during parsing; the source stream represents the valid XML document which was fully parsed and converted to a tree. <br><br> - </li> <li class="listitem"> <a name="status_file_not_found"></a><code class="literal">status_file_not_found</code> is only @@ -330,7 +327,6 @@ <li class="listitem"> <a name="status_internal_error"></a><code class="literal">status_internal_error</code> means that something went horribly wrong; currently this error does not occur <br><br> - </li> <li class="listitem"> <a name="status_unrecognized_tag"></a><code class="literal">status_unrecognized_tag</code> means @@ -371,15 +367,18 @@ opening one (i.e. <code class="computeroutput"><span class="special"><</span><span class="identifier">node</span><span class="special">></</span><span class="identifier">nedo</span><span class="special">></span></code>) or because some tag was not closed at all </li> +<li class="listitem"> + <a name="status_no_document_element"></a><code class="literal">status_no_document_element</code> + means that no element nodes were discovered during parsing; this usually + indicates an empty or invalid document + </li> </ul></div> -<a name="xml_parse_result::description"></a><p> - <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> - member function can be used to convert parsing status to a string; the returned - message is always in English, so you'll have to write your own function if - you need a localized string. However please note that the exact messages - returned by <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> - function may change from version to version, so any complex status handling - should be based on <code class="computeroutput"><span class="identifier">status</span></code> +<p> + <a name="xml_parse_result::description"></a><code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> member function can be used to convert + parsing status to a string; the returned message is always in English, so + you'll have to write your own function if you need a localized string. However + please note that the exact messages returned by <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> function may change from version to version, + so any complex status handling should be based on <code class="computeroutput"><span class="identifier">status</span></code> value. Note that <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> returns a <code class="computeroutput"><span class="keyword">char</span></code> string even in <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>; you'll have to call <a class="link" href="dom.html#as_wide">as_wide</a> to get the <code class="computeroutput"><span class="keyword">wchar_t</span></code> string. @@ -394,16 +393,18 @@ attribute <code class="computeroutput"><span class="identifier">attr</span></code> will contain the string <code class="computeroutput"><span class="identifier">value</span><span class="special">></span><span class="identifier">some</span> <span class="identifier">data</span><span class="special"></</span><span class="identifier">node</span><span class="special">></span></code>. </p> -<a name="xml_parse_result::offset"></a><p> - In addition to the status code, parsing result has an <code class="computeroutput"><span class="identifier">offset</span></code> - member, which contains the offset of last successfully parsed character if - parsing failed because of an error in source data; otherwise <code class="computeroutput"><span class="identifier">offset</span></code> is 0. For parsing efficiency reasons, - pugixml does not track the current line during parsing; this offset is in - units of <a class="link" href="dom.html#char_t">pugi::char_t</a> (bytes for character - mode, wide characters for wide character mode). Many text editors support - 'Go To Position' feature - you can use it to locate the exact error position. - Alternatively, if you're loading the document from memory, you can display - the error chunk along with the error description (see the example code below). +<p> + <a name="xml_parse_result::offset"></a>In addition to the status code, parsing + result has an <code class="computeroutput"><span class="identifier">offset</span></code> member, + which contains the offset of last successfully parsed character if parsing + failed because of an error in source data; otherwise <code class="computeroutput"><span class="identifier">offset</span></code> + is 0. For parsing efficiency reasons, pugixml does not track the current + line during parsing; this offset is in units of <a class="link" href="dom.html#char_t">pugi::char_t</a> + (bytes for character mode, wide characters for wide character mode). Many + text editors support 'Go To Position' feature - you can use it to locate + the exact error position. Alternatively, if you're loading the document from + memory, you can display the error chunk along with the error description + (see the example code below). </p> <div class="caution"><table border="0" summary="Caution"> <tr> @@ -416,16 +417,17 @@ track the error position. </p></td></tr> </table></div> -<a name="xml_parse_result::encoding"></a><p> - Parsing result also has an <code class="computeroutput"><span class="identifier">encoding</span></code> - member, which can be used to check that the source data encoding was correctly - guessed. It is equal to the exact encoding used during parsing (i.e. with - the exact endianness); see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a> for more information. - </p> -<a name="xml_parse_result::bool"></a><p> - Parsing result object can be implicitly converted to <code class="computeroutput"><span class="keyword">bool</span></code>; - if you do not want to handle parsing errors thoroughly, you can just check - the return value of load functions as if it was a <code class="computeroutput"><span class="keyword">bool</span></code>: +<p> + <a name="xml_parse_result::encoding"></a>Parsing result also has an <code class="computeroutput"><span class="identifier">encoding</span></code> member, which can be used to check + that the source data encoding was correctly guessed. It is equal to the exact + encoding used during parsing (i.e. with the exact endianness); see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings">Encodings</a> for + more information. + </p> +<p> + <a name="xml_parse_result::bool"></a>Parsing result object can be implicitly + converted to <code class="computeroutput"><span class="keyword">bool</span></code>; if you do + not want to handle parsing errors thoroughly, you can just check the return + value of load functions as if it was a <code class="computeroutput"><span class="keyword">bool</span></code>: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="string">"file.xml"</span><span class="special">))</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>. </p> @@ -433,7 +435,6 @@ This is an example of handling loading errors (<a href="../samples/load_error_handling.cpp" target="_top">samples/load_error_handling.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span> @@ -452,7 +453,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.options"></a><a class="link" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a> +<a name="manual.loading.options"></a><a class="link" href="loading.html#manual.loading.options" title="Parsing options">Parsing options</a> </h3></div></div></div> <p> All document loading functions accept the optional parameter <code class="computeroutput"><span class="identifier">options</span></code>. This is a bitmask that customizes @@ -478,20 +479,18 @@ <p> These flags control the resulting tree contents: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="parse_declaration"></a><code class="literal">parse_declaration</code> determines if XML document declaration (node with type <a class="link" href="dom.html#node_declaration">node_declaration</a>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_doctype"></a><code class="literal">parse_doctype</code> determines if XML document type declaration (node with type <a class="link" href="dom.html#node_doctype">node_doctype</a>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_pi"></a><code class="literal">parse_pi</code> determines if processing instructions @@ -499,21 +498,26 @@ in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. Note that <code class="computeroutput"><span class="special"><?</span><span class="identifier">xml</span> <span class="special">...?></span></code> (document declaration) is not considered to be a PI. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_comments"></a><code class="literal">parse_comments</code> determines if comments (nodes with type <a class="link" href="dom.html#node_comment">node_comment</a>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_cdata"></a><code class="literal">parse_cdata</code> determines if CDATA sections (nodes with type <a class="link" href="dom.html#node_cdata">node_cdata</a>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is <span class="bold"><strong>on</strong></span> by default. <br><br> - + </li> +<li class="listitem"> + <a name="parse_trim_pcdata"></a><code class="literal">parse_trim_pcdata</code> determines if leading + and trailing whitespace characters are to be removed from PCDATA nodes. + While for some applications leading/trailing whitespace is significant, + often the application only cares about the non-whitespace contents so + it's easier to trim whitespace from text during parsing. This flag is + <span class="bold"><strong>off</strong></span> by default. <br><br> </li> <li class="listitem"> <a name="parse_ws_pcdata"></a><code class="literal">parse_ws_pcdata</code> determines if PCDATA @@ -532,7 +536,6 @@ one child when <code class="computeroutput"><span class="identifier">parse_ws_pcdata</span></code> is not set. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_ws_pcdata_single"></a><code class="literal">parse_ws_pcdata_single</code> determines @@ -550,12 +553,38 @@ and value <code class="computeroutput"><span class="string">" "</span></code>. This flag has no effect if <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a> is enabled. This flag is <span class="bold"><strong>off</strong></span> by default. + <br><br> + </li> +<li class="listitem"> + <a name="parse_fragment"></a><code class="literal">parse_fragment</code> determines if document + should be treated as a fragment of a valid XML. Parsing document as a + fragment leads to top-level PCDATA content (i.e. text that is not located + inside a node) to be added to a tree, and additionally treats documents + without element nodes as valid. This flag is <span class="bold"><strong>off</strong></span> + by default. </li> </ul></div> +<div class="caution"><table border="0" summary="Caution"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td> +<th align="left">Caution</th> +</tr> +<tr><td align="left" valign="top"><p> + Using in-place parsing (<a class="link" href="loading.html#xml_document::load_buffer_inplace">load_buffer_inplace</a>) + with <code class="computeroutput"><span class="identifier">parse_fragment</span></code> flag + may result in the loss of the last character of the buffer if it is a part + of PCDATA. Since PCDATA values are null-terminated strings, the only way + to resolve this is to provide a null-terminated buffer as an input to + <code class="computeroutput"><span class="identifier">load_buffer_inplace</span></code> - i.e. + <code class="computeroutput"><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="string">"test\0"</span><span class="special">,</span> + <span class="number">5</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> + <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_fragment</span><span class="special">)</span></code>. + </p></td></tr> +</table></div> <p> These flags control the transformation of tree element contents: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="parse_escapes"></a><code class="literal">parse_escapes</code> determines if character and entity references are to be expanded during the parsing process. @@ -569,7 +598,6 @@ ones). If character/entity reference can not be expanded, it is left as is, so you can do additional processing later. Reference expansion is performed on attribute values and PCDATA content. This flag is <span class="bold"><strong>on</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_eol"></a><code class="literal">parse_eol</code> determines if EOL handling (that @@ -579,7 +607,6 @@ be performed on input data (that is, comments contents, PCDATA/CDATA contents and attribute values). This flag is <span class="bold"><strong>on</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_wconv_attribute"></a><code class="literal">parse_wconv_attribute</code> determines @@ -590,7 +617,6 @@ is set, i.e. <code class="computeroutput"><span class="special">\</span><span class="identifier">r</span><span class="special">\</span><span class="identifier">n</span></code> is converted to a single space. This flag is <span class="bold"><strong>on</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="parse_wnorm_attribute"></a><code class="literal">parse_wnorm_attribute</code> determines @@ -621,7 +647,7 @@ <p> Additionally there are three predefined option masks: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="parse_minimal"></a><code class="literal">parse_minimal</code> has all options turned off. This option mask means that pugixml does not add declaration nodes, @@ -630,7 +656,6 @@ so theoretically it is the fastest mode. However, as mentioned above, in practice <a class="link" href="loading.html#parse_default">parse_default</a> is usually equally fast. <br><br> - </li> <li class="listitem"> <a name="parse_default"></a><code class="literal">parse_default</code> is the default set of flags, @@ -640,7 +665,6 @@ in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons. <br><br> - </li> <li class="listitem"> <a name="parse_full"></a><code class="literal">parse_full</code> is the set of flags which adds @@ -657,24 +681,23 @@ This is an example of using different parsing options (<a href="../samples/load_options.cpp" target="_top">samples/load_options.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">source</span> <span class="special">=</span> <span class="string">"<!--comment--><node>&lt;</node>"</span><span class="special">;</span> -<span class="comment">// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span> +<span class="comment">// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"First node value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"], node child value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">"]\n"</span><span class="special">;</span> -<span class="comment">// Parsing with additional parse_comments option; comment node is now added to the tree -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_comments</span><span class="special">);</span> +<span class="comment">// Parsing with additional parse_comments option; comment node is now added to the tree</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_comments</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"First node value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"], node child value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">"]\n"</span><span class="special">;</span> -<span class="comment">// Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_comments</span><span class="special">)</span> <span class="special">&</span> <span class="special">~</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_escapes</span><span class="special">);</span> +<span class="comment">// Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_comments</span><span class="special">)</span> <span class="special">&</span> <span class="special">~</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_escapes</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"First node value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"], node child value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">"]\n"</span><span class="special">;</span> -<span class="comment">// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_minimal</span><span class="special">);</span> +<span class="comment">// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_minimal</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"First node value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"], node child value: ["</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">"]\n"</span><span class="special">;</span> </pre> <p> @@ -682,24 +705,25 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.encoding"></a><a class="link" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a> +<a name="manual.loading.encoding"></a><a class="link" href="loading.html#manual.loading.encoding" title="Encodings">Encodings</a> </h3></div></div></div> -<a name="xml_encoding"></a><p> - pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little - endian), UTF-32 (big and little endian); UCS-2 is naturally supported since - it's a strict subset of UTF-16) and handles all encoding conversions. Most - loading functions accept the optional parameter <code class="computeroutput"><span class="identifier">encoding</span></code>. - This is a value of enumeration type <code class="computeroutput"><span class="identifier">xml_encoding</span></code>, +<p> + <a name="xml_encoding"></a>pugixml supports all popular Unicode encodings + (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 + is naturally supported since it's a strict subset of UTF-16) and handles + all encoding conversions. Most loading functions accept the optional parameter + <code class="computeroutput"><span class="identifier">encoding</span></code>. This is a value + of enumeration type <code class="computeroutput"><span class="identifier">xml_encoding</span></code>, that can have the following values: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="encoding_auto"></a><code class="literal">encoding_auto</code> means that pugixml will try to guess the encoding based on source XML data. The algorithm is a modified version of the one presented in Appendix F.1 of XML recommendation; it tries to match the first few bytes of input data with the following patterns in strict order: <br><br> - <div class="itemizedlist"><ul class="itemizedlist" type="circle"> + <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> <li class="listitem"> If first four bytes match UTF-32 BOM (Byte Order Mark), encoding is assumed to be UTF-32 with the endianness equal to that of BOM; @@ -727,7 +751,6 @@ </li> <li class="listitem"> Otherwise encoding is assumed to be UTF-8. <br><br> - </li> </ul></div> </li> @@ -799,7 +822,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.loading.w3c"></a><a class="link" href="loading.html#manual.loading.w3c" title="Conformance to W3C specification"> Conformance to W3C specification</a> +<a name="manual.loading.w3c"></a><a class="link" href="loading.html#manual.loading.w3c" title="Conformance to W3C specification">Conformance to W3C specification</a> </h3></div></div></div> <p> pugixml is not fully W3C conformant - it can load any valid XML document, @@ -818,7 +841,7 @@ As for rejecting invalid XML documents, there are a number of incompatibilities with W3C specification, including: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Multiple attributes of the same node can have equal names. </li> @@ -848,7 +871,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -856,7 +879,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/modify.html b/docs/manual/modify.html index f2f7785..05b0fbe 100644 --- a/docs/manual/modify.html +++ b/docs/manual/modify.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Modifying document data</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="access.html" title="Accessing document data"> <link rel="next" href="saving.html" title="Saving document"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,15 +28,16 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.modify"></a><a class="link" href="modify.html" title="Modifying document data"> Modifying document data</a> +<a name="manual.modify"></a><a class="link" href="modify.html" title="Modifying document data">Modifying document data</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="modify.html#manual.modify.nodedata"> Setting node data</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.attrdata"> Setting attribute data</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.add"> Adding nodes/attributes</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.remove"> Removing nodes/attributes</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.text"> Working with text contents</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.clone"> Cloning nodes/attributes</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="modify.html#manual.modify.nodedata">Setting node data</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.attrdata">Setting attribute data</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.add">Adding nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.remove">Removing nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.text">Working with text contents</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.clone">Cloning nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.fragments">Assembling document from fragments</a></span></dt> </dl></div> <p> The document in pugixml is fully mutable: you can completely change the document @@ -60,11 +61,12 @@ </p> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.modify.nodedata"></a><a class="link" href="modify.html#manual.modify.nodedata" title="Setting node data"> Setting node data</a> +<a name="manual.modify.nodedata"></a><a class="link" href="modify.html#manual.modify.nodedata" title="Setting node data">Setting node data</a> </h3></div></div></div> -<a name="xml_node::set_name"></a><a name="xml_node::set_value"></a><p> - As discussed before, nodes can have name and value, both of which are strings. - Depending on node type, name or value may be absent. <a class="link" href="dom.html#node_document">node_document</a> +<p> + <a name="xml_node::set_name"></a><a name="xml_node::set_value"></a>As discussed + before, nodes can have name and value, both of which are strings. Depending + on node type, name or value may be absent. <a class="link" href="dom.html#node_document">node_document</a> nodes do not have a name or value, <a class="link" href="dom.html#node_element">node_element</a> and <a class="link" href="dom.html#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a class="link" href="dom.html#node_pcdata">node_pcdata</a>, @@ -96,31 +98,31 @@ This is an example of setting node name and value (<a href="../samples/modify_base.cpp" target="_top">samples/modify_base.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span> -<span class="comment">// change node name -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"notnode"</span><span class="special">);</span> +<span class="comment">// change node name</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"notnode"</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">", new node name: "</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// change comment text -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"useless comment"</span><span class="special">);</span> +<span class="comment">// change comment text</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"useless comment"</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">", new comment text: "</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// we can't change value of the element or name of the comment -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"1"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">", "</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"2"</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="comment">// we can't change value of the element or name of the comment</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"1"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">", "</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"2"</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.modify.attrdata"></a><a class="link" href="modify.html#manual.modify.attrdata" title="Setting attribute data"> Setting attribute data</a> +<a name="manual.modify.attrdata"></a><a class="link" href="modify.html#manual.modify.attrdata" title="Setting attribute data">Setting attribute data</a> </h3></div></div></div> -<a name="xml_attribute::set_name"></a><a name="xml_attribute::set_value"></a><p> - All attributes have name and value, both of which are strings (value may - be empty). You can set them with the following functions: +<p> + <a name="xml_attribute::set_name"></a><a name="xml_attribute::set_value"></a>All + attributes have name and value, both of which are strings (value may be empty). + You can set them with the following functions: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span> @@ -142,6 +144,8 @@ <span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> </pre> <p> The above functions convert the argument to string and then call the base @@ -167,14 +171,14 @@ <th align="left">Note</th> </tr> <tr><td align="left" valign="top"><p> - There are no portable 64-bit types in C++, so there is no corresponding - <code class="computeroutput"><span class="identifier">set_value</span></code> function. If - your platform has a 64-bit integer, you can easily write such a function - yourself. + <code class="computeroutput"><span class="identifier">set_value</span></code> overloads with + <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code> + type are only available if your platform has reliable support for the type, + including string conversions. </p></td></tr> </table></div> -<a name="xml_attribute::assign"></a><p> - For convenience, all <code class="computeroutput"><span class="identifier">set_value</span></code> +<p> + <a name="xml_attribute::assign"></a>For convenience, all <code class="computeroutput"><span class="identifier">set_value</span></code> functions have the corresponding assignment operators: </p> <pre class="programlisting"><span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span> @@ -182,6 +186,8 @@ <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> </pre> <p> These operators simply call the right <code class="computeroutput"><span class="identifier">set_value</span></code> @@ -193,20 +199,19 @@ This is an example of setting attribute name and value (<a href="../samples/modify_base.cpp" target="_top">samples/modify_base.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"id"</span><span class="special">);</span> -<span class="comment">// change attribute name/value -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"key"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">", "</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"345"</span><span class="special">);</span> +<span class="comment">// change attribute name/value</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"key"</span><span class="special">)</span> <span class="special"><<</span> <span class="string">", "</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"345"</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">", new attribute: "</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"="</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// we can use numbers or booleans -</span><span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="number">1.234</span><span class="special">);</span> +<span class="comment">// we can use numbers or booleans</span> +<span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="number">1.234</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"new attribute value: "</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// we can also use assignment operators for more concise code -</span><span class="identifier">attr</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span> +<span class="comment">// we can also use assignment operators for more concise code</span> +<span class="identifier">attr</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"final attribute value: "</span> <span class="special"><<</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> @@ -214,10 +219,11 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.modify.add"></a><a class="link" href="modify.html#manual.modify.add" title="Adding nodes/attributes"> Adding nodes/attributes</a> +<a name="manual.modify.add"></a><a class="link" href="modify.html#manual.modify.add" title="Adding nodes/attributes">Adding nodes/attributes</a> </h3></div></div></div> -<a name="xml_node::prepend_attribute"></a><a name="xml_node::append_attribute"></a><a name="xml_node::insert_attribute_after"></a><a name="xml_node::insert_attribute_before"></a><a name="xml_node::prepend_child"></a><a name="xml_node::append_child"></a><a name="xml_node::insert_child_after"></a><a name="xml_node::insert_child_before"></a><p> - Nodes and attributes do not exist without a document tree, so you can't create +<p> + <a name="xml_node::prepend_attribute"></a><a name="xml_node::append_attribute"></a><a name="xml_node::insert_attribute_after"></a><a name="xml_node::insert_attribute_before"></a><a name="xml_node::prepend_child"></a><a name="xml_node::append_child"></a><a name="xml_node::insert_child_after"></a><a name="xml_node::insert_child_before"></a>Nodes + and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node: </p> @@ -260,7 +266,7 @@ All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Adding fails if the target node is null; </li> @@ -311,20 +317,19 @@ This is an example of adding new attributes/nodes to the document (<a href="../samples/modify_add.cpp" target="_top">samples/modify_add.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// add node with some name -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span> +<pre class="programlisting"><span class="comment">// add node with some name</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span> -<span class="comment">// add description node with text child -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">descr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span> +<span class="comment">// add description node with text child</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">descr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span> <span class="identifier">descr</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_pcdata</span><span class="special">).</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"Simple node"</span><span class="special">);</span> -<span class="comment">// add param node before the description -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="string">"param"</span><span class="special">,</span> <span class="identifier">descr</span><span class="special">);</span> +<span class="comment">// add param node before the description</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="string">"param"</span><span class="special">,</span> <span class="identifier">descr</span><span class="special">);</span> -<span class="comment">// add attributes to param node -</span><span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"version"</span><span class="special">;</span> +<span class="comment">// add attributes to param node</span> +<span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"version"</span><span class="special">;</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"value"</span><span class="special">)</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">;</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">insert_attribute_after</span><span class="special">(</span><span class="string">"type"</span><span class="special">,</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">))</span> <span class="special">=</span> <span class="string">"float"</span><span class="special">;</span> </pre> @@ -333,10 +338,11 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.modify.remove"></a><a class="link" href="modify.html#manual.modify.remove" title="Removing nodes/attributes"> Removing nodes/attributes</a> +<a name="manual.modify.remove"></a><a class="link" href="modify.html#manual.modify.remove" title="Removing nodes/attributes">Removing nodes/attributes</a> </h3></div></div></div> -<a name="xml_node::remove_attribute"></a><a name="xml_node::remove_child"></a><p> - If you do not want your document to contain some node or attribute, you can +<p> + <a name="xml_node::remove_attribute"></a><a name="xml_node::remove_child"></a>If + you do not want your document to contain some node or attribute, you can remove it with one of the following functions: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">a</span><span class="special">);</span> @@ -350,7 +356,7 @@ attributes) from the document, and returns the operation result. Removing fails if one of the following is true: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> The node the function is called on is null; </li> @@ -388,18 +394,17 @@ This is an example of removing attributes/nodes from the document (<a href="../samples/modify_remove.cpp" target="_top">samples/modify_remove.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// remove description node with the whole subtree -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span> +<pre class="programlisting"><span class="comment">// remove description node with the whole subtree</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">remove_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span> -<span class="comment">// remove id attribute -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"param"</span><span class="special">);</span> +<span class="comment">// remove id attribute</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"param"</span><span class="special">);</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="string">"value"</span><span class="special">);</span> -<span class="comment">// we can also remove nodes/attributes by handles -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">id</span> <span class="special">=</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">);</span> +<span class="comment">// we can also remove nodes/attributes by handles</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">id</span> <span class="special">=</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">);</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="identifier">id</span><span class="special">);</span> </pre> <p> @@ -407,7 +412,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.modify.text"></a><a class="link" href="modify.html#manual.modify.text" title="Working with text contents"> Working with text contents</a> +<a name="manual.modify.text"></a><a class="link" href="modify.html#manual.modify.text" title="Working with text contents">Working with text contents</a> </h3></div></div></div> <p> pugixml provides a special class, <code class="computeroutput"><span class="identifier">xml_text</span></code>, @@ -416,8 +421,8 @@ documentation for accessing document data</a>; this section describes the modification interface of <code class="computeroutput"><span class="identifier">xml_text</span></code>. </p> -<a name="xml_text::set"></a><p> - Once you have an <code class="computeroutput"><span class="identifier">xml_text</span></code> +<p> + <a name="xml_text::set"></a>Once you have an <code class="computeroutput"><span class="identifier">xml_text</span></code> object, you can set the text contents using the following function: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span> @@ -434,14 +439,16 @@ an element node, this function creates the PCDATA child node if necessary (i.e. if the element node does not have a PCDATA/CDATA child already). </p> -<a name="xml_text::set_value"></a><p> - In addition to a string function, several functions are provided for handling - text with numbers and booleans as contents: +<p> + <a name="xml_text::set_value"></a>In addition to a string function, several + functions are provided for handling text with numbers and booleans as contents: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> </pre> <p> The above functions convert the argument to string and then call the base @@ -450,8 +457,8 @@ functions. You can <a class="link" href="modify.html#xml_attribute::set_value">refer to documentation for the attribute functions</a> for details. </p> -<a name="xml_text::assign"></a><p> - For convenience, all <code class="computeroutput"><span class="identifier">set</span></code> +<p> + <a name="xml_text::assign"></a>For convenience, all <code class="computeroutput"><span class="identifier">set</span></code> functions have the corresponding assignment operators: </p> <pre class="programlisting"><span class="identifier">xml_text</span><span class="special">&</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span> @@ -459,6 +466,8 @@ <span class="identifier">xml_text</span><span class="special">&</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="identifier">xml_text</span><span class="special">&</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span> <span class="identifier">xml_text</span><span class="special">&</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="identifier">xml_text</span><span class="special">&</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> +<span class="identifier">xml_text</span><span class="special">&</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span> </pre> <p> These operators simply call the right <code class="computeroutput"><span class="identifier">set</span></code> @@ -471,30 +480,29 @@ object to modify text contents (<a href="../samples/text.cpp" target="_top">samples/text.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// change project version -</span><span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"version"</span><span class="special">).</span><span class="identifier">text</span><span class="special">()</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// change project version</span> +<span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"version"</span><span class="special">).</span><span class="identifier">text</span><span class="special">()</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">;</span> -<span class="comment">// add description element and set the contents -</span><span class="comment">// note that we do not have to explicitly add the node_pcdata child -</span><span class="identifier">project</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">set</span><span class="special">(</span><span class="string">"a test project"</span><span class="special">);</span> +<span class="comment">// add description element and set the contents</span> +<span class="comment">// note that we do not have to explicitly add the node_pcdata child</span> +<span class="identifier">project</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">set</span><span class="special">(</span><span class="string">"a test project"</span><span class="special">);</span> </pre> <p> </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.modify.clone"></a><a class="link" href="modify.html#manual.modify.clone" title="Cloning nodes/attributes"> Cloning nodes/attributes</a> +<a name="manual.modify.clone"></a><a class="link" href="modify.html#manual.modify.clone" title="Cloning nodes/attributes">Cloning nodes/attributes</a> </h3></div></div></div> -<a name="xml_node::prepend_copy"></a><a name="xml_node::append_copy"></a><a name="xml_node::insert_copy_after"></a><a name="xml_node::insert_copy_before"></a><p> - With the help of previously described functions, it is possible to create - trees with any contents and structure, including cloning the existing data. - However since this is an often needed operation, pugixml provides built-in - node/attribute cloning facilities. Since nodes and attributes do not exist - without a document tree, you can't create a standalone copy - you have to - immediately insert it somewhere in the tree. For this, you can use one of - the following functions: +<p> + <a name="xml_node::prepend_copy"></a><a name="xml_node::append_copy"></a><a name="xml_node::insert_copy_after"></a><a name="xml_node::insert_copy_before"></a>With + the help of previously described functions, it is possible to create trees + with any contents and structure, including cloning the existing data. However + since this is an often needed operation, pugixml provides built-in node/attribute + cloning facilities. Since nodes and attributes do not exist without a document + tree, you can't create a standalone copy - you have to immediately insert + it somewhere in the tree. For this, you can use one of the following functions: </p> <pre class="programlisting"><span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_copy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">proto</span><span class="special">);</span> <span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_copy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&</span> <span class="identifier">proto</span><span class="special">);</span> @@ -528,7 +536,7 @@ for more information</a>. There are additional caveats specific to cloning functions: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Cloning null handles results in operation failure; </li> @@ -551,7 +559,6 @@ node cloning and usage of other document modification functions: </p> <p> - </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">load_preprocess</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span><span class="special">&</span> <span class="identifier">doc</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">);</span> @@ -563,23 +570,23 @@ <span class="special">{</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">include</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">;</span> - <span class="comment">// load new preprocessed document (note: ideally this should handle relative paths) -</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span> <span class="special">=</span> <span class="identifier">include</span><span class="special">.</span><span class="identifier">value</span><span class="special">();</span> + <span class="comment">// load new preprocessed document (note: ideally this should handle relative paths)</span> + <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span> <span class="special">=</span> <span class="identifier">include</span><span class="special">.</span><span class="identifier">value</span><span class="special">();</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> <span class="keyword">if</span> <span class="special">(!</span><span class="identifier">load_preprocess</span><span class="special">(</span><span class="identifier">doc</span><span class="special">,</span> <span class="identifier">path</span><span class="special">))</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span> - <span class="comment">// insert the comment marker above include directive -</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_comment</span><span class="special">,</span> <span class="identifier">include</span><span class="special">).</span><span class="identifier">set_value</span><span class="special">(</span><span class="identifier">path</span><span class="special">);</span> + <span class="comment">// insert the comment marker above include directive</span> + <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_comment</span><span class="special">,</span> <span class="identifier">include</span><span class="special">).</span><span class="identifier">set_value</span><span class="special">(</span><span class="identifier">path</span><span class="special">);</span> - <span class="comment">// copy the document above the include directive (this retains the original order!) -</span> <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">ic</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">ic</span><span class="special">;</span> <span class="identifier">ic</span> <span class="special">=</span> <span class="identifier">ic</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span> + <span class="comment">// copy the document above the include directive (this retains the original order!)</span> + <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">ic</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">ic</span><span class="special">;</span> <span class="identifier">ic</span> <span class="special">=</span> <span class="identifier">ic</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span> <span class="special">{</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_copy_before</span><span class="special">(</span><span class="identifier">ic</span><span class="special">,</span> <span class="identifier">include</span><span class="special">);</span> <span class="special">}</span> - <span class="comment">// remove the include node and move to the next child -</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">();</span> + <span class="comment">// remove the include node and move to the next child</span> + <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">();</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">remove_child</span><span class="special">(</span><span class="identifier">include</span><span class="special">);</span> <span class="special">}</span> @@ -596,18 +603,83 @@ <span class="keyword">bool</span> <span class="identifier">load_preprocess</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span><span class="special">&</span> <span class="identifier">doc</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">)</span> <span class="special">{</span> - <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="identifier">path</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_pi</span><span class="special">);</span> <span class="comment">// for <?include?> -</span> + <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="identifier">path</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_pi</span><span class="special">);</span> <span class="comment">// for <?include?></span> + <span class="keyword">return</span> <span class="identifier">result</span> <span class="special">?</span> <span class="identifier">preprocess</span><span class="special">(</span><span class="identifier">doc</span><span class="special">)</span> <span class="special">:</span> <span class="keyword">false</span><span class="special">;</span> <span class="special">}</span> </pre> <p> </p> </div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="manual.modify.fragments"></a><a class="link" href="modify.html#manual.modify.fragments" title="Assembling document from fragments">Assembling document from fragments</a> +</h3></div></div></div> +<p> + <a name="xml_node::append_buffer"></a>pugixml provides several ways to assemble + an XML document from other XML documents. Assuming there is a set of document + fragments, represented as in-memory buffers, the implementation choices are + as follows: + </p> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> + Use a temporary document to parse the data from a string, then clone + the nodes to a destination node. For example: + </li></ul></div> +<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">append_fragment</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">target</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> + <span class="keyword">if</span> <span class="special">(!</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">))</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span> + + <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">child</span><span class="special">;</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span> + <span class="identifier">target</span><span class="special">.</span><span class="identifier">append_copy</span><span class="special">(</span><span class="identifier">child</span><span class="special">);</span> +<span class="special">}</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> + Cache the parsing step - instead of keeping in-memory buffers, keep document + objects that already contain the parsed fragment: + </li></ul></div> +<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">append_fragment</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">target</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span><span class="special">&</span> <span class="identifier">cached_fragment</span><span class="special">)</span> +<span class="special">{</span> + <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">cached_fragment</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">child</span><span class="special">;</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span> + <span class="identifier">target</span><span class="special">.</span><span class="identifier">append_copy</span><span class="special">(</span><span class="identifier">child</span><span class="special">);</span> +<span class="special">}</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> + Use xml_node::append_buffer directly: + </li></ul></div> +<pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_buffer</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span> +</pre> +<p> + The first method is more convenient, but slower than the other two. The relative + performance of <code class="computeroutput"><span class="identifier">append_copy</span></code> + and <code class="computeroutput"><span class="identifier">append_buffer</span></code> depends + on the buffer format - usually <code class="computeroutput"><span class="identifier">append_buffer</span></code> + is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending + on <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>). At + the same time it might be less efficient in terms of memory usage - the implementation + makes a copy of the provided buffer, and the copy has the same lifetime as + the document - the memory used by that copy will be reclaimed after the document + is destroyed, but no sooner. Even deleting all nodes in the document, including + the appended ones, won't reclaim the memory. + </p> +<p> + <code class="computeroutput"><span class="identifier">append_buffer</span></code> behaves in + the same way as <a class="link" href="loading.html#xml_document::load_buffer">xml_document::load_buffer</a> + - the input buffer is a byte buffer, with size in bytes; the buffer is not + modified and can be freed after the function returns. + </p> +<p> + <a name="status_append_invalid_root"></a>Since <code class="computeroutput"><span class="identifier">append_buffer</span></code> + needs to append child nodes to the current node, it only works if the current + node is either document or element node. Calling <code class="computeroutput"><span class="identifier">append_buffer</span></code> + on a node with any other type results in an error with <code class="computeroutput"><span class="identifier">status_append_invalid_root</span></code> + status. + </p> +</div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -615,7 +687,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/saving.html b/docs/manual/saving.html index d0b2e02..2c05a7b 100644 --- a/docs/manual/saving.html +++ b/docs/manual/saving.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Saving document</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="modify.html" title="Modifying document data"> <link rel="next" href="xpath.html" title="XPath"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,16 +28,16 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.saving"></a><a class="link" href="saving.html" title="Saving document"> Saving document</a> +<a name="manual.saving"></a><a class="link" href="saving.html" title="Saving document">Saving document</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="saving.html#manual.saving.file"> Saving document to a file</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.stream"> Saving document to C++ IOstreams</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.writer"> Saving document via writer interface</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.subtree"> Saving a single subtree</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.options"> Output options</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.encoding"> Encodings</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.declaration"> Customizing document declaration</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="saving.html#manual.saving.file">Saving document to a file</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.stream">Saving document to C++ IOstreams</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.writer">Saving document via writer interface</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.subtree">Saving a single subtree</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.options">Output options</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.encoding">Encodings</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.declaration">Customizing document declaration</a></span></dt> </dl></div> <p> Often after creating a new document or loading the existing one and processing @@ -46,8 +46,8 @@ include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow - to customize the output format (see <a class="xref" href="saving.html#manual.saving.options" title="Output options"> Output options</a>), and also perform - necessary encoding conversions (see <a class="xref" href="saving.html#manual.saving.encoding" title="Encodings"> Encodings</a>). This section documents + to customize the output format (see <a class="xref" href="saving.html#manual.saving.options" title="Output options">Output options</a>), and also perform + necessary encoding conversions (see <a class="xref" href="saving.html#manual.saving.encoding" title="Encodings">Encodings</a>). This section documents the relevant functionality. </p> <p> @@ -68,19 +68,20 @@ </p> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.file"></a><a class="link" href="saving.html#manual.saving.file" title="Saving document to a file"> Saving document to a file</a> +<a name="manual.saving.file"></a><a class="link" href="saving.html#manual.saving.file" title="Saving document to a file">Saving document to a file</a> </h3></div></div></div> -<a name="xml_document::save_file"></a><a name="xml_document::save_file_wide"></a><p> - If you want to save the whole document to a file, you can use one of the - following functions: +<p> + <a name="xml_document::save_file"></a><a name="xml_document::save_file_wide"></a>If + you want to save the whole document to a file, you can use one of the following + functions: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">bool</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> </pre> <p> These functions accept file path as its first argument, and also three optional - arguments, which specify indentation and other output options (see <a class="xref" href="saving.html#manual.saving.options" title="Output options"> Output options</a>) - and output data encoding (see <a class="xref" href="saving.html#manual.saving.encoding" title="Encodings"> Encodings</a>). The path has the target + arguments, which specify indentation and other output options (see <a class="xref" href="saving.html#manual.saving.options" title="Output options">Output options</a>) + and output data encoding (see <a class="xref" href="saving.html#manual.saving.encoding" title="Encodings">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc. @@ -92,38 +93,39 @@ a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function. </p> -<a name="xml_writer_file"></a><p> - <code class="computeroutput"><span class="identifier">save_file</span></code> opens the target - file for writing, outputs the requested header (by default a document declaration - is output, unless the document already has one), and then saves the document - contents. If the file could not be opened, the function returns <code class="computeroutput"><span class="keyword">false</span></code>. Calling <code class="computeroutput"><span class="identifier">save_file</span></code> - is equivalent to creating an <code class="computeroutput"><span class="identifier">xml_writer_file</span></code> - object with <code class="computeroutput"><span class="identifier">FILE</span><span class="special">*</span></code> +<p> + <a name="xml_writer_file"></a><code class="computeroutput"><span class="identifier">save_file</span></code> + opens the target file for writing, outputs the requested header (by default + a document declaration is output, unless the document already has one), and + then saves the document contents. If the file could not be opened, the function + returns <code class="computeroutput"><span class="keyword">false</span></code>. Calling <code class="computeroutput"><span class="identifier">save_file</span></code> is equivalent to creating an + <code class="computeroutput"><span class="identifier">xml_writer_file</span></code> object with + <code class="computeroutput"><span class="identifier">FILE</span><span class="special">*</span></code> handle as the only constructor argument and then calling <code class="computeroutput"><span class="identifier">save</span></code>; - see <a class="xref" href="saving.html#manual.saving.writer" title="Saving document via writer interface"> Saving document via writer interface</a> for writer interface details. + see <a class="xref" href="saving.html#manual.saving.writer" title="Saving document via writer interface">Saving document via writer interface</a> for writer interface details. </p> <p> This is a simple example of saving XML document to file (<a href="../samples/save_file.cpp" target="_top">samples/save_file.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// save document to file -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Saving result: "</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">save_file</span><span class="special">(</span><span class="string">"save_file_output.xml"</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// save document to file</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Saving result: "</span> <span class="special"><<</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">save_file</span><span class="special">(</span><span class="string">"save_file_output.xml"</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.stream"></a><a class="link" href="saving.html#manual.saving.stream" title="Saving document to C++ IOstreams"> Saving document to C++ IOstreams</a> +<a name="manual.saving.stream"></a><a class="link" href="saving.html#manual.saving.stream" title="Saving document to C++ IOstreams">Saving document to C++ IOstreams</a> </h3></div></div></div> -<a name="xml_document::save_stream"></a><p> - To enhance interoperability pugixml provides functions for saving document - to any object which implements C++ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span></code> - interface. This allows you to save documents to any standard C++ stream (i.e. - file stream) or any third-party compliant implementation (i.e. Boost Iostreams). - Most notably, this allows for easy debug output, since you can use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span></code> +<p> + <a name="xml_document::save_stream"></a>To enhance interoperability pugixml + provides functions for saving document to any object which implements C++ + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span></code> interface. This allows you to save + documents to any standard C++ stream (i.e. file stream) or any third-party + compliant implementation (i.e. Boost Iostreams). Most notably, this allows + for easy debug output, since you can use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span></code> stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones: </p> @@ -143,20 +145,19 @@ you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale. </p> -<a name="xml_writer_stream"></a><p> - Calling <code class="computeroutput"><span class="identifier">save</span></code> with stream - target is equivalent to creating an <code class="computeroutput"><span class="identifier">xml_writer_stream</span></code> - object with stream as the only constructor argument and then calling <code class="computeroutput"><span class="identifier">save</span></code>; see <a class="xref" href="saving.html#manual.saving.writer" title="Saving document via writer interface"> Saving document via writer interface</a> for writer +<p> + <a name="xml_writer_stream"></a>Calling <code class="computeroutput"><span class="identifier">save</span></code> + with stream target is equivalent to creating an <code class="computeroutput"><span class="identifier">xml_writer_stream</span></code> + object with stream as the only constructor argument and then calling <code class="computeroutput"><span class="identifier">save</span></code>; see <a class="xref" href="saving.html#manual.saving.writer" title="Saving document via writer interface">Saving document via writer interface</a> for writer interface details. </p> <p> This is a simple example of saving XML document to standard output (<a href="../samples/save_stream.cpp" target="_top">samples/save_stream.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// save document to standard output -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Document:\n"</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// save document to standard output</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Document:\n"</span><span class="special">;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> </pre> <p> @@ -164,10 +165,11 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.writer"></a><a class="link" href="saving.html#manual.saving.writer" title="Saving document via writer interface"> Saving document via writer interface</a> +<a name="manual.saving.writer"></a><a class="link" href="saving.html#manual.saving.writer" title="Saving document via writer interface">Saving document via writer interface</a> </h3></div></div></div> -<a name="xml_document::save"></a><a name="xml_writer"></a><a name="xml_writer::write"></a><p> - All of the above saving functions are implemented in terms of writer interface. +<p> + <a name="xml_document::save"></a><a name="xml_writer"></a><a name="xml_writer::write"></a>All + of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input: </p> @@ -203,7 +205,6 @@ read the sample code for more complex examples: </p> <p> - </p> <pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xml_string_writer</span><span class="special">:</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_writer</span> <span class="special">{</span> @@ -220,10 +221,11 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.subtree"></a><a class="link" href="saving.html#manual.saving.subtree" title="Saving a single subtree"> Saving a single subtree</a> +<a name="manual.saving.subtree"></a><a class="link" href="saving.html#manual.saving.subtree" title="Saving a single subtree">Saving a single subtree</a> </h3></div></div></div> -<a name="xml_node::print"></a><a name="xml_node::print_stream"></a><p> - While the previously described functions save the whole document to the destination, +<p> + <a name="xml_node::print"></a><a name="xml_node::print_stream"></a>While + the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided: </p> <pre class="programlisting"><span class="keyword">void</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">depth</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -246,22 +248,21 @@ illustrates the difference: </p> <p> - </p> -<pre class="programlisting"><span class="comment">// get a test document -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// get a test document</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="string">"<foo bar='baz'><call>hey</call></foo>"</span><span class="special">);</span> -<span class="comment">// print document to standard output (prints <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>) -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> +<span class="comment">// print document to standard output (prints <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>)</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// print document to standard output as a regular node (prints <foo bar="baz"><call>hey</call></foo>) -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> +<span class="comment">// print document to standard output as a regular node (prints <foo bar="baz"><call>hey</call></foo>)</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// print a subtree to standard output (prints <call>hey</call>) -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"foo"</span><span class="special">).</span><span class="identifier">child</span><span class="special">(</span><span class="string">"call"</span><span class="special">).</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> +<span class="comment">// print a subtree to standard output (prints <call>hey</call>)</span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"foo"</span><span class="special">).</span><span class="identifier">child</span><span class="special">(</span><span class="string">"call"</span><span class="special">).</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> @@ -269,7 +270,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.options"></a><a class="link" href="saving.html#manual.saving.options" title="Output options"> Output options</a> +<a name="manual.saving.options"></a><a class="link" href="saving.html#manual.saving.options" title="Output options">Output options</a> </h3></div></div></div> <p> All saving functions accept the optional parameter <code class="computeroutput"><span class="identifier">flags</span></code>. @@ -291,7 +292,7 @@ <p> These flags control the resulting tree contents: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="format_indent"></a><code class="literal">format_indent</code> determines if all nodes should be indented with the indentation string (this is an additional @@ -301,7 +302,6 @@ node's depth relative to the output subtree. This flag has no effect if <a class="link" href="saving.html#format_raw">format_raw</a> is enabled. This flag is <span class="bold"><strong>on</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="format_raw"></a><code class="literal">format_raw</code> switches between formatted and @@ -312,24 +312,23 @@ with <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a> flag, to preserve the original document formatting as much as possible. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="format_no_escapes"></a><code class="literal">format_no_escapes</code> disables output - escaping for attribute values and PCDATA contents. If this flag is on, + escaping for attribute values and PCDATA contents. If this flag is off, special symbols (', &, <, >) and all non-printable characters (those with codepoint values less than 32) are converted to XML escape - sequences (i.e. &amp;) during output. If this flag is off, no text + sequences (i.e. &amp;) during output. If this flag is on, no text processing is performed; therefore, output XML can be malformed if output contents contains invalid symbols (i.e. having a stray < in the PCDATA - will make the output malformed). This flag is <span class="bold"><strong>on</strong></span> + will make the output malformed). This flag is <span class="bold"><strong>off</strong></span> by default. </li> </ul></div> <p> These flags control the additional output information: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a name="format_no_declaration"></a><code class="literal">format_no_declaration</code> disables default node declaration output. By default, if the document is saved @@ -338,7 +337,6 @@ the document contents. Enabling this flag disables this declaration. This flag has no effect in <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span></code> functions: they never output the default declaration. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br> - </li> <li class="listitem"> <a name="format_write_bom"></a><code class="literal">format_write_bom</code> enables Byte Order @@ -364,7 +362,7 @@ <p> Additionally, there is one predefined option mask: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> <a name="format_default"></a><code class="literal">format_default</code> is the default set of flags, i.e. it has all options set to their default values. It sets formatted output with indentation, without BOM and with default node declaration, @@ -374,44 +372,43 @@ This is an example that shows the outputs of different output options (<a href="../samples/save_options.cpp" target="_top">samples/save_options.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// get a test document -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// get a test document</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="string">"<foo bar='baz'><call>hey</call></foo>"</span><span class="special">);</span> -<span class="comment">// default options; prints -</span><span class="comment">// <?xml version="1.0"?> -</span><span class="comment">// <foo bar="baz"> -</span><span class="comment">// <call>hey</call> -</span><span class="comment">// </foo> -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> +<span class="comment">// default options; prints</span> +<span class="comment">// <?xml version="1.0"?></span> +<span class="comment">// <foo bar="baz"></span> +<span class="comment">// <call>hey</call></span> +<span class="comment">// </foo></span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// default options with custom indentation string; prints -</span><span class="comment">// <?xml version="1.0"?> -</span><span class="comment">// <foo bar="baz"> -</span><span class="comment">// --<call>hey</call> -</span><span class="comment">// </foo> -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"--"</span><span class="special">);</span> +<span class="comment">// default options with custom indentation string; prints</span> +<span class="comment">// <?xml version="1.0"?></span> +<span class="comment">// <foo bar="baz"></span> +<span class="comment">// --<call>hey</call></span> +<span class="comment">// </foo></span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"--"</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// default options without indentation; prints -</span><span class="comment">// <?xml version="1.0"?> -</span><span class="comment">// <foo bar="baz"> -</span><span class="comment">// <call>hey</call> -</span><span class="comment">// </foo> -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_default</span> <span class="special">&</span> <span class="special">~</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_indent</span><span class="special">);</span> <span class="comment">// can also pass "" instead of indentation string for the same effect -</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="comment">// default options without indentation; prints</span> +<span class="comment">// <?xml version="1.0"?></span> +<span class="comment">// <foo bar="baz"></span> +<span class="comment">// <call>hey</call></span> +<span class="comment">// </foo></span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_default</span> <span class="special">&</span> <span class="special">~</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_indent</span><span class="special">);</span> <span class="comment">// can also pass "" instead of indentation string for the same effect</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// raw output; prints -</span><span class="comment">// <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo> -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> +<span class="comment">// raw output; prints</span> +<span class="comment">// <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo></span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// raw output without declaration; prints -</span><span class="comment">// <foo bar="baz"><call>hey</call></foo> -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_no_declaration</span><span class="special">);</span> +<span class="comment">// raw output without declaration; prints</span> +<span class="comment">// <foo bar="baz"><call>hey</call></foo></span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_no_declaration</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> @@ -419,7 +416,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.encoding"></a><a class="link" href="saving.html#manual.saving.encoding" title="Encodings"> Encodings</a> +<a name="manual.saving.encoding"></a><a class="link" href="saving.html#manual.saving.encoding" title="Encodings">Encodings</a> </h3></div></div></div> <p> pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little @@ -427,7 +424,7 @@ it's a strict subset of UTF-16) and handles all encoding conversions during output. The output encoding is set via the <code class="computeroutput"><span class="identifier">encoding</span></code> parameter of saving functions, which is of type <code class="computeroutput"><span class="identifier">xml_encoding</span></code>. - The possible values for the encoding are documented in <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>; + The possible values for the encoding are documented in <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings">Encodings</a>; the only flag that has a different meaning is <code class="computeroutput"><span class="identifier">encoding_auto</span></code>. </p> <p> @@ -460,7 +457,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.saving.declaration"></a><a class="link" href="saving.html#manual.saving.declaration" title="Customizing document declaration"> Customizing document declaration</a> +<a name="manual.saving.declaration"></a><a class="link" href="saving.html#manual.saving.declaration" title="Customizing document declaration">Customizing document declaration</a> </h3></div></div></div> <p> When you are saving the document using <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save_file</span><span class="special">()</span></code>, a default XML document declaration is @@ -493,23 +490,22 @@ This is an example that shows how to create a custom declaration node (<a href="../samples/save_declaration.cpp" target="_top">samples/save_declaration.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// get a test document -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// get a test document</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="string">"<foo bar='baz'><call>hey</call></foo>"</span><span class="special">);</span> -<span class="comment">// add a custom declaration node -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">decl</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">prepend_child</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_declaration</span><span class="special">);</span> +<span class="comment">// add a custom declaration node</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">decl</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">prepend_child</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_declaration</span><span class="special">);</span> <span class="identifier">decl</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"version"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"1.0"</span><span class="special">;</span> <span class="identifier">decl</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"encoding"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"UTF-8"</span><span class="special">;</span> <span class="identifier">decl</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"standalone"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"no"</span><span class="special">;</span> -<span class="comment">// <?xml version="1.0" encoding="UTF-8" standalone="no"?> -</span><span class="comment">// <foo bar="baz"> -</span><span class="comment">// <call>hey</call> -</span><span class="comment">// </foo> -</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> +<span class="comment">// <?xml version="1.0" encoding="UTF-8" standalone="no"?> </span> +<span class="comment">// <foo bar="baz"></span> +<span class="comment">// <call>hey</call></span> +<span class="comment">// </foo></span> +<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> </pre> <p> @@ -518,7 +514,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -526,7 +522,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/toc.html b/docs/manual/toc.html index d9fe5f8..3bedd68 100644 --- a/docs/manual/toc.html +++ b/docs/manual/toc.html @@ -3,15 +3,15 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Table of Contents</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="apiref.html" title="API Reference"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -27,115 +27,117 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.toc"></a><a class="link" href="toc.html" title="Table of Contents"> Table of Contents</a> +<a name="manual.toc"></a><a class="link" href="toc.html" title="Table of Contents">Table of Contents</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="../manual.html#manual.overview"> Overview</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="../manual.html#manual.overview">Overview</a></span></dt> <dd><dl> -<dt><span class="section"><a href="../manual.html#manual.overview.introduction"> Introduction</a></span></dt> -<dt><span class="section"><a href="../manual.html#manual.overview.feedback"> Feedback</a></span></dt> -<dt><span class="section"><a href="../manual.html#manual.overview.thanks"> Acknowledgments</a></span></dt> -<dt><span class="section"><a href="../manual.html#manual.overview.license"> License</a></span></dt> +<dt><span class="section"><a href="../manual.html#manual.overview.introduction">Introduction</a></span></dt> +<dt><span class="section"><a href="../manual.html#manual.overview.feedback">Feedback</a></span></dt> +<dt><span class="section"><a href="../manual.html#manual.overview.thanks">Acknowledgments</a></span></dt> +<dt><span class="section"><a href="../manual.html#manual.overview.license">License</a></span></dt> </dl></dd> -<dt><span class="section"><a href="install.html"> Installation</a></span></dt> +<dt><span class="section"><a href="install.html">Installation</a></span></dt> <dd><dl> -<dt><span class="section"><a href="install.html#manual.install.getting"> Getting pugixml</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting">Getting pugixml</a></span></dt> <dd><dl> -<dt><span class="section"><a href="install.html#manual.install.getting.source"> Source distributions</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.getting.subversion"> Subversion repository</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting.source">Source distributions</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting.subversion">Subversion repository</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.getting.git">Git repository</a></span></dt> </dl></dd> -<dt><span class="section"><a href="install.html#manual.install.building"> Building pugixml</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.building">Building pugixml</a></span></dt> <dd><dl> -<dt><span class="section"><a href="install.html#manual.install.building.embed"> Building pugixml as +<dt><span class="section"><a href="install.html#manual.install.building.embed">Building pugixml as a part of another static library/executable</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.static"> Building pugixml as +<dt><span class="section"><a href="install.html#manual.install.building.static">Building pugixml as a standalone static library</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.shared"> Building pugixml as +<dt><span class="section"><a href="install.html#manual.install.building.shared">Building pugixml as a standalone shared library</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.header"> Using pugixml in header-only - mode</a></span></dt> -<dt><span class="section"><a href="install.html#manual.install.building.config"> Additional configuration +<dt><span class="section"><a href="install.html#manual.install.building.header">Using + pugixml in header-only mode</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.building.config">Additional configuration options</a></span></dt> </dl></dd> -<dt><span class="section"><a href="install.html#manual.install.portability"> Portability</a></span></dt> +<dt><span class="section"><a href="install.html#manual.install.portability">Portability</a></span></dt> </dl></dd> -<dt><span class="section"><a href="dom.html"> Document object model</a></span></dt> +<dt><span class="section"><a href="dom.html">Document object model</a></span></dt> <dd><dl> -<dt><span class="section"><a href="dom.html#manual.dom.tree"> Tree structure</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.cpp"> C++ interface</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.unicode"> Unicode interface</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.thread"> Thread-safety guarantees</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.exception"> Exception guarantees</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.memory"> Memory management</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.tree">Tree structure</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.cpp">C++ interface</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.unicode">Unicode interface</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.thread">Thread-safety guarantees</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.exception">Exception guarantees</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.memory">Memory management</a></span></dt> <dd><dl> -<dt><span class="section"><a href="dom.html#manual.dom.memory.custom"> Custom memory allocation/deallocation +<dt><span class="section"><a href="dom.html#manual.dom.memory.custom">Custom memory allocation/deallocation functions</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.memory.tuning"> Memory consumption tuning</a></span></dt> -<dt><span class="section"><a href="dom.html#manual.dom.memory.internals"> Document memory management +<dt><span class="section"><a href="dom.html#manual.dom.memory.tuning">Memory consumption tuning</a></span></dt> +<dt><span class="section"><a href="dom.html#manual.dom.memory.internals">Document memory management internals</a></span></dt> </dl></dd> </dl></dd> -<dt><span class="section"><a href="loading.html"> Loading document</a></span></dt> +<dt><span class="section"><a href="loading.html">Loading document</a></span></dt> <dd><dl> -<dt><span class="section"><a href="loading.html#manual.loading.file"> Loading document from file</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.memory"> Loading document from memory</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.stream"> Loading document from C++ IOstreams</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.errors"> Handling parsing errors</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.options"> Parsing options</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.encoding"> Encodings</a></span></dt> -<dt><span class="section"><a href="loading.html#manual.loading.w3c"> Conformance to W3C specification</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.file">Loading document from file</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.memory">Loading document from memory</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.stream">Loading document from C++ IOstreams</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.errors">Handling parsing errors</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.options">Parsing options</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.encoding">Encodings</a></span></dt> +<dt><span class="section"><a href="loading.html#manual.loading.w3c">Conformance to W3C specification</a></span></dt> </dl></dd> -<dt><span class="section"><a href="access.html"> Accessing document data</a></span></dt> +<dt><span class="section"><a href="access.html">Accessing document data</a></span></dt> <dd><dl> -<dt><span class="section"><a href="access.html#manual.access.basic"> Basic traversal functions</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.nodedata"> Getting node data</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.attrdata"> Getting attribute data</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.contents"> Contents-based traversal functions</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.rangefor"> Range-based for-loop support</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.iterators"> Traversing node/attribute lists +<dt><span class="section"><a href="access.html#manual.access.basic">Basic traversal functions</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.nodedata">Getting node data</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.attrdata">Getting attribute data</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.contents">Contents-based traversal functions</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.rangefor">Range-based for-loop support</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.iterators">Traversing node/attribute lists via iterators</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.walker"> Recursive traversal with xml_tree_walker</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.predicate"> Searching for nodes/attributes +<dt><span class="section"><a href="access.html#manual.access.walker">Recursive traversal with xml_tree_walker</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.predicate">Searching for nodes/attributes with predicates</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.text"> Working with text contents</a></span></dt> -<dt><span class="section"><a href="access.html#manual.access.misc"> Miscellaneous functions</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.text">Working with text contents</a></span></dt> +<dt><span class="section"><a href="access.html#manual.access.misc">Miscellaneous functions</a></span></dt> </dl></dd> -<dt><span class="section"><a href="modify.html"> Modifying document data</a></span></dt> +<dt><span class="section"><a href="modify.html">Modifying document data</a></span></dt> <dd><dl> -<dt><span class="section"><a href="modify.html#manual.modify.nodedata"> Setting node data</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.attrdata"> Setting attribute data</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.add"> Adding nodes/attributes</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.remove"> Removing nodes/attributes</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.text"> Working with text contents</a></span></dt> -<dt><span class="section"><a href="modify.html#manual.modify.clone"> Cloning nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.nodedata">Setting node data</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.attrdata">Setting attribute data</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.add">Adding nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.remove">Removing nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.text">Working with text contents</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.clone">Cloning nodes/attributes</a></span></dt> +<dt><span class="section"><a href="modify.html#manual.modify.fragments">Assembling document from fragments</a></span></dt> </dl></dd> -<dt><span class="section"><a href="saving.html"> Saving document</a></span></dt> +<dt><span class="section"><a href="saving.html">Saving document</a></span></dt> <dd><dl> -<dt><span class="section"><a href="saving.html#manual.saving.file"> Saving document to a file</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.stream"> Saving document to C++ IOstreams</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.writer"> Saving document via writer interface</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.subtree"> Saving a single subtree</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.options"> Output options</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.encoding"> Encodings</a></span></dt> -<dt><span class="section"><a href="saving.html#manual.saving.declaration"> Customizing document declaration</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.file">Saving document to a file</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.stream">Saving document to C++ IOstreams</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.writer">Saving document via writer interface</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.subtree">Saving a single subtree</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.options">Output options</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.encoding">Encodings</a></span></dt> +<dt><span class="section"><a href="saving.html#manual.saving.declaration">Customizing document declaration</a></span></dt> </dl></dd> -<dt><span class="section"><a href="xpath.html"> XPath</a></span></dt> +<dt><span class="section"><a href="xpath.html">XPath</a></span></dt> <dd><dl> -<dt><span class="section"><a href="xpath.html#manual.xpath.types"> XPath types</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.select"> Selecting nodes via XPath expression</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.query"> Using query objects</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.variables"> Using variables</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.errors"> Error handling</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.w3c"> Conformance to W3C specification</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.types">XPath types</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.select">Selecting nodes via XPath expression</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.query">Using query objects</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.variables">Using variables</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.errors">Error handling</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.w3c">Conformance to W3C specification</a></span></dt> </dl></dd> -<dt><span class="section"><a href="changes.html"> Changelog</a></span></dt> -<dt><span class="section"><a href="apiref.html"> API Reference</a></span></dt> -<dt><span class="section"><a href="toc.html"> Table of Contents</a></span></dt> +<dt><span class="section"><a href="changes.html">Changelog</a></span></dt> +<dt><span class="section"><a href="apiref.html">API Reference</a></span></dt> +<dt><span class="section"><a href="toc.html">Table of Contents</a></span></dt> </dl></div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -143,7 +145,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: diff --git a/docs/manual/xpath.html b/docs/manual/xpath.html index bb37f64..e2290e5 100644 --- a/docs/manual/xpath.html +++ b/docs/manual/xpath.html @@ -3,16 +3,16 @@ <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>XPath</title> <link rel="stylesheet" href="../pugixml.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="../manual.html" title="pugixml 1.2"> -<link rel="up" href="../manual.html" title="pugixml 1.2"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<link rel="home" href="../manual.html" title="pugixml 1.4"> +<link rel="up" href="../manual.html" title="pugixml 1.4"> <link rel="prev" href="saving.html" title="Saving document"> <link rel="next" href="changes.html" title="Changelog"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: @@ -28,15 +28,15 @@ <hr> <div class="section"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="manual.xpath"></a><a class="link" href="xpath.html" title="XPath"> XPath</a> +<a name="manual.xpath"></a><a class="link" href="xpath.html" title="XPath">XPath</a> </h2></div></div></div> -<div class="toc"><dl> -<dt><span class="section"><a href="xpath.html#manual.xpath.types"> XPath types</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.select"> Selecting nodes via XPath expression</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.query"> Using query objects</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.variables"> Using variables</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.errors"> Error handling</a></span></dt> -<dt><span class="section"><a href="xpath.html#manual.xpath.w3c"> Conformance to W3C specification</a></span></dt> +<div class="toc"><dl class="toc"> +<dt><span class="section"><a href="xpath.html#manual.xpath.types">XPath types</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.select">Selecting nodes via XPath expression</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.query">Using query objects</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.variables">Using variables</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.errors">Error handling</a></span></dt> +<dt><span class="section"><a href="xpath.html#manual.xpath.w3c">Conformance to W3C specification</a></span></dt> </dl></div> <p> If the task at hand is to select a subset of document nodes that match some @@ -48,7 +48,7 @@ for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found - in <a class="xref" href="xpath.html#manual.xpath.w3c" title="Conformance to W3C specification"> Conformance to W3C specification</a>. The rest of this section describes the interface for XPath + in <a class="xref" href="xpath.html#manual.xpath.w3c" title="Conformance to W3C specification">Conformance to W3C specification</a>. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read <a href="http://www.w3schools.com/xpath/" target="_top">W3Schools XPath tutorial</a>, @@ -58,11 +58,12 @@ </p> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.xpath.types"></a><a class="link" href="xpath.html#manual.xpath.types" title="XPath types"> XPath types</a> +<a name="manual.xpath.types"></a><a class="link" href="xpath.html#manual.xpath.types" title="XPath types">XPath types</a> </h3></div></div></div> -<a name="xpath_value_type"></a><a name="xpath_type_number"></a><a name="xpath_type_string"></a><a name="xpath_type_boolean"></a><a name="xpath_type_node_set"></a><a name="xpath_type_none"></a><p> - Each XPath expression can have one of the following types: boolean, number, - string or node set. Boolean type corresponds to <code class="computeroutput"><span class="keyword">bool</span></code> +<p> + <a name="xpath_value_type"></a><a name="xpath_type_number"></a><a name="xpath_type_string"></a><a name="xpath_type_boolean"></a><a name="xpath_type_node_set"></a><a name="xpath_type_none"></a>Each + XPath expression can have one of the following types: boolean, number, string + or node set. Boolean type corresponds to <code class="computeroutput"><span class="keyword">bool</span></code> type, number type corresponds to <code class="computeroutput"><span class="keyword">double</span></code> type, string type corresponds to either <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span></code>, depending on whether <a class="link" href="dom.html#manual.dom.unicode" title="Unicode interface">wide @@ -72,11 +73,11 @@ <code class="computeroutput"><span class="identifier">xpath_type_number</span></code>, <code class="computeroutput"><span class="identifier">xpath_type_string</span></code> or <code class="computeroutput"><span class="identifier">xpath_type_node_set</span></code>, accordingly. </p> -<a name="xpath_node"></a><a name="xpath_node::node"></a><a name="xpath_node::attribute"></a><a name="xpath_node::parent"></a><p> - Because an XPath node can be either a node or an attribute, there is a special - type, <code class="computeroutput"><span class="identifier">xpath_node</span></code>, which is - a discriminated union of these types. A value of this type contains two node - handles, one of <code class="computeroutput"><span class="identifier">xml_node</span></code> +<p> + <a name="xpath_node"></a><a name="xpath_node::node"></a><a name="xpath_node::attribute"></a><a name="xpath_node::parent"></a>Because an XPath node can be either a node or an + attribute, there is a special type, <code class="computeroutput"><span class="identifier">xpath_node</span></code>, + which is a discriminated union of these types. A value of this type contains + two node handles, one of <code class="computeroutput"><span class="identifier">xml_node</span></code> type, and another one of <code class="computeroutput"><span class="identifier">xml_attribute</span></code> type; at most one of them can be non-null. The accessors to get these handles are available: @@ -101,30 +102,33 @@ handle. For null nodes, <code class="computeroutput"><span class="identifier">parent</span></code> returns null handle. </p> -<a name="xpath_node::unspecified_bool_type"></a><a name="xpath_node::comparison"></a><p> - Like node and attribute handles, XPath node handles can be implicitly cast - to boolean-like object to check if it is a null node, and also can be compared +<p> + <a name="xpath_node::unspecified_bool_type"></a><a name="xpath_node::comparison"></a>Like + node and attribute handles, XPath node handles can be implicitly cast to + boolean-like object to check if it is a null node, and also can be compared for equality with each other. </p> -<a name="xpath_node::ctor"></a><p> - You can also create XPath nodes with one of the three constructors: the default - constructor, the constructor that takes node argument, and the constructor - that takes attribute and node arguments (in which case the attribute must - belong to the attribute list of the node). The constructor from <code class="computeroutput"><span class="identifier">xml_node</span></code> is implicit, so you can usually - pass <code class="computeroutput"><span class="identifier">xml_node</span></code> to functions - that expect <code class="computeroutput"><span class="identifier">xpath_node</span></code>. Apart - from that you usually don't need to create your own XPath node objects, since - they are returned to you via selection functions. - </p> -<a name="xpath_node_set"></a><p> - XPath expressions operate not on single nodes, but instead on node sets. - A node set is a collection of nodes, which can be optionally ordered in either - a forward document order or a reverse one. Document order is defined in XPath - specification; an XPath node is before another node in document order if - it appears before it in XML representation of the corresponding document. - </p> -<a name="xpath_node_set::const_iterator"></a><a name="xpath_node_set::begin"></a><a name="xpath_node_set::end"></a><p> - Node sets are represented by <code class="computeroutput"><span class="identifier">xpath_node_set</span></code> +<p> + <a name="xpath_node::ctor"></a>You can also create XPath nodes with one of + the three constructors: the default constructor, the constructor that takes + node argument, and the constructor that takes attribute and node arguments + (in which case the attribute must belong to the attribute list of the node). + The constructor from <code class="computeroutput"><span class="identifier">xml_node</span></code> + is implicit, so you can usually pass <code class="computeroutput"><span class="identifier">xml_node</span></code> + to functions that expect <code class="computeroutput"><span class="identifier">xpath_node</span></code>. + Apart from that you usually don't need to create your own XPath node objects, + since they are returned to you via selection functions. + </p> +<p> + <a name="xpath_node_set"></a>XPath expressions operate not on single nodes, + but instead on node sets. A node set is a collection of nodes, which can + be optionally ordered in either a forward document order or a reverse one. + Document order is defined in XPath specification; an XPath node is before + another node in document order if it appears before it in XML representation + of the corresponding document. + </p> +<p> + <a name="xpath_node_set::const_iterator"></a><a name="xpath_node_set::begin"></a><a name="xpath_node_set::end"></a>Node sets are represented by <code class="computeroutput"><span class="identifier">xpath_node_set</span></code> object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors: @@ -133,8 +137,9 @@ <span class="identifier">const_iterator</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">const_iterator</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> -<a name="xpath_node_set::index"></a><a name="xpath_node_set::size"></a><a name="xpath_node_set::empty"></a><p> - And it also can be iterated via indices, just like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>: +<p> + <a name="xpath_node_set::index"></a><a name="xpath_node_set::size"></a><a name="xpath_node_set::empty"></a>And it also can be iterated via indices, just + like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>: </p> <pre class="programlisting"><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="keyword">operator</span><span class="special">[](</span><span class="identifier">size_t</span> <span class="identifier">index</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">size_t</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> @@ -147,9 +152,9 @@ set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster. </p> -<a name="xpath_node_set::type"></a><a name="xpath_node_set::type_unsorted"></a><a name="xpath_node_set::type_sorted"></a><a name="xpath_node_set::type_sorted_reverse"></a><a name="xpath_node_set::sort"></a><p> - The order of iteration depends on the order of nodes inside the set; the - order can be queried via the following function: +<p> + <a name="xpath_node_set::type"></a><a name="xpath_node_set::type_unsorted"></a><a name="xpath_node_set::type_sorted"></a><a name="xpath_node_set::type_sorted_reverse"></a><a name="xpath_node_set::sort"></a>The order of iteration depends on the order of + nodes inside the set; the order can be queried via the following function: </p> <pre class="programlisting"><span class="keyword">enum</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">type_t</span> <span class="special">{</span><span class="identifier">type_unsorted</span><span class="special">,</span> <span class="identifier">type_sorted</span><span class="special">,</span> <span class="identifier">type_sorted_reverse</span><span class="special">};</span> <span class="identifier">type_t</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> @@ -173,9 +178,10 @@ will return <code class="computeroutput"><span class="identifier">type_sorted</span></code> or <code class="computeroutput"><span class="identifier">type_sorted_reverse</span></code>. </p> -<a name="xpath_node_set::first"></a><p> - Often the actual iteration is not needed; instead, only the first element - in document order is required. For this, a special accessor is provided: +<p> + <a name="xpath_node_set::first"></a>Often the actual iteration is not needed; + instead, only the first element in document order is required. For this, + a special accessor is provided: </p> <pre class="programlisting"><span class="identifier">xpath_node</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">first</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> @@ -187,10 +193,11 @@ the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse. </p> -<a name="xpath_node_set::ctor"></a><p> - While in the majority of cases the node set is returned by XPath functions, - sometimes there is a need to manually construct a node set. For such cases, - a constructor is provided which takes an iterator range (<code class="computeroutput"><span class="identifier">const_iterator</span></code> +<p> + <a name="xpath_node_set::ctor"></a>While in the majority of cases the node + set is returned by XPath functions, sometimes there is a need to manually + construct a node set. For such cases, a constructor is provided which takes + an iterator range (<code class="computeroutput"><span class="identifier">const_iterator</span></code> is a typedef for <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">*</span></code>), and an optional type: </p> <pre class="programlisting"><span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">xpath_node_set</span><span class="special">(</span><span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">,</span> <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">,</span> <span class="identifier">type_t</span> <span class="identifier">type</span> <span class="special">=</span> <span class="identifier">type_unsorted</span><span class="special">);</span> @@ -205,11 +212,12 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.xpath.select"></a><a class="link" href="xpath.html#manual.xpath.select" title="Selecting nodes via XPath expression"> Selecting nodes via XPath expression</a> +<a name="manual.xpath.select"></a><a class="link" href="xpath.html#manual.xpath.select" title="Selecting nodes via XPath expression">Selecting nodes via XPath expression</a> </h3></div></div></div> -<a name="xml_node::select_single_node"></a><a name="xml_node::select_nodes"></a><p> - If you want to select nodes that match some XPath expression, you can do - it with the following functions: +<p> + <a name="xml_node::select_single_node"></a><a name="xml_node::select_nodes"></a>If + you want to select nodes that match some XPath expression, you can do it + with the following functions: </p> <pre class="programlisting"><span class="identifier">xpath_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_single_node</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">xpath_node_set</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -228,15 +236,15 @@ <p> If exception handling is not disabled, both functions throw <a class="link" href="xpath.html#xpath_exception">xpath_exception</a> if the query can not be compiled or if it returns a value with type other - than node set; see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a> for details. + than node set; see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling">Error handling</a> for details. </p> -<a name="xml_node::select_single_node_precomp"></a><a name="xml_node::select_nodes_precomp"></a><p> - While compiling expressions is fast, the compilation time can introduce a - significant overhead if the same expression is used many times on small subtrees. - If you're doing many similar queries, consider compiling them into query - objects (see <a class="xref" href="xpath.html#manual.xpath.query" title="Using query objects"> Using query objects</a> for further reference). Once you get a compiled - query object, you can pass it to select functions instead of an expression - string: +<p> + <a name="xml_node::select_single_node_precomp"></a><a name="xml_node::select_nodes_precomp"></a>While + compiling expressions is fast, the compilation time can introduce a significant + overhead if the same expression is used many times on small subtrees. If + you're doing many similar queries, consider compiling them into query objects + (see <a class="xref" href="xpath.html#manual.xpath.query" title="Using query objects">Using query objects</a> for further reference). Once you get a compiled query + object, you can pass it to select functions instead of an expression string: </p> <pre class="programlisting"><span class="identifier">xpath_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_single_node</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_query</span><span class="special">&</span> <span class="identifier">query</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">xpath_node_set</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_query</span><span class="special">&</span> <span class="identifier">query</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -249,36 +257,36 @@ This is an example of selecting nodes using XPath expressions (<a href="../samples/xpath_select.cpp" target="_top">samples/xpath_select.cpp</a>): </p> <p> - </p> <pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"</span><span class="special">);</span> -<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Tools:"</span><span class="special">;</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Tools:\n"</span><span class="special">;</span> <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="special">*</span><span class="identifier">it</span><span class="special">;</span> - <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">();</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"\n"</span><span class="special">;</span> <span class="special">}</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node</span> <span class="identifier">build_tool</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_single_node</span><span class="special">(</span><span class="string">"//Tool[contains(Description, 'build system')]"</span><span class="special">);</span> -<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"\nBuild tool: "</span> <span class="special"><<</span> <span class="identifier">build_tool</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"\n"</span><span class="special">;</span> +<span class="keyword">if</span> <span class="special">(</span><span class="identifier">build_tool</span><span class="special">)</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Build tool: "</span> <span class="special"><<</span> <span class="identifier">build_tool</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"\n"</span><span class="special">;</span> </pre> <p> </p> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.xpath.query"></a><a class="link" href="xpath.html#manual.xpath.query" title="Using query objects"> Using query objects</a> +<a name="manual.xpath.query"></a><a class="link" href="xpath.html#manual.xpath.query" title="Using query objects">Using query objects</a> </h3></div></div></div> -<a name="xpath_query"></a><p> - When you call <code class="computeroutput"><span class="identifier">select_nodes</span></code> +<p> + <a name="xpath_query"></a>When you call <code class="computeroutput"><span class="identifier">select_nodes</span></code> with an expression string as an argument, a query object is created behind the scenes. A query object represents a compiled XPath expression. Query objects can be needed in the following circumstances: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> You can precompile expressions to query objects to save compilation time if it becomes an issue; @@ -299,23 +307,25 @@ operator and store pointers to <code class="computeroutput"><span class="identifier">xpath_query</span></code> in the container. </p> -<a name="xpath_query::ctor"></a><p> - You can create a query object with the constructor that takes XPath expression - as an argument: +<p> + <a name="xpath_query::ctor"></a>You can create a query object with the constructor + that takes XPath expression as an argument: </p> <pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">xpath_query</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span> </pre> -<a name="xpath_query::return_type"></a><p> - The expression is compiled and the compiled representation is stored in the - new query object. If compilation fails, <a class="link" href="xpath.html#xpath_exception">xpath_exception</a> - is thrown if exception handling is not disabled (see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a> for - details). After the query is created, you can query the type of the evaluation - result using the following function: +<p> + <a name="xpath_query::return_type"></a>The expression is compiled and the + compiled representation is stored in the new query object. If compilation + fails, <a class="link" href="xpath.html#xpath_exception">xpath_exception</a> is thrown if + exception handling is not disabled (see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling">Error handling</a> for details). + After the query is created, you can query the type of the evaluation result + using the following function: </p> <pre class="programlisting"><span class="identifier">xpath_value_type</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">return_type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> -<a name="xpath_query::evaluate_boolean"></a><a name="xpath_query::evaluate_number"></a><a name="xpath_query::evaluate_string"></a><a name="xpath_query::evaluate_node_set"></a><p> - You can evaluate the query using one of the following functions: +<p> + <a name="xpath_query::evaluate_boolean"></a><a name="xpath_query::evaluate_number"></a><a name="xpath_query::evaluate_string"></a><a name="xpath_query::evaluate_node_set"></a>You + can evaluate the query using one of the following functions: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_boolean</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">double</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_number</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -330,7 +340,7 @@ of this, <code class="computeroutput"><span class="identifier">evaluate_boolean</span></code>, <code class="computeroutput"><span class="identifier">evaluate_number</span></code> and <code class="computeroutput"><span class="identifier">evaluate_string</span></code> always return a result, but <code class="computeroutput"><span class="identifier">evaluate_node_set</span></code> results - in an error if the return type is not node set (see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a>). + in an error if the return type is not node set (see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling">Error handling</a>). </p> <div class="note"><table border="0" summary="Note"> <tr> @@ -342,9 +352,9 @@ is equivalent to calling <code class="computeroutput"><span class="identifier">xpath_query</span><span class="special">(</span><span class="string">"query"</span><span class="special">).</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="identifier">node</span><span class="special">)</span></code>. </p></td></tr> </table></div> -<a name="xpath_query::evaluate_string_buffer"></a><p> - Note that <code class="computeroutput"><span class="identifier">evaluate_string</span></code> - function returns the STL string; as such, it's not available in <a class="link" href="install.html#PUGIXML_NO_STL">PUGIXML_NO_STL</a> +<p> + <a name="xpath_query::evaluate_string_buffer"></a>Note that <code class="computeroutput"><span class="identifier">evaluate_string</span></code> function returns the STL + string; as such, it's not available in <a class="link" href="install.html#PUGIXML_NO_STL">PUGIXML_NO_STL</a> mode and also usually allocates memory. There is another string evaluation function: </p> @@ -357,7 +367,7 @@ is not 0, the resulting buffer is always zero-terminated. You can use this function as follows: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> First call the function with <code class="computeroutput"><span class="identifier">buffer</span> <span class="special">=</span> <span class="number">0</span></code> @@ -376,21 +386,20 @@ This is an example of using query objects (<a href="../samples/xpath_query.cpp" target="_top">samples/xpath_query.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// Select nodes via compiled query -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_remote_tools</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote='true']"</span><span class="special">);</span> +<pre class="programlisting"><span class="comment">// Select nodes via compiled query</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_remote_tools</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote='true']"</span><span class="special">);</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools</span> <span class="special">=</span> <span class="identifier">query_remote_tools</span><span class="special">.</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="identifier">doc</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Remote tool: "</span><span class="special">;</span> <span class="identifier">tools</span><span class="special">[</span><span class="number">2</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> -<span class="comment">// Evaluate numbers via compiled query -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_timeouts</span><span class="special">(</span><span class="string">"sum(//Tool/@Timeout)"</span><span class="special">);</span> +<span class="comment">// Evaluate numbers via compiled query</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_timeouts</span><span class="special">(</span><span class="string">"sum(//Tool/@Timeout)"</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">query_timeouts</span><span class="special">.</span><span class="identifier">evaluate_number</span><span class="special">(</span><span class="identifier">doc</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> -<span class="comment">// Evaluate strings via compiled query for different context nodes -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_name_valid</span><span class="special">(</span><span class="string">"string-length(substring-before(@Filename, '_')) > 0 and @OutputFileMasks"</span><span class="special">);</span> +<span class="comment">// Evaluate strings via compiled query for different context nodes</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_name_valid</span><span class="special">(</span><span class="string">"string-length(substring-before(@Filename, '_')) > 0 and @OutputFileMasks"</span><span class="special">);</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_name</span><span class="special">(</span><span class="string">"concat(substring-before(@Filename, '_'), ' produces ', @OutputFileMasks)"</span><span class="special">);</span> <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_element_by_path</span><span class="special">(</span><span class="string">"Profile/Tools/Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span> @@ -405,7 +414,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.xpath.variables"></a><a class="link" href="xpath.html#manual.xpath.variables" title="Using variables"> Using variables</a> +<a name="manual.xpath.variables"></a><a class="link" href="xpath.html#manual.xpath.variables" title="Using variables">Using variables</a> </h3></div></div></div> <p> XPath queries may contain references to variables; this is useful if you @@ -438,12 +447,13 @@ that the lifetime of the set exceeds that of query object. </p></td></tr> </table></div> -<a name="xpath_variable_set"></a><p> - Variable sets correspond to <code class="computeroutput"><span class="identifier">xpath_variable_set</span></code> - type, which is essentially a variable container. +<p> + <a name="xpath_variable_set"></a>Variable sets correspond to <code class="computeroutput"><span class="identifier">xpath_variable_set</span></code> type, which is essentially + a variable container. </p> -<a name="xpath_variable_set::add"></a><p> - You can add new variables with the following function: +<p> + <a name="xpath_variable_set::add"></a>You can add new variables with the + following function: </p> <pre class="programlisting"><span class="identifier">xpath_variable</span><span class="special">*</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">add</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">xpath_value_type</span> <span class="identifier">type</span><span class="special">);</span> </pre> @@ -460,8 +470,9 @@ <code class="computeroutput"><span class="number">0</span></code> for numbers, <code class="computeroutput"><span class="keyword">false</span></code> for booleans, empty string for strings and empty set for node sets. </p> -<a name="xpath_variable_set::get"></a><p> - You can get the existing variables with the following functions: +<p> + <a name="xpath_variable_set::get"></a>You can get the existing variables + with the following functions: </p> <pre class="programlisting"><span class="identifier">xpath_variable</span><span class="special">*</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">get</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span> <span class="keyword">const</span> <span class="identifier">xpath_variable</span><span class="special">*</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">get</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> @@ -470,13 +481,14 @@ The functions return the variable handle, or null pointer if the variable with the specified name is not found. </p> -<a name="xpath_variable_set::set"></a><p> - Additionally, there are the helper functions for setting the variable value - by name; they try to add the variable with the corresponding type, if it - does not exist, and to set the value. If the variable with the same name - but with different type is already present, they return <code class="computeroutput"><span class="keyword">false</span></code>; - they also return <code class="computeroutput"><span class="keyword">false</span></code> on allocation - failure. Note that these functions do not perform any type conversions. +<p> + <a name="xpath_variable_set::set"></a>Additionally, there are the helper + functions for setting the variable value by name; they try to add the variable + with the corresponding type, if it does not exist, and to set the value. + If the variable with the same name but with different type is already present, + they return <code class="computeroutput"><span class="keyword">false</span></code>; they also + return <code class="computeroutput"><span class="keyword">false</span></code> on allocation failure. + Note that these functions do not perform any type conversions. </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">double</span> <span class="identifier">value</span><span class="special">);</span> @@ -487,14 +499,15 @@ The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return. </p> -<a name="xpath_variable"></a><p> - If setting variables by name is not efficient enough, or if you have to inspect - variable information or get variable values, you can use variable handles. - A variable corresponds to the <code class="computeroutput"><span class="identifier">xpath_variable</span></code> - type, and a variable handle is simply a pointer to <code class="computeroutput"><span class="identifier">xpath_variable</span></code>. +<p> + <a name="xpath_variable"></a>If setting variables by name is not efficient + enough, or if you have to inspect variable information or get variable values, + you can use variable handles. A variable corresponds to the <code class="computeroutput"><span class="identifier">xpath_variable</span></code> type, and a variable handle + is simply a pointer to <code class="computeroutput"><span class="identifier">xpath_variable</span></code>. </p> -<a name="xpath_variable::type"></a><a name="xpath_variable::name"></a><p> - In order to get variable information, you can use one of the following functions: +<p> + <a name="xpath_variable::type"></a><a name="xpath_variable::name"></a>In + order to get variable information, you can use one of the following functions: </p> <pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">xpath_value_type</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> @@ -503,8 +516,9 @@ Note that each variable has a distinct type which is specified upon variable creation and can not be changed later. </p> -<a name="xpath_variable::get_boolean"></a><a name="xpath_variable::get_number"></a><a name="xpath_variable::get_string"></a><a name="xpath_variable::get_node_set"></a><p> - In order to get variable value, you should use one of the following functions, +<p> + <a name="xpath_variable::get_boolean"></a><a name="xpath_variable::get_number"></a><a name="xpath_variable::get_string"></a><a name="xpath_variable::get_node_set"></a>In + order to get variable value, you should use one of the following functions, depending on the variable type: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">get_boolean</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> @@ -517,9 +531,9 @@ are performed; if the type mismatch occurs, a dummy value is returned (<code class="computeroutput"><span class="keyword">false</span></code> for booleans, <code class="computeroutput"><span class="identifier">NaN</span></code> for numbers, empty string for strings and empty set for node sets). </p> -<a name="xpath_variable::set"></a><p> - In order to set variable value, you should use one of the following functions, - depending on the variable type: +<p> + <a name="xpath_variable::set"></a>In order to set variable value, you should + use one of the following functions, depending on the variable type: </p> <pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span> <span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">value</span><span class="special">);</span> @@ -536,10 +550,9 @@ This is an example of using variables in XPath queries (<a href="../samples/xpath_variables.cpp" target="_top">samples/xpath_variables.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// Select nodes via compiled query -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_variable_set</span> <span class="identifier">vars</span><span class="special">;</span> +<pre class="programlisting"><span class="comment">// Select nodes via compiled query</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_variable_set</span> <span class="identifier">vars</span><span class="special">;</span> <span class="identifier">vars</span><span class="special">.</span><span class="identifier">add</span><span class="special">(</span><span class="string">"remote"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_type_boolean</span><span class="special">);</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_remote_tools</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">vars</span><span class="special">);</span> @@ -556,8 +569,8 @@ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Local tool: "</span><span class="special">;</span> <span class="identifier">tools_local</span><span class="special">[</span><span class="number">0</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> -<span class="comment">// You can pass the context directly to select_nodes/select_single_node -</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools_local_imm</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">vars</span><span class="special">);</span> +<span class="comment">// You can pass the context directly to select_nodes/select_single_node</span> +<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools_local_imm</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">vars</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Local tool imm: "</span><span class="special">;</span> <span class="identifier">tools_local_imm</span><span class="special">[</span><span class="number">0</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span> @@ -567,7 +580,7 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.xpath.errors"></a><a class="link" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a> +<a name="manual.xpath.errors"></a><a class="link" href="xpath.html#manual.xpath.errors" title="Error handling">Error handling</a> </h3></div></div></div> <p> There are two different mechanisms for error handling in XPath implementation; @@ -575,21 +588,23 @@ is controlled with <a class="link" href="install.html#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a> define). </p> -<a name="xpath_exception"></a><a name="xpath_exception::result"></a><a name="xpath_exception::what"></a><p> - By default, XPath functions throw <code class="computeroutput"><span class="identifier">xpath_exception</span></code> - object in case of errors; additionally, in the event any memory allocation - fails, an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code> exception is thrown. Also <code class="computeroutput"><span class="identifier">xpath_exception</span></code> is thrown if the query - is evaluated to a node set, but the return type is not node set. If the query - constructor succeeds (i.e. no exception is thrown), the query object is valid. - Otherwise you can get the error details via one of the following functions: +<p> + <a name="xpath_exception"></a><a name="xpath_exception::result"></a><a name="xpath_exception::what"></a>By default, XPath functions throw <code class="computeroutput"><span class="identifier">xpath_exception</span></code> object in case of errors; + additionally, in the event any memory allocation fails, an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code> + exception is thrown. Also <code class="computeroutput"><span class="identifier">xpath_exception</span></code> + is thrown if the query is evaluated to a node set, but the return type is + not node set. If the query constructor succeeds (i.e. no exception is thrown), + the query object is valid. Otherwise you can get the error details via one + of the following functions: </p> <pre class="programlisting"><span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">xpath_exception</span><span class="special">::</span><span class="identifier">what</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">throw</span><span class="special">();</span> <span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&</span> <span class="identifier">xpath_exception</span><span class="special">::</span><span class="identifier">result</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> -<a name="xpath_query::unspecified_bool_type"></a><a name="xpath_query::result"></a><p> - If exceptions are disabled, then in the event of parsing failure the query - is initialized to invalid state; you can test if the query object is valid - by using it in a boolean expression: <code class="computeroutput"><span class="keyword">if</span> +<p> + <a name="xpath_query::unspecified_bool_type"></a><a name="xpath_query::result"></a>If + exceptions are disabled, then in the event of parsing failure the query is + initialized to invalid state; you can test if the query object is valid by + using it in a boolean expression: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">query</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>. Additionally, you can get parsing result via the result() accessor: @@ -602,8 +617,9 @@ a query as a node set results in an empty node set if the return type is not node set. </p> -<a name="xpath_parse_result"></a><p> - The information about parsing result is returned via <code class="computeroutput"><span class="identifier">xpath_parse_result</span></code> +<p> + <a name="xpath_parse_result"></a>The information about parsing result is + returned via <code class="computeroutput"><span class="identifier">xpath_parse_result</span></code> object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream: </p> @@ -616,39 +632,39 @@ <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">description</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="special">};</span> </pre> -<a name="xpath_parse_result::error"></a><p> - Parsing result is represented as the error message; it is either a null pointer, - in case there is no error, or the error message in the form of ASCII zero-terminated - string. +<p> + <a name="xpath_parse_result::error"></a>Parsing result is represented as + the error message; it is either a null pointer, in case there is no error, + or the error message in the form of ASCII zero-terminated string. </p> -<a name="xpath_parse_result::description"></a><p> - <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> - member function can be used to get the error message; it never returns the - null pointer, so you can safely use <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> even if query parsing succeeded. Note that +<p> + <a name="xpath_parse_result::description"></a><code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> member function can be used to get the + error message; it never returns the null pointer, so you can safely use <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> - returns a <code class="computeroutput"><span class="keyword">char</span></code> string even in - <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>; you'll - have to call <a class="link" href="dom.html#as_wide">as_wide</a> to get the <code class="computeroutput"><span class="keyword">wchar_t</span></code> string. + even if query parsing succeeded. Note that <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> returns a <code class="computeroutput"><span class="keyword">char</span></code> + string even in <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>; + you'll have to call <a class="link" href="dom.html#as_wide">as_wide</a> to get the <code class="computeroutput"><span class="keyword">wchar_t</span></code> string. </p> -<a name="xpath_parse_result::offset"></a><p> - In addition to the error message, parsing result has an <code class="computeroutput"><span class="identifier">offset</span></code> +<p> + <a name="xpath_parse_result::offset"></a>In addition to the error message, + parsing result has an <code class="computeroutput"><span class="identifier">offset</span></code> member, which contains the offset of last successfully parsed character. This offset is in units of <a class="link" href="dom.html#char_t">pugi::char_t</a> (bytes for character mode, wide characters for wide character mode). </p> -<a name="xpath_parse_result::bool"></a><p> - Parsing result object can be implicitly converted to <code class="computeroutput"><span class="keyword">bool</span></code> - like this: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">result</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> +<p> + <a name="xpath_parse_result::bool"></a>Parsing result object can be implicitly + converted to <code class="computeroutput"><span class="keyword">bool</span></code> like this: + <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">result</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>. </p> <p> This is an example of XPath error handling (<a href="../samples/xpath_error.cpp" target="_top">samples/xpath_error.cpp</a>): </p> <p> - </p> -<pre class="programlisting"><span class="comment">// Exception is thrown for incorrect query syntax -</span><span class="keyword">try</span> +<pre class="programlisting"><span class="comment">// Exception is thrown for incorrect query syntax</span> +<span class="keyword">try</span> <span class="special">{</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"//nodes[#true()]"</span><span class="special">);</span> <span class="special">}</span> @@ -657,8 +673,8 @@ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Select failed: "</span> <span class="special"><<</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span> -<span class="comment">// Exception is thrown for incorrect query semantics -</span><span class="keyword">try</span> +<span class="comment">// Exception is thrown for incorrect query semantics</span> +<span class="keyword">try</span> <span class="special">{</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"(123)/next"</span><span class="special">);</span> <span class="special">}</span> @@ -667,8 +683,8 @@ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Select failed: "</span> <span class="special"><<</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span> -<span class="comment">// Exception is thrown for query with incorrect return type -</span><span class="keyword">try</span> +<span class="comment">// Exception is thrown for query with incorrect return type</span> +<span class="keyword">try</span> <span class="special">{</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"123"</span><span class="special">);</span> <span class="special">}</span> @@ -682,18 +698,18 @@ </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> -<a name="manual.xpath.w3c"></a><a class="link" href="xpath.html#manual.xpath.w3c" title="Conformance to W3C specification"> Conformance to W3C specification</a> +<a name="manual.xpath.w3c"></a><a class="link" href="xpath.html#manual.xpath.w3c" title="Conformance to W3C specification">Conformance to W3C specification</a> </h3></div></div></div> <p> Because of the differences in document object models, performance considerations and implementation complexity, pugixml does not provide a fully conformant XPath 1.0 implementation. This is the current list of incompatibilities: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> Consecutive text nodes sharing the same parent are not merged, i.e. in <code class="computeroutput"><span class="special"><</span><span class="identifier">node</span><span class="special">></span><span class="identifier">text1</span> - <span class="special"><![</span><span class="identifier">CDATA</span><span class="special">[</span><span class="identifier">data</span><span class="special">]]></span> <span class="identifier">text2</span><span class="special"></</span><span class="identifier">node</span><span class="special">></span></code> node should have one text node children, + <span class="special"><![</span><span class="identifier">CDATA</span><span class="special">[</span><span class="identifier">data</span><span class="special">]]></span> <span class="identifier">text2</span><span class="special"></</span><span class="identifier">node</span><span class="special">></span></code> node should have one text node child, but instead has three. </li> <li class="listitem"> @@ -721,7 +737,7 @@ </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> -<td align="right"><div class="copyright-footer">Copyright © 2012 Arseny Kapoulkine<p> +<td align="right"><div class="copyright-footer">Copyright © 2014 Arseny Kapoulkine<p> Distributed under the MIT License </p> </div></td> @@ -729,7 +745,7 @@ <hr> <table width="100%"><tr> <td> -<a href="http://pugixml.org/">pugixml 1.2</a> manual | +<a href="http://pugixml.org/">pugixml 1.4</a> manual | <a href="../manual.html">Overview</a> | <a href="install.html">Installation</a> | Document: |