Mercurial > minori
comparison dep/pugixml/docs/manual.html @ 123:a45edd073f9e
deps/pugixml: update to v1.14.0
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 08 Nov 2023 21:40:02 -0500 |
parents | d10b6c6b432e |
children |
comparison
equal
deleted
inserted
replaced
122:bc218c9d2ea6 | 123:a45edd073f9e |
---|---|
2 <html lang="en"> | 2 <html lang="en"> |
3 <head> | 3 <head> |
4 <meta charset="UTF-8"> | 4 <meta charset="UTF-8"> |
5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> | 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
7 <meta name="generator" content="Asciidoctor 2.0.16"> | 7 <meta name="generator" content="Asciidoctor 2.0.18"> |
8 <meta name="author" content="website, repository"> | 8 <meta name="author" content="website, repository"> |
9 <title>pugixml 1.13 manual</title> | 9 <title>pugixml 1.14 manual</title> |
10 <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"> | 10 <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"> |
11 <style> | 11 <style> |
12 /*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */ | 12 /*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */ |
13 /* Uncomment the following line when using as a custom stylesheet */ | 13 /* Uncomment the following line when using as a custom stylesheet */ |
14 /* @import "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"; */ | 14 /* @import "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"; */ |
83 small{font-size:60%;line-height:inherit} | 83 small{font-size:60%;line-height:inherit} |
84 code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} | 84 code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} |
85 ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} | 85 ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} |
86 ul,ol{margin-left:1.5em} | 86 ul,ol{margin-left:1.5em} |
87 ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0} | 87 ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0} |
88 ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit} | |
89 ul.square{list-style-type:square} | |
90 ul.circle{list-style-type:circle} | 88 ul.circle{list-style-type:circle} |
91 ul.disc{list-style-type:disc} | 89 ul.disc{list-style-type:disc} |
90 ul.square{list-style-type:square} | |
91 ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit} | |
92 ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} | 92 ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} |
93 dl dt{margin-bottom:.3125em;font-weight:bold} | 93 dl dt{margin-bottom:.3125em;font-weight:bold} |
94 dl dd{margin-bottom:1.25em} | 94 dl dd{margin-bottom:1.25em} |
95 blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} | 95 blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} |
96 blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} | 96 blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} |
192 #content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} | 192 #content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} |
193 #content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} | 193 #content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} |
194 #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} | 194 #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} |
195 details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} | 195 details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} |
196 details{margin-left:1.25rem} | 196 details{margin-left:1.25rem} |
197 details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent} | 197 details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent} |
198 details>summary::-webkit-details-marker{display:none} | |
198 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%)} | 199 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%)} |
199 details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)} | 200 details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)} |
200 details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem} | 201 details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem} |
201 .admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} | 202 .admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} |
202 table.tableblock.fit-content>caption.title{white-space:nowrap;width:0} | 203 table.tableblock.fit-content>caption.title{white-space:nowrap;width:0} |
234 pre.prettyprint li code[data-lang]::before{opacity:1} | 235 pre.prettyprint li code[data-lang]::before{opacity:1} |
235 pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none} | 236 pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none} |
236 table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none} | 237 table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none} |
237 table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal} | 238 table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal} |
238 table.linenotable td.code{padding-left:.75em} | 239 table.linenotable td.code{padding-left:.75em} |
239 table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em} | 240 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} |
240 pre.pygments .lineno{border-right:1px solid;opacity:.35;display:inline-block;margin-right:.75em} | 241 pre.pygments span.linenos{display:inline-block;margin-right:.75em} |
241 pre.pygments .lineno::before{content:"";margin-right:-.125em} | |
242 .quoteblock{margin:0 1em 1.25em 1.5em;display:table} | 242 .quoteblock{margin:0 1em 1.25em 1.5em;display:table} |
243 .quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em} | 243 .quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em} |
244 .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} | 244 .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} |
245 .quoteblock blockquote{margin:0;padding:0;border:0} | 245 .quoteblock blockquote{margin:0;padding:0;border:0} |
246 .quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} | 246 .quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} |
273 table.frame-sides{border-width:0 1px} | 273 table.frame-sides{border-width:0 1px} |
274 table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0} | 274 table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0} |
275 table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0} | 275 table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0} |
276 table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0} | 276 table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0} |
277 table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0} | 277 table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0} |
278 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} | 278 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} |
279 th.halign-left,td.halign-left{text-align:left} | 279 th.halign-left,td.halign-left{text-align:left} |
280 th.halign-right,td.halign-right{text-align:right} | 280 th.halign-right,td.halign-right{text-align:right} |
281 th.halign-center,td.halign-center{text-align:center} | 281 th.halign-center,td.halign-center{text-align:center} |
282 th.valign-top,td.valign-top{vertical-align:top} | 282 th.valign-top,td.valign-top{vertical-align:top} |
283 th.valign-bottom,td.valign-bottom{vertical-align:bottom} | 283 th.valign-bottom,td.valign-bottom{vertical-align:bottom} |
289 p.tableblock{font-size:1em} | 289 p.tableblock{font-size:1em} |
290 ol{margin-left:1.75em} | 290 ol{margin-left:1.75em} |
291 ul li ol{margin-left:1.5em} | 291 ul li ol{margin-left:1.5em} |
292 dl dd{margin-left:1.125em} | 292 dl dd{margin-left:1.125em} |
293 dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} | 293 dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} |
294 ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} | 294 li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} |
295 ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none} | 295 ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none} |
296 ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em} | 296 ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em} |
297 ul.unstyled,ol.unstyled{margin-left:0} | 297 ul.unstyled,ol.unstyled{margin-left:0} |
298 li>p:empty:only-child::before{content:"";display:inline-block} | |
298 ul.checklist>li>p:first-child{margin-left:-1em} | 299 ul.checklist>li>p:first-child{margin-left:-1em} |
299 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} | 300 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} |
300 ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em} | 301 ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em} |
301 ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em} | 302 ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em} |
302 ul.inline>li{margin-left:1.25em} | 303 ul.inline>li{margin-left:1.25em} |
335 #footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0} | 336 #footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0} |
336 #footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em} | 337 #footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em} |
337 #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em} | 338 #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em} |
338 #footnotes .footnote:last-of-type{margin-bottom:0} | 339 #footnotes .footnote:last-of-type{margin-bottom:0} |
339 #content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} | 340 #content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} |
340 .gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0} | |
341 .gist .file-data>table td.line-data{width:99%} | |
342 div.unbreakable{page-break-inside:avoid} | 341 div.unbreakable{page-break-inside:avoid} |
343 .big{font-size:larger} | 342 .big{font-size:larger} |
344 .small{font-size:smaller} | 343 .small{font-size:smaller} |
345 .underline{text-decoration:underline} | 344 .underline{text-decoration:underline} |
346 .overline{text-decoration:overline} | 345 .overline{text-decoration:overline} |
436 #footer{background:none} | 435 #footer{background:none} |
437 #footer-text{color:rgba(0,0,0,.6);font-size:.9em}} | 436 #footer-text{color:rgba(0,0,0,.6);font-size:.9em}} |
438 @media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}} | 437 @media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}} |
439 </style> | 438 </style> |
440 <style> | 439 <style> |
441 pre { line-height: 125%; } | |
442 td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } | |
443 span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } | |
444 td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } | |
445 span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } | |
446 pre.pygments .hll { background-color: #ffffcc } | 440 pre.pygments .hll { background-color: #ffffcc } |
447 pre.pygments { background: #f8f8f8; } | 441 pre.pygments { background: #f8f8f8; } |
448 pre.pygments .tok-c { color: #3D7B7B; font-style: italic } /* Comment */ | 442 pre.pygments .tok-c { color: #3D7B7B; font-style: italic } /* Comment */ |
449 pre.pygments .tok-err { border: 1px solid #FF0000 } /* Error */ | 443 pre.pygments .tok-err { border: 1px solid #FF0000 } /* Error */ |
450 pre.pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */ | 444 pre.pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */ |
514 pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */ | 508 pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */ |
515 </style> | 509 </style> |
516 </head> | 510 </head> |
517 <body class="article toc2 toc-right"> | 511 <body class="article toc2 toc-right"> |
518 <div id="header"> | 512 <div id="header"> |
519 <h1>pugixml 1.13 manual</h1> | 513 <h1>pugixml 1.14 manual</h1> |
520 <div class="details"> | 514 <div class="details"> |
521 <span id="author" class="author">website</span><br> | 515 <span id="author" class="author">website</span><br> |
522 <span id="email" class="email"><a href="https://pugixml.org" class="bare">https://pugixml.org</a></span><br> | 516 <span id="email" class="email"><a href="https://pugixml.org" class="bare">https://pugixml.org</a></span><br> |
523 <span id="author2" class="author">repository</span><br> | 517 <span id="author2" class="author">repository</span><br> |
524 <span id="email2" class="email"><a href="https://github.com/zeux/pugixml" class="bare">https://github.com/zeux/pugixml</a></span><br> | 518 <span id="email2" class="email"><a href="https://github.com/zeux/pugixml" class="bare">https://github.com/zeux/pugixml</a></span><br> |
609 <li><a href="#xpath.w3c">8.6. Conformance to W3C specification</a></li> | 603 <li><a href="#xpath.w3c">8.6. Conformance to W3C specification</a></li> |
610 </ul> | 604 </ul> |
611 </li> | 605 </li> |
612 <li><a href="#changes">9. Changelog</a> | 606 <li><a href="#changes">9. Changelog</a> |
613 <ul class="sectlevel2"> | 607 <ul class="sectlevel2"> |
608 <li><a href="#v1.14">v1.14 <sup>2023-10-01</sup></a></li> | |
614 <li><a href="#v1.13">v1.13 <sup>2022-11-01</sup></a></li> | 609 <li><a href="#v1.13">v1.13 <sup>2022-11-01</sup></a></li> |
615 <li><a href="#v1.12">v1.12 <sup>2022-02-09</sup></a></li> | 610 <li><a href="#v1.12">v1.12 <sup>2022-02-09</sup></a></li> |
616 <li><a href="#v1.11">v1.11 <sup>2020-11-26</sup></a></li> | 611 <li><a href="#v1.11">v1.11 <sup>2020-11-26</sup></a></li> |
617 <li><a href="#v1.10">v1.10 <sup>2019-09-15</sup></a></li> | 612 <li><a href="#v1.10">v1.10 <sup>2019-09-15</sup></a></li> |
618 <li><a href="#v1.9">v1.9 <sup>2018-04-04</sup></a></li> | 613 <li><a href="#v1.9">v1.9 <sup>2018-04-04</sup></a></li> |
713 <div class="paragraph"> | 708 <div class="paragraph"> |
714 <p>The pugixml library is distributed under the MIT license:</p> | 709 <p>The pugixml library is distributed under the MIT license:</p> |
715 </div> | 710 </div> |
716 <div class="literalblock"> | 711 <div class="literalblock"> |
717 <div class="content"> | 712 <div class="content"> |
718 <pre>Copyright (c) 2006-2022 Arseny Kapoulkine | 713 <pre>Copyright (c) 2006-2023 Arseny Kapoulkine |
719 | 714 |
720 Permission is hereby granted, free of charge, to any person | 715 Permission is hereby granted, free of charge, to any person |
721 obtaining a copy of this software and associated documentation | 716 obtaining a copy of this software and associated documentation |
722 files (the "Software"), to deal in the Software without | 717 files (the "Software"), to deal in the Software without |
723 restriction, including without limitation the rights to use, | 718 restriction, including without limitation the rights to use, |
743 <p>This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:</p> | 738 <p>This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:</p> |
744 </div> | 739 </div> |
745 <div class="literalblock"> | 740 <div class="literalblock"> |
746 <div class="content"> | 741 <div class="content"> |
747 <pre>This software is based on pugixml library (https://pugixml.org). | 742 <pre>This software is based on pugixml library (https://pugixml.org). |
748 pugixml is Copyright (C) 2006-2022 Arseny Kapoulkine.</pre> | 743 pugixml is Copyright (C) 2006-2023 Arseny Kapoulkine.</pre> |
749 </div> | 744 </div> |
750 </div> | 745 </div> |
751 </div> | 746 </div> |
752 </div> | 747 </div> |
753 </div> | 748 </div> |
763 <h4 id="install.getting.source"><a class="anchor" href="#install.getting.source"></a><a class="link" href="#install.getting.source">2.1.1. Source distributions</a></h4> | 758 <h4 id="install.getting.source"><a class="anchor" href="#install.getting.source"></a><a class="link" href="#install.getting.source">2.1.1. Source distributions</a></h4> |
764 <div class="paragraph"> | 759 <div class="paragraph"> |
765 <p>You can download the latest source distribution as an archive:</p> | 760 <p>You can download the latest source distribution as an archive:</p> |
766 </div> | 761 </div> |
767 <div class="paragraph"> | 762 <div class="paragraph"> |
768 <p><a href="https://github.com/zeux/pugixml/releases/download/v1.13/pugixml-1.13.zip">pugixml-1.13.zip</a> (Windows line endings) | 763 <p><a href="https://github.com/zeux/pugixml/releases/download/v1.14/pugixml-1.14.zip">pugixml-1.14.zip</a> (Windows line endings) |
769 / | 764 / |
770 <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> | 765 <a href="https://github.com/zeux/pugixml/releases/download/v1.14/pugixml-1.14.tar.gz">pugixml-1.14.tar.gz</a> (Unix line endings)</p> |
771 </div> | 766 </div> |
772 <div class="paragraph"> | 767 <div class="paragraph"> |
773 <p>The distribution contains library source, documentation (the manual you’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> | 768 <p>The distribution contains library source, documentation (the manual you’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> |
774 </div> | 769 </div> |
775 <div class="paragraph"> | 770 <div class="paragraph"> |
786 </div> | 781 </div> |
787 <div class="listingblock"> | 782 <div class="listingblock"> |
788 <div class="content"> | 783 <div class="content"> |
789 <pre class="pygments highlight"><code data-lang="bash">git clone https://github.com/zeux/pugixml | 784 <pre class="pygments highlight"><code data-lang="bash">git clone https://github.com/zeux/pugixml |
790 cd pugixml | 785 cd pugixml |
791 git checkout v1.13</code></pre> | 786 git checkout v1.14</code></pre> |
792 </div> | 787 </div> |
793 </div> | 788 </div> |
794 <div class="paragraph"> | 789 <div class="paragraph"> |
795 <p>The repository contains library source, documentation, code examples and full unit test suite.</p> | 790 <p>The repository contains library source, documentation, code examples and full unit test suite.</p> |
796 </div> | 791 </div> |
803 <div class="paragraph"> | 798 <div class="paragraph"> |
804 <p>You can access the Git repository via Subversion using <a href="https://github.com/zeux/pugixml" class="bare">https://github.com/zeux/pugixml</a> URL. For example, to checkout the current version, you can use this command:</p> | 799 <p>You can access the Git repository via Subversion using <a href="https://github.com/zeux/pugixml" class="bare">https://github.com/zeux/pugixml</a> URL. For example, to checkout the current version, you can use this command:</p> |
805 </div> | 800 </div> |
806 <div class="listingblock"> | 801 <div class="listingblock"> |
807 <div class="content"> | 802 <div class="content"> |
808 <pre class="pygments highlight"><code data-lang="bash">svn checkout https://github.com/zeux/pugixml/tags/v1.13 pugixml</code></pre> | 803 <pre class="pygments highlight"><code data-lang="bash">svn checkout https://github.com/zeux/pugixml/tags/v1.14 pugixml</code></pre> |
809 </div> | 804 </div> |
810 </div> | 805 </div> |
811 </div> | 806 </div> |
812 <div class="sect3"> | 807 <div class="sect3"> |
813 <h4 id="install.getting.packages"><a class="anchor" href="#install.getting.packages"></a><a class="link" href="#install.getting.packages">2.1.4. Packages</a></h4> | 808 <h4 id="install.getting.packages"><a class="anchor" href="#install.getting.packages"></a><a class="link" href="#install.getting.packages">2.1.4. Packages</a></h4> |
851 <div class="paragraph"> | 846 <div class="paragraph"> |
852 <p>If you’re using Microsoft Visual Studio and the project has precompiled headers turned on, you’ll see the following error messages:</p> | 847 <p>If you’re using Microsoft Visual Studio and the project has precompiled headers turned on, you’ll see the following error messages:</p> |
853 </div> | 848 </div> |
854 <div class="listingblock"> | 849 <div class="listingblock"> |
855 <div class="content"> | 850 <div class="content"> |
856 <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">'#</span><span class="tok-n">include</span><span class="tok-w"> </span><span class="tok-s">"stdafx.h"</span><span class="tok-err">'</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> | 851 <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">'#</span><span class="tok-n">include</span><span class="tok-w"> </span><span class="tok-s">"stdafx.h"</span><span class="tok-err">'</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></code></pre> |
857 </div> | 852 </div> |
858 </div> | 853 </div> |
859 <div class="paragraph"> | 854 <div class="paragraph"> |
860 <p>The correct way to resolve this is to disable precompiled headers for <code>pugixml.cpp</code>; you have to set "Create/Use Precompiled Header" option (Properties dialog → C/C++ → Precompiled Headers → Create/Use Precompiled Header) to "Not Using Precompiled Headers". You’ll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option):</p> | 855 <p>The correct way to resolve this is to disable precompiled headers for <code>pugixml.cpp</code>; you have to set "Create/Use Precompiled Header" option (Properties dialog → C/C++ → Precompiled Headers → Create/Use Precompiled Header) to "Not Using Precompiled Headers". You’ll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option):</p> |
861 </div> | 856 </div> |
1076 </li> | 1071 </li> |
1077 <li> | 1072 <li> |
1078 <p>Element/tag node (<a id="node_element"></a><code>node_element</code>) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:</p> | 1073 <p>Element/tag node (<a id="node_element"></a><code>node_element</code>) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:</p> |
1079 <div class="listingblock"> | 1074 <div class="listingblock"> |
1080 <div class="content"> | 1075 <div class="content"> |
1081 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><</span><span class="tok-n">node</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-o">=</span><span class="tok-s">"value"</span><span class="tok-o">><</span><span class="tok-n">child</span><span class="tok-o">/></</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"></span></code></pre> | 1076 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><</span><span class="tok-n">node</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-o">=</span><span class="tok-s">"value"</span><span class="tok-o">><</span><span class="tok-n">child</span><span class="tok-o">/></</span><span class="tok-n">node</span><span class="tok-o">></span></code></pre> |
1082 </div> | 1077 </div> |
1083 </div> | 1078 </div> |
1084 <div class="paragraph"> | 1079 <div class="paragraph"> |
1085 <p>There are two element nodes here: one has name <code>"node"</code>, single attribute <code>"attr"</code> and single child <code>"child"</code>, another has name <code>"child"</code> and does not have any attributes or child nodes.</p> | 1080 <p>There are two element nodes here: one has name <code>"node"</code>, single attribute <code>"attr"</code> and single child <code>"child"</code>, another has name <code>"child"</code> and does not have any attributes or child nodes.</p> |
1086 </div> | 1081 </div> |
1087 </li> | 1082 </li> |
1088 <li> | 1083 <li> |
1089 <p>Plain character data nodes (<a id="node_pcdata"></a><code>node_pcdata</code>) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that <strong>plain character data is not a part of the element node but instead has its own node</strong>; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:</p> | 1084 <p>Plain character data nodes (<a id="node_pcdata"></a><code>node_pcdata</code>) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that <strong>plain character data is not a part of the element node but instead has its own node</strong>; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:</p> |
1090 <div class="listingblock"> | 1085 <div class="listingblock"> |
1091 <div class="content"> | 1086 <div class="content"> |
1092 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-n">text1</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-n">child</span><span class="tok-o">/></span><span class="tok-w"> </span><span class="tok-n">text2</span><span class="tok-w"> </span><span class="tok-o"></</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"></span></code></pre> | 1087 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-n">text1</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-n">child</span><span class="tok-o">/></span><span class="tok-w"> </span><span class="tok-n">text2</span><span class="tok-w"> </span><span class="tok-o"></</span><span class="tok-n">node</span><span class="tok-o">></span></code></pre> |
1093 </div> | 1088 </div> |
1094 </div> | 1089 </div> |
1095 <div class="paragraph"> | 1090 <div class="paragraph"> |
1096 <p>Here <code>"node"</code> element has three children, two of which are PCDATA nodes with values <code>" text1 "</code> and <code>" text2 "</code>.</p> | 1091 <p>Here <code>"node"</code> element has three children, two of which are PCDATA nodes with values <code>" text1 "</code> and <code>" text2 "</code>.</p> |
1097 </div> | 1092 </div> |
1098 </li> | 1093 </li> |
1099 <li> | 1094 <li> |
1100 <p>Character data nodes (<a id="node_cdata"></a><code>node_cdata</code>) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA:</p> | 1095 <p>Character data nodes (<a id="node_cdata"></a><code>node_cdata</code>) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA:</p> |
1101 <div class="listingblock"> | 1096 <div class="listingblock"> |
1102 <div class="content"> | 1097 <div class="content"> |
1103 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-o"><!</span><span class="tok-p">[</span><span class="tok-n">CDATA</span><span class="tok-p">[</span><span class="tok-n">text1</span><span class="tok-p">]]</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-n">child</span><span class="tok-o">/></span><span class="tok-w"> </span><span class="tok-o"><!</span><span class="tok-p">[</span><span class="tok-n">CDATA</span><span class="tok-p">[</span><span class="tok-n">text2</span><span class="tok-p">]]</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-o"></</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"></span></code></pre> | 1098 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><</span><span class="tok-n">node</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-o"><!</span><span class="tok-p">[</span><span class="tok-n">CDATA</span><span class="tok-p">[</span><span class="tok-n">text1</span><span class="tok-p">]]</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-n">child</span><span class="tok-o">/></span><span class="tok-w"> </span><span class="tok-o"><!</span><span class="tok-p">[</span><span class="tok-n">CDATA</span><span class="tok-p">[</span><span class="tok-n">text2</span><span class="tok-p">]]</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-o"></</span><span class="tok-n">node</span><span class="tok-o">></span></code></pre> |
1104 </div> | 1099 </div> |
1105 </div> | 1100 </div> |
1106 <div class="paragraph"> | 1101 <div class="paragraph"> |
1107 <p>CDATA nodes make it easy to include non-escaped <code><</code>, <code>&</code> and <code>></code> characters in plain text. CDATA value can not contain the character sequence <code>]]></code>, since it is used to determine the end of node contents.</p> | 1102 <p>CDATA nodes make it easy to include non-escaped <code><</code>, <code>&</code> and <code>></code> characters in plain text. CDATA value can not contain the character sequence <code>]]></code>, since it is used to determine the end of node contents.</p> |
1108 </div> | 1103 </div> |
1109 </li> | 1104 </li> |
1110 <li> | 1105 <li> |
1111 <p>Comment nodes (<a id="node_comment"></a><code>node_comment</code>) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows:</p> | 1106 <p>Comment nodes (<a id="node_comment"></a><code>node_comment</code>) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows:</p> |
1112 <div class="listingblock"> | 1107 <div class="listingblock"> |
1113 <div class="content"> | 1108 <div class="content"> |
1114 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><!--</span><span class="tok-w"> </span><span class="tok-n">comment</span><span class="tok-w"> </span><span class="tok-n">text</span><span class="tok-w"> </span><span class="tok-o">--></span><span class="tok-w"></span></code></pre> | 1109 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><!--</span><span class="tok-w"> </span><span class="tok-n">comment</span><span class="tok-w"> </span><span class="tok-n">text</span><span class="tok-w"> </span><span class="tok-o">--></span></code></pre> |
1115 </div> | 1110 </div> |
1116 </div> | 1111 </div> |
1117 <div class="paragraph"> | 1112 <div class="paragraph"> |
1118 <p>Here the comment node has value <code>"comment text"</code>. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_comments">parse_comments</a> flag.</p> | 1113 <p>Here the comment node has value <code>"comment text"</code>. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_comments">parse_comments</a> flag.</p> |
1119 </div> | 1114 </div> |
1120 </li> | 1115 </li> |
1121 <li> | 1116 <li> |
1122 <p>Processing instruction node (<a id="node_pi"></a><code>node_pi</code>) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows:</p> | 1117 <p>Processing instruction node (<a id="node_pi"></a><code>node_pi</code>) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows:</p> |
1123 <div class="listingblock"> | 1118 <div class="listingblock"> |
1124 <div class="content"> | 1119 <div class="content"> |
1125 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><?</span><span class="tok-n">name</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-o">?></span><span class="tok-w"></span></code></pre> | 1120 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><?</span><span class="tok-n">name</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-o">?></span></code></pre> |
1126 </div> | 1121 </div> |
1127 </div> | 1122 </div> |
1128 <div class="paragraph"> | 1123 <div class="paragraph"> |
1129 <p>Here the name (also called PI target) is <code>"name"</code>, and the value is <code>"value"</code>. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_pi">parse_pi</a> flag.</p> | 1124 <p>Here the name (also called PI target) is <code>"name"</code>, and the value is <code>"value"</code>. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_pi">parse_pi</a> flag.</p> |
1130 </div> | 1125 </div> |
1131 </li> | 1126 </li> |
1132 <li> | 1127 <li> |
1133 <p>Declaration node (<a id="node_declaration"></a><code>node_declaration</code>) represents document declarations in XML. Declaration nodes have a name (<code>"xml"</code>) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:</p> | 1128 <p>Declaration node (<a id="node_declaration"></a><code>node_declaration</code>) represents document declarations in XML. Declaration nodes have a name (<code>"xml"</code>) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:</p> |
1134 <div class="listingblock"> | 1129 <div class="listingblock"> |
1135 <div class="content"> | 1130 <div class="content"> |
1136 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><?</span><span class="tok-n">xml</span><span class="tok-w"> </span><span class="tok-n">version</span><span class="tok-o">=</span><span class="tok-s">"1.0"</span><span class="tok-o">?></span><span class="tok-w"></span></code></pre> | 1131 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><?</span><span class="tok-n">xml</span><span class="tok-w"> </span><span class="tok-n">version</span><span class="tok-o">=</span><span class="tok-s">"1.0"</span><span class="tok-o">?></span></code></pre> |
1137 </div> | 1132 </div> |
1138 </div> | 1133 </div> |
1139 <div class="paragraph"> | 1134 <div class="paragraph"> |
1140 <p>Here the node has name <code>"xml"</code> and a single attribute with name <code>"version"</code> and value <code>"1.0"</code>. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_declaration">parse_declaration</a> flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with <a href="#format_no_declaration">format_no_declaration</a> flag.</p> | 1135 <p>Here the node has name <code>"xml"</code> and a single attribute with name <code>"version"</code> and value <code>"1.0"</code>. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_declaration">parse_declaration</a> flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with <a href="#format_no_declaration">format_no_declaration</a> flag.</p> |
1141 </div> | 1136 </div> |
1142 </li> | 1137 </li> |
1143 <li> | 1138 <li> |
1144 <p>Document type declaration node (<a id="node_doctype"></a><code>node_doctype</code>) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like <code><!ENTITY></code>. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:</p> | 1139 <p>Document type declaration node (<a id="node_doctype"></a><code>node_doctype</code>) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like <code><!ENTITY></code>. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:</p> |
1145 <div class="listingblock"> | 1140 <div class="listingblock"> |
1146 <div class="content"> | 1141 <div class="content"> |
1147 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><!</span><span class="tok-n">DOCTYPE</span><span class="tok-w"> </span><span class="tok-n">greeting</span><span class="tok-w"> </span><span class="tok-p">[</span><span class="tok-w"> </span><span class="tok-o"><!</span><span class="tok-n">ELEMENT</span><span class="tok-w"> </span><span class="tok-n">greeting</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-err">#</span><span class="tok-n">PCDATA</span><span class="tok-p">)</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-p">]</span><span class="tok-o">></span><span class="tok-w"></span></code></pre> | 1142 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-o"><!</span><span class="tok-n">DOCTYPE</span><span class="tok-w"> </span><span class="tok-n">greeting</span><span class="tok-w"> </span><span class="tok-p">[</span><span class="tok-w"> </span><span class="tok-o"><!</span><span class="tok-n">ELEMENT</span><span class="tok-w"> </span><span class="tok-n">greeting</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-err">#</span><span class="tok-n">PCDATA</span><span class="tok-p">)</span><span class="tok-o">></span><span class="tok-w"> </span><span class="tok-p">]</span><span class="tok-o">></span></code></pre> |
1148 </div> | 1143 </div> |
1149 </div> | 1144 </div> |
1150 <div class="paragraph"> | 1145 <div class="paragraph"> |
1151 <p>Here the node has value <code>"greeting [ <!ELEMENT greeting (#PCDATA)> ]"</code>. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_doctype">parse_doctype</a> flag.</p> | 1146 <p>Here the node has value <code>"greeting [ <!ELEMENT greeting (#PCDATA)> ]"</code>. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_doctype">parse_doctype</a> flag.</p> |
1152 </div> | 1147 </div> |
1164 <tbody> | 1159 <tbody> |
1165 <tr> | 1160 <tr> |
1166 <td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock"> | 1161 <td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock"> |
1167 <div class="content"> | 1162 <div class="content"> |
1168 <pre class="pygments highlight"><code data-lang="xml"><span></span><span class="tok-cp"><?xml version="1.0"?></span> | 1163 <pre class="pygments highlight"><code data-lang="xml"><span></span><span class="tok-cp"><?xml version="1.0"?></span> |
1169 <span class="tok-nt"><mesh</span> <span class="tok-na">name=</span><span class="tok-s">"mesh_root"</span><span class="tok-nt">></span> | 1164 <span class="tok-nt"><mesh</span><span class="tok-w"> </span><span class="tok-na">name=</span><span class="tok-s">"mesh_root"</span><span class="tok-nt">></span> |
1170 <span class="tok-cm"><!-- here is a mesh node --></span> | 1165 <span class="tok-w"> </span><span class="tok-cm"><!-- here is a mesh node --></span> |
1171 some text | 1166 <span class="tok-w"> </span>some<span class="tok-w"> </span>text |
1172 <span class="tok-cp"><![CDATA[someothertext]]></span> | 1167 <span class="tok-w"> </span><span class="tok-cp"><![CDATA[someothertext]]></span> |
1173 some more text | 1168 <span class="tok-w"> </span>some<span class="tok-w"> </span>more<span class="tok-w"> </span>text |
1174 <span class="tok-nt"><node</span> <span class="tok-na">attr1=</span><span class="tok-s">"value1"</span> <span class="tok-na">attr2=</span><span class="tok-s">"value2"</span> <span class="tok-nt">/></span> | 1169 <span class="tok-w"> </span><span class="tok-nt"><node</span><span class="tok-w"> </span><span class="tok-na">attr1=</span><span class="tok-s">"value1"</span><span class="tok-w"> </span><span class="tok-na">attr2=</span><span class="tok-s">"value2"</span><span class="tok-w"> </span><span class="tok-nt">/></span> |
1175 <span class="tok-nt"><node</span> <span class="tok-na">attr1=</span><span class="tok-s">"value2"</span><span class="tok-nt">></span> | 1170 <span class="tok-w"> </span><span class="tok-nt"><node</span><span class="tok-w"> </span><span class="tok-na">attr1=</span><span class="tok-s">"value2"</span><span class="tok-nt">></span> |
1176 <span class="tok-nt"><innernode/></span> | 1171 <span class="tok-w"> </span><span class="tok-nt"><innernode/></span> |
1177 <span class="tok-nt"></node></span> | 1172 <span class="tok-w"> </span><span class="tok-nt"></node></span> |
1178 <span class="tok-nt"></mesh></span> | 1173 <span class="tok-nt"></mesh></span> |
1179 <span class="tok-cp"><?include somedata?></span></code></pre> | 1174 <span class="tok-cp"><?include somedata?></span></code></pre> |
1180 </div> | 1175 </div> |
1181 </div></div></td> | 1176 </div></div></td> |
1182 <td class="tableblock halign-left valign-top"><div class="content"><div class="imageblock"> | 1177 <td class="tableblock halign-left valign-top"><div class="content"><div class="imageblock"> |
1251 <p><a id="xml_attribute::unspecified_bool_type"></a><a id="xml_node::unspecified_bool_type"></a><a id="xml_attribute::empty"></a><a id="xml_node::empty"></a> | 1246 <p><a id="xml_attribute::unspecified_bool_type"></a><a id="xml_node::unspecified_bool_type"></a><a id="xml_attribute::empty"></a><a id="xml_node::empty"></a> |
1252 Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node/attribute is empty with the following code: <code>if (node) { …​ }</code> or <code>if (!node) { …​ } else { …​ }</code>. Alternatively you can check if a given <code>xml_node</code>/<code>xml_attribute</code> handle is null by calling the following methods:</p> | 1247 Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node/attribute is empty with the following code: <code>if (node) { …​ }</code> or <code>if (!node) { …​ } else { …​ }</code>. Alternatively you can check if a given <code>xml_node</code>/<code>xml_attribute</code> handle is null by calling the following methods:</p> |
1253 </div> | 1248 </div> |
1254 <div class="listingblock"> | 1249 <div class="listingblock"> |
1255 <div class="content"> | 1250 <div class="content"> |
1256 <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::empty</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> | 1251 <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::empty</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
1257 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::empty</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> | 1252 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::empty</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
1258 </div> | 1253 </div> |
1259 </div> | 1254 </div> |
1260 <div class="paragraph"> | 1255 <div class="paragraph"> |
1261 <p>Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling <a href="#xml_node::remove_child">xml_node::remove_child</a>) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.</p> | 1256 <p>Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling <a href="#xml_node::remove_child">xml_node::remove_child</a>) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.</p> |
1262 </div> | 1257 </div> |
1281 <div class="paragraph"> | 1276 <div class="paragraph"> |
1282 <p>All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode:</p> | 1277 <p>All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode:</p> |
1283 </div> | 1278 </div> |
1284 <div class="listingblock"> | 1279 <div class="listingblock"> |
1285 <div class="content"> | 1280 <div class="content"> |
1286 <pre class="pygments highlight"><code data-lang="c++"><span></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-nf">xml_node::name</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> | 1281 <pre class="pygments highlight"><code data-lang="c++"><span></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-nf">xml_node::name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
1287 <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-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1282 <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-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span></code></pre> |
1288 </div> | 1283 </div> |
1289 </div> | 1284 </div> |
1290 <div class="paragraph"> | 1285 <div class="paragraph"> |
1291 <p>and like this in wchar_t mode:</p> | 1286 <p>and like this in wchar_t mode:</p> |
1292 </div> | 1287 </div> |
1293 <div class="listingblock"> | 1288 <div class="listingblock"> |
1294 <div class="content"> | 1289 <div class="content"> |
1295 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xml_node::name</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> | 1290 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xml_node::name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
1296 <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-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1291 <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-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span></code></pre> |
1297 </div> | 1292 </div> |
1298 </div> | 1293 </div> |
1299 <div class="paragraph"> | 1294 <div class="paragraph"> |
1300 <p><a id="char_t"></a><a id="string_t"></a> | 1295 <p><a id="char_t"></a><a id="string_t"></a> |
1301 There is a special type, <code>pugi::char_t</code>, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type <code>pugi::string_t</code>, which is defined as the STL string of the character type; it corresponds to <code>std::string</code> in char mode and to <code>std::wstring</code> in wchar_t mode.</p> | 1296 There is a special type, <code>pugi::char_t</code>, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type <code>pugi::string_t</code>, which is defined as the STL string of the character type; it corresponds to <code>std::string</code> in char mode and to <code>std::wstring</code> in wchar_t mode.</p> |
1307 <p><a id="as_utf8"></a><a id="as_wide"></a> | 1302 <p><a id="as_utf8"></a><a id="as_wide"></a> |
1308 There are cases when you’ll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes:</p> | 1303 There are cases when you’ll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes:</p> |
1309 </div> | 1304 </div> |
1310 <div class="listingblock"> | 1305 <div class="listingblock"> |
1311 <div class="content"> | 1306 <div class="content"> |
1312 <pre class="pygments highlight"><code data-lang="c++"><span></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-nf">as_utf8</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span><span class="tok-w"></span> | 1307 <pre class="pygments highlight"><code data-lang="c++"><span></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-nf">as_utf8</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span> |
1313 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><span class="tok-nf">as_wide</span><span class="tok-p">(</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">str</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1308 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><span class="tok-nf">as_wide</span><span class="tok-p">(</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">str</span><span class="tok-p">);</span></code></pre> |
1314 </div> | 1309 </div> |
1315 </div> | 1310 </div> |
1316 <div class="paragraph"> | 1311 <div class="paragraph"> |
1317 <p>Both functions accept a null-terminated string as an argument <code>str</code>, and return the converted string. <code>as_utf8</code> performs conversion from UTF-16/32 to UTF-8; <code>as_wide</code> performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. <code>str</code> has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument:</p> | 1312 <p>Both functions accept a null-terminated string as an argument <code>str</code>, and return the converted string. <code>as_utf8</code> performs conversion from UTF-16/32 to UTF-8; <code>as_wide</code> performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. <code>str</code> has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument:</p> |
1318 </div> | 1313 </div> |
1319 <div class="listingblock"> | 1314 <div class="listingblock"> |
1320 <div class="content"> | 1315 <div class="content"> |
1321 <pre class="pygments highlight"><code data-lang="c++"><span></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-nf">as_utf8</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span><span class="tok-w"></span> | 1316 <pre class="pygments highlight"><code data-lang="c++"><span></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-nf">as_utf8</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span> |
1322 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><span class="tok-nf">as_wide</span><span class="tok-p">(</span><span class="tok-k">const</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-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1317 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><span class="tok-nf">as_wide</span><span class="tok-p">(</span><span class="tok-k">const</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-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span></code></pre> |
1323 </div> | 1318 </div> |
1324 </div> | 1319 </div> |
1325 <div class="admonitionblock note"> | 1320 <div class="admonitionblock note"> |
1326 <table> | 1321 <table> |
1327 <tr> | 1322 <tr> |
1394 <p><a id="allocation_function"></a><a id="deallocation_function"></a> | 1389 <p><a id="allocation_function"></a><a id="deallocation_function"></a> |
1395 All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free:</p> | 1390 All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free:</p> |
1396 </div> | 1391 </div> |
1397 <div class="listingblock"> | 1392 <div class="listingblock"> |
1398 <div class="content"> | 1393 <div class="content"> |
1399 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">typedef</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-p">(</span><span class="tok-o">*</span><span class="tok-n">allocation_function</span><span class="tok-p">)(</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> | 1394 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">typedef</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-p">(</span><span class="tok-o">*</span><span class="tok-n">allocation_function</span><span class="tok-p">)(</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
1400 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">*</span><span class="tok-n">deallocation_function</span><span class="tok-p">)(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">ptr</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1395 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">*</span><span class="tok-n">deallocation_function</span><span class="tok-p">)(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">ptr</span><span class="tok-p">);</span></code></pre> |
1401 </div> | 1396 </div> |
1402 </div> | 1397 </div> |
1403 <div class="paragraph"> | 1398 <div class="paragraph"> |
1404 <p><a id="set_memory_management_functions"></a><a id="get_memory_allocation_function"></a><a id="get_memory_deallocation_function"></a> | 1399 <p><a id="set_memory_management_functions"></a><a id="get_memory_allocation_function"></a><a id="get_memory_deallocation_function"></a> |
1405 You can use the following accessor functions to change or get current memory management functions:</p> | 1400 You can use the following accessor functions to change or get current memory management functions:</p> |
1406 </div> | 1401 </div> |
1407 <div class="listingblock"> | 1402 <div class="listingblock"> |
1408 <div class="content"> | 1403 <div class="content"> |
1409 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">set_memory_management_functions</span><span class="tok-p">(</span><span class="tok-n">allocation_function</span><span class="tok-w"> </span><span class="tok-n">allocate</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">deallocation_function</span><span class="tok-w"> </span><span class="tok-n">deallocate</span><span class="tok-p">);</span><span class="tok-w"></span> | 1404 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">set_memory_management_functions</span><span class="tok-p">(</span><span class="tok-n">allocation_function</span><span class="tok-w"> </span><span class="tok-n">allocate</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">deallocation_function</span><span class="tok-w"> </span><span class="tok-n">deallocate</span><span class="tok-p">);</span> |
1410 <span class="tok-n">allocation_function</span><span class="tok-w"> </span><span class="tok-nf">get_memory_allocation_function</span><span class="tok-p">();</span><span class="tok-w"></span> | 1405 <span class="tok-n">allocation_function</span><span class="tok-w"> </span><span class="tok-nf">get_memory_allocation_function</span><span class="tok-p">();</span> |
1411 <span class="tok-n">deallocation_function</span><span class="tok-w"> </span><span class="tok-nf">get_memory_deallocation_function</span><span class="tok-p">();</span><span class="tok-w"></span></code></pre> | 1406 <span class="tok-n">deallocation_function</span><span class="tok-w"> </span><span class="tok-nf">get_memory_deallocation_function</span><span class="tok-p">();</span></code></pre> |
1412 </div> | 1407 </div> |
1413 </div> | 1408 </div> |
1414 <div class="paragraph"> | 1409 <div class="paragraph"> |
1415 <p>Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of <code>void*</code> and <code>double</code> types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to either return null pointer or to throw an exception.</p> | 1410 <p>Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of <code>void*</code> and <code>double</code> types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to either return null pointer or to throw an exception.</p> |
1416 </div> | 1411 </div> |
1420 <div class="paragraph"> | 1415 <div class="paragraph"> |
1421 <p>This is a simple example of custom memory management (<a href="samples/custom_memory_management.cpp" class="bare">samples/custom_memory_management.cpp</a>):</p> | 1416 <p>This is a simple example of custom memory management (<a href="samples/custom_memory_management.cpp" class="bare">samples/custom_memory_management.cpp</a>):</p> |
1422 </div> | 1417 </div> |
1423 <div class="listingblock"> | 1418 <div class="listingblock"> |
1424 <div class="content"> | 1419 <div class="content"> |
1425 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">custom_allocate</span><span class="tok-p">(</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> | 1420 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">custom_allocate</span><span class="tok-p">(</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">)</span> |
1426 <span class="tok-p">{</span><span class="tok-w"></span> | 1421 <span class="tok-p">{</span> |
1427 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-k">new</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">nothrow</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span><span class="tok-w"></span> | 1422 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-k">new</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">nothrow</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span> |
1428 <span class="tok-p">}</span><span class="tok-w"></span> | 1423 <span class="tok-p">}</span> |
1429 | 1424 |
1430 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">custom_deallocate</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">ptr</span><span class="tok-p">)</span><span class="tok-w"></span> | 1425 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">custom_deallocate</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">ptr</span><span class="tok-p">)</span> |
1431 <span class="tok-p">{</span><span class="tok-w"></span> | 1426 <span class="tok-p">{</span> |
1432 <span class="tok-w"> </span><span class="tok-k">delete</span><span class="tok-p">[]</span><span class="tok-w"> </span><span class="tok-k">static_cast</span><span class="tok-o"><</span><span class="tok-kt">char</span><span class="tok-o">*></span><span class="tok-p">(</span><span class="tok-n">ptr</span><span class="tok-p">);</span><span class="tok-w"></span> | 1427 <span class="tok-w"> </span><span class="tok-k">delete</span><span class="tok-p">[]</span><span class="tok-w"> </span><span class="tok-k">static_cast</span><span class="tok-o"><</span><span class="tok-kt">char</span><span class="tok-o">*></span><span class="tok-p">(</span><span class="tok-n">ptr</span><span class="tok-p">);</span> |
1433 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 1428 <span class="tok-p">}</span></code></pre> |
1434 </div> | 1429 </div> |
1435 </div> | 1430 </div> |
1436 <div class="listingblock"> | 1431 <div class="listingblock"> |
1437 <div class="content"> | 1432 <div class="content"> |
1438 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">set_memory_management_functions</span><span class="tok-p">(</span><span class="tok-n">custom_allocate</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">custom_deallocate</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1433 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">set_memory_management_functions</span><span class="tok-p">(</span><span class="tok-n">custom_allocate</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">custom_deallocate</span><span class="tok-p">);</span></code></pre> |
1439 </div> | 1434 </div> |
1440 </div> | 1435 </div> |
1441 <div class="paragraph"> | 1436 <div class="paragraph"> |
1442 <p>When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.</p> | 1437 <p>When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.</p> |
1443 </div> | 1438 </div> |
1509 <p><a id="xml_document::load_file"></a><a id="xml_document::load_file_wide"></a> | 1504 <p><a id="xml_document::load_file"></a><a id="xml_document::load_file_wide"></a> |
1510 The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:</p> | 1505 The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:</p> |
1511 </div> | 1506 </div> |
1512 <div class="listingblock"> | 1507 <div class="listingblock"> |
1513 <div class="content"> | 1508 <div class="content"> |
1514 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_file</span><span class="tok-p">(</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">path</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 1509 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_file</span><span class="tok-p">(</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">path</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
1515 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_file</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1510 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_file</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span></code></pre> |
1516 </div> | 1511 </div> |
1517 </div> | 1512 </div> |
1518 <div class="paragraph"> | 1513 <div class="paragraph"> |
1519 <p>These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <a href="#loading.options">Parsing options</a>) and input data encoding (see <a href="#loading.encoding">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.</p> | 1514 <p>These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <a href="#loading.options">Parsing options</a>) and input data encoding (see <a href="#loading.encoding">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.</p> |
1520 </div> | 1515 </div> |
1527 <div class="paragraph"> | 1522 <div class="paragraph"> |
1528 <p>This is an example of loading XML document from file (<a href="samples/load_file.cpp" class="bare">samples/load_file.cpp</a>):</p> | 1523 <p>This is an example of loading XML document from file (<a href="samples/load_file.cpp" class="bare">samples/load_file.cpp</a>):</p> |
1529 </div> | 1524 </div> |
1530 <div class="listingblock"> | 1525 <div class="listingblock"> |
1531 <div class="content"> | 1526 <div class="content"> |
1532 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 1527 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
1533 | 1528 |
1534 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-s">"tree.xml"</span><span class="tok-p">);</span><span class="tok-w"></span> | 1529 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-s">"tree.xml"</span><span class="tok-p">);</span> |
1535 | 1530 |
1536 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Load result: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">", mesh name: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"mesh"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 1531 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Load result: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">", mesh name: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"mesh"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
1537 </div> | 1532 </div> |
1538 </div> | 1533 </div> |
1539 </div> | 1534 </div> |
1540 <div class="sect2"> | 1535 <div class="sect2"> |
1541 <h3 id="loading.memory"><a class="anchor" href="#loading.memory"></a><a class="link" href="#loading.memory">4.2. Loading document from memory</a></h3> | 1536 <h3 id="loading.memory"><a class="anchor" href="#loading.memory"></a><a class="link" href="#loading.memory">4.2. Loading document from memory</a></h3> |
1543 <p><a id="xml_document::load_buffer"></a><a id="xml_document::load_buffer_inplace"></a><a id="xml_document::load_buffer_inplace_own"></a> | 1538 <p><a id="xml_document::load_buffer"></a><a id="xml_document::load_buffer_inplace"></a><a id="xml_document::load_buffer_inplace_own"></a> |
1544 Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from GZip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage:</p> | 1539 Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from GZip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage:</p> |
1545 </div> | 1540 </div> |
1546 <div class="listingblock"> | 1541 <div class="listingblock"> |
1547 <div class="content"> | 1542 <div class="content"> |
1548 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_buffer</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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 1543 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_buffer</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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
1549 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 1544 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
1550 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_buffer_inplace_own</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1545 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_buffer_inplace_own</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span></code></pre> |
1551 </div> | 1546 </div> |
1552 </div> | 1547 </div> |
1553 <div class="paragraph"> | 1548 <div class="paragraph"> |
1554 <p>All functions accept the buffer which is represented by a pointer to XML data, <code>contents</code>, and data size in bytes. Also there are two optional arguments, which specify parsing options (see <a href="#loading.options">Parsing options</a>) and input data encoding (see <a href="#loading.encoding">Encodings</a>). The buffer does not have to be zero-terminated.</p> | 1549 <p>All functions accept the buffer which is represented by a pointer to XML data, <code>contents</code>, and data size in bytes. Also there are two optional arguments, which specify parsing options (see <a href="#loading.options">Parsing options</a>) and input data encoding (see <a href="#loading.encoding">Encodings</a>). The buffer does not have to be zero-terminated.</p> |
1555 </div> | 1550 </div> |
1562 <div id="xml_document::load_string" class="paragraph"> | 1557 <div id="xml_document::load_string" class="paragraph"> |
1563 <p>There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:</p> | 1558 <p>There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:</p> |
1564 </div> | 1559 </div> |
1565 <div class="listingblock"> | 1560 <div class="listingblock"> |
1566 <div class="content"> | 1561 <div class="content"> |
1567 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_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">contents</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1562 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load_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">contents</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span></code></pre> |
1568 </div> | 1563 </div> |
1569 </div> | 1564 </div> |
1570 <div class="paragraph"> | 1565 <div class="paragraph"> |
1571 <p>It is equivalent to calling <code>load_buffer</code> with <code>size</code> being either <code>strlen(contents)</code> or <code>wcslen(contents) * sizeof(wchar_t)</code>, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.</p> | 1566 <p>It is equivalent to calling <code>load_buffer</code> with <code>size</code> being either <code>strlen(contents)</code> or <code>wcslen(contents) * sizeof(wchar_t)</code>, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.</p> |
1572 </div> | 1567 </div> |
1573 <div class="paragraph"> | 1568 <div class="paragraph"> |
1574 <p>This is an example of loading XML document from memory using different functions (<a href="samples/load_memory.cpp" class="bare">samples/load_memory.cpp</a>):</p> | 1569 <p>This is an example of loading XML document from memory using different functions (<a href="samples/load_memory.cpp" class="bare">samples/load_memory.cpp</a>):</p> |
1575 </div> | 1570 </div> |
1576 <div class="listingblock"> | 1571 <div class="listingblock"> |
1577 <div class="content"> | 1572 <div class="content"> |
1578 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-p">[]</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1573 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-p">[]</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="tok-p">;</span> |
1579 <span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-k">sizeof</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1574 <span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-k">sizeof</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span></code></pre> |
1580 </div> | 1575 </div> |
1581 </div> | 1576 </div> |
1582 <div class="listingblock"> | 1577 <div class="listingblock"> |
1583 <div class="content"> | 1578 <div class="content"> |
1584 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load_buffer to load document from immutable memory block:</span> | 1579 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load_buffer to load document from immutable memory block:</span> |
1585 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1580 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span></code></pre> |
1586 </div> | 1581 </div> |
1587 </div> | 1582 </div> |
1588 <div class="listingblock"> | 1583 <div class="listingblock"> |
1589 <div class="content"> | 1584 <div class="content"> |
1590 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document</span> | 1585 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document</span> |
1591 <span class="tok-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-k">new</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span><span class="tok-w"></span> | 1586 <span class="tok-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-k">new</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span> |
1592 <span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span> | 1587 <span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
1593 | 1588 |
1594 <span class="tok-c1">// The block can be allocated by any method; the block is modified during parsing</span> | 1589 <span class="tok-c1">// The block can be allocated by any method; the block is modified during parsing</span> |
1595 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span> | 1590 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
1596 | 1591 |
1597 <span class="tok-c1">// You have to destroy the block yourself after the document is no longer used</span> | 1592 <span class="tok-c1">// You have to destroy the block yourself after the document is no longer used</span> |
1598 <span class="tok-k">delete</span><span class="tok-p">[]</span><span class="tok-w"> </span><span class="tok-n">buffer</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 1593 <span class="tok-k">delete</span><span class="tok-p">[]</span><span class="tok-w"> </span><span class="tok-n">buffer</span><span class="tok-p">;</span></code></pre> |
1599 </div> | 1594 </div> |
1600 </div> | 1595 </div> |
1601 <div class="listingblock"> | 1596 <div class="listingblock"> |
1602 <div class="content"> | 1597 <div class="content"> |
1603 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block</span> | 1598 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block</span> |
1604 <span class="tok-c1">// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect</span> | 1599 <span class="tok-c1">// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect</span> |
1605 <span class="tok-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-k">static_cast</span><span class="tok-o"><</span><span class="tok-kt">char</span><span class="tok-o">*></span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">get_memory_allocation_function</span><span class="tok-p">()(</span><span class="tok-n">size</span><span class="tok-p">));</span><span class="tok-w"></span> | 1600 <span class="tok-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-k">static_cast</span><span class="tok-o"><</span><span class="tok-kt">char</span><span class="tok-o">*></span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">get_memory_allocation_function</span><span class="tok-p">()(</span><span class="tok-n">size</span><span class="tok-p">));</span> |
1606 <span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span> | 1601 <span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
1607 | 1602 |
1608 <span class="tok-c1">// The block will be deleted by the document</span> | 1603 <span class="tok-c1">// The block will be deleted by the document</span> |
1609 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace_own</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1604 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace_own</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span></code></pre> |
1610 </div> | 1605 </div> |
1611 </div> | 1606 </div> |
1612 <div class="listingblock"> | 1607 <div class="listingblock"> |
1613 <div class="content"> | 1608 <div class="content"> |
1614 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load to load document from null-terminated strings, for example literals:</span> | 1609 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// You can use load to load document from null-terminated strings, for example literals:</span> |
1615 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1610 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>"</span><span class="tok-p">);</span></code></pre> |
1616 </div> | 1611 </div> |
1617 </div> | 1612 </div> |
1618 </div> | 1613 </div> |
1619 <div class="sect2"> | 1614 <div class="sect2"> |
1620 <h3 id="loading.stream"><a class="anchor" href="#loading.stream"></a><a class="link" href="#loading.stream">4.3. Loading document from C++ IOstreams</a></h3> | 1615 <h3 id="loading.stream"><a class="anchor" href="#loading.stream"></a><a class="link" href="#loading.stream">4.3. Loading document from C++ IOstreams</a></h3> |
1621 <div id="xml_document::load_stream" class="paragraph"> | 1616 <div id="xml_document::load_stream" class="paragraph"> |
1622 <p>To enhance interoperability, pugixml provides functions for loading document from any object which implements C++ <code>std::istream</code> interface. This allows you to load documents from any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones:</p> | 1617 <p>To enhance interoperability, pugixml provides functions for loading document from any object which implements C++ <code>std::istream</code> interface. This allows you to load documents from any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones:</p> |
1623 </div> | 1618 </div> |
1624 <div class="listingblock"> | 1619 <div class="listingblock"> |
1625 <div class="content"> | 1620 <div class="content"> |
1626 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">istream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 1621 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">istream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
1627 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wistream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1622 <span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_document::load</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wistream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span></code></pre> |
1628 </div> | 1623 </div> |
1629 </div> | 1624 </div> |
1630 <div class="paragraph"> | 1625 <div class="paragraph"> |
1631 <p><code>load</code> with <code>std::istream</code> argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling <code>xml_document::load</code> on an opened <code>std::ifstream</code> object is equivalent to calling <code>xml_document::load_file</code>.</p> | 1626 <p><code>load</code> with <code>std::istream</code> argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling <code>xml_document::load</code> on an opened <code>std::ifstream</code> object is equivalent to calling <code>xml_document::load_file</code>.</p> |
1632 </div> | 1627 </div> |
1636 <div class="paragraph"> | 1631 <div class="paragraph"> |
1637 <p>This is a simple example of loading XML document from file using streams (<a href="samples/load_stream.cpp" class="bare">samples/load_stream.cpp</a>); read the sample code for more complex examples involving wide streams and locales:</p> | 1632 <p>This is a simple example of loading XML document from file using streams (<a href="samples/load_stream.cpp" class="bare">samples/load_stream.cpp</a>); read the sample code for more complex examples involving wide streams and locales:</p> |
1638 </div> | 1633 </div> |
1639 <div class="listingblock"> | 1634 <div class="listingblock"> |
1640 <div class="content"> | 1635 <div class="content"> |
1641 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ifstream</span><span class="tok-w"> </span><span class="tok-nf">stream</span><span class="tok-p">(</span><span class="tok-s">"weekly-utf-8.xml"</span><span class="tok-p">);</span><span class="tok-w"></span> | 1636 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ifstream</span><span class="tok-w"> </span><span class="tok-n">stream</span><span class="tok-p">(</span><span class="tok-s">"weekly-utf-8.xml"</span><span class="tok-p">);</span> |
1642 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load</span><span class="tok-p">(</span><span class="tok-n">stream</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 1637 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load</span><span class="tok-p">(</span><span class="tok-n">stream</span><span class="tok-p">);</span></code></pre> |
1643 </div> | 1638 </div> |
1644 </div> | 1639 </div> |
1645 </div> | 1640 </div> |
1646 <div class="sect2"> | 1641 <div class="sect2"> |
1647 <h3 id="loading.errors"><a class="anchor" href="#loading.errors"></a><a class="link" href="#loading.errors">4.4. Handling parsing errors</a></h3> | 1642 <h3 id="loading.errors"><a class="anchor" href="#loading.errors"></a><a class="link" href="#loading.errors">4.4. Handling parsing errors</a></h3> |
1648 <div id="xml_parse_result" class="paragraph"> | 1643 <div id="xml_parse_result" class="paragraph"> |
1649 <p>All document loading functions return the parsing result via <code>xml_parse_result</code> object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream:</p> | 1644 <p>All document loading functions return the parsing result via <code>xml_parse_result</code> object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream:</p> |
1650 </div> | 1645 </div> |
1651 <div class="listingblock"> | 1646 <div class="listingblock"> |
1652 <div class="content"> | 1647 <div class="content"> |
1653 <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> | 1648 <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> |
1654 <span class="tok-p">{</span><span class="tok-w"></span> | 1649 <span class="tok-p">{</span> |
1655 <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> | 1650 <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> |
1656 <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> | 1651 <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> |
1657 <span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-p">;</span><span class="tok-w"></span> | 1652 <span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-p">;</span> |
1658 | 1653 |
1659 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><span class="tok-kt">bool</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> | 1654 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
1660 <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-nf">description</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> | 1655 <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-nf">description</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
1661 <span class="tok-p">};</span><span class="tok-w"></span></code></pre> | 1656 <span class="tok-p">};</span></code></pre> |
1662 </div> | 1657 </div> |
1663 </div> | 1658 </div> |
1664 <div class="paragraph"> | 1659 <div class="paragraph"> |
1665 <p><a id="xml_parse_status"></a><a id="xml_parse_result::status"></a> | 1660 <p><a id="xml_parse_status"></a><a id="xml_parse_result::status"></a> |
1666 Parsing status is represented as the <code>xml_parse_status</code> enumeration and can be one of the following:</p> | 1661 Parsing status is represented as the <code>xml_parse_status</code> enumeration and can be one of the following:</p> |
1738 <div class="paragraph"> | 1733 <div class="paragraph"> |
1739 <p>This is an example of handling loading errors (<a href="samples/load_error_handling.cpp" class="bare">samples/load_error_handling.cpp</a>):</p> | 1734 <p>This is an example of handling loading errors (<a href="samples/load_error_handling.cpp" class="bare">samples/load_error_handling.cpp</a>):</p> |
1740 </div> | 1735 </div> |
1741 <div class="listingblock"> | 1736 <div class="listingblock"> |
1742 <div class="content"> | 1737 <div class="content"> |
1743 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 1738 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
1744 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span><span class="tok-w"></span> | 1739 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span> |
1745 | 1740 |
1746 <span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">result</span><span class="tok-p">)</span><span class="tok-w"></span> | 1741 <span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">result</span><span class="tok-p">)</span> |
1747 <span class="tok-p">{</span><span class="tok-w"></span> | 1742 <span class="tok-p">{</span> |
1748 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"XML ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"] parsed without errors, attr value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1743 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"XML ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"] parsed without errors, attr value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1749 <span class="tok-p">}</span><span class="tok-w"></span> | 1744 <span class="tok-p">}</span> |
1750 <span class="tok-k">else</span><span class="tok-w"></span> | 1745 <span class="tok-k">else</span> |
1751 <span class="tok-p">{</span><span class="tok-w"></span> | 1746 <span class="tok-p">{</span> |
1752 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"XML ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"] parsed with errors, attr value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1747 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"XML ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">source</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"] parsed with errors, attr value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1753 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Error description: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1748 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Error description: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1754 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Error offset: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">" (error at [..."</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-w"> </span><span class="tok-o">+</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1749 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Error offset: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">" (error at [..."</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-w"> </span><span class="tok-o">+</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1755 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 1750 <span class="tok-p">}</span></code></pre> |
1756 </div> | 1751 </div> |
1757 </div> | 1752 </div> |
1758 </div> | 1753 </div> |
1759 <div class="sect2"> | 1754 <div class="sect2"> |
1760 <h3 id="loading.options"><a class="anchor" href="#loading.options"></a><a class="link" href="#loading.options">4.5. Parsing options</a></h3> | 1755 <h3 id="loading.options"><a class="anchor" href="#loading.options"></a><a class="link" href="#loading.options">4.5. Parsing options</a></h3> |
1805 <li> | 1800 <li> |
1806 <p><a id="parse_embed_pcdata"></a><code>parse_embed_pcdata</code> determines if PCDATA contents is to be saved as element values. Normally element nodes have names but not values; this flag forces the parser to store the contents as a value if PCDATA is the first child of the element node (otherwise PCDATA node is created as usual). This can significantly reduce the memory required for documents with many PCDATA nodes. To retrieve the data you can use <code>xml_node::value()</code> on the element nodes or any of the higher-level functions like <code>child_value</code> or <code>text</code>. This flag is <strong>off</strong> by default. | 1801 <p><a id="parse_embed_pcdata"></a><code>parse_embed_pcdata</code> determines if PCDATA contents is to be saved as element values. Normally element nodes have names but not values; this flag forces the parser to store the contents as a value if PCDATA is the first child of the element node (otherwise PCDATA node is created as usual). This can significantly reduce the memory required for documents with many PCDATA nodes. To retrieve the data you can use <code>xml_node::value()</code> on the element nodes or any of the higher-level functions like <code>child_value</code> or <code>text</code>. This flag is <strong>off</strong> by default. |
1807 Since this flag significantly changes the DOM structure it is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments. This flag is <strong>off</strong> by default.</p> | 1802 Since this flag significantly changes the DOM structure it is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments. This flag is <strong>off</strong> by default.</p> |
1808 </li> | 1803 </li> |
1809 <li> | 1804 <li> |
1810 <p><a id="parse_fragment"></a><code>parse_fragment</code> determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid and permits multiple top-level element nodes. This flag is <strong>off</strong> by default.</p> | 1805 <p><a id="parse_merge_pcdata"></a><code>parse_merge_pcdata</code> determines if PCDATA contents is to be merged with the previous PCDATA node when no intermediary nodes are present between them. If the PCDATA contains CDATA sections, PI nodes, or comments in between, and either of the flags <a href="#parse_cdata">parse_cdata</a> ,<a href="#parse_pi">parse_pi</a> ,<a href="#parse_comments">parse_comments</a> is not set, the contents of the PCDATA node will be merged with the previous one. This flag is <strong>off</strong> by default.</p> |
1806 </li> | |
1807 <li> | |
1808 <p><a id="parse_fragment"></a><code>parse_fragment</code> determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid and permits multiple top-level element nodes (currently multiple top-level element nodes are also permitted when the flag is off, but that behavior should not be relied on). This flag is <strong>off</strong> by default.</p> | |
1811 </li> | 1809 </li> |
1812 </ul> | 1810 </ul> |
1813 </div> | 1811 </div> |
1814 <div class="admonitionblock caution"> | 1812 <div class="admonitionblock caution"> |
1815 <table> | 1813 <table> |
1873 <div class="paragraph"> | 1871 <div class="paragraph"> |
1874 <p>This is an example of using different parsing options (<a href="samples/load_options.cpp" class="bare">samples/load_options.cpp</a>):</p> | 1872 <p>This is an example of using different parsing options (<a href="samples/load_options.cpp" class="bare">samples/load_options.cpp</a>):</p> |
1875 </div> | 1873 </div> |
1876 <div class="listingblock"> | 1874 <div class="listingblock"> |
1877 <div class="content"> | 1875 <div class="content"> |
1878 <pre class="pygments highlight"><code data-lang="c++"><span></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">source</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"<!--comment--><node>&lt;</node>"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1876 <pre class="pygments highlight"><code data-lang="c++"><span></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">source</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"<!--comment--><node>&lt;</node>"</span><span class="tok-p">;</span> |
1879 | 1877 |
1880 <span class="tok-c1">// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded</span> | 1878 <span class="tok-c1">// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded</span> |
1881 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span><span class="tok-w"></span> | 1879 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span> |
1882 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1880 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1883 | 1881 |
1884 <span class="tok-c1">// Parsing with additional parse_comments option; comment node is now added to the tree</span> | 1882 <span class="tok-c1">// Parsing with additional parse_comments option; comment node is now added to the tree</span> |
1885 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span><span class="tok-w"> </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">parse_comments</span><span class="tok-p">);</span><span class="tok-w"></span> | 1883 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span><span class="tok-w"> </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">parse_comments</span><span class="tok-p">);</span> |
1886 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1884 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1887 | 1885 |
1888 <span class="tok-c1">// Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded</span> | 1886 <span class="tok-c1">// Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded</span> |
1889 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</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">parse_default</span><span class="tok-w"> </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">parse_comments</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-o">~</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_escapes</span><span class="tok-p">);</span><span class="tok-w"></span> | 1887 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</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">parse_default</span><span class="tok-w"> </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">parse_comments</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-o">~</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_escapes</span><span class="tok-p">);</span> |
1890 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 1888 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
1891 | 1889 |
1892 <span class="tok-c1">// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded</span> | 1890 <span class="tok-c1">// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded</span> |
1893 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_minimal</span><span class="tok-p">);</span><span class="tok-w"></span> | 1891 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_minimal</span><span class="tok-p">);</span> |
1894 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 1892 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"First node value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"], node child value: ["</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"]</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span></code></pre> |
1895 </div> | 1893 </div> |
1896 </div> | 1894 </div> |
1897 </div> | 1895 </div> |
1898 <div class="sect2"> | 1896 <div class="sect2"> |
1899 <h3 id="loading.encoding"><a class="anchor" href="#loading.encoding"></a><a class="link" href="#loading.encoding">4.6. Encodings</a></h3> | 1897 <h3 id="loading.encoding"><a class="anchor" href="#loading.encoding"></a><a class="link" href="#loading.encoding">4.6. Encodings</a></h3> |
2007 <p><a id="xml_node::parent"></a><a id="xml_node::first_child"></a><a id="xml_node::last_child"></a><a id="xml_node::next_sibling"></a><a id="xml_node::previous_sibling"></a><a id="xml_node::first_attribute"></a><a id="xml_node::last_attribute"></a><a id="xml_attribute::next_attribute"></a><a id="xml_attribute::previous_attribute"></a> | 2005 <p><a id="xml_node::parent"></a><a id="xml_node::first_child"></a><a id="xml_node::last_child"></a><a id="xml_node::next_sibling"></a><a id="xml_node::previous_sibling"></a><a id="xml_node::first_attribute"></a><a id="xml_node::last_attribute"></a><a id="xml_attribute::next_attribute"></a><a id="xml_attribute::previous_attribute"></a> |
2008 The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).</p> | 2006 The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).</p> |
2009 </div> | 2007 </div> |
2010 <div class="listingblock"> | 2008 <div class="listingblock"> |
2011 <div class="content"> | 2009 <div class="content"> |
2012 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::parent</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> | 2010 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::parent</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2013 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::first_child</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> | 2011 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::first_child</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2014 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::last_child</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> | 2012 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::last_child</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2015 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::next_sibling</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> | 2013 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::next_sibling</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2016 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::previous_sibling</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> | 2014 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::previous_sibling</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2017 | 2015 |
2018 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::first_attribute</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> | 2016 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::first_attribute</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2019 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::last_attribute</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> | 2017 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::last_attribute</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2020 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::next_attribute</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> | 2018 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::next_attribute</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2021 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::previous_attribute</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> | 2019 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_attribute::previous_attribute</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2022 </div> | 2020 </div> |
2023 </div> | 2021 </div> |
2024 <div class="paragraph"> | 2022 <div class="paragraph"> |
2025 <p><code>parent</code> function returns the node’s parent; all non-null nodes except the document have non-null parent. <code>first_child</code> and <code>last_child</code> return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. <code>next_sibling</code> and <code>previous_sibling</code> return the node that’s immediately to the right/left of this node in the children list, respectively - for example, in <code><a/><b/><c/></code>, calling <code>next_sibling</code> for a handle that points to <code><b/></code> results in a handle pointing to <code><c/></code>, and calling <code>previous_sibling</code> results in handle pointing to <code><a/></code>. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. <code>first_attribute</code>, <code>last_attribute</code>, <code>next_attribute</code> and <code>previous_attribute</code> functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way.</p> | 2023 <p><code>parent</code> function returns the node’s parent; all non-null nodes except the document have non-null parent. <code>first_child</code> and <code>last_child</code> return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. <code>next_sibling</code> and <code>previous_sibling</code> return the node that’s immediately to the right/left of this node in the children list, respectively - for example, in <code><a/><b/><c/></code>, calling <code>next_sibling</code> for a handle that points to <code><b/></code> results in a handle pointing to <code><c/></code>, and calling <code>previous_sibling</code> results in handle pointing to <code><a/></code>. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. <code>first_attribute</code>, <code>last_attribute</code>, <code>next_attribute</code> and <code>previous_attribute</code> functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way.</p> |
2026 </div> | 2024 </div> |
2042 <div class="paragraph"> | 2040 <div class="paragraph"> |
2043 <p>With these functions, you can iterate through all child nodes and display all attributes like this (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p> | 2041 <p>With these functions, you can iterate through all child nodes and display all attributes like this (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p> |
2044 </div> | 2042 </div> |
2045 <div class="listingblock"> | 2043 <div class="listingblock"> |
2046 <div class="content"> | 2044 <div class="content"> |
2047 <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-w"> </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">first_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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">())</span><span class="tok-w"></span> | 2045 <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-w"> </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">first_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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">())</span> |
2048 <span class="tok-p">{</span><span class="tok-w"></span> | 2046 <span class="tok-p">{</span> |
2049 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool:"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2047 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool:"</span><span class="tok-p">;</span> |
2050 | 2048 |
2051 <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-w"> </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">first_attribute</span><span class="tok-p">();</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-n">attr</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">next_attribute</span><span class="tok-p">())</span><span class="tok-w"></span> | 2049 <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-w"> </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">first_attribute</span><span class="tok-p">();</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-n">attr</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">next_attribute</span><span class="tok-p">())</span> |
2052 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2050 <span class="tok-w"> </span><span class="tok-p">{</span> |
2053 <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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-w"> </span><span class="tok-o"><<</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"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</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> | 2051 <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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-w"> </span><span class="tok-o"><<</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"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</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> |
2054 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2052 <span class="tok-w"> </span><span class="tok-p">}</span> |
2055 | 2053 |
2056 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2054 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2057 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 2055 <span class="tok-p">}</span></code></pre> |
2058 </div> | 2056 </div> |
2059 </div> | 2057 </div> |
2060 </div> | 2058 </div> |
2061 <div class="sect2"> | 2059 <div class="sect2"> |
2062 <h3 id="access.nodedata"><a class="anchor" href="#access.nodedata"></a><a class="link" href="#access.nodedata">5.1. Getting node data</a></h3> | 2060 <h3 id="access.nodedata"><a class="anchor" href="#access.nodedata"></a><a class="link" href="#access.nodedata">5.1. Getting node data</a></h3> |
2064 <p><a id="xml_node::name"></a><a id="xml_node::value"></a> | 2062 <p><a id="xml_node::name"></a><a id="xml_node::value"></a> |
2065 Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <a href="#node_document">node_document</a> nodes do not have a name or value, <a href="#node_element">node_element</a> and <a href="#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a href="#node_pcdata">node_pcdata</a>, <a href="#node_cdata">node_cdata</a>, <a href="#node_comment">node_comment</a> and <a href="#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a href="#node_pi">node_pi</a> nodes always have a name and a value (again, value may be empty). In order to get node’s name or value, you can use the following functions:</p> | 2063 Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <a href="#node_document">node_document</a> nodes do not have a name or value, <a href="#node_element">node_element</a> and <a href="#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a href="#node_pcdata">node_pcdata</a>, <a href="#node_cdata">node_cdata</a>, <a href="#node_comment">node_comment</a> and <a href="#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a href="#node_pi">node_pi</a> nodes always have a name and a value (again, value may be empty). In order to get node’s name or value, you can use the following functions:</p> |
2066 </div> | 2064 </div> |
2067 <div class="listingblock"> | 2065 <div class="listingblock"> |
2068 <div class="content"> | 2066 <div class="content"> |
2069 <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_node::name</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> | 2067 <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_node::name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2070 <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_node::value</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> | 2068 <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_node::value</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2071 </div> | 2069 </div> |
2072 </div> | 2070 </div> |
2073 <div class="paragraph"> | 2071 <div class="paragraph"> |
2074 <p>In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers.</p> | 2072 <p>In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers.</p> |
2075 </div> | 2073 </div> |
2076 <div id="xml_node::child_value" class="paragraph"> | 2074 <div id="xml_node::child_value" class="paragraph"> |
2077 <p>It is common to store data as text contents of some node - i.e. <code><node><description>This is a node</description></node></code>. In this case, <code><description></code> node does not have a value, but instead has a child of type <a href="#node_pcdata">node_pcdata</a> with value <code>"This is a node"</code>. pugixml provides several helper functions to parse such data:</p> | 2075 <p>It is common to store data as text contents of some node - i.e. <code><node><description>This is a node</description></node></code>. In this case, <code><description></code> node does not have a value, but instead has a child of type <a href="#node_pcdata">node_pcdata</a> with value <code>"This is a node"</code>. pugixml provides several helper functions to parse such data:</p> |
2078 </div> | 2076 </div> |
2079 <div class="listingblock"> | 2077 <div class="listingblock"> |
2080 <div class="content"> | 2078 <div class="content"> |
2081 <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_node::child_value</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> | 2079 <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_node::child_value</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2082 <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_node::child_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">name</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> | 2080 <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_node::child_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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2083 <span class="tok-n">xml_text</span><span class="tok-w"> </span><span class="tok-nf">xml_node::text</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> | 2081 <span class="tok-n">xml_text</span><span class="tok-w"> </span><span class="tok-nf">xml_node::text</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2084 </div> | 2082 </div> |
2085 </div> | 2083 </div> |
2086 <div class="paragraph"> | 2084 <div class="paragraph"> |
2087 <p><code>child_value()</code> returns the value of the first child with type <a href="#node_pcdata">node_pcdata</a> or <a href="#node_cdata">node_cdata</a>; <code>child_value(name)</code> is a simple wrapper for <code>child(name).child_value()</code>. For the above example, calling <code>node.child_value("description")</code> and <code>description.child_value()</code> will both produce string <code>"This is a node"</code>. If there is no child with relevant type, or if the handle is null, <code>child_value</code> functions return empty string.</p> | 2085 <p><code>child_value()</code> returns the value of the first child with type <a href="#node_pcdata">node_pcdata</a> or <a href="#node_cdata">node_cdata</a>; <code>child_value(name)</code> is a simple wrapper for <code>child(name).child_value()</code>. For the above example, calling <code>node.child_value("description")</code> and <code>description.child_value()</code> will both produce string <code>"This is a node"</code>. If there is no child with relevant type, or if the handle is null, <code>child_value</code> functions return empty string.</p> |
2088 </div> | 2086 </div> |
2099 <p><a id="xml_attribute::name"></a><a id="xml_attribute::value"></a> | 2097 <p><a id="xml_attribute::name"></a><a id="xml_attribute::value"></a> |
2100 All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for <code>xml_node</code>:</p> | 2098 All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for <code>xml_node</code>:</p> |
2101 </div> | 2099 </div> |
2102 <div class="listingblock"> | 2100 <div class="listingblock"> |
2103 <div class="content"> | 2101 <div class="content"> |
2104 <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_attribute::name</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> | 2102 <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_attribute::name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2105 <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_attribute::value</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> | 2103 <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_attribute::value</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2106 </div> | 2104 </div> |
2107 </div> | 2105 </div> |
2108 <div class="paragraph"> | 2106 <div class="paragraph"> |
2109 <p>In case the attribute handle is null, both functions return empty strings - they never return null pointers.</p> | 2107 <p>In case the attribute handle is null, both functions return empty strings - they never return null pointers.</p> |
2110 </div> | 2108 </div> |
2111 <div id="xml_attribute::as_string" class="paragraph"> | 2109 <div id="xml_attribute::as_string" class="paragraph"> |
2112 <p>If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to <code>"sorted"</code> instead of <code>""</code>), you can use <code>as_string</code> accessor:</p> | 2110 <p>If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to <code>"sorted"</code> instead of <code>""</code>), you can use <code>as_string</code> accessor:</p> |
2113 </div> | 2111 </div> |
2114 <div class="listingblock"> | 2112 <div class="listingblock"> |
2115 <div class="content"> | 2113 <div class="content"> |
2116 <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_attribute::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">""</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> | 2114 <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-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">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">""</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2117 </div> | 2115 </div> |
2118 </div> | 2116 </div> |
2119 <div class="paragraph"> | 2117 <div class="paragraph"> |
2120 <p>It returns <code>def</code> argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to <code>value()</code>.</p> | 2118 <p>It returns <code>def</code> argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to <code>value()</code>.</p> |
2121 </div> | 2119 </div> |
2123 <p><a id="xml_attribute::as_int"></a><a id="xml_attribute::as_uint"></a><a id="xml_attribute::as_double"></a><a id="xml_attribute::as_float"></a><a id="xml_attribute::as_bool"></a><a id="xml_attribute::as_llong"></a><a id="xml_attribute::as_ullong"></a> | 2121 <p><a id="xml_attribute::as_int"></a><a id="xml_attribute::as_uint"></a><a id="xml_attribute::as_double"></a><a id="xml_attribute::as_float"></a><a id="xml_attribute::as_bool"></a><a id="xml_attribute::as_llong"></a><a id="xml_attribute::as_ullong"></a> |
2124 In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:</p> | 2122 In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:</p> |
2125 </div> | 2123 </div> |
2126 <div class="listingblock"> | 2124 <div class="listingblock"> |
2127 <div class="content"> | 2125 <div class="content"> |
2128 <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> | 2126 <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> |
2129 <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> | 2127 <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> |
2130 <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> | 2128 <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> |
2131 <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> | 2129 <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> |
2132 <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> | 2130 <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> |
2133 <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> | 2131 <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> |
2134 <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> | 2132 <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></code></pre> |
2135 </div> | 2133 </div> |
2136 </div> | 2134 </div> |
2137 <div class="paragraph"> | 2135 <div class="paragraph"> |
2138 <p><code>as_int</code>, <code>as_uint</code>, <code>as_llong</code>, <code>as_ullong</code>, <code>as_double</code> and <code>as_float</code> convert attribute values to numbers. If attribute handle is null <code>def</code> argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to <code>as_int</code>, <code>as_uint</code>, <code>as_llong</code> and <code>as_ullong</code>; hexadecimal format is used if the number has <code>0x</code> or <code>0X</code> prefix) or as a floating point number in either decimal or scientific form (<code>as_double</code> or <code>as_float</code>).</p> | 2136 <p><code>as_int</code>, <code>as_uint</code>, <code>as_llong</code>, <code>as_ullong</code>, <code>as_double</code> and <code>as_float</code> convert attribute values to numbers. If attribute handle is null <code>def</code> argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to <code>as_int</code>, <code>as_uint</code>, <code>as_llong</code> and <code>as_ullong</code>; hexadecimal format is used if the number has <code>0x</code> or <code>0X</code> prefix) or as a floating point number in either decimal or scientific form (<code>as_double</code> or <code>as_float</code>).</p> |
2139 </div> | 2137 </div> |
2170 <div id="code_traverse_base_data" class="paragraph"> | 2168 <div id="code_traverse_base_data" class="paragraph"> |
2171 <p>This is an example of using these functions, along with node data retrieval ones (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p> | 2169 <p>This is an example of using these functions, along with node data retrieval ones (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p> |
2172 </div> | 2170 </div> |
2173 <div class="listingblock"> | 2171 <div class="listingblock"> |
2174 <div class="content"> | 2172 <div class="content"> |
2175 <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-w"> </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">child</span><span class="tok-p">(</span><span class="tok-s">"Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">))</span><span class="tok-w"></span> | 2173 <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-w"> </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">child</span><span class="tok-p">(</span><span class="tok-s">"Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">))</span> |
2176 <span class="tok-p">{</span><span class="tok-w"></span> | 2174 <span class="tok-p">{</span> |
2177 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">();</span><span class="tok-w"></span> | 2175 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">();</span> |
2178 <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"><<</span><span class="tok-w"> </span><span class="tok-s">": AllowRemote "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"AllowRemote"</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span><span class="tok-w"></span> | 2176 <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"><<</span><span class="tok-w"> </span><span class="tok-s">": AllowRemote "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"AllowRemote"</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span> |
2179 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", Timeout "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"Timeout"</span><span class="tok-p">).</span><span class="tok-n">as_int</span><span class="tok-p">();</span><span class="tok-w"></span> | 2177 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", Timeout "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"Timeout"</span><span class="tok-p">).</span><span class="tok-n">as_int</span><span class="tok-p">();</span> |
2180 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", Description '"</span><span class="tok-w"> </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">child_value</span><span class="tok-p">(</span><span class="tok-s">"Description"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"'</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2178 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", Description '"</span><span class="tok-w"> </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">child_value</span><span class="tok-p">(</span><span class="tok-s">"Description"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"'</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
2181 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 2179 <span class="tok-p">}</span></code></pre> |
2182 </div> | 2180 </div> |
2183 </div> | 2181 </div> |
2184 </div> | 2182 </div> |
2185 <div class="sect2"> | 2183 <div class="sect2"> |
2186 <h3 id="access.contents"><a class="anchor" href="#access.contents"></a><a class="link" href="#access.contents">5.3. Contents-based traversal functions</a></h3> | 2184 <h3 id="access.contents"><a class="anchor" href="#access.contents"></a><a class="link" href="#access.contents">5.3. Contents-based traversal functions</a></h3> |
2188 <p><a id="xml_node::child"></a><a id="xml_node::attribute"></a><a id="xml_node::next_sibling_name"></a><a id="xml_node::previous_sibling_name"></a> | 2186 <p><a id="xml_node::child"></a><a id="xml_node::attribute"></a><a id="xml_node::next_sibling_name"></a><a id="xml_node::previous_sibling_name"></a> |
2189 Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:</p> | 2187 Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:</p> |
2190 </div> | 2188 </div> |
2191 <div class="listingblock"> | 2189 <div class="listingblock"> |
2192 <div class="content"> | 2190 <div class="content"> |
2193 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::child</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">name</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> | 2191 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::child</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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2194 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attribute</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">name</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> | 2192 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attribute</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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2195 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::next_sibling</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">name</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> | 2193 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::next_sibling</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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2196 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::previous_sibling</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">name</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> | 2194 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::previous_sibling</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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2197 </div> | 2195 </div> |
2198 </div> | 2196 </div> |
2199 <div class="paragraph"> | 2197 <div class="paragraph"> |
2200 <p><code>child</code> and <code>attribute</code> return the first child/attribute with the specified name; <code>next_sibling</code> and <code>previous_sibling</code> return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node/attribute with the specified name, null handle is returned.</p> | 2198 <p><code>child</code> and <code>attribute</code> return the first child/attribute with the specified name; <code>next_sibling</code> and <code>previous_sibling</code> return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node/attribute with the specified name, null handle is returned.</p> |
2201 </div> | 2199 </div> |
2202 <div class="paragraph"> | 2200 <div class="paragraph"> |
2203 <p><code>child</code> and <code>next_sibling</code> functions can be used together to loop through all child nodes with the desired name like this:</p> | 2201 <p><code>child</code> and <code>next_sibling</code> functions can be used together to loop through all child nodes with the desired name like this:</p> |
2204 </div> | 2202 </div> |
2205 <div class="listingblock"> | 2203 <div class="listingblock"> |
2206 <div class="content"> | 2204 <div class="content"> |
2207 <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-w"> </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">child</span><span class="tok-p">(</span><span class="tok-s">"Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">))</span><span class="tok-w"></span></code></pre> | 2205 <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-w"> </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">child</span><span class="tok-p">(</span><span class="tok-s">"Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">))</span></code></pre> |
2208 </div> | 2206 </div> |
2207 </div> | |
2208 <div id="xml_node::attribute_hinted" class="paragraph"> | |
2209 <p><code>attribute</code> 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:</p> | |
2210 </div> | |
2211 <div class="listingblock"> | |
2212 <div class="content"> | |
2213 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attribute</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">name</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">hint</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> | |
2214 </div> | |
2215 </div> | |
2216 <div class="paragraph"> | |
2217 <p>The extra <code>hint</code> 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 <code>hint</code> has to be either null or has to belong to the node, otherwise the behavior is undefined.</p> | |
2218 </div> | |
2219 <div class="paragraph"> | |
2220 <p>You can use this function as follows:</p> | |
2221 </div> | |
2222 <div class="listingblock"> | |
2223 <div class="content"> | |
2224 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">hint</span><span class="tok-p">;</span> | |
2225 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">id</span><span class="tok-w"> </span><span class="tok-o">=</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">"id"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">hint</span><span class="tok-p">);</span> | |
2226 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">name</span><span class="tok-w"> </span><span class="tok-o">=</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">"name"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">hint</span><span class="tok-p">);</span> | |
2227 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-n">version</span><span class="tok-w"> </span><span class="tok-o">=</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">"version"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">hint</span><span class="tok-p">);</span></code></pre> | |
2228 </div> | |
2229 </div> | |
2230 <div class="paragraph"> | |
2231 <p>This code is correct regardless of the order of the attributes, but it’s faster if <code>"id"</code>, <code>"name"</code> and <code>"version"</code> occur in that order.</p> | |
2209 </div> | 2232 </div> |
2210 <div id="xml_node::find_child_by_attribute" class="paragraph"> | 2233 <div id="xml_node::find_child_by_attribute" class="paragraph"> |
2211 <p>Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: <code><group><item id="1"/> <item id="2"/></group></code>. There are two functions for finding child nodes based on the attribute values:</p> | 2234 <p>Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: <code><group><item id="1"/> <item id="2"/></group></code>. There are two functions for finding child nodes based on the attribute values:</p> |
2212 </div> | 2235 </div> |
2213 <div class="listingblock"> | 2236 <div class="listingblock"> |
2214 <div class="content"> | 2237 <div class="content"> |
2215 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::find_child_by_attribute</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">name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</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> | 2238 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::find_child_by_attribute</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">name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2216 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::find_child_by_attribute</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">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</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> | 2239 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::find_child_by_attribute</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">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2217 </div> | 2240 </div> |
2218 </div> | 2241 </div> |
2219 <div class="paragraph"> | 2242 <div class="paragraph"> |
2220 <p>The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive.</p> | 2243 <p>The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive.</p> |
2221 </div> | 2244 </div> |
2225 <div class="paragraph"> | 2248 <div class="paragraph"> |
2226 <p>This is an example of using these functions (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p> | 2249 <p>This is an example of using these functions (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p> |
2227 </div> | 2250 </div> |
2228 <div class="listingblock"> | 2251 <div class="listingblock"> |
2229 <div class="content"> | 2252 <div class="content"> |
2230 <pre class="pygments highlight"><code data-lang="c++"><span></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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool for *.dae generation: "</span><span class="tok-w"> </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">find_child_by_attribute</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"OutputFileMasks"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"*.dae"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2253 <pre class="pygments highlight"><code data-lang="c++"><span></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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool for *.dae generation: "</span><span class="tok-w"> </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">find_child_by_attribute</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"OutputFileMasks"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"*.dae"</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
2231 | 2254 |
2232 <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-w"> </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">child</span><span class="tok-p">(</span><span class="tok-s">"Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">))</span><span class="tok-w"></span> | 2255 <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-w"> </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">child</span><span class="tok-p">(</span><span class="tok-s">"Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">(</span><span class="tok-s">"Tool"</span><span class="tok-p">))</span> |
2233 <span class="tok-p">{</span><span class="tok-w"></span> | 2256 <span class="tok-p">{</span> |
2234 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2257 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool "</span><span class="tok-w"> </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">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
2235 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 2258 <span class="tok-p">}</span></code></pre> |
2236 </div> | 2259 </div> |
2237 </div> | 2260 </div> |
2238 </div> | 2261 </div> |
2239 <div class="sect2"> | 2262 <div class="sect2"> |
2240 <h3 id="access.rangefor"><a class="anchor" href="#access.rangefor"></a><a class="link" href="#access.rangefor">5.4. Range-based for-loop support</a></h3> | 2263 <h3 id="access.rangefor"><a class="anchor" href="#access.rangefor"></a><a class="link" href="#access.rangefor">5.4. Range-based for-loop support</a></h3> |
2242 <p><a id="xml_node::children"></a><a id="xml_node::attributes"></a> | 2265 <p><a id="xml_node::children"></a><a id="xml_node::attributes"></a> |
2243 If your C++ compiler supports range-based for-loop (this is a C++11 feature, at the time of writing it’s supported by Microsoft Visual Studio 2012+, GCC 4.6+ and Clang 3.0+), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with <a href="http://www.boost.org/libs/foreach/">Boost Foreach</a>, and possibly other pre-C++11 foreach facilities.</p> | 2266 If your C++ compiler supports range-based for-loop (this is a C++11 feature, at the time of writing it’s supported by Microsoft Visual Studio 2012+, GCC 4.6+ and Clang 3.0+), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with <a href="http://www.boost.org/libs/foreach/">Boost Foreach</a>, and possibly other pre-C++11 foreach facilities.</p> |
2244 </div> | 2267 </div> |
2245 <div class="listingblock"> | 2268 <div class="listingblock"> |
2246 <div class="content"> | 2269 <div class="content"> |
2247 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">children</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> | 2270 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">children</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2248 <span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">children</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">name</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> | 2271 <span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">children</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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2249 <span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attributes</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> | 2272 <span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attributes</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2250 </div> | 2273 </div> |
2251 </div> | 2274 </div> |
2252 <div class="paragraph"> | 2275 <div class="paragraph"> |
2253 <p><code>children</code> function allows you to enumerate all child nodes; <code>children</code> function with <code>name</code> argument allows you to enumerate all child nodes with a specific name; <code>attributes</code> function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using <code>children()</code>.</p> | 2276 <p><code>children</code> function allows you to enumerate all child nodes; <code>children</code> function with <code>name</code> argument allows you to enumerate all child nodes with a specific name; <code>attributes</code> function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using <code>children()</code>.</p> |
2254 </div> | 2277 </div> |
2255 <div class="paragraph"> | 2278 <div class="paragraph"> |
2256 <p>This is an example of using these functions (<a href="samples/traverse_rangefor.cpp" class="bare">samples/traverse_rangefor.cpp</a>):</p> | 2279 <p>This is an example of using these functions (<a href="samples/traverse_rangefor.cpp" class="bare">samples/traverse_rangefor.cpp</a>):</p> |
2257 </div> | 2280 </div> |
2258 <div class="listingblock"> | 2281 <div class="listingblock"> |
2259 <div class="content"> | 2282 <div class="content"> |
2260 <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">"Tool"</span><span class="tok-p">))</span><span class="tok-w"></span> | 2283 <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">"Tool"</span><span class="tok-p">))</span> |
2261 <span class="tok-p">{</span><span class="tok-w"></span> | 2284 <span class="tok-p">{</span> |
2262 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool:"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2285 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool:"</span><span class="tok-p">;</span> |
2263 | 2286 |
2264 <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> | 2287 <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> |
2265 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2288 <span class="tok-w"> </span><span class="tok-p">{</span> |
2266 <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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-w"> </span><span class="tok-o"><<</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"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</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> | 2289 <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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-w"> </span><span class="tok-o"><<</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"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</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> |
2267 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2290 <span class="tok-w"> </span><span class="tok-p">}</span> |
2268 | 2291 |
2269 <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> | 2292 <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> |
2270 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2293 <span class="tok-w"> </span><span class="tok-p">{</span> |
2271 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", child "</span><span class="tok-w"> </span><span class="tok-o"><<</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> | 2294 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", child "</span><span class="tok-w"> </span><span class="tok-o"><<</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> |
2272 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2295 <span class="tok-w"> </span><span class="tok-p">}</span> |
2273 | 2296 |
2274 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2297 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2275 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 2298 <span class="tok-p">}</span></code></pre> |
2276 </div> | 2299 </div> |
2277 </div> | 2300 </div> |
2278 <div class="paragraph"> | 2301 <div class="paragraph"> |
2279 <p>While using <code>children()</code> makes the intent of the code clear, note that each node can be treated as a container of child nodes, since it provides <code>begin()</code>/<code>end()</code> member functions described in the next section. Because of this, you can iterate through node’s children simply by using the node itself:</p> | 2302 <p>While using <code>children()</code> makes the intent of the code clear, note that each node can be treated as a container of child nodes, since it provides <code>begin()</code>/<code>end()</code> member functions described in the next section. Because of this, you can iterate through node’s children simply by using the node itself:</p> |
2280 </div> | 2303 </div> |
2281 <div class="listingblock"> | 2304 <div class="listingblock"> |
2282 <div class="content"> | 2305 <div class="content"> |
2283 <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> | 2306 <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></code></pre> |
2284 </div> | 2307 </div> |
2285 </div> | 2308 </div> |
2286 </div> | 2309 </div> |
2287 <div class="sect2"> | 2310 <div class="sect2"> |
2288 <h3 id="access.iterators"><a class="anchor" href="#access.iterators"></a><a class="link" href="#access.iterators">5.5. Traversing node/attribute lists via iterators</a></h3> | 2311 <h3 id="access.iterators"><a class="anchor" href="#access.iterators"></a><a class="link" href="#access.iterators">5.5. Traversing node/attribute lists via iterators</a></h3> |
2290 <p><a id="xml_node_iterator"></a><a id="xml_attribute_iterator"></a><a id="xml_node::begin"></a><a id="xml_node::end"></a><a id="xml_node::attributes_begin"></a><a id="xml_node::attributes_end"></a> | 2313 <p><a id="xml_node_iterator"></a><a id="xml_attribute_iterator"></a><a id="xml_node::begin"></a><a id="xml_node::end"></a><a id="xml_node::attributes_begin"></a><a id="xml_node::attributes_end"></a> |
2291 Child node lists and attribute lists are simply double-linked lists; while you can use <code>previous_sibling</code>/<code>next_sibling</code> and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes:</p> | 2314 Child node lists and attribute lists are simply double-linked lists; while you can use <code>previous_sibling</code>/<code>next_sibling</code> and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes:</p> |
2292 </div> | 2315 </div> |
2293 <div class="listingblock"> | 2316 <div class="listingblock"> |
2294 <div class="content"> | 2317 <div class="content"> |
2295 <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> | 2318 <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> |
2296 <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> | 2319 <span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">xml_attribute_iterator</span><span class="tok-p">;</span> |
2297 | 2320 |
2298 <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> | 2321 <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> |
2299 <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> | 2322 <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> |
2300 <span class="tok-n">iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::end</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> | 2323 <span class="tok-n">iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::end</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2301 | 2324 |
2302 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">xml_attribute_iterator</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attribute_iterator</span><span class="tok-p">;</span><span class="tok-w"></span> | 2325 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">xml_attribute_iterator</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attribute_iterator</span><span class="tok-p">;</span> |
2303 <span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attributes_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> | 2326 <span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attributes_begin</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2304 <span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attributes_end</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> | 2327 <span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><span class="tok-nf">xml_node::attributes_end</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2305 </div> | 2328 </div> |
2306 </div> | 2329 </div> |
2307 <div class="paragraph"> | 2330 <div class="paragraph"> |
2308 <p><code>begin</code> and <code>attributes_begin</code> return iterators that point to the first node/attribute, respectively; <code>end</code> and <code>attributes_end</code> return past-the-end iterator for node/attribute list, respectively - this iterator can’t be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: <code>xml_node_iterator(node)</code>. For <code>xml_attribute_iterator</code>, you’ll have to provide both an attribute and its parent node.</p> | 2331 <p><code>begin</code> and <code>attributes_begin</code> return iterators that point to the first node/attribute, respectively; <code>end</code> and <code>attributes_end</code> return past-the-end iterator for node/attribute list, respectively - this iterator can’t be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: <code>xml_node_iterator(node)</code>. For <code>xml_attribute_iterator</code>, you’ll have to provide both an attribute and its parent node.</p> |
2309 </div> | 2332 </div> |
2316 <div class="paragraph"> | 2339 <div class="paragraph"> |
2317 <p>Here is an example of using iterators for document traversal (<a href="samples/traverse_iter.cpp" class="bare">samples/traverse_iter.cpp</a>):</p> | 2340 <p>Here is an example of using iterators for document traversal (<a href="samples/traverse_iter.cpp" class="bare">samples/traverse_iter.cpp</a>):</p> |
2318 </div> | 2341 </div> |
2319 <div class="listingblock"> | 2342 <div class="listingblock"> |
2320 <div class="content"> | 2343 <div class="content"> |
2321 <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_iterator</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">begin</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">end</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span><span class="tok-w"></span> | 2344 <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_iterator</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">begin</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">end</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span> |
2322 <span class="tok-p">{</span><span class="tok-w"></span> | 2345 <span class="tok-p">{</span> |
2323 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool:"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2346 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tool:"</span><span class="tok-p">;</span> |
2324 | 2347 |
2325 <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_iterator</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-o">-></span><span class="tok-n">attributes_begin</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-w"> </span><span class="tok-o">!=</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-o">-></span><span class="tok-n">attributes_end</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">ait</span><span class="tok-p">)</span><span class="tok-w"></span> | 2348 <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_iterator</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-o">-></span><span class="tok-n">attributes_begin</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-w"> </span><span class="tok-o">!=</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-o">-></span><span class="tok-n">attributes_end</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">ait</span><span class="tok-p">)</span> |
2326 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2349 <span class="tok-w"> </span><span class="tok-p">{</span> |
2327 <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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-o">-></span><span class="tok-n">name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-o">-></span><span class="tok-n">value</span><span class="tok-p">();</span><span class="tok-w"></span> | 2350 <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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-o">-></span><span class="tok-n">name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">ait</span><span class="tok-o">-></span><span class="tok-n">value</span><span class="tok-p">();</span> |
2328 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2351 <span class="tok-w"> </span><span class="tok-p">}</span> |
2329 | 2352 |
2330 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2353 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2331 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 2354 <span class="tok-p">}</span></code></pre> |
2332 </div> | 2355 </div> |
2333 </div> | 2356 </div> |
2334 <div class="admonitionblock caution"> | 2357 <div class="admonitionblock caution"> |
2335 <table> | 2358 <table> |
2336 <tr> | 2359 <tr> |
2349 <div id="xml_tree_walker" class="paragraph"> | 2372 <div id="xml_tree_walker" class="paragraph"> |
2350 <p>The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you’ll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement <code>xml_tree_walker</code> interface and to call <code>traverse</code> function:</p> | 2373 <p>The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you’ll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement <code>xml_tree_walker</code> interface and to call <code>traverse</code> function:</p> |
2351 </div> | 2374 </div> |
2352 <div class="listingblock"> | 2375 <div class="listingblock"> |
2353 <div class="content"> | 2376 <div class="content"> |
2354 <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> | 2377 <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> |
2355 <span class="tok-p">{</span><span class="tok-w"></span> | 2378 <span class="tok-p">{</span> |
2356 <span class="tok-k">public</span><span class="tok-o">:</span><span class="tok-w"></span> | 2379 <span class="tok-k">public</span><span class="tok-o">:</span> |
2357 <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">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 2380 <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">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
2358 <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">xml_node</span><span class="tok-o">&</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-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">;</span><span class="tok-w"></span> | 2381 <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">xml_node</span><span class="tok-o">&</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-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">;</span> |
2359 <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">end</span><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 2382 <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">end</span><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
2360 | 2383 |
2361 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">depth</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> | 2384 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">depth</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2362 <span class="tok-p">};</span><span class="tok-w"></span> | 2385 <span class="tok-p">};</span> |
2363 | 2386 |
2364 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::traverse</span><span class="tok-p">(</span><span class="tok-n">xml_tree_walker</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2387 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::traverse</span><span class="tok-p">(</span><span class="tok-n">xml_tree_walker</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">);</span></code></pre> |
2365 </div> | 2388 </div> |
2366 </div> | 2389 </div> |
2367 <div class="paragraph"> | 2390 <div class="paragraph"> |
2368 <p><a id="xml_tree_walker::begin"></a><a id="xml_tree_walker::for_each"></a><a id="xml_tree_walker::end"></a><a id="xml_node::traverse"></a> | 2391 <p><a id="xml_tree_walker::begin"></a><a id="xml_tree_walker::for_each"></a><a id="xml_tree_walker::end"></a><a id="xml_node::traverse"></a> |
2369 The traversal is launched by calling <code>traverse</code> function on traversal root and proceeds as follows:</p> | 2392 The traversal is launched by calling <code>traverse</code> function on traversal root and proceeds as follows:</p> |
2390 <div class="paragraph"> | 2413 <div class="paragraph"> |
2391 <p>This is an example of traversing tree hierarchy with xml_tree_walker (<a href="samples/traverse_walker.cpp" class="bare">samples/traverse_walker.cpp</a>):</p> | 2414 <p>This is an example of traversing tree hierarchy with xml_tree_walker (<a href="samples/traverse_walker.cpp" class="bare">samples/traverse_walker.cpp</a>):</p> |
2392 </div> | 2415 </div> |
2393 <div class="listingblock"> | 2416 <div class="listingblock"> |
2394 <div class="content"> | 2417 <div class="content"> |
2395 <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> | 2418 <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> |
2396 <span class="tok-p">{</span><span class="tok-w"></span> | 2419 <span class="tok-p">{</span> |
2397 <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">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">)</span><span class="tok-w"></span> | 2420 <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">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">)</span> |
2398 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2421 <span class="tok-w"> </span><span class="tok-p">{</span> |
2399 <span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">i</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-n">i</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-w"> </span><span class="tok-n">depth</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">i</span><span class="tok-p">)</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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-c1">// indentation</span> | 2422 <span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">i</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-n">i</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-w"> </span><span class="tok-n">depth</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">i</span><span class="tok-p">)</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"><<</span><span class="tok-w"> </span><span class="tok-s">" "</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-c1">// indentation</span> |
2400 | 2423 |
2401 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node_types</span><span class="tok-p">[</span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">type</span><span class="tok-p">()]</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">": name='"</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">node</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"><<</span><span class="tok-w"> </span><span class="tok-s">"', value='"</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">node</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"'</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2424 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node_types</span><span class="tok-p">[</span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">type</span><span class="tok-p">()]</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">": name='"</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">node</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"><<</span><span class="tok-w"> </span><span class="tok-s">"', value='"</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">node</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"'</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
2402 | 2425 |
2403 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-c1">// continue traversal</span> | 2426 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-c1">// continue traversal</span> |
2404 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2427 <span class="tok-w"> </span><span class="tok-p">}</span> |
2405 <span class="tok-p">};</span><span class="tok-w"></span></code></pre> | 2428 <span class="tok-p">};</span></code></pre> |
2406 </div> | 2429 </div> |
2407 </div> | 2430 </div> |
2408 <div class="listingblock"> | 2431 <div class="listingblock"> |
2409 <div class="content"> | 2432 <div class="content"> |
2410 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">simple_walker</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">;</span><span class="tok-w"></span> | 2433 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">simple_walker</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">;</span> |
2411 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">traverse</span><span class="tok-p">(</span><span class="tok-n">walker</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2434 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">traverse</span><span class="tok-p">(</span><span class="tok-n">walker</span><span class="tok-p">);</span></code></pre> |
2412 </div> | 2435 </div> |
2413 </div> | 2436 </div> |
2414 </div> | 2437 </div> |
2415 <div class="sect2"> | 2438 <div class="sect2"> |
2416 <h3 id="access.predicate"><a class="anchor" href="#access.predicate"></a><a class="link" href="#access.predicate">5.7. Searching for nodes/attributes with predicates</a></h3> | 2439 <h3 id="access.predicate"><a class="anchor" href="#access.predicate"></a><a class="link" href="#access.predicate">5.7. Searching for nodes/attributes with predicates</a></h3> |
2418 <p><a id="xml_node::find_attribute"></a><a id="xml_node::find_child"></a><a id="xml_node::find_node"></a> | 2441 <p><a id="xml_node::find_attribute"></a><a id="xml_node::find_child"></a><a id="xml_node::find_node"></a> |
2419 While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of <code>find_</code> functions:</p> | 2442 While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of <code>find_</code> functions:</p> |
2420 </div> | 2443 </div> |
2421 <div class="listingblock"> | 2444 <div class="listingblock"> |
2422 <div class="content"> | 2445 <div class="content"> |
2423 <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"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> | 2446 <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"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> |
2424 <span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> | 2447 <span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> |
2425 <span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> | 2448 <span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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></code></pre> |
2426 </div> | 2449 </div> |
2427 </div> | 2450 </div> |
2428 <div class="paragraph"> | 2451 <div class="paragraph"> |
2429 <p>The predicate should be either a plain function or a function object which accepts one argument of type <code>xml_attribute</code> (for <code>find_attribute</code>) or <code>xml_node</code> (for <code>find_child</code> and <code>find_node</code>), and returns <code>bool</code>. The predicate is never called with null handle as an argument.</p> | 2452 <p>The predicate should be either a plain function or a function object which accepts one argument of type <code>xml_attribute</code> (for <code>find_attribute</code>) or <code>xml_node</code> (for <code>find_child</code> and <code>find_node</code>), and returns <code>bool</code>. The predicate is never called with null handle as an argument.</p> |
2430 </div> | 2453 </div> |
2440 <div class="paragraph"> | 2463 <div class="paragraph"> |
2441 <p>This is an example of using predicate-based functions (<a href="samples/traverse_predicate.cpp" class="bare">samples/traverse_predicate.cpp</a>):</p> | 2464 <p>This is an example of using predicate-based functions (<a href="samples/traverse_predicate.cpp" class="bare">samples/traverse_predicate.cpp</a>):</p> |
2442 </div> | 2465 </div> |
2443 <div class="listingblock"> | 2466 <div class="listingblock"> |
2444 <div class="content"> | 2467 <div class="content"> |
2445 <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">small_timeout</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">node</span><span class="tok-p">)</span><span class="tok-w"></span> | 2468 <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">small_timeout</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">node</span><span class="tok-p">)</span> |
2446 <span class="tok-p">{</span><span class="tok-w"></span> | 2469 <span class="tok-p">{</span> |
2447 <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">"Timeout"</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"><</span><span class="tok-w"> </span><span class="tok-mi">20</span><span class="tok-p">;</span><span class="tok-w"></span> | 2470 <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">"Timeout"</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"><</span><span class="tok-w"> </span><span class="tok-mi">20</span><span class="tok-p">;</span> |
2448 <span class="tok-p">}</span><span class="tok-w"></span> | 2471 <span class="tok-p">}</span> |
2449 | 2472 |
2450 <span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">allow_remote_predicate</span><span class="tok-w"></span> | 2473 <span class="tok-k">struct</span><span class="tok-w"> </span><span class="tok-nc">allow_remote_predicate</span> |
2451 <span class="tok-p">{</span><span class="tok-w"></span> | 2474 <span class="tok-p">{</span> |
2452 <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> | 2475 <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> |
2453 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2476 <span class="tok-w"> </span><span class="tok-p">{</span> |
2454 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-n">strcmp</span><span class="tok-p">(</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-s">"AllowRemote"</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> | 2477 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-n">strcmp</span><span class="tok-p">(</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-s">"AllowRemote"</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> |
2455 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2478 <span class="tok-w"> </span><span class="tok-p">}</span> |
2456 | 2479 |
2457 <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_node</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-k">const</span><span class="tok-w"></span> | 2480 <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_node</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-k">const</span> |
2458 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 2481 <span class="tok-w"> </span><span class="tok-p">{</span> |
2459 <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">"AllowRemote"</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span><span class="tok-w"></span> | 2482 <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">"AllowRemote"</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span> |
2460 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 2483 <span class="tok-w"> </span><span class="tok-p">}</span> |
2461 <span class="tok-p">};</span><span class="tok-w"></span></code></pre> | 2484 <span class="tok-p">};</span></code></pre> |
2462 </div> | 2485 </div> |
2463 </div> | 2486 </div> |
2464 <div class="listingblock"> | 2487 <div class="listingblock"> |
2465 <div class="content"> | 2488 <div class="content"> |
2466 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Find child via predicate (looks for direct children only)</span> | 2489 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Find child via predicate (looks for direct children only)</span> |
2467 <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"><<</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2490 <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"><<</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2468 | 2491 |
2469 <span class="tok-c1">// Find node via predicate (looks for all descendants in depth-first order)</span> | 2492 <span class="tok-c1">// Find node via predicate (looks for all descendants in depth-first order)</span> |
2470 <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"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">find_node</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2493 <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"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">find_node</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2471 | 2494 |
2472 <span class="tok-c1">// Find attribute via predicate</span> | 2495 <span class="tok-c1">// Find attribute via predicate</span> |
2473 <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"><<</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">find_attribute</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2496 <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"><<</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">find_attribute</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2474 | 2497 |
2475 <span class="tok-c1">// We can use simple functions instead of function objects</span> | 2498 <span class="tok-c1">// We can use simple functions instead of function objects</span> |
2476 <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"><<</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">small_timeout</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 2499 <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"><<</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">small_timeout</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
2477 </div> | 2500 </div> |
2478 </div> | 2501 </div> |
2479 </div> | 2502 </div> |
2480 <div class="sect2"> | 2503 <div class="sect2"> |
2481 <h3 id="access.text"><a class="anchor" href="#access.text"></a><a class="link" href="#access.text">5.8. Working with text contents</a></h3> | 2504 <h3 id="access.text"><a class="anchor" href="#access.text"></a><a class="link" href="#access.text">5.8. Working with text contents</a></h3> |
2485 <div id="xml_node::text" class="paragraph"> | 2508 <div id="xml_node::text" class="paragraph"> |
2486 <p>You can get the text object from a node by using <code>text()</code> method:</p> | 2509 <p>You can get the text object from a node by using <code>text()</code> method:</p> |
2487 </div> | 2510 </div> |
2488 <div class="listingblock"> | 2511 <div class="listingblock"> |
2489 <div class="content"> | 2512 <div class="content"> |
2490 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_text</span><span class="tok-w"> </span><span class="tok-nf">xml_node::text</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> | 2513 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_text</span><span class="tok-w"> </span><span class="tok-nf">xml_node::text</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2491 </div> | 2514 </div> |
2492 </div> | 2515 </div> |
2493 <div class="paragraph"> | 2516 <div class="paragraph"> |
2494 <p>If the node has a type <code>node_pcdata</code> or <code>node_cdata</code>, then the node itself is used to return data; otherwise, a first child node of type <code>node_pcdata</code> or <code>node_cdata</code> is used.</p> | 2517 <p>If the node has a type <code>node_pcdata</code> or <code>node_cdata</code>, then the node itself is used to return data; otherwise, a first child node of type <code>node_pcdata</code> or <code>node_cdata</code> is used.</p> |
2495 </div> | 2518 </div> |
2497 <p><a id="xml_text::empty"></a><a id="xml_text::unspecified_bool_type"></a> | 2520 <p><a id="xml_text::empty"></a><a id="xml_text::unspecified_bool_type"></a> |
2498 You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. <code>if (text) { …​ }</code> or <code>if (!text) { …​ }</code>. Alternatively you can check it by using the <code>empty()</code> method:</p> | 2521 You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. <code>if (text) { …​ }</code> or <code>if (!text) { …​ }</code>. Alternatively you can check it by using the <code>empty()</code> method:</p> |
2499 </div> | 2522 </div> |
2500 <div class="listingblock"> | 2523 <div class="listingblock"> |
2501 <div class="content"> | 2524 <div class="content"> |
2502 <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::empty</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> | 2525 <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::empty</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2503 </div> | 2526 </div> |
2504 </div> | 2527 </div> |
2505 <div id="xml_text::get" class="paragraph"> | 2528 <div id="xml_text::get" class="paragraph"> |
2506 <p>Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:</p> | 2529 <p>Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:</p> |
2507 </div> | 2530 </div> |
2508 <div class="listingblock"> | 2531 <div class="listingblock"> |
2509 <div class="content"> | 2532 <div class="content"> |
2510 <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::get</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> | 2533 <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::get</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2511 </div> | 2534 </div> |
2512 </div> | 2535 </div> |
2513 <div class="paragraph"> | 2536 <div class="paragraph"> |
2514 <p>In case text object is empty, the function returns an empty string - it never returns a null pointer.</p> | 2537 <p>In case text object is empty, the function returns an empty string - it never returns a null pointer.</p> |
2515 </div> | 2538 </div> |
2517 <p><a id="xml_text::as_string"></a><a id="xml_text::as_int"></a><a id="xml_text::as_uint"></a><a id="xml_text::as_double"></a><a id="xml_text::as_float"></a><a id="xml_text::as_bool"></a><a id="xml_text::as_llong"></a><a id="xml_text::as_ullong"></a> | 2540 <p><a id="xml_text::as_string"></a><a id="xml_text::as_int"></a><a id="xml_text::as_uint"></a><a id="xml_text::as_double"></a><a id="xml_text::as_float"></a><a id="xml_text::as_bool"></a><a id="xml_text::as_llong"></a><a id="xml_text::as_ullong"></a> |
2518 If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors:</p> | 2541 If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors:</p> |
2519 </div> | 2542 </div> |
2520 <div class="listingblock"> | 2543 <div class="listingblock"> |
2521 <div class="content"> | 2544 <div class="content"> |
2522 <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">""</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> | 2545 <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-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">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">""</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2523 <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> | 2546 <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> |
2524 <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> | 2547 <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> |
2525 <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> | 2548 <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> |
2526 <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> | 2549 <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> |
2527 <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> | 2550 <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> |
2528 <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> | 2551 <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> |
2529 <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> | 2552 <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></code></pre> |
2530 </div> | 2553 </div> |
2531 </div> | 2554 </div> |
2532 <div class="paragraph"> | 2555 <div class="paragraph"> |
2533 <p>All of the above functions have the same semantics as similar <code>xml_attribute</code> members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can <a href="#xml_attribute::as_int">refer to documentation for the attribute functions</a> for details.</p> | 2556 <p>All of the above functions have the same semantics as similar <code>xml_attribute</code> members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can <a href="#xml_attribute::as_int">refer to documentation for the attribute functions</a> for details.</p> |
2534 </div> | 2557 </div> |
2535 <div id="xml_text::data" class="paragraph"> | 2558 <div id="xml_text::data" class="paragraph"> |
2536 <p><code>xml_text</code> is essentially a helper class that operates on <code>xml_node</code> values. It is bound to a node of type <a href="#node_pcdata">node_pcdata</a> or <a href="#node_cdata">node_cdata</a>. You can use the following function to retrieve this node:</p> | 2559 <p><code>xml_text</code> is essentially a helper class that operates on <code>xml_node</code> values. It is bound to a node of type <a href="#node_pcdata">node_pcdata</a> or <a href="#node_cdata">node_cdata</a>. You can use the following function to retrieve this node:</p> |
2537 </div> | 2560 </div> |
2538 <div class="listingblock"> | 2561 <div class="listingblock"> |
2539 <div class="content"> | 2562 <div class="content"> |
2540 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_text::data</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> | 2563 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_text::data</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2541 </div> | 2564 </div> |
2542 </div> | 2565 </div> |
2543 <div class="paragraph"> | 2566 <div class="paragraph"> |
2544 <p>Essentially, assuming <code>text</code> is an <code>xml_text</code> object, calling <code>text.get()</code> is equivalent to calling <code>text.data().value()</code>.</p> | 2567 <p>Essentially, assuming <code>text</code> is an <code>xml_text</code> object, calling <code>text.get()</code> is equivalent to calling <code>text.data().value()</code>.</p> |
2545 </div> | 2568 </div> |
2546 <div class="paragraph"> | 2569 <div class="paragraph"> |
2547 <p>This is an example of using <code>xml_text</code> object (<a href="samples/text.cpp" class="bare">samples/text.cpp</a>):</p> | 2570 <p>This is an example of using <code>xml_text</code> object (<a href="samples/text.cpp" class="bare">samples/text.cpp</a>):</p> |
2548 </div> | 2571 </div> |
2549 <div class="listingblock"> | 2572 <div class="listingblock"> |
2550 <div class="content"> | 2573 <div class="content"> |
2551 <pre class="pygments highlight"><code data-lang="c++"><span></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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project name: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">get</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2574 <pre class="pygments highlight"><code data-lang="c++"><span></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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project name: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">get</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2552 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project version: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"version"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">as_double</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2575 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project version: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"version"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">as_double</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2553 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project visibility: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"public"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">as_bool</span><span class="tok-p">(</span><span class="tok-cm">/* def= */</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">?</span><span class="tok-w"> </span><span class="tok-s">"public"</span><span class="tok-w"> </span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-s">"private"</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2576 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project visibility: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"public"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">as_bool</span><span class="tok-p">(</span><span class="tok-cm">/* def= */</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">?</span><span class="tok-w"> </span><span class="tok-s">"public"</span><span class="tok-w"> </span><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-s">"private"</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2554 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project description: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">get</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 2577 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Project description: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">get</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
2555 </div> | 2578 </div> |
2556 </div> | 2579 </div> |
2557 </div> | 2580 </div> |
2558 <div class="sect2"> | 2581 <div class="sect2"> |
2559 <h3 id="access.misc"><a class="anchor" href="#access.misc"></a><a class="link" href="#access.misc">5.9. Miscellaneous functions</a></h3> | 2582 <h3 id="access.misc"><a class="anchor" href="#access.misc"></a><a class="link" href="#access.misc">5.9. Miscellaneous functions</a></h3> |
2560 <div id="xml_node::root" class="paragraph"> | 2583 <div id="xml_node::root" class="paragraph"> |
2561 <p>If you need to get the document root of some node, you can use the following function:</p> | 2584 <p>If you need to get the document root of some node, you can use the following function:</p> |
2562 </div> | 2585 </div> |
2563 <div class="listingblock"> | 2586 <div class="listingblock"> |
2564 <div class="content"> | 2587 <div class="content"> |
2565 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::root</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> | 2588 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::root</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2566 </div> | 2589 </div> |
2567 </div> | 2590 </div> |
2568 <div class="paragraph"> | 2591 <div class="paragraph"> |
2569 <p>This function returns the node with type <a href="#node_document">node_document</a>, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).</p> | 2592 <p>This function returns the node with type <a href="#node_document">node_document</a>, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).</p> |
2570 </div> | 2593 </div> |
2572 <p><a id="xml_node::path"></a><a id="xml_node::first_element_by_path"></a> | 2595 <p><a id="xml_node::path"></a><a id="xml_node::first_element_by_path"></a> |
2573 While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node:</p> | 2596 While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node:</p> |
2574 </div> | 2597 </div> |
2575 <div class="listingblock"> | 2598 <div class="listingblock"> |
2576 <div class="content"> | 2599 <div class="content"> |
2577 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">string_t</span><span class="tok-w"> </span><span class="tok-nf">xml_node::path</span><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">'/'</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> | 2600 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">string_t</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">path</span><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">'/'</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
2578 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::first_element_by_path</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">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">'/'</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> | 2601 <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">first_element_by_path</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">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">'/'</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2579 </div> | 2602 </div> |
2580 </div> | 2603 </div> |
2581 <div class="paragraph"> | 2604 <div class="paragraph"> |
2582 <p>Node paths consist of node names, separated with a delimiter (which is <code>/</code> by default); also paths can contain self (<code>.</code>) and parent (<code>..</code>) pseudo-names, so that this is a valid path: <code>"../../foo/./bar"</code>. <code>path</code> returns the path to the node from the document root, <code>first_element_by_path</code> looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: <code><a><b><c/></b></a></code>, node <code><c/></code> has path <code>"a/b/c"</code>; calling <code>first_element_by_path</code> for document with path <code>"a/b"</code> results in node <code><b/></code>; calling <code>first_element_by_path</code> for node <code><a/></code> with path <code>"../a/./b/../."</code> results in node <code><a/></code>; calling <code>first_element_by_path</code> with path <code>"/a"</code> results in node <code><a/></code> for any node.</p> | 2605 <p>Node paths consist of node names, separated with a delimiter (which is <code>/</code> by default); also paths can contain self (<code>.</code>) and parent (<code>..</code>) pseudo-names, so that this is a valid path: <code>"../../foo/./bar"</code>. <code>path</code> returns the path to the node from the document root, <code>first_element_by_path</code> looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: <code><a><b><c/></b></a></code>, node <code><c/></code> has path <code>"a/b/c"</code>; calling <code>first_element_by_path</code> for document with path <code>"a/b"</code> results in node <code><b/></code>; calling <code>first_element_by_path</code> for node <code><a/></code> with path <code>"../a/./b/../."</code> results in node <code><a/></code>; calling <code>first_element_by_path</code> with path <code>"/a"</code> results in node <code><a/></code> for any node.</p> |
2583 </div> | 2606 </div> |
2599 <div id="xml_node::offset_debug" class="paragraph"> | 2622 <div id="xml_node::offset_debug" class="paragraph"> |
2600 <p>pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer:</p> | 2623 <p>pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer:</p> |
2601 </div> | 2624 </div> |
2602 <div class="listingblock"> | 2625 <div class="listingblock"> |
2603 <div class="content"> | 2626 <div class="content"> |
2604 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><span class="tok-nf">xml_node::offset_debug</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> | 2627 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><span class="tok-nf">xml_node::offset_debug</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
2605 </div> | 2628 </div> |
2606 </div> | 2629 </div> |
2607 <div class="paragraph"> | 2630 <div class="paragraph"> |
2608 <p>If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node’s data from the beginning of XML buffer in <a href="#char_t">pugi::char_t</a> units. For more information on parsing offsets, see <a href="#xml_parse_result::offset">parsing error handling documentation</a>.</p> | 2631 <p>If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node’s data from the beginning of XML buffer in <a href="#char_t">pugi::char_t</a> units. For more information on parsing offsets, see <a href="#xml_parse_result::offset">parsing error handling documentation</a>.</p> |
2609 </div> | 2632 </div> |
2625 <p><a id="xml_node::set_name"></a><a id="xml_node::set_value"></a> | 2648 <p><a id="xml_node::set_name"></a><a id="xml_node::set_value"></a> |
2626 As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <a href="#node_document">node_document</a> nodes do not have a name or value, <a href="#node_element">node_element</a> and <a href="#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a href="#node_pcdata">node_pcdata</a>, <a href="#node_cdata">node_cdata</a>, <a href="#node_comment">node_comment</a> and <a href="#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a href="#node_pi">node_pi</a> nodes always have a name and a value (again, value may be empty). In order to set node’s name or value, you can use the following functions:</p> | 2649 As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <a href="#node_document">node_document</a> nodes do not have a name or value, <a href="#node_element">node_element</a> and <a href="#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a href="#node_pcdata">node_pcdata</a>, <a href="#node_cdata">node_cdata</a>, <a href="#node_comment">node_comment</a> and <a href="#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a href="#node_pi">node_pi</a> nodes always have a name and a value (again, value may be empty). In order to set node’s name or value, you can use the following functions:</p> |
2627 </div> | 2650 </div> |
2628 <div class="listingblock"> | 2651 <div class="listingblock"> |
2629 <div class="content"> | 2652 <div class="content"> |
2630 <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> | 2653 <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> |
2631 <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> | 2654 <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">size_t</span><span class="tok-w"> </span><span class="tok-n">sz</span><span class="tok-p">)</span> |
2632 <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> | 2655 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">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> |
2656 <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></code></pre> | |
2633 </div> | 2657 </div> |
2634 </div> | 2658 </div> |
2635 <div class="paragraph"> | 2659 <div class="paragraph"> |
2636 <p>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 <code>set_name</code> on a <a href="#node_pcdata">node_pcdata</a> 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.</p> | 2660 <p>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 <code>set_name</code> on a <a href="#node_pcdata">node_pcdata</a> 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.</p> |
2637 </div> | 2661 </div> |
2638 <div class="paragraph"> | 2662 <div class="paragraph"> |
2639 <p>This is an example of setting node name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p> | 2663 <p>This is an example of setting node name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p> |
2640 </div> | 2664 </div> |
2641 <div class="listingblock"> | 2665 <div class="listingblock"> |
2642 <div class="content"> | 2666 <div class="content"> |
2643 <pre class="pygments highlight"><code data-lang="c++"><span></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">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2667 <pre class="pygments highlight"><code data-lang="c++"><span></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">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">);</span> |
2644 | 2668 |
2645 <span class="tok-c1">// change node name</span> | 2669 <span class="tok-c1">// change node name</span> |
2646 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">"notnode"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2670 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">"notnode"</span><span class="tok-p">);</span> |
2647 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", new node name: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">node</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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2671 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", new node name: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">node</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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2648 | 2672 |
2649 <span class="tok-c1">// change comment text</span> | 2673 <span class="tok-c1">// change comment text</span> |
2650 <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"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"useless comment"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2674 <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"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"useless comment"</span><span class="tok-p">);</span> |
2651 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", new comment text: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2675 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", new comment text: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2652 | 2676 |
2653 <span class="tok-c1">// we can't change value of the element or name of the comment</span> | 2677 <span class="tok-c1">// we can't change value of the element or name of the comment</span> |
2654 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"1"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">", "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">"2"</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 2678 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"1"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">", "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">"2"</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
2655 </div> | 2679 </div> |
2656 </div> | 2680 </div> |
2657 </div> | 2681 </div> |
2658 <div class="sect2"> | 2682 <div class="sect2"> |
2659 <h3 id="modify.attrdata"><a class="anchor" href="#modify.attrdata"></a><a class="link" href="#modify.attrdata">6.1. Setting attribute data</a></h3> | 2683 <h3 id="modify.attrdata"><a class="anchor" href="#modify.attrdata"></a><a class="link" href="#modify.attrdata">6.1. Setting attribute data</a></h3> |
2661 <p><a id="xml_attribute::set_name"></a><a id="xml_attribute::set_value"></a> | 2685 <p><a id="xml_attribute::set_name"></a><a id="xml_attribute::set_value"></a> |
2662 All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:</p> | 2686 All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:</p> |
2663 </div> | 2687 </div> |
2664 <div class="listingblock"> | 2688 <div class="listingblock"> |
2665 <div class="content"> | 2689 <div class="content"> |
2666 <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> | 2690 <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> |
2667 <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> | 2691 <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">size_t</span><span class="tok-w"> </span><span class="tok-n">sz</span><span class="tok-p">)</span> |
2668 <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> | 2692 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">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> |
2693 <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></code></pre> | |
2669 </div> | 2694 </div> |
2670 </div> | 2695 </div> |
2671 <div class="paragraph"> | 2696 <div class="paragraph"> |
2672 <p>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.</p> | 2697 <p>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.</p> |
2673 </div> | 2698 </div> |
2674 <div class="paragraph"> | 2699 <div class="paragraph"> |
2675 <p>In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values:</p> | 2700 <p>In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values:</p> |
2676 </div> | 2701 </div> |
2677 <div class="listingblock"> | 2702 <div class="listingblock"> |
2678 <div class="content"> | 2703 <div class="content"> |
2679 <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_value</span><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> | 2704 <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_value</span><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> |
2680 <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-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> | 2705 <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-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> |
2681 <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-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2706 <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-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2682 <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-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> | 2707 <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-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> |
2683 <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-kt">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2708 <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-kt">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2684 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span><span class="tok-w"></span> | 2709 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span> |
2685 <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-kt">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2710 <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-kt">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2686 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span><span class="tok-w"></span> | 2711 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span> |
2687 <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-kt">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2712 <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-kt">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2688 <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-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> | 2713 <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-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> |
2689 <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-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></code></pre> | 2714 <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-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></code></pre> |
2690 </div> | 2715 </div> |
2691 </div> | 2716 </div> |
2692 <div class="paragraph"> | 2717 <div class="paragraph"> |
2693 <p>The above functions convert the argument to string and then call the base <code>set_value</code> function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either <code>"true"</code> or <code>"false"</code>.</p> | 2718 <p>The above functions convert the argument to string and then call the base <code>set_value</code> function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either <code>"true"</code> or <code>"false"</code>.</p> |
2694 </div> | 2719 </div> |
2719 <div id="xml_attribute::assign" class="paragraph"> | 2744 <div id="xml_attribute::assign" class="paragraph"> |
2720 <p>For convenience, all <code>set_value</code> functions have the corresponding assignment operators:</p> | 2745 <p>For convenience, all <code>set_value</code> functions have the corresponding assignment operators:</p> |
2721 </div> | 2746 </div> |
2722 <div class="listingblock"> | 2747 <div class="listingblock"> |
2723 <div class="content"> | 2748 <div class="content"> |
2724 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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> | 2749 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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> |
2725 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2750 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2726 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2751 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span> |
2727 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2752 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2728 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2753 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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-n">rhs</span><span class="tok-p">);</span> |
2729 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2754 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2730 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2755 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2731 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2756 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2732 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2757 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span> |
2733 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2758 <span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span></code></pre> |
2734 </div> | 2759 </div> |
2735 </div> | 2760 </div> |
2736 <div class="paragraph"> | 2761 <div class="paragraph"> |
2737 <p>These operators simply call the right <code>set_value</code> function and return the attribute they’re called on; the return value of <code>set_value</code> is ignored, so errors are ignored.</p> | 2762 <p>These operators simply call the right <code>set_value</code> function and return the attribute they’re called on; the return value of <code>set_value</code> is ignored, so errors are ignored.</p> |
2738 </div> | 2763 </div> |
2739 <div class="paragraph"> | 2764 <div class="paragraph"> |
2740 <p>This is an example of setting attribute name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p> | 2765 <p>This is an example of setting attribute name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p> |
2741 </div> | 2766 </div> |
2742 <div class="listingblock"> | 2767 <div class="listingblock"> |
2743 <div class="content"> | 2768 <div class="content"> |
2744 <pre class="pygments highlight"><code data-lang="c++"><span></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-w"> </span><span class="tok-o">=</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">"id"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2769 <pre class="pygments highlight"><code data-lang="c++"><span></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-w"> </span><span class="tok-o">=</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">"id"</span><span class="tok-p">);</span> |
2745 | 2770 |
2746 <span class="tok-c1">// change attribute name/value</span> | 2771 <span class="tok-c1">// change attribute name/value</span> |
2747 <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"><<</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">"key"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">", "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"345"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2772 <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"><<</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">"key"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-s">", "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"345"</span><span class="tok-p">);</span> |
2748 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", new attribute: "</span><span class="tok-w"> </span><span class="tok-o"><<</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"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2773 <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"><<</span><span class="tok-w"> </span><span class="tok-s">", new attribute: "</span><span class="tok-w"> </span><span class="tok-o"><<</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"><<</span><span class="tok-w"> </span><span class="tok-s">"="</span><span class="tok-w"> </span><span class="tok-o"><<</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2749 | 2774 |
2750 <span class="tok-c1">// we can use numbers or booleans</span> | 2775 <span class="tok-c1">// we can use numbers or booleans</span> |
2751 <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-mf">1.234</span><span class="tok-p">);</span><span class="tok-w"></span> | 2776 <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-mf">1.234</span><span class="tok-p">);</span> |
2752 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"new attribute value: "</span><span class="tok-w"> </span><span class="tok-o"><<</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 2777 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"new attribute value: "</span><span class="tok-w"> </span><span class="tok-o"><<</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
2753 | 2778 |
2754 <span class="tok-c1">// we can also use assignment operators for more concise code</span> | 2779 <span class="tok-c1">// we can also use assignment operators for more concise code</span> |
2755 <span class="tok-n">attr</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">;</span><span class="tok-w"></span> | 2780 <span class="tok-n">attr</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">;</span> |
2756 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"final attribute value: "</span><span class="tok-w"> </span><span class="tok-o"><<</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 2781 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"final attribute value: "</span><span class="tok-w"> </span><span class="tok-o"><<</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-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
2757 </div> | 2782 </div> |
2758 </div> | 2783 </div> |
2759 </div> | 2784 </div> |
2760 <div class="sect2"> | 2785 <div class="sect2"> |
2761 <h3 id="modify.add"><a class="anchor" href="#modify.add"></a><a class="link" href="#modify.add">6.2. Adding nodes/attributes</a></h3> | 2786 <h3 id="modify.add"><a class="anchor" href="#modify.add"></a><a class="link" href="#modify.add">6.2. Adding nodes/attributes</a></h3> |
2763 <p><a id="xml_node::prepend_attribute"></a><a id="xml_node::append_attribute"></a><a id="xml_node::insert_attribute_after"></a><a id="xml_node::insert_attribute_before"></a><a id="xml_node::prepend_child"></a><a id="xml_node::append_child"></a><a id="xml_node::insert_child_after"></a><a id="xml_node::insert_child_before"></a> | 2788 <p><a id="xml_node::prepend_attribute"></a><a id="xml_node::append_attribute"></a><a id="xml_node::insert_attribute_after"></a><a id="xml_node::insert_attribute_before"></a><a id="xml_node::prepend_child"></a><a id="xml_node::append_child"></a><a id="xml_node::insert_child_after"></a><a id="xml_node::insert_child_before"></a> |
2764 Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node:</p> | 2789 Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node:</p> |
2765 </div> | 2790 </div> |
2766 <div class="listingblock"> | 2791 <div class="listingblock"> |
2767 <div class="content"> | 2792 <div class="content"> |
2768 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_attribute</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">name</span><span class="tok-p">);</span><span class="tok-w"></span> | 2793 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_attribute</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">name</span><span class="tok-p">);</span> |
2769 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_attribute</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">name</span><span class="tok-p">);</span><span class="tok-w"></span> | 2794 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_attribute</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">name</span><span class="tok-p">);</span> |
2770 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_attribute_after</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">name</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 2795 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_attribute_after</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">name</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
2771 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_attribute_before</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">name</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 2796 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_attribute_before</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">name</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
2772 | 2797 |
2773 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_child</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span><span class="tok-w"></span> | 2798 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_child</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span> |
2774 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_child</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span><span class="tok-w"></span> | 2799 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_child</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span> |
2775 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_after</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 2800 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_after</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
2776 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_before</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 2801 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_before</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
2777 | 2802 |
2778 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_child</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">name</span><span class="tok-p">);</span><span class="tok-w"></span> | 2803 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_child</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">name</span><span class="tok-p">);</span> |
2779 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_child</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">name</span><span class="tok-p">);</span><span class="tok-w"></span> | 2804 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_child</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">name</span><span class="tok-p">);</span> |
2780 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_after</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">name</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 2805 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_after</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">name</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
2781 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_before</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">name</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2806 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_child_before</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">name</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span></code></pre> |
2782 </div> | 2807 </div> |
2783 </div> | 2808 </div> |
2784 <div class="paragraph"> | 2809 <div class="paragraph"> |
2785 <p><code>append_attribute</code> and <code>append_child</code> create a new node/attribute at the end of the corresponding list of the node the method is called on; <code>prepend_attribute</code> and <code>prepend_child</code> create a new node/attribute at the beginning of the list; <code>insert_attribute_after</code>, <code>insert_attribute_before</code>, <code>insert_child_after</code> and <code>insert_attribute_before</code> add the node/attribute before or after the specified node/attribute.</p> | 2810 <p><code>append_attribute</code> and <code>append_child</code> create a new node/attribute at the end of the corresponding list of the node the method is called on; <code>prepend_attribute</code> and <code>prepend_child</code> create a new node/attribute at the beginning of the list; <code>insert_attribute_after</code>, <code>insert_attribute_before</code>, <code>insert_child_after</code> and <code>insert_attribute_before</code> add the node/attribute before or after the specified node/attribute.</p> |
2786 </div> | 2811 </div> |
2834 <p>This is an example of adding new attributes/nodes to the document (<a href="samples/modify_add.cpp" class="bare">samples/modify_add.cpp</a>):</p> | 2859 <p>This is an example of adding new attributes/nodes to the document (<a href="samples/modify_add.cpp" class="bare">samples/modify_add.cpp</a>):</p> |
2835 </div> | 2860 </div> |
2836 <div class="listingblock"> | 2861 <div class="listingblock"> |
2837 <div class="content"> | 2862 <div class="content"> |
2838 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// add node with some name</span> | 2863 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// add node with some name</span> |
2839 <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">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2864 <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">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">);</span> |
2840 | 2865 |
2841 <span class="tok-c1">// add description node with text child</span> | 2866 <span class="tok-c1">// add description node with text child</span> |
2842 <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">descr</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2867 <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">descr</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">);</span> |
2843 <span class="tok-n">descr</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pcdata</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"Simple node"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2868 <span class="tok-n">descr</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pcdata</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">"Simple node"</span><span class="tok-p">);</span> |
2844 | 2869 |
2845 <span class="tok-c1">// add param node before the description</span> | 2870 <span class="tok-c1">// add param node before the description</span> |
2846 <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">param</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-s">"param"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">descr</span><span class="tok-p">);</span><span class="tok-w"></span> | 2871 <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">param</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-s">"param"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">descr</span><span class="tok-p">);</span> |
2847 | 2872 |
2848 <span class="tok-c1">// add attributes to param node</span> | 2873 <span class="tok-c1">// add attributes to param node</span> |
2849 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"version"</span><span class="tok-p">;</span><span class="tok-w"></span> | 2874 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"version"</span><span class="tok-p">;</span> |
2850 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"value"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mf">1.1</span><span class="tok-p">;</span><span class="tok-w"></span> | 2875 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"value"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mf">1.1</span><span class="tok-p">;</span> |
2851 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">insert_attribute_after</span><span class="tok-p">(</span><span class="tok-s">"type"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">))</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"float"</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 2876 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">insert_attribute_after</span><span class="tok-p">(</span><span class="tok-s">"type"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">))</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"float"</span><span class="tok-p">;</span></code></pre> |
2852 </div> | 2877 </div> |
2853 </div> | 2878 </div> |
2854 </div> | 2879 </div> |
2855 <div class="sect2"> | 2880 <div class="sect2"> |
2856 <h3 id="modify.remove"><a class="anchor" href="#modify.remove"></a><a class="link" href="#modify.remove">6.3. Removing nodes/attributes</a></h3> | 2881 <h3 id="modify.remove"><a class="anchor" href="#modify.remove"></a><a class="link" href="#modify.remove">6.3. Removing nodes/attributes</a></h3> |
2858 <p><a id="xml_node::remove_attribute"></a><a id="xml_node::remove_attributes"></a><a id="xml_node::remove_child"></a><a id="xml_node::remove_children"></a> | 2883 <p><a id="xml_node::remove_attribute"></a><a id="xml_node::remove_attributes"></a><a id="xml_node::remove_child"></a><a id="xml_node::remove_children"></a> |
2859 If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:</p> | 2884 If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:</p> |
2860 </div> | 2885 </div> |
2861 <div class="listingblock"> | 2886 <div class="listingblock"> |
2862 <div class="content"> | 2887 <div class="content"> |
2863 <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::remove_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-p">);</span><span class="tok-w"></span> | 2888 <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::remove_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-p">);</span> |
2864 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_attributes</span><span class="tok-p">();</span><span class="tok-w"></span> | 2889 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_attributes</span><span class="tok-p">();</span> |
2865 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_child</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">);</span><span class="tok-w"></span> | 2890 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_child</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">);</span> |
2866 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_children</span><span class="tok-p">();</span><span class="tok-w"></span></code></pre> | 2891 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_children</span><span class="tok-p">();</span></code></pre> |
2867 </div> | 2892 </div> |
2868 </div> | 2893 </div> |
2869 <div class="paragraph"> | 2894 <div class="paragraph"> |
2870 <p><code>remove_attribute</code> removes the attribute from the attribute list of the node, and returns the operation result. <code>remove_child</code> removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. <code>remove_attributes</code> removes all the attributes of the node, and returns the operation result. <code>remove_children</code> removes all the child nodes of the node, and returns the operation result. Removing fails if one of the following is true:</p> | 2895 <p><code>remove_attribute</code> removes the attribute from the attribute list of the node, and returns the operation result. <code>remove_child</code> removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. <code>remove_attributes</code> removes all the attributes of the node, and returns the operation result. <code>remove_children</code> removes all the child nodes of the node, and returns the operation result. Removing fails if one of the following is true:</p> |
2871 </div> | 2896 </div> |
2888 <div class="paragraph"> | 2913 <div class="paragraph"> |
2889 <p>If you want to remove the attribute or child node by its name, two additional helper functions are available:</p> | 2914 <p>If you want to remove the attribute or child node by its name, two additional helper functions are available:</p> |
2890 </div> | 2915 </div> |
2891 <div class="listingblock"> | 2916 <div class="listingblock"> |
2892 <div class="content"> | 2917 <div class="content"> |
2893 <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::remove_attribute</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">name</span><span class="tok-p">);</span><span class="tok-w"></span> | 2918 <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::remove_attribute</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">name</span><span class="tok-p">);</span> |
2894 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_child</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">name</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2919 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_node::remove_child</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">name</span><span class="tok-p">);</span></code></pre> |
2895 </div> | 2920 </div> |
2896 </div> | 2921 </div> |
2897 <div class="paragraph"> | 2922 <div class="paragraph"> |
2898 <p>These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns <code>false</code>; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: <code>while (node.remove_child("tool")) ;</code>.</p> | 2923 <p>These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns <code>false</code>; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: <code>while (node.remove_child("tool")) ;</code>.</p> |
2899 </div> | 2924 </div> |
2901 <p>This is an example of removing attributes/nodes from the document (<a href="samples/modify_remove.cpp" class="bare">samples/modify_remove.cpp</a>):</p> | 2926 <p>This is an example of removing attributes/nodes from the document (<a href="samples/modify_remove.cpp" class="bare">samples/modify_remove.cpp</a>):</p> |
2902 </div> | 2927 </div> |
2903 <div class="listingblock"> | 2928 <div class="listingblock"> |
2904 <div class="content"> | 2929 <div class="content"> |
2905 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// remove description node with the whole subtree</span> | 2930 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// remove description node with the whole subtree</span> |
2906 <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">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2931 <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">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"node"</span><span class="tok-p">);</span> |
2907 <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2932 <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">);</span> |
2908 | 2933 |
2909 <span class="tok-c1">// remove id attribute</span> | 2934 <span class="tok-c1">// remove id attribute</span> |
2910 <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">param</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"param"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2935 <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">param</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"param"</span><span class="tok-p">);</span> |
2911 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-s">"value"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2936 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-s">"value"</span><span class="tok-p">);</span> |
2912 | 2937 |
2913 <span class="tok-c1">// we can also remove nodes/attributes by handles</span> | 2938 <span class="tok-c1">// we can also remove nodes/attributes by handles</span> |
2914 <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">id</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">);</span><span class="tok-w"></span> | 2939 <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">id</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">"name"</span><span class="tok-p">);</span> |
2915 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-n">id</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2940 <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-n">id</span><span class="tok-p">);</span></code></pre> |
2916 </div> | 2941 </div> |
2917 </div> | 2942 </div> |
2918 </div> | 2943 </div> |
2919 <div class="sect2"> | 2944 <div class="sect2"> |
2920 <h3 id="modify.text"><a class="anchor" href="#modify.text"></a><a class="link" href="#modify.text">6.4. Working with text contents</a></h3> | 2945 <h3 id="modify.text"><a class="anchor" href="#modify.text"></a><a class="link" href="#modify.text">6.4. Working with text contents</a></h3> |
2924 <div id="xml_text::set" class="paragraph"> | 2949 <div id="xml_text::set" class="paragraph"> |
2925 <p>Once you have an <code>xml_text</code> object, you can set the text contents using the following function:</p> | 2950 <p>Once you have an <code>xml_text</code> object, you can set the text contents using the following function:</p> |
2926 </div> | 2951 </div> |
2927 <div class="listingblock"> | 2952 <div class="listingblock"> |
2928 <div class="content"> | 2953 <div class="content"> |
2929 <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> | 2954 <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> |
2930 <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> | 2955 <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></code></pre> |
2931 </div> | 2956 </div> |
2932 </div> | 2957 </div> |
2933 <div class="paragraph"> | 2958 <div class="paragraph"> |
2934 <p>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 <a href="#node_declaration">node_declaration</a> 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).</p> | 2959 <p>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 <a href="#node_declaration">node_declaration</a> 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).</p> |
2935 </div> | 2960 </div> |
2936 <div id="xml_text::set_value" class="paragraph"> | 2961 <div id="xml_text::set_value" class="paragraph"> |
2937 <p>In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:</p> | 2962 <p>In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:</p> |
2938 </div> | 2963 </div> |
2939 <div class="listingblock"> | 2964 <div class="listingblock"> |
2940 <div class="content"> | 2965 <div class="content"> |
2941 <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-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2966 <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-kt">int</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2942 <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-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> | 2967 <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-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> |
2943 <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-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2968 <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-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2944 <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-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> | 2969 <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-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> |
2945 <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-kt">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2970 <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-kt">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2946 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span><span class="tok-w"></span> | 2971 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span> |
2947 <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-kt">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2972 <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-kt">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2948 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span><span class="tok-w"></span> | 2973 <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-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-kt">int</span><span class="tok-w"> </span><span class="tok-n">precision</span><span class="tok-p">);</span> |
2949 <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-kt">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2974 <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-kt">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
2950 <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-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> | 2975 <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-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> |
2951 <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-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></code></pre> | 2976 <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-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></code></pre> |
2952 </div> | 2977 </div> |
2953 </div> | 2978 </div> |
2954 <div class="paragraph"> | 2979 <div class="paragraph"> |
2955 <p>The above functions convert the argument to string and then call the base <code>set</code> function. These functions have the same semantics as similar <code>xml_attribute</code> functions. You can <a href="#xml_attribute::set_value">refer to documentation for the attribute functions</a> for details.</p> | 2980 <p>The above functions convert the argument to string and then call the base <code>set</code> function. These functions have the same semantics as similar <code>xml_attribute</code> functions. You can <a href="#xml_attribute::set_value">refer to documentation for the attribute functions</a> for details.</p> |
2956 </div> | 2981 </div> |
2957 <div id="xml_text::assign" class="paragraph"> | 2982 <div id="xml_text::assign" class="paragraph"> |
2958 <p>For convenience, all <code>set</code> functions have the corresponding assignment operators:</p> | 2983 <p>For convenience, all <code>set</code> functions have the corresponding assignment operators:</p> |
2959 </div> | 2984 </div> |
2960 <div class="listingblock"> | 2985 <div class="listingblock"> |
2961 <div class="content"> | 2986 <div class="content"> |
2962 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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> | 2987 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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> |
2963 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2988 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2964 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2989 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span> |
2965 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2990 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2966 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2991 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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-n">rhs</span><span class="tok-p">);</span> |
2967 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2992 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2968 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2993 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2969 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> | 2994 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><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> |
2970 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 2995 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span> |
2971 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 2996 <span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</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">rhs</span><span class="tok-p">);</span></code></pre> |
2972 </div> | 2997 </div> |
2973 </div> | 2998 </div> |
2974 <div class="paragraph"> | 2999 <div class="paragraph"> |
2975 <p>These operators simply call the right <code>set</code> function and return the attribute they’re called on; the return value of <code>set</code> is ignored, so errors are ignored.</p> | 3000 <p>These operators simply call the right <code>set</code> function and return the attribute they’re called on; the return value of <code>set</code> is ignored, so errors are ignored.</p> |
2976 </div> | 3001 </div> |
2978 <p>This is an example of using <code>xml_text</code> object to modify text contents (<a href="samples/text.cpp" class="bare">samples/text.cpp</a>):</p> | 3003 <p>This is an example of using <code>xml_text</code> object to modify text contents (<a href="samples/text.cpp" class="bare">samples/text.cpp</a>):</p> |
2979 </div> | 3004 </div> |
2980 <div class="listingblock"> | 3005 <div class="listingblock"> |
2981 <div class="content"> | 3006 <div class="content"> |
2982 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// change project version</span> | 3007 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// change project version</span> |
2983 <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"version"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mf">1.2</span><span class="tok-p">;</span><span class="tok-w"></span> | 3008 <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"version"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mf">1.2</span><span class="tok-p">;</span> |
2984 | 3009 |
2985 <span class="tok-c1">// add description element and set the contents</span> | 3010 <span class="tok-c1">// add description element and set the contents</span> |
2986 <span class="tok-c1">// note that we do not have to explicitly add the node_pcdata child</span> | 3011 <span class="tok-c1">// note that we do not have to explicitly add the node_pcdata child</span> |
2987 <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">"a test project"</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3012 <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">"description"</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">"a test project"</span><span class="tok-p">);</span></code></pre> |
2988 </div> | 3013 </div> |
2989 </div> | 3014 </div> |
2990 </div> | 3015 </div> |
2991 <div class="sect2"> | 3016 <div class="sect2"> |
2992 <h3 id="modify.clone"><a class="anchor" href="#modify.clone"></a><a class="link" href="#modify.clone">6.5. Cloning nodes/attributes</a></h3> | 3017 <h3 id="modify.clone"><a class="anchor" href="#modify.clone"></a><a class="link" href="#modify.clone">6.5. Cloning nodes/attributes</a></h3> |
2994 <p><a id="xml_node::prepend_copy"></a><a id="xml_node::append_copy"></a><a id="xml_node::insert_copy_after"></a><a id="xml_node::insert_copy_before"></a> | 3019 <p><a id="xml_node::prepend_copy"></a><a id="xml_node::append_copy"></a><a id="xml_node::insert_copy_after"></a><a id="xml_node::insert_copy_before"></a> |
2995 With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can’t create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions:</p> | 3020 With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can’t create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions:</p> |
2996 </div> | 3021 </div> |
2997 <div class="listingblock"> | 3022 <div class="listingblock"> |
2998 <div class="content"> | 3023 <div class="content"> |
2999 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 3024 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
3000 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 3025 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
3001 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_after</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 3026 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_after</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
3002 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_before</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 3027 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_before</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
3003 | 3028 |
3004 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 3029 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
3005 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 3030 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_copy</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
3006 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_after</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 3031 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_after</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
3007 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_before</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3032 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_copy_before</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span></code></pre> |
3008 </div> | 3033 </div> |
3009 </div> | 3034 </div> |
3010 <div class="paragraph"> | 3035 <div class="paragraph"> |
3011 <p>These functions mirror the structure of <code>append_child</code>, <code>prepend_child</code>, <code>insert_child_before</code> and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure.</p> | 3036 <p>These functions mirror the structure of <code>append_child</code>, <code>prepend_child</code>, <code>insert_child_before</code> and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure.</p> |
3012 </div> | 3037 </div> |
3032 <div class="paragraph"> | 3057 <div class="paragraph"> |
3033 <p>This is an example with one possible implementation of include tags in XML (<a href="samples/include.cpp" class="bare">samples/include.cpp</a>). It illustrates node cloning and usage of other document modification functions:</p> | 3058 <p>This is an example with one possible implementation of include tags in XML (<a href="samples/include.cpp" class="bare">samples/include.cpp</a>). It illustrates node cloning and usage of other document modification functions:</p> |
3034 </div> | 3059 </div> |
3035 <div class="listingblock"> | 3060 <div class="listingblock"> |
3036 <div class="content"> | 3061 <div class="content"> |
3037 <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">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">doc</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-kt">char</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> | 3062 <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">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">doc</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-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">path</span><span class="tok-p">);</span> |
3038 | 3063 |
3039 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">preprocess</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">node</span><span class="tok-p">)</span><span class="tok-w"></span> | 3064 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">preprocess</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">node</span><span class="tok-p">)</span> |
3040 <span class="tok-p">{</span><span class="tok-w"></span> | 3065 <span class="tok-p">{</span> |
3041 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span> | 3066 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-p">)</span> |
3042 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 3067 <span class="tok-w"> </span><span class="tok-p">{</span> |
3043 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">type</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">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pi</span><span class="tok-w"> </span><span class="tok-o">&&</span><span class="tok-w"> </span><span class="tok-n">strcmp</span><span class="tok-p">(</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-s">"include"</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> | 3068 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">type</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">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pi</span><span class="tok-w"> </span><span class="tok-o">&&</span><span class="tok-w"> </span><span class="tok-n">strcmp</span><span class="tok-p">(</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-s">"include"</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> |
3044 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 3069 <span class="tok-w"> </span><span class="tok-p">{</span> |
3045 <span class="tok-w"> </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">include</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"></span> | 3070 <span class="tok-w"> </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">include</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span> |
3046 | 3071 |
3047 <span class="tok-w"> </span><span class="tok-c1">// load new preprocessed document (note: ideally this should handle relative paths)</span> | 3072 <span class="tok-w"> </span><span class="tok-c1">// load new preprocessed document (note: ideally this should handle relative paths)</span> |
3048 <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">path</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">include</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span><span class="tok-w"></span> | 3073 <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">path</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">include</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span> |
3049 | 3074 |
3050 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 3075 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
3051 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">,</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-k">return</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">;</span><span class="tok-w"></span> | 3076 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">,</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-k">return</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">;</span> |
3052 | 3077 |
3053 <span class="tok-w"> </span><span class="tok-c1">// insert the comment marker above include directive</span> | 3078 <span class="tok-w"> </span><span class="tok-c1">// insert the comment marker above include directive</span> |
3054 <span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_comment</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">include</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-n">path</span><span class="tok-p">);</span><span class="tok-w"></span> | 3079 <span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_comment</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">include</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-n">path</span><span class="tok-p">);</span> |
3055 | 3080 |
3056 <span class="tok-w"> </span><span class="tok-c1">// copy the document above the include directive (this retains the original order!)</span> | 3081 <span class="tok-w"> </span><span class="tok-c1">// copy the document above the include directive (this retains the original order!)</span> |
3057 <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">ic</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">ic</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-n">ic</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">ic</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span><span class="tok-w"></span> | 3082 <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">ic</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">ic</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-n">ic</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">ic</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span> |
3058 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 3083 <span class="tok-w"> </span><span class="tok-p">{</span> |
3059 <span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_copy_before</span><span class="tok-p">(</span><span class="tok-n">ic</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">include</span><span class="tok-p">);</span><span class="tok-w"></span> | 3084 <span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_copy_before</span><span class="tok-p">(</span><span class="tok-n">ic</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">include</span><span class="tok-p">);</span> |
3060 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 3085 <span class="tok-w"> </span><span class="tok-p">}</span> |
3061 | 3086 |
3062 <span class="tok-w"> </span><span class="tok-c1">// remove the include node and move to the next child</span> | 3087 <span class="tok-w"> </span><span class="tok-c1">// remove the include node and move to the next child</span> |
3063 <span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">();</span><span class="tok-w"></span> | 3088 <span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">();</span> |
3064 | 3089 |
3065 <span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-n">include</span><span class="tok-p">);</span><span class="tok-w"></span> | 3090 <span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-n">include</span><span class="tok-p">);</span> |
3066 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 3091 <span class="tok-w"> </span><span class="tok-p">}</span> |
3067 <span class="tok-w"> </span><span class="tok-k">else</span><span class="tok-w"></span> | 3092 <span class="tok-w"> </span><span class="tok-k">else</span> |
3068 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 3093 <span class="tok-w"> </span><span class="tok-p">{</span> |
3069 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">preprocess</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">))</span><span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">;</span><span class="tok-w"></span> | 3094 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">preprocess</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">))</span><span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">;</span> |
3070 | 3095 |
3071 <span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">();</span><span class="tok-w"></span> | 3096 <span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">();</span> |
3072 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 3097 <span class="tok-w"> </span><span class="tok-p">}</span> |
3073 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 3098 <span class="tok-w"> </span><span class="tok-p">}</span> |
3074 | 3099 |
3075 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">;</span><span class="tok-w"></span> | 3100 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">;</span> |
3076 <span class="tok-p">}</span><span class="tok-w"></span> | 3101 <span class="tok-p">}</span> |
3077 | 3102 |
3078 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">doc</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-kt">char</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> | 3103 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">doc</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-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">path</span><span class="tok-p">)</span> |
3079 <span class="tok-p">{</span><span class="tok-w"></span> | 3104 <span class="tok-p">{</span> |
3080 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-n">path</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span><span class="tok-w"> </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">parse_pi</span><span class="tok-p">);</span><span class="tok-w"> </span><span class="tok-c1">// for <?include?></span> | 3105 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-n">path</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span><span class="tok-w"> </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">parse_pi</span><span class="tok-p">);</span><span class="tok-w"> </span><span class="tok-c1">// for <?include?></span> |
3081 | 3106 |
3082 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">?</span><span class="tok-w"> </span><span class="tok-n">preprocess</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">)</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> | 3107 <span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-w"> </span><span class="tok-o">?</span><span class="tok-w"> </span><span class="tok-n">preprocess</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">)</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> |
3083 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 3108 <span class="tok-p">}</span></code></pre> |
3084 </div> | 3109 </div> |
3085 </div> | 3110 </div> |
3086 </div> | 3111 </div> |
3087 <div class="sect2"> | 3112 <div class="sect2"> |
3088 <h3 id="modify.move"><a class="anchor" href="#modify.move"></a><a class="link" href="#modify.move">6.6. Moving nodes</a></h3> | 3113 <h3 id="modify.move"><a class="anchor" href="#modify.move"></a><a class="link" href="#modify.move">6.6. Moving nodes</a></h3> |
3090 <p><a id="xml_node::prepend_move"></a><a id="xml_node::append_move"></a><a id="xml_node::insert_move_after"></a><a id="xml_node::insert_move_before"></a> | 3115 <p><a id="xml_node::prepend_move"></a><a id="xml_node::append_move"></a><a id="xml_node::insert_move_after"></a><a id="xml_node::insert_move_before"></a> |
3091 Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:</p> | 3116 Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:</p> |
3092 </div> | 3117 </div> |
3093 <div class="listingblock"> | 3118 <div class="listingblock"> |
3094 <div class="content"> | 3119 <div class="content"> |
3095 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_move</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span><span class="tok-w"></span> | 3120 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_move</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span> |
3096 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_move</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span><span class="tok-w"></span> | 3121 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::prepend_move</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span> |
3097 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_move_after</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 3122 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_move_after</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
3098 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_move_before</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3123 <span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::insert_move_before</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span></code></pre> |
3099 </div> | 3124 </div> |
3100 </div> | 3125 </div> |
3101 <div class="paragraph"> | 3126 <div class="paragraph"> |
3102 <p>These functions mirror the structure of <code>append_copy</code>, <code>prepend_copy</code>, <code>insert_copy_before</code> and <code>insert_copy_after</code> - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.</p> | 3127 <p>These functions mirror the structure of <code>append_copy</code>, <code>prepend_copy</code>, <code>insert_copy_before</code> and <code>insert_copy_after</code> - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.</p> |
3103 </div> | 3128 </div> |
3130 <ul> | 3155 <ul> |
3131 <li> | 3156 <li> |
3132 <p>Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:</p> | 3157 <p>Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:</p> |
3133 <div class="listingblock"> | 3158 <div class="listingblock"> |
3134 <div class="content"> | 3159 <div class="content"> |
3135 <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">append_fragment</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">target</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-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</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> | 3160 <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">append_fragment</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">target</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-kt">char</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</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> |
3136 <span class="tok-p">{</span><span class="tok-w"></span> | 3161 <span class="tok-p">{</span> |
3137 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 3162 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
3138 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</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-k">return</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">;</span><span class="tok-w"></span> | 3163 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</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-k">return</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">;</span> |
3139 | 3164 |
3140 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span><span class="tok-w"></span> | 3165 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span> |
3141 <span class="tok-w"> </span><span class="tok-n">target</span><span class="tok-p">.</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">);</span><span class="tok-w"></span> | 3166 <span class="tok-w"> </span><span class="tok-n">target</span><span class="tok-p">.</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">);</span> |
3142 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 3167 <span class="tok-p">}</span></code></pre> |
3143 </div> | 3168 </div> |
3144 </div> | 3169 </div> |
3145 </li> | 3170 </li> |
3146 <li> | 3171 <li> |
3147 <p>Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment:</p> | 3172 <p>Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment:</p> |
3148 <div class="listingblock"> | 3173 <div class="listingblock"> |
3149 <div class="content"> | 3174 <div class="content"> |
3150 <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">append_fragment</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">target</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-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">cached_fragment</span><span class="tok-p">)</span><span class="tok-w"></span> | 3175 <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">append_fragment</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">target</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-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">cached_fragment</span><span class="tok-p">)</span> |
3151 <span class="tok-p">{</span><span class="tok-w"></span> | 3176 <span class="tok-p">{</span> |
3152 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">cached_fragment</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span><span class="tok-w"></span> | 3177 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">cached_fragment</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">;</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span> |
3153 <span class="tok-w"> </span><span class="tok-n">target</span><span class="tok-p">.</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">);</span><span class="tok-w"></span> | 3178 <span class="tok-w"> </span><span class="tok-n">target</span><span class="tok-p">.</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">);</span> |
3154 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 3179 <span class="tok-p">}</span></code></pre> |
3155 </div> | 3180 </div> |
3156 </div> | 3181 </div> |
3157 </li> | 3182 </li> |
3158 <li> | 3183 <li> |
3159 <p>Use <code>xml_node::append_buffer</code> directly:</p> | 3184 <p>Use <code>xml_node::append_buffer</code> directly:</p> |
3160 <div class="listingblock"> | 3185 <div class="listingblock"> |
3161 <div class="content"> | 3186 <div class="content"> |
3162 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_buffer</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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3187 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><span class="tok-nf">xml_node::append_buffer</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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span></code></pre> |
3163 </div> | 3188 </div> |
3164 </div> | 3189 </div> |
3165 </li> | 3190 </li> |
3166 </ul> | 3191 </ul> |
3167 </div> | 3192 </div> |
3195 <p><a id="xml_document::save_file"></a><a id="xml_document::save_file_wide"></a> | 3220 <p><a id="xml_document::save_file"></a><a id="xml_document::save_file_wide"></a> |
3196 If you want to save the whole document to a file, you can use one of the following functions:</p> | 3221 If you want to save the whole document to a file, you can use one of the following functions:</p> |
3197 </div> | 3222 </div> |
3198 <div class="listingblock"> | 3223 <div class="listingblock"> |
3199 <div class="content"> | 3224 <div class="content"> |
3200 <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_document::save_file</span><span class="tok-p">(</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">path</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 3225 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save_file</span><span class="tok-p">(</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">path</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3201 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xml_document::save_file</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-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">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 3226 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-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">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3202 </div> | 3227 </div> |
3203 </div> | 3228 </div> |
3204 <div class="paragraph"> | 3229 <div class="paragraph"> |
3205 <p>These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see <a href="#saving.options">Output options</a>) and output data encoding (see <a href="#saving.encoding">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc. The functions return <code>true</code> on success and <code>false</code> if the file could not be opened or written to.</p> | 3230 <p>These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see <a href="#saving.options">Output options</a>) and output data encoding (see <a href="#saving.encoding">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc. The functions return <code>true</code> on success and <code>false</code> if the file could not be opened or written to.</p> |
3206 </div> | 3231 </div> |
3214 <p>This is a simple example of saving XML document to file (<a href="samples/save_file.cpp" class="bare">samples/save_file.cpp</a>):</p> | 3239 <p>This is a simple example of saving XML document to file (<a href="samples/save_file.cpp" class="bare">samples/save_file.cpp</a>):</p> |
3215 </div> | 3240 </div> |
3216 <div class="listingblock"> | 3241 <div class="listingblock"> |
3217 <div class="content"> | 3242 <div class="content"> |
3218 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// save document to file</span> | 3243 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// save document to file</span> |
3219 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Saving result: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-s">"save_file_output.xml"</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 3244 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Saving result: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-s">"save_file_output.xml"</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
3220 </div> | 3245 </div> |
3221 </div> | 3246 </div> |
3222 </div> | 3247 </div> |
3223 <div class="sect2"> | 3248 <div class="sect2"> |
3224 <h3 id="saving.stream"><a class="anchor" href="#saving.stream"></a><a class="link" href="#saving.stream">7.2. Saving document to C++ IOstreams</a></h3> | 3249 <h3 id="saving.stream"><a class="anchor" href="#saving.stream"></a><a class="link" href="#saving.stream">7.2. Saving document to C++ IOstreams</a></h3> |
3225 <div id="xml_document::save_stream" class="paragraph"> | 3250 <div id="xml_document::save_stream" class="paragraph"> |
3226 <p>To enhance interoperability pugixml provides functions for saving document to any object which implements C++ <code>std::ostream</code> interface. This allows you to save documents to any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use <code>std::cout</code> stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:</p> | 3251 <p>To enhance interoperability pugixml provides functions for saving document to any object which implements C++ <code>std::ostream</code> interface. This allows you to save documents to any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use <code>std::cout</code> stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:</p> |
3227 </div> | 3252 </div> |
3228 <div class="listingblock"> | 3253 <div class="listingblock"> |
3229 <div class="content"> | 3254 <div class="content"> |
3230 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xml_document::save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 3255 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3231 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xml_document::save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</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> | 3256 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3232 </div> | 3257 </div> |
3233 </div> | 3258 </div> |
3234 <div class="paragraph"> | 3259 <div class="paragraph"> |
3235 <p><code>save</code> with <code>std::ostream</code> argument saves the document to the stream in the same way as <code>save_file</code> (i.e. with requested header and with encoding conversions). On the other hand, <code>save</code> with <code>std::wstream</code> argument saves the document to the wide stream with <a href="#encoding_wchar">encoding_wchar</a> encoding. Because of this, using <code>save</code> with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the <code>imbue</code> function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale.</p> | 3260 <p><code>save</code> with <code>std::ostream</code> argument saves the document to the stream in the same way as <code>save_file</code> (i.e. with requested header and with encoding conversions). On the other hand, <code>save</code> with <code>std::wstream</code> argument saves the document to the wide stream with <a href="#encoding_wchar">encoding_wchar</a> encoding. Because of this, using <code>save</code> with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the <code>imbue</code> function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale.</p> |
3236 </div> | 3261 </div> |
3241 <p>This is a simple example of saving XML document to standard output (<a href="samples/save_stream.cpp" class="bare">samples/save_stream.cpp</a>):</p> | 3266 <p>This is a simple example of saving XML document to standard output (<a href="samples/save_stream.cpp" class="bare">samples/save_stream.cpp</a>):</p> |
3242 </div> | 3267 </div> |
3243 <div class="listingblock"> | 3268 <div class="listingblock"> |
3244 <div class="content"> | 3269 <div class="content"> |
3245 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// save document to standard output</span> | 3270 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// save document to standard output</span> |
3246 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Document:</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 3271 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Document:</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
3247 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3272 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span></code></pre> |
3248 </div> | 3273 </div> |
3249 </div> | 3274 </div> |
3250 </div> | 3275 </div> |
3251 <div class="sect2"> | 3276 <div class="sect2"> |
3252 <h3 id="saving.writer"><a class="anchor" href="#saving.writer"></a><a class="link" href="#saving.writer">7.3. Saving document via writer interface</a></h3> | 3277 <h3 id="saving.writer"><a class="anchor" href="#saving.writer"></a><a class="link" href="#saving.writer">7.3. Saving document via writer interface</a></h3> |
3254 <p><a id="xml_document::save"></a><a id="xml_writer"></a><a id="xml_writer::write"></a> | 3279 <p><a id="xml_document::save"></a><a id="xml_writer"></a><a id="xml_writer::write"></a> |
3255 All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input:</p> | 3280 All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input:</p> |
3256 </div> | 3281 </div> |
3257 <div class="listingblock"> | 3282 <div class="listingblock"> |
3258 <div class="content"> | 3283 <div class="content"> |
3259 <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> | 3284 <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> |
3260 <span class="tok-p">{</span><span class="tok-w"></span> | 3285 <span class="tok-p">{</span> |
3261 <span class="tok-k">public</span><span class="tok-o">:</span><span class="tok-w"></span> | 3286 <span class="tok-k">public</span><span class="tok-o">:</span> |
3262 <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> | 3287 <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> |
3263 <span class="tok-p">};</span><span class="tok-w"></span> | 3288 <span class="tok-p">};</span> |
3264 | 3289 |
3265 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xml_document::save</span><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 3290 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3266 </div> | 3291 </div> |
3267 </div> | 3292 </div> |
3268 <div class="paragraph"> | 3293 <div class="paragraph"> |
3269 <p>In order to output the document via some custom transport, for example sockets, you should create an object which implements <code>xml_writer</code> interface and pass it to <code>save</code> function. <code>xml_writer::write</code> function is called with a buffer as an input, where <code>data</code> points to buffer start, and <code>size</code> is equal to the buffer size in bytes. <code>write</code> implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after <code>write</code> returns. The buffer contains the chunk of document data in the desired encoding.</p> | 3294 <p>In order to output the document via some custom transport, for example sockets, you should create an object which implements <code>xml_writer</code> interface and pass it to <code>save</code> function. <code>xml_writer::write</code> function is called with a buffer as an input, where <code>data</code> points to buffer start, and <code>size</code> is equal to the buffer size in bytes. <code>write</code> implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after <code>write</code> returns. The buffer contains the chunk of document data in the desired encoding.</p> |
3270 </div> | 3295 </div> |
3274 <div class="paragraph"> | 3299 <div class="paragraph"> |
3275 <p>This is a simple example of custom writer for saving document data to STL string (<a href="samples/save_custom_writer.cpp" class="bare">samples/save_custom_writer.cpp</a>); read the sample code for more complex examples:</p> | 3300 <p>This is a simple example of custom writer for saving document data to STL string (<a href="samples/save_custom_writer.cpp" class="bare">samples/save_custom_writer.cpp</a>); read the sample code for more complex examples:</p> |
3276 </div> | 3301 </div> |
3277 <div class="listingblock"> | 3302 <div class="listingblock"> |
3278 <div class="content"> | 3303 <div class="content"> |
3279 <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> | 3304 <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> |
3280 <span class="tok-p">{</span><span class="tok-w"></span> | 3305 <span class="tok-p">{</span> |
3281 <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> | 3306 <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> |
3282 | 3307 |
3283 <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-nf">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> | 3308 <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-nf">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> |
3284 <span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span> | 3309 <span class="tok-w"> </span><span class="tok-p">{</span> |
3285 <span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">append</span><span class="tok-p">(</span><span class="tok-k">static_cast</span><span class="tok-o"><</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-p">(</span><span class="tok-n">data</span><span class="tok-p">),</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span><span class="tok-w"></span> | 3310 <span class="tok-w"> </span><span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">append</span><span class="tok-p">(</span><span class="tok-k">static_cast</span><span class="tok-o"><</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-p">(</span><span class="tok-n">data</span><span class="tok-p">),</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
3286 <span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span> | 3311 <span class="tok-w"> </span><span class="tok-p">}</span> |
3287 <span class="tok-p">};</span><span class="tok-w"></span></code></pre> | 3312 <span class="tok-p">};</span></code></pre> |
3288 </div> | 3313 </div> |
3289 </div> | 3314 </div> |
3290 </div> | 3315 </div> |
3291 <div class="sect2"> | 3316 <div class="sect2"> |
3292 <h3 id="saving.subtree"><a class="anchor" href="#saving.subtree"></a><a class="link" href="#saving.subtree">7.4. Saving a single subtree</a></h3> | 3317 <h3 id="saving.subtree"><a class="anchor" href="#saving.subtree"></a><a class="link" href="#saving.subtree">7.4. Saving a single subtree</a></h3> |
3294 <p><a id="xml_node::print"></a><a id="xml_node::print_stream"></a> | 3319 <p><a id="xml_node::print"></a><a id="xml_node::print_stream"></a> |
3295 While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided:</p> | 3320 While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided:</p> |
3296 </div> | 3321 </div> |
3297 <div class="listingblock"> | 3322 <div class="listingblock"> |
3298 <div class="content"> | 3323 <div class="content"> |
3299 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xml_node::print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> | 3324 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> |
3300 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xml_node::print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</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">depth</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> | 3325 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</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">depth</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> |
3301 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xml_node::print</span><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> | 3326 <span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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></code></pre> |
3302 </div> | 3327 </div> |
3303 </div> | 3328 </div> |
3304 <div class="paragraph"> | 3329 <div class="paragraph"> |
3305 <p>These functions have the same arguments with the same meaning as the corresponding <code>xml_document::save</code> functions, and allow you to save the subtree to either a C++ IOstream or to any object that implements <code>xml_writer</code> interface.</p> | 3330 <p>These functions have the same arguments with the same meaning as the corresponding <code>xml_document::save</code> functions, and allow you to save the subtree to either a C++ IOstream or to any object that implements <code>xml_writer</code> interface.</p> |
3306 </div> | 3331 </div> |
3308 <p>Saving a subtree differs from saving the whole document: the process behaves as if <a href="#format_write_bom">format_write_bom</a> is off, and <a href="#format_no_declaration">format_no_declaration</a> is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node’s children. Note that this also holds if you’re saving a document; this example (<a href="samples/save_subtree.cpp" class="bare">samples/save_subtree.cpp</a>) illustrates the difference:</p> | 3333 <p>Saving a subtree differs from saving the whole document: the process behaves as if <a href="#format_write_bom">format_write_bom</a> is off, and <a href="#format_no_declaration">format_no_declaration</a> is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node’s children. Note that this also holds if you’re saving a document; this example (<a href="samples/save_subtree.cpp" class="bare">samples/save_subtree.cpp</a>) illustrates the difference:</p> |
3309 </div> | 3334 </div> |
3310 <div class="listingblock"> | 3335 <div class="listingblock"> |
3311 <div class="content"> | 3336 <div class="content"> |
3312 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// get a test document</span> | 3337 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// get a test document</span> |
3313 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 3338 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
3314 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<foo bar='baz'><call>hey</call></foo>"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3339 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<foo bar='baz'><call>hey</call></foo>"</span><span class="tok-p">);</span> |
3315 | 3340 |
3316 <span class="tok-c1">// print document to standard output (prints <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>)</span> | 3341 <span class="tok-c1">// print document to standard output (prints <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>)</span> |
3317 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span><span class="tok-w"></span> | 3342 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span> |
3318 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3343 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3319 | 3344 |
3320 <span class="tok-c1">// print document to standard output as a regular node (prints <foo bar="baz"><call>hey</call></foo>)</span> | 3345 <span class="tok-c1">// print document to standard output as a regular node (prints <foo bar="baz"><call>hey</call></foo>)</span> |
3321 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span><span class="tok-w"></span> | 3346 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span> |
3322 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3347 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3323 | 3348 |
3324 <span class="tok-c1">// print a subtree to standard output (prints <call>hey</call>)</span> | 3349 <span class="tok-c1">// print a subtree to standard output (prints <call>hey</call>)</span> |
3325 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"foo"</span><span class="tok-p">).</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"call"</span><span class="tok-p">).</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span><span class="tok-w"></span> | 3350 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"foo"</span><span class="tok-p">).</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">"call"</span><span class="tok-p">).</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span> |
3326 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 3351 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
3327 </div> | 3352 </div> |
3328 </div> | 3353 </div> |
3329 </div> | 3354 </div> |
3330 <div class="sect2"> | 3355 <div class="sect2"> |
3331 <h3 id="saving.options"><a class="anchor" href="#saving.options"></a><a class="link" href="#saving.options">7.5. Output options</a></h3> | 3356 <h3 id="saving.options"><a class="anchor" href="#saving.options"></a><a class="link" href="#saving.options">7.5. Output options</a></h3> |
3403 <p>This is an example that shows the outputs of different output options (<a href="samples/save_options.cpp" class="bare">samples/save_options.cpp</a>):</p> | 3428 <p>This is an example that shows the outputs of different output options (<a href="samples/save_options.cpp" class="bare">samples/save_options.cpp</a>):</p> |
3404 </div> | 3429 </div> |
3405 <div class="listingblock"> | 3430 <div class="listingblock"> |
3406 <div class="content"> | 3431 <div class="content"> |
3407 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// get a test document</span> | 3432 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// get a test document</span> |
3408 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 3433 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
3409 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<foo bar='baz'><call>hey</call></foo>"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3434 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<foo bar='baz'><call>hey</call></foo>"</span><span class="tok-p">);</span> |
3410 | 3435 |
3411 <span class="tok-c1">// default options; prints</span> | 3436 <span class="tok-c1">// default options; prints</span> |
3412 <span class="tok-c1">// <?xml version="1.0"?></span> | 3437 <span class="tok-c1">// <?xml version="1.0"?></span> |
3413 <span class="tok-c1">// <foo bar="baz"></span> | 3438 <span class="tok-c1">// <foo bar="baz"></span> |
3414 <span class="tok-c1">// <call>hey</call></span> | 3439 <span class="tok-c1">// <call>hey</call></span> |
3415 <span class="tok-c1">// </foo></span> | 3440 <span class="tok-c1">// </foo></span> |
3416 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span> | 3441 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span> |
3417 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3442 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3418 | 3443 |
3419 <span class="tok-c1">// default options with custom indentation string; prints</span> | 3444 <span class="tok-c1">// default options with custom indentation string; prints</span> |
3420 <span class="tok-c1">// <?xml version="1.0"?></span> | 3445 <span class="tok-c1">// <?xml version="1.0"?></span> |
3421 <span class="tok-c1">// <foo bar="baz"></span> | 3446 <span class="tok-c1">// <foo bar="baz"></span> |
3422 <span class="tok-c1">// --<call>hey</call></span> | 3447 <span class="tok-c1">// --<call>hey</call></span> |
3423 <span class="tok-c1">// </foo></span> | 3448 <span class="tok-c1">// </foo></span> |
3424 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"--"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3449 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"--"</span><span class="tok-p">);</span> |
3425 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3450 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3426 | 3451 |
3427 <span class="tok-c1">// default options without indentation; prints</span> | 3452 <span class="tok-c1">// default options without indentation; prints</span> |
3428 <span class="tok-c1">// <?xml version="1.0"?></span> | 3453 <span class="tok-c1">// <?xml version="1.0"?></span> |
3429 <span class="tok-c1">// <foo bar="baz"></span> | 3454 <span class="tok-c1">// <foo bar="baz"></span> |
3430 <span class="tok-c1">// <call>hey</call></span> | 3455 <span class="tok-c1">// <call>hey</call></span> |
3431 <span class="tok-c1">// </foo></span> | 3456 <span class="tok-c1">// </foo></span> |
3432 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_default</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-o">~</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_indent</span><span class="tok-p">);</span><span class="tok-w"> </span><span class="tok-c1">// can also pass "" instead of indentation string for the same effect</span> | 3457 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_default</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-o">~</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_indent</span><span class="tok-p">);</span><span class="tok-w"> </span><span class="tok-c1">// can also pass "" instead of indentation string for the same effect</span> |
3433 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3458 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3434 | 3459 |
3435 <span class="tok-c1">// raw output; prints</span> | 3460 <span class="tok-c1">// raw output; prints</span> |
3436 <span class="tok-c1">// <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo></span> | 3461 <span class="tok-c1">// <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo></span> |
3437 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span><span class="tok-w"></span> | 3462 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span> |
3438 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3463 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3439 | 3464 |
3440 <span class="tok-c1">// raw output without declaration; prints</span> | 3465 <span class="tok-c1">// raw output without declaration; prints</span> |
3441 <span class="tok-c1">// <foo bar="baz"><call>hey</call></foo></span> | 3466 <span class="tok-c1">// <foo bar="baz"><call>hey</call></foo></span> |
3442 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-w"> </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">format_no_declaration</span><span class="tok-p">);</span><span class="tok-w"></span> | 3467 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-w"> </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">format_no_declaration</span><span class="tok-p">);</span> |
3443 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 3468 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
3444 </div> | 3469 </div> |
3445 </div> | 3470 </div> |
3446 </div> | 3471 </div> |
3447 <div class="sect2"> | 3472 <div class="sect2"> |
3448 <h3 id="saving.encoding"><a class="anchor" href="#saving.encoding"></a><a class="link" href="#saving.encoding">7.6. Encodings</a></h3> | 3473 <h3 id="saving.encoding"><a class="anchor" href="#saving.encoding"></a><a class="link" href="#saving.encoding">7.6. Encodings</a></h3> |
3492 <p>This is an example that shows how to create a custom declaration node (<a href="samples/save_declaration.cpp" class="bare">samples/save_declaration.cpp</a>):</p> | 3517 <p>This is an example that shows how to create a custom declaration node (<a href="samples/save_declaration.cpp" class="bare">samples/save_declaration.cpp</a>):</p> |
3493 </div> | 3518 </div> |
3494 <div class="listingblock"> | 3519 <div class="listingblock"> |
3495 <div class="content"> | 3520 <div class="content"> |
3496 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// get a test document</span> | 3521 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// get a test document</span> |
3497 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span><span class="tok-w"></span> | 3522 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">;</span> |
3498 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<foo bar='baz'><call>hey</call></foo>"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3523 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">"<foo bar='baz'><call>hey</call></foo>"</span><span class="tok-p">);</span> |
3499 | 3524 |
3500 <span class="tok-c1">// add a custom declaration node</span> | 3525 <span class="tok-c1">// add a custom declaration node</span> |
3501 <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">decl</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">prepend_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_declaration</span><span class="tok-p">);</span><span class="tok-w"></span> | 3526 <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">decl</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">prepend_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_declaration</span><span class="tok-p">);</span> |
3502 <span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"version"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"1.0"</span><span class="tok-p">;</span><span class="tok-w"></span> | 3527 <span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"version"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"1.0"</span><span class="tok-p">;</span> |
3503 <span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"encoding"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"UTF-8"</span><span class="tok-p">;</span><span class="tok-w"></span> | 3528 <span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"encoding"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"UTF-8"</span><span class="tok-p">;</span> |
3504 <span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"standalone"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"no"</span><span class="tok-p">;</span><span class="tok-w"></span> | 3529 <span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">"standalone"</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"no"</span><span class="tok-p">;</span> |
3505 | 3530 |
3506 <span class="tok-c1">// <?xml version="1.0" encoding="UTF-8" standalone="no"?></span> | 3531 <span class="tok-c1">// <?xml version="1.0" encoding="UTF-8" standalone="no"?></span> |
3507 <span class="tok-c1">// <foo bar="baz"></span> | 3532 <span class="tok-c1">// <foo bar="baz"></span> |
3508 <span class="tok-c1">// <call>hey</call></span> | 3533 <span class="tok-c1">// <call>hey</call></span> |
3509 <span class="tok-c1">// </foo></span> | 3534 <span class="tok-c1">// </foo></span> |
3510 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span> | 3535 <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span> |
3511 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 3536 <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"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre> |
3512 </div> | 3537 </div> |
3513 </div> | 3538 </div> |
3514 </div> | 3539 </div> |
3515 </div> | 3540 </div> |
3516 </div> | 3541 </div> |
3517 <div class="sect1"> | 3542 <div class="sect1"> |
3518 <h2 id="xpath"><a class="anchor" href="#xpath"></a><a class="link" href="#xpath">8. XPath</a></h2> | 3543 <h2 id="xpath"><a class="anchor" href="#xpath"></a><a class="link" href="#xpath">8. XPath</a></h2> |
3519 <div class="sectionbody"> | 3544 <div class="sectionbody"> |
3520 <div class="paragraph"> | 3545 <div class="paragraph"> |
3521 <p>If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in <a href="#xpath.w3c">Conformance to W3C specification</a>. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read <a href="http://www.w3schools.com/xpath/">W3Schools XPath tutorial</a>, <a href="http://www.tizag.com/xmlTutorial/xpathtutorial.php">XPath tutorial at tizag.com</a>, and <a href="http://www.w3.org/TR/xpath/">the XPath 1.0 specification</a>.</p> | 3546 <p>If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in <a href="#xpath.w3c">Conformance to W3C specification</a>. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read <a href="https://www.w3schools.com/xml/xpath_intro.asp">W3Schools XPath tutorial</a> or <a href="https://www.w3.org/TR/xpath-10/">the XPath 1.0 specification</a>.</p> |
3522 </div> | 3547 </div> |
3523 <div class="sect2"> | 3548 <div class="sect2"> |
3524 <h3 id="xpath.types"><a class="anchor" href="#xpath.types"></a><a class="link" href="#xpath.types">8.1. XPath types</a></h3> | 3549 <h3 id="xpath.types"><a class="anchor" href="#xpath.types"></a><a class="link" href="#xpath.types">8.1. XPath types</a></h3> |
3525 <div class="paragraph"> | 3550 <div class="paragraph"> |
3526 <p><a id="xpath_value_type"></a><a id="xpath_type_number"></a><a id="xpath_type_string"></a><a id="xpath_type_boolean"></a><a id="xpath_type_node_set"></a><a id="xpath_type_none"></a> | 3551 <p><a id="xpath_value_type"></a><a id="xpath_type_number"></a><a id="xpath_type_string"></a><a id="xpath_type_boolean"></a><a id="xpath_type_node_set"></a><a id="xpath_type_none"></a> |
3530 <p><a id="xpath_node"></a><a id="xpath_node::node"></a><a id="xpath_node::attribute"></a><a id="xpath_node::parent"></a> | 3555 <p><a id="xpath_node"></a><a id="xpath_node::node"></a><a id="xpath_node::attribute"></a><a id="xpath_node::parent"></a> |
3531 Because an XPath node can be either a node or an attribute, there is a special type, <code>xpath_node</code>, which is a discriminated union of these types. A value of this type contains two node handles, one of <code>xml_node</code> type, and another one of <code>xml_attribute</code> type; at most one of them can be non-null. The accessors to get these handles are available:</p> | 3556 Because an XPath node can be either a node or an attribute, there is a special type, <code>xpath_node</code>, which is a discriminated union of these types. A value of this type contains two node handles, one of <code>xml_node</code> type, and another one of <code>xml_attribute</code> type; at most one of them can be non-null. The accessors to get these handles are available:</p> |
3532 </div> | 3557 </div> |
3533 <div class="listingblock"> | 3558 <div class="listingblock"> |
3534 <div class="content"> | 3559 <div class="content"> |
3535 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_node::node</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> | 3560 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_node::node</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3536 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xpath_node::attribute</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> | 3561 <span class="tok-n">xml_attribute</span><span class="tok-w"> </span><span class="tok-nf">xpath_node::attribute</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3537 </div> | 3562 </div> |
3538 </div> | 3563 </div> |
3539 <div class="paragraph"> | 3564 <div class="paragraph"> |
3540 <p>XPath nodes can be null, in which case both accessors return null handles.</p> | 3565 <p>XPath nodes can be null, in which case both accessors return null handles.</p> |
3541 </div> | 3566 </div> |
3542 <div class="paragraph"> | 3567 <div class="paragraph"> |
3543 <p>Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function:</p> | 3568 <p>Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function:</p> |
3544 </div> | 3569 </div> |
3545 <div class="listingblock"> | 3570 <div class="listingblock"> |
3546 <div class="content"> | 3571 <div class="content"> |
3547 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_node::parent</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> | 3572 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xml_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_node::parent</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3548 </div> | 3573 </div> |
3549 </div> | 3574 </div> |
3550 <div class="paragraph"> | 3575 <div class="paragraph"> |
3551 <p><code>parent</code> function returns the node’s parent if the XPath node corresponds to <code>xml_node</code> handle (equivalent to <code>node().parent()</code>), or the node to which the attribute belongs to, if the XPath node corresponds to <code>xml_attribute</code> handle. For null nodes, <code>parent</code> returns null handle.</p> | 3576 <p><code>parent</code> function returns the node’s parent if the XPath node corresponds to <code>xml_node</code> handle (equivalent to <code>node().parent()</code>), or the node to which the attribute belongs to, if the XPath node corresponds to <code>xml_attribute</code> handle. For null nodes, <code>parent</code> returns null handle.</p> |
3552 </div> | 3577 </div> |
3564 <p><a id="xpath_node_set::const_iterator"></a><a id="xpath_node_set::begin"></a><a id="xpath_node_set::end"></a> | 3589 <p><a id="xpath_node_set::const_iterator"></a><a id="xpath_node_set::begin"></a><a id="xpath_node_set::end"></a> |
3565 Node sets are represented by <code>xpath_node_set</code> object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors:</p> | 3590 Node sets are represented by <code>xpath_node_set</code> object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors:</p> |
3566 </div> | 3591 </div> |
3567 <div class="listingblock"> | 3592 <div class="listingblock"> |
3568 <div class="content"> | 3593 <div class="content"> |
3569 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span><span class="tok-p">;</span><span class="tok-w"></span> | 3594 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span><span class="tok-p">;</span> |
3570 <span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::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> | 3595 <span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::begin</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3571 <span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::end</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> | 3596 <span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::end</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3572 </div> | 3597 </div> |
3573 </div> | 3598 </div> |
3574 <div class="paragraph"> | 3599 <div class="paragraph"> |
3575 <p><a id="xpath_node_set::index"></a><a id="xpath_node_set::size"></a><a id="xpath_node_set::empty"></a> | 3600 <p><a id="xpath_node_set::index"></a><a id="xpath_node_set::size"></a><a id="xpath_node_set::empty"></a> |
3576 And it also can be iterated via indices, just like <code>std::vector</code>:</p> | 3601 And it also can be iterated via indices, just like <code>std::vector</code>:</p> |
3577 </div> | 3602 </div> |
3578 <div class="listingblock"> | 3603 <div class="listingblock"> |
3579 <div class="content"> | 3604 <div class="content"> |
3580 <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">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-p">[](</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">index</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> | 3605 <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">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-p">[](</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">index</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3581 <span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::size</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> | 3606 <span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::size</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3582 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::empty</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> | 3607 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::empty</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3583 </div> | 3608 </div> |
3584 </div> | 3609 </div> |
3585 <div class="paragraph"> | 3610 <div class="paragraph"> |
3586 <p>All of the above operations have the same semantics as that of <code>std::vector</code>: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster.</p> | 3611 <p>All of the above operations have the same semantics as that of <code>std::vector</code>: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster.</p> |
3587 </div> | 3612 </div> |
3589 <p><a id="xpath_node_set::type"></a><a id="xpath_node_set::type_unsorted"></a><a id="xpath_node_set::type_sorted"></a><a id="xpath_node_set::type_sorted_reverse"></a><a id="xpath_node_set::sort"></a> | 3614 <p><a id="xpath_node_set::type"></a><a id="xpath_node_set::type_unsorted"></a><a id="xpath_node_set::type_sorted"></a><a id="xpath_node_set::type_sorted_reverse"></a><a id="xpath_node_set::sort"></a> |
3590 The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:</p> | 3615 The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:</p> |
3591 </div> | 3616 </div> |
3592 <div class="listingblock"> | 3617 <div class="listingblock"> |
3593 <div class="content"> | 3618 <div class="content"> |
3594 <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> | 3619 <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> |
3595 <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> | 3620 <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></code></pre> |
3596 </div> | 3621 </div> |
3597 </div> | 3622 </div> |
3598 <div class="paragraph"> | 3623 <div class="paragraph"> |
3599 <p><code>type</code> function returns the current order of nodes; <code>type_sorted</code> means that the nodes are in forward document order, <code>type_sorted_reverse</code> means that the nodes are in reverse document order, and <code>type_unsorted</code> means that neither order is guaranteed (nodes can accidentally be in a sorted order even if <code>type()</code> returns <code>type_unsorted</code>). If you require a specific order of iteration, you can change it via <code>sort</code> function:</p> | 3624 <p><code>type</code> function returns the current order of nodes; <code>type_sorted</code> means that the nodes are in forward document order, <code>type_sorted_reverse</code> means that the nodes are in reverse document order, and <code>type_unsorted</code> means that neither order is guaranteed (nodes can accidentally be in a sorted order even if <code>type()</code> returns <code>type_unsorted</code>). If you require a specific order of iteration, you can change it via <code>sort</code> function:</p> |
3600 </div> | 3625 </div> |
3601 <div class="listingblock"> | 3626 <div class="listingblock"> |
3602 <div class="content"> | 3627 <div class="content"> |
3603 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::sort</span><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></code></pre> | 3628 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::sort</span><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></code></pre> |
3604 </div> | 3629 </div> |
3605 </div> | 3630 </div> |
3606 <div class="paragraph"> | 3631 <div class="paragraph"> |
3607 <p>Calling <code>sort</code> sorts the nodes in either forward or reverse document order, depending on the argument; after this call <code>type()</code> will return <code>type_sorted</code> or <code>type_sorted_reverse</code>.</p> | 3632 <p>Calling <code>sort</code> sorts the nodes in either forward or reverse document order, depending on the argument; after this call <code>type()</code> will return <code>type_sorted</code> or <code>type_sorted_reverse</code>.</p> |
3608 </div> | 3633 </div> |
3609 <div id="xpath_node_set::first" class="paragraph"> | 3634 <div id="xpath_node_set::first" class="paragraph"> |
3610 <p>Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:</p> | 3635 <p>Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:</p> |
3611 </div> | 3636 </div> |
3612 <div class="listingblock"> | 3637 <div class="listingblock"> |
3613 <div class="content"> | 3638 <div class="content"> |
3614 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::first</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> | 3639 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_node_set::first</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3615 </div> | 3640 </div> |
3616 </div> | 3641 </div> |
3617 <div class="paragraph"> | 3642 <div class="paragraph"> |
3618 <p>This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of <code>type()</code>), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.</p> | 3643 <p>This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of <code>type()</code>), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.</p> |
3619 </div> | 3644 </div> |
3620 <div id="xpath_node_set::ctor" class="paragraph"> | 3645 <div id="xpath_node_set::ctor" class="paragraph"> |
3621 <p>While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (<code>const_iterator</code> is a typedef for <code>const xpath_node*</code>), and an optional type:</p> | 3646 <p>While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (<code>const_iterator</code> is a typedef for <code>const xpath_node*</code>), and an optional type:</p> |
3622 </div> | 3647 </div> |
3623 <div class="listingblock"> | 3648 <div class="listingblock"> |
3624 <div class="content"> | 3649 <div class="content"> |
3625 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-p">(</span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">begin</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">end</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-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">type_unsorted</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3650 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-p">(</span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">begin</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">end</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-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">type_unsorted</span><span class="tok-p">);</span></code></pre> |
3626 </div> | 3651 </div> |
3627 </div> | 3652 </div> |
3628 <div class="paragraph"> | 3653 <div class="paragraph"> |
3629 <p>The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you’ll have to ensure that the range contains no duplicates, and that the objects are sorted according to the <code>type</code> parameter. Otherwise XPath operations with this set may produce unexpected results.</p> | 3654 <p>The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you’ll have to ensure that the range contains no duplicates, and that the objects are sorted according to the <code>type</code> parameter. Otherwise XPath operations with this set may produce unexpected results.</p> |
3630 </div> | 3655 </div> |
3635 <p><a id="xml_node::select_node"></a><a id="xml_node::select_nodes"></a> | 3660 <p><a id="xml_node::select_node"></a><a id="xml_node::select_nodes"></a> |
3636 If you want to select nodes that match some XPath expression, you can do it with the following functions:</p> | 3661 If you want to select nodes that match some XPath expression, you can do it with the following functions:</p> |
3637 </div> | 3662 </div> |
3638 <div class="listingblock"> | 3663 <div class="listingblock"> |
3639 <div class="content"> | 3664 <div class="content"> |
3640 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_node</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 3665 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_node</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> |
3641 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_nodes</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 3666 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_nodes</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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></code></pre> |
3642 </div> | 3667 </div> |
3643 </div> | 3668 </div> |
3644 <div class="paragraph"> | 3669 <div class="paragraph"> |
3645 <p><code>select_nodes</code> function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. <code>select_node</code> returns only the first node in document order from the result, and is equivalent to calling <code>select_nodes(query).first()</code>. If the XPath expression does not match anything, or the node handle is null, <code>select_nodes</code> returns an empty set, and <code>select_node</code> returns null XPath node.</p> | 3670 <p><code>select_nodes</code> function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. <code>select_node</code> returns only the first node in document order from the result, and is equivalent to calling <code>select_nodes(query).first()</code>. If the XPath expression does not match anything, or the node handle is null, <code>select_nodes</code> returns an empty set, and <code>select_node</code> returns null XPath node.</p> |
3646 </div> | 3671 </div> |
3651 <p><a id="xml_node::select_node_precomp"></a><a id="xml_node::select_nodes_precomp"></a> | 3676 <p><a id="xml_node::select_node_precomp"></a><a id="xml_node::select_nodes_precomp"></a> |
3652 While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you’re doing many similar queries, consider compiling them into query objects (see <a href="#xpath.query">Using query objects</a> for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:</p> | 3677 While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you’re doing many similar queries, consider compiling them into query objects (see <a href="#xpath.query">Using query objects</a> for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:</p> |
3653 </div> | 3678 </div> |
3654 <div class="listingblock"> | 3679 <div class="listingblock"> |
3655 <div class="content"> | 3680 <div class="content"> |
3656 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_node</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</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> | 3681 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_node</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3657 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_nodes</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</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> | 3682 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_nodes</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3658 </div> | 3683 </div> |
3659 </div> | 3684 </div> |
3660 <div class="paragraph"> | 3685 <div class="paragraph"> |
3661 <p>If exception handling is not disabled, both functions throw <a href="#xpath_exception">xpath_exception</a> if the query returns a value with type other than node set.</p> | 3686 <p>If exception handling is not disabled, both functions throw <a href="#xpath_exception">xpath_exception</a> if the query returns a value with type other than node set.</p> |
3662 </div> | 3687 </div> |
3663 <div class="paragraph"> | 3688 <div class="paragraph"> |
3664 <p>This is an example of selecting nodes using XPath expressions (<a href="samples/xpath_select.cpp" class="bare">samples/xpath_select.cpp</a>):</p> | 3689 <p>This is an example of selecting nodes using XPath expressions (<a href="samples/xpath_select.cpp" class="bare">samples/xpath_select.cpp</a>):</p> |
3665 </div> | 3690 </div> |
3666 <div class="listingblock"> | 3691 <div class="listingblock"> |
3667 <div class="content"> | 3692 <div class="content"> |
3668 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3693 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"</span><span class="tok-p">);</span> |
3669 | 3694 |
3670 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tools:</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 3695 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Tools:</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
3671 | 3696 |
3672 <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">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">begin</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">end</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span><span class="tok-w"></span> | 3697 <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">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">begin</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-n">it</span><span class="tok-w"> </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">end</span><span class="tok-p">();</span><span class="tok-w"> </span><span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span> |
3673 <span class="tok-p">{</span><span class="tok-w"></span> | 3698 <span class="tok-p">{</span> |
3674 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-o">*</span><span class="tok-n">it</span><span class="tok-p">;</span><span class="tok-w"></span> | 3699 <span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-o">*</span><span class="tok-n">it</span><span class="tok-p">;</span> |
3675 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</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">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span> | 3700 <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"><<</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">.</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">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span> |
3676 <span class="tok-p">}</span><span class="tok-w"></span> | 3701 <span class="tok-p">}</span> |
3677 | 3702 |
3678 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-n">build_tool</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-s">"//Tool[contains(Description, 'build system')]"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3703 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-n">build_tool</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-s">"//Tool[contains(Description, 'build system')]"</span><span class="tok-p">);</span> |
3679 | 3704 |
3680 <span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">build_tool</span><span class="tok-p">)</span><span class="tok-w"></span> | 3705 <span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">build_tool</span><span class="tok-p">)</span> |
3681 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Build tool: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">build_tool</span><span class="tok-p">.</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">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 3706 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Build tool: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">build_tool</span><span class="tok-p">.</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">"Filename"</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-o"><<</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span></code></pre> |
3682 </div> | 3707 </div> |
3683 </div> | 3708 </div> |
3684 </div> | 3709 </div> |
3685 <div class="sect2"> | 3710 <div class="sect2"> |
3686 <h3 id="xpath.query"><a class="anchor" href="#xpath.query"></a><a class="link" href="#xpath.query">8.3. Using query objects</a></h3> | 3711 <h3 id="xpath.query"><a class="anchor" href="#xpath.query"></a><a class="link" href="#xpath.query">8.3. Using query objects</a></h3> |
3706 <div id="xpath_query::ctor" class="paragraph"> | 3731 <div id="xpath_query::ctor" class="paragraph"> |
3707 <p>You can create a query object with the constructor that takes XPath expression as an argument:</p> | 3732 <p>You can create a query object with the constructor that takes XPath expression as an argument:</p> |
3708 </div> | 3733 </div> |
3709 <div class="listingblock"> | 3734 <div class="listingblock"> |
3710 <div class="content"> | 3735 <div class="content"> |
3711 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">explicit</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">xpath_query</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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></code></pre> | 3736 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">explicit</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">xpath_query</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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></code></pre> |
3712 </div> | 3737 </div> |
3713 </div> | 3738 </div> |
3714 <div id="xpath_query::return_type" class="paragraph"> | 3739 <div id="xpath_query::return_type" class="paragraph"> |
3715 <p>The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, <a href="#xpath_exception">xpath_exception</a> is thrown if exception handling is not disabled (see <a href="#xpath.errors">Error handling</a> for details). After the query is created, you can query the type of the evaluation result using the following function:</p> | 3740 <p>The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, <a href="#xpath_exception">xpath_exception</a> is thrown if exception handling is not disabled (see <a href="#xpath.errors">Error handling</a> for details). After the query is created, you can query the type of the evaluation result using the following function:</p> |
3716 </div> | 3741 </div> |
3717 <div class="listingblock"> | 3742 <div class="listingblock"> |
3718 <div class="content"> | 3743 <div class="content"> |
3719 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::return_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> | 3744 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::return_type</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3720 </div> | 3745 </div> |
3721 </div> | 3746 </div> |
3722 <div class="paragraph"> | 3747 <div class="paragraph"> |
3723 <p><a id="xpath_query::evaluate_boolean"></a><a id="xpath_query::evaluate_number"></a><a id="xpath_query::evaluate_string"></a><a id="xpath_query::evaluate_node_set"></a><a id="xpath_query::evaluate_node"></a> | 3748 <p><a id="xpath_query::evaluate_boolean"></a><a id="xpath_query::evaluate_number"></a><a id="xpath_query::evaluate_string"></a><a id="xpath_query::evaluate_node_set"></a><a id="xpath_query::evaluate_node"></a> |
3724 You can evaluate the query using one of the following functions:</p> | 3749 You can evaluate the query using one of the following functions:</p> |
3725 </div> | 3750 </div> |
3726 <div class="listingblock"> | 3751 <div class="listingblock"> |
3727 <div class="content"> | 3752 <div class="content"> |
3728 <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">xpath_query::evaluate_boolean</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 3753 <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">xpath_query::evaluate_boolean</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3729 <span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_number</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 3754 <span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_number</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3730 <span class="tok-n">string_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_string</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 3755 <span class="tok-n">string_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_string</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3731 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_node_set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 3756 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_node_set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3732 <span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_node</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 3757 <span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_node</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3733 </div> | 3758 </div> |
3734 </div> | 3759 </div> |
3735 <div class="paragraph"> | 3760 <div class="paragraph"> |
3736 <p>All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, <code>evaluate_boolean</code>, <code>evaluate_number</code> and <code>evaluate_string</code> always return a result, but <code>evaluate_node_set</code> and <code>evaluate_node</code> result in an error if the return type is not node set (see <a href="#xpath.errors">Error handling</a>).</p> | 3761 <p>All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, <code>evaluate_boolean</code>, <code>evaluate_number</code> and <code>evaluate_string</code> always return a result, but <code>evaluate_node_set</code> and <code>evaluate_node</code> result in an error if the return type is not node set (see <a href="#xpath.errors">Error handling</a>).</p> |
3737 </div> | 3762 </div> |
3750 <div id="xpath_query::evaluate_string_buffer" class="paragraph"> | 3775 <div id="xpath_query::evaluate_string_buffer" class="paragraph"> |
3751 <p>Note that <code>evaluate_string</code> function returns the STL string; as such, it’s not available in <a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a> mode and also usually allocates memory. There is another string evaluation function:</p> | 3776 <p>Note that <code>evaluate_string</code> function returns the STL string; as such, it’s not available in <a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a> mode and also usually allocates memory. There is another string evaluation function:</p> |
3752 </div> | 3777 </div> |
3753 <div class="listingblock"> | 3778 <div class="listingblock"> |
3754 <div class="content"> | 3779 <div class="content"> |
3755 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_string</span><span class="tok-p">(</span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</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">capacity</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-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 3780 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::evaluate_string</span><span class="tok-p">(</span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</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">capacity</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-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3756 </div> | 3781 </div> |
3757 </div> | 3782 </div> |
3758 <div class="paragraph"> | 3783 <div class="paragraph"> |
3759 <p>This function evaluates the string, and then writes the result to <code>buffer</code> (but at most <code>capacity</code> characters); then it returns the full size of the result in characters, including the terminating zero. If <code>capacity</code> is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:</p> | 3784 <p>This function evaluates the string, and then writes the result to <code>buffer</code> (but at most <code>capacity</code> characters); then it returns the full size of the result in characters, including the terminating zero. If <code>capacity</code> is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:</p> |
3760 </div> | 3785 </div> |
3772 <p>This is an example of using query objects (<a href="samples/xpath_query.cpp" class="bare">samples/xpath_query.cpp</a>):</p> | 3797 <p>This is an example of using query objects (<a href="samples/xpath_query.cpp" class="bare">samples/xpath_query.cpp</a>):</p> |
3773 </div> | 3798 </div> |
3774 <div class="listingblock"> | 3799 <div class="listingblock"> |
3775 <div class="content"> | 3800 <div class="content"> |
3776 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Select nodes via compiled query</span> | 3801 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Select nodes via compiled query</span> |
3777 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-nf">query_remote_tools</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote='true']"</span><span class="tok-p">);</span><span class="tok-w"></span> | 3802 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote='true']"</span><span class="tok-p">);</span> |
3778 | 3803 |
3779 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span><span class="tok-w"></span> | 3804 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span> |
3780 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Remote tool: "</span><span class="tok-p">;</span><span class="tok-w"></span> | 3805 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Remote tool: "</span><span class="tok-p">;</span> |
3781 <span class="tok-n">tools</span><span class="tok-p">[</span><span class="tok-mi">2</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span> | 3806 <span class="tok-n">tools</span><span class="tok-p">[</span><span class="tok-mi">2</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span> |
3782 | 3807 |
3783 <span class="tok-c1">// Evaluate numbers via compiled query</span> | 3808 <span class="tok-c1">// Evaluate numbers via compiled query</span> |
3784 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-nf">query_timeouts</span><span class="tok-p">(</span><span class="tok-s">"sum(//Tool/@Timeout)")</span><span class="tok-p">;</span><span class="tok-w"></span> | 3809 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-n">query_timeouts</span><span class="tok-p">(</span><span class="tok-s">"sum(//Tool/@Timeout)"</span><span class="tok-p">);</span> |
3785 <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"><<</span><span class="tok-w"> </span><span class="tok-n">query_timeouts</span><span class="tok-p">.</span><span class="tok-n">evaluate_number</span><span class="tok-p">(</span><span class="tok-n">doc</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3810 <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"><<</span><span class="tok-w"> </span><span class="tok-n">query_timeouts</span><span class="tok-p">.</span><span class="tok-n">evaluate_number</span><span class="tok-p">(</span><span class="tok-n">doc</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3786 | 3811 |
3787 <span class="tok-c1">// Evaluate strings via compiled query for different context nodes</span> | 3812 <span class="tok-c1">// Evaluate strings via compiled query for different context nodes</span> |
3788 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-nf">query_name_valid</span><span class="tok-p">(</span><span class="tok-s">"string-length(substring-before(@Filename, '_')</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-w"> </span><span class="tok-n">and</span><span class="tok-w"> </span><span class="tok-err">@</span><span class="tok-n">OutputFileMasks</span><span class="tok-s">")</span><span class="tok-p">;</span><span class="tok-w"></span> | 3813 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-n">query_name_valid</span><span class="tok-p">(</span><span class="tok-s">"string-length(substring-before(@Filename, '_')) > 0 and @OutputFileMasks"</span><span class="tok-p">);</span> |
3789 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-nf">query_name</span><span class="tok-p">(</span><span class="tok-s">"concat(substring-before(@Filename, '_')</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-err">'</span><span class="tok-w"> </span><span class="tok-n">produces</span><span class="tok-w"> </span><span class="tok-err">'</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-err">@</span><span class="tok-n">OutputFileMasks</span><span class="tok-p">)</span><span class="tok-s">")</span><span class="tok-p">;</span><span class="tok-w"></span> | 3814 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-n">query_name</span><span class="tok-p">(</span><span class="tok-s">"concat(substring-before(@Filename, '_'), ' produces ', @OutputFileMasks)"</span><span class="tok-p">);</span> |
3790 | 3815 |
3791 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_element_by_path</span><span class="tok-p">(</span><span class="tok-s">"Profile/Tools/Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">())</span><span class="tok-w"></span> | 3816 <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-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_element_by_path</span><span class="tok-p">(</span><span class="tok-s">"Profile/Tools/Tool"</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><span class="tok-n">tool</span><span class="tok-w"> </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">next_sibling</span><span class="tok-p">())</span> |
3792 <span class="tok-p">{</span><span class="tok-w"></span> | 3817 <span class="tok-p">{</span> |
3793 <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">s</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_name</span><span class="tok-p">.</span><span class="tok-n">evaluate_string</span><span class="tok-p">(</span><span class="tok-n">tool</span><span class="tok-p">);</span><span class="tok-w"></span> | 3818 <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">s</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_name</span><span class="tok-p">.</span><span class="tok-n">evaluate_string</span><span class="tok-p">(</span><span class="tok-n">tool</span><span class="tok-p">);</span> |
3794 | 3819 |
3795 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">query_name_valid</span><span class="tok-p">.</span><span class="tok-n">evaluate_boolean</span><span class="tok-p">(</span><span class="tok-n">tool</span><span class="tok-p">))</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"><<</span><span class="tok-w"> </span><span class="tok-n">s</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 3820 <span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">query_name_valid</span><span class="tok-p">.</span><span class="tok-n">evaluate_boolean</span><span class="tok-p">(</span><span class="tok-n">tool</span><span class="tok-p">))</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"><<</span><span class="tok-w"> </span><span class="tok-n">s</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
3796 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 3821 <span class="tok-p">}</span></code></pre> |
3797 </div> | 3822 </div> |
3798 </div> | 3823 </div> |
3799 </div> | 3824 </div> |
3800 <div class="sect2"> | 3825 <div class="sect2"> |
3801 <h3 id="xpath.variables"><a class="anchor" href="#xpath.variables"></a><a class="link" href="#xpath.variables">8.4. Using variables</a></h3> | 3826 <h3 id="xpath.variables"><a class="anchor" href="#xpath.variables"></a><a class="link" href="#xpath.variables">8.4. Using variables</a></h3> |
3805 <div class="paragraph"> | 3830 <div class="paragraph"> |
3806 <p>Variable references have the form <code>$name</code>; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to <code>xpath_query</code> constructor or to <code>select_nodes</code>/<code>select_node</code> functions:</p> | 3831 <p>Variable references have the form <code>$name</code>; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to <code>xpath_query</code> constructor or to <code>select_nodes</code>/<code>select_node</code> functions:</p> |
3807 </div> | 3832 </div> |
3808 <div class="listingblock"> | 3833 <div class="listingblock"> |
3809 <div class="content"> | 3834 <div class="content"> |
3810 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">explicit</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">xpath_query</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 3835 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">explicit</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">xpath_query</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> |
3811 <span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_node</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 3836 <span class="tok-n">xpath_node</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_node</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> |
3812 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_nodes</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 3837 <span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-nf">xml_node::select_nodes</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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></code></pre> |
3813 </div> | 3838 </div> |
3814 </div> | 3839 </div> |
3815 <div class="paragraph"> | 3840 <div class="paragraph"> |
3816 <p>If you’re using query objects, you can change the variable values before <code>evaluate</code>/<code>select</code> calls to change the query behavior.</p> | 3841 <p>If you’re using query objects, you can change the variable values before <code>evaluate</code>/<code>select</code> calls to change the query behavior.</p> |
3817 </div> | 3842 </div> |
3833 <div id="xpath_variable_set::add" class="paragraph"> | 3858 <div id="xpath_variable_set::add" class="paragraph"> |
3834 <p>You can add new variables with the following function:</p> | 3859 <p>You can add new variables with the following function:</p> |
3835 </div> | 3860 </div> |
3836 <div class="listingblock"> | 3861 <div class="listingblock"> |
3837 <div class="content"> | 3862 <div class="content"> |
3838 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::add</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">name</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3863 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::add</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">name</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-p">);</span></code></pre> |
3839 </div> | 3864 </div> |
3840 </div> | 3865 </div> |
3841 <div class="paragraph"> | 3866 <div class="paragraph"> |
3842 <p>The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure.</p> | 3867 <p>The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure.</p> |
3843 </div> | 3868 </div> |
3847 <div id="xpath_variable_set::get" class="paragraph"> | 3872 <div id="xpath_variable_set::get" class="paragraph"> |
3848 <p>You can get the existing variables with the following functions:</p> | 3873 <p>You can get the existing variables with the following functions:</p> |
3849 </div> | 3874 </div> |
3850 <div class="listingblock"> | 3875 <div class="listingblock"> |
3851 <div class="content"> | 3876 <div class="content"> |
3852 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::get</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">name</span><span class="tok-p">);</span><span class="tok-w"></span> | 3877 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::get</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">name</span><span class="tok-p">);</span> |
3853 <span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::get</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">name</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> | 3878 <span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::get</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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3854 </div> | 3879 </div> |
3855 </div> | 3880 </div> |
3856 <div class="paragraph"> | 3881 <div class="paragraph"> |
3857 <p>The functions return the variable handle, or null pointer if the variable with the specified name is not found.</p> | 3882 <p>The functions return the variable handle, or null pointer if the variable with the specified name is not found.</p> |
3858 </div> | 3883 </div> |
3859 <div id="xpath_variable_set::set" class="paragraph"> | 3884 <div id="xpath_variable_set::set" class="paragraph"> |
3860 <p>Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return <code>false</code>; they also return <code>false</code> on allocation failure. Note that these functions do not perform any type conversions.</p> | 3885 <p>Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return <code>false</code>; they also return <code>false</code> on allocation failure. Note that these functions do not perform any type conversions.</p> |
3861 </div> | 3886 </div> |
3862 <div class="listingblock"> | 3887 <div class="listingblock"> |
3863 <div class="content"> | 3888 <div class="content"> |
3864 <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">xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 3889 <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">xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span> |
3865 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 3890 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span> |
3866 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::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">name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 3891 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::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">name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> |
3867 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::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">name</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-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3892 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable_set::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">name</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-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span></code></pre> |
3868 </div> | 3893 </div> |
3869 </div> | 3894 </div> |
3870 <div class="paragraph"> | 3895 <div class="paragraph"> |
3871 <p>The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.</p> | 3896 <p>The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.</p> |
3872 </div> | 3897 </div> |
3877 <p><a id="xpath_variable::type"></a><a id="xpath_variable::name"></a> | 3902 <p><a id="xpath_variable::type"></a><a id="xpath_variable::name"></a> |
3878 In order to get variable information, you can use one of the following functions:</p> | 3903 In order to get variable information, you can use one of the following functions:</p> |
3879 </div> | 3904 </div> |
3880 <div class="listingblock"> | 3905 <div class="listingblock"> |
3881 <div class="content"> | 3906 <div class="content"> |
3882 <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">xpath_variable::name</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> | 3907 <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">xpath_variable::name</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3883 <span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::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> | 3908 <span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::type</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3884 </div> | 3909 </div> |
3885 </div> | 3910 </div> |
3886 <div class="paragraph"> | 3911 <div class="paragraph"> |
3887 <p>Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.</p> | 3912 <p>Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.</p> |
3888 </div> | 3913 </div> |
3890 <p><a id="xpath_variable::get_boolean"></a><a id="xpath_variable::get_number"></a><a id="xpath_variable::get_string"></a><a id="xpath_variable::get_node_set"></a> | 3915 <p><a id="xpath_variable::get_boolean"></a><a id="xpath_variable::get_number"></a><a id="xpath_variable::get_string"></a><a id="xpath_variable::get_node_set"></a> |
3891 In order to get variable value, you should use one of the following functions, depending on the variable type:</p> | 3916 In order to get variable value, you should use one of the following functions, depending on the variable type:</p> |
3892 </div> | 3917 </div> |
3893 <div class="listingblock"> | 3918 <div class="listingblock"> |
3894 <div class="content"> | 3919 <div class="content"> |
3895 <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">xpath_variable::get_boolean</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> | 3920 <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">xpath_variable::get_boolean</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3896 <span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::get_number</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> | 3921 <span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::get_number</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3897 <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">xpath_variable::get_string</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> | 3922 <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">xpath_variable::get_string</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3898 <span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::get_node_set</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> | 3923 <span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::get_node_set</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3899 </div> | 3924 </div> |
3900 </div> | 3925 </div> |
3901 <div class="paragraph"> | 3926 <div class="paragraph"> |
3902 <p>These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (<code>false</code> for booleans, <code>NaN</code> for numbers, empty string for strings and empty set for node sets).</p> | 3927 <p>These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (<code>false</code> for booleans, <code>NaN</code> for numbers, empty string for strings and empty set for node sets).</p> |
3903 </div> | 3928 </div> |
3904 <div id="xpath_variable::set" class="paragraph"> | 3929 <div id="xpath_variable::set" class="paragraph"> |
3905 <p>In order to set variable value, you should use one of the following functions, depending on the variable type:</p> | 3930 <p>In order to set variable value, you should use one of the following functions, depending on the variable type:</p> |
3906 </div> | 3931 </div> |
3907 <div class="listingblock"> | 3932 <div class="listingblock"> |
3908 <div class="content"> | 3933 <div class="content"> |
3909 <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">xpath_variable::set</span><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 3934 <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">xpath_variable::set</span><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> |
3910 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::set</span><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 3935 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::set</span><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> |
3911 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::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">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 3936 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::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">value</span><span class="tok-p">);</span> |
3912 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3937 <span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-nf">xpath_variable::set</span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span></code></pre> |
3913 </div> | 3938 </div> |
3914 </div> | 3939 </div> |
3915 <div class="paragraph"> | 3940 <div class="paragraph"> |
3916 <p>These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return <code>false</code>; they also return <code>false</code> on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.</p> | 3941 <p>These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return <code>false</code>; they also return <code>false</code> on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.</p> |
3917 </div> | 3942 </div> |
3919 <p>This is an example of using variables in XPath queries (<a href="samples/xpath_variables.cpp" class="bare">samples/xpath_variables.cpp</a>):</p> | 3944 <p>This is an example of using variables in XPath queries (<a href="samples/xpath_variables.cpp" class="bare">samples/xpath_variables.cpp</a>):</p> |
3920 </div> | 3945 </div> |
3921 <div class="listingblock"> | 3946 <div class="listingblock"> |
3922 <div class="content"> | 3947 <div class="content"> |
3923 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Select nodes via compiled query</span> | 3948 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Select nodes via compiled query</span> |
3924 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_variable_set</span><span class="tok-w"> </span><span class="tok-n">vars</span><span class="tok-p">;</span><span class="tok-w"></span> | 3949 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_variable_set</span><span class="tok-w"> </span><span class="tok-n">vars</span><span class="tok-p">;</span> |
3925 <span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">add</span><span class="tok-p">(</span><span class="tok-s">"remote"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_type_boolean</span><span class="tok-p">);</span><span class="tok-w"></span> | 3950 <span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">add</span><span class="tok-p">(</span><span class="tok-s">"remote"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_type_boolean</span><span class="tok-p">);</span> |
3926 | 3951 |
3927 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-nf">query_remote_tools</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote = string($remote)</span><span class="tok-p">]</span><span class="tok-s">", &vars)</span><span class="tok-p">;</span><span class="tok-w"></span> | 3952 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-n">vars</span><span class="tok-p">);</span> |
3928 | 3953 |
3929 <span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">"remote"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">);</span><span class="tok-w"></span> | 3954 <span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">"remote"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-nb">true</span><span class="tok-p">);</span> |
3930 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools_remote</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span><span class="tok-w"></span> | 3955 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools_remote</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span> |
3931 | 3956 |
3932 <span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">"remote"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">);</span><span class="tok-w"></span> | 3957 <span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">"remote"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-nb">false</span><span class="tok-p">);</span> |
3933 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools_local</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span><span class="tok-w"></span> | 3958 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools_local</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span> |
3934 | 3959 |
3935 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Remote tool: "</span><span class="tok-p">;</span><span class="tok-w"></span> | 3960 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Remote tool: "</span><span class="tok-p">;</span> |
3936 <span class="tok-n">tools_remote</span><span class="tok-p">[</span><span class="tok-mi">2</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span> | 3961 <span class="tok-n">tools_remote</span><span class="tok-p">[</span><span class="tok-mi">2</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span> |
3937 | 3962 |
3938 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Local tool: "</span><span class="tok-p">;</span><span class="tok-w"></span> | 3963 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Local tool: "</span><span class="tok-p">;</span> |
3939 <span class="tok-n">tools_local</span><span class="tok-p">[</span><span class="tok-mi">0</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span> | 3964 <span class="tok-n">tools_local</span><span class="tok-p">[</span><span class="tok-mi">0</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span> |
3940 | 3965 |
3941 <span class="tok-c1">// You can pass the context directly to select_nodes/select_node</span> | 3966 <span class="tok-c1">// You can pass the context directly to select_nodes/select_node</span> |
3942 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools_local_imm</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-n">vars</span><span class="tok-p">);</span><span class="tok-w"></span> | 3967 <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><span class="tok-n">tools_local_imm</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-o">&</span><span class="tok-n">vars</span><span class="tok-p">);</span> |
3943 | 3968 |
3944 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Local tool imm: "</span><span class="tok-p">;</span><span class="tok-w"></span> | 3969 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Local tool imm: "</span><span class="tok-p">;</span> |
3945 <span class="tok-n">tools_local_imm</span><span class="tok-p">[</span><span class="tok-mi">0</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 3970 <span class="tok-n">tools_local_imm</span><span class="tok-p">[</span><span class="tok-mi">0</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span></code></pre> |
3946 </div> | 3971 </div> |
3947 </div> | 3972 </div> |
3948 </div> | 3973 </div> |
3949 <div class="sect2"> | 3974 <div class="sect2"> |
3950 <h3 id="xpath.errors"><a class="anchor" href="#xpath.errors"></a><a class="link" href="#xpath.errors">8.5. Error handling</a></h3> | 3975 <h3 id="xpath.errors"><a class="anchor" href="#xpath.errors"></a><a class="link" href="#xpath.errors">8.5. Error handling</a></h3> |
3955 <p><a id="xpath_exception"></a><a id="xpath_exception::result"></a><a id="xpath_exception::what"></a> | 3980 <p><a id="xpath_exception"></a><a id="xpath_exception::result"></a><a id="xpath_exception::what"></a> |
3956 By default, XPath functions throw <code>xpath_exception</code> object in case of errors; additionally, in the event any memory allocation fails, an <code>std::bad_alloc</code> exception is thrown. Also <code>xpath_exception</code> is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions:</p> | 3981 By default, XPath functions throw <code>xpath_exception</code> object in case of errors; additionally, in the event any memory allocation fails, an <code>std::bad_alloc</code> exception is thrown. Also <code>xpath_exception</code> is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions:</p> |
3957 </div> | 3982 </div> |
3958 <div class="listingblock"> | 3983 <div class="listingblock"> |
3959 <div class="content"> | 3984 <div class="content"> |
3960 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">virtual</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-nf">xpath_exception::what</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-k">throw</span><span class="tok-p">();</span><span class="tok-w"></span> | 3985 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">virtual</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-nf">xpath_exception::what</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-k">throw</span><span class="tok-p">();</span> |
3961 <span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-nf">xpath_exception::result</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> | 3986 <span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-nf">xpath_exception::result</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3962 </div> | 3987 </div> |
3963 </div> | 3988 </div> |
3964 <div class="paragraph"> | 3989 <div class="paragraph"> |
3965 <p><a id="xpath_query::unspecified_bool_type"></a><a id="xpath_query::result"></a> | 3990 <p><a id="xpath_query::unspecified_bool_type"></a><a id="xpath_query::result"></a> |
3966 If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: <code>if (query) { …​ }</code>. Additionally, you can get parsing result via the result() accessor:</p> | 3991 If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: <code>if (query) { …​ }</code>. Additionally, you can get parsing result via the result() accessor:</p> |
3967 </div> | 3992 </div> |
3968 <div class="listingblock"> | 3993 <div class="listingblock"> |
3969 <div class="content"> | 3994 <div class="content"> |
3970 <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">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::result</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> | 3995 <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">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-nf">xpath_query::result</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span></code></pre> |
3971 </div> | 3996 </div> |
3972 </div> | 3997 </div> |
3973 <div class="paragraph"> | 3998 <div class="paragraph"> |
3974 <p>Without exceptions, evaluating invalid query results in <code>false</code>, empty string, <code>NaN</code> or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.</p> | 3999 <p>Without exceptions, evaluating invalid query results in <code>false</code>, empty string, <code>NaN</code> or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.</p> |
3975 </div> | 4000 </div> |
3976 <div id="xpath_parse_result" class="paragraph"> | 4001 <div id="xpath_parse_result" class="paragraph"> |
3977 <p>The information about parsing result is returned via <code>xpath_parse_result</code> object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:</p> | 4002 <p>The information about parsing result is returned via <code>xpath_parse_result</code> object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:</p> |
3978 </div> | 4003 </div> |
3979 <div class="listingblock"> | 4004 <div class="listingblock"> |
3980 <div class="content"> | 4005 <div class="content"> |
3981 <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> | 4006 <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> |
3982 <span class="tok-p">{</span><span class="tok-w"></span> | 4007 <span class="tok-p">{</span> |
3983 <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> | 4008 <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> |
3984 <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> | 4009 <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> |
3985 | 4010 |
3986 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><span class="tok-kt">bool</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> | 4011 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3987 <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-nf">description</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> | 4012 <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-nf">description</span><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
3988 <span class="tok-p">};</span><span class="tok-w"></span></code></pre> | 4013 <span class="tok-p">};</span></code></pre> |
3989 </div> | 4014 </div> |
3990 </div> | 4015 </div> |
3991 <div id="xpath_parse_result::error" class="paragraph"> | 4016 <div id="xpath_parse_result::error" class="paragraph"> |
3992 <p>Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string.</p> | 4017 <p>Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string.</p> |
3993 </div> | 4018 </div> |
4004 <p>This is an example of XPath error handling (<a href="samples/xpath_error.cpp" class="bare">samples/xpath_error.cpp</a>):</p> | 4029 <p>This is an example of XPath error handling (<a href="samples/xpath_error.cpp" class="bare">samples/xpath_error.cpp</a>):</p> |
4005 </div> | 4030 </div> |
4006 <div class="listingblock"> | 4031 <div class="listingblock"> |
4007 <div class="content"> | 4032 <div class="content"> |
4008 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Exception is thrown for incorrect query syntax</span> | 4033 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Exception is thrown for incorrect query syntax</span> |
4009 <span class="tok-k">try</span><span class="tok-w"></span> | 4034 <span class="tok-k">try</span> |
4010 <span class="tok-p">{</span><span class="tok-w"></span> | 4035 <span class="tok-p">{</span> |
4011 <span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"//nodes[#true()]"</span><span class="tok-p">);</span><span class="tok-w"></span> | 4036 <span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"//nodes[#true()]"</span><span class="tok-p">);</span> |
4012 <span class="tok-p">}</span><span class="tok-w"></span> | 4037 <span class="tok-p">}</span> |
4013 <span class="tok-k">catch</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">)</span><span class="tok-w"></span> | 4038 <span class="tok-k">catch</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">)</span> |
4014 <span class="tok-p">{</span><span class="tok-w"></span> | 4039 <span class="tok-p">{</span> |
4015 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Select failed: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 4040 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Select failed: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
4016 <span class="tok-p">}</span><span class="tok-w"></span> | 4041 <span class="tok-p">}</span> |
4017 | 4042 |
4018 <span class="tok-c1">// Exception is thrown for incorrect query semantics</span> | 4043 <span class="tok-c1">// Exception is thrown for incorrect query semantics</span> |
4019 <span class="tok-k">try</span><span class="tok-w"></span> | 4044 <span class="tok-k">try</span> |
4020 <span class="tok-p">{</span><span class="tok-w"></span> | 4045 <span class="tok-p">{</span> |
4021 <span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"(123)/next"</span><span class="tok-p">);</span><span class="tok-w"></span> | 4046 <span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"(123)/next"</span><span class="tok-p">);</span> |
4022 <span class="tok-p">}</span><span class="tok-w"></span> | 4047 <span class="tok-p">}</span> |
4023 <span class="tok-k">catch</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">)</span><span class="tok-w"></span> | 4048 <span class="tok-k">catch</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">)</span> |
4024 <span class="tok-p">{</span><span class="tok-w"></span> | 4049 <span class="tok-p">{</span> |
4025 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Select failed: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 4050 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Select failed: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
4026 <span class="tok-p">}</span><span class="tok-w"></span> | 4051 <span class="tok-p">}</span> |
4027 | 4052 |
4028 <span class="tok-c1">// Exception is thrown for query with incorrect return type</span> | 4053 <span class="tok-c1">// Exception is thrown for query with incorrect return type</span> |
4029 <span class="tok-k">try</span><span class="tok-w"></span> | 4054 <span class="tok-k">try</span> |
4030 <span class="tok-p">{</span><span class="tok-w"></span> | 4055 <span class="tok-p">{</span> |
4031 <span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"123"</span><span class="tok-p">);</span><span class="tok-w"></span> | 4056 <span class="tok-w"> </span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">"123"</span><span class="tok-p">);</span> |
4032 <span class="tok-p">}</span><span class="tok-w"></span> | 4057 <span class="tok-p">}</span> |
4033 <span class="tok-k">catch</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">)</span><span class="tok-w"></span> | 4058 <span class="tok-k">catch</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">)</span> |
4034 <span class="tok-p">{</span><span class="tok-w"></span> | 4059 <span class="tok-p">{</span> |
4035 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Select failed: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span><span class="tok-w"></span> | 4060 <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"><<</span><span class="tok-w"> </span><span class="tok-s">"Select failed: "</span><span class="tok-w"> </span><span class="tok-o"><<</span><span class="tok-w"> </span><span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</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">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span> |
4036 <span class="tok-p">}</span><span class="tok-w"></span></code></pre> | 4061 <span class="tok-p">}</span></code></pre> |
4037 </div> | 4062 </div> |
4038 </div> | 4063 </div> |
4039 </div> | 4064 </div> |
4040 <div class="sect2"> | 4065 <div class="sect2"> |
4041 <h3 id="xpath.w3c"><a class="anchor" href="#xpath.w3c"></a><a class="link" href="#xpath.w3c">8.6. Conformance to W3C specification</a></h3> | 4066 <h3 id="xpath.w3c"><a class="anchor" href="#xpath.w3c"></a><a class="link" href="#xpath.w3c">8.6. Conformance to W3C specification</a></h3> |
4065 </div> | 4090 </div> |
4066 </div> | 4091 </div> |
4067 <div class="sect1"> | 4092 <div class="sect1"> |
4068 <h2 id="changes"><a class="anchor" href="#changes"></a><a class="link" href="#changes">9. Changelog</a></h2> | 4093 <h2 id="changes"><a class="anchor" href="#changes"></a><a class="link" href="#changes">9. Changelog</a></h2> |
4069 <div class="sectionbody"> | 4094 <div class="sectionbody"> |
4095 <div class="sect2"> | |
4096 <h3 id="v1.14"><a class="anchor" href="#v1.14"></a><a class="link" href="#v1.14">v1.14 <sup>2023-10-01</sup></a></h3> | |
4097 <div class="paragraph"> | |
4098 <p>Maintenance release. Changes:</p> | |
4099 </div> | |
4100 <div class="ulist"> | |
4101 <ul> | |
4102 <li> | |
4103 <p>Improvements:</p> | |
4104 <div class="olist arabic"> | |
4105 <ol class="arabic"> | |
4106 <li> | |
4107 <p><code>xml_attribute::set_name</code> and <code>xml_node::set_name</code> now have overloads that accept pointer to non-null-terminated string and size</p> | |
4108 </li> | |
4109 <li> | |
4110 <p>Implement <code>parse_merge_pcdata</code> parsing mode in which PCDATA contents is merged into a single node when original document had comments that were skipped during parsing</p> | |
4111 </li> | |
4112 <li> | |
4113 <p><code>xml_document::load_file</code> now returns a more consistent error status when given a path to a folder</p> | |
4114 </li> | |
4115 </ol> | |
4116 </div> | |
4117 </li> | |
4118 <li> | |
4119 <p>Bug fixes:</p> | |
4120 <div class="olist arabic"> | |
4121 <ol class="arabic"> | |
4122 <li> | |
4123 <p>Fix assertion in XPath number→string conversion when using non-English locales</p> | |
4124 </li> | |
4125 <li> | |
4126 <p>Fix PUGIXML_STATIC_CRT CMake option to correctly select static CRT when using MSVC and recent CMake</p> | |
4127 </li> | |
4128 </ol> | |
4129 </div> | |
4130 </li> | |
4131 <li> | |
4132 <p>Compatibility improvements:</p> | |
4133 <div class="olist arabic"> | |
4134 <ol class="arabic"> | |
4135 <li> | |
4136 <p>Fix GCC 2.95/3.3 builds</p> | |
4137 </li> | |
4138 <li> | |
4139 <p>Fix CMake 3.27 deprecation warnings</p> | |
4140 </li> | |
4141 <li> | |
4142 <p>Fix XCode 14 sprintf deprecation warning when compiling in C++03 mode</p> | |
4143 </li> | |
4144 <li> | |
4145 <p>Fix clang/gcc warnings <code>-Wweak-vtables</code>, <code>-Wreserved-macro-identifier</code></p> | |
4146 </li> | |
4147 </ol> | |
4148 </div> | |
4149 </li> | |
4150 </ul> | |
4151 </div> | |
4152 </div> | |
4070 <div class="sect2"> | 4153 <div class="sect2"> |
4071 <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> | 4154 <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> |
4072 <div class="paragraph"> | 4155 <div class="paragraph"> |
4073 <p>Maintenance release. Changes:</p> | 4156 <p>Maintenance release. Changes:</p> |
4074 </div> | 4157 </div> |
5584 </div> | 5667 </div> |
5585 <div class="sect2"> | 5668 <div class="sect2"> |
5586 <h3 id="apiref.types"><a class="anchor" href="#apiref.types"></a><a class="link" href="#apiref.types">10.2. Types</a></h3> | 5669 <h3 id="apiref.types"><a class="anchor" href="#apiref.types"></a><a class="link" href="#apiref.types">10.2. Types</a></h3> |
5587 <div class="listingblock"> | 5670 <div class="listingblock"> |
5588 <div class="content"> | 5671 <div class="content"> |
5589 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">configuration</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#char_t">char_t</a><span class="tok-p">;</span><span class="tok-w"></span> | 5672 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">configuration</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#char_t">char_t</a><span class="tok-p">;</span> |
5590 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">configuration</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#string_t">string_t</a><span class="tok-p">;</span><span class="tok-w"></span> | 5673 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">configuration</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#string_t">string_t</a><span class="tok-p">;</span> |
5591 <span class="tok-k">typedef</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-p">(</span><span class="tok-o">*</span><a href="#allocation_function">allocation_function</a><span class="tok-p">)(</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> | 5674 <span class="tok-k">typedef</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-p">(</span><span class="tok-o">*</span><a href="#allocation_function">allocation_function</a><span class="tok-p">)(</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
5592 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">*</span><a href="#deallocation_function">deallocation_function</a><span class="tok-p">)(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">ptr</span><span class="tok-p">);</span><span class="tok-w"></span></code></pre> | 5675 <span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">*</span><a href="#deallocation_function">deallocation_function</a><span class="tok-p">)(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">ptr</span><span class="tok-p">);</span></code></pre> |
5593 </div> | 5676 </div> |
5594 </div> | 5677 </div> |
5595 </div> | 5678 </div> |
5596 <div class="sect2"> | 5679 <div class="sect2"> |
5597 <h3 id="apiref.enums"><a class="anchor" href="#apiref.enums"></a><a class="link" href="#apiref.enums">10.3. Enumerations</a></h3> | 5680 <h3 id="apiref.enums"><a class="anchor" href="#apiref.enums"></a><a class="link" href="#apiref.enums">10.3. Enumerations</a></h3> |
5598 <div class="listingblock"> | 5681 <div class="listingblock"> |
5599 <div class="content"> | 5682 <div class="content"> |
5600 <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> | 5683 <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> |
5601 <span class="tok-w"> </span><a href="#node_null">node_null</a><span class="tok-w"></span> | 5684 <span class="tok-w"> </span><a href="#node_null">node_null</a> |
5602 <span class="tok-w"> </span><a href="#node_document">node_document</a><span class="tok-w"></span> | 5685 <span class="tok-w"> </span><a href="#node_document">node_document</a> |
5603 <span class="tok-w"> </span><a href="#node_element">node_element</a><span class="tok-w"></span> | 5686 <span class="tok-w"> </span><a href="#node_element">node_element</a> |
5604 <span class="tok-w"> </span><a href="#node_pcdata">node_pcdata</a><span class="tok-w"></span> | 5687 <span class="tok-w"> </span><a href="#node_pcdata">node_pcdata</a> |
5605 <span class="tok-w"> </span><a href="#node_cdata">node_cdata</a><span class="tok-w"></span> | 5688 <span class="tok-w"> </span><a href="#node_cdata">node_cdata</a> |
5606 <span class="tok-w"> </span><a href="#node_comment">node_comment</a><span class="tok-w"></span> | 5689 <span class="tok-w"> </span><a href="#node_comment">node_comment</a> |
5607 <span class="tok-w"> </span><a href="#node_pi">node_pi</a><span class="tok-w"></span> | 5690 <span class="tok-w"> </span><a href="#node_pi">node_pi</a> |
5608 <span class="tok-w"> </span><a href="#node_declaration">node_declaration</a><span class="tok-w"></span> | 5691 <span class="tok-w"> </span><a href="#node_declaration">node_declaration</a> |
5609 <span class="tok-w"> </span><a href="#node_doctype">node_doctype</a><span class="tok-w"></span> | 5692 <span class="tok-w"> </span><a href="#node_doctype">node_doctype</a> |
5610 | 5693 |
5611 <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> | 5694 <span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xml_parse_status">xml_parse_status</a> |
5612 <span class="tok-w"> </span><a href="#status_ok">status_ok</a><span class="tok-w"></span> | 5695 <span class="tok-w"> </span><a href="#status_ok">status_ok</a> |
5613 <span class="tok-w"> </span><a href="#status_file_not_found">status_file_not_found</a><span class="tok-w"></span> | 5696 <span class="tok-w"> </span><a href="#status_file_not_found">status_file_not_found</a> |
5614 <span class="tok-w"> </span><a href="#status_io_error">status_io_error</a><span class="tok-w"></span> | 5697 <span class="tok-w"> </span><a href="#status_io_error">status_io_error</a> |
5615 <span class="tok-w"> </span><a href="#status_out_of_memory">status_out_of_memory</a><span class="tok-w"></span> | 5698 <span class="tok-w"> </span><a href="#status_out_of_memory">status_out_of_memory</a> |
5616 <span class="tok-w"> </span><a href="#status_internal_error">status_internal_error</a><span class="tok-w"></span> | 5699 <span class="tok-w"> </span><a href="#status_internal_error">status_internal_error</a> |
5617 <span class="tok-w"> </span><a href="#status_unrecognized_tag">status_unrecognized_tag</a><span class="tok-w"></span> | 5700 <span class="tok-w"> </span><a href="#status_unrecognized_tag">status_unrecognized_tag</a> |
5618 <span class="tok-w"> </span><a href="#status_bad_pi">status_bad_pi</a><span class="tok-w"></span> | 5701 <span class="tok-w"> </span><a href="#status_bad_pi">status_bad_pi</a> |
5619 <span class="tok-w"> </span><a href="#status_bad_comment">status_bad_comment</a><span class="tok-w"></span> | 5702 <span class="tok-w"> </span><a href="#status_bad_comment">status_bad_comment</a> |
5620 <span class="tok-w"> </span><a href="#status_bad_cdata">status_bad_cdata</a><span class="tok-w"></span> | 5703 <span class="tok-w"> </span><a href="#status_bad_cdata">status_bad_cdata</a> |
5621 <span class="tok-w"> </span><a href="#status_bad_doctype">status_bad_doctype</a><span class="tok-w"></span> | 5704 <span class="tok-w"> </span><a href="#status_bad_doctype">status_bad_doctype</a> |
5622 <span class="tok-w"> </span><a href="#status_bad_pcdata">status_bad_pcdata</a><span class="tok-w"></span> | 5705 <span class="tok-w"> </span><a href="#status_bad_pcdata">status_bad_pcdata</a> |
5623 <span class="tok-w"> </span><a href="#status_bad_start_element">status_bad_start_element</a><span class="tok-w"></span> | 5706 <span class="tok-w"> </span><a href="#status_bad_start_element">status_bad_start_element</a> |
5624 <span class="tok-w"> </span><a href="#status_bad_attribute">status_bad_attribute</a><span class="tok-w"></span> | 5707 <span class="tok-w"> </span><a href="#status_bad_attribute">status_bad_attribute</a> |
5625 <span class="tok-w"> </span><a href="#status_bad_end_element">status_bad_end_element</a><span class="tok-w"></span> | 5708 <span class="tok-w"> </span><a href="#status_bad_end_element">status_bad_end_element</a> |
5626 <span class="tok-w"> </span><a href="#status_end_element_mismatch">status_end_element_mismatch</a><span class="tok-w"></span> | 5709 <span class="tok-w"> </span><a href="#status_end_element_mismatch">status_end_element_mismatch</a> |
5627 <span class="tok-w"> </span><a href="#status_append_invalid_root">status_append_invalid_root</a><span class="tok-w"></span> | 5710 <span class="tok-w"> </span><a href="#status_append_invalid_root">status_append_invalid_root</a> |
5628 <span class="tok-w"> </span><a href="#status_no_document_element">status_no_document_element</a><span class="tok-w"></span> | 5711 <span class="tok-w"> </span><a href="#status_no_document_element">status_no_document_element</a> |
5629 | 5712 |
5630 <span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xml_encoding">xml_encoding</a><span class="tok-w"></span> | 5713 <span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xml_encoding">xml_encoding</a> |
5631 <span class="tok-w"> </span><a href="#encoding_auto">encoding_auto</a><span class="tok-w"></span> | 5714 <span class="tok-w"> </span><a href="#encoding_auto">encoding_auto</a> |
5632 <span class="tok-w"> </span><a href="#encoding_utf8">encoding_utf8</a><span class="tok-w"></span> | 5715 <span class="tok-w"> </span><a href="#encoding_utf8">encoding_utf8</a> |
5633 <span class="tok-w"> </span><a href="#encoding_utf16_le">encoding_utf16_le</a><span class="tok-w"></span> | 5716 <span class="tok-w"> </span><a href="#encoding_utf16_le">encoding_utf16_le</a> |
5634 <span class="tok-w"> </span><a href="#encoding_utf16_be">encoding_utf16_be</a><span class="tok-w"></span> | 5717 <span class="tok-w"> </span><a href="#encoding_utf16_be">encoding_utf16_be</a> |
5635 <span class="tok-w"> </span><a href="#encoding_utf16">encoding_utf16</a><span class="tok-w"></span> | 5718 <span class="tok-w"> </span><a href="#encoding_utf16">encoding_utf16</a> |
5636 <span class="tok-w"> </span><a href="#encoding_utf32_le">encoding_utf32_le</a><span class="tok-w"></span> | 5719 <span class="tok-w"> </span><a href="#encoding_utf32_le">encoding_utf32_le</a> |
5637 <span class="tok-w"> </span><a href="#encoding_utf32_be">encoding_utf32_be</a><span class="tok-w"></span> | 5720 <span class="tok-w"> </span><a href="#encoding_utf32_be">encoding_utf32_be</a> |
5638 <span class="tok-w"> </span><a href="#encoding_utf32">encoding_utf32</a><span class="tok-w"></span> | 5721 <span class="tok-w"> </span><a href="#encoding_utf32">encoding_utf32</a> |
5639 <span class="tok-w"> </span><a href="#encoding_wchar">encoding_wchar</a><span class="tok-w"></span> | 5722 <span class="tok-w"> </span><a href="#encoding_wchar">encoding_wchar</a> |
5640 <span class="tok-w"> </span><a href="#encoding_latin1">encoding_latin1</a><span class="tok-w"></span> | 5723 <span class="tok-w"> </span><a href="#encoding_latin1">encoding_latin1</a> |
5641 | 5724 |
5642 <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> | 5725 <span class="tok-k">enum</span><span class="tok-w"> </span><a href="#xpath_value_type">xpath_value_type</a> |
5643 <span class="tok-w"> </span><a href="#xpath_type_none">xpath_type_none</a><span class="tok-w"></span> | 5726 <span class="tok-w"> </span><a href="#xpath_type_none">xpath_type_none</a> |
5644 <span class="tok-w"> </span><a href="#xpath_type_node_set">xpath_type_node_set</a><span class="tok-w"></span> | 5727 <span class="tok-w"> </span><a href="#xpath_type_node_set">xpath_type_node_set</a> |
5645 <span class="tok-w"> </span><a href="#xpath_type_number">xpath_type_number</a><span class="tok-w"></span> | 5728 <span class="tok-w"> </span><a href="#xpath_type_number">xpath_type_number</a> |
5646 <span class="tok-w"> </span><a href="#xpath_type_string">xpath_type_string</a><span class="tok-w"></span> | 5729 <span class="tok-w"> </span><a href="#xpath_type_string">xpath_type_string</a> |
5647 <span class="tok-w"> </span><a href="#xpath_type_boolean">xpath_type_boolean</a><span class="tok-w"></span></code></pre> | 5730 <span class="tok-w"> </span><a href="#xpath_type_boolean">xpath_type_boolean</a></code></pre> |
5648 </div> | 5731 </div> |
5649 </div> | 5732 </div> |
5650 </div> | 5733 </div> |
5651 <div class="sect2"> | 5734 <div class="sect2"> |
5652 <h3 id="apiref.constants"><a class="anchor" href="#apiref.constants"></a><a class="link" href="#apiref.constants">10.4. Constants</a></h3> | 5735 <h3 id="apiref.constants"><a class="anchor" href="#apiref.constants"></a><a class="link" href="#apiref.constants">10.4. Constants</a></h3> |
5653 <div class="listingblock"> | 5736 <div class="listingblock"> |
5654 <div class="content"> | 5737 <div class="content"> |
5655 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Formatting options bit flags:</span> | 5738 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-c1">// Formatting options bit flags:</span> |
5656 <span class="tok-k">const</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><a href="#format_attribute_single_quote">format_attribute_single_quote</a><span class="tok-w"></span> | 5739 <span class="tok-k">const</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><a href="#format_attribute_single_quote">format_attribute_single_quote</a> |
5657 <span class="tok-k">const</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><a href="#format_default">format_default</a><span class="tok-w"></span> | 5740 <span class="tok-k">const</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><a href="#format_default">format_default</a> |
5658 <span class="tok-k">const</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><a href="#format_indent">format_indent</a><span class="tok-w"></span> | 5741 <span class="tok-k">const</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><a href="#format_indent">format_indent</a> |
5659 <span class="tok-k">const</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><a href="#format_indent_attributes">format_indent_attributes</a><span class="tok-w"></span> | 5742 <span class="tok-k">const</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><a href="#format_indent_attributes">format_indent_attributes</a> |
5660 <span class="tok-k">const</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><a href="#format_no_declaration">format_no_declaration</a><span class="tok-w"></span> | 5743 <span class="tok-k">const</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><a href="#format_no_declaration">format_no_declaration</a> |
5661 <span class="tok-k">const</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><a href="#format_no_empty_element_tags">format_no_empty_element_tags</a><span class="tok-w"></span> | 5744 <span class="tok-k">const</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><a href="#format_no_empty_element_tags">format_no_empty_element_tags</a> |
5662 <span class="tok-k">const</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><a href="#format_no_escapes">format_no_escapes</a><span class="tok-w"></span> | 5745 <span class="tok-k">const</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><a href="#format_no_escapes">format_no_escapes</a> |
5663 <span class="tok-k">const</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><a href="#format_raw">format_raw</a><span class="tok-w"></span> | 5746 <span class="tok-k">const</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><a href="#format_raw">format_raw</a> |
5664 <span class="tok-k">const</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><a href="#format_save_file_text">format_save_file_text</a><span class="tok-w"></span> | 5747 <span class="tok-k">const</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><a href="#format_save_file_text">format_save_file_text</a> |
5665 <span class="tok-k">const</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><a href="#format_skip_control_chars">format_skip_control_chars</a><span class="tok-w"></span> | 5748 <span class="tok-k">const</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><a href="#format_skip_control_chars">format_skip_control_chars</a> |
5666 <span class="tok-k">const</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><a href="#format_write_bom">format_write_bom</a><span class="tok-w"></span> | 5749 <span class="tok-k">const</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><a href="#format_write_bom">format_write_bom</a> |
5667 | 5750 |
5668 <span class="tok-c1">// Parsing options bit flags:</span> | 5751 <span class="tok-c1">// Parsing options bit flags:</span> |
5669 <span class="tok-k">const</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><a href="#parse_cdata">parse_cdata</a><span class="tok-w"></span> | 5752 <span class="tok-k">const</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><a href="#parse_cdata">parse_cdata</a> |
5670 <span class="tok-k">const</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><a href="#parse_comments">parse_comments</a><span class="tok-w"></span> | 5753 <span class="tok-k">const</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><a href="#parse_comments">parse_comments</a> |
5671 <span class="tok-k">const</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><a href="#parse_declaration">parse_declaration</a><span class="tok-w"></span> | 5754 <span class="tok-k">const</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><a href="#parse_declaration">parse_declaration</a> |
5672 <span class="tok-k">const</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><a href="#parse_default">parse_default</a><span class="tok-w"></span> | 5755 <span class="tok-k">const</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><a href="#parse_default">parse_default</a> |
5673 <span class="tok-k">const</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><a href="#parse_doctype">parse_doctype</a><span class="tok-w"></span> | 5756 <span class="tok-k">const</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><a href="#parse_doctype">parse_doctype</a> |
5674 <span class="tok-k">const</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><a href="#parse_eol">parse_eol</a><span class="tok-w"></span> | 5757 <span class="tok-k">const</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><a href="#parse_eol">parse_eol</a> |
5675 <span class="tok-k">const</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><a href="#parse_escapes">parse_escapes</a><span class="tok-w"></span> | 5758 <span class="tok-k">const</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><a href="#parse_escapes">parse_escapes</a> |
5676 <span class="tok-k">const</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><a href="#parse_fragment">parse_fragment</a><span class="tok-w"></span> | 5759 <span class="tok-k">const</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><a href="#parse_fragment">parse_fragment</a> |
5677 <span class="tok-k">const</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><a href="#parse_full">parse_full</a><span class="tok-w"></span> | 5760 <span class="tok-k">const</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><a href="#parse_full">parse_full</a> |
5678 <span class="tok-k">const</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><a href="#parse_minimal">parse_minimal</a><span class="tok-w"></span> | 5761 <span class="tok-k">const</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><a href="#parse_minimal">parse_minimal</a> |
5679 <span class="tok-k">const</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><a href="#parse_pi">parse_pi</a><span class="tok-w"></span> | 5762 <span class="tok-k">const</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><a href="#parse_pi">parse_pi</a> |
5680 <span class="tok-k">const</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><a href="#parse_trim_pcdata">parse_trim_pcdata</a><span class="tok-w"></span> | 5763 <span class="tok-k">const</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><a href="#parse_trim_pcdata">parse_trim_pcdata</a> |
5681 <span class="tok-k">const</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><a href="#parse_ws_pcdata">parse_ws_pcdata</a><span class="tok-w"></span> | 5764 <span class="tok-k">const</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><a href="#parse_ws_pcdata">parse_ws_pcdata</a> |
5682 <span class="tok-k">const</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><a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a><span class="tok-w"></span> | 5765 <span class="tok-k">const</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><a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a> |
5683 <span class="tok-k">const</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><a href="#parse_embed_pcdata">parse_embed_pcdata</a><span class="tok-w"></span> | 5766 <span class="tok-k">const</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><a href="#parse_embed_pcdata">parse_embed_pcdata</a> |
5684 <span class="tok-k">const</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><a href="#parse_wconv_attribute">parse_wconv_attribute</a><span class="tok-w"></span> | 5767 <span class="tok-k">const</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><a href="#parse_merge_pcdata">parse_merge_pcdata</a> |
5685 <span class="tok-k">const</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><a href="#parse_wnorm_attribute">parse_wnorm_attribute</a><span class="tok-w"></span></code></pre> | 5768 <span class="tok-k">const</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><a href="#parse_wconv_attribute">parse_wconv_attribute</a> |
5769 <span class="tok-k">const</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><a href="#parse_wnorm_attribute">parse_wnorm_attribute</a></code></pre> | |
5686 </div> | 5770 </div> |
5687 </div> | 5771 </div> |
5688 </div> | 5772 </div> |
5689 <div class="sect2"> | 5773 <div class="sect2"> |
5690 <h3 id="apiref.classes"><a class="anchor" href="#apiref.classes"></a><a class="link" href="#apiref.classes">10.5. Classes</a></h3> | 5774 <h3 id="apiref.classes"><a class="anchor" href="#apiref.classes"></a><a class="link" href="#apiref.classes">10.5. Classes</a></h3> |
5691 <div class="listingblock"> | 5775 <div class="listingblock"> |
5692 <div class="content"> | 5776 <div class="content"> |
5693 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span> <a href="#xml_attribute">xml_attribute</a><span class="tok-w"></span> | 5777 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-k">class</span> <a href="#xml_attribute">xml_attribute</a> |
5694 <span class="tok-w"> </span><a href="#xml_attribute::ctor">xml_attribute</a><span class="tok-p">();</span><span class="tok-w"></span> | 5778 <span class="tok-w"> </span><a href="#xml_attribute::ctor">xml_attribute</a><span class="tok-p">();</span> |
5695 | 5779 |
5696 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::empty">empty</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> | 5780 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::empty">empty</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5697 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_attribute::unspecified_bool_type">unspecified_bool_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> | 5781 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_attribute::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5698 | 5782 |
5699 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5783 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5700 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5784 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5701 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator<</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5785 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator<</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5702 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator></a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5786 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator></a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5703 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator<=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5787 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator<=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5704 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator>=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5788 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::comparison">operator>=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5705 | 5789 |
5706 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xml_attribute::hash_value">hash_value</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> | 5790 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xml_attribute::hash_value">hash_value</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5707 | 5791 |
5708 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_attribute::next_attribute">next_attribute</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> | 5792 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_attribute::next_attribute">next_attribute</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5709 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_attribute::previous_attribute">previous_attribute</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> | 5793 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_attribute::previous_attribute">previous_attribute</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5710 | 5794 |
5711 <span class="tok-w"> </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><a href="#xml_attribute::name">name</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> | 5795 <span class="tok-w"> </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><a href="#xml_attribute::name">name</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5712 <span class="tok-w"> </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><a href="#xml_attribute::value">value</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> | 5796 <span class="tok-w"> </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><a href="#xml_attribute::value">value</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5713 | 5797 |
5714 <span class="tok-w"> </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><a href="#xml_attribute::as_string">as_string</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">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">""</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> | 5798 <span class="tok-w"> </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><a href="#xml_attribute::as_string">as_string</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">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5715 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><a href="#xml_attribute::as_int">as_int</a><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> | 5799 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><a href="#xml_attribute::as_int">as_int</a><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> |
5716 <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><a href="#xml_attribute::as_uint">as_uint</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">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> | 5800 <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><a href="#xml_attribute::as_uint">as_uint</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">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> |
5717 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xml_attribute::as_double">as_double</a><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> | 5801 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xml_attribute::as_double">as_double</a><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> |
5718 <span class="tok-w"> </span><span class="tok-kt">float</span><span class="tok-w"> </span><a href="#xml_attribute::as_float">as_float</a><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> | 5802 <span class="tok-w"> </span><span class="tok-kt">float</span><span class="tok-w"> </span><a href="#xml_attribute::as_float">as_float</a><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> |
5719 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::as_bool">as_bool</a><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> | 5803 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_attribute::as_bool">as_bool</a><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> |
5720 <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_attribute::as_llong">as_llong</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">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> | 5804 <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_attribute::as_llong">as_llong</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">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> |
5721 <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_attribute::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> | 5805 <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_attribute::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> |
5722 | 5806 |
5723 <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> | 5807 <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> |
5724 <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> | 5808 <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-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
5725 <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> | 5809 <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> |
5726 <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> | 5810 <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> |
5727 <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> | 5811 <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> |
5728 <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> | 5812 <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> |
5729 <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">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 5813 <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> |
5730 <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">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 5814 <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">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
5731 <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">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 5815 <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">double</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
5732 <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">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 5816 <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">float</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
5733 <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-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span><span class="tok-w"></span> | 5817 <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">bool</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
5734 <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">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> | 5818 <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-kt">long</span><span class="tok-w"> </span><span class="tok-n">rhs</span><span class="tok-p">);</span> |
5735 | 5819 <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">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> |
5736 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::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> | 5820 |
5737 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::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> | 5821 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::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> |
5738 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5822 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::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> |
5739 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5823 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5740 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5824 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5741 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5825 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5742 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5826 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5743 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5827 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5744 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> | 5828 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5745 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-n">unsnigned</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> | 5829 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</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> |
5746 | 5830 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-n">unsnigned</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> |
5747 <span class="tok-k">class</span> <a href="#xml_node">xml_node</a><span class="tok-w"></span> | 5831 |
5748 <span class="tok-w"> </span><a href="#xml_node::ctor">xml_node</a><span class="tok-p">();</span><span class="tok-w"></span> | 5832 <span class="tok-k">class</span> <a href="#xml_node">xml_node</a> |
5749 | 5833 <span class="tok-w"> </span><a href="#xml_node::ctor">xml_node</a><span class="tok-p">();</span> |
5750 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::empty">empty</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> | 5834 |
5751 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_node::unspecified_bool_type">unspecified_bool_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> | 5835 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::empty">empty</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5752 | 5836 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_node::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5753 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5837 |
5754 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5838 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5755 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator<</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5839 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5756 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator></a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5840 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator<</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5757 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator<=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5841 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator></a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5758 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator>=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</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> | 5842 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator<=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5759 | 5843 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::comparison">operator>=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">r</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5760 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xml_node::hash_value">hash_value</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> | 5844 |
5761 | 5845 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xml_node::hash_value">hash_value</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5762 <span class="tok-w"> </span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><a href="#xml_node::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> | 5846 |
5763 | 5847 <span class="tok-w"> </span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><a href="#xml_node::type">type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5764 <span class="tok-w"> </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><a href="#xml_node::name">name</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> | 5848 |
5765 <span class="tok-w"> </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><a href="#xml_node::value">value</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> | 5849 <span class="tok-w"> </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><a href="#xml_node::name">name</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5766 | 5850 <span class="tok-w"> </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><a href="#xml_node::value">value</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5767 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::parent">parent</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> | 5851 |
5768 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::first_child">first_child</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> | 5852 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::parent">parent</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5769 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::last_child">last_child</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> | 5853 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::first_child">first_child</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5770 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::next_sibling">next_sibling</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> | 5854 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::last_child">last_child</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5771 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::previous_sibling">previous_sibling</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> | 5855 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::next_sibling">next_sibling</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5772 | 5856 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::previous_sibling">previous_sibling</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5773 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::first_attribute">first_attribute</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> | 5857 |
5774 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::last_attribute">last_attribute</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> | 5858 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::first_attribute">first_attribute</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5775 | 5859 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::last_attribute">last_attribute</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5776 <span class="tok-w"> </span><span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#xml_node::children">children</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> | 5860 |
5777 <span class="tok-w"> </span><span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#xml_node::children">children</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-k">const</span><span class="tok-p">;</span><span class="tok-w"></span> | 5861 <span class="tok-w"> </span><span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#xml_node::children">children</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5778 <span class="tok-w"> </span><span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#xml_node::attributes">attributes</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> | 5862 <span class="tok-w"> </span><span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#xml_node::children">children</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-k">const</span><span class="tok-p">;</span> |
5779 | 5863 <span class="tok-w"> </span><span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span><span class="tok-w"> </span><a href="#xml_node::attributes">attributes</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5780 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::child">child</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-k">const</span><span class="tok-p">;</span><span class="tok-w"></span> | 5864 |
5781 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::attribute">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-k">const</span><span class="tok-p">;</span><span class="tok-w"></span> | 5865 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::child">child</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-k">const</span><span class="tok-p">;</span> |
5782 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::next_sibling_name">next_sibling</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-k">const</span><span class="tok-p">;</span><span class="tok-w"></span> | 5866 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::attribute">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-k">const</span><span class="tok-p">;</span> |
5783 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::previous_sibling_name">previous_sibling</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-k">const</span><span class="tok-p">;</span><span class="tok-w"></span> | 5867 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::next_sibling_name">next_sibling</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-k">const</span><span class="tok-p">;</span> |
5784 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_child_by_attribute">find_child_by_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-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">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</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> | 5868 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::previous_sibling_name">previous_sibling</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-k">const</span><span class="tok-p">;</span> |
5785 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_child_by_attribute">find_child_by_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">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</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> | 5869 |
5786 | 5870 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::attribute_hinted">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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">hint</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5787 <span class="tok-w"> </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><a href="#xml_node::child_value">child_value</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> | 5871 |
5788 <span class="tok-w"> </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><a href="#xml_node::child_value">child_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">name</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> | 5872 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_child_by_attribute">find_child_by_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-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">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5789 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-w"> </span><a href="#xml_node::text">text</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> | 5873 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::find_child_by_attribute">find_child_by_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">attr_name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">attr_value</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5790 | 5874 |
5791 <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><a href="#xml_node_iterator">iterator</a><span class="tok-p">;</span><span class="tok-w"></span> | 5875 <span class="tok-w"> </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><a href="#xml_node::child_value">child_value</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5792 <span class="tok-w"> </span><span class="tok-n">iterator</span><span class="tok-w"> </span><a href="#xml_node::begin">begin</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> | 5876 <span class="tok-w"> </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><a href="#xml_node::child_value">child_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">name</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5793 <span class="tok-w"> </span><span class="tok-n">iterator</span><span class="tok-w"> </span><a href="#xml_node::end">end</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> | 5877 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-w"> </span><a href="#xml_node::text">text</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5794 | 5878 |
5795 <span class="tok-w"> </span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">xml_attribute_iterator</span><span class="tok-w"> </span><a href="#xml_attribute_iterator">attribute_iterator</a><span class="tok-p">;</span><span class="tok-w"></span> | 5879 <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><a href="#xml_node_iterator">iterator</a><span class="tok-p">;</span> |
5796 <span class="tok-w"> </span><span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><a href="#xml_node::attributes_begin">attributes_begin</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> | 5880 <span class="tok-w"> </span><span class="tok-n">iterator</span><span class="tok-w"> </span><a href="#xml_node::begin">begin</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5797 <span class="tok-w"> </span><span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><a href="#xml_node::attributes_end">attributes_end</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> | 5881 <span class="tok-w"> </span><span class="tok-n">iterator</span><span class="tok-w"> </span><a href="#xml_node::end">end</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5798 | 5882 |
5799 <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">&</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">);</span><span class="tok-w"></span> | 5883 <span class="tok-w"> </span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-n">xml_attribute_iterator</span><span class="tok-w"> </span><a href="#xml_attribute_iterator">attribute_iterator</a><span class="tok-p">;</span> |
5800 | 5884 <span class="tok-w"> </span><span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><a href="#xml_node::attributes_begin">attributes_begin</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5801 <span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> | 5885 <span class="tok-w"> </span><span class="tok-n">attribute_iterator</span><span class="tok-w"> </span><a href="#xml_node::attributes_end">attributes_end</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5802 <span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> | 5886 |
5803 <span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> | 5887 <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">&</span><span class="tok-w"> </span><span class="tok-n">walker</span><span class="tok-p">);</span> |
5804 | 5888 |
5805 <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">'/'</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> | 5889 <span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> |
5806 <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">'/'</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> | 5890 <span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> |
5807 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::root">root</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> | 5891 <span class="tok-w"> </span><span class="tok-k">template</span><span class="tok-w"> </span><span class="tok-o"><</span><span class="tok-k">typename</span><span class="tok-w"> </span><span class="tok-nc">Predicate</span><span class="tok-o">></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> |
5808 <span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><a href="#xml_node::offset_debug">offset_debug</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> | 5892 |
5809 | 5893 <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">'/'</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5810 <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> | 5894 <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">'/'</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5811 <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> | 5895 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::root">root</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5812 <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> | 5896 <span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><a href="#xml_node::offset_debug">offset_debug</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5813 | 5897 |
5814 <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> | 5898 <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> |
5815 <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> | 5899 <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-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">size</span><span class="tok-p">);</span> |
5816 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_attribute_after">insert_attribute_after</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 5900 <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> |
5817 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_attribute_before">insert_attribute_before</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 5901 <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> |
5818 | 5902 |
5819 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_child">append_child</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span><span class="tok-w"></span> | 5903 <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> |
5820 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_child">prepend_child</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span><span class="tok-w"></span> | 5904 <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> |
5821 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_after">insert_child_after</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5905 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_attribute_after">insert_attribute_after</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
5822 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_before">insert_child_before</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5906 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_attribute_before">insert_attribute_before</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
5823 | 5907 |
5824 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_child">append_child</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> | 5908 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_child">append_child</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span> |
5825 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_child">prepend_child</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> | 5909 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_child">prepend_child</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">node_element</span><span class="tok-p">);</span> |
5826 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_after">insert_child_after</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5910 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_after">insert_child_after</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5827 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_before">insert_child_before</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5911 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_before">insert_child_before</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span><span class="tok-w"> </span><span class="tok-n">type</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5828 | 5912 |
5829 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::append_copy">append_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5913 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_child">append_child</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> |
5830 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::prepend_copy">prepend_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5914 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_child">prepend_child</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> |
5831 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_after">insert_copy_after</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 5915 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_after">insert_child_after</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5832 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_before">insert_copy_before</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span><span class="tok-w"></span> | 5916 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_child_before">insert_child_before</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-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5833 | 5917 |
5834 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_copy">append_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5918 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::append_copy">append_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
5835 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_copy">prepend_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5919 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::prepend_copy">prepend_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
5836 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_after">insert_copy_after</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5920 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_after">insert_copy_after</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
5837 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_before">insert_copy_before</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5921 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_before">insert_copy_before</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attr</span><span class="tok-p">);</span> |
5838 | 5922 |
5839 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_move">append_move</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span><span class="tok-w"></span> | 5923 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_copy">append_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
5840 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_move">prepend_move</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span><span class="tok-w"></span> | 5924 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_copy">prepend_copy</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
5841 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_move_after">insert_move_after</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5925 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_after">insert_copy_after</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5842 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_move_before">insert_move_before</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5926 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_copy_before">insert_copy_before</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5843 | 5927 |
5844 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_attribute">remove_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-p">);</span><span class="tok-w"></span> | 5928 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::append_move">append_move</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span> |
5845 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_attribute">remove_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> | 5929 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::prepend_move">prepend_move</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</span><span class="tok-p">);</span> |
5846 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_attributes">remove_attributes</a><span class="tok-p">();</span><span class="tok-w"></span> | 5930 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_move_after">insert_move_after</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5847 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_child">remove_child</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">);</span><span class="tok-w"></span> | 5931 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_node::insert_move_before">insert_move_before</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">moved</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5848 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_child">remove_child</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> | 5932 |
5849 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_children">remove_children</a><span class="tok-p">();</span><span class="tok-w"></span> | 5933 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_attribute">remove_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-p">);</span> |
5850 | 5934 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_attribute">remove_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> |
5851 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_node::append_buffer">append_buffer</a><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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5935 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_attributes">remove_attributes</a><span class="tok-p">();</span> |
5852 | 5936 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_child">remove_child</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">);</span> |
5853 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_node::print">print</a><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> | 5937 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_child">remove_child</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> |
5854 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_node::print_stream">print</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> | 5938 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_node::remove_children">remove_children</a><span class="tok-p">();</span> |
5855 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_node::print_stream">print</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</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">depth</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> | 5939 |
5856 | 5940 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_node::append_buffer">append_buffer</a><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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5857 <span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xml_node::select_node">select_node</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 5941 |
5858 <span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xml_node::select_node_precomp">select_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</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> | 5942 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_node::print">print</a><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> |
5859 <span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><a href="#xml_node::select_nodes">select_nodes</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 5943 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_node::print_stream">print</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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">depth</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> |
5860 <span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><a href="#xml_node::select_nodes_precomp">select_nodes</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</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> | 5944 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_node::print_stream">print</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">os</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</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">depth</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> |
5861 | 5945 |
5862 <span class="tok-k">class</span> <a href="#xml_document">xml_document</a><span class="tok-w"></span> | 5946 <span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xml_node::select_node">select_node</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> |
5863 <span class="tok-w"> </span><a href="#xml_document::ctor">xml_document</a><span class="tok-p">();</span><span class="tok-w"></span> | 5947 <span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xml_node::select_node_precomp">select_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5864 <span class="tok-w"> </span><span class="tok-o">~</span><a href="#xml_document::dtor">xml_document</a><span class="tok-p">();</span><span class="tok-w"></span> | 5948 <span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><a href="#xml_node::select_nodes">select_nodes</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> |
5865 | 5949 <span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><a href="#xml_node::select_nodes_precomp">select_nodes</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_query</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">query</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5866 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::reset">reset</a><span class="tok-p">();</span><span class="tok-w"></span> | 5950 |
5867 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::reset">reset</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5951 <span class="tok-k">class</span> <a href="#xml_document">xml_document</a> |
5868 | 5952 <span class="tok-w"> </span><a href="#xml_document::ctor">xml_document</a><span class="tok-p">();</span> |
5869 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_stream">load</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">istream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5953 <span class="tok-w"> </span><span class="tok-o">~</span><a href="#xml_document::dtor">xml_document</a><span class="tok-p">();</span> |
5870 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_stream">load</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wistream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span><span class="tok-w"></span> | 5954 |
5871 | 5955 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::reset">reset</a><span class="tok-p">();</span> |
5872 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_string">load_string</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">contents</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span><span class="tok-w"></span> | 5956 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::reset">reset</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_document</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">proto</span><span class="tok-p">);</span> |
5873 | 5957 |
5874 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_file">load_file</a><span class="tok-p">(</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">path</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5958 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_stream">load</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">istream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5875 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_file_wide">load_file</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5959 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_stream">load</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wistream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span> |
5876 | 5960 |
5877 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_buffer">load_buffer</a><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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5961 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_string">load_string</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">contents</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">);</span> |
5878 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_buffer_inplace">load_buffer_inplace</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5962 |
5879 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_buffer_inplace_own">load_buffer_inplace_own</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span><span class="tok-w"></span> | 5963 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_file">load_file</a><span class="tok-p">(</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">path</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">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5880 | 5964 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_file_wide">load_file</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5881 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_document::save_file">save_file</a><span class="tok-p">(</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">path</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 5965 |
5882 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_document::save_file_wide">save_file</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-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">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 5966 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_buffer">load_buffer</a><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">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5883 | 5967 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_buffer_inplace">load_buffer_inplace</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5884 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::save_stream">save</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 5968 <span class="tok-w"> </span><span class="tok-n">xml_parse_result</span><span class="tok-w"> </span><a href="#xml_document::load_buffer_inplace_own">load_buffer_inplace_own</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">contents</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-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">options</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">parse_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">);</span> |
5885 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::save_stream">save</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</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> | 5969 |
5886 | 5970 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_document::save_file">save_file</a><span class="tok-p">(</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">path</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5887 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::save">save</a><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</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> | 5971 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_document::save_file_wide">save_file</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_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-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">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5888 | 5972 |
5889 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_document::document_element">document_element</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> | 5973 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::save_stream">save</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5890 | 5974 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::save_stream">save</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5891 <span class="tok-k">struct</span> <a href="#xml_parse_result">xml_parse_result</a><span class="tok-w"></span> | 5975 |
5892 <span class="tok-w"> </span><span class="tok-n">xml_parse_status</span><span class="tok-w"> </span><a href="#xml_parse_result::status">status</a><span class="tok-p">;</span><span class="tok-w"></span> | 5976 <span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><a href="#xml_document::save">save</a><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">writer</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">indent</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">"</span><span class="tok-se">\t</span><span class="tok-s">"</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">flags</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">format_default</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><span class="tok-n">encoding</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">encoding_auto</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5893 <span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><a href="#xml_parse_result::offset">offset</a><span class="tok-p">;</span><span class="tok-w"></span> | 5977 |
5894 <span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><a href="#xml_parse_result::encoding">encoding</a><span class="tok-p">;</span><span class="tok-w"></span> | 5978 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_document::document_element">document_element</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5895 | 5979 |
5896 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_parse_result::bool">bool</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> | 5980 <span class="tok-k">struct</span> <a href="#xml_parse_result">xml_parse_result</a> |
5897 <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><a href="#xml_parse_result::description">description</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> | 5981 <span class="tok-w"> </span><span class="tok-n">xml_parse_status</span><span class="tok-w"> </span><a href="#xml_parse_result::status">status</a><span class="tok-p">;</span> |
5898 | 5982 <span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><a href="#xml_parse_result::offset">offset</a><span class="tok-p">;</span> |
5899 <span class="tok-k">class</span> <a href="#xml_node_iterator">xml_node_iterator</a><span class="tok-w"></span> | 5983 <span class="tok-w"> </span><span class="tok-n">xml_encoding</span><span class="tok-w"> </span><a href="#xml_parse_result::encoding">encoding</a><span class="tok-p">;</span> |
5900 <span class="tok-k">class</span> <a href="#xml_attribute_iterator">xml_attribute_iterator</a><span class="tok-w"></span> | 5984 |
5901 | 5985 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_parse_result::bool">bool</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5902 <span class="tok-k">class</span> <a href="#xml_tree_walker">xml_tree_walker</a><span class="tok-w"></span> | 5986 <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><a href="#xml_parse_result::description">description</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5903 <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><a href="#xml_tree_walker::begin">begin</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5987 |
5904 <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><a href="#xml_tree_walker::for_each">for_each</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</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-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">;</span><span class="tok-w"></span> | 5988 <span class="tok-k">class</span> <a href="#xml_node_iterator">xml_node_iterator</a> |
5905 <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><a href="#xml_tree_walker::end">end</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 5989 <span class="tok-k">class</span> <a href="#xml_attribute_iterator">xml_attribute_iterator</a> |
5906 | 5990 |
5907 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><a href="#xml_tree_walker::depth">depth</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> | 5991 <span class="tok-k">class</span> <a href="#xml_tree_walker">xml_tree_walker</a> |
5908 | 5992 <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><a href="#xml_tree_walker::begin">begin</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5909 <span class="tok-k">class</span> <a href="#xml_text">xml_text</a><span class="tok-w"></span> | 5993 <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><a href="#xml_tree_walker::for_each">for_each</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</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-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">;</span> |
5910 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::empty">empty</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> | 5994 <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><a href="#xml_tree_walker::end">end</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5911 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_text::unspecified_bool_type">xml_text::unspecified_bool_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> | 5995 |
5912 | 5996 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><a href="#xml_tree_walker::depth">depth</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5913 <span class="tok-w"> </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><a href="#xml_text::get">xml_text::get</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> | 5997 |
5914 | 5998 <span class="tok-k">class</span> <a href="#xml_text">xml_text</a> |
5915 <span class="tok-w"> </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><a href="#xml_text::as_string">as_string</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">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">""</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> | 5999 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::empty">empty</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5916 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><a href="#xml_text::as_int">as_int</a><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> | 6000 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xml_text::unspecified_bool_type">xml_text::unspecified_bool_type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5917 <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><a href="#xml_text::as_uint">as_uint</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">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> | 6001 |
5918 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xml_text::as_double">as_double</a><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> | 6002 <span class="tok-w"> </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><a href="#xml_text::get">xml_text::get</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5919 <span class="tok-w"> </span><span class="tok-kt">float</span><span class="tok-w"> </span><a href="#xml_text::as_float">as_float</a><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> | 6003 |
5920 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::as_bool">as_bool</a><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> | 6004 <span class="tok-w"> </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><a href="#xml_text::as_string">as_string</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">def</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-s">""</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5921 <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_llong">as_llong</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">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> | 6005 <span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><a href="#xml_text::as_int">as_int</a><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> |
5922 <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> | 6006 <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><a href="#xml_text::as_uint">as_uint</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">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> |
5923 | 6007 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xml_text::as_double">as_double</a><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> |
5924 <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> | 6008 <span class="tok-w"> </span><span class="tok-kt">float</span><span class="tok-w"> </span><a href="#xml_text::as_float">as_float</a><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> |
5925 <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> | 6009 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xml_text::as_bool">as_bool</a><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> |
5926 | 6010 <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_llong">as_llong</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">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> |
5927 <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> | 6011 <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> |
5928 <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> | 6012 |
5929 <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> | 6013 <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> |
5930 <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> | 6014 <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> |
5931 <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> | 6015 |
5932 <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> | 6016 <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> |
5933 <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> | 6017 <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> |
5934 <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> | 6018 <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> |
5935 <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> | 6019 <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> |
5936 | 6020 <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> |
5937 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</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> | 6021 <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> |
5938 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</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> | 6022 <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> |
5939 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6023 <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> |
5940 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6024 <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> |
5941 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6025 |
5942 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6026 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</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> |
5943 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6027 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</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> |
5944 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6028 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5945 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6029 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5946 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> | 6030 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5947 | 6031 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5948 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_text::data">data</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> | 6032 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5949 | 6033 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5950 <span class="tok-k">class</span> <a href="#xml_writer">xml_writer</a><span class="tok-w"></span> | 6034 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5951 <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><a href="#xml_writer::write">write</a><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> | 6035 <span class="tok-w"> </span><span class="tok-n">xml_text</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xml_text::assign">operator=</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> |
5952 | 6036 |
5953 <span class="tok-k">class</span> <a href="#xml_writer_file">xml_writer_file</a><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-k">public</span><span class="tok-w"> </span><span class="tok-n">xml_writer</span><span class="tok-w"></span> | 6037 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xml_text::data">data</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5954 <span class="tok-w"> </span><a href="#xml_writer_file">xml_writer_file</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">file</span><span class="tok-p">);</span><span class="tok-w"></span> | 6038 |
5955 | 6039 <span class="tok-k">class</span> <a href="#xml_writer">xml_writer</a> |
5956 <span class="tok-k">class</span> <a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-k">public</span><span class="tok-w"> </span><span class="tok-n">xml_writer</span><span class="tok-w"></span> | 6040 <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><a href="#xml_writer::write">write</a><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> |
5957 <span class="tok-w"> </span><a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</span><span class="tok-p">);</span><span class="tok-w"></span> | 6041 |
5958 <span class="tok-w"> </span><a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</span><span class="tok-p">);</span><span class="tok-w"></span> | 6042 <span class="tok-k">class</span> <a href="#xml_writer_file">xml_writer_file</a><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-k">public</span><span class="tok-w"> </span><span class="tok-n">xml_writer</span> |
5959 | 6043 <span class="tok-w"> </span><a href="#xml_writer_file">xml_writer_file</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">file</span><span class="tok-p">);</span> |
5960 <span class="tok-k">struct</span> <a href="#xpath_parse_result">xpath_parse_result</a><span class="tok-w"></span> | 6044 |
5961 <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><a href="#xpath_parse_result::error">error</a><span class="tok-p">;</span><span class="tok-w"></span> | 6045 <span class="tok-k">class</span> <a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-k">public</span><span class="tok-w"> </span><span class="tok-n">xml_writer</span> |
5962 <span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><a href="#xpath_parse_result::offset">offset</a><span class="tok-p">;</span><span class="tok-w"></span> | 6046 <span class="tok-w"> </span><a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</span><span class="tok-p">);</span> |
5963 | 6047 <span class="tok-w"> </span><a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">stream</span><span class="tok-p">);</span> |
5964 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xpath_parse_result::bool">bool</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> | 6048 |
5965 <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><a href="#xpath_parse_result::description">description</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> | 6049 <span class="tok-k">struct</span> <a href="#xpath_parse_result">xpath_parse_result</a> |
5966 | 6050 <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><a href="#xpath_parse_result::error">error</a><span class="tok-p">;</span> |
5967 <span class="tok-k">class</span> <a href="#xpath_query">xpath_query</a><span class="tok-w"></span> | 6051 <span class="tok-w"> </span><span class="tok-kt">ptrdiff_t</span><span class="tok-w"> </span><a href="#xpath_parse_result::offset">offset</a><span class="tok-p">;</span> |
5968 <span class="tok-w"> </span><span class="tok-k">explicit</span><span class="tok-w"> </span><a href="#xpath_query::ctor">xpath_query</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> | 6052 |
5969 | 6053 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xpath_parse_result::bool">bool</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5970 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_boolean">evaluate_boolean</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6054 <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><a href="#xpath_parse_result::description">description</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5971 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_number">evaluate_number</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6055 |
5972 <span class="tok-w"> </span><span class="tok-n">string_t</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_string">evaluate_string</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6056 <span class="tok-k">class</span> <a href="#xpath_query">xpath_query</a> |
5973 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_string_buffer">evaluate_string</a><span class="tok-p">(</span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</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">capacity</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-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6057 <span class="tok-w"> </span><span class="tok-k">explicit</span><span class="tok-w"> </span><a href="#xpath_query::ctor">xpath_query</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">query</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">variables</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> |
5974 <span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_node_set">evaluate_node_set</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6058 |
5975 <span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_node">evaluate_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6059 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_boolean">evaluate_boolean</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5976 | 6060 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_number">evaluate_number</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5977 <span class="tok-w"> </span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><a href="#xpath_query::return_type">return_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> | 6061 <span class="tok-w"> </span><span class="tok-n">string_t</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_string">evaluate_string</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5978 | 6062 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_string_buffer">evaluate_string</a><span class="tok-p">(</span><span class="tok-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">buffer</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">capacity</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-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5979 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_query::result">result</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> | 6063 <span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_node_set">evaluate_node_set</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5980 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xpath_query::unspecified_bool_type">unspecified_bool_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> | 6064 <span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-w"> </span><a href="#xpath_query::evaluate_node">evaluate_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5981 | 6065 |
5982 <span class="tok-k">class</span> <a href="#xpath_exception">xpath_exception</a><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-k">public</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">exception</span><span class="tok-w"></span> | 6066 <span class="tok-w"> </span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><a href="#xpath_query::return_type">return_type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5983 <span class="tok-w"> </span><span class="tok-k">virtual</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><a href="#xpath_exception::what">what</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-k">throw</span><span class="tok-p">();</span><span class="tok-w"></span> | 6067 |
5984 | 6068 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_query::result">result</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5985 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_exception::result">result</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> | 6069 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xpath_query::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5986 | 6070 |
5987 <span class="tok-k">class</span> <a href="#xpath_node">xpath_node</a><span class="tok-w"></span> | 6071 <span class="tok-k">class</span> <a href="#xpath_exception">xpath_exception</a><span class="tok-o">:</span><span class="tok-w"> </span><span class="tok-k">public</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">exception</span> |
5988 <span class="tok-w"> </span><a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">();</span><span class="tok-w"></span> | 6072 <span class="tok-w"> </span><span class="tok-k">virtual</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><a href="#xpath_exception::what">what</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-k">throw</span><span class="tok-p">();</span> |
5989 <span class="tok-w"> </span><a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span><span class="tok-w"></span> | 6073 |
5990 <span class="tok-w"> </span><a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attribute</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">parent</span><span class="tok-p">);</span><span class="tok-w"></span> | 6074 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_parse_result</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_exception::result">result</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5991 | 6075 |
5992 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xpath_node::node">node</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> | 6076 <span class="tok-k">class</span> <a href="#xpath_node">xpath_node</a> |
5993 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xpath_node::attribute">attribute</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> | 6077 <span class="tok-w"> </span><a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">();</span> |
5994 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xpath_node::parent">parent</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> | 6078 <span class="tok-w"> </span><a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">node</span><span class="tok-p">);</span> |
5995 | 6079 <span class="tok-w"> </span><a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">attribute</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-n">xml_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">parent</span><span class="tok-p">);</span> |
5996 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xpath_node::unspecified_bool_type">unspecified_bool_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> | 6080 |
5997 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_node::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6081 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xpath_node::node">node</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5998 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_node::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</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> | 6082 <span class="tok-w"> </span><span class="tok-n">xml_attribute</span><span class="tok-w"> </span><a href="#xpath_node::attribute">attribute</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
5999 | 6083 <span class="tok-w"> </span><span class="tok-n">xml_node</span><span class="tok-w"> </span><a href="#xpath_node::parent">parent</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6000 <span class="tok-k">class</span> <a href="#xpath_node_set">xpath_node_set</a><span class="tok-w"></span> | 6084 |
6001 <span class="tok-w"> </span><a href="#xpath_node_set::ctor">xpath_node_set</a><span class="tok-p">();</span><span class="tok-w"></span> | 6085 <span class="tok-w"> </span><span class="tok-k">operator</span><span class="tok-w"> </span><a href="#xpath_node::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6002 <span class="tok-w"> </span><a href="#xpath_node_set::ctor">xpath_node_set</a><span class="tok-p">(</span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">begin</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">end</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-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">type_unsorted</span><span class="tok-p">);</span><span class="tok-w"></span> | 6086 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_node::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6003 | 6087 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_node::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6004 <span class="tok-w"> </span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_node_set::const_iterator">const_iterator</a><span class="tok-p">;</span><span class="tok-w"></span> | 6088 |
6005 <span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><a href="#xpath_node_set::begin">begin</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> | 6089 <span class="tok-k">class</span> <a href="#xpath_node_set">xpath_node_set</a> |
6006 <span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><a href="#xpath_node_set::end">end</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> | 6090 <span class="tok-w"> </span><a href="#xpath_node_set::ctor">xpath_node_set</a><span class="tok-p">();</span> |
6007 | 6091 <span class="tok-w"> </span><a href="#xpath_node_set::ctor">xpath_node_set</a><span class="tok-p">(</span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">begin</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><span class="tok-n">end</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-n">type</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">type_unsorted</span><span class="tok-p">);</span> |
6008 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_node_set::index">operator[</a><span class="tok-p">](</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">index</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> | 6092 |
6009 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xpath_node_set::size">size</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> | 6093 <span class="tok-w"> </span><span class="tok-k">typedef</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_node_set::const_iterator">const_iterator</a><span class="tok-p">;</span> |
6010 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_node_set::empty">empty</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> | 6094 <span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><a href="#xpath_node_set::begin">begin</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6011 | 6095 <span class="tok-w"> </span><span class="tok-n">const_iterator</span><span class="tok-w"> </span><a href="#xpath_node_set::end">end</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6012 <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> | 6096 |
6013 | 6097 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_node_set::index">operator[</a><span class="tok-p">](</span><span class="tok-kt">size_t</span><span class="tok-w"> </span><span class="tok-n">index</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6014 <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> | 6098 <span class="tok-w"> </span><span class="tok-kt">size_t</span><span class="tok-w"> </span><a href="#xpath_node_set::size">size</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6015 <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> | 6099 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_node_set::empty">empty</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6016 <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> | 6100 |
6017 | 6101 <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> |
6018 <span class="tok-k">class</span> <a href="#xpath_variable">xpath_variable</a><span class="tok-w"></span> | 6102 |
6019 <span class="tok-w"> </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><a href="#xpath_variable::name">name</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> | 6103 <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> |
6020 <span class="tok-w"> </span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><a href="#xpath_variable::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> | 6104 <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> |
6021 | 6105 <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> |
6022 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::get_boolean">get_boolean</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> | 6106 |
6023 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xpath_variable::get_number">get_number</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> | 6107 <span class="tok-k">class</span> <a href="#xpath_variable">xpath_variable</a> |
6024 <span class="tok-w"> </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><a href="#xpath_variable::get_string">get_string</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> | 6108 <span class="tok-w"> </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><a href="#xpath_variable::name">name</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6025 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_variable::get_node_set">get_node_set</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> | 6109 <span class="tok-w"> </span><span class="tok-n">xpath_value_type</span><span class="tok-w"> </span><a href="#xpath_variable::type">type</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6026 | 6110 |
6027 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6111 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::get_boolean">get_boolean</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6028 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6112 <span class="tok-w"> </span><span class="tok-kt">double</span><span class="tok-w"> </span><a href="#xpath_variable::get_number">get_number</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6029 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::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">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6113 <span class="tok-w"> </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><a href="#xpath_variable::get_string">get_string</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6030 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6114 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><a href="#xpath_variable::get_node_set">get_node_set</a><span class="tok-p">()</span><span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-p">;</span> |
6031 | 6115 |
6032 <span class="tok-k">class</span> <a href="#xpath_variable_set">xpath_variable_set</a><span class="tok-w"></span> | 6116 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-kt">bool</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> |
6033 <span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_variable_set::add">add</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-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-p">);</span><span class="tok-w"></span> | 6117 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-kt">double</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> |
6034 | 6118 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::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">value</span><span class="tok-p">);</span> |
6035 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6119 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> |
6036 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6120 |
6037 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6121 <span class="tok-k">class</span> <a href="#xpath_variable_set">xpath_variable_set</a> |
6038 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span><span class="tok-w"></span> | 6122 <span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_variable_set::add">add</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-n">xpath_value_type</span><span class="tok-w"> </span><span class="tok-n">type</span><span class="tok-p">);</span> |
6039 | 6123 |
6040 <span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_variable_set::get">get</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> | 6124 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span> |
6041 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_variable_set::get">get</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-k">const</span><span class="tok-p">;</span><span class="tok-w"></span></code></pre> | 6125 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">value</span><span class="tok-p">);</span> |
6126 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">char_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> | |
6127 <span class="tok-w"> </span><span class="tok-kt">bool</span><span class="tok-w"> </span><a href="#xpath_variable_set::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">name</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-n">xpath_node_set</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">value</span><span class="tok-p">);</span> | |
6128 | |
6129 <span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_variable_set::get">get</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> | |
6130 <span class="tok-w"> </span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">xpath_variable</span><span class="tok-o">*</span><span class="tok-w"> </span><a href="#xpath_variable_set::get">get</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-k">const</span><span class="tok-p">;</span></code></pre> | |
6042 </div> | 6131 </div> |
6043 </div> | 6132 </div> |
6044 </div> | 6133 </div> |
6045 <div class="sect2"> | 6134 <div class="sect2"> |
6046 <h3 id="apiref.functions"><a class="anchor" href="#apiref.functions"></a><a class="link" href="#apiref.functions">10.6. Functions</a></h3> | 6135 <h3 id="apiref.functions"><a class="anchor" href="#apiref.functions"></a><a class="link" href="#apiref.functions">10.6. Functions</a></h3> |
6047 <div class="listingblock"> | 6136 <div class="listingblock"> |
6048 <div class="content"> | 6137 <div class="content"> |
6049 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-w"> </span><a href="#as_utf8">as_utf8</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span><span class="tok-w"></span> | 6138 <pre class="pygments highlight"><code data-lang="c++"><span></span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-w"> </span><a href="#as_utf8">as_utf8</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-kt">wchar_t</span><span class="tok-o">*</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span> |
6050 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-w"> </span><a href="#as_utf8">as_utf8</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span><span class="tok-w"></span> | 6139 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-w"> </span><a href="#as_utf8">as_utf8</a><span class="tok-p">(</span><span class="tok-k">const</span><span class="tok-w"> </span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span> |
6051 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><a href="#as_wide">as_wide</a><span class="tok-p">(</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">str</span><span class="tok-p">);</span><span class="tok-w"></span> | 6140 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><a href="#as_wide">as_wide</a><span class="tok-p">(</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">str</span><span class="tok-p">);</span> |
6052 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><a href="#as_wide">as_wide</a><span class="tok-p">(</span><span class="tok-k">const</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-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span><span class="tok-w"></span> | 6141 <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-w"> </span><a href="#as_wide">as_wide</a><span class="tok-p">(</span><span class="tok-k">const</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-o">&</span><span class="tok-w"> </span><span class="tok-n">str</span><span class="tok-p">);</span> |
6053 <span class="tok-kt">void</span><span class="tok-w"> </span><a href="#set_memory_management_functions">set_memory_management_functions</a><span class="tok-p">(</span><span class="tok-n">allocation_function</span><span class="tok-w"> </span><span class="tok-n">allocate</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">deallocation_function</span><span class="tok-w"> </span><span class="tok-n">deallocate</span><span class="tok-p">);</span><span class="tok-w"></span> | 6142 <span class="tok-kt">void</span><span class="tok-w"> </span><a href="#set_memory_management_functions">set_memory_management_functions</a><span class="tok-p">(</span><span class="tok-n">allocation_function</span><span class="tok-w"> </span><span class="tok-n">allocate</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">deallocation_function</span><span class="tok-w"> </span><span class="tok-n">deallocate</span><span class="tok-p">);</span> |
6054 <span class="tok-n">allocation_function</span><span class="tok-w"> </span><a href="#get_memory_allocation_function">get_memory_allocation_function</a><span class="tok-p">();</span><span class="tok-w"></span> | 6143 <span class="tok-n">allocation_function</span><span class="tok-w"> </span><a href="#get_memory_allocation_function">get_memory_allocation_function</a><span class="tok-p">();</span> |
6055 <span class="tok-n">deallocation_function</span><span class="tok-w"> </span><a href="#get_memory_deallocation_function">get_memory_deallocation_function</a><span class="tok-p">();</span><span class="tok-w"></span></code></pre> | 6144 <span class="tok-n">deallocation_function</span><span class="tok-w"> </span><a href="#get_memory_deallocation_function">get_memory_deallocation_function</a><span class="tok-p">();</span></code></pre> |
6056 </div> | 6145 </div> |
6057 </div> | 6146 </div> |
6058 </div> | 6147 </div> |
6059 </div> | 6148 </div> |
6060 </div> | 6149 </div> |
6065 <a href="#_footnoteref_1">1</a>. All trademarks used are properties of their respective owners. | 6154 <a href="#_footnoteref_1">1</a>. All trademarks used are properties of their respective owners. |
6066 </div> | 6155 </div> |
6067 </div> | 6156 </div> |
6068 <div id="footer"> | 6157 <div id="footer"> |
6069 <div id="footer-text"> | 6158 <div id="footer-text"> |
6070 Last updated 2022-10-20 20:18:02 -0700 | 6159 Last updated 2023-09-07 11:54:45 -0700 |
6071 </div> | 6160 </div> |
6072 </div> | 6161 </div> |
6073 </body> | 6162 </body> |
6074 </html> | 6163 </html> |