Warning, file /include/Geant4/pugixml.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef PUGIXML_VERSION
0017 # define PUGIXML_VERSION 1130
0018 #endif
0019
0020
0021 #include "pugiconfig.hpp"
0022
0023 #ifndef HEADER_PUGIXML_HPP
0024 #define HEADER_PUGIXML_HPP
0025
0026
0027 #include <stddef.h>
0028
0029
0030 #if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
0031 # include <exception>
0032 #endif
0033
0034
0035 #ifndef PUGIXML_NO_STL
0036 # include <iterator>
0037 # include <iosfwd>
0038 # include <string>
0039 #endif
0040
0041
0042 #ifndef PUGIXML_DEPRECATED
0043 # if defined(__GNUC__)
0044 # define PUGIXML_DEPRECATED __attribute__((deprecated))
0045 # elif defined(_MSC_VER) && _MSC_VER >= 1300
0046 # define PUGIXML_DEPRECATED __declspec(deprecated)
0047 # else
0048 # define PUGIXML_DEPRECATED
0049 # endif
0050 #endif
0051
0052
0053 #ifndef PUGIXML_API
0054 # define PUGIXML_API
0055 #endif
0056
0057
0058 #ifndef PUGIXML_CLASS
0059 # define PUGIXML_CLASS PUGIXML_API
0060 #endif
0061
0062
0063 #ifndef PUGIXML_FUNCTION
0064 # define PUGIXML_FUNCTION PUGIXML_API
0065 #endif
0066
0067
0068 #ifndef PUGIXML_HAS_LONG_LONG
0069 # if __cplusplus >= 201103
0070 # define PUGIXML_HAS_LONG_LONG
0071 # elif defined(_MSC_VER) && _MSC_VER >= 1400
0072 # define PUGIXML_HAS_LONG_LONG
0073 # endif
0074 #endif
0075
0076
0077 #ifndef PUGIXML_HAS_MOVE
0078 # if __cplusplus >= 201103
0079 # define PUGIXML_HAS_MOVE
0080 # elif defined(_MSC_VER) && _MSC_VER >= 1600
0081 # define PUGIXML_HAS_MOVE
0082 # endif
0083 #endif
0084
0085
0086 #ifndef PUGIXML_NOEXCEPT
0087 # if __cplusplus >= 201103
0088 # define PUGIXML_NOEXCEPT noexcept
0089 # elif defined(_MSC_VER) && _MSC_VER >= 1900
0090 # define PUGIXML_NOEXCEPT noexcept
0091 # else
0092 # define PUGIXML_NOEXCEPT
0093 # endif
0094 #endif
0095
0096
0097 #ifdef PUGIXML_COMPACT
0098 # define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
0099 #else
0100 # define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
0101 #endif
0102
0103
0104 #ifndef PUGIXML_OVERRIDE
0105 # if __cplusplus >= 201103
0106 # define PUGIXML_OVERRIDE override
0107 # elif defined(_MSC_VER) && _MSC_VER >= 1700
0108 # define PUGIXML_OVERRIDE override
0109 # else
0110 # define PUGIXML_OVERRIDE
0111 # endif
0112 #endif
0113
0114
0115 #ifndef PUGIXML_NULL
0116 # if __cplusplus >= 201103
0117 # define PUGIXML_NULL nullptr
0118 # elif defined(_MSC_VER) && _MSC_VER >= 1600
0119 # define PUGIXML_NULL nullptr
0120 # else
0121 # define PUGIXML_NULL 0
0122 # endif
0123 #endif
0124
0125
0126 #ifdef PUGIXML_WCHAR_MODE
0127 # define PUGIXML_TEXT(t) L ## t
0128 # define PUGIXML_CHAR wchar_t
0129 #else
0130 # define PUGIXML_TEXT(t) t
0131 # define PUGIXML_CHAR char
0132 #endif
0133
0134 namespace pugi
0135 {
0136
0137 typedef PUGIXML_CHAR char_t;
0138
0139 #ifndef PUGIXML_NO_STL
0140
0141 typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t;
0142 #endif
0143 }
0144
0145
0146 namespace pugi
0147 {
0148
0149 enum xml_node_type
0150 {
0151 node_null,
0152 node_document,
0153 node_element,
0154 node_pcdata,
0155 node_cdata,
0156 node_comment,
0157 node_pi,
0158 node_declaration,
0159 node_doctype
0160 };
0161
0162
0163
0164
0165
0166 const unsigned int parse_minimal = 0x0000;
0167
0168
0169 const unsigned int parse_pi = 0x0001;
0170
0171
0172 const unsigned int parse_comments = 0x0002;
0173
0174
0175 const unsigned int parse_cdata = 0x0004;
0176
0177
0178
0179 const unsigned int parse_ws_pcdata = 0x0008;
0180
0181
0182 const unsigned int parse_escapes = 0x0010;
0183
0184
0185 const unsigned int parse_eol = 0x0020;
0186
0187
0188 const unsigned int parse_wconv_attribute = 0x0040;
0189
0190
0191 const unsigned int parse_wnorm_attribute = 0x0080;
0192
0193
0194 const unsigned int parse_declaration = 0x0100;
0195
0196
0197 const unsigned int parse_doctype = 0x0200;
0198
0199
0200
0201
0202 const unsigned int parse_ws_pcdata_single = 0x0400;
0203
0204
0205 const unsigned int parse_trim_pcdata = 0x0800;
0206
0207
0208
0209 const unsigned int parse_fragment = 0x1000;
0210
0211
0212
0213
0214 const unsigned int parse_embed_pcdata = 0x2000;
0215
0216
0217
0218
0219 const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol;
0220
0221
0222
0223
0224 const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype;
0225
0226
0227 enum xml_encoding
0228 {
0229 encoding_auto,
0230 encoding_utf8,
0231 encoding_utf16_le,
0232 encoding_utf16_be,
0233 encoding_utf16,
0234 encoding_utf32_le,
0235 encoding_utf32_be,
0236 encoding_utf32,
0237 encoding_wchar,
0238 encoding_latin1
0239 };
0240
0241
0242
0243
0244 const unsigned int format_indent = 0x01;
0245
0246
0247 const unsigned int format_write_bom = 0x02;
0248
0249
0250 const unsigned int format_raw = 0x04;
0251
0252
0253 const unsigned int format_no_declaration = 0x08;
0254
0255
0256 const unsigned int format_no_escapes = 0x10;
0257
0258
0259 const unsigned int format_save_file_text = 0x20;
0260
0261
0262 const unsigned int format_indent_attributes = 0x40;
0263
0264
0265 const unsigned int format_no_empty_element_tags = 0x80;
0266
0267
0268 const unsigned int format_skip_control_chars = 0x100;
0269
0270
0271 const unsigned int format_attribute_single_quote = 0x200;
0272
0273
0274
0275 const unsigned int format_default = format_indent;
0276
0277 const int default_double_precision = 17;
0278 const int default_float_precision = 9;
0279
0280
0281 struct xml_attribute_struct;
0282 struct xml_node_struct;
0283
0284 class xml_node_iterator;
0285 class xml_attribute_iterator;
0286 class xml_named_node_iterator;
0287
0288 class xml_tree_walker;
0289
0290 struct xml_parse_result;
0291
0292 class xml_node;
0293
0294 class xml_text;
0295
0296 #ifndef PUGIXML_NO_XPATH
0297 class xpath_node;
0298 class xpath_node_set;
0299 class xpath_query;
0300 class xpath_variable_set;
0301 #endif
0302
0303
0304 template <typename It> class xml_object_range
0305 {
0306 public:
0307 typedef It const_iterator;
0308 typedef It iterator;
0309
0310 xml_object_range(It b, It e): _begin(b), _end(e)
0311 {
0312 }
0313
0314 It begin() const { return _begin; }
0315 It end() const { return _end; }
0316
0317 bool empty() const { return _begin == _end; }
0318
0319 private:
0320 It _begin, _end;
0321 };
0322
0323
0324 class PUGIXML_CLASS xml_writer
0325 {
0326 public:
0327 virtual ~xml_writer() {}
0328
0329
0330 virtual void write(const void* data, size_t size) = 0;
0331 };
0332
0333
0334 class PUGIXML_CLASS xml_writer_file: public xml_writer
0335 {
0336 public:
0337
0338 xml_writer_file(void* file);
0339
0340 virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
0341
0342 private:
0343 void* file;
0344 };
0345
0346 #ifndef PUGIXML_NO_STL
0347
0348 class PUGIXML_CLASS xml_writer_stream: public xml_writer
0349 {
0350 public:
0351
0352 xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
0353 xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
0354
0355 virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
0356
0357 private:
0358 std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
0359 std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
0360 };
0361 #endif
0362
0363
0364 class PUGIXML_CLASS xml_attribute
0365 {
0366 friend class xml_attribute_iterator;
0367 friend class xml_node;
0368
0369 private:
0370 xml_attribute_struct* _attr;
0371
0372 typedef void (*unspecified_bool_type)(xml_attribute***);
0373
0374 public:
0375
0376 xml_attribute();
0377
0378
0379 explicit xml_attribute(xml_attribute_struct* attr);
0380
0381
0382 operator unspecified_bool_type() const;
0383
0384
0385 bool operator!() const;
0386
0387
0388 bool operator==(const xml_attribute& r) const;
0389 bool operator!=(const xml_attribute& r) const;
0390 bool operator<(const xml_attribute& r) const;
0391 bool operator>(const xml_attribute& r) const;
0392 bool operator<=(const xml_attribute& r) const;
0393 bool operator>=(const xml_attribute& r) const;
0394
0395
0396 bool empty() const;
0397
0398
0399 const char_t* name() const;
0400 const char_t* value() const;
0401
0402
0403 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
0404
0405
0406 int as_int(int def = 0) const;
0407 unsigned int as_uint(unsigned int def = 0) const;
0408 double as_double(double def = 0) const;
0409 float as_float(float def = 0) const;
0410
0411 #ifdef PUGIXML_HAS_LONG_LONG
0412 long long as_llong(long long def = 0) const;
0413 unsigned long long as_ullong(unsigned long long def = 0) const;
0414 #endif
0415
0416
0417 bool as_bool(bool def = false) const;
0418
0419
0420 bool set_name(const char_t* rhs);
0421 bool set_value(const char_t* rhs, size_t sz);
0422 bool set_value(const char_t* rhs);
0423
0424
0425 bool set_value(int rhs);
0426 bool set_value(unsigned int rhs);
0427 bool set_value(long rhs);
0428 bool set_value(unsigned long rhs);
0429 bool set_value(double rhs);
0430 bool set_value(double rhs, int precision);
0431 bool set_value(float rhs);
0432 bool set_value(float rhs, int precision);
0433 bool set_value(bool rhs);
0434
0435 #ifdef PUGIXML_HAS_LONG_LONG
0436 bool set_value(long long rhs);
0437 bool set_value(unsigned long long rhs);
0438 #endif
0439
0440
0441 xml_attribute& operator=(const char_t* rhs);
0442 xml_attribute& operator=(int rhs);
0443 xml_attribute& operator=(unsigned int rhs);
0444 xml_attribute& operator=(long rhs);
0445 xml_attribute& operator=(unsigned long rhs);
0446 xml_attribute& operator=(double rhs);
0447 xml_attribute& operator=(float rhs);
0448 xml_attribute& operator=(bool rhs);
0449
0450 #ifdef PUGIXML_HAS_LONG_LONG
0451 xml_attribute& operator=(long long rhs);
0452 xml_attribute& operator=(unsigned long long rhs);
0453 #endif
0454
0455
0456 xml_attribute next_attribute() const;
0457 xml_attribute previous_attribute() const;
0458
0459
0460 size_t hash_value() const;
0461
0462
0463 xml_attribute_struct* internal_object() const;
0464 };
0465
0466 #ifdef __BORLANDC__
0467
0468 bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs);
0469 bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs);
0470 #endif
0471
0472
0473 class PUGIXML_CLASS xml_node
0474 {
0475 friend class xml_attribute_iterator;
0476 friend class xml_node_iterator;
0477 friend class xml_named_node_iterator;
0478
0479 protected:
0480 xml_node_struct* _root;
0481
0482 typedef void (*unspecified_bool_type)(xml_node***);
0483
0484 public:
0485
0486 xml_node();
0487
0488
0489 explicit xml_node(xml_node_struct* p);
0490
0491
0492 operator unspecified_bool_type() const;
0493
0494
0495 bool operator!() const;
0496
0497
0498 bool operator==(const xml_node& r) const;
0499 bool operator!=(const xml_node& r) const;
0500 bool operator<(const xml_node& r) const;
0501 bool operator>(const xml_node& r) const;
0502 bool operator<=(const xml_node& r) const;
0503 bool operator>=(const xml_node& r) const;
0504
0505
0506 bool empty() const;
0507
0508
0509 xml_node_type type() const;
0510
0511
0512 const char_t* name() const;
0513
0514
0515
0516 const char_t* value() const;
0517
0518
0519 xml_attribute first_attribute() const;
0520 xml_attribute last_attribute() const;
0521
0522
0523 xml_node first_child() const;
0524 xml_node last_child() const;
0525
0526
0527 xml_node next_sibling() const;
0528 xml_node previous_sibling() const;
0529
0530
0531 xml_node parent() const;
0532
0533
0534 xml_node root() const;
0535
0536
0537 xml_text text() const;
0538
0539
0540 xml_node child(const char_t* name) const;
0541 xml_attribute attribute(const char_t* name) const;
0542 xml_node next_sibling(const char_t* name) const;
0543 xml_node previous_sibling(const char_t* name) const;
0544
0545
0546 xml_attribute attribute(const char_t* name, xml_attribute& hint) const;
0547
0548
0549 const char_t* child_value() const;
0550
0551
0552 const char_t* child_value(const char_t* name) const;
0553
0554
0555 bool set_name(const char_t* rhs);
0556 bool set_value(const char_t* rhs, size_t sz);
0557 bool set_value(const char_t* rhs);
0558
0559
0560 xml_attribute append_attribute(const char_t* name);
0561 xml_attribute prepend_attribute(const char_t* name);
0562 xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
0563 xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
0564
0565
0566 xml_attribute append_copy(const xml_attribute& proto);
0567 xml_attribute prepend_copy(const xml_attribute& proto);
0568 xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
0569 xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
0570
0571
0572 xml_node append_child(xml_node_type type = node_element);
0573 xml_node prepend_child(xml_node_type type = node_element);
0574 xml_node insert_child_after(xml_node_type type, const xml_node& node);
0575 xml_node insert_child_before(xml_node_type type, const xml_node& node);
0576
0577
0578 xml_node append_child(const char_t* name);
0579 xml_node prepend_child(const char_t* name);
0580 xml_node insert_child_after(const char_t* name, const xml_node& node);
0581 xml_node insert_child_before(const char_t* name, const xml_node& node);
0582
0583
0584 xml_node append_copy(const xml_node& proto);
0585 xml_node prepend_copy(const xml_node& proto);
0586 xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
0587 xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
0588
0589
0590 xml_node append_move(const xml_node& moved);
0591 xml_node prepend_move(const xml_node& moved);
0592 xml_node insert_move_after(const xml_node& moved, const xml_node& node);
0593 xml_node insert_move_before(const xml_node& moved, const xml_node& node);
0594
0595
0596 bool remove_attribute(const xml_attribute& a);
0597 bool remove_attribute(const char_t* name);
0598
0599
0600 bool remove_attributes();
0601
0602
0603 bool remove_child(const xml_node& n);
0604 bool remove_child(const char_t* name);
0605
0606
0607 bool remove_children();
0608
0609
0610
0611
0612 xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
0613
0614
0615 template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
0616 {
0617 if (!_root) return xml_attribute();
0618
0619 for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
0620 if (pred(attrib))
0621 return attrib;
0622
0623 return xml_attribute();
0624 }
0625
0626
0627 template <typename Predicate> xml_node find_child(Predicate pred) const
0628 {
0629 if (!_root) return xml_node();
0630
0631 for (xml_node node = first_child(); node; node = node.next_sibling())
0632 if (pred(node))
0633 return node;
0634
0635 return xml_node();
0636 }
0637
0638
0639 template <typename Predicate> xml_node find_node(Predicate pred) const
0640 {
0641 if (!_root) return xml_node();
0642
0643 xml_node cur = first_child();
0644
0645 while (cur._root && cur._root != _root)
0646 {
0647 if (pred(cur)) return cur;
0648
0649 if (cur.first_child()) cur = cur.first_child();
0650 else if (cur.next_sibling()) cur = cur.next_sibling();
0651 else
0652 {
0653 while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
0654
0655 if (cur._root != _root) cur = cur.next_sibling();
0656 }
0657 }
0658
0659 return xml_node();
0660 }
0661
0662
0663 xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
0664 xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
0665
0666 #ifndef PUGIXML_NO_STL
0667
0668 string_t path(char_t delimiter = '/') const;
0669 #endif
0670
0671
0672 xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
0673
0674
0675 bool traverse(xml_tree_walker& walker);
0676
0677 #ifndef PUGIXML_NO_XPATH
0678
0679 xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
0680 xpath_node select_node(const xpath_query& query) const;
0681
0682
0683 xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
0684 xpath_node_set select_nodes(const xpath_query& query) const;
0685
0686
0687 PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
0688 PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
0689
0690 #endif
0691
0692
0693 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;
0694
0695 #ifndef PUGIXML_NO_STL
0696
0697 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;
0698 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;
0699 #endif
0700
0701
0702 typedef xml_node_iterator iterator;
0703
0704 iterator begin() const;
0705 iterator end() const;
0706
0707
0708 typedef xml_attribute_iterator attribute_iterator;
0709
0710 attribute_iterator attributes_begin() const;
0711 attribute_iterator attributes_end() const;
0712
0713
0714 xml_object_range<xml_node_iterator> children() const;
0715 xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
0716 xml_object_range<xml_attribute_iterator> attributes() const;
0717
0718
0719 ptrdiff_t offset_debug() const;
0720
0721
0722 size_t hash_value() const;
0723
0724
0725 xml_node_struct* internal_object() const;
0726 };
0727
0728 #ifdef __BORLANDC__
0729
0730 bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs);
0731 bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs);
0732 #endif
0733
0734
0735 class PUGIXML_CLASS xml_text
0736 {
0737 friend class xml_node;
0738
0739 xml_node_struct* _root;
0740
0741 typedef void (*unspecified_bool_type)(xml_text***);
0742
0743 explicit xml_text(xml_node_struct* root);
0744
0745 xml_node_struct* _data_new();
0746 xml_node_struct* _data() const;
0747
0748 public:
0749
0750 xml_text();
0751
0752
0753 operator unspecified_bool_type() const;
0754
0755
0756 bool operator!() const;
0757
0758
0759 bool empty() const;
0760
0761
0762 const char_t* get() const;
0763
0764
0765 const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
0766
0767
0768 int as_int(int def = 0) const;
0769 unsigned int as_uint(unsigned int def = 0) const;
0770 double as_double(double def = 0) const;
0771 float as_float(float def = 0) const;
0772
0773 #ifdef PUGIXML_HAS_LONG_LONG
0774 long long as_llong(long long def = 0) const;
0775 unsigned long long as_ullong(unsigned long long def = 0) const;
0776 #endif
0777
0778
0779 bool as_bool(bool def = false) const;
0780
0781
0782 bool set(const char_t* rhs, size_t sz);
0783 bool set(const char_t* rhs);
0784
0785
0786 bool set(int rhs);
0787 bool set(unsigned int rhs);
0788 bool set(long rhs);
0789 bool set(unsigned long rhs);
0790 bool set(double rhs);
0791 bool set(double rhs, int precision);
0792 bool set(float rhs);
0793 bool set(float rhs, int precision);
0794 bool set(bool rhs);
0795
0796 #ifdef PUGIXML_HAS_LONG_LONG
0797 bool set(long long rhs);
0798 bool set(unsigned long long rhs);
0799 #endif
0800
0801
0802 xml_text& operator=(const char_t* rhs);
0803 xml_text& operator=(int rhs);
0804 xml_text& operator=(unsigned int rhs);
0805 xml_text& operator=(long rhs);
0806 xml_text& operator=(unsigned long rhs);
0807 xml_text& operator=(double rhs);
0808 xml_text& operator=(float rhs);
0809 xml_text& operator=(bool rhs);
0810
0811 #ifdef PUGIXML_HAS_LONG_LONG
0812 xml_text& operator=(long long rhs);
0813 xml_text& operator=(unsigned long long rhs);
0814 #endif
0815
0816
0817 xml_node data() const;
0818 };
0819
0820 #ifdef __BORLANDC__
0821
0822 bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs);
0823 bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs);
0824 #endif
0825
0826
0827 class PUGIXML_CLASS xml_node_iterator
0828 {
0829 friend class xml_node;
0830
0831 private:
0832 mutable xml_node _wrap;
0833 xml_node _parent;
0834
0835 xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent);
0836
0837 public:
0838
0839 typedef ptrdiff_t difference_type;
0840 typedef xml_node value_type;
0841 typedef xml_node* pointer;
0842 typedef xml_node& reference;
0843
0844 #ifndef PUGIXML_NO_STL
0845 typedef std::bidirectional_iterator_tag iterator_category;
0846 #endif
0847
0848
0849 xml_node_iterator();
0850
0851
0852 xml_node_iterator(const xml_node& node);
0853
0854
0855 bool operator==(const xml_node_iterator& rhs) const;
0856 bool operator!=(const xml_node_iterator& rhs) const;
0857
0858 xml_node& operator*() const;
0859 xml_node* operator->() const;
0860
0861 xml_node_iterator& operator++();
0862 xml_node_iterator operator++(int);
0863
0864 xml_node_iterator& operator--();
0865 xml_node_iterator operator--(int);
0866 };
0867
0868
0869 class PUGIXML_CLASS xml_attribute_iterator
0870 {
0871 friend class xml_node;
0872
0873 private:
0874 mutable xml_attribute _wrap;
0875 xml_node _parent;
0876
0877 xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
0878
0879 public:
0880
0881 typedef ptrdiff_t difference_type;
0882 typedef xml_attribute value_type;
0883 typedef xml_attribute* pointer;
0884 typedef xml_attribute& reference;
0885
0886 #ifndef PUGIXML_NO_STL
0887 typedef std::bidirectional_iterator_tag iterator_category;
0888 #endif
0889
0890
0891 xml_attribute_iterator();
0892
0893
0894 xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
0895
0896
0897 bool operator==(const xml_attribute_iterator& rhs) const;
0898 bool operator!=(const xml_attribute_iterator& rhs) const;
0899
0900 xml_attribute& operator*() const;
0901 xml_attribute* operator->() const;
0902
0903 xml_attribute_iterator& operator++();
0904 xml_attribute_iterator operator++(int);
0905
0906 xml_attribute_iterator& operator--();
0907 xml_attribute_iterator operator--(int);
0908 };
0909
0910
0911 class PUGIXML_CLASS xml_named_node_iterator
0912 {
0913 friend class xml_node;
0914
0915 public:
0916
0917 typedef ptrdiff_t difference_type;
0918 typedef xml_node value_type;
0919 typedef xml_node* pointer;
0920 typedef xml_node& reference;
0921
0922 #ifndef PUGIXML_NO_STL
0923 typedef std::bidirectional_iterator_tag iterator_category;
0924 #endif
0925
0926
0927 xml_named_node_iterator();
0928
0929
0930 xml_named_node_iterator(const xml_node& node, const char_t* name);
0931
0932
0933 bool operator==(const xml_named_node_iterator& rhs) const;
0934 bool operator!=(const xml_named_node_iterator& rhs) const;
0935
0936 xml_node& operator*() const;
0937 xml_node* operator->() const;
0938
0939 xml_named_node_iterator& operator++();
0940 xml_named_node_iterator operator++(int);
0941
0942 xml_named_node_iterator& operator--();
0943 xml_named_node_iterator operator--(int);
0944
0945 private:
0946 mutable xml_node _wrap;
0947 xml_node _parent;
0948 const char_t* _name;
0949
0950 xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name);
0951 };
0952
0953
0954 class PUGIXML_CLASS xml_tree_walker
0955 {
0956 friend class xml_node;
0957
0958 private:
0959 int _depth;
0960
0961 protected:
0962
0963 int depth() const;
0964
0965 public:
0966 xml_tree_walker();
0967 virtual ~xml_tree_walker();
0968
0969
0970 virtual bool begin(xml_node& node);
0971
0972
0973 virtual bool for_each(xml_node& node) = 0;
0974
0975
0976 virtual bool end(xml_node& node);
0977 };
0978
0979
0980 enum xml_parse_status
0981 {
0982 status_ok = 0,
0983
0984 status_file_not_found,
0985 status_io_error,
0986 status_out_of_memory,
0987 status_internal_error,
0988
0989 status_unrecognized_tag,
0990
0991 status_bad_pi,
0992 status_bad_comment,
0993 status_bad_cdata,
0994 status_bad_doctype,
0995 status_bad_pcdata,
0996 status_bad_start_element,
0997 status_bad_attribute,
0998 status_bad_end_element,
0999 status_end_element_mismatch,
1000
1001 status_append_invalid_root,
1002
1003 status_no_document_element
1004 };
1005
1006
1007 struct PUGIXML_CLASS xml_parse_result
1008 {
1009
1010 xml_parse_status status;
1011
1012
1013 ptrdiff_t offset;
1014
1015
1016 xml_encoding encoding;
1017
1018
1019 xml_parse_result();
1020
1021
1022 operator bool() const;
1023
1024
1025 const char* description() const;
1026 };
1027
1028
1029 class PUGIXML_CLASS xml_document: public xml_node
1030 {
1031 private:
1032 char_t* _buffer;
1033
1034 char _memory[192];
1035
1036
1037 xml_document(const xml_document&);
1038 xml_document& operator=(const xml_document&);
1039
1040 void _create();
1041 void _destroy();
1042 void _move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1043
1044 public:
1045
1046 xml_document();
1047
1048
1049 ~xml_document();
1050
1051 #ifdef PUGIXML_HAS_MOVE
1052
1053 xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1054 xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1055 #endif
1056
1057
1058 void reset();
1059
1060
1061 void reset(const xml_document& proto);
1062
1063 #ifndef PUGIXML_NO_STL
1064
1065 xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1066 xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
1067 #endif
1068
1069
1070 PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
1071
1072
1073 xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
1074
1075
1076 xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1077 xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1078
1079
1080 xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1081
1082
1083
1084 xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1085
1086
1087
1088 xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1089
1090
1091 void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1092
1093 #ifndef PUGIXML_NO_STL
1094
1095 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;
1096 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;
1097 #endif
1098
1099
1100 bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
1101 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;
1102
1103
1104 xml_node document_element() const;
1105 };
1106
1107 #ifndef PUGIXML_NO_XPATH
1108
1109 enum xpath_value_type
1110 {
1111 xpath_type_none,
1112 xpath_type_node_set,
1113 xpath_type_number,
1114 xpath_type_string,
1115 xpath_type_boolean
1116 };
1117
1118
1119 struct PUGIXML_CLASS xpath_parse_result
1120 {
1121
1122 const char* error;
1123
1124
1125 ptrdiff_t offset;
1126
1127
1128 xpath_parse_result();
1129
1130
1131 operator bool() const;
1132
1133
1134 const char* description() const;
1135 };
1136
1137
1138 class PUGIXML_CLASS xpath_variable
1139 {
1140 friend class xpath_variable_set;
1141
1142 protected:
1143 xpath_value_type _type;
1144 xpath_variable* _next;
1145
1146 xpath_variable(xpath_value_type type);
1147
1148
1149 xpath_variable(const xpath_variable&);
1150 xpath_variable& operator=(const xpath_variable&);
1151
1152 public:
1153
1154 const char_t* name() const;
1155
1156
1157 xpath_value_type type() const;
1158
1159
1160 bool get_boolean() const;
1161 double get_number() const;
1162 const char_t* get_string() const;
1163 const xpath_node_set& get_node_set() const;
1164
1165
1166 bool set(bool value);
1167 bool set(double value);
1168 bool set(const char_t* value);
1169 bool set(const xpath_node_set& value);
1170 };
1171
1172
1173 class PUGIXML_CLASS xpath_variable_set
1174 {
1175 private:
1176 xpath_variable* _data[64];
1177
1178 void _assign(const xpath_variable_set& rhs);
1179 void _swap(xpath_variable_set& rhs);
1180
1181 xpath_variable* _find(const char_t* name) const;
1182
1183 static bool _clone(xpath_variable* var, xpath_variable** out_result);
1184 static void _destroy(xpath_variable* var);
1185
1186 public:
1187
1188 xpath_variable_set();
1189 ~xpath_variable_set();
1190
1191
1192 xpath_variable_set(const xpath_variable_set& rhs);
1193 xpath_variable_set& operator=(const xpath_variable_set& rhs);
1194
1195 #ifdef PUGIXML_HAS_MOVE
1196
1197 xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
1198 xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
1199 #endif
1200
1201
1202 xpath_variable* add(const char_t* name, xpath_value_type type);
1203
1204
1205 bool set(const char_t* name, bool value);
1206 bool set(const char_t* name, double value);
1207 bool set(const char_t* name, const char_t* value);
1208 bool set(const char_t* name, const xpath_node_set& value);
1209
1210
1211 xpath_variable* get(const char_t* name);
1212 const xpath_variable* get(const char_t* name) const;
1213 };
1214
1215
1216 class PUGIXML_CLASS xpath_query
1217 {
1218 private:
1219 void* _impl;
1220 xpath_parse_result _result;
1221
1222 typedef void (*unspecified_bool_type)(xpath_query***);
1223
1224
1225 xpath_query(const xpath_query&);
1226 xpath_query& operator=(const xpath_query&);
1227
1228 public:
1229
1230
1231 explicit xpath_query(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL);
1232
1233
1234 xpath_query();
1235
1236
1237 ~xpath_query();
1238
1239 #ifdef PUGIXML_HAS_MOVE
1240
1241 xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
1242 xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
1243 #endif
1244
1245
1246 xpath_value_type return_type() const;
1247
1248
1249
1250 bool evaluate_boolean(const xpath_node& n) const;
1251
1252
1253
1254 double evaluate_number(const xpath_node& n) const;
1255
1256 #ifndef PUGIXML_NO_STL
1257
1258
1259 string_t evaluate_string(const xpath_node& n) const;
1260 #endif
1261
1262
1263
1264
1265
1266 size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
1267
1268
1269
1270
1271 xpath_node_set evaluate_node_set(const xpath_node& n) const;
1272
1273
1274
1275
1276
1277 xpath_node evaluate_node(const xpath_node& n) const;
1278
1279
1280 const xpath_parse_result& result() const;
1281
1282
1283 operator unspecified_bool_type() const;
1284
1285
1286 bool operator!() const;
1287 };
1288
1289 #ifndef PUGIXML_NO_EXCEPTIONS
1290 #if defined(_MSC_VER)
1291
1292
1293 #pragma warning(push)
1294 #pragma warning(disable: 4275)
1295 #endif
1296
1297 class PUGIXML_CLASS xpath_exception: public std::exception
1298 {
1299 private:
1300 xpath_parse_result _result;
1301
1302 public:
1303
1304 explicit xpath_exception(const xpath_parse_result& result);
1305
1306
1307 virtual const char* what() const throw() PUGIXML_OVERRIDE;
1308
1309
1310 const xpath_parse_result& result() const;
1311 };
1312 #if defined(_MSC_VER)
1313 #pragma warning(pop)
1314 #endif
1315 #endif
1316
1317
1318 class PUGIXML_CLASS xpath_node
1319 {
1320 private:
1321 xml_node _node;
1322 xml_attribute _attribute;
1323
1324 typedef void (*unspecified_bool_type)(xpath_node***);
1325
1326 public:
1327
1328 xpath_node();
1329
1330
1331 xpath_node(const xml_node& node);
1332 xpath_node(const xml_attribute& attribute, const xml_node& parent);
1333
1334
1335 xml_node node() const;
1336 xml_attribute attribute() const;
1337
1338
1339 xml_node parent() const;
1340
1341
1342 operator unspecified_bool_type() const;
1343
1344
1345 bool operator!() const;
1346
1347
1348 bool operator==(const xpath_node& n) const;
1349 bool operator!=(const xpath_node& n) const;
1350 };
1351
1352 #ifdef __BORLANDC__
1353
1354 bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs);
1355 bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs);
1356 #endif
1357
1358
1359 class PUGIXML_CLASS xpath_node_set
1360 {
1361 public:
1362
1363 enum type_t
1364 {
1365 type_unsorted,
1366 type_sorted,
1367 type_sorted_reverse
1368 };
1369
1370
1371 typedef const xpath_node* const_iterator;
1372
1373
1374 typedef const xpath_node* iterator;
1375
1376
1377 xpath_node_set();
1378
1379
1380 xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
1381
1382
1383 ~xpath_node_set();
1384
1385
1386 xpath_node_set(const xpath_node_set& ns);
1387 xpath_node_set& operator=(const xpath_node_set& ns);
1388
1389 #ifdef PUGIXML_HAS_MOVE
1390
1391 xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
1392 xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
1393 #endif
1394
1395
1396 type_t type() const;
1397
1398
1399 size_t size() const;
1400
1401
1402 const xpath_node& operator[](size_t index) const;
1403
1404
1405 const_iterator begin() const;
1406 const_iterator end() const;
1407
1408
1409 void sort(bool reverse = false);
1410
1411
1412 xpath_node first() const;
1413
1414
1415 bool empty() const;
1416
1417 private:
1418 type_t _type;
1419
1420 xpath_node _storage[1];
1421
1422 xpath_node* _begin;
1423 xpath_node* _end;
1424
1425 void _assign(const_iterator begin, const_iterator end, type_t type);
1426 void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT;
1427 };
1428 #endif
1429
1430 #ifndef PUGIXML_NO_STL
1431
1432 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
1433 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);
1434
1435
1436 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
1437 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);
1438 #endif
1439
1440
1441 typedef void* (*allocation_function)(size_t size);
1442
1443
1444 typedef void (*deallocation_function)(void* ptr);
1445
1446
1447 void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
1448
1449
1450 allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
1451 deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
1452 }
1453
1454 #if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
1455 namespace std
1456 {
1457
1458 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&);
1459 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&);
1460 std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&);
1461 }
1462 #endif
1463
1464 #if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
1465 namespace std
1466 {
1467
1468 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&);
1469 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&);
1470 std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&);
1471 }
1472 #endif
1473
1474 #endif
1475
1476
1477
1478 #if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
1479 # define PUGIXML_SOURCE "pugixml.cpp"
1480 # include PUGIXML_SOURCE
1481 #endif
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506