summaryrefslogtreecommitdiff
path: root/docs/manual.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/manual.adoc')
-rw-r--r--docs/manual.adoc1227
1 files changed, 601 insertions, 626 deletions
diff --git a/docs/manual.adoc b/docs/manual.adoc
index af53aa4..9820a6f 100644
--- a/docs/manual.adoc
+++ b/docs/manual.adoc
@@ -182,7 +182,7 @@ In addition to adding pugixml project to your workspace, you'll have to make sur
[[install.building.shared]]
==== Building pugixml as a standalone shared library
-It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining [link PUGIXML_API] macro, i.e. via `pugiconfig.hpp`:
+It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining <<PUGIXML_API,PUGIXML_API>> macro, i.e. via `pugiconfig.hpp`:
[source]
----
@@ -195,13 +195,13 @@ It's possible to compile pugixml as a standalone shared library. The process is
CAUTION: If you're using STL-related functions, you should use the shared runtime library to ensure that a single heap is used for STL allocations in your application and in pugixml; in MSVC, this means selecting the 'Multithreaded DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (/MD or /MDd linker switch). You should also make sure that your runtime library choice is consistent between different projects.
-[#PUGIXML_HEADER_ONLY]
[[install.building.header]]
==== Using pugixml in header-only mode
+[[PUGIXML_HEADER_ONLY]]
It's possible to use pugixml in header-only mode. This means that all source code for pugixml will be included in every translation unit that includes `pugixml.hpp`. This is how most of Boost and STL libraries work.
-Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using [link PUGIXML_NO_XPATH] define to improve compilation time.
+Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using <<PUGIXML_NO_XPATH,PUGIXML_NO_XPATH>> define to improve compilation time.
Enabling header-only mode is a two-step process:
@@ -232,21 +232,21 @@ can include pugixml.cpp in your project (see <<install.building.embed>>), and co
pugixml uses several defines to control the compilation process. There are two ways to define them: either put the needed definitions to `pugiconfig.hpp` (it has some examples that are commented out) or provide them via compiler command-line. Consistency is important: the definitions should match in all source files that include `pugixml.hpp` (including pugixml sources) throughout the application. Adding defines to `pugiconfig.hpp` lets you guarantee this, unless your macro definition is wrapped in preprocessor `#if`/`#ifdef` directive and this directive is not consistent. `pugiconfig.hpp` will never contain anything but comments, which means that when upgrading to a new version, you can safely leave your modified version intact.
-[anchor PUGIXML_WCHAR_MODE] define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use `char` as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on `wchar_t` size, most functions use `wchar_t` as character type). See <<dom.unicode>> for more details.
+[[PUGIXML_WCHAR_MODE]]`PUGIXML_WCHAR_MODE` define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use `char` as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on `wchar_t` size, most functions use `wchar_t` as character type). See <<dom.unicode>> for more details.
-[anchor PUGIXML_NO_XPATH] define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space.
+[[PUGIXML_NO_XPATH]]`PUGIXML_NO_XPATH` define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space.
-[anchor PUGIXML_NO_STL] define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation.
+[[PUGIXML_NO_STL]]`PUGIXML_NO_STL` define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation.
-[anchor PUGIXML_NO_EXCEPTIONS] define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities.
+[[PUGIXML_NO_EXCEPTIONS]]`PUGIXML_NO_EXCEPTIONS` define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities.
-[anchor PUGIXML_API], [anchor PUGIXML_CLASS] and [anchor PUGIXML_FUNCTION] defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of `PUGIXML_CLASS` or `PUGIXML_FUNCTION` definitions, `PUGIXML_API` definition is used instead. For example, to specify fixed calling convention, you can define `PUGIXML_FUNCTION` to i.e. `__fastcall`. Another example is DLL import/export attributes in MSVC (see <<install.building.shared>>).
+[[PUGIXML_API]]`PUGIXML_API`, [[PUGIXML_CLASS]]`PUGIXML_CLASS` and [[PUGIXML_FUNCTION]]`PUGIXML_FUNCTION` defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of `PUGIXML_CLASS` or `PUGIXML_FUNCTION` definitions, `PUGIXML_API` definition is used instead. For example, to specify fixed calling convention, you can define `PUGIXML_FUNCTION` to i.e. `__fastcall`. Another example is DLL import/export attributes in MSVC (see <<install.building.shared>>).
NOTE: In that example `PUGIXML_API` is inconsistent between several source files; this is an exception to the consistency rule.
-[anchor PUGIXML_MEMORY_PAGE_SIZE], [anchor PUGIXML_MEMORY_OUTPUT_STACK] and [anchor PUGIXML_MEMORY_XPATH_PAGE_SIZE] can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <<dom.memory.tuning>>.
+[[PUGIXML_MEMORY_PAGE_SIZE]]`PUGIXML_MEMORY_PAGE_SIZE`, [[PUGIXML_MEMORY_OUTPUT_STACK]]`PUGIXML_MEMORY_OUTPUT_STACK` and [[PUGIXML_MEMORY_XPATH_PAGE_SIZE]]`PUGIXML_MEMORY_XPATH_PAGE_SIZE` can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <<dom.memory.tuning>>.
-[anchor PUGIXML_HAS_LONG_LONG] define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C{plus}{plus}-11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually.
+[[PUGIXML_HAS_LONG_LONG]]`PUGIXML_HAS_LONG_LONG` define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C{plus}{plus}-11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually.
[[install.portability]]
=== Portability
@@ -279,14 +279,14 @@ pugixml stores XML data in DOM-like way: the entire XML document (both document
[[dom.tree]]
=== Tree structure
-The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C{plus}{plus} type [link xml_document]. Document has one or more child nodes, which correspond to C{plus}{plus} type [link xml_node]. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C{plus}{plus} type [link xml_attribute], and some additional data (i.e. name).
+The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C{plus}{plus} type <<xml_document,xml_document>>. Document has one or more child nodes, which correspond to C{plus}{plus} type <<xml_node,xml_node>>. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C{plus}{plus} type <<xml_attribute,xml_attribute>>, and some additional data (i.e. name).
-[#xml_node_type]
+[[xml_node_type]]
The tree nodes can be of one of the following types (which together form the enumeration `xml_node_type`):
-* Document node ([anchor node_document]) - this is the root of the tree, which consists of several child nodes. This node corresponds to [link xml_document] class; note that [link xml_document] is a sub-class of [link xml_node], so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation.
+* Document node ([[node_document]]`node_document`) - this is the root of the tree, which consists of several child nodes. This node corresponds to <<xml_document,xml_document>> class; note that <<xml_document,xml_document>> is a sub-class of <<xml_node,xml_node>>, so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation.
-* Element/tag node ([anchor node_element]) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:
+* Element/tag node ([[node_element]]`node_element`) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:
+
----
<node attr="value"><child/></node>
@@ -294,7 +294,7 @@ The tree nodes can be of one of the following types (which together form the enu
+
There are two element nodes here: one has name `"node"`, single attribute `"attr"` and single child `"child"`, another has name `"child"` and does not have any attributes or child nodes.
-* Plain character data nodes ([anchor node_pcdata]) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:
+* Plain character data nodes ([[node_pcdata]]`node_pcdata`) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:
+
----
<node> text1 <child/> text2 </node>
@@ -302,7 +302,7 @@ There are two element nodes here: one has name `"node"`, single attribute `"attr
+
Here `"node"` element has three children, two of which are PCDATA nodes with values `" text1 "` and `" text2 "`.
-* Character data nodes ([anchor node_cdata]) 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 looks like this with CDATA:
+* Character data nodes ([[node_cdata]]`node_cdata`) 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 looks like this with CDATA:
+
----
<node> <![CDATA[[text1]]> <child/> <![CDATA[[text2]]> </node>
@@ -310,37 +310,37 @@ Here `"node"` element has three children, two of which are PCDATA nodes with val
+
CDATA nodes make it easy to include non-escaped <, & and > characters in plain text. CDATA value can not contain the character sequence ]]>, since it is used to determine the end of node contents.
-* Comment nodes ([anchor node_comment]) 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 is as follows:
+* Comment nodes ([[node_comment]]`node_comment`) 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 is as follows:
+
----
<!-- comment text -->
----
+
-Here the comment node has value `"comment text"`. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_comments] flag.
+Here the comment node has value `"comment text"`. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_comments,parse_comments>> flag.
-* Processing instruction node ([anchor node_pi]) 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 of a PI node is as follows:
+* Processing instruction node ([[node_pi]]`node_pi`) 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 of a PI node is as follows:
+
----
<?name value?>
----
+
-Here the name (also called PI target) is `"name"`, and the value is `"value"`. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_pi] flag.
+Here the name (also called PI target) is `"name"`, and the value is `"value"`. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_pi,parse_pi>> flag.
-* Declaration node ([anchor node_declaration]) represents document declarations in XML. Declaration nodes have a name (`"xml"`) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:
+* Declaration node ([[node_declaration]]`node_declaration`) represents document declarations in XML. Declaration nodes have a name (`"xml"`) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:
+
----
<?xml version="1.0"?>
----
+
-Here the node has name `"xml"` and a single attribute with name `"version"` and value `"1.0"`. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_declaration] flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with [link format_no_declaration] flag.
+Here the node has name `"xml"` and a single attribute with name `"version"` and value `"1.0"`. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_declaration,parse_declaration>> flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with <<format_no_declaration,format_no_declaration>> flag.
-* Document type declaration node ([anchor node_doctype]) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like `<!ENTITY>`. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:
+* Document type declaration node ([[node_doctype]]`node_doctype`) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like `<!ENTITY>`. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:
+
----
<!DOCTYPE greeting [ <!ELEMENT greeting (#PCDATA)> ]>
----
+
-Here the node has value `"greeting [ <!ELEMENT greeting (#PCDATA)> ]"`. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_doctype] flag.
+Here the node has value `"greeting [ <!ELEMENT greeting (#PCDATA)> ]"`. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_doctype,parse_doctype>> flag.
Finally, here is a complete example of XML document and the corresponding tree representation (link:samples/tree.xml[]):
@@ -373,43 +373,33 @@ NOTE: All pugixml classes and functions are located in the `pugi` namespace; you
Despite the fact that there are several node types, there are only three C{plus}{plus} classes representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. The classes are described below.
-[#xml_document]
-[#xml_document::document_element]
+[[xml_document]][[xml_document::document_element]]
`xml_document` is the owner of the entire document structure; it is a non-copyable class. The interface of `xml_document` consists of loading functions (see <<loading>>), saving functions (see <<saving>>) and the entire interface of `xml_node`, which allows for document inspection and/or modification. Note that while `xml_document` is a sub-class of `xml_node`, `xml_node` is not a polymorphic type; the inheritance is present only to simplify usage. Alternatively you can use the `document_element` function to get the element node that's the immediate child of the document.
-[#xml_document::ctor]
-[#xml_document::dtor]
-[#xml_document::reset]
+[[xml_document::ctor]][[xml_document::dtor]][[xml_document::reset]]
Default constructor of `xml_document` 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 all occupied memory, which puts existing node/attribute handles for this document to invalid state. If you want to destroy the previous tree, you can use the `xml_document::reset` function; it destroys the tree and replaces it with either an empty one or a copy of the specified document. Destructor of `xml_document` also destroys the tree, thus the lifetime of the document object should exceed the lifetimes of any node/attribute handles that point to the tree.
CAUTION: While technically node/attribute handles can be alive when the tree they're referring to is destroyed, calling any member function for these handles results in undefined behavior. Thus it is recommended to make sure that the document is destroyed only after all references to its nodes/attributes are destroyed.
-[#xml_node]
-[#xml_node::type]
-`xml_node` 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 [link xml_node_type node type] can be queried via the `xml_node::type()` method. Note that `xml_node` is only a handle to the actual node, not the node itself - you can have several `xml_node` handles pointing to the same underlying object. Destroying `xml_node` handle does not destroy the node and does not remove it from the tree. The size of `xml_node` is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return `xml_node` objects by value without additional overhead.
+[[xml_node]][[xml_node::type]]
+`xml_node` 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 <<xml_node_type,node type>> can be queried via the `xml_node::type()` method. Note that `xml_node` is only a handle to the actual node, not the node itself - you can have several `xml_node` handles pointing to the same underlying object. Destroying `xml_node` handle does not destroy the node and does not remove it from the tree. The size of `xml_node` is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return `xml_node` objects by value without additional overhead.
-[#node_null]
+[[node_null]]
There is a special value of `xml_node` type, known as null node or empty node (such nodes have type `node_null`). 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 return empty nodes/attributes or empty strings as their result (see documentation for specific functions for more detailed information). This is useful for chaining calls; i.e. you can get the grandparent of a node like so: `node.parent().parent()`; if a node is a null node or it does not have a parent, the first `parent()` call returns null node; the second `parent()` call then also returns null node, which makes error handling easier.
-[#xml_attribute]
+[[xml_attribute]]
`xml_attribute` is the handle to an XML attribute; it has the same semantics as `xml_node`, i.e. there can be several `xml_attribute` handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.
-[#xml_attribute::ctor]
-[#xml_node::ctor]
+[[xml_attribute::ctor]][[xml_node::ctor]]
Both `xml_node` and `xml_attribute` have the default constructor which initializes them to null objects.
-[#xml_attribute::comparison]
-[#xml_node::comparison]
+[[xml_attribute::comparison]][[xml_node::comparison]]
`xml_node` and `xml_attribute` 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).
-[#xml_attribute::hash_value]
-[#xml_node::hash_value]
+[[xml_attribute::hash_value]][[xml_node::hash_value]]
If you want to use `xml_node` or `xml_attribute` objects as keys in hash-based associative containers, you can use the `hash_value` 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.
-[#xml_attribute::unspecified_bool_type]
-[#xml_node::unspecified_bool_type]
-[#xml_attribute::empty]
-[#xml_node::empty]
+[[xml_attribute::unspecified_bool_type]][[xml_node::unspecified_bool_type]][[xml_attribute::empty]][[xml_node::empty]]
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: `if (node) { ... }` or `if (!node) { ... } else { ... }`. Alternatively you can check if a given `xml_node`/`xml_attribute` handle is null by calling the following methods:
[source]
@@ -418,12 +408,12 @@ bool xml_attribute::empty() const;
bool xml_node::empty() const;
----
-Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling [link xml_node::remove_child]) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.
+Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling <<xml_node::remove_child,xml_node::remove_child>>) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.
[[dom.unicode]]
=== Unicode interface
-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 [link PUGIXML_WCHAR_MODE] define; you can set it via `pugiconfig.hpp` or via preprocessor options, as discussed in <<install.building.config>>. 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 is determined based on the size of `wchar_t` type.
+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 <<PUGIXML_WCHAR_MODE,PUGIXML_WCHAR_MODE>> define; you can set it via `pugiconfig.hpp` or via preprocessor options, as discussed in <<install.building.config>>. 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 is determined based on the size of `wchar_t` type.
NOTE: If the size of `wchar_t` is 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some characters are represented as two code points.
@@ -443,14 +433,12 @@ const wchar_t* xml_node::name() const;
bool xml_node::set_name(const wchar_t* value);
----
-[#char_t]
-[#string_t]
+[[char_t]][[string_t]]
There is a special type, `pugi::char_t`, 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 `pugi::string_t`, which is defined as the STL string of the character type; it corresponds to `std::string` in char mode and to `std::wstring` in wchar_t mode.
In addition to the interface, the internal implementation changes to store XML data as `pugi::char_t`; this means that these two modes have different memory usage characteristics. The conversion to `pugi::char_t` upon document loading and from `pugi::char_t` upon document saving happen automatically, which also carries minor performance penalty. The general advice however is to select the character mode based on usage scenario, i.e. if UTF-8 is inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice.
-[#as_utf8]
-[#as_wide]
+[[as_utf8]][[as_wide]]
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:
[source]
@@ -469,7 +457,7 @@ std::wstring as_wide(const std::string& str);
[NOTE]
====
-Most examples in this documentation assume char interface and therefore will not compile with [link PUGIXML_WCHAR_MODE]. This is done to simplify the documentation; usually the only changes you'll have to make is to pass `wchar_t` string literals, i.e. instead of
+Most examples in this documentation assume char interface and therefore will not compile with <<PUGIXML_WCHAR_MODE,PUGIXML_WCHAR_MODE>>. This is done to simplify the documentation; usually the only changes you'll have to make is to pass `wchar_t` string literals, i.e. instead of
`xml_node node = doc.child("bookstore").find_child_by_attribute("book", "id", "12345");`
@@ -489,16 +477,16 @@ Almost all functions in pugixml have the following thread-safety guarantees:
Concurrent modification and traversing of a single tree requires synchronization, for example via reader-writer lock. Modification includes altering document structure and altering individual node/attribute data, i.e. changing names/values.
-The only exception is [link set_memory_management_functions]; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see <<dom.memory.custom>>.
+The only exception is <<set_memory_management_functions,set_memory_management_functions>>; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see <<dom.memory.custom>>.
[[dom.exception]]
=== Exception guarantees
With the exception of XPath, pugixml itself does not throw any exceptions. Additionally, most pugixml functions have a no-throw exception guarantee.
-This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. [link xml_node::traverse] or [link xml_node::find_node]) do not provide any exception guarantees beyond the ones provided by the callback.
+This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. <<xml_node::traverse,xml_node::traverse>> or <<xml_node::find_node,xml_node::find_node>>) do not provide any exception guarantees beyond the ones provided by the callback.
-If exception handling is not disabled with [link PUGIXML_NO_EXCEPTIONS] define, XPath functions may throw [link xpath_exception] on parsing errors; also, XPath functions may throw `std::bad_alloc` in low memory conditions. Still, XPath functions provide strong exception guarantee.
+If exception handling is not disabled with <<PUGIXML_NO_EXCEPTIONS,PUGIXML_NO_EXCEPTIONS>> define, XPath functions may throw <<xpath_exception,xpath_exception>> on parsing errors; also, XPath functions may throw `std::bad_alloc` in low memory conditions. Still, XPath functions provide strong exception guarantee.
[[dom.memory]]
=== Memory management
@@ -508,8 +496,7 @@ pugixml requests the memory needed for document storage in big chunks, and alloc
[[dom.memory.custom]]
==== Custom memory allocation/deallocation functions
-[#allocation_function]
-[#deallocation_function]
+[[allocation_function]][[deallocation_function]]
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:
[source]
@@ -518,9 +505,7 @@ typedef void* (*allocation_function)(size_t size);
typedef void (*deallocation_function)(void* ptr);
----
-[#set_memory_management_functions]
-[#get_memory_allocation_function]
-[#get_memory_deallocation_function]
+[[set_memory_management_functions]][[get_memory_allocation_function]][[get_memory_deallocation_function]]
You can use the following accessor functions to change or get current memory management functions:
[source]
@@ -563,9 +548,9 @@ These constants can be tuned via configuration defines, as discussed in <<instal
[[dom.memory.internals]]
==== Document memory management internals
-Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the [link xml_document] object.
+Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the <<xml_document,xml_document>> object.
-When the document is loaded from file/buffer, unless an inplace loading function is used (see <<loading.memory>>), 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 [link xml_document] object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns.
+When the document is loaded from file/buffer, unless an inplace loading function is used (see <<loading.memory>>), 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 <<xml_document,xml_document>> object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns.
All additional memory, such as memory for document structure (node/attribute objects) and memory for node/attribute names/values is allocated in pages on the order of 32 kilobytes; actual objects are allocated inside the pages using a memory management scheme optimized for fast allocation/deallocation of many small objects. Because of the scheme specifics, the pages are only destroyed if all objects inside them are destroyed; also, generally destroying an object does not mean that subsequent object creation will reuse the same memory. This means that it is possible to devise a usage scheme which will lead to higher memory usage than expected; one example is adding a lot of nodes, and them removing all even numbered ones; not a single page is reclaimed in the process. However this is an example specifically crafted to produce unsatisfying behavior; in all practical usage scenarios the memory consumption is less than that of a general-purpose allocator because allocation meta-data is very small in size.
@@ -579,8 +564,7 @@ XML data is always converted to internal character format (see <<dom.unicode>>)
[[loading.file]]
=== Loading document from file
-[#xml_document::load_file]
-[#xml_document::load_file_wide]
+[[xml_document::load_file]][[xml_document::load_file_wide]]
The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:
[source]
@@ -593,7 +577,7 @@ These functions accept the file path as its first argument, and also two optiona
File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses 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.
-`load_file` destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an [link xml_parse_result] 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 <<loading.errors>> for error handling details.
+`load_file` destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an <<xml_parse_result,xml_parse_result>> 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 <<loading.errors>> for error handling details.
This is an example of loading XML document from file (link:samples/load_file.cpp[]):
@@ -605,9 +589,7 @@ include::samples/load_file.cpp[tags=code]
[[loading.memory]]
=== Loading document from memory
-[#xml_document::load_buffer]
-[#xml_document::load_buffer_inplace]
-[#xml_document::load_buffer_inplace_own]
+[[xml_document::load_buffer]][[xml_document::load_buffer_inplace]][[xml_document::load_buffer_inplace_own]]
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:
[source]
@@ -619,11 +601,11 @@ xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t si
All functions accept the buffer which is represented by a pointer to XML data, `contents`, and data size in bytes. Also there are two optional arguments, which specify parsing options (see <<loading.options>>) and input data encoding (see <<loading.encoding>>). The buffer does not have to be zero-terminated.
-`load_buffer` function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - `load_buffer_inplace` and `load_buffer_inplace_own` store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer's lifetime exceeds that of the tree if you're using inplace functions. In addition to that, `load_buffer_inplace` does not assume ownership of the buffer, so you'll have to destroy it yourself; `load_buffer_inplace_own` assumes ownership of the buffer and destroys it once it is not needed. This means that if you're using `load_buffer_inplace_own`, you have to allocate memory with pugixml allocation function (you can get it via [link get_memory_allocation_function]).
+`load_buffer` function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - `load_buffer_inplace` and `load_buffer_inplace_own` store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer's lifetime exceeds that of the tree if you're using inplace functions. In addition to that, `load_buffer_inplace` does not assume ownership of the buffer, so you'll have to destroy it yourself; `load_buffer_inplace_own` assumes ownership of the buffer and destroys it once it is not needed. This means that if you're using `load_buffer_inplace_own`, you have to allocate memory with pugixml allocation function (you can get it via <<get_memory_allocation_function,get_memory_allocation_function>>).
The best way from the performance/memory point of view is to load document using `load_buffer_inplace_own`; this function has maximum control of the buffer with XML data so it is able to avoid redundant copies and reduce peak memory usage while parsing. This is the recommended function if you have to load the document from memory and performance is critical.
-[#xml_document::load_string]
+[[xml_document::load_string]]
There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:
[source]
@@ -662,7 +644,7 @@ include::samples/load_memory.cpp[tags=load_string]
[[loading.stream]]
=== Loading document from C{plus}{plus} IOstreams
-[#xml_document::load_stream]
+[[xml_document::load_stream]]
To enhance interoperability, pugixml provides functions for loading document from any object which implements C{plus}{plus} `std::istream` interface. This allows you to load documents from any standard C{plus}{plus} 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:
[source]
@@ -673,7 +655,7 @@ xml_parse_result xml_document::load(std::wistream& stream, unsigned int options
`load` with `std::istream` argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling `xml_document::load` on an opened `std::ifstream` object is equivalent to calling `xml_document::load_file`.
-`load` with `std::wstream` argument treats the stream contents as a wide character stream (encoding is always [link encoding_wchar]). Because of this, using `load` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale.
+`load` with `std::wstream` argument treats the stream contents as a wide character stream (encoding is always <<encoding_wchar,encoding_wchar>>). Because of this, using `load` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale.
This is a simple example of loading XML document from file using streams (link:samples/load_stream.cpp[]); read the sample code for more complex examples involving wide streams and locales:
@@ -685,7 +667,7 @@ include::samples/load_stream.cpp[tags=code]
[[loading.errors]]
=== Handling parsing errors
-[#xml_parse_result]
+[[xml_parse_result]]
All document loading functions return the parsing result via `xml_parse_result` 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:
[source]
@@ -701,40 +683,39 @@ struct xml_parse_result
};
----
-[#xml_parse_status]
-[#xml_parse_result::status]
+[[xml_parse_status]][[xml_parse_result::status]]
Parsing status is represented as the `xml_parse_status` enumeration and can be one of the following:
-* [anchor status_ok] 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.
+* [[status_ok]]`status_ok` 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.
-* [anchor status_file_not_found] is only returned by `load_file` function and means that file could not be opened.
-* [anchor status_io_error] is returned by `load_file` function and by `load` functions with `std::istream`/`std::wstream` arguments; it means that some I/O error has occurred during reading the file/stream.
-* [anchor status_out_of_memory] means that there was not enough memory during some allocation; any allocation failure during parsing results in this error.
-* [anchor status_internal_error] means that something went horribly wrong; currently this error does not occur
+* [[status_file_not_found]]`status_file_not_found` is only returned by `load_file` function and means that file could not be opened.
+* [[status_io_error]]`status_io_error` is returned by `load_file` function and by `load` functions with `std::istream`/`std::wstream` arguments; it means that some I/O error has occurred during reading the file/stream.
+* [[status_out_of_memory]]`status_out_of_memory` means that there was not enough memory during some allocation; any allocation failure during parsing results in this error.
+* [[status_internal_error]]`status_internal_error` means that something went horribly wrong; currently this error does not occur
-* [anchor status_unrecognized_tag] means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as #.
-* [anchor status_bad_pi] means that parsing stopped due to incorrect document declaration/processing instruction
-* [anchor status_bad_comment], [anchor status_bad_cdata], [anchor status_bad_doctype] and [anchor status_bad_pcdata] mean that parsing stopped due to the invalid construct of the respective type
-* [anchor status_bad_start_element] means that parsing stopped because starting tag either had no closing `>` symbol or contained some incorrect symbol
-* [anchor status_bad_attribute] means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that `<node attr=1>` is incorrect in XML)
-* [anchor status_bad_end_element] means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and `>`)
-* [anchor status_end_element_mismatch] means that parsing stopped because the closing tag did not match the opening one (i.e. `<node></nedo>`) or because some tag was not closed at all
-* [anchor status_no_document_element] means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document
+* [[status_unrecognized_tag]]`status_unrecognized_tag` means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as #.
+* [[status_bad_pi]]`status_bad_pi` means that parsing stopped due to incorrect document declaration/processing instruction
+* [[status_bad_comment]]`status_bad_comment`, [[status_bad_cdata]]`status_bad_cdata`, [[status_bad_doctype]]`status_bad_doctype` and [[status_bad_pcdata]]`status_bad_pcdata` mean that parsing stopped due to the invalid construct of the respective type
+* [[status_bad_start_element]]`status_bad_start_element` means that parsing stopped because starting tag either had no closing `>` symbol or contained some incorrect symbol
+* [[status_bad_attribute]]`status_bad_attribute` means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that `<node attr=1>` is incorrect in XML)
+* [[status_bad_end_element]]`status_bad_end_element` means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and `>`)
+* [[status_end_element_mismatch]]`status_end_element_mismatch` means that parsing stopped because the closing tag did not match the opening one (i.e. `<node></nedo>`) or because some tag was not closed at all
+* [[status_no_document_element]]`status_no_document_element` means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document
-[#xml_parse_result::description]
-`description()` 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 `description()` function may change from version to version, so any complex status handling should be based on `status` value. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call [link as_wide] to get the `wchar_t` string.
+[[xml_parse_result::description]]
+`description()` 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 `description()` function may change from version to version, so any complex status handling should be based on `status` value. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call <<as_wide,as_wide>> to get the `wchar_t` string.
If parsing failed because the source data was not a valid XML, the resulting tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that was successfully parsed. Obviously, the last element may have an unexpected name/value; for example, if the attribute value does not end with the necessary quotation mark, like in `<node attr="value>some data</node>` example, the value of attribute `attr` will contain the string `value>some data</node>`.
-[#xml_parse_result::offset]
-In addition to the status code, parsing result has an `offset` member, which contains the offset of last successfully parsed character if parsing failed because of an error in source data; otherwise `offset` is 0. For parsing efficiency reasons, pugixml does not track the current line during parsing; this offset is in units of [link char_t pugi::char_t] (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).
+[[xml_parse_result::offset]]
+In addition to the status code, parsing result has an `offset` member, which contains the offset of last successfully parsed character if parsing failed because of an error in source data; otherwise `offset` is 0. For parsing efficiency reasons, pugixml does not track the current line during parsing; this offset is in units of <<char_t,pugi::char_t>> (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).
CAUTION: Offset is calculated in the XML buffer in native encoding; if encoding conversion is performed during parsing, offset can not be used to reliably track the error position.
-[#xml_parse_result::encoding]
+[[xml_parse_result::encoding]]
Parsing result also has an `encoding` 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 <<loading.encoding>> for more information.
-[#xml_parse_result::bool]
+[[xml_parse_result::bool]]
Parsing result object can be implicitly converted to `bool`; 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 `bool`: `if (doc.load_file("file.xml")) { ... } else { ... }`.
This is an example of handling loading errors (link:samples/load_error_handling.cpp[]):
@@ -753,45 +734,45 @@ NOTE: You should use the usual bitwise arithmetics to manipulate the bitmask: to
These flags control the resulting tree contents:
-* [anchor parse_declaration] determines if XML document declaration (node with type [link node_declaration]) 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 *off* by default.
+* [[parse_declaration]]`parse_declaration` determines if XML document declaration (node with type <<node_declaration,node_declaration>>) 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 *off* by default.
-* [anchor parse_doctype] determines if XML document type declaration (node with type [link node_doctype]) 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 *off* by default.
+* [[parse_doctype]]`parse_doctype` determines if XML document type declaration (node with type <<node_doctype,node_doctype>>) 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 *off* by default.
-* [anchor parse_pi] determines if processing instructions (nodes with type [link node_pi]) 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. Note that `<?xml ...?>` (document declaration) is not considered to be a PI. This flag is *off* by default.
+* [[parse_pi]]`parse_pi` determines if processing instructions (nodes with type <<node_pi,node_pi>>) 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. Note that `<?xml ...?>` (document declaration) is not considered to be a PI. This flag is *off* by default.
-* [anchor parse_comments] determines if comments (nodes with type [link node_comment]) 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 *off* by default.
+* [[parse_comments]]`parse_comments` determines if comments (nodes with type <<node_comment,node_comment>>) 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 *off* by default.
-* [anchor parse_cdata] determines if CDATA sections (nodes with type [link node_cdata]) 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 *on* by default.
+* [[parse_cdata]]`parse_cdata` determines if CDATA sections (nodes with type <<node_cdata,node_cdata>>) 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 *on* by default.
-* [anchor parse_trim_pcdata] 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 *off* by default.
+* [[parse_trim_pcdata]]`parse_trim_pcdata` 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 *off* by default.
-* [anchor parse_ws_pcdata] determines if PCDATA nodes (nodes with type [link node_pcdata]) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string `<node> <a/> </node>`, `<node>` element will have three children when `parse_ws_pcdata` is set (child with type [link node_pcdata] and value `" "`, child with type [link node_element] and name `"a"`, and another child with type [link node_pcdata] and value `" "`), and only one child when `parse_ws_pcdata` is not set. This flag is *off* by default.
+* [[parse_ws_pcdata]]`parse_ws_pcdata` determines if PCDATA nodes (nodes with type <<node_pcdata,node_pcdata>>) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string `<node> <a/> </node>`, `<node>` element will have three children when `parse_ws_pcdata` is set (child with type <<node_pcdata,node_pcdata>> and value `" "`, child with type <<node_element,node_element>> and name `"a"`, and another child with type <<node_pcdata,node_pcdata>> and value `" "`), and only one child when `parse_ws_pcdata` is not set. This flag is *off* by default.
-* [anchor parse_ws_pcdata_single] determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. `<node> </node>`, but is not interested in whitespace markup elsewhere. It is possible to use [link parse_ws_pcdata] flag in this case, but it results in excessive allocations and complicates document processing in some cases; this flag is intended to avoid that. As an example, after parsing XML string `<node> <a> </a> </node>` with `parse_ws_pcdata_single` flag set, `<node>` element will have one child `<a>`, and `<a>` element will have one child with type [link node_pcdata] and value `" "`. This flag has no effect if [link parse_ws_pcdata] is enabled. This flag is *off* by default.
+* [[parse_ws_pcdata_single]]`parse_ws_pcdata_single` determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. `<node> </node>`, but is not interested in whitespace markup elsewhere. It is possible to use <<parse_ws_pcdata,parse_ws_pcdata>> flag in this case, but it results in excessive allocations and complicates document processing in some cases; this flag is intended to avoid that. As an example, after parsing XML string `<node> <a> </a> </node>` with `parse_ws_pcdata_single` flag set, `<node>` element will have one child `<a>`, and `<a>` element will have one child with type <<node_pcdata,node_pcdata>> and value `" "`. This flag has no effect if <<parse_ws_pcdata,parse_ws_pcdata>> is enabled. This flag is *off* by default.
-* [anchor parse_fragment] 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 *off* by default.
+* [[parse_fragment]]`parse_fragment` 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 *off* by default.
-CAUTION: Using in-place parsing ([link xml_document::load_buffer_inplace load_buffer_inplace]) with `parse_fragment` 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 `load_buffer_inplace` - i.e. `doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment)`.
+CAUTION: Using in-place parsing (<<xml_document::load_buffer_inplace,load_buffer_inplace>>) with `parse_fragment` 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 `load_buffer_inplace` - i.e. `doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment)`.
These flags control the transformation of tree element contents:
-* [anchor parse_escapes] determines if character and entity references are to be expanded during the parsing process. Character references have the form `&#...;` or `&#x...;` (`...` is Unicode numeric representation of character in either decimal (`&#...;`) or hexadecimal (`&#x...;`) form), entity references are `&lt;`, `&gt;`, `&amp;`, `&apos;` and `&quot;` (note that as pugixml does not handle DTD, the only allowed entities are predefined 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 *on* by default.
+* [[parse_escapes]]`parse_escapes` determines if character and entity references are to be expanded during the parsing process. Character references have the form `&#...;` or `&#x...;` (`...` is Unicode numeric representation of character in either decimal (`&#...;`) or hexadecimal (`&#x...;`) form), entity references are `&lt;`, `&gt;`, `&amp;`, `&apos;` and `&quot;` (note that as pugixml does not handle DTD, the only allowed entities are predefined 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 *on* by default.
-* [anchor parse_eol] determines if EOL handling (that is, replacing sequences `0x0d 0x0a` by a single `0x0a` character, and replacing all standalone `0x0d` characters by `0x0a`) is to be performed on input data (that is, comments contents, PCDATA/CDATA contents and attribute values). This flag is *on* by default.
+* [[parse_eol]]`parse_eol` determines if EOL handling (that is, replacing sequences `0x0d 0x0a` by a single `0x0a` character, and replacing all standalone `0x0d` characters by `0x0a`) is to be performed on input data (that is, comments contents, PCDATA/CDATA contents and attribute values). This flag is *on* by default.
-* [anchor parse_wconv_attribute] determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (`' '`). New line characters are always treated as if [link parse_eol] is set, i.e. `\r\n` is converted to a single space. This flag is *on* by default.
+* [[parse_wconv_attribute]]`parse_wconv_attribute` determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (`' '`). New line characters are always treated as if <<parse_eol,parse_eol>> is set, i.e. `\r\n` is converted to a single space. This flag is *on* by default.
-* [anchor parse_wnorm_attribute] determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if [link parse_wconv_attribute] was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. [link parse_wconv_attribute] has no effect if this flag is on. This flag is *off* by default.
+* [[parse_wnorm_attribute]]`parse_wnorm_attribute` determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if <<parse_wconv_attribute,parse_wconv_attribute>> was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. <<parse_wconv_attribute,parse_wconv_attribute>> has no effect if this flag is on. This flag is *off* by default.
-NOTE: `parse_wconv_attribute` option performs transformations that are required by W3C specification for attributes that are declared as CDATA; [link parse_wnorm_attribute] performs transformations required for NMTOKENS attributes. In the absence of document type declaration all attributes should behave as if they are declared as CDATA, thus [link parse_wconv_attribute] is the default option.
+NOTE: `parse_wconv_attribute` option performs transformations that are required by W3C specification for attributes that are declared as CDATA; <<parse_wnorm_attribute,parse_wnorm_attribute>> performs transformations required for NMTOKENS attributes. In the absence of document type declaration all attributes should behave as if they are declared as CDATA, thus <<parse_wconv_attribute,parse_wconv_attribute>> is the default option.
Additionally there are three predefined option masks:
-* [anchor parse_minimal] has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice [link parse_default] is usually equally fast.
+* [[parse_minimal]]`parse_minimal` has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice <<parse_default,parse_default>> is usually equally fast.
-* [anchor parse_default] is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons.
+* [[parse_default]]`parse_default` is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons.
-* [anchor parse_full] is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode.
+* [[parse_full]]`parse_full` is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode.
This is an example of using different parsing options (link:samples/load_options.cpp[]):
@@ -803,10 +784,10 @@ include::samples/load_options.cpp[tags=code]
[[loading.encodings]]
=== Encodings
-[#xml_encoding]
+[[xml_encoding]]
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 `encoding`. This is a value of enumeration type `xml_encoding`, that can have the following values:
-* [anchor encoding_auto] 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 http://www.w3.org/TR/REC-xml/#sec-guessing-no-ext-info[Appendix F.1 of XML recommendation]; it tries to match the first few bytes of input data with the following patterns in strict order:
+* [[encoding_auto]]`encoding_auto` 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 http://www.w3.org/TR/REC-xml/#sec-guessing-no-ext-info[Appendix F.1 of XML recommendation]; it tries to match the first few bytes of input data with the following patterns in strict order:
** 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;
** If first two bytes match UTF-16 BOM, encoding is assumed to be UTF-16 with the endianness equal to that of BOM;
** If first three bytes match UTF-8 BOM, encoding is assumed to be UTF-8;
@@ -815,15 +796,15 @@ pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little en
** If first two bytes match UTF-16 representation of `<`, encoding is assumed to be UTF-16 with the corresponding endianness (this guess may yield incorrect result, but it's better than UTF-8);
** Otherwise encoding is assumed to be UTF-8.
-* [anchor encoding_utf8] corresponds to UTF-8 encoding as defined in the Unicode standard; UTF-8 sequences with length equal to 5 or 6 are not standard and are rejected.
-* [anchor encoding_utf16_le] corresponds to little-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
-* [anchor encoding_utf16_be] corresponds to big-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
-* [anchor encoding_utf16] corresponds to UTF-16 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
-* [anchor encoding_utf32_le] corresponds to little-endian UTF-32 encoding as defined in the Unicode standard.
-* [anchor encoding_utf32_be] corresponds to big-endian UTF-32 encoding as defined in the Unicode standard.
-* [anchor encoding_utf32] corresponds to UTF-32 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
-* [anchor encoding_wchar] corresponds to the encoding of `wchar_t` type; it has the same meaning as either `encoding_utf16` or `encoding_utf32`, depending on `wchar_t` size.
-* [anchor encoding_latin1] corresponds to ISO-8859-1 encoding (also known as Latin-1).
+* [[encoding_utf8]]`encoding_utf8` corresponds to UTF-8 encoding as defined in the Unicode standard; UTF-8 sequences with length equal to 5 or 6 are not standard and are rejected.
+* [[encoding_utf16_le]]`encoding_utf16_le` corresponds to little-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
+* [[encoding_utf16_be]]`encoding_utf16_be` corresponds to big-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
+* [[encoding_utf16]]`encoding_utf16` corresponds to UTF-16 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
+* [[encoding_utf32_le]]`encoding_utf32_le` corresponds to little-endian UTF-32 encoding as defined in the Unicode standard.
+* [[encoding_utf32_be]]`encoding_utf32_be` corresponds to big-endian UTF-32 encoding as defined in the Unicode standard.
+* [[encoding_utf32]]`encoding_utf32` corresponds to UTF-32 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
+* [[encoding_wchar]]`encoding_wchar` corresponds to the encoding of `wchar_t` type; it has the same meaning as either `encoding_utf16` or `encoding_utf32`, depending on `wchar_t` size.
+* [[encoding_latin1]]`encoding_latin1` corresponds to ISO-8859-1 encoding (also known as Latin-1).
The algorithm used for `encoding_auto` correctly detects any supported Unicode encoding for all well-formed XML documents (since they start with document declaration) and for all other XML documents that start with `<`; if your XML document does not start with `<` and has encoding that is different from UTF-8, use the specific encoding.
@@ -849,14 +830,14 @@ As for rejecting invalid XML documents, there are a number of incompatibilities
[[access]]
== Accessing document data
-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 <<xpath>> for XPath reference. As discussed in <<dom.cpp>>, there are two types of handles to tree data - [link xml_node] and [link xml_attribute]. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see [link node_null this description] for details. The documentation in this section will explicitly state the results of all function in case of null inputs.
+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 <<xpath>> for XPath reference. As discussed in <<dom.cpp>>, there are two types of handles to tree data - <<xml_node,xml_node>> and <<xml_attribute,xml_attribute>>. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see <<node_null,this description>> for details. The documentation in this section will explicitly state the results of all function in case of null inputs.
[import samples/traverse_base.cpp]
[[access.basic]]
=== Basic traversal functions
-[#xml_node::parent][#xml_node::first_child][#xml_node::last_child][#xml_node::next_sibling][#xml_node::previous_sibling][#xml_node::first_attribute][#xml_node::last_attribute][#xml_attribute::next_attribute][#xml_attribute::previous_attribute]
+[[xml_node::parent]][[xml_node::first_child]][[xml_node::last_child]][[xml_node::next_sibling]][[xml_node::previous_sibling]][[xml_node::first_attribute]][[xml_node::last_attribute]][[xml_attribute::next_attribute]][[xml_attribute::previous_attribute]]
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 to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).
[source]
@@ -889,8 +870,8 @@ include::samples/traverse_base.cpp[tags=basic]
[[access.nodedata]]
=== Getting node data
-[#xml_node::name][#xml_node::value]
-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. <<node_document>> nodes do not have a name or value, [link node_element] and [link node_declaration] nodes always have a name but never have a value, [link node_pcdata], [link node_cdata], [link node_comment] and [link node_doctype] nodes never have a name but always have a value (it may be empty though), [link node_pi] nodes always have a name and a value (again, value may be empty). In order to get node's name or value, you can use the following functions:
+[[xml_node::name]][[xml_node::value]]
+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. <<node_document>> nodes do not have a name or value, <<node_element,node_element>> and <<node_declaration,node_declaration>> nodes always have a name but never have a value, <<node_pcdata,node_pcdata>>, <<node_cdata,node_cdata>>, <<node_comment,node_comment>> and <<node_doctype,node_doctype>> nodes never have a name but always have a value (it may be empty though), <<node_pi,node_pi>> nodes always have a name and a value (again, value may be empty). In order to get node's name or value, you can use the following functions:
[source]
----
@@ -900,8 +881,8 @@ const char_t* xml_node::value() const;
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.
-[#xml_node::child_value]
-It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type [link node_pcdata] with value `"This is a node"`. pugixml provides several helper functions to parse such data:
+[[xml_node::child_value]]
+It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type <<node_pcdata,node_pcdata>> with value `"This is a node"`. pugixml provides several helper functions to parse such data:
[source]
----
@@ -910,16 +891,16 @@ const char_t* xml_node::child_value(const char_t* name) const;
xml_text xml_node::text() const;
----
-`child_value()` returns the value of the first child with type [link node_pcdata] or [link node_cdata]; `child_value(name)` is a simple wrapper for `child(name).child_value()`. For the above example, calling `node.child_value("description")` and `description.child_value()` will both produce string `"This is a node"`. If there is no child with relevant type, or if the handle is null, `child_value` functions return empty string.
+`child_value()` returns the value of the first child with type <<node_pcdata,node_pcdata>> or <<node_cdata,node_cdata>>; `child_value(name)` is a simple wrapper for `child(name).child_value()`. For the above example, calling `node.child_value("description")` and `description.child_value()` will both produce string `"This is a node"`. If there is no child with relevant type, or if the handle is null, `child_value` functions return empty string.
`text()` 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 <<access.text>> sections.
-There is an example of using some of these functions [link code_traverse_base_data at the end of the next section].
+There is an example of using some of these functions <<code_traverse_base_data,at the end of the next section>>.
[[access.attrdata]]
=== Getting attribute data
-[#xml_attribute::name][#xml_attribute::value]
+[[xml_attribute::name]][[xml_attribute::value]]
All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for `xml_node`:
[source]
@@ -930,7 +911,7 @@ const char_t* xml_attribute::value() const;
In case the attribute handle is null, both functions return empty strings - they never return null pointers.
-[#xml_attribute::as_string]
+[[xml_attribute::as_string]]
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 `"sorted"` instead of `""`), you can use `as_string` accessor:
[source]
@@ -940,7 +921,7 @@ const char_t* xml_attribute::as_string(const char_t* def = "") const;
It returns `def` argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to `value()`.
-[#xml_attribute::as_int][#xml_attribute::as_uint][#xml_attribute::as_double][#xml_attribute::as_float][#xml_attribute::as_bool][#xml_attribute::as_llong][#xml_attribute::as_ullong]
+[[xml_attribute::as_int]][[xml_attribute::as_uint]][[xml_attribute::as_double]][[xml_attribute::as_float]][[xml_attribute::as_bool]][[xml_attribute::as_llong]][[xml_attribute::as_ullong]]
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:
[source]
@@ -964,7 +945,7 @@ CAUTION: Number conversion functions depend on current C locale as set with `set
NOTE: `as_llong` and `as_ullong` are only available if your platform has reliable support for the `long long` type, including string conversions.
-[#code_traverse_base_data]
+[[code_traverse_base_data]]
This is an example of using these functions, along with node data retrieval ones (link:samples/traverse_base.cpp[]):
[source,indent=0]
@@ -975,7 +956,7 @@ include::samples/traverse_base.cpp[tags=data]
[[access.contents]]
=== Contents-based traversal functions
-[#xml_node::child][#xml_node::attribute][#xml_node::next_sibling_name][#xml_node::previous_sibling_name]
+[[xml_node::child]][[xml_node::attribute]][[xml_node::next_sibling_name]][[xml_node::previous_sibling_name]]
Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:
[source]
@@ -995,7 +976,7 @@ xml_node xml_node::previous_sibling(const char_t* name) const;
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
----
-[#xml_node::find_child_by_attribute]
+[[xml_node::find_child_by_attribute]]
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: `<group><item id="1"/> <item id="2"/></group>`. There are two functions for finding child nodes based on the attribute values:
[source]
@@ -1018,7 +999,7 @@ include::samples/traverse_base.cpp[tags=contents]
[[access.rangefor]]
=== Range-based for-loop support
-[#xml_node::children][#xml_node::attributes]
+[[xml_node::children]][[xml_node::attributes]]
If your C{plus}{plus} compiler supports range-based for-loop (this is a C{plus}{plus}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 http://www.boost.org/libs/foreach/[Boost Foreach], and possibly other pre-C{plus}{plus}11 foreach facilities.
[source,subs="+quotes"]
@@ -1040,7 +1021,7 @@ include::samples/traverse_rangefor.cpp[tags=code]
[[access.iterators]]
=== Traversing node/attribute lists via iterators
-[#xml_node_iterator][#xml_attribute_iterator][#xml_node::begin][#xml_node::end][#xml_node::attributes_begin][#xml_node::attributes_end]
+[[xml_node_iterator]][[xml_attribute_iterator]][[xml_node::begin]][[xml_node::end]][[xml_node::attributes_begin]][[xml_node::attributes_end]]
Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` 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:
[source]
@@ -1075,7 +1056,7 @@ CAUTION: Node and attribute iterators are somewhere in the middle between const
[[access.walker]]
=== Recursive traversal with xml_tree_walker
-[#xml_tree_walker]
+[[xml_tree_walker]]
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 `xml_tree_walker` interface and to call `traverse` function:
[source]
@@ -1093,7 +1074,7 @@ public:
bool xml_node::traverse(xml_tree_walker& walker);
----
-[#xml_tree_walker::begin][#xml_tree_walker::for_each][#xml_tree_walker::end][#xml_node::traverse]
+[[xml_tree_walker::begin]][[xml_tree_walker::for_each]][[xml_tree_walker::end]][[xml_node::traverse]]
The traversal is launched by calling `traverse` function on traversal root and proceeds as follows:
* First, `begin` function is called with traversal root as its argument.
@@ -1102,7 +1083,7 @@ The traversal is launched by calling `traverse` function on traversal root and p
If `begin`, `end` or any of the `for_each` calls return `false`, the traversal is terminated and `false` is returned as the traversal result; otherwise, the traversal results in `true`. Note that you don't have to override `begin` or `end` functions; their default implementations return `true`.
-[#xml_tree_walker::depth]
+[[xml_tree_walker::depth]]
You can get the node's depth relative to the traversal root at any point by calling `depth` function. It returns `-1` if called from `begin`/`end`, and returns 0-based depth if called from `for_each` - depth is 0 for all children of the traversal root, 1 for all grandchildren and so on.
This is an example of traversing tree hierarchy with xml_tree_walker (link:samples/traverse_walker.cpp[]):
@@ -1119,7 +1100,7 @@ include::samples/traverse_walker.cpp[tags=traverse]
[[access.predicate]]
=== Searching for nodes/attributes with predicates
-[#xml_node::find_attribute][#xml_node::find_child][#xml_node::find_node]
+[[xml_node::find_attribute]][[xml_node::find_child]][[xml_node::find_node]]
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 `find_` functions:
[source]
@@ -1151,10 +1132,10 @@ include::samples/traverse_predicate.cpp[tags=find]
[[access.text]]
=== Working with text contents
-[#xml_text]
-It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type [link node_pcdata] with value `"This is a node"`. pugixml provides a special class, `xml_text`, to work with such data. Working with text objects to modify data is described in [link manual.modify.text the documentation for modifying document data]; this section describes the access interface of `xml_text`.
+[[xml_text]]
+It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type <<node_pcdata,node_pcdata>> with value `"This is a node"`. pugixml provides a special class, `xml_text`, to work with such data. Working with text objects to modify data is described in <<manual.modify.text,the documentation for modifying document data>>; this section describes the access interface of `xml_text`.
-[#xml_node::text]
+[[xml_node::text]]
You can get the text object from a node by using `text()` method:
[source]
@@ -1164,8 +1145,7 @@ xml_text xml_node::text() const;
If the node has a type `node_pcdata` or `node_cdata`, then the node itself is used to return data; otherwise, a first child node of type `node_pcdata` or `node_cdata` is used.
-[#xml_text::empty]
-[#xml_text::unspecified_bool_type]
+[[xml_text::empty]][[xml_text::unspecified_bool_type]]
You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. `if (text) { ... }` or `if (!text) { ... }`. Alternatively you can check it by using the `empty()` method:
[source]
@@ -1173,7 +1153,7 @@ You can check if the text object is bound to a valid PCDATA/CDATA node by using
bool xml_text::empty() const;
----
-[#xml_text::get]
+[[xml_text::get]]
Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:
[source]
@@ -1183,7 +1163,7 @@ const char_t* xml_text::get() const;
In case text object is empty, the function returns an empty string - it never returns a null pointer.
-[#xml_text::as_string][#xml_text::as_int][#xml_text::as_uint][#xml_text::as_double][#xml_text::as_float][#xml_text::as_bool][#xml_text::as_llong][#xml_text::as_ullong]
+[[xml_text::as_string]][[xml_text::as_int]][[xml_text::as_uint]][[xml_text::as_double]][[xml_text::as_float]][[xml_text::as_bool]][[xml_text::as_llong]][[xml_text::as_ullong]]
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:
[source]
@@ -1198,10 +1178,10 @@ long long xml_text::as_llong(long long def = 0) const;
unsigned long long xml_text::as_ullong(unsigned long long def = 0) const;
----
-All of the above functions have the same semantics as similar `xml_attribute` members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can [link xml_attribute::as_int refer to documentation for the attribute functions] for details.
+All of the above functions have the same semantics as similar `xml_attribute` members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can <<xml_attribute::as_int,refer to documentation for the attribute functions>> for details.
-[#xml_text::data]
-`xml_text` is essentially a helper class that operates on `xml_node` values. It is bound to a node of type [link node_pcdata] or [link node_cdata]. You can use the following function to retrieve this node:
+[[xml_text::data]]
+`xml_text` is essentially a helper class that operates on `xml_node` values. It is bound to a node of type <<node_pcdata,node_pcdata>> or <<node_cdata,node_cdata>>. You can use the following function to retrieve this node:
[source]
----
@@ -1220,7 +1200,7 @@ include::samples/text.cpp[tags=access]
[[access.misc]]
=== Miscellaneous functions
-[#xml_node::root]
+[[xml_node::root]]
If you need to get the document root of some node, you can use the following function:
[source]
@@ -1228,10 +1208,9 @@ If you need to get the document root of some node, you can use the following fun
xml_node xml_node::root() const;
----
-This function returns the node with type [link node_document], which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).
+This function returns the node with type <<node_document,node_document>>, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).
-[#xml_node::path]
-[#xml_node::first_element_by_path]
+[[xml_node::path]][[xml_node::first_element_by_path]]
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:
[source]
@@ -1244,9 +1223,9 @@ Node paths consist of node names, separated with a delimiter (which is `/` by de
In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of `first_element_by_path` is null node; also `first_element_by_path` returns null node for null nodes, in which case the path does not matter. `path` returns an empty string for null nodes.
-NOTE: `path` function returns the result as STL string, and thus is not available if [link PUGIXML_NO_STL] is defined.
+NOTE: `path` function returns the result as STL string, and thus is not available if <<PUGIXML_NO_STL,PUGIXML_NO_STL>> is defined.
-[#xml_node::offset_debug]
+[[xml_node::offset_debug]]
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:
[source]
@@ -1254,7 +1233,7 @@ pugixml does not record row/column information for nodes upon parsing for effici
ptrdiff_t xml_node::offset_debug() const;
----
-If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node's data from the beginning of XML buffer in [link char_t pugi::char_t] units. For more information on parsing offsets, see [link xml_parse_result::offset parsing error handling documentation].
+If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node's data from the beginning of XML buffer in <<char_t,pugi::char_t>> units. For more information on parsing offsets, see <<xml_parse_result::offset,parsing error handling documentation>>.
[[modify]]
== Modifying document data
@@ -1268,8 +1247,8 @@ All member functions that change node/attribute data or structure are non-consta
[[modify.nodedata]]
=== Setting node data
-[#xml_node::set_name][#xml_node::set_value]
-As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. [link node_document] nodes do not have a name or value, [link node_element] and [link node_declaration] nodes always have a name but never have a value, [link node_pcdata], [link node_cdata], [link node_comment] and [link node_doctype] nodes never have a name but always have a value (it may be empty though), [link node_pi] nodes always have a name and a value (again, value may be empty). In order to set node's name or value, you can use the following functions:
+[[xml_node::set_name]][[xml_node::set_value]]
+As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <<node_document,node_document>> nodes do not have a name or value, <<node_element,node_element>> and <<node_declaration,node_declaration>> nodes always have a name but never have a value, <<node_pcdata,node_pcdata>>, <<node_cdata,node_cdata>>, <<node_comment,node_comment>> and <<node_doctype,node_doctype>> nodes never have a name but always have a value (it may be empty though), <<node_pi,node_pi>> nodes always have a name and a value (again, value may be empty). In order to set node's name or value, you can use the following functions:
[source]
----
@@ -1277,9 +1256,9 @@ bool xml_node::set_name(const char_t* rhs);
bool xml_node::set_value(const char_t* rhs);
----
-Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call `set_name` on a [link node_pcdata] node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.
+Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call `set_name` on a <<node_pcdata,node_pcdata>> node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.
-There is no equivalent of [link xml_node::child_value child_value] function for modifying text children of the node.
+There is no equivalent of <<xml_node::child_value,child_value>> function for modifying text children of the node.
This is an example of setting node name and value (link:samples/modify_base.cpp[]):
@@ -1291,7 +1270,7 @@ include::samples/modify_base.cpp[tags=node]
[[modify.attrdata]]
=== Setting attribute data
-[#xml_attribute::set_name][#xml_attribute::set_value]
+[[xml_attribute::set_name]][[xml_attribute::set_value]]
All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:
[source]
@@ -1321,7 +1300,7 @@ CAUTION: Number conversion functions depend on current C locale as set with `set
NOTE: `set_value` overloads with `long long` type are only available if your platform has reliable support for the type, including string conversions.
-[#xml_attribute::assign]
+[[xml_attribute::assign]]
For convenience, all `set_value` functions have the corresponding assignment operators:
@@ -1349,7 +1328,7 @@ include::samples/modify_base.cpp[tags=attr]
[[modify.add]]
=== Adding nodes/attributes
-[#xml_node::prepend_attribute][#xml_node::append_attribute][#xml_node::insert_attribute_after][#xml_node::insert_attribute_before][#xml_node::prepend_child][#xml_node::append_child][#xml_node::insert_child_after][#xml_node::insert_child_before]
+[[xml_node::prepend_attribute]][[xml_node::append_attribute]][[xml_node::insert_attribute_after]][[xml_node::insert_attribute_before]][[xml_node::prepend_child]][[xml_node::append_child]][[xml_node::insert_child_after]][[xml_node::insert_child_before]]
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:
[source]
@@ -1372,15 +1351,15 @@ xml_node xml_node::insert_child_before(const char_t* name, const xml_node& node)
`append_attribute` and `append_child` create a new node/attribute at the end of the corresponding list of the node the method is called on; `prepend_attribute` and `prepend_child` create a new node/attribute at the beginning of the list; `insert_attribute_after`, `insert_attribute_before`, `insert_child_after` and `insert_attribute_before` add the node/attribute before or after the specified node/attribute.
-Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the `type` argument create the node with the specified type; since node type can't be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the `name` argument create the element node ([link node_element]) with the specified name.
+Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the `type` argument create the node with the specified type; since node type can't be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the `name` argument create the element node (<<node_element,node_element>>) with the specified name.
All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure:
* Adding fails if the target node is null;
-* Only [link node_element] nodes can contain attributes, so attribute adding fails if node is not an element;
-* Only [link node_document] and [link node_element] nodes can contain children, so child node adding fails if the target node is not an element or a document;
-* [link node_document] and [link node_null] nodes can not be inserted as children, so passing [link node_document] or [link node_null] value as `type` results in operation failure;
-* [link node_declaration] nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails;
+* Only <<node_element,node_element>> nodes can contain attributes, so attribute adding fails if node is not an element;
+* Only <<node_document,node_document>> and <<node_element,node_element>> nodes can contain children, so child node adding fails if the target node is not an element or a document;
+* <<node_document,node_document>> and <<node_null,node_null>> nodes can not be inserted as children, so passing <<node_document,node_document>> or <<node_null,node_null>> value as `type` results in operation failure;
+* <<node_declaration,node_declaration>> nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails;
* Adding node/attribute results in memory allocation, which may fail;
* Insertion functions fail if the specified node or attribute is null or is not in the target node's children/attribute list.
@@ -1398,7 +1377,7 @@ include::samples/modify_add.cpp[tags=code]
[[modify.remove]]
=== Removing nodes/attributes
-[#xml_node::remove_attribute][#xml_node::remove_child]
+[[xml_node::remove_attribute]][[xml_node::remove_child]]
If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:
[source]
@@ -1435,9 +1414,9 @@ include::samples/modify_remove.cpp[tags=code]
[[modify.text]]
=== Working with text contents
-pugixml provides a special class, `xml_text`, to work with text contents stored as a value of some node, i.e. `<node><description>This is a node</description></node>`. Working with text objects to retrieve data is described in [link manual.access.text the documentation for accessing document data]; this section describes the modification interface of `xml_text`.
+pugixml provides a special class, `xml_text`, to work with text contents stored as a value of some node, i.e. `<node><description>This is a node</description></node>`. Working with text objects to retrieve data is described in <<manual.access.text,the documentation for accessing document data>>; this section describes the modification interface of `xml_text`.
-[#xml_text::set]
+[[xml_text::set]]
Once you have an `xml_text` object, you can set the text contents using the following function:
[source]
@@ -1445,9 +1424,9 @@ Once you have an `xml_text` object, you can set the text contents using the foll
bool xml_text::set(const char_t* rhs);
----
-This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a [link node_declaration] node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from 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).
+This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a <<node_declaration,node_declaration>> node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from 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).
-[#xml_text::set_value]
+[[xml_text::set_value]]
In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:
[source]
@@ -1461,9 +1440,9 @@ bool xml_text::set(long long rhs);
bool xml_text::set(unsigned long long rhs);
----
-The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can [link xml_attribute::set_value refer to documentation for the attribute functions] for details.
+The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can <<xml_attribute::set_value,refer to documentation for the attribute functions>> for details.
-[#xml_text::assign]
+[[xml_text::assign]]
For convenience, all `set` functions have the corresponding assignment operators:
@@ -1491,7 +1470,7 @@ include::samples/text.cpp[tags=modify]
[[modify.clone]]
=== Cloning nodes/attributes
-[#xml_node::prepend_copy][#xml_node::append_copy][#xml_node::insert_copy_after][#xml_node::insert_copy_before]
+[[xml_node::prepend_copy]][[xml_node::append_copy]][[xml_node::insert_copy_after]][[xml_node::insert_copy_before]]
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:
[source]
@@ -1511,10 +1490,10 @@ These functions mirror the structure of `append_child`, `prepend_child`, `insert
The attribute is copied along with the name and value; the node is copied along with its type, name and value; additionally attribute list and all children are recursively cloned, resulting in the deep subtree clone. The prototype object can be a part of the same document, or a part of any other document.
-The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, [link xml_node::append_child consult their documentation for more information]. There are additional caveats specific to cloning functions:
+The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, <<xml_node::append_child,consult their documentation for more information>>. There are additional caveats specific to cloning functions:
* Cloning null handles results in operation failure;
-* Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since [link node_document] is not a valid insertion type. The example below provides a workaround.
+* Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since <<node_document,node_document>> is not a valid insertion type. The example below provides a workaround.
* It is possible to copy a subtree as a child of some node inside this subtree, i.e. `node.append_copy(node.parent().parent());`. This is a valid operation, and it results in a clone of the subtree in the state before cloning started, i.e. no infinite recursion takes place.
This is an example with one possible implementation of include tags in XML (link:samples/include.cpp[]). It illustrates node cloning and usage of other document modification functions:
@@ -1527,7 +1506,7 @@ include::samples/include.cpp[tags=code]
[[modify.move]]
=== Moving nodes
-[#xml_node::prepend_move][#xml_node::append_move][#xml_node::insert_move_after][#xml_node::insert_move_before]
+[[xml_node::prepend_move]][[xml_node::append_move]][[xml_node::insert_move_after]][[xml_node::insert_move_before]]
Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:
[source]
@@ -1540,7 +1519,7 @@ xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& nod
These functions mirror the structure of `append_copy`, `prepend_copy`, `insert_copy_before` and `insert_copy_after` - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.
-The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, [link xml_node::append_child consult their documentation for more information]. There are additional caveats specific to moving functions:
+The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, <<xml_node::append_child,consult their documentation for more information>>. There are additional caveats specific to moving functions:
* Moving null handles results in operation failure;
* Moving is only possible for nodes that belong to the same document; attempting to move nodes between documents will fail.
@@ -1550,7 +1529,7 @@ The failure conditions resemble those of `append_child`, `insert_child_before` a
[[modify.fragments]]
=== Assembling document from fragments
-[#xml_node::append_buffer]
+[[xml_node::append_buffer]]
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:
* Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:
@@ -1587,9 +1566,9 @@ xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsi
The first method is more convenient, but slower than the other two. The relative performance of `append_copy` and `append_buffer` depends on the buffer format - usually `append_buffer` is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending on `PUGIXML_WCHAR_MODE`). 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.
-`append_buffer` behaves in the same way as [link xml_document::load_buffer] - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns.
+`append_buffer` behaves in the same way as <<xml_document::load_buffer,xml_document::load_buffer>> - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns.
-[#status_append_invalid_root]
+[[status_append_invalid_root]]
Since `append_buffer` needs to append child nodes to the current node, it only works if the current node is either document or element node. Calling `append_buffer` on a node with any other type results in an error with `status_append_invalid_root` status.
[[saving]]
@@ -1597,15 +1576,14 @@ Since `append_buffer` needs to append child nodes to the current node, it only w
Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases 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 <<saving.options>>), and also perform necessary encoding conversions (see <<saving.encoding>>). This section documents the relevant functionality.
-Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped (unless [link format_no_escapes] flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values.
+Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped (unless <<format_no_escapes,format_no_escapes>> flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values.
CDATA sections with values that contain `"]]>"` are split into several sections as follows: section with value `"pre]]>post"` is written as `<![CDATA[pre]]]]><![CDATA[>post]]>`. While this alters the structure of the document (if you load the document after saving it, there will be two CDATA sections instead of one), this is the only way to escape CDATA contents.
[[saving.file]]
=== Saving document to a file
-[#xml_document::save_file]
-[#xml_document::save_file_wide]
+[[xml_document::save_file]][[xml_document::save_file_wide]]
If you want to save the whole document to a file, you can use one of the following functions:
[source]
@@ -1618,7 +1596,7 @@ These functions accept file path as its first argument, and also three optional
File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses 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.
-[#xml_writer_file]
+[[xml_writer_file]]
`save_file` 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 `false`. Calling `save_file` is equivalent to creating an `xml_writer_file` object with `FILE*` handle as the only constructor argument and then calling `save`; see <<saving.writer>> for writer interface details.
This is a simple example of saving XML document to file (link:samples/save_file.cpp[]):
@@ -1631,7 +1609,7 @@ include::samples/save_file.cpp[tags=code]
[[saving.stream]]
=== Saving document to C{plus}{plus} IOstreams
-[#xml_document::save_stream]
+[[xml_document::save_stream]]
To enhance interoperability pugixml provides functions for saving document to any object which implements C{plus}{plus} `std::ostream` interface. This allows you to save documents to any standard C{plus}{plus} 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 `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:
[source]
@@ -1640,9 +1618,9 @@ void xml_document::save(std::ostream& stream, const char_t* indent = "\t", unsig
void xml_document::save(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
----
-`save` with `std::ostream` argument saves the document to the stream in the same way as `save_file` (i.e. with requested header and with encoding conversions). On the other hand, `save` with `std::wstream` argument saves the document to the wide stream with [link encoding_wchar] encoding. Because of this, using `save` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides 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.
+`save` with `std::ostream` argument saves the document to the stream in the same way as `save_file` (i.e. with requested header and with encoding conversions). On the other hand, `save` with `std::wstream` argument saves the document to the wide stream with <<encoding_wchar,encoding_wchar>> encoding. Because of this, using `save` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides 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.
-[#xml_writer_stream]
+[[xml_writer_stream]]
Calling `save` with stream target is equivalent to creating an `xml_writer_stream` object with stream as the only constructor argument and then calling `save`; see <<saving.writer>> for writer interface details.
This is a simple example of saving XML document to standard output (link:samples/save_stream.cpp[]):
@@ -1655,7 +1633,7 @@ include::samples/save_stream.cpp[tags=code]
[[saving.writer]]
=== Saving document via writer interface
-[#xml_document::save][#xml_writer][#xml_writer::write]
+[[xml_document::save]][[xml_writer]][[xml_writer::write]]
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:
[source]
@@ -1683,7 +1661,7 @@ include::samples/save_custom_writer.cpp[tags=code]
[[saving.subtree]]
=== Saving a single subtree
-[#xml_node::print][#xml_node::print_stream]
+[[xml_node::print]][[xml_node::print_stream]]
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:
[source]
@@ -1695,7 +1673,7 @@ void xml_node::print(xml_writer& writer, const char_t* indent = "\t", unsigned i
These functions have the same arguments with the same meaning as the corresponding `xml_document::save` functions, and allow you to save the subtree to either a C{plus}{plus} IOstream or to any object that implements `xml_writer` interface.
-Saving a subtree differs from saving the whole document: the process behaves as if [link format_write_bom] is off, and [link format_no_declaration] is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node's children. Note that this also holds if you're saving a document; this example (link:samples/save_subtree.cpp[]) illustrates the difference:
+Saving a subtree differs from saving the whole document: the process behaves as if <<format_write_bom,format_write_bom>> is off, and <<format_no_declaration,format_no_declaration>> is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node's children. Note that this also holds if you're saving a document; this example (link:samples/save_subtree.cpp[]) illustrates the difference:
[source,indent=0]
----
@@ -1711,24 +1689,24 @@ NOTE: You should use the usual bitwise arithmetics to manipulate the bitmask: to
These flags control the resulting tree contents:
-* [anchor format_indent] determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is `"\t"` by default). If this flag is on, before every node the indentation string is output several times, where the amount of indentation depends on the node's depth relative to the output subtree. This flag has no effect if [link format_raw] is enabled. This flag is *on* by default.
+* [[format_indent]]`format_indent` determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is `"\t"` by default). If this flag is on, before every node the indentation string is output several times, where the amount of indentation depends on the node's depth relative to the output subtree. This flag has no effect if <<format_raw,format_raw>> is enabled. This flag is *on* by default.
-* [anchor format_raw] switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with [link parse_ws_pcdata] flag, to preserve the original document formatting as much as possible. This flag is *off* by default.
+* [[format_raw]]`format_raw` switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with <<parse_ws_pcdata,parse_ws_pcdata>> flag, to preserve the original document formatting as much as possible. This flag is *off* by default.
-* [anchor format_no_escapes] disables output 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 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 *off* by default.
+* [[format_no_escapes]]`format_no_escapes` disables output 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 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 *off* by default.
These flags control the additional output information:
-* [anchor format_no_declaration] disables default node declaration output. By default, if the document is saved via `save` or `save_file` function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in `xml_node::print` functions: they never output the default declaration. This flag is *off* by default.
+* [[format_no_declaration]]`format_no_declaration` disables default node declaration output. By default, if the document is saved via `save` or `save_file` function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in `xml_node::print` functions: they never output the default declaration. This flag is *off* by default.
-* [anchor format_write_bom] enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document's encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in `xml_node::print` functions: they never output the BOM. This flag is *off* by default.
+* [[format_write_bom]]`format_write_bom` enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document's encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in `xml_node::print` functions: they never output the BOM. This flag is *off* by default.
-* [anchor format_save_file_text] changes the file mode when using `save_file` function. By default, file is opened in binary mode, which means that the output file will
+* [[format_save_file_text]]`format_save_file_text` changes the file mode when using `save_file` function. By default, file is opened in binary mode, which means that the output file will
contain platform-independent newline \n (ASCII 10). If this flag is on, file is opened in text mode, which on some systems changes the newline format (i.e. on Windows you can use this flag to output XML documents with \r\n (ASCII 13 10) newlines. This flag is *off* by default.
Additionally, there is one predefined option mask:
-* [anchor format_default] 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, if necessary.
+* [[format_default]]`format_default` 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, if necessary.
This is an example that shows the outputs of different output options (link:samples/save_options.cpp[]):
@@ -1744,7 +1722,7 @@ pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little en
While all other flags set the exact encoding, `encoding_auto` is meant for automatic encoding detection. The automatic detection does not make sense for output encoding, since there is usually nothing to infer the actual encoding from, so here `encoding_auto` means UTF-8 encoding, which is the most popular encoding for XML data storage. This is also the default value of output encoding; specify another value if you do not want UTF-8 encoded output.
-Also note that wide stream saving functions do not have `encoding` argument and always assume [link encoding_wchar] encoding.
+Also note that wide stream saving functions do not have `encoding` argument and always assume <<encoding_wchar,encoding_wchar>> encoding.
NOTE: The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; if your node/attribute names do not contain any valid UTF sequences, they may be output as if they are empty, which will result in malformed XML document.
@@ -1753,9 +1731,9 @@ NOTE: The current behavior for Unicode conversion is to skip all invalid UTF seq
When you are saving the document using `xml_document::save()` or `xml_document::save_file()`, a default XML document declaration is output, if `format_no_declaration` is not specified and if the document does not have a declaration node. However, the default declaration is not customizable. If you want to customize the declaration output, you need to create the declaration node yourself.
-NOTE: By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag [link parse_declaration] to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving.
+NOTE: By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag <<parse_declaration,parse_declaration>> to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving.
-Declaration node is a node with type [link node_declaration]; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values.
+Declaration node is a node with type <<node_declaration,node_declaration>>; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values.
This is an example that shows how to create a custom declaration node (link:samples/save_declaration.cpp[]):
@@ -1772,10 +1750,10 @@ If the task at hand is to select a subset of document nodes that match some crit
[[xpath.types]]
=== XPath types
-[#xpath_value_type][#xpath_type_number][#xpath_type_string][#xpath_type_boolean][#xpath_type_node_set][#xpath_type_none]
-Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to `bool` type, number type corresponds to `double` type, string type corresponds to either `std::string` or `std::wstring`, depending on whether [link manual.dom.unicode wide character interface is enabled], and node set corresponds to [link xpath_node_set] type. There is an enumeration, `xpath_value_type`, which can take the values `xpath_type_boolean`, `xpath_type_number`, `xpath_type_string` or `xpath_type_node_set`, accordingly.
+[[xpath_value_type]][[xpath_type_number]][[xpath_type_string]][[xpath_type_boolean]][[xpath_type_node_set]][[xpath_type_none]]
+Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to `bool` type, number type corresponds to `double` type, string type corresponds to either `std::string` or `std::wstring`, depending on whether <<manual.dom.unicode,wide character interface is enabled>>, and node set corresponds to <<xpath_node_set,xpath_node_set>> type. There is an enumeration, `xpath_value_type`, which can take the values `xpath_type_boolean`, `xpath_type_number`, `xpath_type_string` or `xpath_type_node_set`, accordingly.
-[#xpath_node][#xpath_node::node][#xpath_node::attribute][#xpath_node::parent]
+[[xpath_node]][[xpath_node::node]][[xpath_node::attribute]][[xpath_node::parent]]
Because an XPath node can be either a node or an attribute, there is a special type, `xpath_node`, which is a discriminated union of these types. A value of this type contains two node handles, one of `xml_node` type, and another one of `xml_attribute` type; at most one of them can be non-null. The accessors to get these handles are available:
[source]
@@ -1795,16 +1773,16 @@ xml_node xpath_node::parent() const;
`parent` function returns the node's parent if the XPath node corresponds to `xml_node` handle (equivalent to `node().parent()`), or the node to which the attribute belongs to, if the XPath node corresponds to `xml_attribute` handle. For null nodes, `parent` returns null handle.
-[#xpath_node::unspecified_bool_type][#xpath_node::comparison]
+[[xpath_node::unspecified_bool_type]][[xpath_node::comparison]]
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.
-[#xpath_node::ctor]
+[[xpath_node::ctor]]
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 `xml_node` is implicit, so you can usually pass `xml_node` to functions that expect `xpath_node`. Apart from that you usually don't need to create your own XPath node objects, since they are returned to you via selection functions.
-[#xpath_node_set]
+[[xpath_node_set]]
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.
-[#xpath_node_set::const_iterator][#xpath_node_set::begin][#xpath_node_set::end]
+[[xpath_node_set::const_iterator]][[xpath_node_set::begin]][[xpath_node_set::end]]
Node sets are represented by `xpath_node_set` 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:
[source]
@@ -1814,7 +1792,7 @@ const_iterator xpath_node_set::begin() const;
const_iterator xpath_node_set::end() const;
----
-[#xpath_node_set::index][#xpath_node_set::size][#xpath_node_set::empty]
+[[xpath_node_set::index]][[xpath_node_set::size]][[xpath_node_set::empty]]
And it also can be iterated via indices, just like `std::vector`:
[source]
@@ -1826,7 +1804,7 @@ bool xpath_node_set::empty() const;
All of the above operations have the same semantics as that of `std::vector`: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the 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.
-[#xpath_node_set::type][#xpath_node_set::type_unsorted][#xpath_node_set::type_sorted][#xpath_node_set::type_sorted_reverse][#xpath_node_set::sort]
+[[xpath_node_set::type]][[xpath_node_set::type_unsorted]][[xpath_node_set::type_sorted]][[xpath_node_set::type_sorted_reverse]][[xpath_node_set::sort]]
The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:
[source]
@@ -1844,7 +1822,7 @@ void xpath_node_set::sort(bool reverse = false);
Calling `sort` sorts the nodes in either forward or reverse document order, depending on the argument; after this call `type()` will return `type_sorted` or `type_sorted_reverse`.
-[#xpath_node_set::first]
+[[xpath_node_set::first]]
Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:
[source]
@@ -1854,7 +1832,7 @@ xpath_node xpath_node_set::first() const;
This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of `type()`), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.
-[#xpath_node_set::ctor]
+[[xpath_node_set::ctor]]
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 (`const_iterator` is a typedef for `const xpath_node*`), and an optional type:
[source]
@@ -1867,7 +1845,7 @@ The constructor copies the specified range and sets the specified type. The obje
[[xpath.select]]
=== Selecting nodes via XPath expression
-[#xml_node::select_node][#xml_node::select_nodes]
+[[xml_node::select_node]][[xml_node::select_nodes]]
If you want to select nodes that match some XPath expression, you can do it with the following functions:
[source]
@@ -1878,9 +1856,9 @@ xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* v
`select_nodes` function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. `select_node` returns only the first node in document order from the result, and is equivalent to calling `select_nodes(query).first()`. If the XPath expression does not match anything, or the node handle is null, `select_nodes` returns an empty set, and `select_node` returns null XPath node.
-If exception handling is not disabled, both functions throw [link xpath_exception] if the query can not be compiled or if it returns a value with type other than node set; see <<xpath.errors>> for details.
+If exception handling is not disabled, both functions throw <<xpath_exception,xpath_exception>> if the query can not be compiled or if it returns a value with type other than node set; see <<xpath.errors>> for details.
-[#xml_node::select_node_precomp][#xml_node::select_nodes_precomp]
+[[xml_node::select_node_precomp]][[xml_node::select_nodes_precomp]]
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 <<xpath.query>> for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:
[source]
@@ -1889,7 +1867,7 @@ xpath_node xml_node::select_node(const xpath_query& query) const;
xpath_node_set xml_node::select_nodes(const xpath_query& query) const;
----
-If exception handling is not disabled, both functions throw [link xpath_exception] if the query returns a value with type other than node set.
+If exception handling is not disabled, both functions throw <<xpath_exception,xpath_exception>> if the query returns a value with type other than node set.
This is an example of selecting nodes using XPath expressions (link:samples/xpath_select.cpp[]):
@@ -1901,7 +1879,7 @@ include::samples/xpath_select.cpp[tags=code]
[[xpath.query]]
=== Using query objects
-[#xpath_query]
+[[xpath_query]]
When you call `select_nodes` 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:
* You can precompile expressions to query objects to save compilation time if it becomes an issue;
@@ -1910,7 +1888,7 @@ When you call `select_nodes` with an expression string as an argument, a query o
Query objects correspond to `xpath_query` type. They are immutable and non-copyable: they are bound to the expression at creation time and can not be cloned. If you want to put query objects in a container, allocate them on heap via `new` operator and store pointers to `xpath_query` in the container.
-[#xpath_query::ctor]
+[[xpath_query::ctor]]
You can create a query object with the constructor that takes XPath expression as an argument:
[source]
@@ -1918,15 +1896,15 @@ You can create a query object with the constructor that takes XPath expression a
explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
----
-[#xpath_query::return_type]
-The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, [link xpath_exception] is thrown if exception handling is not disabled (see <<xpath.errors>> for details). After the query is created, you can query the type of the evaluation result using the following function:
+[[xpath_query::return_type]]
+The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, <<xpath_exception,xpath_exception>> is thrown if exception handling is not disabled (see <<xpath.errors>> for details). After the query is created, you can query the type of the evaluation result using the following function:
[source]
----
xpath_value_type xpath_query::return_type() const;
----
-[#xpath_query::evaluate_boolean][#xpath_query::evaluate_number][#xpath_query::evaluate_string][#xpath_query::evaluate_node_set][#xpath_query::evaluate_node]
+[[xpath_query::evaluate_boolean]][[xpath_query::evaluate_number]][[xpath_query::evaluate_string]][[xpath_query::evaluate_node_set]][[xpath_query::evaluate_node]]
You can evaluate the query using one of the following functions:
[source]
@@ -1942,8 +1920,8 @@ All functions take the context node as an argument, compute the expression and r
NOTE: Calling `node.select_nodes("query")` is equivalent to calling `xpath_query("query").evaluate_node_set(node)`. Calling `node.select_node("query")` is equivalent to calling `xpath_query("query").evaluate_node(node)`.
-[#xpath_query::evaluate_string_buffer]
-Note that `evaluate_string` function returns the STL string; as such, it's not available in [link PUGIXML_NO_STL] mode and also usually allocates memory. There is another string evaluation function:
+[[xpath_query::evaluate_string_buffer]]
+Note that `evaluate_string` function returns the STL string; as such, it's not available in <<PUGIXML_NO_STL,PUGIXML_NO_STL>> mode and also usually allocates memory. There is another string evaluation function:
[source]
----
@@ -1980,10 +1958,10 @@ If you're using query objects, you can change the variable values before `evalua
NOTE: The variable set pointer is stored in the query object; you have to ensure that the lifetime of the set exceeds that of query object.
-[#xpath_variable_set]
+[[xpath_variable_set]]
Variable sets correspond to `xpath_variable_set` type, which is essentially a variable container.
-[#xpath_variable_set::add]
+[[xpath_variable_set::add]]
You can add new variables with the following function:
[source]
@@ -1995,7 +1973,7 @@ The function tries to add a new variable with the specified name and type; if th
New variables are assigned the default value which depends on the type: `0` for numbers, `false` for booleans, empty string for strings and empty set for node sets.
-[#xpath_variable_set::get]
+[[xpath_variable_set::get]]
You can get the existing variables with the following functions:
[source]
@@ -2006,7 +1984,7 @@ const xpath_variable* xpath_variable_set::get(const char_t* name) const;
The functions return the variable handle, or null pointer if the variable with the specified name is not found.
-[#xpath_variable_set::set]
+[[xpath_variable_set::set]]
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 `false`; they also return `false` on allocation failure. Note that these functions do not perform any type conversions.
[source]
@@ -2019,10 +1997,10 @@ bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value);
The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.
-[#xpath_variable]
+[[xpath_variable]]
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 `xpath_variable` type, and a variable handle is simply a pointer to `xpath_variable`.
-[#xpath_variable::type][#xpath_variable::name]
+[[xpath_variable::type]][[xpath_variable::name]]
In order to get variable information, you can use one of the following functions:
[source]
@@ -2033,7 +2011,7 @@ xpath_value_type xpath_variable::type() const;
Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.
-[#xpath_variable::get_boolean][#xpath_variable::get_number][#xpath_variable::get_string][#xpath_variable::get_node_set]
+[[xpath_variable::get_boolean]][[xpath_variable::get_number]][[xpath_variable::get_string]][[xpath_variable::get_node_set]]
In order to get variable value, you should use one of the following functions, depending on the variable type:
[source]
@@ -2046,7 +2024,7 @@ const xpath_node_set& xpath_variable::get_node_set() const;
These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (`false` for booleans, `NaN` for numbers, empty string for strings and empty set for node sets).
-[#xpath_variable::set]
+[[xpath_variable::set]]
In order to set variable value, you should use one of the following functions, depending on the variable type:
[source]
@@ -2069,11 +2047,9 @@ include::samples/xpath_variables.cpp[tags=code]
[[xpath.errors]]
=== Error handling
-There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with [link PUGIXML_NO_EXCEPTIONS] define).
+There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with <<PUGIXML_NO_EXCEPTIONS,PUGIXML_NO_EXCEPTIONS>> define).
-[#xpath_exception]
-[#xpath_exception::result]
-[#xpath_exception::what]
+[[xpath_exception]][[xpath_exception::result]][[xpath_exception::what]]
By default, XPath functions throw `xpath_exception` object in case of errors; additionally, in the event any memory allocation fails, an `std::bad_alloc` exception is thrown. Also `xpath_exception` 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:
[source]
@@ -2082,8 +2058,7 @@ virtual const char* xpath_exception::what() const throw();
const xpath_parse_result& xpath_exception::result() const;
----
-[#xpath_query::unspecified_bool_type]
-[#xpath_query::result]
+[[xpath_query::unspecified_bool_type]][[xpath_query::result]]
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: `if (query) { ... }`. Additionally, you can get parsing result via the result() accessor:
[source]
@@ -2093,7 +2068,7 @@ const xpath_parse_result& xpath_query::result() const;
Without exceptions, evaluating invalid query results in `false`, empty string, NaN or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.
-[#xpath_parse_result]
+[[xpath_parse_result]]
The information about parsing result is returned via `xpath_parse_result` object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:
[source]
@@ -2108,16 +2083,16 @@ struct xpath_parse_result
};
----
-[#xpath_parse_result::error]
+[[xpath_parse_result::error]]
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.
-[#xpath_parse_result::description]
-`description()` member function can be used to get the error message; it never returns the null pointer, so you can safely use `description()` even if query parsing succeeded. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call [link as_wide] to get the `wchar_t` string.
+[[xpath_parse_result::description]]
+`description()` member function can be used to get the error message; it never returns the null pointer, so you can safely use `description()` even if query parsing succeeded. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call <<as_wide,as_wide>> to get the `wchar_t` string.
-[#xpath_parse_result::offset]
-In addition to the error message, parsing result has an `offset` member, which contains the offset of last successfully parsed character. This offset is in units of [link char_t pugi::char_t] (bytes for character mode, wide characters for wide character mode).
+[[xpath_parse_result::offset]]
+In addition to the error message, parsing result has an `offset` member, which contains the offset of last successfully parsed character. This offset is in units of <<char_t,pugi::char_t>> (bytes for character mode, wide characters for wide character mode).
-[#xpath_parse_result::bool]
+[[xpath_parse_result::bool]]
Parsing result object can be implicitly converted to `bool` like this: `if (result) { ... } else { ... }`.
This is an example of XPath error handling (link:samples/xpath_error.cpp[]):
@@ -2503,82 +2478,82 @@ Macros:
[source,subs="+macros"]
----
-#define [link PUGIXML_WCHAR_MODE]
-#define [link PUGIXML_NO_XPATH]
-#define [link PUGIXML_NO_STL]
-#define [link PUGIXML_NO_EXCEPTIONS]
-#define [link PUGIXML_API]
-#define [link PUGIXML_CLASS]
-#define [link PUGIXML_FUNCTION]
-#define [link PUGIXML_MEMORY_PAGE_SIZE]
-#define [link PUGIXML_MEMORY_OUTPUT_STACK]
-#define [link PUGIXML_MEMORY_XPATH_PAGE_SIZE]
-#define [link PUGIXML_HEADER_ONLY]
-#define [link PUGIXML_HAS_LONG_LONG]
+#define +++<a href="#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a>+++
+#define +++<a href="#PUGIXML_NO_XPATH">PUGIXML_NO_XPATH</a>+++
+#define +++<a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a>+++
+#define +++<a href="#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a>+++
+#define +++<a href="#PUGIXML_API">PUGIXML_API</a>+++
+#define +++<a href="#PUGIXML_CLASS">PUGIXML_CLASS</a>+++
+#define +++<a href="#PUGIXML_FUNCTION">PUGIXML_FUNCTION</a>+++
+#define +++<a href="#PUGIXML_MEMORY_PAGE_SIZE">PUGIXML_MEMORY_PAGE_SIZE</a>+++
+#define +++<a href="#PUGIXML_MEMORY_OUTPUT_STACK">PUGIXML_MEMORY_OUTPUT_STACK</a>+++
+#define +++<a href="#PUGIXML_MEMORY_XPATH_PAGE_SIZE">PUGIXML_MEMORY_XPATH_PAGE_SIZE</a>+++
+#define +++<a href="#PUGIXML_HEADER_ONLY">PUGIXML_HEADER_ONLY</a>+++
+#define +++<a href="#PUGIXML_HAS_LONG_LONG">PUGIXML_HAS_LONG_LONG</a>+++
----
Types:
[source,subs="+macros,+quotes"]
----
-typedef _configuration-defined-type_ [link char_t];
-typedef _configuration-defined-type_ [link string_t];
-typedef void* (*[link allocation_function])(size_t size);
-typedef void (*[link deallocation_function])(void* ptr);
+typedef _configuration-defined-type_ +++<a href="#char_t">char_t</a>+++;
+typedef _configuration-defined-type_ +++<a href="#string_t">string_t</a>+++;
+typedef void* (*+++<a href="#allocation_function">allocation_function</a>+++)(size_t size);
+typedef void (*+++<a href="#deallocation_function">deallocation_function</a>+++)(void* ptr);
----
Enumerations:
[source,subs="+macros"]
----
-enum [link xml_node_type]
- [link node_null]
- [link node_document]
- [link node_element]
- [link node_pcdata]
- [link node_cdata]
- [link node_comment]
- [link node_pi]
- [link node_declaration]
- [link node_doctype]
-
-enum [link xml_parse_status]
- [link status_ok]
- [link status_file_not_found]
- [link status_io_error]
- [link status_out_of_memory]
- [link status_internal_error]
- [link status_unrecognized_tag]
- [link status_bad_pi]
- [link status_bad_comment]
- [link status_bad_cdata]
- [link status_bad_doctype]
- [link status_bad_pcdata]
- [link status_bad_start_element]
- [link status_bad_attribute]
- [link status_bad_end_element]
- [link status_end_element_mismatch]
- [link status_append_invalid_root]
- [link status_no_document_element]
-
-enum [link xml_encoding]
- [link encoding_auto]
- [link encoding_utf8]
- [link encoding_utf16_le]
- [link encoding_utf16_be]
- [link encoding_utf16]
- [link encoding_utf32_le]
- [link encoding_utf32_be]
- [link encoding_utf32]
- [link encoding_wchar]
- [link encoding_latin1]
-
-enum [link xpath_value_type]
- [link xpath_type_none]
- [link xpath_type_node_set]
- [link xpath_type_number]
- [link xpath_type_string]
- [link xpath_type_boolean]
+enum +++<a href="#xml_node_type">xml_node_type</a>+++
+ +++<a href="#node_null">node_null</a>+++
+ +++<a href="#node_document">node_document</a>+++
+ +++<a href="#node_element">node_element</a>+++
+ +++<a href="#node_pcdata">node_pcdata</a>+++
+ +++<a href="#node_cdata">node_cdata</a>+++
+ +++<a href="#node_comment">node_comment</a>+++
+ +++<a href="#node_pi">node_pi</a>+++
+ +++<a href="#node_declaration">node_declaration</a>+++
+ +++<a href="#node_doctype">node_doctype</a>+++
+
+enum +++<a href="#xml_parse_status">xml_parse_status</a>+++
+ +++<a href="#status_ok">status_ok</a>+++
+ +++<a href="#status_file_not_found">status_file_not_found</a>+++
+ +++<a href="#status_io_error">status_io_error</a>+++
+ +++<a href="#status_out_of_memory">status_out_of_memory</a>+++
+ +++<a href="#status_internal_error">status_internal_error</a>+++
+ +++<a href="#status_unrecognized_tag">status_unrecognized_tag</a>+++
+ +++<a href="#status_bad_pi">status_bad_pi</a>+++
+ +++<a href="#status_bad_comment">status_bad_comment</a>+++
+ +++<a href="#status_bad_cdata">status_bad_cdata</a>+++
+ +++<a href="#status_bad_doctype">status_bad_doctype</a>+++
+ +++<a href="#status_bad_pcdata">status_bad_pcdata</a>+++
+ +++<a href="#status_bad_start_element">status_bad_start_element</a>+++
+ +++<a href="#status_bad_attribute">status_bad_attribute</a>+++
+ +++<a href="#status_bad_end_element">status_bad_end_element</a>+++
+ +++<a href="#status_end_element_mismatch">status_end_element_mismatch</a>+++
+ +++<a href="#status_append_invalid_root">status_append_invalid_root</a>+++
+ +++<a href="#status_no_document_element">status_no_document_element</a>+++
+
+enum +++<a href="#xml_encoding">xml_encoding</a>+++
+ +++<a href="#encoding_auto">encoding_auto</a>+++
+ +++<a href="#encoding_utf8">encoding_utf8</a>+++
+ +++<a href="#encoding_utf16_le">encoding_utf16_le</a>+++
+ +++<a href="#encoding_utf16_be">encoding_utf16_be</a>+++
+ +++<a href="#encoding_utf16">encoding_utf16</a>+++
+ +++<a href="#encoding_utf32_le">encoding_utf32_le</a>+++
+ +++<a href="#encoding_utf32_be">encoding_utf32_be</a>+++
+ +++<a href="#encoding_utf32">encoding_utf32</a>+++
+ +++<a href="#encoding_wchar">encoding_wchar</a>+++
+ +++<a href="#encoding_latin1">encoding_latin1</a>+++
+
+enum +++<a href="#xpath_value_type">xpath_value_type</a>+++
+ +++<a href="#xpath_type_none">xpath_type_none</a>+++
+ +++<a href="#xpath_type_node_set">xpath_type_node_set</a>+++
+ +++<a href="#xpath_type_number">xpath_type_number</a>+++
+ +++<a href="#xpath_type_string">xpath_type_string</a>+++
+ +++<a href="#xpath_type_boolean">xpath_type_boolean</a>+++
----
Constants:
@@ -2586,384 +2561,384 @@ Constants:
[source,subs="+macros"]
----
// Formatting options bit flags:
- [link format_default]
- [link format_indent]
- [link format_no_declaration]
- [link format_no_escapes]
- [link format_raw]
- [link format_save_file_text]
- [link format_write_bom]
+ +++<a href="#format_default">format_default</a>+++
+ +++<a href="#format_indent">format_indent</a>+++
+ +++<a href="#format_no_declaration">format_no_declaration</a>+++
+ +++<a href="#format_no_escapes">format_no_escapes</a>+++
+ +++<a href="#format_raw">format_raw</a>+++
+ +++<a href="#format_save_file_text">format_save_file_text</a>+++
+ +++<a href="#format_write_bom">format_write_bom</a>+++
// Parsing options bit flags:
- [link parse_cdata]
- [link parse_comments]
- [link parse_declaration]
- [link parse_default]
- [link parse_doctype]
- [link parse_eol]
- [link parse_escapes]
- [link parse_fragment]
- [link parse_full]
- [link parse_minimal]
- [link parse_pi]
- [link parse_trim_pcdata]
- [link parse_ws_pcdata]
- [link parse_ws_pcdata_single]
- [link parse_wconv_attribute]
- [link parse_wnorm_attribute]
+ +++<a href="#parse_cdata">parse_cdata</a>+++
+ +++<a href="#parse_comments">parse_comments</a>+++
+ +++<a href="#parse_declaration">parse_declaration</a>+++
+ +++<a href="#parse_default">parse_default</a>+++
+ +++<a href="#parse_doctype">parse_doctype</a>+++
+ +++<a href="#parse_eol">parse_eol</a>+++
+ +++<a href="#parse_escapes">parse_escapes</a>+++
+ +++<a href="#parse_fragment">parse_fragment</a>+++
+ +++<a href="#parse_full">parse_full</a>+++
+ +++<a href="#parse_minimal">parse_minimal</a>+++
+ +++<a href="#parse_pi">parse_pi</a>+++
+ +++<a href="#parse_trim_pcdata">parse_trim_pcdata</a>+++
+ +++<a href="#parse_ws_pcdata">parse_ws_pcdata</a>+++
+ +++<a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a>+++
+ +++<a href="#parse_wconv_attribute">parse_wconv_attribute</a>+++
+ +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>+++
----
Classes:
[source,subs="+macros"]
----
-class [link xml_attribute]
- [link xml_attribute::ctor xml_attribute]();
-
- bool [link xml_attribute::empty empty]() const;
- operator [link xml_attribute::unspecified_bool_type unspecified_bool_type]() const;
-
- bool [link xml_attribute::comparison operator==](const xml_attribute& r) const;
- bool [link xml_attribute::comparison operator!=](const xml_attribute& r) const;
- bool [link xml_attribute::comparison operator<](const xml_attribute& r) const;
- bool [link xml_attribute::comparison operator>](const xml_attribute& r) const;
- bool [link xml_attribute::comparison operator<=](const xml_attribute& r) const;
- bool [link xml_attribute::comparison operator>=](const xml_attribute& r) const;
-
- size_t [link xml_attribute::hash_value hash_value]() const;
-
- xml_attribute [link xml_attribute::next_attribute next_attribute]() const;
- xml_attribute [link xml_attribute::previous_attribute previous_attribute]() const;
-
- const char_t* [link xml_attribute::name name]() const;
- const char_t* [link xml_attribute::value value]() const;
-
- const char_t* [link xml_attribute::as_string as_string](const char_t* def = "") const;
- int [link xml_attribute::as_int as_int](int def = 0) const;
- unsigned int [link xml_attribute::as_uint as_uint](unsigned int def = 0) const;
- double [link xml_attribute::as_double as_double](double def = 0) const;
- float [link xml_attribute::as_float as_float](float def = 0) const;
- bool [link xml_attribute::as_bool as_bool](bool def = false) const;
- long long [link xml_attribute::as_llong as_llong](long long def = 0) const;
- unsigned long long [link xml_attribute::as_ullong as_ullong](unsigned long long def = 0) const;
-
- bool [link xml_attribute::set_name set_name](const char_t* rhs);
- bool [link xml_attribute::set_value set_value](const char_t* rhs);
- bool [link xml_attribute::set_value set_value](int rhs);
- bool [link xml_attribute::set_value set_value](unsigned int rhs);
- bool [link xml_attribute::set_value set_value](double rhs);
- bool [link xml_attribute::set_value set_value](float rhs);
- bool [link xml_attribute::set_value set_value](bool rhs);
- bool [link xml_attribute::set_value set_value](long long rhs);
- bool [link xml_attribute::set_value set_value](unsigned long long rhs);
-
- xml_attribute& [link xml_attribute::assign operator=](const char_t* rhs);
- xml_attribute& [link xml_attribute::assign operator=](int rhs);
- xml_attribute& [link xml_attribute::assign operator=](unsigned int rhs);
- xml_attribute& [link xml_attribute::assign operator=](double rhs);
- xml_attribute& [link xml_attribute::assign operator=](float rhs);
- xml_attribute& [link xml_attribute::assign operator=](bool rhs);
- xml_attribute& [link xml_attribute::assign operator=](long long rhs);
- xml_attribute& [link xml_attribute::assign operator=](unsnigned long long rhs);
-
-class [link xml_node]
- [link xml_node::ctor xml_node]();
-
- bool [link xml_node::empty empty]() const;
- operator [link xml_node::unspecified_bool_type unspecified_bool_type]() const;
-
- bool [link xml_node::comparison operator==](const xml_node& r) const;
- bool [link xml_node::comparison operator!=](const xml_node& r) const;
- bool [link xml_node::comparison operator<](const xml_node& r) const;
- bool [link xml_node::comparison operator>](const xml_node& r) const;
- bool [link xml_node::comparison operator<=](const xml_node& r) const;
- bool [link xml_node::comparison operator>=](const xml_node& r) const;
-
- size_t [link xml_node::hash_value hash_value]() const;
-
- xml_node_type [link xml_node::type type]() const;
-
- const char_t* [link xml_node::name name]() const;
- const char_t* [link xml_node::value value]() const;
-
- xml_node [link xml_node::parent parent]() const;
- xml_node [link xml_node::first_child first_child]() const;
- xml_node [link xml_node::last_child last_child]() const;
- xml_node [link xml_node::next_sibling next_sibling]() const;
- xml_node [link xml_node::previous_sibling previous_sibling]() const;
-
- xml_attribute [link xml_node::first_attribute first_attribute]() const;
- xml_attribute [link xml_node::last_attribute last_attribute]() const;
-
- /implementation-defined type/ [link xml_node::children children]() const;
- /implementation-defined type/ [link xml_node::children children](const char_t* name) const;
- /implementation-defined type/ [link xml_node::attributes attributes]() const;
-
- xml_node [link xml_node::child child](const char_t* name) const;
- xml_attribute [link xml_node::attribute attribute](const char_t* name) const;
- xml_node [link xml_node::next_sibling_name next_sibling](const char_t* name) const;
- xml_node [link xml_node::previous_sibling_name previous_sibling](const char_t* name) const;
- xml_node [link xml_node::find_child_by_attribute find_child_by_attribute](const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
- xml_node [link xml_node::find_child_by_attribute find_child_by_attribute](const char_t* attr_name, const char_t* attr_value) const;
-
- const char_t* [link xml_node::child_value child_value]() const;
- const char_t* [link xml_node::child_value child_value](const char_t* name) const;
- xml_text [link xml_node::text text]() const;
-
- typedef xml_node_iterator [link xml_node_iterator iterator];
- iterator [link xml_node::begin begin]() const;
- iterator [link xml_node::end end]() const;
-
- typedef xml_attribute_iterator [link xml_attribute_iterator attribute_iterator];
- attribute_iterator [link xml_node::attributes_begin attributes_begin]() const;
- attribute_iterator [link xml_node::attributes_end attributes_end]() const;
-
- bool [link xml_node::traverse traverse](xml_tree_walker& walker);
-
- template <typename Predicate> xml_attribute [link xml_node::find_attribute find_attribute](Predicate pred) const;
- template <typename Predicate> xml_node [link xml_node::find_child find_child](Predicate pred) const;
- template <typename Predicate> xml_node [link xml_node::find_node find_node](Predicate pred) const;
-
- string_t [link xml_node::path path](char_t delimiter = '/') const;
- xml_node [link xml_node::first_element_by_path](const char_t* path, char_t delimiter = '/') const;
- xml_node [link xml_node::root root]() const;
- ptrdiff_t [link xml_node::offset_debug offset_debug]() const;
+class +++<a href="#xml_attribute">xml_attribute</a>+++
+ +++<a href="#xml_attribute::ctor">xml_attribute</a>+++();
+
+ bool +++<a href="#xml_attribute::empty">empty</a>+++() const;
+ operator +++<a href="#xml_attribute::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+
+ bool +++<a href="#xml_attribute::comparison">operator==</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator!=</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator<</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator></a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator<=</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator>=</a>+++(const xml_attribute& r) const;
+
+ size_t +++<a href="#xml_attribute::hash_value">hash_value</a>+++() const;
+
+ xml_attribute +++<a href="#xml_attribute::next_attribute">next_attribute</a>+++() const;
+ xml_attribute +++<a href="#xml_attribute::previous_attribute">previous_attribute</a>+++() const;
+
+ const char_t* +++<a href="#xml_attribute::name">name</a>+++() const;
+ const char_t* +++<a href="#xml_attribute::value">value</a>+++() const;
+
+ const char_t* +++<a href="#xml_attribute::as_string">as_string</a>+++(const char_t* def = "") const;
+ int +++<a href="#xml_attribute::as_int">as_int</a>+++(int def = 0) const;
+ unsigned int +++<a href="#xml_attribute::as_uint">as_uint</a>+++(unsigned int def = 0) const;
+ double +++<a href="#xml_attribute::as_double">as_double</a>+++(double def = 0) const;
+ float +++<a href="#xml_attribute::as_float">as_float</a>+++(float def = 0) const;
+ bool +++<a href="#xml_attribute::as_bool">as_bool</a>+++(bool def = false) const;
+ long long +++<a href="#xml_attribute::as_llong">as_llong</a>+++(long long def = 0) const;
+ unsigned long long +++<a href="#xml_attribute::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
+
+ bool +++<a href="#xml_attribute::set_name">set_name</a>+++(const char_t* rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(const char_t* rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(int rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(unsigned int rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(double rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(float rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(bool rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(long long rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(unsigned long long rhs);
+
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(const char_t* rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(int rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(unsigned int rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(double rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(float rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(bool rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(long long rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(unsnigned long long rhs);
+
+class +++<a href="#xml_node">xml_node</a>+++
+ +++<a href="#xml_node::ctor">xml_node</a>+++();
+
+ bool +++<a href="#xml_node::empty">empty</a>+++() const;
+ operator +++<a href="#xml_node::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+
+ bool +++<a href="#xml_node::comparison">operator==</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator!=</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator<</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator></a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator<=</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator>=</a>+++(const xml_node& r) const;
+
+ size_t +++<a href="#xml_node::hash_value">hash_value</a>+++() const;
+
+ xml_node_type +++<a href="#xml_node::type">type</a>+++() const;
+
+ const char_t* +++<a href="#xml_node::name">name</a>+++() const;
+ const char_t* +++<a href="#xml_node::value">value</a>+++() const;
+
+ xml_node +++<a href="#xml_node::parent">parent</a>+++() const;
+ xml_node +++<a href="#xml_node::first_child">first_child</a>+++() const;
+ xml_node +++<a href="#xml_node::last_child">last_child</a>+++() const;
+ xml_node +++<a href="#xml_node::next_sibling">next_sibling</a>+++() const;
+ xml_node +++<a href="#xml_node::previous_sibling">previous_sibling</a>+++() const;
+
+ xml_attribute +++<a href="#xml_node::first_attribute">first_attribute</a>+++() const;
+ xml_attribute +++<a href="#xml_node::last_attribute">last_attribute</a>+++() const;
+
+ /implementation-defined type/ +++<a href="#xml_node::children">children</a>+++() const;
+ /implementation-defined type/ +++<a href="#xml_node::children">children</a>+++(const char_t* name) const;
+ /implementation-defined type/ +++<a href="#xml_node::attributes">attributes</a>+++() const;
+
+ xml_node +++<a href="#xml_node::child">child</a>+++(const char_t* name) const;
+ xml_attribute +++<a href="#xml_node::attribute">attribute</a>+++(const char_t* name) const;
+ xml_node +++<a href="#xml_node::next_sibling_name">next_sibling</a>+++(const char_t* name) const;
+ xml_node +++<a href="#xml_node::previous_sibling_name">previous_sibling</a>+++(const char_t* name) const;
+ xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
+ xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* attr_name, const char_t* attr_value) const;
+
+ const char_t* +++<a href="#xml_node::child_value">child_value</a>+++() const;
+ const char_t* +++<a href="#xml_node::child_value">child_value</a>+++(const char_t* name) const;
+ xml_text +++<a href="#xml_node::text">text</a>+++() const;
+
+ typedef xml_node_iterator +++<a href="#xml_node_iterator">iterator</a>+++;
+ iterator +++<a href="#xml_node::begin">begin</a>+++() const;
+ iterator +++<a href="#xml_node::end">end</a>+++() const;
+
+ typedef xml_attribute_iterator +++<a href="#xml_attribute_iterator">attribute_iterator</a>+++;
+ attribute_iterator +++<a href="#xml_node::attributes_begin">attributes_begin</a>+++() const;
+ attribute_iterator +++<a href="#xml_node::attributes_end">attributes_end</a>+++() const;
+
+ bool +++<a href="#xml_node::traverse">traverse</a>+++(xml_tree_walker& walker);
+
+ template <typename Predicate> xml_attribute +++<a href="#xml_node::find_attribute">find_attribute</a>+++(Predicate pred) const;
+ template <typename Predicate> xml_node +++<a href="#xml_node::find_child">find_child</a>+++(Predicate pred) const;
+ template <typename Predicate> xml_node +++<a href="#xml_node::find_node">find_node</a>+++(Predicate pred) const;
+
+ string_t +++<a href="#xml_node::path">path</a>+++(char_t delimiter = '/') const;
+ xml_node +++<a href="#xml_node::first_element_by_path">xml_node::first_element_by_path</a>+++(const char_t* path, char_t delimiter = '/') const;
+ xml_node +++<a href="#xml_node::root">root</a>+++() const;
+ ptrdiff_t +++<a href="#xml_node::offset_debug">offset_debug</a>+++() const;
- bool [link xml_node::set_name set_name](const char_t* rhs);
- bool [link xml_node::set_value set_value](const char_t* rhs);
+ bool +++<a href="#xml_node::set_name">set_name</a>+++(const char_t* rhs);
+ bool +++<a href="#xml_node::set_value">set_value</a>+++(const char_t* rhs);
- xml_attribute [link xml_node::append_attribute append_attribute](const char_t* name);
- xml_attribute [link xml_node::prepend_attribute prepend_attribute](const char_t* name);
- xml_attribute [link xml_node::insert_attribute_after insert_attribute_after](const char_t* name, const xml_attribute& attr);
- xml_attribute [link xml_node::insert_attribute_before insert_attribute_before](const char_t* name, const xml_attribute& attr);
-
- xml_node [link xml_node::append_child append_child](xml_node_type type = node_element);
- xml_node [link xml_node::prepend_child prepend_child](xml_node_type type = node_element);
- xml_node [link xml_node::insert_child_after insert_child_after](xml_node_type type, const xml_node& node);
- xml_node [link xml_node::insert_child_before insert_child_before](xml_node_type type, const xml_node& node);
-
- xml_node [link xml_node::append_child append_child](const char_t* name);
- xml_node [link xml_node::prepend_child prepend_child](const char_t* name);
- xml_node [link xml_node::insert_child_after insert_child_after](const char_t* name, const xml_node& node);
- xml_node [link xml_node::insert_child_before insert_child_before](const char_t* name, const xml_node& node);
-
- xml_attribute [link xml_node::append_copy append_copy](const xml_attribute& proto);
- xml_attribute [link xml_node::prepend_copy prepend_copy](const xml_attribute& proto);
- xml_attribute [link xml_node::insert_copy_after insert_copy_after](const xml_attribute& proto, const xml_attribute& attr);
- xml_attribute [link xml_node::insert_copy_before insert_copy_before](const xml_attribute& proto, const xml_attribute& attr);
-
- xml_node [link xml_node::append_copy append_copy](const xml_node& proto);
- xml_node [link xml_node::prepend_copy prepend_copy](const xml_node& proto);
- xml_node [link xml_node::insert_copy_after insert_copy_after](const xml_node& proto, const xml_node& node);
- xml_node [link xml_node::insert_copy_before insert_copy_before](const xml_node& proto, const xml_node& node);
-
- xml_node [link xml_node::append_move append_move](const xml_node& moved);
- xml_node [link xml_node::prepend_move prepend_move](const xml_node& moved);
- xml_node [link xml_node::insert_move_after insert_move_after](const xml_node& moved, const xml_node& node);
- xml_node [link xml_node::insert_move_before insert_move_before](const xml_node& moved, const xml_node& node);
+ xml_attribute +++<a href="#xml_node::append_attribute">append_attribute</a>+++(const char_t* name);
+ xml_attribute +++<a href="#xml_node::prepend_attribute">prepend_attribute</a>+++(const char_t* name);
+ xml_attribute +++<a href="#xml_node::insert_attribute_after">insert_attribute_after</a>+++(const char_t* name, const xml_attribute& attr);
+ xml_attribute +++<a href="#xml_node::insert_attribute_before">insert_attribute_before</a>+++(const char_t* name, const xml_attribute& attr);
+
+ xml_node +++<a href="#xml_node::append_child">append_child</a>+++(xml_node_type type = node_element);
+ xml_node +++<a href="#xml_node::prepend_child">prepend_child</a>+++(xml_node_type type = node_element);
+ xml_node +++<a href="#xml_node::insert_child_after">insert_child_after</a>+++(xml_node_type type, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_child_before">insert_child_before</a>+++(xml_node_type type, const xml_node& node);
+
+ xml_node +++<a href="#xml_node::append_child">append_child</a>+++(const char_t* name);
+ xml_node +++<a href="#xml_node::prepend_child">prepend_child</a>+++(const char_t* name);
+ xml_node +++<a href="#xml_node::insert_child_after">insert_child_after</a>+++(const char_t* name, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_child_before">insert_child_before</a>+++(const char_t* name, const xml_node& node);
+
+ xml_attribute +++<a href="#xml_node::append_copy">append_copy</a>+++(const xml_attribute& proto);
+ xml_attribute +++<a href="#xml_node::prepend_copy">prepend_copy</a>+++(const xml_attribute& proto);
+ xml_attribute +++<a href="#xml_node::insert_copy_after">insert_copy_after</a>+++(const xml_attribute& proto, const xml_attribute& attr);
+ xml_attribute +++<a href="#xml_node::insert_copy_before">insert_copy_before</a>+++(const xml_attribute& proto, const xml_attribute& attr);
+
+ xml_node +++<a href="#xml_node::append_copy">append_copy</a>+++(const xml_node& proto);
+ xml_node +++<a href="#xml_node::prepend_copy">prepend_copy</a>+++(const xml_node& proto);
+ xml_node +++<a href="#xml_node::insert_copy_after">insert_copy_after</a>+++(const xml_node& proto, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_copy_before">insert_copy_before</a>+++(const xml_node& proto, const xml_node& node);
+
+ xml_node +++<a href="#xml_node::append_move">append_move</a>+++(const xml_node& moved);
+ xml_node +++<a href="#xml_node::prepend_move">prepend_move</a>+++(const xml_node& moved);
+ xml_node +++<a href="#xml_node::insert_move_after">insert_move_after</a>+++(const xml_node& moved, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_move_before">insert_move_before</a>+++(const xml_node& moved, const xml_node& node);
- bool [link xml_node::remove_attribute remove_attribute](const xml_attribute& a);
- bool [link xml_node::remove_attribute remove_attribute](const char_t* name);
- bool [link xml_node::remove_child remove_child](const xml_node& n);
- bool [link xml_node::remove_child remove_child](const char_t* name);
+ bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const xml_attribute& a);
+ bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const char_t* name);
+ bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const xml_node& n);
+ bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const char_t* name);
- xml_parse_result [link xml_node::append_buffer append_buffer](const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_node::append_buffer">append_buffer</a>+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- void [link xml_node::print print](xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
- void [link xml_node::print_stream print](std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
- void [link xml_node::print_stream print](std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
+ void +++<a href="#xml_node::print">print</a>+++(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
+ void +++<a href="#xml_node::print_stream">print</a>+++(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
+ void +++<a href="#xml_node::print_stream">print</a>+++(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
- xpath_node [link xml_node::select_node select_node](const char_t* query, xpath_variable_set* variables = 0) const;
- xpath_node [link xml_node::select_node_precomp select_node](const xpath_query& query) const;
- xpath_node_set [link xml_node::select_nodes select_nodes](const char_t* query, xpath_variable_set* variables = 0) const;
- xpath_node_set [link xml_node::select_nodes_precomp select_nodes](const xpath_query& query) const;
+ xpath_node +++<a href="#xml_node::select_node">select_node</a>+++(const char_t* query, xpath_variable_set* variables = 0) const;
+ xpath_node +++<a href="#xml_node::select_node_precomp">select_node</a>+++(const xpath_query& query) const;
+ xpath_node_set +++<a href="#xml_node::select_nodes">select_nodes</a>+++(const char_t* query, xpath_variable_set* variables = 0) const;
+ xpath_node_set +++<a href="#xml_node::select_nodes_precomp">select_nodes</a>+++(const xpath_query& query) const;
-class [link xml_document]
- [link xml_document::ctor xml_document]();
- ~[link xml_document::dtor xml_document]();
+class +++<a href="#xml_document">xml_document</a>+++
+ +++<a href="#xml_document::ctor">xml_document</a>+++();
+ ~+++<a href="#xml_document::dtor">xml_document</a>+++();
- void [link xml_document::reset reset]();
- void [link xml_document::reset reset](const xml_document& proto);
+ void +++<a href="#xml_document::reset">reset</a>+++();
+ void +++<a href="#xml_document::reset">reset</a>+++(const xml_document& proto);
- xml_parse_result [link xml_document::load_stream load](std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result [link xml_document::load_stream load](std::wistream& stream, unsigned int options = parse_default);
+ xml_parse_result +++<a href="#xml_document::load_stream">load</a>+++(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_stream">load</a>+++(std::wistream& stream, unsigned int options = parse_default);
- xml_parse_result [link xml_document::load_string load_string](const char_t* contents, unsigned int options = parse_default);
+ xml_parse_result +++<a href="#xml_document::load_string">load_string</a>+++(const char_t* contents, unsigned int options = parse_default);
- xml_parse_result [link xml_document::load_file load_file](const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result [link xml_document::load_file_wide load_file](const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_file">load_file</a>+++(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_file_wide">load_file</a>+++(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result [link xml_document::load_buffer load_buffer](const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result [link xml_document::load_buffer_inplace load_buffer_inplace](void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result [link xml_document::load_buffer_inplace_own load_buffer_inplace_own](void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_buffer">load_buffer</a>+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_buffer_inplace">load_buffer_inplace</a>+++(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_buffer_inplace_own">load_buffer_inplace_own</a>+++(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- bool [link xml_document::save_file save_file](const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
- bool [link xml_document::save_file_wide save_file](const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+ bool +++<a href="#xml_document::save_file">save_file</a>+++(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+ bool +++<a href="#xml_document::save_file_wide">save_file</a>+++(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
- void [link xml_document::save_stream save](std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
- void [link xml_document::save_stream save](std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
+ void +++<a href="#xml_document::save_stream">save</a>+++(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+ void +++<a href="#xml_document::save_stream">save</a>+++(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
- void [link xml_document::save save](xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+ void +++<a href="#xml_document::save">save</a>+++(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
- xml_node [link xml_document::document_element document_element]() const;
+ xml_node +++<a href="#xml_document::document_element">document_element</a>+++() const;
-struct [link xml_parse_result]
- xml_parse_status [link xml_parse_result::status status];
- ptrdiff_t [link xml_parse_result::offset offset];
- xml_encoding [link xml_parse_result::encoding encoding];
+struct +++<a href="#xml_parse_result">xml_parse_result</a>+++
+ xml_parse_status +++<a href="#xml_parse_result::status">status</a>+++;
+ ptrdiff_t +++<a href="#xml_parse_result::offset">offset</a>+++;
+ xml_encoding +++<a href="#xml_parse_result::encoding">encoding</a>+++;
- operator [link xml_parse_result::bool bool]() const;
- const char* [link xml_parse_result::description description]() const;
+ operator +++<a href="#xml_parse_result::bool">bool</a>+++() const;
+ const char* +++<a href="#xml_parse_result::description">description</a>+++() const;
-class [link xml_node_iterator]
-class [link xml_attribute_iterator]
+class +++<a href="#xml_node_iterator">xml_node_iterator</a>+++
+class +++<a href="#xml_attribute_iterator">xml_attribute_iterator</a>+++
-class [link xml_tree_walker]
- virtual bool [link xml_tree_walker::begin begin](xml_node& node);
- virtual bool [link xml_tree_walker::for_each for_each](xml_node& node) = 0;
- virtual bool [link xml_tree_walker::end end](xml_node& node);
+class +++<a href="#xml_tree_walker">xml_tree_walker</a>+++
+ virtual bool +++<a href="#xml_tree_walker::begin">begin</a>+++(xml_node& node);
+ virtual bool +++<a href="#xml_tree_walker::for_each">for_each</a>+++(xml_node& node) = 0;
+ virtual bool +++<a href="#xml_tree_walker::end">end</a>+++(xml_node& node);
- int [link xml_tree_walker::depth depth]() const;
+ int +++<a href="#xml_tree_walker::depth">depth</a>+++() const;
-class [link xml_text]
- bool [link xml_text::empty empty]() const;
- operator [link xml_text::unspecified_bool_type]() const;
+class +++<a href="#xml_text">xml_text</a>+++
+ bool +++<a href="#xml_text::empty">empty</a>+++() const;
+ operator +++<a href="#xml_text::unspecified_bool_type">xml_text::unspecified_bool_type</a>+++() const;
- const char_t* [link xml_text::get]() const;
+ const char_t* +++<a href="#xml_text::get">xml_text::get</a>+++() const;
- const char_t* [link xml_text::as_string as_string](const char_t* def = "") const;
- int [link xml_text::as_int as_int](int def = 0) const;
- unsigned int [link xml_text::as_uint as_uint](unsigned int def = 0) const;
- double [link xml_text::as_double as_double](double def = 0) const;
- float [link xml_text::as_float as_float](float def = 0) const;
- bool [link xml_text::as_bool as_bool](bool def = false) const;
- long long [link xml_text::as_llong as_llong](long long def = 0) const;
- unsigned long long [link xml_text::as_ullong as_ullong](unsigned long long def = 0) const;
+ const char_t* +++<a href="#xml_text::as_string">as_string</a>+++(const char_t* def = "") const;
+ int +++<a href="#xml_text::as_int">as_int</a>+++(int def = 0) const;
+ unsigned int +++<a href="#xml_text::as_uint">as_uint</a>+++(unsigned int def = 0) const;
+ double +++<a href="#xml_text::as_double">as_double</a>+++(double def = 0) const;
+ float +++<a href="#xml_text::as_float">as_float</a>+++(float def = 0) const;
+ bool +++<a href="#xml_text::as_bool">as_bool</a>+++(bool def = false) const;
+ long long +++<a href="#xml_text::as_llong">as_llong</a>+++(long long def = 0) const;
+ unsigned long long +++<a href="#xml_text::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
- bool [link xml_text::set set](const char_t* rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs);
- bool [link xml_text::set set](int rhs);
- bool [link xml_text::set set](unsigned int rhs);
- bool [link xml_text::set set](double rhs);
- bool [link xml_text::set set](float rhs);
- bool [link xml_text::set set](bool rhs);
- bool [link xml_text::set set](long long rhs);
- bool [link xml_text::set set](unsigned long long rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(int rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(unsigned int rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(double rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(float rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(bool rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(long long rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(unsigned long long rhs);
- xml_text& [link xml_text::assign operator=](const char_t* rhs);
- xml_text& [link xml_text::assign operator=](int rhs);
- xml_text& [link xml_text::assign operator=](unsigned int rhs);
- xml_text& [link xml_text::assign operator=](double rhs);
- xml_text& [link xml_text::assign operator=](float rhs);
- xml_text& [link xml_text::assign operator=](bool rhs);
- xml_text& [link xml_text::assign operator=](long long rhs);
- xml_text& [link xml_text::assign operator=](unsigned long long rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(const char_t* rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(int rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(unsigned int rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(double rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(float rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(bool rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(long long rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(unsigned long long rhs);
- xml_node [link xml_text::data data]() const;
+ xml_node +++<a href="#xml_text::data">data</a>+++() const;
-class [link xml_writer]
- virtual void [link xml_writer::write write](const void* data, size_t size) = 0;
+class +++<a href="#xml_writer">xml_writer</a>+++
+ virtual void +++<a href="#xml_writer::write">write</a>+++(const void* data, size_t size) = 0;
-class [link xml_writer_file]: public xml_writer
- [link xml_writer_file](void* file);
+class +++<a href="#xml_writer_file">xml_writer_file</a>+++: public xml_writer
+ +++<a href="#xml_writer_file">xml_writer_file</a>+++(void* file);
-class [link xml_writer_stream]: public xml_writer
- [link xml_writer_stream](std::ostream& stream);
- [link xml_writer_stream](std::wostream& stream);
+class +++<a href="#xml_writer_stream">xml_writer_stream</a>+++: public xml_writer
+ +++<a href="#xml_writer_stream">xml_writer_stream</a>+++(std::ostream& stream);
+ +++<a href="#xml_writer_stream">xml_writer_stream</a>+++(std::wostream& stream);
-struct [link xpath_parse_result]
- const char* [link xpath_parse_result::error error];
- ptrdiff_t [link xpath_parse_result::offset offset];
+struct +++<a href="#xpath_parse_result">xpath_parse_result</a>+++
+ const char* +++<a href="#xpath_parse_result::error">error</a>+++;
+ ptrdiff_t +++<a href="#xpath_parse_result::offset">offset</a>+++;
- operator [link xpath_parse_result::bool bool]() const;
- const char* [link xpath_parse_result::description description]() const;
+ operator +++<a href="#xpath_parse_result::bool">bool</a>+++() const;
+ const char* +++<a href="#xpath_parse_result::description">description</a>+++() const;
-class [link xpath_query]
- explicit [link xpath_query::ctor xpath_query](const char_t* query, xpath_variable_set* variables = 0);
+class +++<a href="#xpath_query">xpath_query</a>+++
+ explicit +++<a href="#xpath_query::ctor">xpath_query</a>+++(const char_t* query, xpath_variable_set* variables = 0);
- bool [link xpath_query::evaluate_boolean evaluate_boolean](const xpath_node& n) const;
- double [link xpath_query::evaluate_number evaluate_number](const xpath_node& n) const;
- string_t [link xpath_query::evaluate_string evaluate_string](const xpath_node& n) const;
- size_t [link xpath_query::evaluate_string_buffer evaluate_string](char_t* buffer, size_t capacity, const xpath_node& n) const;
- xpath_node_set [link xpath_query::evaluate_node_set evaluate_node_set](const xpath_node& n) const;
- xpath_node [link xpath_query::evaluate_node evaluate_node](const xpath_node& n) const;
+ bool +++<a href="#xpath_query::evaluate_boolean">evaluate_boolean</a>+++(const xpath_node& n) const;
+ double +++<a href="#xpath_query::evaluate_number">evaluate_number</a>+++(const xpath_node& n) const;
+ string_t +++<a href="#xpath_query::evaluate_string">evaluate_string</a>+++(const xpath_node& n) const;
+ size_t +++<a href="#xpath_query::evaluate_string_buffer">evaluate_string</a>+++(char_t* buffer, size_t capacity, const xpath_node& n) const;
+ xpath_node_set +++<a href="#xpath_query::evaluate_node_set">evaluate_node_set</a>+++(const xpath_node& n) const;
+ xpath_node +++<a href="#xpath_query::evaluate_node">evaluate_node</a>+++(const xpath_node& n) const;
- xpath_value_type [link xpath_query::return_type return_type]() const;
+ xpath_value_type +++<a href="#xpath_query::return_type">return_type</a>+++() const;
- const xpath_parse_result& [link xpath_query::result result]() const;
- operator [link xpath_query::unspecified_bool_type unspecified_bool_type]() const;
+ const xpath_parse_result& +++<a href="#xpath_query::result">result</a>+++() const;
+ operator +++<a href="#xpath_query::unspecified_bool_type">unspecified_bool_type</a>+++() const;
-class [link xpath_exception]: public std::exception
- virtual const char* [link xpath_exception::what what]() const throw();
+class +++<a href="#xpath_exception">xpath_exception</a>+++: public std::exception
+ virtual const char* +++<a href="#xpath_exception::what">what</a>+++() const throw();
- const xpath_parse_result& [link xpath_exception::result result]() const;
+ const xpath_parse_result& +++<a href="#xpath_exception::result">result</a>+++() const;
-class [link xpath_node]
- [link xpath_node::ctor xpath_node]();
- [link xpath_node::ctor xpath_node](const xml_node& node);
- [link xpath_node::ctor xpath_node](const xml_attribute& attribute, const xml_node& parent);
+class +++<a href="#xpath_node">xpath_node</a>+++
+ +++<a href="#xpath_node::ctor">xpath_node</a>+++();
+ +++<a href="#xpath_node::ctor">xpath_node</a>+++(const xml_node& node);
+ +++<a href="#xpath_node::ctor">xpath_node</a>+++(const xml_attribute& attribute, const xml_node& parent);
- xml_node [link xpath_node::node node]() const;
- xml_attribute [link xpath_node::attribute attribute]() const;
- xml_node [link xpath_node::parent parent]() const;
+ xml_node +++<a href="#xpath_node::node">node</a>+++() const;
+ xml_attribute +++<a href="#xpath_node::attribute">attribute</a>+++() const;
+ xml_node +++<a href="#xpath_node::parent">parent</a>+++() const;
- operator [link xpath_node::unspecified_bool_type unspecified_bool_type]() const;
- bool [link xpath_node::comparison operator==](const xpath_node& n) const;
- bool [link xpath_node::comparison operator!=](const xpath_node& n) const;
+ operator +++<a href="#xpath_node::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+ bool +++<a href="#xpath_node::comparison">operator==</a>+++(const xpath_node& n) const;
+ bool +++<a href="#xpath_node::comparison">operator!=</a>+++(const xpath_node& n) const;
-class [link xpath_node_set]
- [link xpath_node_set::ctor xpath_node_set]();
- [link xpath_node_set::ctor xpath_node_set](const_iterator begin, const_iterator end, type_t type = type_unsorted);
+class +++<a href="#xpath_node_set">xpath_node_set</a>+++
+ +++<a href="#xpath_node_set::ctor">xpath_node_set</a>+++();
+ +++<a href="#xpath_node_set::ctor">xpath_node_set</a>+++(const_iterator begin, const_iterator end, type_t type = type_unsorted);
- typedef const xpath_node* [link xpath_node_set::const_iterator const_iterator];
- const_iterator [link xpath_node_set::begin begin]() const;
- const_iterator [link xpath_node_set::end end]() const;
+ typedef const xpath_node* +++<a href="#xpath_node_set::const_iterator">const_iterator</a>+++;
+ const_iterator +++<a href="#xpath_node_set::begin">begin</a>+++() const;
+ const_iterator +++<a href="#xpath_node_set::end">end</a>+++() const;
- const xpath_node& [link xpath_node_set::index operator[]](size_t index) const;
- size_t [link xpath_node_set::size size]() const;
- bool [link xpath_node_set::empty empty]() const;
+ const xpath_node& +++<a href="#xpath_node_set::index">operator[</a>+++](size_t index) const;
+ size_t +++<a href="#xpath_node_set::size">size</a>+++() const;
+ bool +++<a href="#xpath_node_set::empty">empty</a>+++() const;
- xpath_node [link xpath_node_set::first first]() const;
+ xpath_node +++<a href="#xpath_node_set::first">first</a>+++() const;
- enum type_t {[link xpath_node_set::type_unsorted type_unsorted], [link xpath_node_set::type_sorted type_sorted], [link xpath_node_set::type_sorted_reverse type_sorted_reverse]};
- type_t [link xpath_node_set::type type]() const;
- void [link xpath_node_set::sort sort](bool reverse = false);
+ enum type_t {+++<a href="#xpath_node_set::type_unsorted">type_unsorted</a>+++, +++<a href="#xpath_node_set::type_sorted">type_sorted</a>+++, +++<a href="#xpath_node_set::type_sorted_reverse">type_sorted_reverse</a>+++};
+ type_t +++<a href="#xpath_node_set::type">type</a>+++() const;
+ void +++<a href="#xpath_node_set::sort">sort</a>+++(bool reverse = false);
-class [link xpath_variable]
- const char_t* [link xpath_variable::name name]() const;
- xpath_value_type [link xpath_variable::type type]() const;
+class +++<a href="#xpath_variable">xpath_variable</a>+++
+ const char_t* +++<a href="#xpath_variable::name">name</a>+++() const;
+ xpath_value_type +++<a href="#xpath_variable::type">type</a>+++() const;
- bool [link xpath_variable::get_boolean get_boolean]() const;
- double [link xpath_variable::get_number get_number]() const;
- const char_t* [link xpath_variable::get_string get_string]() const;
- const xpath_node_set& [link xpath_variable::get_node_set get_node_set]() const;
+ bool +++<a href="#xpath_variable::get_boolean">get_boolean</a>+++() const;
+ double +++<a href="#xpath_variable::get_number">get_number</a>+++() const;
+ const char_t* +++<a href="#xpath_variable::get_string">get_string</a>+++() const;
+ const xpath_node_set& +++<a href="#xpath_variable::get_node_set">get_node_set</a>+++() const;
- bool [link xpath_variable::set set](bool value);
- bool [link xpath_variable::set set](double value);
- bool [link xpath_variable::set set](const char_t* value);
- bool [link xpath_variable::set set](const xpath_node_set& value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(bool value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(double value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(const char_t* value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(const xpath_node_set& value);
-class [link xpath_variable_set]
- xpath_variable* [link xpath_variable_set::add add](const char_t* name, xpath_value_type type);
+class +++<a href="#xpath_variable_set">xpath_variable_set</a>+++
+ xpath_variable* +++<a href="#xpath_variable_set::add">add</a>+++(const char_t* name, xpath_value_type type);
- bool [link xpath_variable_set::set set](const char_t* name, bool value);
- bool [link xpath_variable_set::set set](const char_t* name, double value);
- bool [link xpath_variable_set::set set](const char_t* name, const char_t* value);
- bool [link xpath_variable_set::set set](const char_t* name, const xpath_node_set& value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, bool value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, double value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, const char_t* value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, const xpath_node_set& value);
- xpath_variable* [link xpath_variable_set::get get](const char_t* name);
- const xpath_variable* [link xpath_variable_set::get get](const char_t* name) const;
+ xpath_variable* +++<a href="#xpath_variable_set::get">get</a>+++(const char_t* name);
+ const xpath_variable* +++<a href="#xpath_variable_set::get">get</a>+++(const char_t* name) const;
----
Functions:
[source,subs="+macros"]
----
-std::string [link as_utf8](const wchar_t* str);
-std::string [link as_utf8](const std::wstring& str);
-std::wstring [link as_wide](const char* str);
-std::wstring [link as_wide](const std::string& str);
-void [link set_memory_management_functions](allocation_function allocate, deallocation_function deallocate);
-allocation_function [link get_memory_allocation_function]();
-deallocation_function [link get_memory_deallocation_function]();
+std::string +++<a href="#as_utf8">as_utf8</a>+++(const wchar_t* str);
+std::string +++<a href="#as_utf8">as_utf8</a>+++(const std::wstring& str);
+std::wstring +++<a href="#as_wide">as_wide</a>+++(const char* str);
+std::wstring +++<a href="#as_wide">as_wide</a>+++(const std::string& str);
+void +++<a href="#set_memory_management_functions">set_memory_management_functions</a>+++(allocation_function allocate, deallocation_function deallocate);
+allocation_function +++<a href="#get_memory_allocation_function">get_memory_allocation_function</a>+++();
+deallocation_function +++<a href="#get_memory_deallocation_function">get_memory_deallocation_function</a>+++();
----