Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
83 namespace 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
95 namespace 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
218  struct xml_attribute_struct;
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:
244  using const_iterator = It;
245  using iterator = It;
246 
247  xml_object_range(It b, It e): _begin(b), _end(e)
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:
305  xml_attribute_struct* _attr;
306 
307  using unspecified_bool_type = void (*)(xml_attribute***);
308 
309  public:
310  // Default constructor. Constructs an empty attribute.
311  xml_attribute();
312 
313  // Constructs attribute from internal pointer
314  explicit xml_attribute(xml_attribute_struct* attr);
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)
371  xml_attribute& operator=(const char_t* rhs);
372  xml_attribute& operator=(int rhs);
373  xml_attribute& operator=(unsigned int rhs);
374  xml_attribute& operator=(double rhs);
375  xml_attribute& operator=(float rhs);
376  xml_attribute& operator=(bool 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
384  xml_attribute next_attribute() const;
385  xml_attribute previous_attribute() const;
386 
387  // Get hash value (unique for handles to the same object)
388  size_t hash_value() const;
389 
390  // Get internal pointer
391  xml_attribute_struct* internal_object() const;
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:
408  xml_node_struct* _root;
409 
410  using unspecified_bool_type = void (*)(xml_node***);
411 
412  public:
413  // Default constructor. Constructs an empty node.
414  xml_node();
415 
416  // Constructs node from internal pointer
417  explicit xml_node(xml_node_struct* p);
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
437  xml_node_type type() const;
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
447  xml_attribute first_attribute() const;
448  xml_attribute last_attribute() const;
449 
450  // Get children list
451  xml_node first_child() const;
452  xml_node last_child() const;
453 
454  // Get next/previous sibling in the children list of the parent node
455  xml_node next_sibling() const;
456  xml_node previous_sibling() const;
457 
458  // Get parent node
459  xml_node parent() const;
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)
474  xml_attribute attribute(const char_t* name, xml_attribute& hint) const;
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.
487  xml_attribute append_attribute(const char_t* name);
488  xml_attribute prepend_attribute(const char_t* name);
489  xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
490  xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
491 
492  // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors.
493  xml_attribute append_copy(const xml_attribute& proto);
494  xml_attribute prepend_copy(const xml_attribute& proto);
495  xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
496  xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
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);
500  xml_node prepend_child(xml_node_type type = node_element);
501  xml_node insert_child_after(xml_node_type type, const xml_node& node);
502  xml_node insert_child_before(xml_node_type type, const xml_node& node);
503 
504  // Add child element with specified name. Returns added node, or empty node on errors.
505  xml_node append_child(const char_t* name);
506  xml_node prepend_child(const char_t* name);
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.
511  xml_node append_copy(const xml_node& proto);
512  xml_node prepend_copy(const xml_node& proto);
513  xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
514  xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
515 
516  // Move the specified node to become a child of this node. Returns moved node, or empty node on errors.
517  xml_node append_move(const xml_node& moved);
518  xml_node prepend_move(const xml_node& moved);
519  xml_node insert_move_after(const xml_node& moved, const xml_node& node);
520  xml_node insert_move_before(const xml_node& moved, const xml_node& node);
521 
522  // Remove specified attribute
523  bool remove_attribute(const xml_attribute& a);
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
584  xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
585  xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
586 
587  #ifndef PUGIXML_NO_STL
588  // Get the absolute node path from root as a text string.
589  string_t path(char_t delimiter = '/') const;
590  #endif
591 
592  // Search for a node by path consisting of node names and . or .. elements.
593  xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
594 
595  // Recursively traverse subtree with xml_tree_walker
596  bool traverse(xml_tree_walker& walker);
597 
598  #ifndef PUGIXML_NO_XPATH
599  // Select single node by evaluating XPath query. Returns first node from the resulting node set.
600  xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
601  xpath_node select_node(const xpath_query& query) const;
602 
603  // Select node set by evaluating XPath query
604  xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
605  xpath_node_set select_nodes(const xpath_query& query) const;
606 
607  // (deprecated: use select_node instead) Select single node by evaluating XPath query.
608  xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
609  xpath_node select_single_node(const xpath_query& query) const;
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 
625  iterator begin() const;
626  iterator end() const;
627 
628  // Attribute iterators
630 
631  attribute_iterator attributes_begin() const;
632  attribute_iterator attributes_end() const;
633 
634  // Range-based for support
635  xml_object_range<xml_node_iterator> children() const;
636  xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
637  xml_object_range<xml_attribute_iterator> attributes() const;
638 
639  // Get node offset in parsed file/string (in char_t units) for debugging purposes
640  ptrdiff_t offset_debug() const;
641 
642  // Get hash value (unique for handles to the same object)
643  size_t hash_value() const;
644 
645  // Get internal pointer
646  xml_node_struct* internal_object() const;
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 
660  xml_node_struct* _root;
661 
662  using unspecified_bool_type = void (*)(xml_text***);
663 
664  explicit xml_text(xml_node_struct* root);
665 
666  xml_node_struct* _data_new();
667  xml_node_struct* _data() const;
668 
669  public:
670  // Default constructor. Constructs an empty object.
671  xml_text();
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)
718  xml_text& operator=(const char_t* rhs);
719  xml_text& operator=(int rhs);
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:
746  mutable xml_node _wrap;
748 
749  xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent);
750 
751  public:
752  // Iterator traits
753  using difference_type = ptrdiff_t;
755  using pointer = xml_node*;
756  using reference = xml_node&;
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 
772  xml_node& operator*() const;
773  xml_node* operator->() const;
774 
775  const xml_node_iterator& operator++();
776  xml_node_iterator operator++(int);
777 
778  const xml_node_iterator& operator--();
779  xml_node_iterator operator--(int);
780  };
781 
782  // Attribute iterator (a bidirectional iterator over a collection of xml_attribute)
784  {
785  friend class xml_node;
786 
787  private:
790 
791  xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
792 
793  public:
794  // Iterator traits
795  using difference_type = ptrdiff_t;
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
808  xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
809 
810  // Iterator operators
811  bool operator==(const xml_attribute_iterator& rhs) const;
812  bool operator!=(const xml_attribute_iterator& rhs) const;
813 
814  xml_attribute& operator*() const;
815  xml_attribute* operator->() const;
816 
817  const xml_attribute_iterator& operator++();
818  xml_attribute_iterator operator++(int);
819 
820  const xml_attribute_iterator& operator--();
821  xml_attribute_iterator operator--(int);
822  };
823 
824  // Named node range helper
826  {
827  friend class xml_node;
828 
829  public:
830  // Iterator traits
831  using difference_type = ptrdiff_t;
833  using pointer = xml_node*;
834  using reference = xml_node&;
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 
850  xml_node& operator*() const;
851  xml_node* operator->() const;
852 
853  const xml_named_node_iterator& operator++();
854  xml_named_node_iterator operator++(int);
855 
856  const xml_named_node_iterator& operator--();
857  xml_named_node_iterator operator--(int);
858 
859  private:
860  mutable xml_node _wrap;
862  const char_t* _name;
863 
864  xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name);
865  };
866 
867  // Abstract tree walker class (see xml_node::traverse)
869  {
870  friend class xml_node;
871 
872  private:
873  int _depth;
874 
875  protected:
876  // Get current traversal depth
877  int depth() const;
878 
879  public:
880  xml_tree_walker();
881  virtual ~xml_tree_walker();
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)
927  ptrdiff_t offset;
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
951  xml_document(const xml_document&);
952  xml_document& operator=(const xml_document&);
953 
954  void create();
955  void destroy();
956 
957  public:
958  // Default constructor, makes empty document
959  xml_document();
960 
961  // Destructor, invalidates all node/attribute handles to this document
962  ~xml_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
968  void reset(const xml_document& proto);
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
1011  xml_node document_element() const;
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)
1023  };
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)
1032  ptrdiff_t offset;
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  {
1047  friend class xpath_variable_set;
1048 
1049  protected:
1052 
1054 
1055  // Non-copyable semantics
1057  xpath_variable& operator=(const xpath_variable&);
1058 
1059  public:
1060  // Get variable name
1061  const char_t* name() const;
1062 
1063  // Get variable type
1064  xpath_value_type type() const;
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;
1070  const xpath_node_set& get_node_set() 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);
1086  void _swap(xpath_variable_set& rhs);
1087 
1088  xpath_variable* _find(const char_t* name) const;
1089 
1090  static bool _clone(xpath_variable* var, xpath_variable** out_result);
1091  static void _destroy(xpath_variable* var);
1092 
1093  public:
1094  // Default constructor/destructor
1096  ~xpath_variable_set();
1097 
1098  // Copy constructor/assignment operator
1100  xpath_variable_set& operator=(const xpath_variable_set& rhs);
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
1109  xpath_variable* add(const char_t* name, xpath_value_type type);
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
1118  xpath_variable* get(const char_t* 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 
1129  using unspecified_bool_type = void (*)(xpath_query***);
1130 
1131  // Non-copyable semantics
1132  xpath_query(const xpath_query&);
1133  xpath_query& operator=(const xpath_query&);
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.
1138  explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0);
1139 
1140  // Constructor
1141  xpath_query();
1142 
1143  // Destructor
1144  ~xpath_query();
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
1153  xpath_value_type return_type() const;
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.
1166  string_t evaluate_string(const xpath_node& n) const;
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.
1178  xpath_node_set evaluate_node_set(const xpath_node& n) const;
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.
1184  xpath_node evaluate_node(const xpath_node& n) const;
1185 
1186  // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode)
1187  const xpath_parse_result& result() const;
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 
1222  using unspecified_bool_type = void (*)(xpath_node***);
1223 
1224  public:
1225  // Default constructor; constructs empty XPath node
1226  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
1233  xml_node node() const;
1234  xml_attribute attribute() const;
1235 
1236  // Get parent of contained node/attribute
1237  xml_node parent() const;
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
1261  enum type_t
1262  {
1263  type_unsorted, // Not ordered
1264  type_sorted, // Sorted by document order (ascending)
1265  type_sorted_reverse // Sorted by document order (descending)
1266  };
1267 
1268  // Constant iterator type
1269  using const_iterator = const xpath_node*;
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.
1275  xpath_node_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
1279 
1280  // Destructor
1281  ~xpath_node_set();
1282 
1283  // Copy constructor/assignment operator
1284  xpath_node_set(const xpath_node_set& ns);
1285  xpath_node_set& operator=(const xpath_node_set& ns);
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
1303  const_iterator begin() const;
1304  const_iterator end() const;
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
1310  xpath_node first() const;
1311 
1312  // Check if collection is empty
1313  bool empty() const;
1314 
1315  private:
1317 
1319 
1322 
1324  void _move(xpath_node_set& rhs);
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))
1353 namespace 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)
1363 namespace 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 
pugi::xml_named_node_iterator::difference_type
ptrdiff_t difference_type
Definition: pugixml.h:831
pugi::status_bad_cdata
@ status_bad_cdata
Definition: pugixml.h:907
pugi::xpath_node::_node
xml_node _node
Definition: pugixml.h:1219
pugi::parse_ws_pcdata
const unsigned int parse_ws_pcdata
Definition: pugixml.h:128
pugi::xml_attribute
Definition: pugixml.h:299
pugi::parse_default
const unsigned int parse_default
Definition: pugixml.h:168
pugi::parse_cdata
const unsigned int parse_cdata
Definition: pugixml.h:124
PUGIXML_TEXT
#define PUGIXML_TEXT(t)
Definition: pugixml.h:79
pugi::status_bad_attribute
@ status_bad_attribute
Definition: pugixml.h:911
ogdf::embedder::operator>=
bool operator>=(const MDMFLengthAttribute &x, const MDMFLengthAttribute &y)
Definition: MDMFLengthAttribute.h:96
pugi::xml_node::parent
xml_node parent() const
pugi::xml_attribute::unspecified_bool_type
void(*)(xml_attribute ***) unspecified_bool_type
Definition: pugixml.h:307
pugi::parse_ws_pcdata_single
const unsigned int parse_ws_pcdata_single
Definition: pugixml.h:151
pugi::status_io_error
@ status_io_error
Definition: pugixml.h:899
pugi::xml_node_iterator::difference_type
ptrdiff_t difference_type
Definition: pugixml.h:753
pugi::xml_node_iterator::_wrap
xml_node _wrap
Definition: pugixml.h:746
pugi::xpath_node
Definition: pugixml.h:1216
pugi::xml_named_node_iterator::_parent
xml_node _parent
Definition: pugixml.h:861
pugi::as_utf8
std::basic_string< char, std::char_traits< char >, std::allocator< char > > PUGIXML_FUNCTION as_utf8(const wchar_t *str)
pugi::format_indent
const unsigned int format_indent
Definition: pugixml.h:193
pugi::node_null
@ node_null
Definition: pugixml.h:100
pugi::xpath_node_set::_type
type_t _type
Definition: pugixml.h:1316
pugi::xml_node::find_child
xml_node find_child(Predicate pred) const
Definition: pugixml.h:548
pugi::xml_node::unspecified_bool_type
void(*)(xml_node ***) unspecified_bool_type
Definition: pugixml.h:410
pugi::status_bad_doctype
@ status_bad_doctype
Definition: pugixml.h:908
pugi::xpath_node_set::type_t
type_t
Definition: pugixml.h:1261
pugi::xpath_node_set
Definition: pugixml.h:1257
pugi::status_bad_comment
@ status_bad_comment
Definition: pugixml.h:906
pugi::node_comment
@ node_comment
Definition: pugixml.h:105
pugi::node_cdata
@ node_cdata
Definition: pugixml.h:104
pugi::parse_declaration
const unsigned int parse_declaration
Definition: pugixml.h:143
pugi::xml_writer_stream::wide_stream
std::basic_ostream< wchar_t, std::char_traits< wchar_t > > * wide_stream
Definition: pugixml.h:294
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::embedder::operator<
bool operator<(const MDMFLengthAttribute &x, const MDMFLengthAttribute &y)
Definition: MDMFLengthAttribute.h:90
pugi::xml_attribute_iterator::_parent
xml_node _parent
Definition: pugixml.h:789
pugi::xpath_parse_result
Definition: pugixml.h:1026
pugi::xpath_parse_result::offset
ptrdiff_t offset
Definition: pugixml.h:1032
pugi::format_write_bom
const unsigned int format_write_bom
Definition: pugixml.h:196
ogdf::operator==
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
Definition: tuples.h:74
backward::Color::reset
@ reset
Definition: backward.hpp:1719
pugi::set_memory_management_functions
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate)
pugi::encoding_utf16_le
@ encoding_utf16_le
Definition: pugixml.h:180
pugi::xml_named_node_iterator::_wrap
xml_node _wrap
Definition: pugixml.h:860
pugi::xpath_node::_attribute
xml_attribute _attribute
Definition: pugixml.h:1220
pugi::encoding_utf16
@ encoding_utf16
Definition: pugixml.h:182
pugi::format_save_file_text
const unsigned int format_save_file_text
Definition: pugixml.h:208
pugi::xml_object_range::xml_object_range
xml_object_range(It b, It e)
Definition: pugixml.h:247
pugi::xml_parse_result::status
xml_parse_status status
Definition: pugixml.h:924
pugi::node_document
@ node_document
Definition: pugixml.h:101
pugi::xml_node::next_sibling
xml_node next_sibling() const
pugi::parse_escapes
const unsigned int parse_escapes
Definition: pugixml.h:131
pugi::parse_wconv_attribute
const unsigned int parse_wconv_attribute
Definition: pugixml.h:137
pugi::xml_writer_stream::narrow_stream
std::basic_ostream< char, std::char_traits< char > > * narrow_stream
Definition: pugixml.h:293
pugi::xml_text::unspecified_bool_type
void(*)(xml_text ***) unspecified_bool_type
Definition: pugixml.h:662
pugi::parse_doctype
const unsigned int parse_doctype
Definition: pugixml.h:146
pugi::xpath_node::unspecified_bool_type
void(*)(xpath_node ***) unspecified_bool_type
Definition: pugixml.h:1222
pugi::xml_attribute::_attr
xml_attribute_struct * _attr
Definition: pugixml.h:305
PUGIXML_CHAR
#define PUGIXML_CHAR
Definition: pugixml.h:80
pugi::format_raw
const unsigned int format_raw
Definition: pugixml.h:199
pugi::status_bad_start_element
@ status_bad_start_element
Definition: pugixml.h:910
pugi::xml_object_range::const_iterator
It const_iterator
Definition: pugixml.h:244
pugi::xml_text
Definition: pugixml.h:656
pugi::char_t
PUGIXML_CHAR char_t
Definition: pugixml.h:86
pugi::parse_pi
const unsigned int parse_pi
Definition: pugixml.h:118
ogdf::reverse
Reverse< T > reverse(T &container)
Provides iterators for container to make it easily iterable in reverse.
Definition: Reverse.h:74
pugi::parse_embed_pcdata
const unsigned int parse_embed_pcdata
Definition: pugixml.h:163
pugi::xml_node::find_attribute
xml_attribute find_attribute(Predicate pred) const
Definition: pugixml.h:536
pugi::xml_object_range::end
It end() const
Definition: pugixml.h:252
Minisat::Internal::sort
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
pugi::xml_text::_root
xml_node_struct * _root
Definition: pugixml.h:660
pugi::xpath_type_none
@ xpath_type_none
Definition: pugixml.h:1018
pugi::status_ok
@ status_ok
Definition: pugixml.h:896
pugi::status_internal_error
@ status_internal_error
Definition: pugixml.h:901
r
int r[]
Definition: hierarchical-ranking.cpp:8
pugi::xml_named_node_iterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: pugixml.h:837
pugi::xml_object_range::begin
It begin() const
Definition: pugixml.h:251
pugi::xml_document::_buffer
char_t * _buffer
Definition: pugixml.h:946
backward::Color::type
type
Definition: backward.hpp:1716
pugi::xpath_value_type
xpath_value_type
Definition: pugixml.h:1016
pugi::xpath_type_number
@ xpath_type_number
Definition: pugixml.h:1020
pugi::xml_node::first_child
xml_node first_child() const
PUGIXML_CLASS
#define PUGIXML_CLASS
Definition: pugixml.h:57
pugi::xml_writer_file
Definition: pugixml.h:269
pugi::as_wide
std::basic_string< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > PUGIXML_FUNCTION as_wide(const char *str)
pugi::format_indent_attributes
const unsigned int format_indent_attributes
Definition: pugixml.h:211
pugi::xml_attribute_iterator::difference_type
ptrdiff_t difference_type
Definition: pugixml.h:795
pugi::xml_node
Definition: pugixml.h:401
pugi::xpath_variable_set
Definition: pugixml.h:1080
pugi::encoding_utf32_be
@ encoding_utf32_be
Definition: pugixml.h:184
pugi::status_bad_pcdata
@ status_bad_pcdata
Definition: pugixml.h:909
pugi::xpath_query::unspecified_bool_type
void(*)(xpath_query ***) unspecified_bool_type
Definition: pugixml.h:1129
pugi::status_bad_pi
@ status_bad_pi
Definition: pugixml.h:905
pugi::xpath_node_set::type_sorted
@ type_sorted
Definition: pugixml.h:1264
pugi::xml_attribute::next_attribute
xml_attribute next_attribute() const
pugi::xml_node_iterator
Definition: pugixml.h:741
pugi::parse_comments
const unsigned int parse_comments
Definition: pugixml.h:121
pugi::status_file_not_found
@ status_file_not_found
Definition: pugixml.h:898
pugi::status_bad_end_element
@ status_bad_end_element
Definition: pugixml.h:912
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
pugi::xml_node::find_node
xml_node find_node(Predicate pred) const
Definition: pugixml.h:560
pugi::allocation_function
void *(*)(size_t size) allocation_function
Definition: pugixml.h:1339
pugi::xpath_type_boolean
@ xpath_type_boolean
Definition: pugixml.h:1022
pugi::xpath_node_set::type_unsorted
@ type_unsorted
Definition: pugixml.h:1263
pugi::node_pcdata
@ node_pcdata
Definition: pugixml.h:103
pugi::xml_tree_walker::_depth
int _depth
Definition: pugixml.h:873
pugi::parse_fragment
const unsigned int parse_fragment
Definition: pugixml.h:158
ogdf::operator!=
bool operator!=(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Inequality operator for 2-tuples.
Definition: tuples.h:80
pugi::xml_parse_result::offset
ptrdiff_t offset
Definition: pugixml.h:927
pugi::xml_node_iterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: pugixml.h:759
pugi::xml_object_range
Definition: pugixml.h:241
pugi::encoding_wchar
@ encoding_wchar
Definition: pugixml.h:186
pugi::node_declaration
@ node_declaration
Definition: pugixml.h:107
pugi::xml_writer_stream
Definition: pugixml.h:283
pugi::xpath_type_node_set
@ xpath_type_node_set
Definition: pugixml.h:1019
pugi::encoding_utf32
@ encoding_utf32
Definition: pugixml.h:185
pugi::encoding_latin1
@ encoding_latin1
Definition: pugixml.h:187
pugi::xml_object_range::_end
It _end
Definition: pugixml.h:255
pugi::parse_full
const unsigned int parse_full
Definition: pugixml.h:173
pugi::encoding_utf8
@ encoding_utf8
Definition: pugixml.h:179
pugi::xml_parse_result::encoding
xml_encoding encoding
Definition: pugixml.h:930
pugi::node_pi
@ node_pi
Definition: pugixml.h:106
pugi::xml_attribute_iterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: pugixml.h:801
pugi::xml_tree_walker
Definition: pugixml.h:868
std
Definition: GML.h:110
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
ogdf::operator>
bool operator>(int lhs, BoyerMyrvoldPlanar::EmbeddingGrade rhs)
Definition: BoyerMyrvoldPlanar.h:475
pugi::encoding_utf32_le
@ encoding_utf32_le
Definition: pugixml.h:183
pugi::xml_attribute_iterator
Definition: pugixml.h:783
pugi::encoding_auto
@ encoding_auto
Definition: pugixml.h:178
pugi::xml_attribute_iterator::_wrap
xml_attribute _wrap
Definition: pugixml.h:788
pugi::xpath_node_set::_end
xpath_node * _end
Definition: pugixml.h:1321
pugi::format_no_declaration
const unsigned int format_no_declaration
Definition: pugixml.h:202
pugi::xml_object_range::iterator
It iterator
Definition: pugixml.h:245
pugi::xpath_variable::_type
xpath_value_type _type
Definition: pugixml.h:1050
pugiconfig.h
pugi::get_memory_allocation_function
allocation_function PUGIXML_FUNCTION get_memory_allocation_function()
pugi::xpath_node_set::_begin
xpath_node * _begin
Definition: pugixml.h:1320
ogdf::print
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
Definition: Array.h:967
pugi::xml_document
Definition: pugixml.h:943
pugi::parse_wnorm_attribute
const unsigned int parse_wnorm_attribute
Definition: pugixml.h:140
pugi::parse_trim_pcdata
const unsigned int parse_trim_pcdata
Definition: pugixml.h:154
Minisat::Internal::var
int var(Lit p)
Definition: SolverTypes.h:61
pugi::format_no_escapes
const unsigned int format_no_escapes
Definition: pugixml.h:205
pugi::xml_encoding
xml_encoding
Definition: pugixml.h:176
pugi::node_element
@ node_element
Definition: pugixml.h:102
pugi::format_default
const unsigned int format_default
Definition: pugixml.h:215
pugi::status_end_element_mismatch
@ status_end_element_mismatch
Definition: pugixml.h:913
pugi::status_no_document_element
@ status_no_document_element
Definition: pugixml.h:917
pugi::xml_named_node_iterator
Definition: pugixml.h:825
pugi::xml_writer
Definition: pugixml.h:259
pugi::node_doctype
@ node_doctype
Definition: pugixml.h:108
pugi::xpath_query::_result
xpath_parse_result _result
Definition: pugixml.h:1127
pugi::string_t
std::basic_string< PUGIXML_CHAR, std::char_traits< PUGIXML_CHAR >, std::allocator< PUGIXML_CHAR > > string_t
Definition: pugixml.h:90
pugi
Definition: pugixml.h:83
PUGIXML_FUNCTION
#define PUGIXML_FUNCTION
Definition: pugixml.h:62
pugi::xpath_query
Definition: pugixml.h:1123
pugi::xml_writer::~xml_writer
virtual ~xml_writer()
Definition: pugixml.h:262
pugi::parse_minimal
const unsigned int parse_minimal
Definition: pugixml.h:115
pugi::xpath_parse_result::error
const char * error
Definition: pugixml.h:1029
pugi::status_append_invalid_root
@ status_append_invalid_root
Definition: pugixml.h:915
pugi::xml_parse_status
xml_parse_status
Definition: pugixml.h:894
pugi::status_out_of_memory
@ status_out_of_memory
Definition: pugixml.h:900
pugi::xml_object_range::_begin
It _begin
Definition: pugixml.h:255
pugi::xpath_variable
Definition: pugixml.h:1045
pugi::xpath_variable::_next
xpath_variable * _next
Definition: pugixml.h:1051
pugi::deallocation_function
void(*)(void *ptr) deallocation_function
Definition: pugixml.h:1342
pugi::xml_node::_root
xml_node_struct * _root
Definition: pugixml.h:408
pugi::parse_eol
const unsigned int parse_eol
Definition: pugixml.h:134
pugi::xml_parse_result
Definition: pugixml.h:921
pugi::get_memory_deallocation_function
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function()
pugi::xml_named_node_iterator::_name
const char_t * _name
Definition: pugixml.h:862
ogdf::operator<=
bool operator<=(int lhs, BoyerMyrvoldPlanar::EmbeddingGrade rhs)
Definition: BoyerMyrvoldPlanar.h:487
pugi::status_unrecognized_tag
@ status_unrecognized_tag
Definition: pugixml.h:903
pugi::xml_writer_file::file
void * file
Definition: pugixml.h:278
pugi::xml_node_iterator::_parent
xml_node _parent
Definition: pugixml.h:747
pugi::xpath_query::_impl
void * _impl
Definition: pugixml.h:1126
pugi::encoding_utf16_be
@ encoding_utf16_be
Definition: pugixml.h:181
pugi::xpath_type_string
@ xpath_type_string
Definition: pugixml.h:1021
pugi::xml_node_type
xml_node_type
Definition: pugixml.h:98
pugi::xpath_node_set::_storage
xpath_node _storage
Definition: pugixml.h:1318