Compare commits

...

41 commits

Author SHA1 Message Date
Arseny Kapoulkine
1dc3266fff docs: Add missing documentation for xml_node::attribute with hint
The feature was added in 2015 but somehow was never documented.
2022-11-08 16:49:34 -08:00
Arseny Kapoulkine
cb217f5a85
Merge pull request #530 from zeux/snprintf
Fix Xcode 14 sprintf deprecation warning
2022-11-06 15:09:53 -08:00
Arseny Kapoulkine
e11e0c965f Fix comment typo. 2022-11-06 13:47:53 -08:00
Arseny Kapoulkine
b6b747244e Adjust the workaround for -pedantic mode and fix tests 2022-11-06 10:21:35 -08:00
Arseny Kapoulkine
8be081fbbe Fix Xcode 14 sprintf deprecation warning
We use snprintf when stdc is set to C++11, however in C++98 mode we can't use variadic macros,
and Xcode 14 complains about the use of sprintf.

It should be safe however to use variadic macros on any remotely recent version of clang on Apple,
unless -pedantic is defined which warns against the use of variadic macros in C++98 mode...

This change fixes the problem for the builds that don't specify -pedantic, which is a problem for
another day.
2022-11-06 10:16:21 -08:00
Arseny Kapoulkine
a0e0643363
Merge pull request #526 from zeux/newver
Prepare for 1.13 release
2022-10-28 16:53:25 -07:00
Arseny Kapoulkine
3bd1f452b5 Fix version check in test 2022-10-20 20:23:26 -07:00
Arseny Kapoulkine
c5b288d91a Update HTML documentation 2022-10-20 20:20:45 -07:00
Arseny Kapoulkine
0ef3da1e6e Update release notes and manual for 1.13
This includes a previously unnoticed link fix for xml_text::set
2022-10-20 20:18:08 -07:00
Arseny Kapoulkine
76dcd89427 Update version number in preparation for 1.13 2022-10-20 20:08:52 -07:00
Arseny Kapoulkine
43ef7e25d9
Merge pull request #525 from bruxisma/master
Fix exported symbols under clang-cl (Closes #503)
2022-10-20 19:49:48 -07:00
Izzy Muerte
ab8af53059 Fix exported symbols under clang-cl (Closes #503)
This also turns the define for PUGIXML_API into an `$<IF:>`, instead of an
`$<IF:>` with an empty true condition. If this is inadequate, I will
undo it, and place them on separate lines as they were before, but will
most likely use an inverse `$<NOT:>` instead of an `$<IF:>`.
2022-10-20 13:35:49 -07:00
Arseny Kapoulkine
86c9105154
Merge pull request #523 from zeux/ferrh
Fix error handling in xml_document::save_file
2022-10-09 09:08:50 -07:00
Arseny Kapoulkine
444963e269 Fix error handling in xml_document::save_file
There were two conditions under which xml_document::save_file could
previously return true even though the saving failed:

- The last write to the file was buffered in stdio buffer, and it's that
  last write that would fail due to lack of disk space
- The data has been written correctly but fclose failed to update file
  metadata, which can result in truncated size / missing inode updates.

This change fixes both by adjusting save_file to fflush before the check,
and also checking fclose results. Note that while fflush here is
technically redundant, because it's implied by fclose, we must check
ferror explicitly anyway, and so it feels a little cleaner to do most of
the error handling in save_file_impl, so that the changes of fclose()
failing are very slim.

Of course, neither change guarantees that the contents of the file are
going to be safe on disk following a power failure.
2022-10-07 22:13:04 -07:00
Arseny Kapoulkine
0cb4f02579 Final tweaks after #522
This cleans up xml_attribute::set_value to be uniform wrt
xml_node::set_value and xml_text::set_value - for now we duplicate the
body since the logic is trivial and this keeps debug performance
excellent.
2022-10-07 21:46:27 -07:00
Arseny Kapoulkine
c342266fae
Merge pull request #522 from Ferenc-/followup-on-pr-490
Followup on pr 490
2022-10-07 21:42:41 -07:00
Ferenc Géczi
39e169285c Add test for xml_attribute::set_value with size argument 2022-09-29 00:00:00 +00:00
Ferenc Géczi
1905284494 Add test for xml_node::set_value with size argument 2022-09-29 00:00:00 +00:00
Ferenc Géczi
d359402311 Add xml_text::set test with size set to substring 2022-09-29 00:00:00 +00:00
Ferenc Géczi
09e7cc9b1c Add test for xml_text::set with size argument 2022-09-29 00:00:00 +00:00
Ferenc Géczi
f327371219 Add overloads with size_t type argument
* xml_node::set_value(const char_t* rhs, size_t sz)
* xml_text::set(const char_t* rhs, size_t sz)

Signed-off-by: Ferenc Géczi <ferenc.gm@gmail.com>
2022-09-29 18:26:05 +00:00
Arseny Kapoulkine
bcf483c3b7
Merge pull request #492 from KDAB/fix-default-visibility
Correctly set default visibility on non-windows compilers
2022-09-27 12:53:06 -07:00
Milian Wolff
173a263490 Correctly set default visibility on non-windows compilers
This fixes compilation of pugixml with -fvisibility=hidden. Without
this patch, one would get lots of unresolved symbols when consuming
pugixml as a shared library.
2022-09-25 11:37:48 +02:00
Arseny Kapoulkine
521b2cd854 Add issue templates to try to route questions to Discussions 2022-09-02 21:42:25 -07:00
Arseny Kapoulkine
27bc68ab45
Merge pull request #506 from brandl-muc/nullptr_for_msvc
Enable usage of nullptr for MSVC 16 and newer (MSVS 2010)
2022-08-04 08:46:13 -07:00
Matthäus Brandl
f7de324855 Enable usage of nullptr for MSVC 16 and newer (MSVS 2010) 2022-08-04 16:59:37 +02:00
Arseny Kapoulkine
3b5c1fb022 tests: Fix MSVC 2005 build
... I forgot we still support platforms without C99, 23 years later.
2022-07-21 21:17:17 -07:00
Arseny Kapoulkine
ab8453c572 tests: Use snprintf instead of sprintf
sprintf now results in a deprecation warning in Xcode 14 beta.
2022-07-21 20:51:26 -07:00
Arseny Kapoulkine
2639dfd053
Merge pull request #477 from zeux/compactopt
Optimize compact mode
2022-05-31 20:00:01 -05:00
Arseny Kapoulkine
0401559dde
Merge pull request #498 from zeux/fix-oom-safer
Fix memory leak during OOM in convert_buffer
2022-05-16 20:50:07 -07:00
Arseny Kapoulkine
832a4f4914 Use more idiomatic code in this codebase 2022-05-16 19:14:29 -07:00
Arseny Kapoulkine
33a75c734b Fix memory leak during OOM in convert_buffer
This is the same fix as #497, but we're using auto_deleter instead
because if allocation function throws, we can't rely on an explicit call
to deallocate.

Comes along with two tests that validate the behavior.
2022-05-16 19:12:52 -07:00
Arseny Kapoulkine
ec851bb18d
Merge pull request #497 from TodorHryn/master
Fix memory leak
2022-05-16 19:05:29 -07:00
TodorHryn
6fbf32140b Fix memory leak 2022-05-16 13:21:20 +03:00
Viktor Govako
effc46f0ed Added bool set_value(const char_t* rhs, size_t sz). 2022-04-13 12:25:01 +03:00
Arseny Kapoulkine
363ebdde91
Merge pull request #482 from zeux/fix-msvc-test
tests: Fix MSVC 2022 build
2022-02-15 21:12:03 -08:00
Arseny Kapoulkine
c60ca94cdd tests: Fix MSVC 2022 build
Instead of trying to detect if we can safely use random shuffle simply reimplement it ourselves.
The quality of the RNG is not essential for these tests.
2022-02-15 20:23:05 -08:00
Arseny Kapoulkine
dd50fa5b45 Fix PUGIXML_VERSION macro
Also make sure the line shows up in grep when using the current version
number.

Fixes #478.
2022-02-10 08:36:19 -08:00
Arseny Kapoulkine
2fa9158b4f Optimize compact mode: xml_text 2022-02-08 23:04:31 -08:00
Arseny Kapoulkine
fad2d5e4ef Optimize compact mode: xml_attribute/xml_node implementation 2022-02-08 23:00:17 -08:00
Arseny Kapoulkine
f388c465dd Optimize compact mode: reuse access in insert/remove 2022-02-08 22:44:31 -08:00
20 changed files with 627 additions and 231 deletions

8
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View file

@ -0,0 +1,8 @@
---
name: Bug report
about: Create a report if you believe you've found a bug in this project; please use GitHub Discussions instead if you think the bug may be in your code.
title: ''
labels: bug
assignees: ''
---

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Help and support
url: https://github.com/zeux/pugixml/discussions
about: Please use GitHub Discussions if you have questions or need help.

View file

@ -0,0 +1,8 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---

View file

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.4)
project(pugixml VERSION 1.12 LANGUAGES CXX)
project(pugixml VERSION 1.13 LANGUAGES CXX)
include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
@ -101,6 +101,10 @@ if (BUILD_SHARED_LIBS)
${PROJECT_SOURCE_DIR}/src/pugixml.cpp)
add_library(pugixml::shared ALIAS pugixml-shared)
list(APPEND libs pugixml-shared)
string(CONCAT pugixml.msvc $<OR:
$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},MSVC>,
$<CXX_COMPILER_ID:MSVC>
>)
set_property(TARGET pugixml-shared PROPERTY EXPORT_NAME shared)
target_include_directories(pugixml-shared
@ -111,7 +115,8 @@ if (BUILD_SHARED_LIBS)
${PUGIXML_BUILD_DEFINES}
${PUGIXML_PUBLIC_DEFINITIONS}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:PUGIXML_API=__declspec\(dllexport\)>)
PUGIXML_API=$<IF:${pugixml.msvc},__declspec\(dllexport\),__attribute__\(\(visibility\("default"\)\)\)>
)
target_compile_options(pugixml-shared
PRIVATE
${msvc-rt-mtd-shared}

View file

@ -969,6 +969,28 @@ 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::attribute_hinted]]
`attribute` function needs to look for the target attribute by name. If a node has many attributes, finding each by name can be time consuming. If you have an idea of how attributes are ordered in the node, you can use a faster function:
[source]
----
xml_attribute xml_node::attribute(const char_t* name, xml_attribute& hint) const;
----
The extra `hint` argument is used to guess where the attribute might be, and is updated to the location of the next attribute so that if you search for multiple attributes in the right order, the performance is maximized. Note that `hint` has to be either null or has to belong to the node, otherwise the behavior is undefined.
You can use this function as follows:
[source]
----
xml_attribute hint;
xml_attribute id = node.attribute("id", hint);
xml_attribute name = node.attribute("name", hint);
xml_attribute version = node.attribute("version", hint);
----
This code is correct regardless of the order of the attributes, but it's faster if `"id"`, `"name"` and `"version"` occur in that order.
[[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:
@ -1254,6 +1276,7 @@ As discussed before, nodes can have name and value, both of which are strings. D
----
bool xml_node::set_name(const char_t* rhs);
bool xml_node::set_value(const char_t* rhs);
bool xml_node::set_value(const char_t* rhs, size_t size);
----
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.
@ -1275,6 +1298,7 @@ All attributes have name and value, both of which are strings (value may be empt
----
bool xml_attribute::set_name(const char_t* rhs);
bool xml_attribute::set_value(const char_t* rhs);
bool xml_attribute::set_value(const char_t* rhs, size_t size);
----
Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the attribute 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.
@ -1428,6 +1452,7 @@ Once you have an `xml_text` object, you can set the text contents using the foll
[source]
----
bool xml_text::set(const char_t* rhs);
bool xml_text::set(const char_t* rhs, size_t size);
----
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).
@ -2138,6 +2163,23 @@ Because of the differences in document object models, performance considerations
:!numbered:
[[v1.13]]
=== v1.13 ^2022-11-01^
Maintenance release. Changes:
* Improvements:
. `xml_attribute::set_value`, `xml_node::set_value` and `xml_text::set` now have overloads that accept pointer to non-null-terminated string and size
. Improve performance of tree traversal when using compact mode (`PUGIXML_COMPACT`)
* Bug fixes:
. Fix error handling in `xml_document::save_file` that could result in the function succeeding while running out of disk space
. Fix memory leak during error handling of some out-of-memory conditions during `xml_document::load`
* Compatibility improvements:
. Fix exported symbols in CMake DLL builds when using CMake
. Fix exported symbols in CMake shared object builds when using -fvisibility=hidden
[[v1.12]]
=== v1.12 ^2022-02-09^
@ -2798,6 +2840,7 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
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>+++(const char_t* rhs, size_t size);
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>+++(long rhs);
@ -2856,6 +2899,9 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
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_attribute +++<a href="#xml_node::attribute_hinted">attribute</a>+++(const char_t* name, xml_attribute& hint) 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;
@ -2884,6 +2930,7 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
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);
bool +++<a href="#xml_node::set_value">set_value</a>+++(const char_t* rhs, size_t size);
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);
@ -2996,16 +3043,17 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
unsigned long long +++<a href="#xml_text::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs);
bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs, size_t size);
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>+++(long rhs);
bool +++<a href="#xml_text::set">set</a>+++(unsigned long 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);
bool +++<a href="#xml_text::set_value">set</a>+++(int rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(unsigned int rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(long rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(unsigned long rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(double rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(float rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(bool rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(long long rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(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);

View file

@ -4,9 +4,9 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.17">
<meta name="generator" content="Asciidoctor 2.0.16">
<meta name="author" content="website, repository">
<title>pugixml 1.12 manual</title>
<title>pugixml 1.13 manual</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
@ -194,8 +194,7 @@ body.toc2.toc-right{padding-left:0;padding-right:20em}}
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
details{margin-left:1.25rem}
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
details>summary::-webkit-details-marker{display:none}
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent}
details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
@ -237,8 +236,9 @@ pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
table.linenotable td.code{padding-left:.75em}
table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
pre.pygments span.linenos{display:inline-block;margin-right:.75em}
table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em}
pre.pygments .lineno{border-right:1px solid;opacity:.35;display:inline-block;margin-right:.75em}
pre.pygments .lineno::before{content:"";margin-right:-.125em}
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
@ -275,7 +275,7 @@ table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-c
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd),table.stripes-even tr:nth-of-type(even),table.stripes-hover tr:hover{background:#f8f8f7}
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
@ -291,11 +291,10 @@ ol{margin-left:1.75em}
ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
ul.unstyled,ol.unstyled{margin-left:0}
li>p:empty:only-child::before{content:"";display:inline-block}
ul.checklist>li>p:first-child{margin-left:-1em}
ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
@ -338,6 +337,8 @@ sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
#footnotes .footnote:last-of-type{margin-bottom:0}
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
.gist .file-data>table td.line-data{width:99%}
div.unbreakable{page-break-inside:avoid}
.big{font-size:larger}
.small{font-size:smaller}
@ -437,24 +438,29 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
</style>
<style>
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
pre.pygments .hll { background-color: #ffffcc }
pre.pygments { background: #f8f8f8; }
pre.pygments .tok-c { color: #408080; font-style: italic } /* Comment */
pre.pygments .tok-c { color: #3D7B7B; font-style: italic } /* Comment */
pre.pygments .tok-err { border: 1px solid #FF0000 } /* Error */
pre.pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */
pre.pygments .tok-o { color: #666666 } /* Operator */
pre.pygments .tok-ch { color: #408080; font-style: italic } /* Comment.Hashbang */
pre.pygments .tok-cm { color: #408080; font-style: italic } /* Comment.Multiline */
pre.pygments .tok-cp { color: #BC7A00 } /* Comment.Preproc */
pre.pygments .tok-cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
pre.pygments .tok-c1 { color: #408080; font-style: italic } /* Comment.Single */
pre.pygments .tok-cs { color: #408080; font-style: italic } /* Comment.Special */
pre.pygments .tok-ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
pre.pygments .tok-cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
pre.pygments .tok-cp { color: #9C6500 } /* Comment.Preproc */
pre.pygments .tok-cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
pre.pygments .tok-c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
pre.pygments .tok-cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
pre.pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */
pre.pygments .tok-gr { color: #FF0000 } /* Generic.Error */
pre.pygments .tok-gr { color: #E40000 } /* Generic.Error */
pre.pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
pre.pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
pre.pygments .tok-go { color: #888888 } /* Generic.Output */
pre.pygments .tok-gi { color: #008400 } /* Generic.Inserted */
pre.pygments .tok-go { color: #717171 } /* Generic.Output */
pre.pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
pre.pygments .tok-gs { font-weight: bold } /* Generic.Strong */
pre.pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
@ -467,15 +473,15 @@ pre.pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved *
pre.pygments .tok-kt { color: #B00040 } /* Keyword.Type */
pre.pygments .tok-m { color: #666666 } /* Literal.Number */
pre.pygments .tok-s { color: #BA2121 } /* Literal.String */
pre.pygments .tok-na { color: #7D9029 } /* Name.Attribute */
pre.pygments .tok-na { color: #687822 } /* Name.Attribute */
pre.pygments .tok-nb { color: #008000 } /* Name.Builtin */
pre.pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */
pre.pygments .tok-no { color: #880000 } /* Name.Constant */
pre.pygments .tok-nd { color: #AA22FF } /* Name.Decorator */
pre.pygments .tok-ni { color: #999999; font-weight: bold } /* Name.Entity */
pre.pygments .tok-ne { color: #D2413A; font-weight: bold } /* Name.Exception */
pre.pygments .tok-ni { color: #717171; font-weight: bold } /* Name.Entity */
pre.pygments .tok-ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
pre.pygments .tok-nf { color: #0000FF } /* Name.Function */
pre.pygments .tok-nl { color: #A0A000 } /* Name.Label */
pre.pygments .tok-nl { color: #767600 } /* Name.Label */
pre.pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
pre.pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */
pre.pygments .tok-nv { color: #19177C } /* Name.Variable */
@ -492,11 +498,11 @@ pre.pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */
pre.pygments .tok-dl { color: #BA2121 } /* Literal.String.Delimiter */
pre.pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
pre.pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */
pre.pygments .tok-se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
pre.pygments .tok-se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
pre.pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */
pre.pygments .tok-si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
pre.pygments .tok-si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
pre.pygments .tok-sx { color: #008000 } /* Literal.String.Other */
pre.pygments .tok-sr { color: #BB6688 } /* Literal.String.Regex */
pre.pygments .tok-sr { color: #A45A77 } /* Literal.String.Regex */
pre.pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */
pre.pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */
pre.pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */
@ -510,7 +516,7 @@ pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
</head>
<body class="article toc2 toc-right">
<div id="header">
<h1>pugixml 1.12 manual</h1>
<h1>pugixml 1.13 manual</h1>
<div class="details">
<span id="author" class="author">website</span><br>
<span id="email" class="email"><a href="https://pugixml.org" class="bare">https://pugixml.org</a></span><br>
@ -605,6 +611,7 @@ pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
</li>
<li><a href="#changes">9. Changelog</a>
<ul class="sectlevel2">
<li><a href="#v1.13">v1.13 <sup>2022-11-01</sup></a></li>
<li><a href="#v1.12">v1.12 <sup>2022-02-09</sup></a></li>
<li><a href="#v1.11">v1.11 <sup>2020-11-26</sup></a></li>
<li><a href="#v1.10">v1.10 <sup>2019-09-15</sup></a></li>
@ -758,9 +765,9 @@ pugixml is Copyright (C) 2006-2022 Arseny Kapoulkine.</pre>
<p>You can download the latest source distribution as an archive:</p>
</div>
<div class="paragraph">
<p><a href="https://github.com/zeux/pugixml/releases/download/v1.12/pugixml-1.12.zip">pugixml-1.12.zip</a> (Windows line endings)
<p><a href="https://github.com/zeux/pugixml/releases/download/v1.13/pugixml-1.13.zip">pugixml-1.13.zip</a> (Windows line endings)
/
<a href="https://github.com/zeux/pugixml/releases/download/v1.12/pugixml-1.12.tar.gz">pugixml-1.12.tar.gz</a> (Unix line endings)</p>
<a href="https://github.com/zeux/pugixml/releases/download/v1.13/pugixml-1.13.tar.gz">pugixml-1.13.tar.gz</a> (Unix line endings)</p>
</div>
<div class="paragraph">
<p>The distribution contains library source, documentation (the manual you&#8217;re reading now and the quick start guide) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.</p>
@ -781,7 +788,7 @@ pugixml is Copyright (C) 2006-2022 Arseny Kapoulkine.</pre>
<div class="content">
<pre class="pygments highlight"><code data-lang="bash">git clone https://github.com/zeux/pugixml
cd pugixml
git checkout v1.12</code></pre>
git checkout v1.13</code></pre>
</div>
</div>
<div class="paragraph">
@ -798,7 +805,7 @@ git checkout v1.12</code></pre>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="bash">svn checkout https://github.com/zeux/pugixml/tags/v1.12 pugixml</code></pre>
<pre class="pygments highlight"><code data-lang="bash">svn checkout https://github.com/zeux/pugixml/tags/v1.13 pugixml</code></pre>
</div>
</div>
</div>
@ -846,7 +853,7 @@ git checkout v1.12</code></pre>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugixml</span><span class="tok-p">.</span><span class="tok-n">cpp</span><span class="tok-p">(</span><span class="tok-mi">3477</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">fatal</span><span class="tok-w"> </span><span class="tok-n">error</span><span class="tok-w"> </span><span class="tok-nl">C1010</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">unexpected</span><span class="tok-w"> </span><span class="tok-n">end</span><span class="tok-w"> </span><span class="tok-n">of</span><span class="tok-w"> </span><span class="tok-n">file</span><span class="tok-w"> </span><span class="tok-k">while</span><span class="tok-w"> </span><span class="tok-n">looking</span><span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-n">precompiled</span><span class="tok-w"> </span><span class="tok-n">header</span><span class="tok-p">.</span><span class="tok-w"> </span><span class="tok-n">Did</span><span class="tok-w"> </span><span class="tok-n">you</span><span class="tok-w"> </span><span class="tok-n">forget</span><span class="tok-w"> </span><span class="tok-n">to</span><span class="tok-w"> </span><span class="tok-n">add</span><span class="tok-w"> </span><span class="tok-err">&#39;#</span><span class="tok-n">include</span><span class="tok-w"> </span><span class="tok-s">&quot;stdafx.h&quot;</span><span class="tok-err">&#39;</span><span class="tok-w"> </span><span class="tok-n">to</span><span class="tok-w"> </span><span class="tok-n">your</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-o">?</span><span class="tok-w"></span></code></pre>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugixml</span><span class="tok-p">.</span><span class="tok-n">cpp</span><span class="tok-p">(</span><span class="tok-mi">3477</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">fatal</span><span class="tok-w"> </span><span class="tok-n">error</span><span class="tok-w"> </span><span class="tok-n">C1010</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">unexpected</span><span class="tok-w"> </span><span class="tok-n">end</span><span class="tok-w"> </span><span class="tok-n">of</span><span class="tok-w"> </span><span class="tok-n">file</span><span class="tok-w"> </span><span class="tok-k">while</span><span class="tok-w"> </span><span class="tok-n">looking</span><span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-n">precompiled</span><span class="tok-w"> </span><span class="tok-n">header</span><span class="tok-p">.</span><span class="tok-w"> </span><span class="tok-n">Did</span><span class="tok-w"> </span><span class="tok-n">you</span><span class="tok-w"> </span><span class="tok-n">forget</span><span class="tok-w"> </span><span class="tok-n">to</span><span class="tok-w"> </span><span class="tok-n">add</span><span class="tok-w"> </span><span class="tok-err">&#39;#</span><span class="tok-n">include</span><span class="tok-w"> </span><span class="tok-s">&quot;stdafx.h&quot;</span><span class="tok-err">&#39;</span><span class="tok-w"> </span><span class="tok-n">to</span><span class="tok-w"> </span><span class="tok-n">your</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-o">?</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -1160,7 +1167,7 @@ In that example <code>PUGIXML_API</code> is inconsistent between several source
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><span></span><span class="tok-cp">&lt;?xml version=&quot;1.0&quot;?&gt;</span>
<span class="tok-nt">&lt;mesh</span> <span class="tok-na">name=</span><span class="tok-s">&quot;mesh_root&quot;</span><span class="tok-nt">&gt;</span>
<span class="tok-c">&lt;!-- here is a mesh node --&gt;</span>
<span class="tok-cm">&lt;!-- here is a mesh node --&gt;</span>
some text
<span class="tok-cp">&lt;![CDATA[someothertext]]&gt;</span>
some more text
@ -1643,7 +1650,7 @@ Sometimes XML data should be loaded from some other source than a file, i.e. HTT
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span> <span class="tok-nc">xml_parse_result</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">xml_parse_result</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">xml_parse_status</span><span class="tok-w"> </span><span class="tok-n">status</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><span class="tok-n">offset</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -2119,12 +2126,12 @@ In many cases attribute values have types that are not strings - i.e. an attribu
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_int</span><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_uint</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_uint</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_double</span><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_float</span><span class="tok-p">(</span><span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_bool</span><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_llong</span><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_ullong</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
<span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_llong</span><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::as_ullong</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -2250,16 +2257,16 @@ If your C&#43;&#43; compiler supports range-based for-loop (this is a C&#43;&#43
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nl">tool</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nl">attr</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attributes</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attributes</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot; &quot;</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot;=&quot;</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nl">child</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot;, child &quot;</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">();</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span>
@ -2273,7 +2280,7 @@ If your C&#43;&#43; compiler supports range-based for-loop (this is a C&#43;&#43
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nl">child</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
</div>
</div>
</div>
@ -2285,8 +2292,8 @@ Child node lists and attribute lists are simply double-linked lists; while you c
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span> <span class="tok-nc">xml_node_iterator</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">class</span> <span class="tok-nc">xml_attribute_iterator</span><span class="tok-p">;</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">xml_node_iterator</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">xml_attribute_iterator</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">xml_node_iterator</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">iterator</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-n">iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::begin</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -2344,7 +2351,7 @@ Node and attribute iterators are somewhere in the middle between const and non-c
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span> <span class="tok-nc">xml_tree_walker</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">xml_tree_walker</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-k">public</span><span class="tok-o">:</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">virtual</span><span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">begin</span><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span>
@ -2385,7 +2392,7 @@ The traversal is launched by calling <code>traverse</code> function on traversal
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span> <span class="tok-nc">simple_walker</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_tree_walker</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">simple_walker</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_tree_walker</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">virtual</span><span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">for_each</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">)</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
@ -2413,9 +2420,9 @@ While there are existing functions for getting a node/attribute with known conte
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_attribute</span><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_node</span><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_attribute</span><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_node</span><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -2440,7 +2447,7 @@ While there are existing functions for getting a node/attribute with known conte
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Timeout&quot;</span><span class="tok-p">).</span><span class="tok-n">as_int</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-w"> </span><span class="tok-mi">20</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-p">}</span><span class="tok-w"></span>
<span class="tok-k">struct</span> <span class="tok-nc">allow_remote_predicate</span><span class="tok-w"></span>
<span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">allow_remote_predicate</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">operator</span><span class="tok-p">()(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
@ -2514,12 +2521,12 @@ If you need a non-empty string if the text object is empty, or if the text conte
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_string</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">&quot;&quot;</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_int</span><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_uint</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_uint</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_double</span><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_float</span><span class="tok-p">(</span><span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_bool</span><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_llong</span><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_ullong</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
<span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_llong</span><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-nf">xml_text::as_ullong</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -2621,7 +2628,8 @@ As discussed before, nodes can have name and value, both of which are strings. D
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::set_name</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::set_value</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::set_value</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::set_value</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -2656,7 +2664,8 @@ All attributes have name and value, both of which are strings (value may be empt
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::set_name</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::set_value</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::set_value</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::set_value</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -2917,7 +2926,8 @@ If you do not want your document to contain some node or attribute, you can remo
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_text::set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_text::set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_text::set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre>
</div>
</div>
<div class="paragraph">
@ -3246,7 +3256,7 @@ All of the above saving functions are implemented in terms of writer interface.
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span> <span class="tok-nc">xml_writer</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">xml_writer</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-k">public</span><span class="tok-o">:</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">virtual</span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">write</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">data</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -3266,7 +3276,7 @@ All of the above saving functions are implemented in terms of writer interface.
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span> <span class="tok-nc">xml_string_writer</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_writer</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">xml_string_writer</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_writer</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -3581,7 +3591,7 @@ The order of iteration depends on the order of nodes inside the set; the order c
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">enum</span> <span class="tok-nc">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">type_t</span><span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-n">type_unsorted</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">type_sorted</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">type_sorted_reverse</span><span class="tok-p">};</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">enum</span><span class="tok-w"> </span><span class="tok-nc">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">type_t</span><span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-n">type_unsorted</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">type_sorted</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">type_sorted_reverse</span><span class="tok-p">};</span><span class="tok-w"></span>
<span class="tok-n">type_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::type</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre>
</div>
</div>
@ -3968,7 +3978,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span> <span class="tok-nc">xpath_parse_result</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">xpath_parse_result</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">error</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><span class="tok-n">offset</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -4058,6 +4068,55 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<h2 id="changes"><a class="anchor" href="#changes"></a><a class="link" href="#changes">9. Changelog</a></h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="v1.13"><a class="anchor" href="#v1.13"></a><a class="link" href="#v1.13">v1.13 <sup>2022-11-01</sup></a></h3>
<div class="paragraph">
<p>Maintenance release. Changes:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Improvements:</p>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>xml_attribute::set_value</code>, <code>xml_node::set_value</code> and <code>xml_text::set</code> now have overloads that accept pointer to non-null-terminated string and size</p>
</li>
<li>
<p>Improve performance of tree traversal when using compact mode (<code>PUGIXML_COMPACT</code>)</p>
</li>
</ol>
</div>
</li>
<li>
<p>Bug fixes:</p>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Fix error handling in <code>xml_document::save_file</code> that could result in the function succeeding while running out of disk space</p>
</li>
<li>
<p>Fix memory leak during error handling of some out-of-memory conditions during <code>xml_document::load</code></p>
</li>
</ol>
</div>
</li>
<li>
<p>Compatibility improvements:</p>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Fix exported symbols in CMake DLL builds when using CMake</p>
</li>
<li>
<p>Fix exported symbols in CMake shared object builds when using -fvisibility=hidden</p>
</li>
</ol>
</div>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="v1.12"><a class="anchor" href="#v1.12"></a><a class="link" href="#v1.12">v1.12 <sup>2022-02-09</sup></a></h3>
<div class="paragraph">
<p>Maintenance release. Changes:</p>
@ -5538,7 +5597,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<h3 id="apiref.enums"><a class="anchor" href="#apiref.enums"></a><a class="link" href="#apiref.enums">10.3. Enumerations</a></h3>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">enum</span> <a href="#xml_node_type">xml_node_type</a><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xml_node_type">xml_node_type</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#node_null">node_null</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#node_document">node_document</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#node_element">node_element</a><span class="tok-w"></span>
@ -5549,7 +5608,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><a href="#node_declaration">node_declaration</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#node_doctype">node_doctype</a><span class="tok-w"></span>
<span class="tok-k">enum</span> <a href="#xml_parse_status">xml_parse_status</a><span class="tok-w"></span>
<span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xml_parse_status">xml_parse_status</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#status_ok">status_ok</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#status_file_not_found">status_file_not_found</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#status_io_error">status_io_error</a><span class="tok-w"></span>
@ -5568,7 +5627,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><a href="#status_append_invalid_root">status_append_invalid_root</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#status_no_document_element">status_no_document_element</a><span class="tok-w"></span>
<span class="tok-k">enum</span> <a href="#xml_encoding">xml_encoding</a><span class="tok-w"></span>
<span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xml_encoding">xml_encoding</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#encoding_auto">encoding_auto</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#encoding_utf8">encoding_utf8</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#encoding_utf16_le">encoding_utf16_le</a><span class="tok-w"></span>
@ -5580,7 +5639,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><a href="#encoding_wchar">encoding_wchar</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#encoding_latin1">encoding_latin1</a><span class="tok-w"></span>
<span class="tok-k">enum</span> <a href="#xpath_value_type">xpath_value_type</a><span class="tok-w"></span>
<span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xpath_value_type">xpath_value_type</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#xpath_type_none">xpath_type_none</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#xpath_type_node_set">xpath_type_node_set</a><span class="tok-w"></span>
<span class="tok-w"> </span><a href="#xpath_type_number">xpath_type_number</a><span class="tok-w"></span>
@ -5663,6 +5722,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::set_name">set_name</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
@ -5738,9 +5798,9 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::traverse">traverse</a><span class="tok-p">(</span><span class="tok-n">xml_tree_walker</span><span class="tok-o">&amp;</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::find_attribute">find_attribute</a><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_child">find_child</a><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_node">find_node</a><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::find_attribute">find_attribute</a><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_child">find_child</a><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_node">find_node</a><span class="tok-p">(</span><span class="tok-n">Predicate</span><span class="tok-w"> </span><span class="tok-n">pred</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">string_t</span><span class="tok-w"> </span><a href="#xml_node::path">path</a><span class="tok-p">(</span><span class="tok-n">char_t</span><span class="tok-w"> </span><span class="tok-n">delimiter</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-sc">&#39;/&#39;</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::first_element_by_path">xml_node::first_element_by_path</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">path</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-w"> </span><span class="tok-n">delimiter</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-sc">&#39;/&#39;</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -5749,6 +5809,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::set_name">set_name</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::set_value">set_value</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::set_value">set_value</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::append_attribute">append_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">name</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::prepend_attribute">prepend_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">name</span><span class="tok-p">);</span><span class="tok-w"></span>
@ -5861,16 +5922,17 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><a href="#xml_text::as_ullong">as_ullong</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::set_value">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&amp;</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&amp;</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span>
@ -5949,7 +6011,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
<span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xpath_node_set::first">first</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">enum</span> <span class="tok-nc">type_t</span><span class="tok-w"> </span><span class="tok-p">{</span><a href="#xpath_node_set::type_unsorted">type_unsorted</a><span class="tok-p">,</span><span class="tok-w"> </span><a href="#xpath_node_set::type_sorted">type_sorted</a><span class="tok-p">,</span><span class="tok-w"> </span><a href="#xpath_node_set::type_sorted_reverse">type_sorted_reverse</a><span class="tok-p">};</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">enum</span><span class="tok-w"> </span><span class="tok-nc">type_t</span><span class="tok-w"> </span><span class="tok-p">{</span><a href="#xpath_node_set::type_unsorted">type_unsorted</a><span class="tok-p">,</span><span class="tok-w"> </span><a href="#xpath_node_set::type_sorted">type_sorted</a><span class="tok-p">,</span><span class="tok-w"> </span><a href="#xpath_node_set::type_sorted_reverse">type_sorted_reverse</a><span class="tok-p">};</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">type_t</span><span class="tok-w"> </span><a href="#xpath_node_set::type">type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xpath_node_set::sort">sort</a><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">reverse</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">);</span><span class="tok-w"></span>
@ -6005,7 +6067,7 @@ If exceptions are disabled, then in the event of parsing failure the query is in
</div>
<div id="footer">
<div id="footer-text">
Last updated 2022-02-08 19:57:06 -0800
Last updated 2022-10-20 20:18:02 -0700
</div>
</div>
</body>

View file

@ -4,9 +4,9 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.17">
<meta name="generator" content="Asciidoctor 2.0.16">
<meta name="author" content="website, repository">
<title>pugixml 1.12 quick start guide</title>
<title>pugixml 1.13 quick start guide</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
@ -194,8 +194,7 @@ body.toc2.toc-right{padding-left:0;padding-right:20em}}
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
details{margin-left:1.25rem}
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
details>summary::-webkit-details-marker{display:none}
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent}
details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
@ -237,8 +236,9 @@ pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
table.linenotable td.code{padding-left:.75em}
table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
pre.pygments span.linenos{display:inline-block;margin-right:.75em}
table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em}
pre.pygments .lineno{border-right:1px solid;opacity:.35;display:inline-block;margin-right:.75em}
pre.pygments .lineno::before{content:"";margin-right:-.125em}
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
@ -275,7 +275,7 @@ table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-c
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd),table.stripes-even tr:nth-of-type(even),table.stripes-hover tr:hover{background:#f8f8f7}
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
@ -291,11 +291,10 @@ ol{margin-left:1.75em}
ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
ul.unstyled,ol.unstyled{margin-left:0}
li>p:empty:only-child::before{content:"";display:inline-block}
ul.checklist>li>p:first-child{margin-left:-1em}
ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
@ -338,6 +337,8 @@ sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
#footnotes .footnote:last-of-type{margin-bottom:0}
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
.gist .file-data>table td.line-data{width:99%}
div.unbreakable{page-break-inside:avoid}
.big{font-size:larger}
.small{font-size:smaller}
@ -437,24 +438,29 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
</style>
<style>
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
pre.pygments .hll { background-color: #ffffcc }
pre.pygments { background: #f8f8f8; }
pre.pygments .tok-c { color: #408080; font-style: italic } /* Comment */
pre.pygments .tok-c { color: #3D7B7B; font-style: italic } /* Comment */
pre.pygments .tok-err { border: 1px solid #FF0000 } /* Error */
pre.pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */
pre.pygments .tok-o { color: #666666 } /* Operator */
pre.pygments .tok-ch { color: #408080; font-style: italic } /* Comment.Hashbang */
pre.pygments .tok-cm { color: #408080; font-style: italic } /* Comment.Multiline */
pre.pygments .tok-cp { color: #BC7A00 } /* Comment.Preproc */
pre.pygments .tok-cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
pre.pygments .tok-c1 { color: #408080; font-style: italic } /* Comment.Single */
pre.pygments .tok-cs { color: #408080; font-style: italic } /* Comment.Special */
pre.pygments .tok-ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
pre.pygments .tok-cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
pre.pygments .tok-cp { color: #9C6500 } /* Comment.Preproc */
pre.pygments .tok-cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
pre.pygments .tok-c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
pre.pygments .tok-cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
pre.pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */
pre.pygments .tok-gr { color: #FF0000 } /* Generic.Error */
pre.pygments .tok-gr { color: #E40000 } /* Generic.Error */
pre.pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
pre.pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
pre.pygments .tok-go { color: #888888 } /* Generic.Output */
pre.pygments .tok-gi { color: #008400 } /* Generic.Inserted */
pre.pygments .tok-go { color: #717171 } /* Generic.Output */
pre.pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
pre.pygments .tok-gs { font-weight: bold } /* Generic.Strong */
pre.pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
@ -467,15 +473,15 @@ pre.pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved *
pre.pygments .tok-kt { color: #B00040 } /* Keyword.Type */
pre.pygments .tok-m { color: #666666 } /* Literal.Number */
pre.pygments .tok-s { color: #BA2121 } /* Literal.String */
pre.pygments .tok-na { color: #7D9029 } /* Name.Attribute */
pre.pygments .tok-na { color: #687822 } /* Name.Attribute */
pre.pygments .tok-nb { color: #008000 } /* Name.Builtin */
pre.pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */
pre.pygments .tok-no { color: #880000 } /* Name.Constant */
pre.pygments .tok-nd { color: #AA22FF } /* Name.Decorator */
pre.pygments .tok-ni { color: #999999; font-weight: bold } /* Name.Entity */
pre.pygments .tok-ne { color: #D2413A; font-weight: bold } /* Name.Exception */
pre.pygments .tok-ni { color: #717171; font-weight: bold } /* Name.Entity */
pre.pygments .tok-ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
pre.pygments .tok-nf { color: #0000FF } /* Name.Function */
pre.pygments .tok-nl { color: #A0A000 } /* Name.Label */
pre.pygments .tok-nl { color: #767600 } /* Name.Label */
pre.pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
pre.pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */
pre.pygments .tok-nv { color: #19177C } /* Name.Variable */
@ -492,11 +498,11 @@ pre.pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */
pre.pygments .tok-dl { color: #BA2121 } /* Literal.String.Delimiter */
pre.pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
pre.pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */
pre.pygments .tok-se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
pre.pygments .tok-se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
pre.pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */
pre.pygments .tok-si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
pre.pygments .tok-si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
pre.pygments .tok-sx { color: #008000 } /* Literal.String.Other */
pre.pygments .tok-sr { color: #BB6688 } /* Literal.String.Regex */
pre.pygments .tok-sr { color: #A45A77 } /* Literal.String.Regex */
pre.pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */
pre.pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */
pre.pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */
@ -510,7 +516,7 @@ pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
</head>
<body class="article toc2 toc-right">
<div id="header">
<h1>pugixml 1.12 quick start guide</h1>
<h1>pugixml 1.13 quick start guide</h1>
<div class="details">
<span id="author" class="author">website</span><br>
<span id="email" class="email"><a href="https://pugixml.org" class="bare">https://pugixml.org</a></span><br>
@ -566,9 +572,9 @@ No documentation is perfect; neither is this one. If you find errors or omission
<p>You can download the latest source distribution as an archive:</p>
</div>
<div class="paragraph">
<p><a href="https://github.com/zeux/pugixml/releases/download/v1.12/pugixml-1.12.zip">pugixml-1.12.zip</a> (Windows line endings)
<p><a href="https://github.com/zeux/pugixml/releases/download/v1.13/pugixml-1.13.zip">pugixml-1.13.zip</a> (Windows line endings)
/
<a href="https://github.com/zeux/pugixml/releases/download/v1.12/pugixml-1.12.tar.gz">pugixml-1.12.tar.gz</a> (Unix line endings)</p>
<a href="https://github.com/zeux/pugixml/releases/download/v1.13/pugixml-1.13.tar.gz">pugixml-1.13.tar.gz</a> (Unix line endings)</p>
</div>
<div class="paragraph">
<p>The distribution contains library source, documentation (the guide you&#8217;re reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.</p>
@ -799,16 +805,16 @@ All pugixml classes and functions are located in <code>pugi</code> namespace; yo
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nl">tool</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nl">attr</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attributes</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attributes</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot; &quot;</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot;=&quot;</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nl">child</span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">())</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-s">&quot;, child &quot;</span><span class="tok-w"> </span><span class="tok-o">&lt;&lt;</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">();</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span>
@ -825,7 +831,7 @@ All pugixml classes and functions are located in <code>pugi</code> namespace; yo
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span> <span class="tok-nc">simple_walker</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_tree_walker</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">simple_walker</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_tree_walker</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-k">virtual</span><span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">for_each</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">)</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
@ -1022,7 +1028,7 @@ XPath functions throw <code>xpath_exception</code> objects on error; the sample
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span> <span class="tok-nc">xml_string_writer</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_writer</span><span class="tok-w"></span>
<pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">xml_string_writer</span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_writer</span><span class="tok-w"></span>
<span class="tok-p">{</span><span class="tok-w"></span>
<span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">;</span><span class="tok-w"></span>
@ -1101,7 +1107,7 @@ pugixml is Copyright (C) 2006-2022 Arseny Kapoulkine.</pre>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2022-02-08 19:57:47 -0800
Last updated 2022-09-02 21:41:39 -0700
</div>
</div>
</body>

View file

@ -1,4 +1,4 @@
pugixml 1.12 - an XML processing library
pugixml 1.13 - an XML processing library
Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
Report bugs and download new versions at https://pugixml.org/

View file

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>pugixml</id>
<version>1.12.0-appveyor</version>
<version>1.13.0-appveyor</version>
<title>pugixml</title>
<authors>Arseny Kapoulkine</authors>
<owners>Arseny Kapoulkine</owners>

View file

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "pugixml"
s.version = "1.12"
s.version = "1.13"
s.summary = "C++ XML parser library."
s.homepage = "https://pugixml.org"
s.license = "MIT"

View file

@ -1,9 +1,9 @@
#include <winver.h>
#define PUGIXML_VERSION_MAJOR 1
#define PUGIXML_VERSION_MINOR 12
#define PUGIXML_VERSION_MINOR 13
#define PUGIXML_VERSION_PATCH 0
#define PUGIXML_VERSION_NUMBER "1.12.0\0"
#define PUGIXML_VERSION_NUMBER "1.13.0\0"
#if defined(GCC_WINDRES) || defined(__MINGW32__) || defined(__CYGWIN__)
VS_VERSION_INFO VERSIONINFO

View file

@ -1,5 +1,5 @@
/**
* pugixml parser - version 1.12
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/

View file

@ -1,5 +1,5 @@
/**
* pugixml parser - version 1.12
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
@ -143,6 +143,8 @@ using std::memset;
# define PUGI__SNPRINTF(buf, ...) snprintf(buf, sizeof(buf), __VA_ARGS__)
#elif defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
# define PUGI__SNPRINTF(buf, ...) _snprintf_s(buf, _countof(buf), _TRUNCATE, __VA_ARGS__)
#elif defined(__APPLE__) && __clang_major__ >= 14 // Xcode 14 marks sprintf as deprecated while still using C++98 by default
# define PUGI__SNPRINTF(buf, fmt, arg1, arg2) snprintf(buf, sizeof(buf), fmt, arg1, arg2)
#else
# define PUGI__SNPRINTF sprintf
#endif
@ -1276,12 +1278,14 @@ PUGI__NS_BEGIN
child->parent = parent;
if (node->next_sibling)
node->next_sibling->prev_sibling_c = child;
xml_node_struct* next = node->next_sibling;
if (next)
next->prev_sibling_c = child;
else
parent->first_child->prev_sibling_c = child;
child->next_sibling = node->next_sibling;
child->next_sibling = next;
child->prev_sibling_c = node;
node->next_sibling = child;
@ -1293,12 +1297,14 @@ PUGI__NS_BEGIN
child->parent = parent;
if (node->prev_sibling_c->next_sibling)
node->prev_sibling_c->next_sibling = child;
xml_node_struct* prev = node->prev_sibling_c;
if (prev->next_sibling)
prev->next_sibling = child;
else
parent->first_child = child;
child->prev_sibling_c = node->prev_sibling_c;
child->prev_sibling_c = prev;
child->next_sibling = node;
node->prev_sibling_c = child;
@ -1308,15 +1314,18 @@ PUGI__NS_BEGIN
{
xml_node_struct* parent = node->parent;
if (node->next_sibling)
node->next_sibling->prev_sibling_c = node->prev_sibling_c;
else
parent->first_child->prev_sibling_c = node->prev_sibling_c;
xml_node_struct* next = node->next_sibling;
xml_node_struct* prev = node->prev_sibling_c;
if (node->prev_sibling_c->next_sibling)
node->prev_sibling_c->next_sibling = node->next_sibling;
if (next)
next->prev_sibling_c = prev;
else
parent->first_child = node->next_sibling;
parent->first_child->prev_sibling_c = prev;
if (prev->next_sibling)
prev->next_sibling = next;
else
parent->first_child = next;
node->parent = 0;
node->prev_sibling_c = 0;
@ -1360,39 +1369,46 @@ PUGI__NS_BEGIN
inline void insert_attribute_after(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node)
{
if (place->next_attribute)
place->next_attribute->prev_attribute_c = attr;
xml_attribute_struct* next = place->next_attribute;
if (next)
next->prev_attribute_c = attr;
else
node->first_attribute->prev_attribute_c = attr;
attr->next_attribute = place->next_attribute;
attr->next_attribute = next;
attr->prev_attribute_c = place;
place->next_attribute = attr;
}
inline void insert_attribute_before(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node)
{
if (place->prev_attribute_c->next_attribute)
place->prev_attribute_c->next_attribute = attr;
xml_attribute_struct* prev = place->prev_attribute_c;
if (prev->next_attribute)
prev->next_attribute = attr;
else
node->first_attribute = attr;
attr->prev_attribute_c = place->prev_attribute_c;
attr->prev_attribute_c = prev;
attr->next_attribute = place;
place->prev_attribute_c = attr;
}
inline void remove_attribute(xml_attribute_struct* attr, xml_node_struct* node)
{
if (attr->next_attribute)
attr->next_attribute->prev_attribute_c = attr->prev_attribute_c;
else
node->first_attribute->prev_attribute_c = attr->prev_attribute_c;
xml_attribute_struct* next = attr->next_attribute;
xml_attribute_struct* prev = attr->prev_attribute_c;
if (attr->prev_attribute_c->next_attribute)
attr->prev_attribute_c->next_attribute = attr->next_attribute;
if (next)
next->prev_attribute_c = prev;
else
node->first_attribute = attr->next_attribute;
node->first_attribute->prev_attribute_c = prev;
if (prev->next_attribute)
prev->next_attribute = next;
else
node->first_attribute = next;
attr->prev_attribute_c = 0;
attr->next_attribute = 0;
@ -4707,6 +4723,9 @@ PUGI__NS_BEGIN
// get actual encoding
xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
// if convert_buffer below throws bad_alloc, we still need to deallocate contents if we own it
auto_deleter<void> contents_guard(own ? contents : 0, xml_memory::deallocate);
// get private buffer
char_t* buffer = 0;
size_t length = 0;
@ -4714,6 +4733,9 @@ PUGI__NS_BEGIN
// coverity[var_deref_model]
if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory);
// after this we either deallocate contents (below) or hold on to it via doc->buffer, so we don't need to guard it
contents_guard.release();
// delete original buffer if we performed a conversion
if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents);
@ -5050,7 +5072,7 @@ PUGI__NS_BEGIN
xml_writer_file writer(file);
doc.save(writer, indent, flags, encoding);
return ferror(file) == 0;
return fflush(file) == 0 && ferror(file) == 0;
}
struct name_null_sentry
@ -5185,53 +5207,72 @@ namespace pugi
PUGI__FN xml_attribute xml_attribute::next_attribute() const
{
return _attr ? xml_attribute(_attr->next_attribute) : xml_attribute();
if (!_attr) return xml_attribute();
return xml_attribute(_attr->next_attribute);
}
PUGI__FN xml_attribute xml_attribute::previous_attribute() const
{
return _attr && _attr->prev_attribute_c->next_attribute ? xml_attribute(_attr->prev_attribute_c) : xml_attribute();
if (!_attr) return xml_attribute();
xml_attribute_struct* prev = _attr->prev_attribute_c;
return prev->next_attribute ? xml_attribute(prev) : xml_attribute();
}
PUGI__FN const char_t* xml_attribute::as_string(const char_t* def) const
{
return (_attr && _attr->value) ? _attr->value + 0 : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? value : def;
}
PUGI__FN int xml_attribute::as_int(int def) const
{
return (_attr && _attr->value) ? impl::get_value_int(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_int(value) : def;
}
PUGI__FN unsigned int xml_attribute::as_uint(unsigned int def) const
{
return (_attr && _attr->value) ? impl::get_value_uint(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_uint(value) : def;
}
PUGI__FN double xml_attribute::as_double(double def) const
{
return (_attr && _attr->value) ? impl::get_value_double(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_double(value) : def;
}
PUGI__FN float xml_attribute::as_float(float def) const
{
return (_attr && _attr->value) ? impl::get_value_float(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_float(value) : def;
}
PUGI__FN bool xml_attribute::as_bool(bool def) const
{
return (_attr && _attr->value) ? impl::get_value_bool(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_bool(value) : def;
}
#ifdef PUGIXML_HAS_LONG_LONG
PUGI__FN long long xml_attribute::as_llong(long long def) const
{
return (_attr && _attr->value) ? impl::get_value_llong(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_llong(value) : def;
}
PUGI__FN unsigned long long xml_attribute::as_ullong(unsigned long long def) const
{
return (_attr && _attr->value) ? impl::get_value_ullong(_attr->value) : def;
if (!_attr) return def;
const char_t* value = _attr->value;
return value ? impl::get_value_ullong(value) : def;
}
#endif
@ -5242,12 +5283,16 @@ namespace pugi
PUGI__FN const char_t* xml_attribute::name() const
{
return (_attr && _attr->name) ? _attr->name + 0 : PUGIXML_TEXT("");
if (!_attr) return PUGIXML_TEXT("");
const char_t* name = _attr->name;
return name ? name : PUGIXML_TEXT("");
}
PUGI__FN const char_t* xml_attribute::value() const
{
return (_attr && _attr->value) ? _attr->value + 0 : PUGIXML_TEXT("");
if (!_attr) return PUGIXML_TEXT("");
const char_t* value = _attr->value;
return value ? value : PUGIXML_TEXT("");
}
PUGI__FN size_t xml_attribute::hash_value() const
@ -5329,6 +5374,13 @@ namespace pugi
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
}
PUGI__FN bool xml_attribute::set_value(const char_t* rhs, size_t sz)
{
if (!_attr) return false;
return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
}
PUGI__FN bool xml_attribute::set_value(const char_t* rhs)
{
if (!_attr) return false;
@ -5521,7 +5573,9 @@ namespace pugi
PUGI__FN const char_t* xml_node::name() const
{
return (_root && _root->name) ? _root->name + 0 : PUGIXML_TEXT("");
if (!_root) return PUGIXML_TEXT("");
const char_t* name = _root->name;
return name ? name : PUGIXML_TEXT("");
}
PUGI__FN xml_node_type xml_node::type() const
@ -5531,7 +5585,9 @@ namespace pugi
PUGI__FN const char_t* xml_node::value() const
{
return (_root && _root->value) ? _root->value + 0 : PUGIXML_TEXT("");
if (!_root) return PUGIXML_TEXT("");
const char_t* value = _root->value;
return value ? value : PUGIXML_TEXT("");
}
PUGI__FN xml_node xml_node::child(const char_t* name_) const
@ -5539,7 +5595,11 @@ namespace pugi
if (!_root) return xml_node();
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
if (i->name && impl::strequal(name_, i->name)) return xml_node(i);
{
const char_t* iname = i->name;
if (iname && impl::strequal(name_, iname))
return xml_node(i);
}
return xml_node();
}
@ -5549,8 +5609,11 @@ namespace pugi
if (!_root) return xml_attribute();
for (xml_attribute_struct* i = _root->first_attribute; i; i = i->next_attribute)
if (i->name && impl::strequal(name_, i->name))
{
const char_t* iname = i->name;
if (iname && impl::strequal(name_, iname))
return xml_attribute(i);
}
return xml_attribute();
}
@ -5560,7 +5623,11 @@ namespace pugi
if (!_root) return xml_node();
for (xml_node_struct* i = _root->next_sibling; i; i = i->next_sibling)
if (i->name && impl::strequal(name_, i->name)) return xml_node(i);
{
const char_t* iname = i->name;
if (iname && impl::strequal(name_, iname))
return xml_node(i);
}
return xml_node();
}
@ -5575,7 +5642,11 @@ namespace pugi
if (!_root) return xml_node();
for (xml_node_struct* i = _root->prev_sibling_c; i->next_sibling; i = i->prev_sibling_c)
if (i->name && impl::strequal(name_, i->name)) return xml_node(i);
{
const char_t* iname = i->name;
if (iname && impl::strequal(name_, iname))
return xml_node(i);
}
return xml_node();
}
@ -5591,24 +5662,30 @@ namespace pugi
// optimistically search from hint up until the end
for (xml_attribute_struct* i = hint; i; i = i->next_attribute)
if (i->name && impl::strequal(name_, i->name))
{
const char_t* iname = i->name;
if (iname && impl::strequal(name_, iname))
{
// update hint to maximize efficiency of searching for consecutive attributes
hint_._attr = i->next_attribute;
return xml_attribute(i);
}
}
// wrap around and search from the first attribute until the hint
// 'j' null pointer check is technically redundant, but it prevents a crash in case the assertion above fails
for (xml_attribute_struct* j = _root->first_attribute; j && j != hint; j = j->next_attribute)
if (j->name && impl::strequal(name_, j->name))
{
const char_t* jname = j->name;
if (jname && impl::strequal(name_, jname))
{
// update hint to maximize efficiency of searching for consecutive attributes
hint_._attr = j->next_attribute;
return xml_attribute(j);
}
}
return xml_attribute();
}
@ -5616,9 +5693,8 @@ namespace pugi
PUGI__FN xml_node xml_node::previous_sibling() const
{
if (!_root) return xml_node();
if (_root->prev_sibling_c->next_sibling) return xml_node(_root->prev_sibling_c);
else return xml_node();
xml_node_struct* prev = _root->prev_sibling_c;
return prev->next_sibling ? xml_node(prev) : xml_node();
}
PUGI__FN xml_node xml_node::parent() const
@ -5645,8 +5721,11 @@ namespace pugi
return _root->value;
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
if (impl::is_text_node(i) && i->value)
return i->value;
{
const char_t* ivalue = i->value;
if (impl::is_text_node(i) && ivalue)
return ivalue;
}
return PUGIXML_TEXT("");
}
@ -5658,22 +5737,28 @@ namespace pugi
PUGI__FN xml_attribute xml_node::first_attribute() const
{
return _root ? xml_attribute(_root->first_attribute) : xml_attribute();
if (!_root) return xml_attribute();
return xml_attribute(_root->first_attribute);
}
PUGI__FN xml_attribute xml_node::last_attribute() const
{
return _root && _root->first_attribute ? xml_attribute(_root->first_attribute->prev_attribute_c) : xml_attribute();
if (!_root) return xml_attribute();
xml_attribute_struct* first = _root->first_attribute;
return first ? xml_attribute(first->prev_attribute_c) : xml_attribute();
}
PUGI__FN xml_node xml_node::first_child() const
{
return _root ? xml_node(_root->first_child) : xml_node();
if (!_root) return xml_node();
return xml_node(_root->first_child);
}
PUGI__FN xml_node xml_node::last_child() const
{
return _root && _root->first_child ? xml_node(_root->first_child->prev_sibling_c) : xml_node();
if (!_root) return xml_node();
xml_node_struct* first = _root->first_child;
return first ? xml_node(first->prev_sibling_c) : xml_node();
}
PUGI__FN bool xml_node::set_name(const char_t* rhs)
@ -5686,6 +5771,16 @@ namespace pugi
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
}
PUGI__FN bool xml_node::set_value(const char_t* rhs, size_t sz)
{
xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null;
if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype)
return false;
return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
}
PUGI__FN bool xml_node::set_value(const char_t* rhs)
{
xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null;
@ -6199,12 +6294,22 @@ namespace pugi
if (!_root) return xml_node();
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
if (i->name && impl::strequal(name_, i->name))
{
const char_t* iname = i->name;
if (iname && impl::strequal(name_, iname))
{
for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value + 0 : PUGIXML_TEXT("")))
return xml_node(i);
{
const char_t* aname = a->name;
if (aname && impl::strequal(attr_name, aname))
{
const char_t* avalue = a->value;
if (impl::strequal(attr_value, avalue ? avalue : PUGIXML_TEXT("")))
return xml_node(i);
}
}
}
}
return xml_node();
}
@ -6215,8 +6320,15 @@ namespace pugi
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value + 0 : PUGIXML_TEXT("")))
return xml_node(i);
{
const char_t* aname = a->name;
if (aname && impl::strequal(attr_name, aname))
{
const char_t* avalue = a->value;
if (impl::strequal(attr_value, avalue ? avalue : PUGIXML_TEXT("")))
return xml_node(i);
}
}
return xml_node();
}
@ -6230,8 +6342,9 @@ namespace pugi
for (xml_node_struct* i = _root; i; i = i->parent)
{
const char_t* iname = i->name;
offset += (i != _root);
offset += i->name ? impl::strlength(i->name) : 0;
offset += iname ? impl::strlength(iname) : 0;
}
string_t result;
@ -6242,12 +6355,13 @@ namespace pugi
if (j != _root)
result[--offset] = delimiter;
if (j->name)
const char_t* jname = j->name;
if (jname)
{
size_t length = impl::strlength(j->name);
size_t length = impl::strlength(jname);
offset -= length;
memcpy(&result[offset], j->name, length * sizeof(char_t));
memcpy(&result[offset], jname, length * sizeof(char_t));
}
}
@ -6285,7 +6399,8 @@ namespace pugi
{
for (xml_node_struct* j = context._root->first_child; j; j = j->next_sibling)
{
if (j->name && impl::strequalrange(j->name, path_segment, static_cast<size_t>(path_segment_end - path_segment)))
const char_t* jname = j->name;
if (jname && impl::strequalrange(jname, path_segment, static_cast<size_t>(path_segment_end - path_segment)))
{
xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter);
@ -6477,68 +6592,84 @@ namespace pugi
PUGI__FN const char_t* xml_text::get() const
{
xml_node_struct* d = _data();
return (d && d->value) ? d->value + 0 : PUGIXML_TEXT("");
if (!d) return PUGIXML_TEXT("");
const char_t* value = d->value;
return value ? value : PUGIXML_TEXT("");
}
PUGI__FN const char_t* xml_text::as_string(const char_t* def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? d->value + 0 : def;
if (!d) return def;
const char_t* value = d->value;
return value ? value : def;
}
PUGI__FN int xml_text::as_int(int def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_int(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_int(value) : def;
}
PUGI__FN unsigned int xml_text::as_uint(unsigned int def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_uint(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_uint(value) : def;
}
PUGI__FN double xml_text::as_double(double def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_double(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_double(value) : def;
}
PUGI__FN float xml_text::as_float(float def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_float(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_float(value) : def;
}
PUGI__FN bool xml_text::as_bool(bool def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_bool(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_bool(value) : def;
}
#ifdef PUGIXML_HAS_LONG_LONG
PUGI__FN long long xml_text::as_llong(long long def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_llong(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_llong(value) : def;
}
PUGI__FN unsigned long long xml_text::as_ullong(unsigned long long def) const
{
xml_node_struct* d = _data();
return (d && d->value) ? impl::get_value_ullong(d->value) : def;
if (!d) return def;
const char_t* value = d->value;
return value ? impl::get_value_ullong(value) : def;
}
#endif
PUGI__FN bool xml_text::set(const char_t* rhs, size_t sz)
{
xml_node_struct* dn = _data_new();
return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, sz) : false;
}
PUGI__FN bool xml_text::set(const char_t* rhs)
{
xml_node_struct* dn = _data_new();
@ -7294,7 +7425,7 @@ namespace pugi
using impl::auto_deleter; // MSVC7 workaround
auto_deleter<FILE> file(impl::open_file(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);
return impl::save_file_impl(*this, file.data, indent, flags, encoding);
return impl::save_file_impl(*this, file.data, indent, flags, encoding) && fclose(file.release()) == 0;
}
PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const
@ -7302,7 +7433,7 @@ namespace pugi
using impl::auto_deleter; // MSVC7 workaround
auto_deleter<FILE> file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), impl::close_file);
return impl::save_file_impl(*this, file.data, indent, flags, encoding);
return impl::save_file_impl(*this, file.data, indent, flags, encoding) && fclose(file.release()) == 0;
}
PUGI__FN xml_node xml_document::document_element() const

View file

@ -1,5 +1,5 @@
/**
* pugixml parser - version 1.12
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
@ -11,10 +11,10 @@
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
#ifndef PUGIXML_VERSION
// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons
// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits
# define PUGIXML_VERSION 1110
#ifndef PUGIXML_VERSION
# define PUGIXML_VERSION 1130 // 1.13
#endif
// Include user configuration file (this can define various configuration macros)
@ -115,6 +115,8 @@
#ifndef PUGIXML_NULL
# if __cplusplus >= 201103
# define PUGIXML_NULL nullptr
# elif defined(_MSC_VER) && _MSC_VER >= 1600
# define PUGIXML_NULL nullptr
# else
# define PUGIXML_NULL 0
# endif
@ -416,6 +418,7 @@ namespace pugi
// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
bool set_name(const char_t* rhs);
bool set_value(const char_t* rhs, size_t sz);
bool set_value(const char_t* rhs);
// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
@ -550,6 +553,7 @@ namespace pugi
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
bool set_name(const char_t* rhs);
bool set_value(const char_t* rhs, size_t sz);
bool set_value(const char_t* rhs);
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
@ -775,6 +779,7 @@ namespace pugi
bool as_bool(bool def = false) const;
// Set text (returns false if object is empty or there is not enough memory)
bool set(const char_t* rhs, size_t sz);
bool set(const char_t* rhs);
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")

View file

@ -736,7 +736,12 @@ struct temp_file
temp_file()
{
static int index = 0;
#if __cplusplus >= 201103 || defined(__APPLE__) // Xcode 14 warns about use of sprintf in C++98 builds
snprintf(path, sizeof(path), "%stempfile%d", test_runner::_temp_path, index++);
#else
sprintf(path, "%stempfile%d", test_runner::_temp_path, index++);
#endif
}
~temp_file()
@ -1817,3 +1822,39 @@ TEST(document_move_assign_empty)
CHECK_NODE(doc, STR("<node2/>"));
}
#endif
TEST(document_load_buffer_convert_out_of_memory)
{
const char* source = "<node>\xe7</node>";
size_t size = strlen(source);
test_runner::_memory_fail_threshold = 1;
xml_document doc;
xml_parse_result result;
result.status = status_out_of_memory;
CHECK_ALLOC_FAIL(result = doc.load_buffer(source, size, pugi::parse_default, pugi::encoding_latin1));
CHECK(result.status == status_out_of_memory);
}
TEST(document_load_buffer_own_convert_out_of_memory)
{
const char* source = "<node>\xe7</node>";
size_t size = strlen(source);
void* buffer = pugi::get_memory_allocation_function()(size);
CHECK(buffer);
memcpy(buffer, source, size);
test_runner::_memory_fail_threshold = 1;
xml_document doc;
xml_parse_result result;
result.status = status_out_of_memory;
CHECK_ALLOC_FAIL(result = doc.load_buffer_inplace_own(buffer, size, pugi::parse_default, pugi::encoding_latin1));
CHECK(result.status == status_out_of_memory);
}

View file

@ -70,7 +70,13 @@ TEST_XML(dom_attr_set_value, "<node/>")
CHECK(node.append_attribute(STR("attr8")).set_value(true));
CHECK(!xml_attribute().set_value(true));
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\"/>"));
CHECK(node.append_attribute(STR("attr9")).set_value(STR("v2"), 2));
CHECK(!xml_attribute().set_value(STR("v2")));
CHECK(node.append_attribute(STR("attr10")).set_value(STR("v3foobar"), 2));
CHECK(!xml_attribute().set_value(STR("v3")));
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\" attr9=\"v2\" attr10=\"v3\"/>"));
}
#if LONG_MAX > 2147483647
@ -209,6 +215,24 @@ TEST_XML(dom_node_set_value, "<node>text</node>")
CHECK_NODE(doc, STR("<node>no text</node>"));
}
TEST_XML(dom_node_set_value_partially_with_size, "<node>text</node>")
{
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"), 2));
CHECK(!doc.child(STR("node")).set_value(STR("no text"), 2));
CHECK(!xml_node().set_value(STR("no text"), 2));
CHECK_NODE(doc, STR("<node>no</node>"));
}
TEST_XML(dom_node_set_value_with_size, "<node>text</node>")
{
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"), 7));
CHECK(!doc.child(STR("node")).set_value(STR("no text"), 7));
CHECK(!xml_node().set_value(STR("no text"), 7));
CHECK_NODE(doc, STR("<node>no text</node>"));
}
TEST_XML(dom_node_set_value_allocated, "<node>text</node>")
{
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text")));

View file

@ -249,6 +249,46 @@ TEST_XML(dom_text_set, "<node/>")
CHECK_NODE(node, STR("<node>foobarfoobar</node>"));
}
TEST_XML(dom_text_set_with_size, "<node/>")
{
xml_node node = doc.child(STR("node"));
xml_text t = node.text();
t.set(STR(""), 0);
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
t.set(STR("boo"), 3);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>boo</node>"));
t.set(STR("foobarfoobar"), 12);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>foobarfoobar</node>"));
}
TEST_XML(dom_text_set_partially_with_size, "<node/>")
{
xml_node node = doc.child(STR("node"));
xml_text t = node.text();
t.set(STR("foo"), 0);
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
t.set(STR("boofoo"), 3);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>boo</node>"));
t.set(STR("foobarfoobar"), 3);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>foo</node>"));
}
TEST_XML(dom_text_assign, "<node/>")
{
xml_node node = doc.child(STR("node"));

View file

@ -795,7 +795,12 @@ struct test_walker: xml_tree_walker
std::basic_string<char_t> depthstr() const
{
char buf[32];
#if __cplusplus >= 201103 || defined(__APPLE__) // Xcode 14 warns about use of sprintf in C++98 builds
snprintf(buf, sizeof(buf), "%d", depth());
#else
sprintf(buf, "%d", depth());
#endif
#ifdef PUGIXML_WCHAR_MODE
wchar_t wbuf[32];

View file

@ -1,5 +1,5 @@
#include "../src/pugixml.hpp"
#if PUGIXML_VERSION != 1110
#if PUGIXML_VERSION != 1130
#error Unexpected pugixml version
#endif

View file

@ -10,14 +10,6 @@
#include <algorithm>
#include <limits>
// std::random_shuffle is deprecated in c++14, is removed in c++17.
#if defined(__cplusplus) && (__cplusplus >= 201402L)
# include <random>
# define PUGIXML_SHUFFLE(rng) std::shuffle(rng.begin(), rng.end(), std::default_random_engine{std::random_device{}()})
#else
# define PUGIXML_SHUFFLE(rng) std::random_shuffle(rng.begin(), rng.end())
#endif
using namespace pugi;
static void load_document_copy(xml_document& doc, const char_t* text)
@ -28,6 +20,22 @@ static void load_document_copy(xml_document& doc, const char_t* text)
doc.append_copy(source.first_child());
}
template <typename T>
static void random_shuffle(std::vector<T>& v)
{
size_t rng = 2147483647;
for (size_t i = v.size() - 1; i > 0; --i)
{
// Fisher-Yates shuffle
size_t j = rng % (i + 1);
std::swap(v[j], v[i]);
// LCG RNG, constants from Numerical Recipes
rng = rng * 1664525 + 1013904223;
}
}
TEST(xpath_allocator_many_pages)
{
std::basic_string<char_t> query = STR("0");
@ -163,7 +171,7 @@ TEST(xpath_sort_random_medium)
xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
std::vector<xpath_node> nsv(ns.begin(), ns.end());
PUGIXML_SHUFFLE(nsv);
random_shuffle(nsv);
xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
copy.sort();
@ -192,7 +200,7 @@ TEST(xpath_sort_random_large)
xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
std::vector<xpath_node> nsv(ns.begin(), ns.end());
PUGIXML_SHUFFLE(nsv);
random_shuffle(nsv);
xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
copy.sort();