CARLA
Loading...
Searching...
No Matches
pugixml.hpp
Go to the documentation of this file.
1/**
2 * pugixml parser - version 1.9
3 * --------------------------------------------------------
4 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
5 * Report bugs and download new versions at http://pugixml.org/
6 *
7 * This library is distributed under the MIT License. See notice at the end
8 * of this file.
9 *
10 * This work is based on the pugxml parser, which is:
11 * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
12 */
13
14#ifndef PUGIXML_VERSION
15// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons
16# define PUGIXML_VERSION 190
17#endif
18
19// Include user configuration file (this can define various configuration macros)
20#include "pugiconfig.hpp"
21
22#ifndef HEADER_PUGIXML_HPP
23#define HEADER_PUGIXML_HPP
24
25// Include stddef.h for size_t and ptrdiff_t
26#include <stddef.h>
27
28// Include exception header for XPath
29#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
30# include <exception>
31#endif
32
33// Include STL headers
34#ifndef PUGIXML_NO_STL
35# include <iterator>
36# include <iosfwd>
37# include <string>
38#endif
39
40// Macro for deprecated features
41#ifndef PUGIXML_DEPRECATED
42# if defined(__GNUC__)
43# define PUGIXML_DEPRECATED __attribute__((deprecated))
44# elif defined(_MSC_VER) && _MSC_VER >= 1300
45# define PUGIXML_DEPRECATED __declspec(deprecated)
46# else
47# define PUGIXML_DEPRECATED
48# endif
49#endif
50
51// If no API is defined, assume default
52#ifndef PUGIXML_API
53# define PUGIXML_API
54#endif
55
56// If no API for classes is defined, assume default
57#ifndef PUGIXML_CLASS
58# define PUGIXML_CLASS PUGIXML_API
59#endif
60
61// If no API for functions is defined, assume default
62#ifndef PUGIXML_FUNCTION
63# define PUGIXML_FUNCTION PUGIXML_API
64#endif
65
66// If the platform is known to have long long support, enable long long functions
67#ifndef PUGIXML_HAS_LONG_LONG
68# if __cplusplus >= 201103
69# define PUGIXML_HAS_LONG_LONG
70# elif defined(_MSC_VER) && _MSC_VER >= 1400
71# define PUGIXML_HAS_LONG_LONG
72# endif
73#endif
74
75// If the platform is known to have move semantics support, compile move ctor/operator implementation
76#ifndef PUGIXML_HAS_MOVE
77# if __cplusplus >= 201103
78# define PUGIXML_HAS_MOVE
79# elif defined(_MSC_VER) && _MSC_VER >= 1600
80# define PUGIXML_HAS_MOVE
81# endif
82#endif
83
84// HACK(Andrei): Disable exceptions as they are not available in Unreal engine
85#define PUGIXML_NOEXCEPT
86
87// If C++ is 2011 or higher, add 'noexcept' specifiers
88#ifndef PUGIXML_NOEXCEPT
89# if __cplusplus >= 201103
90# define PUGIXML_NOEXCEPT noexcept
91# elif defined(_MSC_VER) && _MSC_VER >= 1900
92# define PUGIXML_NOEXCEPT noexcept
93# else
94# define PUGIXML_NOEXCEPT
95# endif
96#endif
97
98// Some functions can not be noexcept in compact mode
99#ifdef PUGIXML_COMPACT
100# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
101#else
102# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
103#endif
104
105// If C++ is 2011 or higher, add 'override' qualifiers
106#ifndef PUGIXML_OVERRIDE
107# if __cplusplus >= 201103
108# define PUGIXML_OVERRIDE override
109# elif defined(_MSC_VER) && _MSC_VER >= 1700
110# define PUGIXML_OVERRIDE override
111# else
112# define PUGIXML_OVERRIDE
113# endif
114#endif
115
116// Character interface macros
117#ifdef PUGIXML_WCHAR_MODE
118# define PUGIXML_TEXT(t) L ## t
119# define PUGIXML_CHAR wchar_t
120#else
121# define PUGIXML_TEXT(t) t
122# define PUGIXML_CHAR char
123#endif
124
125namespace pugi
126{
127 // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
129
130#ifndef PUGIXML_NO_STL
131 // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
132 typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t;
133#endif
134}
135
136// The PugiXML namespace
137namespace pugi
138{
139 // Tree node types
141 {
142 node_null, // Empty (null) node handle
143 node_document, // A document tree's absolute root
144 node_element, // Element tag, i.e. '<node/>'
145 node_pcdata, // Plain character data, i.e. 'text'
146 node_cdata, // Character data, i.e. '<![CDATA[text]]>'
147 node_comment, // Comment tag, i.e. '<!-- text -->'
148 node_pi, // Processing instruction, i.e. '<?name?>'
149 node_declaration, // Document declaration, i.e. '<?xml version="1.0"?>'
150 node_doctype // Document type declaration, i.e. '<!DOCTYPE doc>'
151 };
152
153 // Parsing options
154
155 // Minimal parsing mode (equivalent to turning all other flags off).
156 // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed.
157 const unsigned int parse_minimal = 0x0000;
158
159 // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default.
160 const unsigned int parse_pi = 0x0001;
161
162 // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default.
163 const unsigned int parse_comments = 0x0002;
164
165 // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default.
166 const unsigned int parse_cdata = 0x0004;
167
168 // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree.
169 // This flag is off by default; turning it on usually results in slower parsing and more memory consumption.
170 const unsigned int parse_ws_pcdata = 0x0008;
171
172 // This flag determines if character and entity references are expanded during parsing. This flag is on by default.
173 const unsigned int parse_escapes = 0x0010;
174
175 // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
176 const unsigned int parse_eol = 0x0020;
177
178 // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
179 const unsigned int parse_wconv_attribute = 0x0040;
180
181 // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
182 const unsigned int parse_wnorm_attribute = 0x0080;
183
184 // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
185 const unsigned int parse_declaration = 0x0100;
186
187 // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default.
188 const unsigned int parse_doctype = 0x0200;
189
190 // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only
191 // of whitespace is added to the DOM tree.
192 // This flag is off by default; turning it on may result in slower parsing and more memory consumption.
193 const unsigned int parse_ws_pcdata_single = 0x0400;
194
195 // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default.
196 const unsigned int parse_trim_pcdata = 0x0800;
197
198 // This flag determines if plain character data that does not have a parent node is added to the DOM tree, and if an empty document
199 // is a valid document. This flag is off by default.
200 const unsigned int parse_fragment = 0x1000;
201
202 // This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of
203 // the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments.
204 // This flag is off by default.
205 const unsigned int parse_embed_pcdata = 0x2000;
206
207 // The default parsing mode.
208 // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
209 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
211
212 // The full parsing mode.
213 // Nodes of all types are added to the DOM tree, character/reference entities are expanded,
214 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
216
217 // These flags determine the encoding of input data for XML document
219 {
220 encoding_auto, // Auto-detect input encoding using BOM or < / <? detection; use UTF8 if BOM is not found
221 encoding_utf8, // UTF8 encoding
222 encoding_utf16_le, // Little-endian UTF16
223 encoding_utf16_be, // Big-endian UTF16
224 encoding_utf16, // UTF16 with native endianness
225 encoding_utf32_le, // Little-endian UTF32
226 encoding_utf32_be, // Big-endian UTF32
227 encoding_utf32, // UTF32 with native endianness
228 encoding_wchar, // The same encoding wchar_t has (either UTF16 or UTF32)
230 };
231
232 // Formatting flags
233
234 // Indent the nodes that are written to output stream with as many indentation strings as deep the node is in DOM tree. This flag is on by default.
235 const unsigned int format_indent = 0x01;
236
237 // Write encoding-specific BOM to the output stream. This flag is off by default.
238 const unsigned int format_write_bom = 0x02;
239
240 // Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
241 const unsigned int format_raw = 0x04;
242
243 // Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
244 const unsigned int format_no_declaration = 0x08;
245
246 // Don't escape attribute values and PCDATA contents. This flag is off by default.
247 const unsigned int format_no_escapes = 0x10;
248
249 // Open file using text mode in xml_document::save_file. This enables special character (i.e. new-line) conversions on some systems. This flag is off by default.
250 const unsigned int format_save_file_text = 0x20;
251
252 // Write every attribute on a new line with appropriate indentation. This flag is off by default.
253 const unsigned int format_indent_attributes = 0x40;
254
255 // Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default.
256 const unsigned int format_no_empty_element_tags = 0x80;
257
258 // The default set of formatting flags.
259 // Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
260 const unsigned int format_default = format_indent;
261
262 // Forward declarations
264 struct xml_node_struct;
265
266 class xml_node_iterator;
269
270 class xml_tree_walker;
271
272 struct xml_parse_result;
273
274 class xml_node;
275
276 class xml_text;
277
278 #ifndef PUGIXML_NO_XPATH
279 class xpath_node;
280 class xpath_node_set;
281 class xpath_query;
282 class xpath_variable_set;
283 #endif
284
285 // Range-based for loop support
286 template <typename It> class xml_object_range
287 {
288 public:
289 typedef It const_iterator;
290 typedef It iterator;
291
292 xml_object_range(It b, It e): _begin(b), _end(e)
293 {
294 }
295
296 It begin() const { return _begin; }
297 It end() const { return _end; }
298
299 private:
301 };
302
303 // Writer interface for node printing (see xml_node::print)
305 {
306 public:
307 virtual ~xml_writer() {}
308
309 // Write memory chunk into stream/file/whatever
310 virtual void write(const void* data, size_t size) = 0;
311 };
312
313 // xml_writer implementation for FILE*
315 {
316 public:
317 // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio
318 xml_writer_file(void* file);
319
320 virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
321
322 private:
323 void* file;
324 };
325
326 #ifndef PUGIXML_NO_STL
327 // xml_writer implementation for streams
329 {
330 public:
331 // Construct writer from an output stream object
332 xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
333 xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
334
335 virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
336
337 private:
338 std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
339 std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
340 };
341 #endif
342
343 // A light-weight handle for manipulating attributes in DOM tree
345 {
347 friend class xml_node;
348
349 private:
351
353
354 public:
355 // Default constructor. Constructs an empty attribute.
357
358 // Constructs attribute from internal pointer
359 explicit xml_attribute(xml_attribute_struct* attr);
360
361 // Safe bool conversion operator
362 operator unspecified_bool_type() const;
363
364 // Borland C++ workaround
365 bool operator!() const;
366
367 // Comparison operators (compares wrapped attribute pointers)
368 bool operator==(const xml_attribute& r) const;
369 bool operator!=(const xml_attribute& r) const;
370 bool operator<(const xml_attribute& r) const;
371 bool operator>(const xml_attribute& r) const;
372 bool operator<=(const xml_attribute& r) const;
373 bool operator>=(const xml_attribute& r) const;
374
375 // Check if attribute is empty
376 bool empty() const;
377
378 // Get attribute name/value, or "" if attribute is empty
379 const char_t* name() const;
380 const char_t* value() const;
381
382 // Get attribute value, or the default value if attribute is empty
383 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
384
385 // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty
386 int as_int(int def = 0) const;
387 unsigned int as_uint(unsigned int def = 0) const;
388 double as_double(double def = 0) const;
389 float as_float(float def = 0) const;
390
391 #ifdef PUGIXML_HAS_LONG_LONG
392 long long as_llong(long long def = 0) const;
393 unsigned long long as_ullong(unsigned long long def = 0) const;
394 #endif
395
396 // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
397 bool as_bool(bool def = false) const;
398
399 // Set attribute name/value (returns false if attribute is empty or there is not enough memory)
400 bool set_name(const char_t* rhs);
401 bool set_value(const char_t* rhs);
402
403 // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
404 bool set_value(int rhs);
405 bool set_value(unsigned int rhs);
406 bool set_value(long rhs);
407 bool set_value(unsigned long rhs);
408 bool set_value(double rhs);
409 bool set_value(float rhs);
410 bool set_value(bool rhs);
411
412 #ifdef PUGIXML_HAS_LONG_LONG
413 bool set_value(long long rhs);
414 bool set_value(unsigned long long rhs);
415 #endif
416
417 // Set attribute value (equivalent to set_value without error checking)
418 xml_attribute& operator=(const char_t* rhs);
419 xml_attribute& operator=(int rhs);
420 xml_attribute& operator=(unsigned int rhs);
421 xml_attribute& operator=(long rhs);
422 xml_attribute& operator=(unsigned long rhs);
423 xml_attribute& operator=(double rhs);
424 xml_attribute& operator=(float rhs);
425 xml_attribute& operator=(bool rhs);
426
427 #ifdef PUGIXML_HAS_LONG_LONG
428 xml_attribute& operator=(long long rhs);
429 xml_attribute& operator=(unsigned long long rhs);
430 #endif
431
432 // Get next/previous attribute in the attribute list of the parent node
435
436 // Get hash value (unique for handles to the same object)
437 size_t hash_value() const;
438
439 // Get internal pointer
441 };
442
443#ifdef __BORLANDC__
444 // Borland C++ workaround
445 bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs);
446 bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs);
447#endif
448
449 // A light-weight handle for manipulating nodes in DOM tree
451 {
453 friend class xml_node_iterator;
455
456 protected:
458
459 typedef void (*unspecified_bool_type)(xml_node***);
460
461 public:
462 // Default constructor. Constructs an empty node.
463 xml_node();
464
465 // Constructs node from internal pointer
466 explicit xml_node(xml_node_struct* p);
467
468 // Safe bool conversion operator
469 operator unspecified_bool_type() const;
470
471 // Borland C++ workaround
472 bool operator!() const;
473
474 // Comparison operators (compares wrapped node pointers)
475 bool operator==(const xml_node& r) const;
476 bool operator!=(const xml_node& r) const;
477 bool operator<(const xml_node& r) const;
478 bool operator>(const xml_node& r) const;
479 bool operator<=(const xml_node& r) const;
480 bool operator>=(const xml_node& r) const;
481
482 // Check if node is empty.
483 bool empty() const;
484
485 // Get node type
486 xml_node_type type() const;
487
488 // Get node name, or "" if node is empty or it has no name
489 const char_t* name() const;
490
491 // Get node value, or "" if node is empty or it has no value
492 // Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
493 const char_t* value() const;
494
495 // Get attribute list
498
499 // Get children list
500 xml_node first_child() const;
501 xml_node last_child() const;
502
503 // Get next/previous sibling in the children list of the parent node
504 xml_node next_sibling() const;
506
507 // Get parent node
508 xml_node parent() const;
509
510 // Get root of DOM tree this node belongs to
511 xml_node root() const;
512
513 // Get text object for the current node
514 xml_text text() const;
515
516 // Get child, attribute or next/previous sibling with the specified name
517 xml_node child(const char_t* name) const;
518 xml_attribute attribute(const char_t* name) const;
519 xml_node next_sibling(const char_t* name) const;
520 xml_node previous_sibling(const char_t* name) const;
521
522 // Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast)
523 xml_attribute attribute(const char_t* name, xml_attribute& hint) const;
524
525 // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
526 const char_t* child_value() const;
527
528 // Get child value of child with specified name. Equivalent to child(name).child_value().
529 const char_t* child_value(const char_t* name) const;
530
531 // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
532 bool set_name(const char_t* rhs);
533 bool set_value(const char_t* rhs);
534
535 // Add attribute with specified name. Returns added attribute, or empty attribute on errors.
540
541 // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors.
546
547 // Add child node with specified type. Returns added node, or empty node on errors.
552
553 // Add child element with specified name. Returns added node, or empty node on errors.
556 xml_node insert_child_after(const char_t* name, const xml_node& node);
557 xml_node insert_child_before(const char_t* name, const xml_node& node);
558
559 // Add a copy of the specified node as a child. Returns added node, or empty node on errors.
560 xml_node append_copy(const xml_node& proto);
561 xml_node prepend_copy(const xml_node& proto);
562 xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
563 xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
564
565 // Move the specified node to become a child of this node. Returns moved node, or empty node on errors.
566 xml_node append_move(const xml_node& moved);
567 xml_node prepend_move(const xml_node& moved);
568 xml_node insert_move_after(const xml_node& moved, const xml_node& node);
569 xml_node insert_move_before(const xml_node& moved, const xml_node& node);
570
571 // Remove specified attribute
572 bool remove_attribute(const xml_attribute& a);
573 bool remove_attribute(const char_t* name);
574
575 // Remove specified child
576 bool remove_child(const xml_node& n);
577 bool remove_child(const char_t* name);
578
579 // Parses buffer as an XML document fragment and appends all nodes as children of the current node.
580 // Copies/converts the buffer, so it may be deleted or changed after the function returns.
581 // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory.
582 xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
583
584 // Find attribute using predicate. Returns first attribute for which predicate returned true.
585 template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
586 {
587 if (!_root) return xml_attribute();
588
589 for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
590 if (pred(attrib))
591 return attrib;
592
593 return xml_attribute();
594 }
595
596 // Find child node using predicate. Returns first child for which predicate returned true.
597 template <typename Predicate> xml_node find_child(Predicate pred) const
598 {
599 if (!_root) return xml_node();
600
601 for (xml_node node = first_child(); node; node = node.next_sibling())
602 if (pred(node))
603 return node;
604
605 return xml_node();
606 }
607
608 // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true.
609 template <typename Predicate> xml_node find_node(Predicate pred) const
610 {
611 if (!_root) return xml_node();
612
613 xml_node cur = first_child();
614
615 while (cur._root && cur._root != _root)
616 {
617 if (pred(cur)) return cur;
618
619 if (cur.first_child()) cur = cur.first_child();
620 else if (cur.next_sibling()) cur = cur.next_sibling();
621 else
622 {
623 while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
624
625 if (cur._root != _root) cur = cur.next_sibling();
626 }
627 }
628
629 return xml_node();
630 }
631
632 // Find child node by attribute name/value
633 xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
634 xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
635
636 #ifndef PUGIXML_NO_STL
637 // Get the absolute node path from root as a text string.
638 string_t path(char_t delimiter = '/') const;
639 #endif
640
641 // Search for a node by path consisting of node names and . or .. elements.
642 xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
643
644 // Recursively traverse subtree with xml_tree_walker
645 bool traverse(xml_tree_walker& walker);
646
647 #ifndef PUGIXML_NO_XPATH
648 // Select single node by evaluating XPath query. Returns first node from the resulting node set.
649 xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
650 xpath_node select_node(const xpath_query& query) const;
651
652 // Select node set by evaluating XPath query
653 xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
654 xpath_node_set select_nodes(const xpath_query& query) const;
655
656 // (deprecated: use select_node instead) Select single node by evaluating XPath query.
657 PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
658 PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
659
660 #endif
661
662 // Print subtree using a writer object
663 void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
664
665 #ifndef PUGIXML_NO_STL
666 // Print subtree to stream
667 void print(std::basic_ostream<char, std::char_traits<char> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
668 void print(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const;
669 #endif
670
671 // Child nodes iterators
673
674 iterator begin() const;
675 iterator end() const;
676
677 // Attribute iterators
679
682
683 // Range-based for support
687
688 // Get node offset in parsed file/string (in char_t units) for debugging purposes
689 ptrdiff_t offset_debug() const;
690
691 // Get hash value (unique for handles to the same object)
692 size_t hash_value() const;
693
694 // Get internal pointer
696 };
697
698#ifdef __BORLANDC__
699 // Borland C++ workaround
700 bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs);
701 bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs);
702#endif
703
704 // A helper for working with text inside PCDATA nodes
706 {
707 friend class xml_node;
708
710
711 typedef void (*unspecified_bool_type)(xml_text***);
712
713 explicit xml_text(xml_node_struct* root);
714
716 xml_node_struct* _data() const;
717
718 public:
719 // Default constructor. Constructs an empty object.
720 xml_text();
721
722 // Safe bool conversion operator
723 operator unspecified_bool_type() const;
724
725 // Borland C++ workaround
726 bool operator!() const;
727
728 // Check if text object is empty
729 bool empty() const;
730
731 // Get text, or "" if object is empty
732 const char_t* get() const;
733
734 // Get text, or the default value if object is empty
735 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
736
737 // Get text as a number, or the default value if conversion did not succeed or object is empty
738 int as_int(int def = 0) const;
739 unsigned int as_uint(unsigned int def = 0) const;
740 double as_double(double def = 0) const;
741 float as_float(float def = 0) const;
742
743 #ifdef PUGIXML_HAS_LONG_LONG
744 long long as_llong(long long def = 0) const;
745 unsigned long long as_ullong(unsigned long long def = 0) const;
746 #endif
747
748 // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
749 bool as_bool(bool def = false) const;
750
751 // Set text (returns false if object is empty or there is not enough memory)
752 bool set(const char_t* rhs);
753
754 // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
755 bool set(int rhs);
756 bool set(unsigned int rhs);
757 bool set(long rhs);
758 bool set(unsigned long rhs);
759 bool set(double rhs);
760 bool set(float rhs);
761 bool set(bool rhs);
762
763 #ifdef PUGIXML_HAS_LONG_LONG
764 bool set(long long rhs);
765 bool set(unsigned long long rhs);
766 #endif
767
768 // Set text (equivalent to set without error checking)
769 xml_text& operator=(const char_t* rhs);
770 xml_text& operator=(int rhs);
771 xml_text& operator=(unsigned int rhs);
772 xml_text& operator=(long rhs);
773 xml_text& operator=(unsigned long rhs);
774 xml_text& operator=(double rhs);
775 xml_text& operator=(float rhs);
776 xml_text& operator=(bool rhs);
777
778 #ifdef PUGIXML_HAS_LONG_LONG
779 xml_text& operator=(long long rhs);
780 xml_text& operator=(unsigned long long rhs);
781 #endif
782
783 // Get the data node (node_pcdata or node_cdata) for this object
784 xml_node data() const;
785 };
786
787#ifdef __BORLANDC__
788 // Borland C++ workaround
789 bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs);
790 bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs);
791#endif
792
793 // Child node iterator (a bidirectional iterator over a collection of xml_node)
795 {
796 friend class xml_node;
797
798 private:
801
803
804 public:
805 // Iterator traits
806 typedef ptrdiff_t difference_type;
810
811 #ifndef PUGIXML_NO_STL
812 typedef std::bidirectional_iterator_tag iterator_category;
813 #endif
814
815 // Default constructor
817
818 // Construct an iterator which points to the specified node
819 xml_node_iterator(const xml_node& node);
820
821 // Iterator operators
822 bool operator==(const xml_node_iterator& rhs) const;
823 bool operator!=(const xml_node_iterator& rhs) const;
824
825 xml_node& operator*() const;
826 xml_node* operator->() const;
827
830
833 };
834
835 // Attribute iterator (a bidirectional iterator over a collection of xml_attribute)
837 {
838 friend class xml_node;
839
840 private:
843
845
846 public:
847 // Iterator traits
848 typedef ptrdiff_t difference_type;
852
853 #ifndef PUGIXML_NO_STL
854 typedef std::bidirectional_iterator_tag iterator_category;
855 #endif
856
857 // Default constructor
859
860 // Construct an iterator which points to the specified attribute
861 xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
862
863 // Iterator operators
864 bool operator==(const xml_attribute_iterator& rhs) const;
865 bool operator!=(const xml_attribute_iterator& rhs) const;
866
867 xml_attribute& operator*() const;
868 xml_attribute* operator->() const;
869
872
875 };
876
877 // Named node range helper
879 {
880 friend class xml_node;
881
882 public:
883 // Iterator traits
884 typedef ptrdiff_t difference_type;
888
889 #ifndef PUGIXML_NO_STL
890 typedef std::bidirectional_iterator_tag iterator_category;
891 #endif
892
893 // Default constructor
895
896 // Construct an iterator which points to the specified node
897 xml_named_node_iterator(const xml_node& node, const char_t* name);
898
899 // Iterator operators
900 bool operator==(const xml_named_node_iterator& rhs) const;
901 bool operator!=(const xml_named_node_iterator& rhs) const;
902
903 xml_node& operator*() const;
904 xml_node* operator->() const;
905
908
911
912 private:
915 const char_t* _name;
916
918 };
919
920 // Abstract tree walker class (see xml_node::traverse)
922 {
923 friend class xml_node;
924
925 private:
927
928 protected:
929 // Get current traversal depth
930 int depth() const;
931
932 public:
934 virtual ~xml_tree_walker();
935
936 // Callback that is called when traversal begins
937 virtual bool begin(xml_node& node);
938
939 // Callback that is called for each node traversed
940 virtual bool for_each(xml_node& node) = 0;
941
942 // Callback that is called when traversal ends
943 virtual bool end(xml_node& node);
944 };
945
946 // Parsing status, returned as part of xml_parse_result object
948 {
949 status_ok = 0, // No error
950
951 status_file_not_found, // File was not found during load_file()
952 status_io_error, // Error reading from file/stream
953 status_out_of_memory, // Could not allocate memory
954 status_internal_error, // Internal error occurred
955
956 status_unrecognized_tag, // Parser could not determine tag type
957
958 status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction
959 status_bad_comment, // Parsing error occurred while parsing comment
960 status_bad_cdata, // Parsing error occurred while parsing CDATA section
961 status_bad_doctype, // Parsing error occurred while parsing document type declaration
962 status_bad_pcdata, // Parsing error occurred while parsing PCDATA section
963 status_bad_start_element, // Parsing error occurred while parsing start element tag
964 status_bad_attribute, // Parsing error occurred while parsing element attribute
965 status_bad_end_element, // Parsing error occurred while parsing end element tag
966 status_end_element_mismatch,// There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag)
967
968 status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer)
969
970 status_no_document_element // Parsing resulted in a document without element nodes
971 };
972
973 // Parsing result
975 {
976 // Parsing status (see xml_parse_status)
978
979 // Last parsed offset (in char_t units from start of input data)
980 ptrdiff_t offset;
981
982 // Source document encoding
984
985 // Default constructor, initializes object to failed state
987
988 // Cast to bool operator
989 operator bool() const;
990
991 // Get error description
992 const char* description() const;
993 };
994
995 // Document class (DOM tree root)
997 {
998 private:
1000
1001 char _memory[192];
1002
1003 // Non-copyable semantics
1006
1007 void _create();
1008 void _destroy();
1010
1011 public:
1012 // Default constructor, makes empty document
1013 xml_document();
1014
1015 // Destructor, invalidates all node/attribute handles to this document
1016 ~xml_document();
1017
1018 #ifdef PUGIXML_HAS_MOVE
1019 // Move semantics support
1022 #endif
1023
1024 // Removes all nodes, leaving the empty document
1025 void reset();
1026
1027 // Removes all nodes, then copies the entire contents of the specified document
1028 void reset(const xml_document& proto);
1029
1030 #ifndef PUGIXML_NO_STL
1031 // Load document from stream.
1032 xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1033 xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
1034 #endif
1035
1036 // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
1037 PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
1038
1039 // Load document from zero-terminated string. No encoding conversions are applied.
1040 xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
1041
1042 // Load document from file
1043 xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1044 xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1045
1046 // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns.
1047 xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1048
1049 // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
1050 // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed.
1051 xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1052
1053 // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
1054 // You should allocate the buffer with pugixml allocation function; document will free the buffer when it is no longer needed (you can't use it anymore).
1055 xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1056
1057 // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details).
1058 void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1059
1060 #ifndef PUGIXML_NO_STL
1061 // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details).
1062 void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1063 void save(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
1064 #endif
1065
1066 // Save XML to file
1067 bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1068 bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1069
1070 // Get document element
1071 xml_node document_element() const;
1072 };
1073
1074#ifndef PUGIXML_NO_XPATH
1075 // XPath query return type
1077 {
1078 xpath_type_none, // Unknown type (query failed to compile)
1079 xpath_type_node_set, // Node set (xpath_node_set)
1083 };
1084
1085 // XPath parsing result
1087 {
1088 // Error message (0 if no error)
1089 const char* error;
1090
1091 // Last parsed offset (in char_t units from string start)
1092 ptrdiff_t offset;
1093
1094 // Default constructor, initializes object to failed state
1096
1097 // Cast to bool operator
1098 operator bool() const;
1099
1100 // Get error description
1101 const char* description() const;
1102 };
1103
1104 // A single XPath variable
1106 {
1108
1109 protected:
1112
1114
1115 // Non-copyable semantics
1118
1119 public:
1120 // Get variable name
1121 const char_t* name() const;
1122
1123 // Get variable type
1124 xpath_value_type type() const;
1125
1126 // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error
1127 bool get_boolean() const;
1128 double get_number() const;
1129 const char_t* get_string() const;
1130 const xpath_node_set& get_node_set() const;
1131
1132 // Set variable value; no type conversion is performed, false is returned on type mismatch error
1133 bool set(bool value);
1134 bool set(double value);
1135 bool set(const char_t* value);
1136 bool set(const xpath_node_set& value);
1137 };
1138
1139 // A set of XPath variables
1141 {
1142 private:
1144
1145 void _assign(const xpath_variable_set& rhs);
1146 void _swap(xpath_variable_set& rhs);
1147
1148 xpath_variable* _find(const char_t* name) const;
1149
1150 static bool _clone(xpath_variable* var, xpath_variable** out_result);
1151 static void _destroy(xpath_variable* var);
1152
1153 public:
1154 // Default constructor/destructor
1157
1158 // Copy constructor/assignment operator
1161
1162 #ifdef PUGIXML_HAS_MOVE
1163 // Move semantics support
1166 #endif
1167
1168 // Add a new variable or get the existing one, if the types match
1169 xpath_variable* add(const char_t* name, xpath_value_type type);
1170
1171 // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch
1172 bool set(const char_t* name, bool value);
1173 bool set(const char_t* name, double value);
1174 bool set(const char_t* name, const char_t* value);
1175 bool set(const char_t* name, const xpath_node_set& value);
1176
1177 // Get existing variable by name
1178 xpath_variable* get(const char_t* name);
1179 const xpath_variable* get(const char_t* name) const;
1180 };
1181
1182 // A compiled XPath query object
1184 {
1185 private:
1186 void* _impl;
1188
1190
1191 // Non-copyable semantics
1194
1195 public:
1196 // Construct a compiled object from XPath expression.
1197 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors.
1198 explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0);
1199
1200 // Constructor
1201 xpath_query();
1202
1203 // Destructor
1204 ~xpath_query();
1205
1206 #ifdef PUGIXML_HAS_MOVE
1207 // Move semantics support
1210 #endif
1211
1212 // Get query expression return type
1214
1215 // Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
1216 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1217 bool evaluate_boolean(const xpath_node& n) const;
1218
1219 // Evaluate expression as double value in the specified context; performs type conversion if necessary.
1220 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1221 double evaluate_number(const xpath_node& n) const;
1222
1223 #ifndef PUGIXML_NO_STL
1224 // Evaluate expression as string value in the specified context; performs type conversion if necessary.
1225 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1226 string_t evaluate_string(const xpath_node& n) const;
1227 #endif
1228
1229 // Evaluate expression as string value in the specified context; performs type conversion if necessary.
1230 // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
1231 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1232 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead.
1233 size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
1234
1235 // Evaluate expression as node set in the specified context.
1236 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
1237 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead.
1239
1240 // Evaluate expression as node set in the specified context.
1241 // Return first node in document order, or empty node if node set is empty.
1242 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
1243 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node instead.
1244 xpath_node evaluate_node(const xpath_node& n) const;
1245
1246 // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode)
1247 const xpath_parse_result& result() const;
1248
1249 // Safe bool conversion operator
1250 operator unspecified_bool_type() const;
1251
1252 // Borland C++ workaround
1253 bool operator!() const;
1254 };
1255
1256 #ifndef PUGIXML_NO_EXCEPTIONS
1257 // XPath exception class
1258 class PUGIXML_CLASS xpath_exception: public std::exception
1259 {
1260 private:
1262
1263 public:
1264 // Construct exception from parse result
1265 explicit xpath_exception(const xpath_parse_result& result);
1266
1267 // Get error message
1268 virtual const char* what() const noexcept PUGIXML_OVERRIDE;
1269
1270 // Get parse result
1271 const xpath_parse_result& result() const;
1272 };
1273 #endif
1274
1275 // XPath node class (either xml_node or xml_attribute)
1277 {
1278 private:
1281
1283
1284 public:
1285 // Default constructor; constructs empty XPath node
1286 xpath_node();
1287
1288 // Construct XPath node from XML node/attribute
1289 xpath_node(const xml_node& node);
1291
1292 // Get node/attribute, if any
1293 xml_node node() const;
1294 xml_attribute attribute() const;
1295
1296 // Get parent of contained node/attribute
1297 xml_node parent() const;
1298
1299 // Safe bool conversion operator
1300 operator unspecified_bool_type() const;
1301
1302 // Borland C++ workaround
1303 bool operator!() const;
1304
1305 // Comparison operators
1306 bool operator==(const xpath_node& n) const;
1307 bool operator!=(const xpath_node& n) const;
1308 };
1309
1310#ifdef __BORLANDC__
1311 // Borland C++ workaround
1312 bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs);
1313 bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs);
1314#endif
1315
1316 // A fixed-size collection of XPath nodes
1318 {
1319 public:
1320 // Collection type
1322 {
1323 type_unsorted, // Not ordered
1324 type_sorted, // Sorted by document order (ascending)
1325 type_sorted_reverse // Sorted by document order (descending)
1326 };
1327
1328 // Constant iterator type
1330
1331 // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
1332 typedef const xpath_node* iterator;
1333
1334 // Default constructor. Constructs empty set.
1336
1337 // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful
1339
1340 // Destructor
1342
1343 // Copy constructor/assignment operator
1344 xpath_node_set(const xpath_node_set& ns);
1346
1347 #ifdef PUGIXML_HAS_MOVE
1348 // Move semantics support
1351 #endif
1352
1353 // Get collection type
1354 type_t type() const;
1355
1356 // Get collection size
1357 size_t size() const;
1358
1359 // Indexing operator
1360 const xpath_node& operator[](size_t index) const;
1361
1362 // Collection iterators
1363 const_iterator begin() const;
1364 const_iterator end() const;
1365
1366 // Sort the collection in ascending/descending order by document order
1367 void sort(bool reverse = false);
1368
1369 // Get first node in the collection by document order
1370 xpath_node first() const;
1371
1372 // Check if collection is empty
1373 bool empty() const;
1374
1375 private:
1377
1379
1382
1385 };
1386#endif
1387
1388#ifndef PUGIXML_NO_STL
1389 // Convert wide string to UTF8
1390 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
1391 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str);
1392
1393 // Convert UTF8 to wide string
1394 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
1395 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >& str);
1396#endif
1397
1398 // Memory allocation function interface; returns pointer to allocated memory or NULL on failure
1399 typedef void* (*allocation_function)(size_t size);
1400
1401 // Memory deallocation function interface
1402 typedef void (*deallocation_function)(void* ptr);
1403
1404 // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
1406
1407 // Get current memory management functions
1410}
1411
1412#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
1413namespace std
1414{
1415 // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier)
1416 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&);
1417 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&);
1418 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&);
1419}
1420#endif
1421
1422#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
1423namespace std
1424{
1425 // Workarounds for (non-standard) iterator category detection
1426 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&);
1427 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&);
1428 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&);
1429}
1430#endif
1431
1432#endif
1433
1434// Make sure implementation is included in header-only mode
1435// Use macro expansion in #include to work around QMake (QTBUG-11923)
1436#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
1437# define PUGIXML_SOURCE "pugixml.cpp"
1438# include PUGIXML_SOURCE
1439#endif
1440
1441/**
1442 * Copyright (c) 2006-2018 Arseny Kapoulkine
1443 *
1444 * Permission is hereby granted, free of charge, to any person
1445 * obtaining a copy of this software and associated documentation
1446 * files (the "Software"), to deal in the Software without
1447 * restriction, including without limitation the rights to use,
1448 * copy, modify, merge, publish, distribute, sublicense, and/or sell
1449 * copies of the Software, and to permit persons to whom the
1450 * Software is furnished to do so, subject to the following
1451 * conditions:
1452 *
1453 * The above copyright notice and this permission notice shall be
1454 * included in all copies or substantial portions of the Software.
1455 *
1456 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1457 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1458 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1459 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1460 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1461 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1462 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1463 * OTHER DEALINGS IN THE SOFTWARE.
1464 */
bool operator!=(const xml_attribute_iterator &rhs) const
Definition pugixml.cpp:6689
xml_attribute_iterator(xml_attribute_struct *ref, xml_node_struct *parent)
Definition pugixml.cpp:6680
const xml_attribute_iterator & operator--()
Definition pugixml.cpp:6720
xml_attribute * operator->() const
Definition pugixml.cpp:6700
std::bidirectional_iterator_tag iterator_category
Definition pugixml.hpp:854
xml_attribute & operator*() const
Definition pugixml.cpp:6694
bool operator==(const xml_attribute_iterator &rhs) const
Definition pugixml.cpp:6684
xml_attribute & reference
Definition pugixml.hpp:851
const xml_attribute_iterator & operator++()
Definition pugixml.cpp:6706
friend class xml_node
Definition pugixml.hpp:347
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const
Definition pugixml.cpp:5163
bool operator>=(const xml_attribute &r) const
Definition pugixml.cpp:5148
bool as_bool(bool def=false) const
Definition pugixml.cpp:5188
bool operator!=(const xml_attribute &r) const
Definition pugixml.cpp:5128
bool operator<(const xml_attribute &r) const
Definition pugixml.cpp:5133
int as_int(int def=0) const
Definition pugixml.cpp:5168
float as_float(float def=0) const
Definition pugixml.cpp:5183
bool operator==(const xml_attribute &r) const
Definition pugixml.cpp:5123
bool empty() const
Definition pugixml.cpp:5205
size_t hash_value() const
Definition pugixml.cpp:5220
void(*) unspecified_bool_type(xml_attribute ***)
Definition pugixml.hpp:352
const char_t * name() const
Definition pugixml.cpp:5210
xml_attribute & operator=(const char_t *rhs)
Definition pugixml.cpp:5230
xml_attribute previous_attribute() const
Definition pugixml.cpp:5158
xml_attribute_struct * _attr
Definition pugixml.hpp:350
xml_attribute next_attribute() const
Definition pugixml.cpp:5153
bool operator!() const
Definition pugixml.cpp:5118
bool operator<=(const xml_attribute &r) const
Definition pugixml.cpp:5143
double as_double(double def=0) const
Definition pugixml.cpp:5178
bool set_name(const char_t *rhs)
Definition pugixml.cpp:5292
friend class xml_attribute_iterator
Definition pugixml.hpp:346
bool set_value(const char_t *rhs)
Definition pugixml.cpp:5299
unsigned int as_uint(unsigned int def=0) const
Definition pugixml.cpp:5173
xml_attribute_struct * internal_object() const
Definition pugixml.cpp:5225
bool operator>(const xml_attribute &r) const
Definition pugixml.cpp:5138
const char_t * value() const
Definition pugixml.cpp:5215
xml_parse_result load_buffer_inplace(void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
Definition pugixml.cpp:7135
xml_document(const xml_document &)
xml_node document_element() const
Definition pugixml.cpp:7209
xml_parse_result load_string(const char_t *contents, unsigned int options=parse_default)
Definition pugixml.cpp:7091
bool save_file(const char *path, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
Definition pugixml.cpp:7193
xml_parse_result load_buffer_inplace_own(void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
Definition pugixml.cpp:7142
xml_parse_result load_file(const char *path, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
Definition pugixml.cpp:7108
xml_parse_result load_buffer(const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
Definition pugixml.cpp:7128
xml_document & operator=(const xml_document &)
xml_parse_result load(std::basic_istream< char, std::char_traits< char > > &stream, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
Definition pugixml.cpp:7076
void save(xml_writer &writer, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
Definition pugixml.cpp:7149
void _move(xml_document &rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT
bool operator!=(const xml_named_node_iterator &rhs) const
Definition pugixml.cpp:6750
xml_node * operator->() const
Definition pugixml.cpp:6761
const xml_named_node_iterator & operator--()
Definition pugixml.cpp:6781
std::bidirectional_iterator_tag iterator_category
Definition pugixml.hpp:890
bool operator==(const xml_named_node_iterator &rhs) const
Definition pugixml.cpp:6745
xml_node & operator*() const
Definition pugixml.cpp:6755
const xml_named_node_iterator & operator++()
Definition pugixml.cpp:6767
friend class xml_node
Definition pugixml.hpp:796
xml_node_iterator(xml_node_struct *ref, xml_node_struct *parent)
Definition pugixml.cpp:6619
bool operator==(const xml_node_iterator &rhs) const
Definition pugixml.cpp:6623
const xml_node_iterator & operator--()
Definition pugixml.cpp:6659
xml_node * operator->() const
Definition pugixml.cpp:6639
bool operator!=(const xml_node_iterator &rhs) const
Definition pugixml.cpp:6628
std::bidirectional_iterator_tag iterator_category
Definition pugixml.hpp:812
const xml_node_iterator & operator++()
Definition pugixml.cpp:6645
xml_node & operator*() const
Definition pugixml.cpp:6633
string_t path(char_t delimiter='/') const
Definition pugixml.cpp:6136
size_t hash_value() const
Definition pugixml.cpp:6265
bool set_value(const char_t *rhs)
Definition pugixml.cpp:5642
xml_node_type type() const
Definition pugixml.cpp:5480
xml_node append_child(xml_node_type type=node_element)
Definition pugixml.cpp:5792
xml_node child(const char_t *name) const
Definition pugixml.cpp:5490
friend class xml_named_node_iterator
Definition pugixml.hpp:454
xml_node insert_move_after(const xml_node &moved, const xml_node &node)
Definition pugixml.cpp:6000
xml_node last_child() const
Definition pugixml.cpp:5627
xml_node append_move(const xml_node &moved)
Definition pugixml.cpp:5968
xml_node first_child() const
Definition pugixml.cpp:5622
bool operator>(const xml_node &r) const
Definition pugixml.cpp:5455
xml_object_range< xml_node_iterator > children() const
Definition pugixml.cpp:5425
xml_node prepend_move(const xml_node &moved)
Definition pugixml.cpp:5984
xml_attribute append_attribute(const char_t *name)
Definition pugixml.cpp:5652
xml_node next_sibling() const
Definition pugixml.cpp:5521
xml_node_struct * internal_object() const
Definition pugixml.cpp:6270
xml_attribute find_attribute(Predicate pred) const
Definition pugixml.hpp:585
xml_node_struct * _root
Definition pugixml.hpp:457
xml_object_range< xml_attribute_iterator > attributes() const
Definition pugixml.cpp:5435
xml_node parent() const
Definition pugixml.cpp:5577
bool remove_child(const xml_node &n)
Definition pugixml.cpp:6060
xml_attribute append_copy(const xml_attribute &proto)
Definition pugixml.cpp:5722
xml_node insert_child_after(xml_node_type type, const xml_node &node)
Definition pugixml.cpp:5844
xml_attribute last_attribute() const
Definition pugixml.cpp:5617
attribute_iterator attributes_end() const
Definition pugixml.cpp:5420
xml_node previous_sibling() const
Definition pugixml.cpp:5569
ptrdiff_t offset_debug() const
Definition pugixml.cpp:6302
iterator end() const
Definition pugixml.cpp:5410
xml_text text() const
Definition pugixml.cpp:5587
xml_attribute insert_attribute_before(const char_t *name, const xml_attribute &attr)
Definition pugixml.cpp:5704
xml_attribute insert_attribute_after(const char_t *name, const xml_attribute &attr)
Definition pugixml.cpp:5686
bool operator!=(const xml_node &r) const
Definition pugixml.cpp:5445
bool operator<(const xml_node &r) const
Definition pugixml.cpp:5450
xml_attribute prepend_attribute(const char_t *name)
Definition pugixml.cpp:5669
xml_parse_result append_buffer(const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
Definition pugixml.cpp:6073
const char_t * value() const
Definition pugixml.cpp:5485
xml_node find_node(Predicate pred) const
Definition pugixml.hpp:609
xml_attribute_iterator attribute_iterator
Definition pugixml.hpp:678
const char_t * child_value() const
Definition pugixml.cpp:5592
bool set_name(const char_t *rhs)
Definition pugixml.cpp:5632
xml_node prepend_child(xml_node_type type=node_element)
Definition pugixml.cpp:5809
friend class xml_node_iterator
Definition pugixml.hpp:453
xml_attribute first_attribute() const
Definition pugixml.cpp:5612
bool operator!() const
Definition pugixml.cpp:5400
bool operator>=(const xml_node &r) const
Definition pugixml.cpp:5465
void(*) unspecified_bool_type(xml_node ***)
Definition pugixml.hpp:459
xml_attribute insert_copy_after(const xml_attribute &proto, const xml_attribute &attr)
Definition pugixml.cpp:5756
xml_attribute prepend_copy(const xml_attribute &proto)
Definition pugixml.cpp:5739
xml_node insert_move_before(const xml_node &moved, const xml_node &node)
Definition pugixml.cpp:6018
xml_attribute attribute(const char_t *name) const
Definition pugixml.cpp:5500
const char_t * name() const
Definition pugixml.cpp:5475
xml_attribute insert_copy_before(const xml_attribute &proto, const xml_attribute &attr)
Definition pugixml.cpp:5774
attribute_iterator attributes_begin() const
Definition pugixml.cpp:5415
xml_node find_child(Predicate pred) const
Definition pugixml.hpp:597
xml_node_iterator iterator
Definition pugixml.hpp:672
bool operator<=(const xml_node &r) const
Definition pugixml.cpp:5460
iterator begin() const
Definition pugixml.cpp:5405
bool remove_attribute(const xml_attribute &a)
Definition pugixml.cpp:6041
friend class xml_attribute_iterator
Definition pugixml.hpp:452
xml_node root() const
Definition pugixml.cpp:5582
bool empty() const
Definition pugixml.cpp:5470
xml_node insert_child_before(xml_node_type type, const xml_node &node)
Definition pugixml.cpp:5826
bool operator==(const xml_node &r) const
Definition pugixml.cpp:5440
xml_object_range(It b, It e)
Definition pugixml.hpp:292
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const
Definition pugixml.cpp:6402
double as_double(double def=0) const
Definition pugixml.cpp:6423
xml_text & operator=(const char_t *rhs)
Definition pugixml.cpp:6532
bool operator!() const
Definition pugixml.cpp:6385
friend class xml_node
Definition pugixml.hpp:707
float as_float(float def=0) const
Definition pugixml.cpp:6430
xml_node_struct * _data_new()
Definition pugixml.cpp:6364
xml_node_struct * _root
Definition pugixml.hpp:709
bool as_bool(bool def=false) const
Definition pugixml.cpp:6437
xml_node data() const
Definition pugixml.cpp:6594
bool empty() const
Definition pugixml.cpp:6390
bool set(const char_t *rhs)
Definition pugixml.cpp:6460
xml_text(xml_node_struct *root)
Definition pugixml.cpp:6345
int as_int(int def=0) const
Definition pugixml.cpp:6409
unsigned int as_uint(unsigned int def=0) const
Definition pugixml.cpp:6416
void(*) unspecified_bool_type(xml_text ***)
Definition pugixml.hpp:711
const char_t * get() const
Definition pugixml.cpp:6395
xml_node_struct * _data() const
Definition pugixml.cpp:6349
friend class xml_node
Definition pugixml.hpp:923
virtual bool end(xml_node &node)
Definition pugixml.cpp:5096
virtual bool for_each(xml_node &node)=0
virtual bool begin(xml_node &node)
Definition pugixml.cpp:5091
xml_writer_file(void *file)
Definition pugixml.cpp:5042
virtual void write(const void *data, size_t size) PUGIXML_OVERRIDE
Definition pugixml.cpp:5046
xml_writer_stream(std::basic_ostream< char, std::char_traits< char > > &stream)
Definition pugixml.cpp:5053
std::basic_ostream< wchar_t, std::char_traits< wchar_t > > * wide_stream
Definition pugixml.hpp:339
virtual void write(const void *data, size_t size) PUGIXML_OVERRIDE
Definition pugixml.cpp:5061
std::basic_ostream< char, std::char_traits< char > > * narrow_stream
Definition pugixml.hpp:338
virtual ~xml_writer()
Definition pugixml.hpp:307
virtual void write(const void *data, size_t size)=0
const xpath_parse_result & result() const
xpath_exception(const xpath_parse_result &result)
virtual const char * what() const noexcept PUGIXML_OVERRIDE
xpath_parse_result _result
Definition pugixml.hpp:1261
type_t type() const
xpath_node_set & operator=(const xpath_node_set &ns)
void _assign(const_iterator begin, const_iterator end, type_t type)
const_iterator end() const
const xpath_node * const_iterator
Definition pugixml.hpp:1329
void sort(bool reverse=false)
const_iterator begin() const
xpath_node first() const
const xpath_node * iterator
Definition pugixml.hpp:1332
const xpath_node & operator[](size_t index) const
size_t size() const
xpath_node * _begin
Definition pugixml.hpp:1380
xpath_node * _end
Definition pugixml.hpp:1381
void _move(xpath_node_set &rhs) PUGIXML_NOEXCEPT
bool operator!() const
xml_node parent() const
xml_attribute attribute() const
xml_node node() const
void(*) unspecified_bool_type(xpath_node ***)
Definition pugixml.hpp:1282
bool operator!=(const xpath_node &n) const
xml_attribute _attribute
Definition pugixml.hpp:1280
bool operator==(const xpath_node &n) const
string_t evaluate_string(const xpath_node &n) const
void(*) unspecified_bool_type(xpath_query ***)
Definition pugixml.hpp:1189
bool operator!() const
double evaluate_number(const xpath_node &n) const
xpath_node_set evaluate_node_set(const xpath_node &n) const
xpath_value_type return_type() const
xpath_parse_result _result
Definition pugixml.hpp:1187
xpath_query & operator=(const xpath_query &)
xpath_query(const xpath_query &)
const xpath_parse_result & result() const
bool evaluate_boolean(const xpath_node &n) const
xpath_node evaluate_node(const xpath_node &n) const
xpath_variable * add(const char_t *name, xpath_value_type type)
void _swap(xpath_variable_set &rhs)
bool set(const char_t *name, bool value)
void _assign(const xpath_variable_set &rhs)
static void _destroy(xpath_variable *var)
static bool _clone(xpath_variable *var, xpath_variable **out_result)
xpath_variable * get(const char_t *name)
xpath_variable * _data[64]
Definition pugixml.hpp:1143
xpath_variable * _find(const char_t *name) const
xpath_variable_set & operator=(const xpath_variable_set &rhs)
xpath_variable * _next
Definition pugixml.hpp:1111
bool set(bool value)
xpath_variable(xpath_value_type type)
xpath_variable(const xpath_variable &)
double get_number() const
const char_t * get_string() const
bool get_boolean() const
const xpath_node_set & get_node_set() const
xpath_variable & operator=(const xpath_variable &)
xpath_value_type type() const
const char_t * name() const
friend class xpath_variable_set
Definition pugixml.hpp:1107
xpath_value_type _type
Definition pugixml.hpp:1110
const unsigned int format_no_empty_element_tags
Definition pugixml.hpp:256
xml_encoding
Definition pugixml.hpp:219
@ encoding_utf32
Definition pugixml.hpp:227
@ encoding_utf16_le
Definition pugixml.hpp:222
@ encoding_utf32_be
Definition pugixml.hpp:226
@ encoding_utf16_be
Definition pugixml.hpp:223
@ encoding_utf8
Definition pugixml.hpp:221
@ encoding_latin1
Definition pugixml.hpp:229
@ encoding_utf16
Definition pugixml.hpp:224
@ encoding_utf32_le
Definition pugixml.hpp:225
@ encoding_auto
Definition pugixml.hpp:220
@ encoding_wchar
Definition pugixml.hpp:228
std::basic_string< PUGIXML_CHAR, std::char_traits< PUGIXML_CHAR >, std::allocator< PUGIXML_CHAR > > string_t
Definition pugixml.hpp:132
PUGI__FN deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function()
Definition pugixml.cpp:7257
PUGI__FN allocation_function PUGIXML_FUNCTION get_memory_allocation_function()
Definition pugixml.cpp:7252
const unsigned int format_no_declaration
Definition pugixml.hpp:244
xml_node_type
Definition pugixml.hpp:141
@ node_comment
Definition pugixml.hpp:147
@ node_pcdata
Definition pugixml.hpp:145
@ node_element
Definition pugixml.hpp:144
@ node_doctype
Definition pugixml.hpp:150
@ node_document
Definition pugixml.hpp:143
@ node_declaration
Definition pugixml.hpp:149
@ node_pi
Definition pugixml.hpp:148
@ node_null
Definition pugixml.hpp:142
@ node_cdata
Definition pugixml.hpp:146
const unsigned int parse_trim_pcdata
Definition pugixml.hpp:196
const unsigned int parse_wconv_attribute
Definition pugixml.hpp:179
const unsigned int format_raw
Definition pugixml.hpp:241
const unsigned int format_default
Definition pugixml.hpp:260
const unsigned int parse_cdata
Definition pugixml.hpp:166
PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const wchar_t *str)
Definition pugixml.cpp:7221
const unsigned int parse_fragment
Definition pugixml.hpp:200
const unsigned int parse_full
Definition pugixml.hpp:215
const unsigned int parse_embed_pcdata
Definition pugixml.hpp:205
const unsigned int parse_wnorm_attribute
Definition pugixml.hpp:182
const unsigned int format_indent_attributes
Definition pugixml.hpp:253
const unsigned int parse_pi
Definition pugixml.hpp:160
xml_parse_status
Definition pugixml.hpp:948
@ status_append_invalid_root
Definition pugixml.hpp:968
@ status_end_element_mismatch
Definition pugixml.hpp:966
@ status_bad_end_element
Definition pugixml.hpp:965
@ status_io_error
Definition pugixml.hpp:952
@ status_bad_attribute
Definition pugixml.hpp:964
@ status_file_not_found
Definition pugixml.hpp:951
@ status_internal_error
Definition pugixml.hpp:954
@ status_bad_start_element
Definition pugixml.hpp:963
@ status_ok
Definition pugixml.hpp:949
@ status_bad_comment
Definition pugixml.hpp:959
@ status_bad_doctype
Definition pugixml.hpp:961
@ status_out_of_memory
Definition pugixml.hpp:953
@ status_unrecognized_tag
Definition pugixml.hpp:956
@ status_bad_cdata
Definition pugixml.hpp:960
@ status_bad_pcdata
Definition pugixml.hpp:962
@ status_bad_pi
Definition pugixml.hpp:958
@ status_no_document_element
Definition pugixml.hpp:970
const unsigned int format_save_file_text
Definition pugixml.hpp:250
const unsigned int parse_escapes
Definition pugixml.hpp:173
const unsigned int format_write_bom
Definition pugixml.hpp:238
PUGI__FN void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate)
Definition pugixml.cpp:7246
const unsigned int format_indent
Definition pugixml.hpp:235
const unsigned int parse_eol
Definition pugixml.hpp:176
const unsigned int parse_default
Definition pugixml.hpp:210
const unsigned int parse_declaration
Definition pugixml.hpp:185
const unsigned int parse_comments
Definition pugixml.hpp:163
PUGI__FN std::basic_string< wchar_t > PUGIXML_FUNCTION as_wide(const char *str)
Definition pugixml.cpp:7233
xpath_value_type
Definition pugixml.hpp:1077
@ xpath_type_number
Definition pugixml.hpp:1080
@ xpath_type_boolean
Definition pugixml.hpp:1082
@ xpath_type_none
Definition pugixml.hpp:1078
@ xpath_type_string
Definition pugixml.hpp:1081
@ xpath_type_node_set
Definition pugixml.hpp:1079
const unsigned int parse_ws_pcdata
Definition pugixml.hpp:170
const unsigned int parse_minimal
Definition pugixml.hpp:157
const unsigned int parse_ws_pcdata_single
Definition pugixml.hpp:193
const unsigned int format_no_escapes
Definition pugixml.hpp:247
void *(*) allocation_function(size_t size)
Definition pugixml.hpp:1399
PUGIXML_CHAR char_t
Definition pugixml.hpp:128
void(*) deallocation_function(void *ptr)
Definition pugixml.hpp:1402
const unsigned int parse_doctype
Definition pugixml.hpp:188
void reverse(I begin, I end)
Definition pugixml.cpp:7358
allocation_function xml_memory_management_function_storage< T >::allocate
Definition pugixml.cpp:209
deallocation_function xml_memory_management_function_storage< T >::deallocate
Definition pugixml.cpp:210
#define PUGIXML_DEPRECATED
Definition pugixml.hpp:47
#define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
Definition pugixml.hpp:102
#define PUGIXML_FUNCTION
Definition pugixml.hpp:63
#define PUGIXML_NOEXCEPT
Definition pugixml.hpp:85
#define PUGIXML_OVERRIDE
Definition pugixml.hpp:112
#define PUGIXML_CLASS
Definition pugixml.hpp:58
#define PUGIXML_TEXT(t)
Definition pugixml.hpp:121
#define PUGIXML_CHAR
Definition pugixml.hpp:122
const char * description() const
Definition pugixml.cpp:6812
xml_encoding encoding
Definition pugixml.hpp:983
xml_parse_status status
Definition pugixml.hpp:977
const char * description() const