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/
7 * This library is distributed under the MIT License. See notice at the end
10 * This work is based on the pugxml parser, which is:
11 * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
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
19 // Include user configuration file (this can define various configuration macros)
20 #include "pugiconfig.hpp"
22 #ifndef HEADER_PUGIXML_HPP
23 #define HEADER_PUGIXML_HPP
25 // Include stddef.h for size_t and ptrdiff_t
28 // Include exception header for XPath
29 #if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
33 // Include STL headers
34 #ifndef PUGIXML_NO_STL
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)
47 # define PUGIXML_DEPRECATED
51 // If no API is defined, assume default
56 // If no API for classes is defined, assume default
58 # define PUGIXML_CLASS PUGIXML_API
61 // If no API for functions is defined, assume default
62 #ifndef PUGIXML_FUNCTION
63 # define PUGIXML_FUNCTION PUGIXML_API
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
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
84 // If C++ is 2011 or higher, add 'noexcept' specifiers
85 #ifndef PUGIXML_NOEXCEPT
86 # if __cplusplus >= 201103
87 # define PUGIXML_NOEXCEPT noexcept
88 # elif defined(_MSC_VER) && _MSC_VER >= 1900
89 # define PUGIXML_NOEXCEPT noexcept
91 # define PUGIXML_NOEXCEPT
95 // Some functions can not be noexcept in compact mode
96 #ifdef PUGIXML_COMPACT
97 # define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
99 # define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
102 // If C++ is 2011 or higher, add 'override' qualifiers
103 #ifndef PUGIXML_OVERRIDE
104 # if __cplusplus >= 201103
105 # define PUGIXML_OVERRIDE override
106 # elif defined(_MSC_VER) && _MSC_VER >= 1700
107 # define PUGIXML_OVERRIDE override
109 # define PUGIXML_OVERRIDE
113 // Character interface macros
114 #ifdef PUGIXML_WCHAR_MODE
115 # define PUGIXML_TEXT(t) L ## t
116 # define PUGIXML_CHAR wchar_t
118 # define PUGIXML_TEXT(t) t
119 # define PUGIXML_CHAR char
124 // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
125 typedef PUGIXML_CHAR char_t;
127 #ifndef PUGIXML_NO_STL
128 // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
129 typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t;
133 // The PugiXML namespace
139 node_null, // Empty (null) node handle
140 node_document, // A document tree's absolute root
141 node_element, // Element tag, i.e. '<node/>'
142 node_pcdata, // Plain character data, i.e. 'text'
143 node_cdata, // Character data, i.e. '<![CDATA[text]]>'
144 node_comment, // Comment tag, i.e. '<!-- text -->'
145 node_pi, // Processing instruction, i.e. '<?name?>'
146 node_declaration, // Document declaration, i.e. '<?xml version="1.0"?>'
147 node_doctype // Document type declaration, i.e. '<!DOCTYPE doc>'
152 // Minimal parsing mode (equivalent to turning all other flags off).
153 // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed.
154 const unsigned int parse_minimal = 0x0000;
156 // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default.
157 const unsigned int parse_pi = 0x0001;
159 // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default.
160 const unsigned int parse_comments = 0x0002;
162 // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default.
163 const unsigned int parse_cdata = 0x0004;
165 // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree.
166 // This flag is off by default; turning it on usually results in slower parsing and more memory consumption.
167 const unsigned int parse_ws_pcdata = 0x0008;
169 // This flag determines if character and entity references are expanded during parsing. This flag is on by default.
170 const unsigned int parse_escapes = 0x0010;
172 // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
173 const unsigned int parse_eol = 0x0020;
175 // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
176 const unsigned int parse_wconv_attribute = 0x0040;
178 // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
179 const unsigned int parse_wnorm_attribute = 0x0080;
181 // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
182 const unsigned int parse_declaration = 0x0100;
184 // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default.
185 const unsigned int parse_doctype = 0x0200;
187 // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only
188 // of whitespace is added to the DOM tree.
189 // This flag is off by default; turning it on may result in slower parsing and more memory consumption.
190 const unsigned int parse_ws_pcdata_single = 0x0400;
192 // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default.
193 const unsigned int parse_trim_pcdata = 0x0800;
195 // 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
196 // is a valid document. This flag is off by default.
197 const unsigned int parse_fragment = 0x1000;
199 // This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of
200 // the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments.
201 // This flag is off by default.
202 const unsigned int parse_embed_pcdata = 0x2000;
204 // The default parsing mode.
205 // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
206 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
207 const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol;
209 // The full parsing mode.
210 // Nodes of all types are added to the DOM tree, character/reference entities are expanded,
211 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
212 const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype;
214 // These flags determine the encoding of input data for XML document
217 encoding_auto, // Auto-detect input encoding using BOM or < / <? detection; use UTF8 if BOM is not found
218 encoding_utf8, // UTF8 encoding
219 encoding_utf16_le, // Little-endian UTF16
220 encoding_utf16_be, // Big-endian UTF16
221 encoding_utf16, // UTF16 with native endianness
222 encoding_utf32_le, // Little-endian UTF32
223 encoding_utf32_be, // Big-endian UTF32
224 encoding_utf32, // UTF32 with native endianness
225 encoding_wchar, // The same encoding wchar_t has (either UTF16 or UTF32)
231 // 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.
232 const unsigned int format_indent = 0x01;
234 // Write encoding-specific BOM to the output stream. This flag is off by default.
235 const unsigned int format_write_bom = 0x02;
237 // Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
238 const unsigned int format_raw = 0x04;
240 // Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
241 const unsigned int format_no_declaration = 0x08;
243 // Don't escape attribute values and PCDATA contents. This flag is off by default.
244 const unsigned int format_no_escapes = 0x10;
246 // 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.
247 const unsigned int format_save_file_text = 0x20;
249 // Write every attribute on a new line with appropriate indentation. This flag is off by default.
250 const unsigned int format_indent_attributes = 0x40;
252 // 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.
253 const unsigned int format_no_empty_element_tags = 0x80;
255 // The default set of formatting flags.
256 // Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
257 const unsigned int format_default = format_indent;
259 // Forward declarations
260 struct xml_attribute_struct;
261 struct xml_node_struct;
263 class xml_node_iterator;
264 class xml_attribute_iterator;
265 class xml_named_node_iterator;
267 class xml_tree_walker;
269 struct xml_parse_result;
275 #ifndef PUGIXML_NO_XPATH
277 class xpath_node_set;
279 class xpath_variable_set;
282 // Range-based for loop support
283 template <typename It> class xml_object_range
286 typedef It const_iterator;
289 xml_object_range(It b, It e): _begin(b), _end(e)
293 It begin() const { return _begin; }
294 It end() const { return _end; }
300 // Writer interface for node printing (see xml_node::print)
301 class PUGIXML_CLASS xml_writer
304 virtual ~xml_writer() {}
306 // Write memory chunk into stream/file/whatever
307 virtual void write(const void* data, size_t size) = 0;
310 // xml_writer implementation for FILE*
311 class PUGIXML_CLASS xml_writer_file: public xml_writer
314 // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio
315 xml_writer_file(void* file);
317 virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
323 #ifndef PUGIXML_NO_STL
324 // xml_writer implementation for streams
325 class PUGIXML_CLASS xml_writer_stream: public xml_writer
328 // Construct writer from an output stream object
329 xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
330 xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
332 virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
335 std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
336 std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
340 // A light-weight handle for manipulating attributes in DOM tree
341 class PUGIXML_CLASS xml_attribute
343 friend class xml_attribute_iterator;
344 friend class xml_node;
347 xml_attribute_struct* _attr;
349 typedef void (*unspecified_bool_type)(xml_attribute***);
352 // Default constructor. Constructs an empty attribute.
355 // Constructs attribute from internal pointer
356 explicit xml_attribute(xml_attribute_struct* attr);
358 // Safe bool conversion operator
359 operator unspecified_bool_type() const;
361 // Borland C++ workaround
362 bool operator!() const;
364 // Comparison operators (compares wrapped attribute pointers)
365 bool operator==(const xml_attribute& r) const;
366 bool operator!=(const xml_attribute& r) const;
367 bool operator<(const xml_attribute& r) const;
368 bool operator>(const xml_attribute& r) const;
369 bool operator<=(const xml_attribute& r) const;
370 bool operator>=(const xml_attribute& r) const;
372 // Check if attribute is empty
375 // Get attribute name/value, or "" if attribute is empty
376 const char_t* name() const;
377 const char_t* value() const;
379 // Get attribute value, or the default value if attribute is empty
380 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
382 // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty
383 int as_int(int def = 0) const;
384 unsigned int as_uint(unsigned int def = 0) const;
385 double as_double(double def = 0) const;
386 float as_float(float def = 0) const;
388 #ifdef PUGIXML_HAS_LONG_LONG
389 long long as_llong(long long def = 0) const;
390 unsigned long long as_ullong(unsigned long long def = 0) const;
393 // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
394 bool as_bool(bool def = false) const;
396 // Set attribute name/value (returns false if attribute is empty or there is not enough memory)
397 bool set_name(const char_t* rhs);
398 bool set_value(const char_t* rhs);
400 // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
401 bool set_value(int rhs);
402 bool set_value(unsigned int rhs);
403 bool set_value(long rhs);
404 bool set_value(unsigned long rhs);
405 bool set_value(double rhs);
406 bool set_value(float rhs);
407 bool set_value(bool rhs);
409 #ifdef PUGIXML_HAS_LONG_LONG
410 bool set_value(long long rhs);
411 bool set_value(unsigned long long rhs);
414 // Set attribute value (equivalent to set_value without error checking)
415 xml_attribute& operator=(const char_t* rhs);
416 xml_attribute& operator=(int rhs);
417 xml_attribute& operator=(unsigned int rhs);
418 xml_attribute& operator=(long rhs);
419 xml_attribute& operator=(unsigned long rhs);
420 xml_attribute& operator=(double rhs);
421 xml_attribute& operator=(float rhs);
422 xml_attribute& operator=(bool rhs);
424 #ifdef PUGIXML_HAS_LONG_LONG
425 xml_attribute& operator=(long long rhs);
426 xml_attribute& operator=(unsigned long long rhs);
429 // Get next/previous attribute in the attribute list of the parent node
430 xml_attribute next_attribute() const;
431 xml_attribute previous_attribute() const;
433 // Get hash value (unique for handles to the same object)
434 size_t hash_value() const;
436 // Get internal pointer
437 xml_attribute_struct* internal_object() const;
441 // Borland C++ workaround
442 bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs);
443 bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs);
446 // A light-weight handle for manipulating nodes in DOM tree
447 class PUGIXML_CLASS xml_node
449 friend class xml_attribute_iterator;
450 friend class xml_node_iterator;
451 friend class xml_named_node_iterator;
454 xml_node_struct* _root;
456 typedef void (*unspecified_bool_type)(xml_node***);
459 // Default constructor. Constructs an empty node.
462 // Constructs node from internal pointer
463 explicit xml_node(xml_node_struct* p);
465 // Safe bool conversion operator
466 operator unspecified_bool_type() const;
468 // Borland C++ workaround
469 bool operator!() const;
471 // Comparison operators (compares wrapped node pointers)
472 bool operator==(const xml_node& r) const;
473 bool operator!=(const xml_node& r) const;
474 bool operator<(const xml_node& r) const;
475 bool operator>(const xml_node& r) const;
476 bool operator<=(const xml_node& r) const;
477 bool operator>=(const xml_node& r) const;
479 // Check if node is empty.
483 xml_node_type type() const;
485 // Get node name, or "" if node is empty or it has no name
486 const char_t* name() const;
488 // Get node value, or "" if node is empty or it has no value
489 // Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
490 const char_t* value() const;
492 // Get attribute list
493 xml_attribute first_attribute() const;
494 xml_attribute last_attribute() const;
497 xml_node first_child() const;
498 xml_node last_child() const;
500 // Get next/previous sibling in the children list of the parent node
501 xml_node next_sibling() const;
502 xml_node previous_sibling() const;
505 xml_node parent() const;
507 // Get root of DOM tree this node belongs to
508 xml_node root() const;
510 // Get text object for the current node
511 xml_text text() const;
513 // Get child, attribute or next/previous sibling with the specified name
514 xml_node child(const char_t* name) const;
515 xml_attribute attribute(const char_t* name) const;
516 xml_node next_sibling(const char_t* name) const;
517 xml_node previous_sibling(const char_t* name) const;
519 // Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast)
520 xml_attribute attribute(const char_t* name, xml_attribute& hint) const;
522 // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
523 const char_t* child_value() const;
525 // Get child value of child with specified name. Equivalent to child(name).child_value().
526 const char_t* child_value(const char_t* name) const;
528 // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
529 bool set_name(const char_t* rhs);
530 bool set_value(const char_t* rhs);
532 // Add attribute with specified name. Returns added attribute, or empty attribute on errors.
533 xml_attribute append_attribute(const char_t* name);
534 xml_attribute prepend_attribute(const char_t* name);
535 xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
536 xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
538 // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors.
539 xml_attribute append_copy(const xml_attribute& proto);
540 xml_attribute prepend_copy(const xml_attribute& proto);
541 xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
542 xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
544 // Add child node with specified type. Returns added node, or empty node on errors.
545 xml_node append_child(xml_node_type type = node_element);
546 xml_node prepend_child(xml_node_type type = node_element);
547 xml_node insert_child_after(xml_node_type type, const xml_node& node);
548 xml_node insert_child_before(xml_node_type type, const xml_node& node);
550 // Add child element with specified name. Returns added node, or empty node on errors.
551 xml_node append_child(const char_t* name);
552 xml_node prepend_child(const char_t* name);
553 xml_node insert_child_after(const char_t* name, const xml_node& node);
554 xml_node insert_child_before(const char_t* name, const xml_node& node);
556 // Add a copy of the specified node as a child. Returns added node, or empty node on errors.
557 xml_node append_copy(const xml_node& proto);
558 xml_node prepend_copy(const xml_node& proto);
559 xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
560 xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
562 // Move the specified node to become a child of this node. Returns moved node, or empty node on errors.
563 xml_node append_move(const xml_node& moved);
564 xml_node prepend_move(const xml_node& moved);
565 xml_node insert_move_after(const xml_node& moved, const xml_node& node);
566 xml_node insert_move_before(const xml_node& moved, const xml_node& node);
568 // Remove specified attribute
569 bool remove_attribute(const xml_attribute& a);
570 bool remove_attribute(const char_t* name);
572 // Remove specified child
573 bool remove_child(const xml_node& n);
574 bool remove_child(const char_t* name);
576 // Parses buffer as an XML document fragment and appends all nodes as children of the current node.
577 // Copies/converts the buffer, so it may be deleted or changed after the function returns.
578 // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory.
579 xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
581 // Find attribute using predicate. Returns first attribute for which predicate returned true.
582 template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
584 if (!_root) return xml_attribute();
586 for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
590 return xml_attribute();
593 // Find child node using predicate. Returns first child for which predicate returned true.
594 template <typename Predicate> xml_node find_child(Predicate pred) const
596 if (!_root) return xml_node();
598 for (xml_node node = first_child(); node; node = node.next_sibling())
605 // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true.
606 template <typename Predicate> xml_node find_node(Predicate pred) const
608 if (!_root) return xml_node();
610 xml_node cur = first_child();
612 while (cur._root && cur._root != _root)
614 if (pred(cur)) return cur;
616 if (cur.first_child()) cur = cur.first_child();
617 else if (cur.next_sibling()) cur = cur.next_sibling();
620 while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
622 if (cur._root != _root) cur = cur.next_sibling();
629 // Find child node by attribute name/value
630 xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
631 xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
633 #ifndef PUGIXML_NO_STL
634 // Get the absolute node path from root as a text string.
635 string_t path(char_t delimiter = '/') const;
638 // Search for a node by path consisting of node names and . or .. elements.
639 xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
641 // Recursively traverse subtree with xml_tree_walker
642 bool traverse(xml_tree_walker& walker);
644 #ifndef PUGIXML_NO_XPATH
645 // Select single node by evaluating XPath query. Returns first node from the resulting node set.
646 xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
647 xpath_node select_node(const xpath_query& query) const;
649 // Select node set by evaluating XPath query
650 xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
651 xpath_node_set select_nodes(const xpath_query& query) const;
653 // (deprecated: use select_node instead) Select single node by evaluating XPath query.
654 PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
655 PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
659 // Print subtree using a writer object
660 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;
662 #ifndef PUGIXML_NO_STL
663 // Print subtree to stream
664 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;
665 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;
668 // Child nodes iterators
669 typedef xml_node_iterator iterator;
671 iterator begin() const;
672 iterator end() const;
674 // Attribute iterators
675 typedef xml_attribute_iterator attribute_iterator;
677 attribute_iterator attributes_begin() const;
678 attribute_iterator attributes_end() const;
680 // Range-based for support
681 xml_object_range<xml_node_iterator> children() const;
682 xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
683 xml_object_range<xml_attribute_iterator> attributes() const;
685 // Get node offset in parsed file/string (in char_t units) for debugging purposes
686 ptrdiff_t offset_debug() const;
688 // Get hash value (unique for handles to the same object)
689 size_t hash_value() const;
691 // Get internal pointer
692 xml_node_struct* internal_object() const;
696 // Borland C++ workaround
697 bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs);
698 bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs);
701 // A helper for working with text inside PCDATA nodes
702 class PUGIXML_CLASS xml_text
704 friend class xml_node;
706 xml_node_struct* _root;
708 typedef void (*unspecified_bool_type)(xml_text***);
710 explicit xml_text(xml_node_struct* root);
712 xml_node_struct* _data_new();
713 xml_node_struct* _data() const;
716 // Default constructor. Constructs an empty object.
719 // Safe bool conversion operator
720 operator unspecified_bool_type() const;
722 // Borland C++ workaround
723 bool operator!() const;
725 // Check if text object is empty
728 // Get text, or "" if object is empty
729 const char_t* get() const;
731 // Get text, or the default value if object is empty
732 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
734 // Get text as a number, or the default value if conversion did not succeed or object is empty
735 int as_int(int def = 0) const;
736 unsigned int as_uint(unsigned int def = 0) const;
737 double as_double(double def = 0) const;
738 float as_float(float def = 0) const;
740 #ifdef PUGIXML_HAS_LONG_LONG
741 long long as_llong(long long def = 0) const;
742 unsigned long long as_ullong(unsigned long long def = 0) const;
745 // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
746 bool as_bool(bool def = false) const;
748 // Set text (returns false if object is empty or there is not enough memory)
749 bool set(const char_t* rhs);
751 // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
753 bool set(unsigned int rhs);
755 bool set(unsigned long rhs);
756 bool set(double rhs);
760 #ifdef PUGIXML_HAS_LONG_LONG
761 bool set(long long rhs);
762 bool set(unsigned long long rhs);
765 // Set text (equivalent to set without error checking)
766 xml_text& operator=(const char_t* rhs);
767 xml_text& operator=(int rhs);
768 xml_text& operator=(unsigned int rhs);
769 xml_text& operator=(long rhs);
770 xml_text& operator=(unsigned long rhs);
771 xml_text& operator=(double rhs);
772 xml_text& operator=(float rhs);
773 xml_text& operator=(bool rhs);
775 #ifdef PUGIXML_HAS_LONG_LONG
776 xml_text& operator=(long long rhs);
777 xml_text& operator=(unsigned long long rhs);
780 // Get the data node (node_pcdata or node_cdata) for this object
781 xml_node data() const;
785 // Borland C++ workaround
786 bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs);
787 bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs);
790 // Child node iterator (a bidirectional iterator over a collection of xml_node)
791 class PUGIXML_CLASS xml_node_iterator
793 friend class xml_node;
796 mutable xml_node _wrap;
799 xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent);
803 typedef ptrdiff_t difference_type;
804 typedef xml_node value_type;
805 typedef xml_node* pointer;
806 typedef xml_node& reference;
808 #ifndef PUGIXML_NO_STL
809 typedef std::bidirectional_iterator_tag iterator_category;
812 // Default constructor
815 // Construct an iterator which points to the specified node
816 xml_node_iterator(const xml_node& node);
818 // Iterator operators
819 bool operator==(const xml_node_iterator& rhs) const;
820 bool operator!=(const xml_node_iterator& rhs) const;
822 xml_node& operator*() const;
823 xml_node* operator->() const;
825 const xml_node_iterator& operator++();
826 xml_node_iterator operator++(int);
828 const xml_node_iterator& operator--();
829 xml_node_iterator operator--(int);
832 // Attribute iterator (a bidirectional iterator over a collection of xml_attribute)
833 class PUGIXML_CLASS xml_attribute_iterator
835 friend class xml_node;
838 mutable xml_attribute _wrap;
841 xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
845 typedef ptrdiff_t difference_type;
846 typedef xml_attribute value_type;
847 typedef xml_attribute* pointer;
848 typedef xml_attribute& reference;
850 #ifndef PUGIXML_NO_STL
851 typedef std::bidirectional_iterator_tag iterator_category;
854 // Default constructor
855 xml_attribute_iterator();
857 // Construct an iterator which points to the specified attribute
858 xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
860 // Iterator operators
861 bool operator==(const xml_attribute_iterator& rhs) const;
862 bool operator!=(const xml_attribute_iterator& rhs) const;
864 xml_attribute& operator*() const;
865 xml_attribute* operator->() const;
867 const xml_attribute_iterator& operator++();
868 xml_attribute_iterator operator++(int);
870 const xml_attribute_iterator& operator--();
871 xml_attribute_iterator operator--(int);
874 // Named node range helper
875 class PUGIXML_CLASS xml_named_node_iterator
877 friend class xml_node;
881 typedef ptrdiff_t difference_type;
882 typedef xml_node value_type;
883 typedef xml_node* pointer;
884 typedef xml_node& reference;
886 #ifndef PUGIXML_NO_STL
887 typedef std::bidirectional_iterator_tag iterator_category;
890 // Default constructor
891 xml_named_node_iterator();
893 // Construct an iterator which points to the specified node
894 xml_named_node_iterator(const xml_node& node, const char_t* name);
896 // Iterator operators
897 bool operator==(const xml_named_node_iterator& rhs) const;
898 bool operator!=(const xml_named_node_iterator& rhs) const;
900 xml_node& operator*() const;
901 xml_node* operator->() const;
903 const xml_named_node_iterator& operator++();
904 xml_named_node_iterator operator++(int);
906 const xml_named_node_iterator& operator--();
907 xml_named_node_iterator operator--(int);
910 mutable xml_node _wrap;
914 xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name);
917 // Abstract tree walker class (see xml_node::traverse)
918 class PUGIXML_CLASS xml_tree_walker
920 friend class xml_node;
926 // Get current traversal depth
931 virtual ~xml_tree_walker();
933 // Callback that is called when traversal begins
934 virtual bool begin(xml_node& node);
936 // Callback that is called for each node traversed
937 virtual bool for_each(xml_node& node) = 0;
939 // Callback that is called when traversal ends
940 virtual bool end(xml_node& node);
943 // Parsing status, returned as part of xml_parse_result object
944 enum xml_parse_status
946 status_ok = 0, // No error
948 status_file_not_found, // File was not found during load_file()
949 status_io_error, // Error reading from file/stream
950 status_out_of_memory, // Could not allocate memory
951 status_internal_error, // Internal error occurred
953 status_unrecognized_tag, // Parser could not determine tag type
955 status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction
956 status_bad_comment, // Parsing error occurred while parsing comment
957 status_bad_cdata, // Parsing error occurred while parsing CDATA section
958 status_bad_doctype, // Parsing error occurred while parsing document type declaration
959 status_bad_pcdata, // Parsing error occurred while parsing PCDATA section
960 status_bad_start_element, // Parsing error occurred while parsing start element tag
961 status_bad_attribute, // Parsing error occurred while parsing element attribute
962 status_bad_end_element, // Parsing error occurred while parsing end element tag
963 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)
965 status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer)
967 status_no_document_element // Parsing resulted in a document without element nodes
971 struct PUGIXML_CLASS xml_parse_result
973 // Parsing status (see xml_parse_status)
974 xml_parse_status status;
976 // Last parsed offset (in char_t units from start of input data)
979 // Source document encoding
980 xml_encoding encoding;
982 // Default constructor, initializes object to failed state
985 // Cast to bool operator
986 operator bool() const;
988 // Get error description
989 const char* description() const;
992 // Document class (DOM tree root)
993 class PUGIXML_CLASS xml_document: public xml_node
1000 // Non-copyable semantics
1001 xml_document(const xml_document&);
1002 xml_document& operator=(const xml_document&);
1006 void _move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1009 // Default constructor, makes empty document
1012 // Destructor, invalidates all node/attribute handles to this document
1015 #ifdef PUGIXML_HAS_MOVE
1016 // Move semantics support
1017 xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1018 xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1021 // Removes all nodes, leaving the empty document
1024 // Removes all nodes, then copies the entire contents of the specified document
1025 void reset(const xml_document& proto);
1027 #ifndef PUGIXML_NO_STL
1028 // Load document from stream.
1029 xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1030 xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
1033 // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
1034 PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
1036 // Load document from zero-terminated string. No encoding conversions are applied.
1037 xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
1039 // Load document from file
1040 xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1041 xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1043 // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns.
1044 xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1046 // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
1047 // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed.
1048 xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1050 // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
1051 // 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).
1052 xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1054 // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details).
1055 void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1057 #ifndef PUGIXML_NO_STL
1058 // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details).
1059 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;
1060 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 bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1065 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;
1067 // Get document element
1068 xml_node document_element() const;
1071 #ifndef PUGIXML_NO_XPATH
1072 // XPath query return type
1073 enum xpath_value_type
1075 xpath_type_none, // Unknown type (query failed to compile)
1076 xpath_type_node_set, // Node set (xpath_node_set)
1077 xpath_type_number, // Number
1078 xpath_type_string, // String
1079 xpath_type_boolean // Boolean
1082 // XPath parsing result
1083 struct PUGIXML_CLASS xpath_parse_result
1085 // Error message (0 if no error)
1088 // Last parsed offset (in char_t units from string start)
1091 // Default constructor, initializes object to failed state
1092 xpath_parse_result();
1094 // Cast to bool operator
1095 operator bool() const;
1097 // Get error description
1098 const char* description() const;
1101 // A single XPath variable
1102 class PUGIXML_CLASS xpath_variable
1104 friend class xpath_variable_set;
1107 xpath_value_type _type;
1108 xpath_variable* _next;
1110 xpath_variable(xpath_value_type type);
1112 // Non-copyable semantics
1113 xpath_variable(const xpath_variable&);
1114 xpath_variable& operator=(const xpath_variable&);
1117 // Get variable name
1118 const char_t* name() const;
1120 // Get variable type
1121 xpath_value_type type() const;
1123 // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error
1124 bool get_boolean() const;
1125 double get_number() const;
1126 const char_t* get_string() const;
1127 const xpath_node_set& get_node_set() const;
1129 // Set variable value; no type conversion is performed, false is returned on type mismatch error
1130 bool set(bool value);
1131 bool set(double value);
1132 bool set(const char_t* value);
1133 bool set(const xpath_node_set& value);
1136 // A set of XPath variables
1137 class PUGIXML_CLASS xpath_variable_set
1140 xpath_variable* _data[64];
1142 void _assign(const xpath_variable_set& rhs);
1143 void _swap(xpath_variable_set& rhs);
1145 xpath_variable* _find(const char_t* name) const;
1147 static bool _clone(xpath_variable* var, xpath_variable** out_result);
1148 static void _destroy(xpath_variable* var);
1151 // Default constructor/destructor
1152 xpath_variable_set();
1153 ~xpath_variable_set();
1155 // Copy constructor/assignment operator
1156 xpath_variable_set(const xpath_variable_set& rhs);
1157 xpath_variable_set& operator=(const xpath_variable_set& rhs);
1159 #ifdef PUGIXML_HAS_MOVE
1160 // Move semantics support
1161 xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
1162 xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
1165 // Add a new variable or get the existing one, if the types match
1166 xpath_variable* add(const char_t* name, xpath_value_type type);
1168 // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch
1169 bool set(const char_t* name, bool value);
1170 bool set(const char_t* name, double value);
1171 bool set(const char_t* name, const char_t* value);
1172 bool set(const char_t* name, const xpath_node_set& value);
1174 // Get existing variable by name
1175 xpath_variable* get(const char_t* name);
1176 const xpath_variable* get(const char_t* name) const;
1179 // A compiled XPath query object
1180 class PUGIXML_CLASS xpath_query
1184 xpath_parse_result _result;
1186 typedef void (*unspecified_bool_type)(xpath_query***);
1188 // Non-copyable semantics
1189 xpath_query(const xpath_query&);
1190 xpath_query& operator=(const xpath_query&);
1193 // Construct a compiled object from XPath expression.
1194 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors.
1195 explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0);
1203 #ifdef PUGIXML_HAS_MOVE
1204 // Move semantics support
1205 xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
1206 xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
1209 // Get query expression return type
1210 xpath_value_type return_type() const;
1212 // Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
1213 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1214 bool evaluate_boolean(const xpath_node& n) const;
1216 // Evaluate expression as double value in the specified context; performs type conversion if necessary.
1217 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1218 double evaluate_number(const xpath_node& n) const;
1220 #ifndef PUGIXML_NO_STL
1221 // Evaluate expression as string value in the specified context; performs type conversion if necessary.
1222 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1223 string_t evaluate_string(const xpath_node& n) const;
1226 // Evaluate expression as string value in the specified context; performs type conversion if necessary.
1227 // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
1228 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1229 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead.
1230 size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
1232 // Evaluate expression as node set in the specified context.
1233 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
1234 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead.
1235 xpath_node_set evaluate_node_set(const xpath_node& n) const;
1237 // Evaluate expression as node set in the specified context.
1238 // Return first node in document order, or empty node if node set is empty.
1239 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
1240 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node instead.
1241 xpath_node evaluate_node(const xpath_node& n) const;
1243 // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode)
1244 const xpath_parse_result& result() const;
1246 // Safe bool conversion operator
1247 operator unspecified_bool_type() const;
1249 // Borland C++ workaround
1250 bool operator!() const;
1253 #ifndef PUGIXML_NO_EXCEPTIONS
1254 // XPath exception class
1255 class PUGIXML_CLASS xpath_exception: public std::exception
1258 xpath_parse_result _result;
1261 // Construct exception from parse result
1262 explicit xpath_exception(const xpath_parse_result& result);
1264 // Get error message
1265 virtual const char* what() const throw() PUGIXML_OVERRIDE;
1268 const xpath_parse_result& result() const;
1272 // XPath node class (either xml_node or xml_attribute)
1273 class PUGIXML_CLASS xpath_node
1277 xml_attribute _attribute;
1279 typedef void (*unspecified_bool_type)(xpath_node***);
1282 // Default constructor; constructs empty XPath node
1285 // Construct XPath node from XML node/attribute
1286 xpath_node(const xml_node& node);
1287 xpath_node(const xml_attribute& attribute, const xml_node& parent);
1289 // Get node/attribute, if any
1290 xml_node node() const;
1291 xml_attribute attribute() const;
1293 // Get parent of contained node/attribute
1294 xml_node parent() const;
1296 // Safe bool conversion operator
1297 operator unspecified_bool_type() const;
1299 // Borland C++ workaround
1300 bool operator!() const;
1302 // Comparison operators
1303 bool operator==(const xpath_node& n) const;
1304 bool operator!=(const xpath_node& n) const;
1308 // Borland C++ workaround
1309 bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs);
1310 bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs);
1313 // A fixed-size collection of XPath nodes
1314 class PUGIXML_CLASS xpath_node_set
1320 type_unsorted, // Not ordered
1321 type_sorted, // Sorted by document order (ascending)
1322 type_sorted_reverse // Sorted by document order (descending)
1325 // Constant iterator type
1326 typedef const xpath_node* const_iterator;
1328 // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
1329 typedef const xpath_node* iterator;
1331 // Default constructor. Constructs empty set.
1334 // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful
1335 xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
1340 // Copy constructor/assignment operator
1341 xpath_node_set(const xpath_node_set& ns);
1342 xpath_node_set& operator=(const xpath_node_set& ns);
1344 #ifdef PUGIXML_HAS_MOVE
1345 // Move semantics support
1346 xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
1347 xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
1350 // Get collection type
1351 type_t type() const;
1353 // Get collection size
1354 size_t size() const;
1356 // Indexing operator
1357 const xpath_node& operator[](size_t index) const;
1359 // Collection iterators
1360 const_iterator begin() const;
1361 const_iterator end() const;
1363 // Sort the collection in ascending/descending order by document order
1364 void sort(bool reverse = false);
1366 // Get first node in the collection by document order
1367 xpath_node first() const;
1369 // Check if collection is empty
1375 xpath_node _storage;
1380 void _assign(const_iterator begin, const_iterator end, type_t type);
1381 void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT;
1385 #ifndef PUGIXML_NO_STL
1386 // Convert wide string to UTF8
1387 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
1388 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);
1390 // Convert UTF8 to wide string
1391 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
1392 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);
1395 // Memory allocation function interface; returns pointer to allocated memory or NULL on failure
1396 typedef void* (*allocation_function)(size_t size);
1398 // Memory deallocation function interface
1399 typedef void (*deallocation_function)(void* ptr);
1401 // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
1402 void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
1404 // Get current memory management functions
1405 allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
1406 deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
1409 #if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
1412 // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier)
1413 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&);
1414 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&);
1415 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&);
1419 #if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
1422 // Workarounds for (non-standard) iterator category detection
1423 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&);
1424 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&);
1425 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&);
1431 // Make sure implementation is included in header-only mode
1432 // Use macro expansion in #include to work around QMake (QTBUG-11923)
1433 #if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
1434 # define PUGIXML_SOURCE "pugixml.cpp"
1435 # include PUGIXML_SOURCE
1439 * Copyright (c) 2006-2018 Arseny Kapoulkine
1441 * Permission is hereby granted, free of charge, to any person
1442 * obtaining a copy of this software and associated documentation
1443 * files (the "Software"), to deal in the Software without
1444 * restriction, including without limitation the rights to use,
1445 * copy, modify, merge, publish, distribute, sublicense, and/or sell
1446 * copies of the Software, and to permit persons to whom the
1447 * Software is furnished to do so, subject to the following
1450 * The above copyright notice and this permission notice shall be
1451 * included in all copies or substantial portions of the Software.
1453 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1454 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1455 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1456 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1457 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1458 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1459 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1460 * OTHER DEALINGS IN THE SOFTWARE.