comparison dep/pugixml/src/pugixml.hpp @ 123:a45edd073f9e

deps/pugixml: update to v1.14.0
author Paper <mrpapersonic@gmail.com>
date Wed, 08 Nov 2023 21:40:02 -0500
parents d10b6c6b432e
children
comparison
equal deleted inserted replaced
122:bc218c9d2ea6 123:a45edd073f9e
1 /** 1 /**
2 * pugixml parser - version 1.13 2 * pugixml parser - version 1.14
3 * -------------------------------------------------------- 3 * --------------------------------------------------------
4 * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 4 * Copyright (C) 2006-2023, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
5 * Report bugs and download new versions at https://pugixml.org/ 5 * Report bugs and download new versions at https://pugixml.org/
6 * 6 *
7 * This library is distributed under the MIT License. See notice at the end 7 * This library is distributed under the MIT License. See notice at the end
8 * of this file. 8 * of this file.
9 * 9 *
12 */ 12 */
13 13
14 // Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons 14 // Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons
15 // Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits 15 // Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits
16 #ifndef PUGIXML_VERSION 16 #ifndef PUGIXML_VERSION
17 # define PUGIXML_VERSION 1130 // 1.13 17 # define PUGIXML_VERSION 1140 // 1.14
18 #endif 18 #endif
19 19
20 // Include user configuration file (this can define various configuration macros) 20 // Include user configuration file (this can define various configuration macros)
21 #include "pugiconfig.hpp" 21 #include "pugiconfig.hpp"
22 22
210 210
211 // This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of 211 // This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of
212 // the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments. 212 // the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments.
213 // This flag is off by default. 213 // This flag is off by default.
214 const unsigned int parse_embed_pcdata = 0x2000; 214 const unsigned int parse_embed_pcdata = 0x2000;
215
216 // This flag determines whether determines whether the the two pcdata should be merged or not, if no intermediatory data are parsed in the document.
217 // This flag is off by default.
218 const unsigned int parse_merge_pcdata = 0x4000;
215 219
216 // The default parsing mode. 220 // The default parsing mode.
217 // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, 221 // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
218 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. 222 // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
219 const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol; 223 const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol;
322 326
323 // Writer interface for node printing (see xml_node::print) 327 // Writer interface for node printing (see xml_node::print)
324 class PUGIXML_CLASS xml_writer 328 class PUGIXML_CLASS xml_writer
325 { 329 {
326 public: 330 public:
327 virtual ~xml_writer() {} 331 virtual ~xml_writer();
328 332
329 // Write memory chunk into stream/file/whatever 333 // Write memory chunk into stream/file/whatever
330 virtual void write(const void* data, size_t size) = 0; 334 virtual void write(const void* data, size_t size) = 0;
331 }; 335 };
332 336
416 // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty 420 // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
417 bool as_bool(bool def = false) const; 421 bool as_bool(bool def = false) const;
418 422
419 // Set attribute name/value (returns false if attribute is empty or there is not enough memory) 423 // Set attribute name/value (returns false if attribute is empty or there is not enough memory)
420 bool set_name(const char_t* rhs); 424 bool set_name(const char_t* rhs);
421 bool set_value(const char_t* rhs, size_t sz); 425 bool set_name(const char_t* rhs, size_t size);
422 bool set_value(const char_t* rhs); 426 bool set_value(const char_t* rhs);
427 bool set_value(const char_t* rhs, size_t size);
423 428
424 // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") 429 // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
425 bool set_value(int rhs); 430 bool set_value(int rhs);
426 bool set_value(unsigned int rhs); 431 bool set_value(unsigned int rhs);
427 bool set_value(long rhs); 432 bool set_value(long rhs);
551 // Get child value of child with specified name. Equivalent to child(name).child_value(). 556 // Get child value of child with specified name. Equivalent to child(name).child_value().
552 const char_t* child_value(const char_t* name) const; 557 const char_t* child_value(const char_t* name) const;
553 558
554 // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) 559 // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
555 bool set_name(const char_t* rhs); 560 bool set_name(const char_t* rhs);
556 bool set_value(const char_t* rhs, size_t sz); 561 bool set_name(const char_t* rhs, size_t size);
557 bool set_value(const char_t* rhs); 562 bool set_value(const char_t* rhs);
563 bool set_value(const char_t* rhs, size_t size);
558 564
559 // Add attribute with specified name. Returns added attribute, or empty attribute on errors. 565 // Add attribute with specified name. Returns added attribute, or empty attribute on errors.
560 xml_attribute append_attribute(const char_t* name); 566 xml_attribute append_attribute(const char_t* name);
561 xml_attribute prepend_attribute(const char_t* name); 567 xml_attribute prepend_attribute(const char_t* name);
562 xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr); 568 xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
710 attribute_iterator attributes_begin() const; 716 attribute_iterator attributes_begin() const;
711 attribute_iterator attributes_end() const; 717 attribute_iterator attributes_end() const;
712 718
713 // Range-based for support 719 // Range-based for support
714 xml_object_range<xml_node_iterator> children() const; 720 xml_object_range<xml_node_iterator> children() const;
721 xml_object_range<xml_attribute_iterator> attributes() const;
722
723 // Range-based for support for all children with the specified name
724 // Note: name pointer must have a longer lifetime than the returned object; be careful with passing temporaries!
715 xml_object_range<xml_named_node_iterator> children(const char_t* name) const; 725 xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
716 xml_object_range<xml_attribute_iterator> attributes() const;
717 726
718 // Get node offset in parsed file/string (in char_t units) for debugging purposes 727 // Get node offset in parsed file/string (in char_t units) for debugging purposes
719 ptrdiff_t offset_debug() const; 728 ptrdiff_t offset_debug() const;
720 729
721 // Get hash value (unique for handles to the same object) 730 // Get hash value (unique for handles to the same object)
777 786
778 // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty 787 // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
779 bool as_bool(bool def = false) const; 788 bool as_bool(bool def = false) const;
780 789
781 // Set text (returns false if object is empty or there is not enough memory) 790 // Set text (returns false if object is empty or there is not enough memory)
782 bool set(const char_t* rhs, size_t sz);
783 bool set(const char_t* rhs); 791 bool set(const char_t* rhs);
792 bool set(const char_t* rhs, size_t size);
784 793
785 // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") 794 // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
786 bool set(int rhs); 795 bool set(int rhs);
787 bool set(unsigned int rhs); 796 bool set(unsigned int rhs);
788 bool set(long rhs); 797 bool set(long rhs);
925 934
926 // Default constructor 935 // Default constructor
927 xml_named_node_iterator(); 936 xml_named_node_iterator();
928 937
929 // Construct an iterator which points to the specified node 938 // Construct an iterator which points to the specified node
939 // Note: name pointer is stored in the iterator and must have a longer lifetime than iterator itself
930 xml_named_node_iterator(const xml_node& node, const char_t* name); 940 xml_named_node_iterator(const xml_node& node, const char_t* name);
931 941
932 // Iterator operators 942 // Iterator operators
933 bool operator==(const xml_named_node_iterator& rhs) const; 943 bool operator==(const xml_named_node_iterator& rhs) const;
934 bool operator!=(const xml_named_node_iterator& rhs) const; 944 bool operator!=(const xml_named_node_iterator& rhs) const;
1479 # define PUGIXML_SOURCE "pugixml.cpp" 1489 # define PUGIXML_SOURCE "pugixml.cpp"
1480 # include PUGIXML_SOURCE 1490 # include PUGIXML_SOURCE
1481 #endif 1491 #endif
1482 1492
1483 /** 1493 /**
1484 * Copyright (c) 2006-2022 Arseny Kapoulkine 1494 * Copyright (c) 2006-2023 Arseny Kapoulkine
1485 * 1495 *
1486 * Permission is hereby granted, free of charge, to any person 1496 * Permission is hereby granted, free of charge, to any person
1487 * obtaining a copy of this software and associated documentation 1497 * obtaining a copy of this software and associated documentation
1488 * files (the "Software"), to deal in the Software without 1498 * files (the "Software"), to deal in the Software without
1489 * restriction, including without limitation the rights to use, 1499 * restriction, including without limitation the rights to use,