Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
pugixml.h
Go to the documentation of this file.
1
14#pragma once
15
16#ifndef PUGIXML_VERSION
17// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons
18# define PUGIXML_VERSION 170
19#endif
20
21// Include user configuration file (this can define various configuration macros)
22#include "pugiconfig.h"
23
24// Include stddef.h for size_t and ptrdiff_t
25#include <stddef.h>
26
27// Include exception header for XPath
28#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
29# include <exception>
30#endif
31
32// Include STL headers
33#ifndef PUGIXML_NO_STL
34# include <iterator>
35# include <iosfwd>
36# include <string>
37#endif
38
39// Macro for deprecated features
40#ifndef PUGIXML_DEPRECATED
41# if defined(__GNUC__)
42# define PUGIXML_DEPRECATED __attribute__((deprecated))
43# elif defined(_MSC_VER) && _MSC_VER >= 1300
44# define PUGIXML_DEPRECATED __declspec(deprecated)
45# else
46# define PUGIXML_DEPRECATED
47# endif
48#endif
49
50// If no API is defined, assume default
51#ifndef PUGIXML_API
52# define PUGIXML_API
53#endif
54
55// If no API for classes is defined, assume default
56#ifndef PUGIXML_CLASS
57# define PUGIXML_CLASS PUGIXML_API
58#endif
59
60// If no API for functions is defined, assume default
61#ifndef PUGIXML_FUNCTION
62# define PUGIXML_FUNCTION PUGIXML_API
63#endif
64
65// If the platform is known to have long long support, enable long long functions
66#ifndef PUGIXML_HAS_LONG_LONG
67# if __cplusplus >= 201103
68# define PUGIXML_HAS_LONG_LONG
69# elif defined(_MSC_VER) && _MSC_VER >= 1400
70# define PUGIXML_HAS_LONG_LONG
71# endif
72#endif
73
74// Character interface macros
75#ifdef PUGIXML_WCHAR_MODE
76# define PUGIXML_TEXT(t) L ## t
77# define PUGIXML_CHAR wchar_t
78#else
79# define PUGIXML_TEXT(t) t
80# define PUGIXML_CHAR char
81#endif
82
83namespace pugi
84{
85 // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
87
88#ifndef PUGIXML_NO_STL
89 // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
90 using string_t = std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR>>;
91#endif
92}
93
94// The PugiXML namespace
95namespace pugi
96{
97 // Tree node types
99 {
100 node_null, // Empty (null) node handle
101 node_document, // A document tree's absolute root
102 node_element, // Element tag, i.e. '<node/>'
103 node_pcdata, // Plain character data, i.e. 'text'
104 node_cdata, // Character data, i.e. '<![CDATA[text]]>'
105 node_comment, // Comment tag, i.e. '<!-- text -->'
106 node_pi, // Processing instruction, i.e. '<?name?>'
107 node_declaration, // Document declaration, i.e. '<?xml version="1.0"?>'
108 node_doctype // Document type declaration, i.e. '<!DOCTYPE doc>'
109 };
110
111 // Parsing options
112
113 // Minimal parsing mode (equivalent to turning all other flags off).
114 // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed.
115 const unsigned int parse_minimal = 0x0000;
116
117 // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default.
118 const unsigned int parse_pi = 0x0001;
119
120 // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default.
121 const unsigned int parse_comments = 0x0002;
122
123 // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default.
124 const unsigned int parse_cdata = 0x0004;
125
126 // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree.
127 // This flag is off by default; turning it on usually results in slower parsing and more memory consumption.
128 const unsigned int parse_ws_pcdata = 0x0008;
129
130 // This flag determines if character and entity references are expanded during parsing. This flag is on by default.
131 const unsigned int parse_escapes = 0x0010;
132
133 // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
134 const unsigned int parse_eol = 0x0020;
135
136 // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
137 const unsigned int parse_wconv_attribute = 0x0040;
138
139 // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
140 const unsigned int parse_wnorm_attribute = 0x0080;
141
142 // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
143 const unsigned int parse_declaration = 0x0100;
144
145 // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default.
146 const unsigned int parse_doctype = 0x0200;
147
148 // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only
149 // of whitespace is added to the DOM tree.
150 // This flag is off by default; turning it on may result in slower parsing and more memory consumption.
151 const unsigned int parse_ws_pcdata_single = 0x0400;
152
153 // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default.
154 const unsigned int parse_trim_pcdata = 0x0800;
155
156 // 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
157 // is a valid document. This flag is off by default.
158 const unsigned int parse_fragment = 0x1000;
159
160 // This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of
161 // the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments.
162 // This flag is off by default.
163 const unsigned int parse_embed_pcdata = 0x2000;
164
165 // The default parsing mode.
166 // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
167 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
169
170 // The full parsing mode.
171 // Nodes of all types are added to the DOM tree, character/reference entities are expanded,
172 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
174
175 // These flags determine the encoding of input data for XML document
177 {
178 encoding_auto, // Auto-detect input encoding using BOM or < / <? detection; use UTF8 if BOM is not found
179 encoding_utf8, // UTF8 encoding
180 encoding_utf16_le, // Little-endian UTF16
181 encoding_utf16_be, // Big-endian UTF16
182 encoding_utf16, // UTF16 with native endianness
183 encoding_utf32_le, // Little-endian UTF32
184 encoding_utf32_be, // Big-endian UTF32
185 encoding_utf32, // UTF32 with native endianness
186 encoding_wchar, // The same encoding wchar_t has (either UTF16 or UTF32)
188 };
189
190 // Formatting flags
191
192 // 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.
193 const unsigned int format_indent = 0x01;
194
195 // Write encoding-specific BOM to the output stream. This flag is off by default.
196 const unsigned int format_write_bom = 0x02;
197
198 // Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
199 const unsigned int format_raw = 0x04;
200
201 // Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
202 const unsigned int format_no_declaration = 0x08;
203
204 // Don't escape attribute values and PCDATA contents. This flag is off by default.
205 const unsigned int format_no_escapes = 0x10;
206
207 // 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.
208 const unsigned int format_save_file_text = 0x20;
209
210 // Write every attribute on a new line with appropriate indentation. This flag is off by default.
211 const unsigned int format_indent_attributes = 0x40;
212
213 // The default set of formatting flags.
214 // Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
215 const unsigned int format_default = format_indent;
216
217 // Forward declarations
219 struct xml_node_struct;
220
221 class xml_node_iterator;
224
225 class xml_tree_walker;
226
227 struct xml_parse_result;
228
229 class xml_node;
230
231 class xml_text;
232
233 #ifndef PUGIXML_NO_XPATH
234 class xpath_node;
235 class xpath_node_set;
236 class xpath_query;
237 class xpath_variable_set;
238 #endif
239
240 // Range-based for loop support
241 template <typename It> class xml_object_range
242 {
243 public:
245 using iterator = It;
246
248 {
249 }
250
251 It begin() const { return _begin; }
252 It end() const { return _end; }
253
254 private:
256 };
257
258 // Writer interface for node printing (see xml_node::print)
260 {
261 public:
262 virtual ~xml_writer() {}
263
264 // Write memory chunk into stream/file/whatever
265 virtual void write(const void* data, size_t size) = 0;
266 };
267
268 // xml_writer implementation for FILE*
270 {
271 public:
272 // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio
273 xml_writer_file(void* file);
274
275 virtual void write(const void* data, size_t size);
276
277 private:
278 void* file;
279 };
280
281 #ifndef PUGIXML_NO_STL
282 // xml_writer implementation for streams
284 {
285 public:
286 // Construct writer from an output stream object
287 xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
288 xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
289
290 virtual void write(const void* data, size_t size);
291
292 private:
293 std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
294 std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
295 };
296 #endif
297
298 // A light-weight handle for manipulating attributes in DOM tree
300 {
302 friend class xml_node;
303
304 private:
306
308
309 public:
310 // Default constructor. Constructs an empty attribute.
312
313 // Constructs attribute from internal pointer
315
316 // Safe bool conversion operator
317 operator unspecified_bool_type() const;
318
319 // Borland C++ workaround
320 bool operator!() const;
321
322 // Comparison operators (compares wrapped attribute pointers)
323 bool operator==(const xml_attribute& r) const;
324 bool operator!=(const xml_attribute& r) const;
325 bool operator<(const xml_attribute& r) const;
326 bool operator>(const xml_attribute& r) const;
327 bool operator<=(const xml_attribute& r) const;
328 bool operator>=(const xml_attribute& r) const;
329
330 // Check if attribute is empty
331 bool empty() const;
332
333 // Get attribute name/value, or "" if attribute is empty
334 const char_t* name() const;
335 const char_t* value() const;
336
337 // Get attribute value, or the default value if attribute is empty
338 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
339
340 // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty
341 int as_int(int def = 0) const;
342 unsigned int as_uint(unsigned int def = 0) const;
343 double as_double(double def = 0) const;
344 float as_float(float def = 0) const;
345
346 #ifdef PUGIXML_HAS_LONG_LONG
347 long long as_llong(long long def = 0) const;
348 unsigned long long as_ullong(unsigned long long def = 0) const;
349 #endif
350
351 // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
352 bool as_bool(bool def = false) const;
353
354 // Set attribute name/value (returns false if attribute is empty or there is not enough memory)
355 bool set_name(const char_t* rhs);
356 bool set_value(const char_t* rhs);
357
358 // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
359 bool set_value(int rhs);
360 bool set_value(unsigned int rhs);
361 bool set_value(double rhs);
362 bool set_value(float rhs);
363 bool set_value(bool rhs);
364
365 #ifdef PUGIXML_HAS_LONG_LONG
366 bool set_value(long long rhs);
367 bool set_value(unsigned long long rhs);
368 #endif
369
370 // Set attribute value (equivalent to set_value without error checking)
373 xml_attribute& operator=(unsigned int rhs);
377
378 #ifdef PUGIXML_HAS_LONG_LONG
379 xml_attribute& operator=(long long rhs);
380 xml_attribute& operator=(unsigned long long rhs);
381 #endif
382
383 // Get next/previous attribute in the attribute list of the parent node
386
387 // Get hash value (unique for handles to the same object)
388 size_t hash_value() const;
389
390 // Get internal pointer
392 };
393
394#ifdef __BORLANDC__
395 // Borland C++ workaround
396 bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs);
397 bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs);
398#endif
399
400 // A light-weight handle for manipulating nodes in DOM tree
402 {
404 friend class xml_node_iterator;
406
407 protected:
409
411
412 public:
413 // Default constructor. Constructs an empty node.
415
416 // Constructs node from internal pointer
418
419 // Safe bool conversion operator
420 operator unspecified_bool_type() const;
421
422 // Borland C++ workaround
423 bool operator!() const;
424
425 // Comparison operators (compares wrapped node pointers)
426 bool operator==(const xml_node& r) const;
427 bool operator!=(const xml_node& r) const;
428 bool operator<(const xml_node& r) const;
429 bool operator>(const xml_node& r) const;
430 bool operator<=(const xml_node& r) const;
431 bool operator>=(const xml_node& r) const;
432
433 // Check if node is empty.
434 bool empty() const;
435
436 // Get node type
438
439 // Get node name, or "" if node is empty or it has no name
440 const char_t* name() const;
441
442 // Get node value, or "" if node is empty or it has no value
443 // Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
444 const char_t* value() const;
445
446 // Get attribute list
449
450 // Get children list
453
454 // Get next/previous sibling in the children list of the parent node
457
458 // Get parent node
460
461 // Get root of DOM tree this node belongs to
462 xml_node root() const;
463
464 // Get text object for the current node
465 xml_text text() const;
466
467 // Get child, attribute or next/previous sibling with the specified name
468 xml_node child(const char_t* name) const;
469 xml_attribute attribute(const char_t* name) const;
470 xml_node next_sibling(const char_t* name) const;
471 xml_node previous_sibling(const char_t* name) const;
472
473 // Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast)
475
476 // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
477 const char_t* child_value() const;
478
479 // Get child value of child with specified name. Equivalent to child(name).child_value().
480 const char_t* child_value(const char_t* name) const;
481
482 // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
483 bool set_name(const char_t* rhs);
484 bool set_value(const char_t* rhs);
485
486 // Add attribute with specified name. Returns added attribute, or empty attribute on errors.
491
492 // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors.
497
498 // Add child node with specified type. Returns added node, or empty node on errors.
499 xml_node append_child(xml_node_type type = node_element);
503
504 // Add child element with specified name. Returns added node, or empty node on errors.
507 xml_node insert_child_after(const char_t* name, const xml_node& node);
508 xml_node insert_child_before(const char_t* name, const xml_node& node);
509
510 // Add a copy of the specified node as a child. Returns added node, or empty node on errors.
515
516 // Move the specified node to become a child of this node. Returns moved node, or empty node on errors.
521
522 // Remove specified attribute
524 bool remove_attribute(const char_t* name);
525
526 // Remove specified child
527 bool remove_child(const xml_node& n);
528 bool remove_child(const char_t* name);
529
530 // Parses buffer as an XML document fragment and appends all nodes as children of the current node.
531 // Copies/converts the buffer, so it may be deleted or changed after the function returns.
532 // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory.
533 xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
534
535 // Find attribute using predicate. Returns first attribute for which predicate returned true.
536 template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
537 {
538 if (!_root) return xml_attribute();
539
540 for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
541 if (pred(attrib))
542 return attrib;
543
544 return xml_attribute();
545 }
546
547 // Find child node using predicate. Returns first child for which predicate returned true.
548 template <typename Predicate> xml_node find_child(Predicate pred) const
549 {
550 if (!_root) return xml_node();
551
552 for (xml_node node = first_child(); node; node = node.next_sibling())
553 if (pred(node))
554 return node;
555
556 return xml_node();
557 }
558
559 // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true.
560 template <typename Predicate> xml_node find_node(Predicate pred) const
561 {
562 if (!_root) return xml_node();
563
564 xml_node cur = first_child();
565
566 while (cur._root && cur._root != _root)
567 {
568 if (pred(cur)) return cur;
569
570 if (cur.first_child()) cur = cur.first_child();
571 else if (cur.next_sibling()) cur = cur.next_sibling();
572 else
573 {
574 while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
575
576 if (cur._root != _root) cur = cur.next_sibling();
577 }
578 }
579
580 return xml_node();
581 }
582
583 // Find child node by attribute name/value
586
587 #ifndef PUGIXML_NO_STL
588 // Get the absolute node path from root as a text string.
590 #endif
591
592 // Search for a node by path consisting of node names and . or .. elements.
594
595 // Recursively traverse subtree with xml_tree_walker
597
598 #ifndef PUGIXML_NO_XPATH
599 // Select single node by evaluating XPath query. Returns first node from the resulting node set.
602
603 // Select node set by evaluating XPath query
606
607 // (deprecated: use select_node instead) Select single node by evaluating XPath query.
610
611 #endif
612
613 // Print subtree using a writer object
614 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;
615
616 #ifndef PUGIXML_NO_STL
617 // Print subtree to stream
618 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;
619 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;
620 #endif
621
622 // Child nodes iterators
624
626 iterator end() const;
627
628 // Attribute iterators
630
633
634 // Range-based for support
638
639 // Get node offset in parsed file/string (in char_t units) for debugging purposes
641
642 // Get hash value (unique for handles to the same object)
643 size_t hash_value() const;
644
645 // Get internal pointer
647 };
648
649#ifdef __BORLANDC__
650 // Borland C++ workaround
651 bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs);
652 bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs);
653#endif
654
655 // A helper for working with text inside PCDATA nodes
657 {
658 friend class xml_node;
659
661
663
664 explicit xml_text(xml_node_struct* root);
665
668
669 public:
670 // Default constructor. Constructs an empty object.
672
673 // Safe bool conversion operator
674 operator unspecified_bool_type() const;
675
676 // Borland C++ workaround
677 bool operator!() const;
678
679 // Check if text object is empty
680 bool empty() const;
681
682 // Get text, or "" if object is empty
683 const char_t* get() const;
684
685 // Get text, or the default value if object is empty
686 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
687
688 // Get text as a number, or the default value if conversion did not succeed or object is empty
689 int as_int(int def = 0) const;
690 unsigned int as_uint(unsigned int def = 0) const;
691 double as_double(double def = 0) const;
692 float as_float(float def = 0) const;
693
694 #ifdef PUGIXML_HAS_LONG_LONG
695 long long as_llong(long long def = 0) const;
696 unsigned long long as_ullong(unsigned long long def = 0) const;
697 #endif
698
699 // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
700 bool as_bool(bool def = false) const;
701
702 // Set text (returns false if object is empty or there is not enough memory)
703 bool set(const char_t* rhs);
704
705 // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
706 bool set(int rhs);
707 bool set(unsigned int rhs);
708 bool set(double rhs);
709 bool set(float rhs);
710 bool set(bool rhs);
711
712 #ifdef PUGIXML_HAS_LONG_LONG
713 bool set(long long rhs);
714 bool set(unsigned long long rhs);
715 #endif
716
717 // Set text (equivalent to set without error checking)
720 xml_text& operator=(unsigned int rhs);
721 xml_text& operator=(double rhs);
722 xml_text& operator=(float rhs);
723 xml_text& operator=(bool rhs);
724
725 #ifdef PUGIXML_HAS_LONG_LONG
726 xml_text& operator=(long long rhs);
727 xml_text& operator=(unsigned long long rhs);
728 #endif
729
730 // Get the data node (node_pcdata or node_cdata) for this object
731 xml_node data() const;
732 };
733
734#ifdef __BORLANDC__
735 // Borland C++ workaround
736 bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs);
737 bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs);
738#endif
739
740 // Child node iterator (a bidirectional iterator over a collection of xml_node)
742 {
743 friend class xml_node;
744
745 private:
748
750
751 public:
752 // Iterator traits
757
758 #ifndef PUGIXML_NO_STL
759 using iterator_category = std::bidirectional_iterator_tag;
760 #endif
761
762 // Default constructor
764
765 // Construct an iterator which points to the specified node
767
768 // Iterator operators
769 bool operator==(const xml_node_iterator& rhs) const;
770 bool operator!=(const xml_node_iterator& rhs) const;
771
774
777
780 };
781
782 // Attribute iterator (a bidirectional iterator over a collection of xml_attribute)
784 {
785 friend class xml_node;
786
787 private:
790
792
793 public:
794 // Iterator traits
799
800 #ifndef PUGIXML_NO_STL
801 using iterator_category = std::bidirectional_iterator_tag;
802 #endif
803
804 // Default constructor
806
807 // Construct an iterator which points to the specified attribute
809
810 // Iterator operators
811 bool operator==(const xml_attribute_iterator& rhs) const;
812 bool operator!=(const xml_attribute_iterator& rhs) const;
813
816
819
822 };
823
824 // Named node range helper
826 {
827 friend class xml_node;
828
829 public:
830 // Iterator traits
835
836 #ifndef PUGIXML_NO_STL
837 using iterator_category = std::bidirectional_iterator_tag;
838 #endif
839
840 // Default constructor
842
843 // Construct an iterator which points to the specified node
844 xml_named_node_iterator(const xml_node& node, const char_t* name);
845
846 // Iterator operators
847 bool operator==(const xml_named_node_iterator& rhs) const;
848 bool operator!=(const xml_named_node_iterator& rhs) const;
849
852
855
858
859 private:
862 const char_t* _name;
863
865 };
866
867 // Abstract tree walker class (see xml_node::traverse)
869 {
870 friend class xml_node;
871
872 private:
874
875 protected:
876 // Get current traversal depth
877 int depth() const;
878
879 public:
882
883 // Callback that is called when traversal begins
884 virtual bool begin(xml_node& node);
885
886 // Callback that is called for each node traversed
887 virtual bool for_each(xml_node& node) = 0;
888
889 // Callback that is called when traversal ends
890 virtual bool end(xml_node& node);
891 };
892
893 // Parsing status, returned as part of xml_parse_result object
895 {
896 status_ok = 0, // No error
897
898 status_file_not_found, // File was not found during load_file()
899 status_io_error, // Error reading from file/stream
900 status_out_of_memory, // Could not allocate memory
901 status_internal_error, // Internal error occurred
902
903 status_unrecognized_tag, // Parser could not determine tag type
904
905 status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction
906 status_bad_comment, // Parsing error occurred while parsing comment
907 status_bad_cdata, // Parsing error occurred while parsing CDATA section
908 status_bad_doctype, // Parsing error occurred while parsing document type declaration
909 status_bad_pcdata, // Parsing error occurred while parsing PCDATA section
910 status_bad_start_element, // Parsing error occurred while parsing start element tag
911 status_bad_attribute, // Parsing error occurred while parsing element attribute
912 status_bad_end_element, // Parsing error occurred while parsing end element tag
913 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)
914
915 status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer)
916
917 status_no_document_element // Parsing resulted in a document without element nodes
918 };
919
920 // Parsing result
922 {
923 // Parsing status (see xml_parse_status)
925
926 // Last parsed offset (in char_t units from start of input data)
928
929 // Source document encoding
931
932 // Default constructor, initializes object to failed state
934
935 // Cast to bool operator
936 operator bool() const;
937
938 // Get error description
939 const char* description() const;
940 };
941
942 // Document class (DOM tree root)
944 {
945 private:
947
948 char _memory[192];
949
950 // Non-copyable semantics
953
954 void create();
955 void destroy();
956
957 public:
958 // Default constructor, makes empty document
960
961 // Destructor, invalidates all node/attribute handles to this document
963
964 // Removes all nodes, leaving the empty document
965 void reset();
966
967 // Removes all nodes, then copies the entire contents of the specified document
969
970 #ifndef PUGIXML_NO_STL
971 // Load document from stream.
972 xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
973 xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
974 #endif
975
976 // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
977 xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
978
979 // Load document from zero-terminated string. No encoding conversions are applied.
980 xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
981
982 // Load document from file
983 xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
984 xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
985
986 // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns.
987 xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
988
989 // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
990 // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed.
991 xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
992
993 // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
994 // 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).
995 xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
996
997 // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details).
998 void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
999
1000 #ifndef PUGIXML_NO_STL
1001 // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details).
1002 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;
1003 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;
1004 #endif
1005
1006 // Save XML to file
1007 bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1008 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;
1009
1010 // Get document element
1012 };
1013
1014#ifndef PUGIXML_NO_XPATH
1015 // XPath query return type
1017 {
1018 xpath_type_none, // Unknown type (query failed to compile)
1019 xpath_type_node_set, // Node set (xpath_node_set)
1022 xpath_type_boolean // Boolean
1024
1025 // XPath parsing result
1027 {
1028 // Error message (0 if no error)
1029 const char* error;
1030
1031 // Last parsed offset (in char_t units from string start)
1033
1034 // Default constructor, initializes object to failed state
1036
1037 // Cast to bool operator
1038 operator bool() const;
1039
1040 // Get error description
1041 const char* description() const;
1042 };
1043
1044 // A single XPath variable
1046 {
1048
1049 protected:
1052
1054
1055 // Non-copyable semantics
1058
1059 public:
1060 // Get variable name
1061 const char_t* name() const;
1062
1063 // Get variable type
1065
1066 // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error
1067 bool get_boolean() const;
1068 double get_number() const;
1069 const char_t* get_string() const;
1071
1072 // Set variable value; no type conversion is performed, false is returned on type mismatch error
1073 bool set(bool value);
1074 bool set(double value);
1075 bool set(const char_t* value);
1076 bool set(const xpath_node_set& value);
1077 };
1078
1079 // A set of XPath variables
1081 {
1082 private:
1083 xpath_variable* _data[64];
1084
1085 void _assign(const xpath_variable_set& rhs);
1087
1088 xpath_variable* _find(const char_t* name) const;
1089
1091 static void _destroy(xpath_variable* var);
1092
1093 public:
1094 // Default constructor/destructor
1097
1098 // Copy constructor/assignment operator
1101
1102 #if __cplusplus >= 201103
1103 // Move semantics support
1105 xpath_variable_set& operator=(xpath_variable_set&& rhs);
1106 #endif
1107
1108 // Add a new variable or get the existing one, if the types match
1110
1111 // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch
1112 bool set(const char_t* name, bool value);
1113 bool set(const char_t* name, double value);
1114 bool set(const char_t* name, const char_t* value);
1115 bool set(const char_t* name, const xpath_node_set& value);
1116
1117 // Get existing variable by name
1119 const xpath_variable* get(const char_t* name) const;
1120 };
1121
1122 // A compiled XPath query object
1124 {
1125 private:
1126 void* _impl;
1128
1130
1131 // Non-copyable semantics
1134
1135 public:
1136 // Construct a compiled object from XPath expression.
1137 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors.
1139
1140 // Constructor
1142
1143 // Destructor
1145
1146 #if __cplusplus >= 201103
1147 // Move semantics support
1148 xpath_query(xpath_query&& rhs);
1149 xpath_query& operator=(xpath_query&& rhs);
1150 #endif
1151
1152 // Get query expression return type
1154
1155 // Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
1156 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1157 bool evaluate_boolean(const xpath_node& n) const;
1158
1159 // Evaluate expression as double value in the specified context; performs type conversion if necessary.
1160 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1161 double evaluate_number(const xpath_node& n) const;
1162
1163 #ifndef PUGIXML_NO_STL
1164 // Evaluate expression as string value in the specified context; performs type conversion if necessary.
1165 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1167 #endif
1168
1169 // Evaluate expression as string value in the specified context; performs type conversion if necessary.
1170 // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
1171 // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
1172 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead.
1173 size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
1174
1175 // Evaluate expression as node set in the specified context.
1176 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
1177 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead.
1179
1180 // Evaluate expression as node set in the specified context.
1181 // Return first node in document order, or empty node if node set is empty.
1182 // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors.
1183 // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node instead.
1185
1186 // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode)
1188
1189 // Safe bool conversion operator
1190 operator unspecified_bool_type() const;
1191
1192 // Borland C++ workaround
1193 bool operator!() const;
1194 };
1195
1196 #ifndef PUGIXML_NO_EXCEPTIONS
1197 // XPath exception class
1198 class PUGIXML_CLASS xpath_exception: public std::exception
1199 {
1200 private:
1201 xpath_parse_result _result;
1202
1203 public:
1204 // Construct exception from parse result
1205 explicit xpath_exception(const xpath_parse_result& result);
1206
1207 // Get error message
1208 virtual const char* what() const throw();
1209
1210 // Get parse result
1211 const xpath_parse_result& result() const;
1212 };
1213 #endif
1214
1215 // XPath node class (either xml_node or xml_attribute)
1217 {
1218 private:
1221
1223
1224 public:
1225 // Default constructor; constructs empty XPath node
1227
1228 // Construct XPath node from XML node/attribute
1229 xpath_node(const xml_node& node);
1230 xpath_node(const xml_attribute& attribute, const xml_node& parent);
1231
1232 // Get node/attribute, if any
1235
1236 // Get parent of contained node/attribute
1238
1239 // Safe bool conversion operator
1240 operator unspecified_bool_type() const;
1241
1242 // Borland C++ workaround
1243 bool operator!() const;
1244
1245 // Comparison operators
1246 bool operator==(const xpath_node& n) const;
1247 bool operator!=(const xpath_node& n) const;
1248 };
1249
1250#ifdef __BORLANDC__
1251 // Borland C++ workaround
1252 bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs);
1253 bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs);
1254#endif
1255
1256 // A fixed-size collection of XPath nodes
1258 {
1259 public:
1260 // Collection type
1262 {
1263 type_unsorted, // Not ordered
1264 type_sorted, // Sorted by document order (ascending)
1265 type_sorted_reverse // Sorted by document order (descending)
1267
1268 // Constant iterator type
1270
1271 // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
1272 using iterator = const xpath_node*;
1273
1274 // Default constructor. Constructs empty set.
1276
1277 // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful
1278 xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
1279
1280 // Destructor
1282
1283 // Copy constructor/assignment operator
1286
1287 #if __cplusplus >= 201103
1288 // Move semantics support
1290 xpath_node_set& operator=(xpath_node_set&& rhs);
1291 #endif
1292
1293 // Get collection type
1294 type_t type() const;
1295
1296 // Get collection size
1297 size_t size() const;
1298
1299 // Indexing operator
1300 const xpath_node& operator[](size_t index) const;
1301
1302 // Collection iterators
1305
1306 // Sort the collection in ascending/descending order by document order
1307 void sort(bool reverse = false);
1308
1309 // Get first node in the collection by document order
1311
1312 // Check if collection is empty
1313 bool empty() const;
1314
1315 private:
1317
1319
1322
1325 };
1326#endif
1327
1328#ifndef PUGIXML_NO_STL
1329 // Convert wide string to UTF8
1330 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
1331 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);
1332
1333 // Convert UTF8 to wide string
1334 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
1335 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);
1336#endif
1337
1338 // Memory allocation function interface; returns pointer to allocated memory or NULL on failure
1339 using allocation_function = void* (*)(size_t size);
1340
1341 // Memory deallocation function interface
1342 using deallocation_function = void (*)(void* ptr);
1343
1344 // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
1346
1347 // Get current memory management functions
1350}
1351
1352#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
1353namespace std
1354{
1355 // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier)
1356 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&);
1357 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&);
1358 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&);
1359}
1360#endif
1361
1362#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
1363namespace std
1364{
1365 // Workarounds for (non-standard) iterator category detection
1366 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&);
1367 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&);
1368 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&);
1369}
1370#endif
1371
1372// Make sure implementation is included in header-only mode
1373// Use macro expansion in #include to work around QMake (QTBUG-11923)
1374#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
1375# define PUGIXML_SOURCE "pugixml.cpp"
1376# include PUGIXML_SOURCE
1377#endif
1378
std::bidirectional_iterator_tag iterator_category
Definition pugixml.h:801
xml_attribute * operator->() const
const xml_attribute_iterator & operator--()
xml_attribute_iterator operator--(int)
xml_attribute_iterator operator++(int)
xml_attribute_iterator(xml_attribute_struct *ref, xml_node_struct *parent)
const xml_attribute_iterator & operator++()
xml_attribute_iterator(const xml_attribute &attr, const xml_node &parent)
bool operator==(const xml_attribute_iterator &rhs) const
bool operator!=(const xml_attribute_iterator &rhs) const
xml_attribute & operator*() const
void(*)(xml_attribute ***) unspecified_bool_type
Definition pugixml.h:307
bool operator>(const xml_attribute &r) const
bool set_value(unsigned long long rhs)
unsigned long long as_ullong(unsigned long long def=0) const
bool operator<=(const xml_attribute &r) const
xml_attribute & operator=(unsigned int rhs)
xml_attribute & operator=(const char_t *rhs)
xml_attribute next_attribute() const
xml_attribute & operator=(long long rhs)
size_t hash_value() const
xml_attribute_struct * internal_object() const
xml_attribute(xml_attribute_struct *attr)
bool operator!() const
bool as_bool(bool def=false) const
const char_t * value() const
float as_float(float def=0) const
xml_attribute & operator=(unsigned long long rhs)
const char_t * name() const
bool set_value(const char_t *rhs)
bool set_value(double rhs)
bool set_value(long long rhs)
bool empty() const
bool operator>=(const xml_attribute &r) const
bool operator==(const xml_attribute &r) const
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const
double as_double(double def=0) const
bool operator<(const xml_attribute &r) const
unsigned int as_uint(unsigned int def=0) const
xml_attribute_struct * _attr
Definition pugixml.h:305
bool set_value(int rhs)
xml_attribute previous_attribute() const
bool set_value(unsigned int rhs)
bool operator!=(const xml_attribute &r) const
long long as_llong(long long def=0) const
xml_attribute & operator=(float rhs)
xml_attribute & operator=(double rhs)
bool set_name(const char_t *rhs)
bool set_value(float rhs)
xml_attribute & operator=(bool rhs)
xml_attribute & operator=(int rhs)
int as_int(int def=0) const
bool set_value(bool rhs)
xml_parse_result load_buffer_inplace_own(void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_parse_result load_file(const char *path, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_parse_result load(std::basic_istream< char, std::char_traits< char > > &stream, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
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
xml_document(const xml_document &)
void save(xml_writer &writer, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
xml_parse_result load_string(const char_t *contents, unsigned int options=parse_default)
xml_parse_result load_file(const wchar_t *path, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_parse_result load(std::basic_istream< wchar_t, std::char_traits< wchar_t > > &stream, unsigned int options=parse_default)
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
xml_node document_element() const
xml_document & operator=(const xml_document &)
void reset(const xml_document &proto)
xml_parse_result load_buffer_inplace(void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
char_t * _buffer
Definition pugixml.h:946
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
bool save_file(const char *path, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
xml_parse_result load(const char_t *contents, unsigned int options=parse_default)
xml_parse_result load_buffer(const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_named_node_iterator(xml_node_struct *ref, xml_node_struct *parent, const char_t *name)
bool operator!=(const xml_named_node_iterator &rhs) const
const xml_named_node_iterator & operator++()
xml_named_node_iterator(const xml_node &node, const char_t *name)
xml_named_node_iterator operator--(int)
xml_node & operator*() const
xml_named_node_iterator operator++(int)
xml_node * operator->() const
std::bidirectional_iterator_tag iterator_category
Definition pugixml.h:837
bool operator==(const xml_named_node_iterator &rhs) const
const xml_named_node_iterator & operator--()
std::bidirectional_iterator_tag iterator_category
Definition pugixml.h:759
bool operator==(const xml_node_iterator &rhs) const
const xml_node_iterator & operator--()
xml_node_iterator(xml_node_struct *ref, xml_node_struct *parent)
ptrdiff_t difference_type
Definition pugixml.h:753
xml_node_iterator(const xml_node &node)
xml_node_iterator operator--(int)
bool operator!=(const xml_node_iterator &rhs) const
const xml_node_iterator & operator++()
xml_node_iterator operator++(int)
xml_node * operator->() const
xml_node & operator*() const
xpath_node select_single_node(const char_t *query, xpath_variable_set *variables=0) const
void(*)(xml_node ***) unspecified_bool_type
Definition pugixml.h:410
xml_node insert_copy_after(const xml_node &proto, const xml_node &node)
bool remove_child(const xml_node &n)
xml_node insert_move_before(const xml_node &moved, const xml_node &node)
iterator begin() const
xml_node insert_child_before(const char_t *name, const xml_node &node)
xml_node prepend_copy(const xml_node &proto)
const char_t * value() const
bool operator>=(const xml_node &r) const
bool operator<=(const xml_node &r) const
xml_node insert_move_after(const xml_node &moved, const xml_node &node)
xml_node find_child_by_attribute(const char_t *attr_name, const char_t *attr_value) const
xml_node prepend_move(const xml_node &moved)
xml_node next_sibling(const char_t *name) const
xml_attribute first_attribute() const
xml_attribute insert_copy_after(const xml_attribute &proto, const xml_attribute &attr)
bool operator!=(const xml_node &r) const
xml_attribute insert_attribute_after(const char_t *name, const xml_attribute &attr)
bool traverse(xml_tree_walker &walker)
xml_attribute find_attribute(Predicate pred) const
Definition pugixml.h:536
xml_node prepend_child(xml_node_type type=node_element)
xml_node_struct * _root
Definition pugixml.h:408
xml_attribute append_attribute(const char_t *name)
xpath_node select_node(const xpath_query &query) const
xml_node append_child(xml_node_type type=node_element)
xml_node first_element_by_path(const char_t *path, char_t delimiter='/') const
xml_node_struct * internal_object() const
xml_node append_copy(const xml_node &proto)
xml_object_range< xml_node_iterator > children() const
const char_t * name() const
xml_attribute insert_attribute_before(const char_t *name, const xml_attribute &attr)
xml_node(xml_node_struct *p)
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
xml_node find_child_by_attribute(const char_t *name, const char_t *attr_name, const char_t *attr_value) const
xml_object_range< xml_attribute_iterator > attributes() const
xml_node previous_sibling(const char_t *name) const
bool set_name(const char_t *rhs)
xml_node root() const
xml_attribute prepend_attribute(const char_t *name)
ptrdiff_t offset_debug() const
xml_node first_child() const
xml_node append_child(const char_t *name)
xml_node previous_sibling() const
xml_attribute prepend_copy(const xml_attribute &proto)
xml_node append_move(const xml_node &moved)
xml_object_range< xml_named_node_iterator > children(const char_t *name) const
xml_node insert_copy_before(const xml_node &proto, const xml_node &node)
bool remove_child(const char_t *name)
xml_attribute attribute(const char_t *name) const
xml_node find_node(Predicate pred) const
Definition pugixml.h:560
xpath_node select_node(const char_t *query, xpath_variable_set *variables=0) const
bool operator<(const xml_node &r) const
attribute_iterator attributes_begin() const
iterator end() const
bool operator==(const xml_node &r) const
xml_attribute last_attribute() const
xml_attribute insert_copy_before(const xml_attribute &proto, const xml_attribute &attr)
bool remove_attribute(const char_t *name)
xml_parse_result append_buffer(const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_node insert_child_before(xml_node_type type, const xml_node &node)
xml_node parent() const
bool operator!() const
xml_node last_child() const
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
const char_t * child_value() const
xml_attribute append_copy(const xml_attribute &proto)
size_t hash_value() const
xml_text text() const
xml_node prepend_child(const char_t *name)
xml_node_type type() const
xml_node find_child(Predicate pred) const
Definition pugixml.h:548
xml_attribute attribute(const char_t *name, xml_attribute &hint) const
xml_node insert_child_after(const char_t *name, const xml_node &node)
bool remove_attribute(const xml_attribute &a)
const char_t * child_value(const char_t *name) const
string_t path(char_t delimiter='/') const
bool empty() const
xpath_node_set select_nodes(const xpath_query &query) const
bool operator>(const xml_node &r) const
xml_node next_sibling() const
xpath_node_set select_nodes(const char_t *query, xpath_variable_set *variables=0) const
xpath_node select_single_node(const xpath_query &query) const
attribute_iterator attributes_end() const
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
xml_node child(const char_t *name) const
xml_node insert_child_after(xml_node_type type, const xml_node &node)
bool set_value(const char_t *rhs)
xml_object_range(It b, It e)
Definition pugixml.h:247
bool empty() const
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const
xml_text(xml_node_struct *root)
double as_double(double def=0) const
float as_float(float def=0) const
int as_int(int def=0) const
xml_node_struct * _data() const
bool set(float rhs)
xml_text & operator=(double rhs)
xml_text & operator=(int rhs)
bool set(unsigned int rhs)
xml_node_struct * _root
Definition pugixml.h:660
xml_text & operator=(long long rhs)
xml_text & operator=(unsigned long long rhs)
bool set(double rhs)
xml_text & operator=(bool rhs)
bool as_bool(bool def=false) const
bool set(const char_t *rhs)
long long as_llong(long long def=0) const
bool set(long long rhs)
xml_node_struct * _data_new()
bool set(int rhs)
unsigned long long as_ullong(unsigned long long def=0) const
bool operator!() const
void(*)(xml_text ***) unspecified_bool_type
Definition pugixml.h:662
bool set(unsigned long long rhs)
bool set(bool rhs)
xml_text & operator=(float rhs)
unsigned int as_uint(unsigned int def=0) const
xml_node data() const
const char_t * get() const
xml_text & operator=(const char_t *rhs)
xml_text & operator=(unsigned int rhs)
virtual bool for_each(xml_node &node)=0
virtual ~xml_tree_walker()
virtual bool end(xml_node &node)
virtual bool begin(xml_node &node)
virtual void write(const void *data, size_t size)
xml_writer_file(void *file)
xml_writer_stream(std::basic_ostream< wchar_t, std::char_traits< wchar_t > > &stream)
std::basic_ostream< wchar_t, std::char_traits< wchar_t > > * wide_stream
Definition pugixml.h:294
xml_writer_stream(std::basic_ostream< char, std::char_traits< char > > &stream)
virtual void write(const void *data, size_t size)
std::basic_ostream< char, std::char_traits< char > > * narrow_stream
Definition pugixml.h:293
virtual ~xml_writer()
Definition pugixml.h:262
virtual void write(const void *data, size_t size)=0
const_iterator begin() const
xpath_node_set(const_iterator begin, const_iterator end, type_t type=type_unsorted)
void sort(bool reverse=false)
xpath_node_set(const xpath_node_set &ns)
const_iterator end() const
xpath_node first() const
const xpath_node & operator[](size_t index) const
bool empty() const
void _assign(const_iterator begin, const_iterator end, type_t type)
xpath_node * _begin
Definition pugixml.h:1320
size_t size() const
void _move(xpath_node_set &rhs)
xpath_node_set & operator=(const xpath_node_set &ns)
type_t type() const
xpath_node * _end
Definition pugixml.h:1321
xpath_node _storage
Definition pugixml.h:1318
xml_node parent() const
xml_attribute attribute() const
bool operator!=(const xpath_node &n) const
xml_node _node
Definition pugixml.h:1219
xml_node node() const
void(*)(xpath_node ***) unspecified_bool_type
Definition pugixml.h:1222
xpath_node(const xml_attribute &attribute, const xml_node &parent)
bool operator==(const xpath_node &n) const
bool operator!() const
xpath_node(const xml_node &node)
xml_attribute _attribute
Definition pugixml.h:1220
xpath_node_set evaluate_node_set(const xpath_node &n) const
string_t evaluate_string(const xpath_node &n) const
xpath_query(const char_t *query, xpath_variable_set *variables=0)
size_t evaluate_string(char_t *buffer, size_t capacity, const xpath_node &n) const
xpath_parse_result _result
Definition pugixml.h:1127
xpath_node evaluate_node(const xpath_node &n) const
xpath_query & operator=(const xpath_query &)
double evaluate_number(const xpath_node &n) const
void(*)(xpath_query ***) unspecified_bool_type
Definition pugixml.h:1129
const xpath_parse_result & result() const
xpath_query(const xpath_query &)
xpath_value_type return_type() const
bool evaluate_boolean(const xpath_node &n) const
bool operator!() const
void _swap(xpath_variable_set &rhs)
const xpath_variable * get(const char_t *name) const
xpath_variable * _find(const char_t *name) const
xpath_variable_set & operator=(const xpath_variable_set &rhs)
bool set(const char_t *name, const xpath_node_set &value)
bool set(const char_t *name, bool value)
bool set(const char_t *name, const char_t *value)
bool set(const char_t *name, double value)
xpath_variable * get(const char_t *name)
static bool _clone(xpath_variable *var, xpath_variable **out_result)
void _assign(const xpath_variable_set &rhs)
static void _destroy(xpath_variable *var)
xpath_variable_set(const xpath_variable_set &rhs)
xpath_variable * add(const char_t *name, xpath_value_type type)
xpath_variable * _next
Definition pugixml.h:1051
bool set(const char_t *value)
xpath_variable(const xpath_variable &)
bool get_boolean() const
xpath_value_type type() const
xpath_variable(xpath_value_type type)
double get_number() const
const xpath_node_set & get_node_set() const
const char_t * get_string() const
const char_t * name() const
bool set(bool value)
xpath_variable & operator=(const xpath_variable &)
bool set(double value)
bool set(const xpath_node_set &value)
xpath_value_type _type
Definition pugixml.h:1050
int r[]
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
Definition pugixml.h:84
void(*)(void *ptr) deallocation_function
Definition pugixml.h:1342
xml_encoding
Definition pugixml.h:177
@ encoding_utf32
Definition pugixml.h:185
@ encoding_utf16_le
Definition pugixml.h:180
@ encoding_utf32_be
Definition pugixml.h:184
@ encoding_utf16_be
Definition pugixml.h:181
@ encoding_utf8
Definition pugixml.h:179
@ encoding_latin1
Definition pugixml.h:187
@ encoding_utf16
Definition pugixml.h:182
@ encoding_utf32_le
Definition pugixml.h:183
@ encoding_auto
Definition pugixml.h:178
@ encoding_wchar
Definition pugixml.h:186
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function()
allocation_function PUGIXML_FUNCTION get_memory_allocation_function()
const unsigned int format_no_declaration
Definition pugixml.h:202
xml_node_type
Definition pugixml.h:99
@ node_comment
Definition pugixml.h:105
@ node_pcdata
Definition pugixml.h:103
@ node_element
Definition pugixml.h:102
@ node_doctype
Definition pugixml.h:108
@ node_document
Definition pugixml.h:101
@ node_declaration
Definition pugixml.h:107
@ node_pi
Definition pugixml.h:106
@ node_null
Definition pugixml.h:100
@ node_cdata
Definition pugixml.h:104
const unsigned int parse_trim_pcdata
Definition pugixml.h:154
const unsigned int parse_wconv_attribute
Definition pugixml.h:137
const unsigned int format_raw
Definition pugixml.h:199
PUGIXML_CHAR char_t
Definition pugixml.h:86
const unsigned int format_default
Definition pugixml.h:215
const unsigned int parse_cdata
Definition pugixml.h:124
std::basic_string< char, std::char_traits< char >, std::allocator< char > > PUGIXML_FUNCTION as_utf8(const wchar_t *str)
const unsigned int parse_fragment
Definition pugixml.h:158
const unsigned int parse_full
Definition pugixml.h:173
const unsigned int parse_embed_pcdata
Definition pugixml.h:163
const unsigned int parse_wnorm_attribute
Definition pugixml.h:140
const unsigned int format_indent_attributes
Definition pugixml.h:211
const unsigned int parse_pi
Definition pugixml.h:118
xml_parse_status
Definition pugixml.h:895
@ status_append_invalid_root
Definition pugixml.h:915
@ status_end_element_mismatch
Definition pugixml.h:913
@ status_bad_end_element
Definition pugixml.h:912
@ status_io_error
Definition pugixml.h:899
@ status_bad_attribute
Definition pugixml.h:911
@ status_file_not_found
Definition pugixml.h:898
@ status_internal_error
Definition pugixml.h:901
@ status_bad_start_element
Definition pugixml.h:910
@ status_ok
Definition pugixml.h:896
@ status_bad_comment
Definition pugixml.h:906
@ status_bad_doctype
Definition pugixml.h:908
@ status_out_of_memory
Definition pugixml.h:900
@ status_unrecognized_tag
Definition pugixml.h:903
@ status_bad_cdata
Definition pugixml.h:907
@ status_bad_pcdata
Definition pugixml.h:909
@ status_bad_pi
Definition pugixml.h:905
@ status_no_document_element
Definition pugixml.h:917
const unsigned int format_save_file_text
Definition pugixml.h:208
const unsigned int parse_escapes
Definition pugixml.h:131
const unsigned int format_write_bom
Definition pugixml.h:196
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate)
const unsigned int format_indent
Definition pugixml.h:193
const unsigned int parse_eol
Definition pugixml.h:134
const unsigned int parse_default
Definition pugixml.h:168
const unsigned int parse_declaration
Definition pugixml.h:143
const unsigned int parse_comments
Definition pugixml.h:121
std::basic_string< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > PUGIXML_FUNCTION as_wide(const char *str)
xpath_value_type
Definition pugixml.h:1017
@ xpath_type_number
Definition pugixml.h:1020
@ xpath_type_boolean
Definition pugixml.h:1022
@ xpath_type_none
Definition pugixml.h:1018
@ xpath_type_string
Definition pugixml.h:1021
@ xpath_type_node_set
Definition pugixml.h:1019
const unsigned int parse_ws_pcdata
Definition pugixml.h:128
const unsigned int parse_minimal
Definition pugixml.h:115
void *(*)(size_t size) allocation_function
Definition pugixml.h:1339
const unsigned int parse_ws_pcdata_single
Definition pugixml.h:151
std::basic_string< PUGIXML_CHAR, std::char_traits< PUGIXML_CHAR >, std::allocator< PUGIXML_CHAR > > string_t
Definition pugixml.h:90
const unsigned int format_no_escapes
Definition pugixml.h:205
const unsigned int parse_doctype
Definition pugixml.h:146
Definition GML.h:110
#define PUGIXML_FUNCTION
Definition pugixml.h:62
#define PUGIXML_CLASS
Definition pugixml.h:57
#define PUGIXML_TEXT(t)
Definition pugixml.h:79
#define PUGIXML_CHAR
Definition pugixml.h:80
const char * description() const
xml_encoding encoding
Definition pugixml.h:930
xml_parse_status status
Definition pugixml.h:924
const char * description() const