14 #ifndef PUGIXML_VERSION
16 # define PUGIXML_VERSION 190
20 #include "smpugiconfig.hh"
22 #ifndef HEADER_PUGIXML_HPP
23 #define HEADER_PUGIXML_HPP
29 #if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
34 #ifndef PUGIXML_NO_STL
41 #ifndef PUGIXML_DEPRECATED
42 # if defined(__GNUC__)
43 # define PUGIXML_DEPRECATED __attribute__((deprecated))
44 # elif defined(_MSC_VER) && _MSC_VER >= 1300
45 # define PUGIXML_DEPRECATED __declspec(deprecated)
47 # define PUGIXML_DEPRECATED
58 # define PUGIXML_CLASS PUGIXML_API
62 #ifndef PUGIXML_FUNCTION
63 # define PUGIXML_FUNCTION PUGIXML_API
67 #ifndef PUGIXML_HAS_LONG_LONG
68 # if __cplusplus >= 201103
69 # define PUGIXML_HAS_LONG_LONG
70 # elif defined(_MSC_VER) && _MSC_VER >= 1400
71 # define PUGIXML_HAS_LONG_LONG
76 #ifndef PUGIXML_HAS_MOVE
77 # if __cplusplus >= 201103
78 # define PUGIXML_HAS_MOVE
79 # elif defined(_MSC_VER) && _MSC_VER >= 1600
80 # define PUGIXML_HAS_MOVE
85 #ifndef PUGIXML_NOEXCEPT
86 # if __cplusplus >= 201103
87 # define PUGIXML_NOEXCEPT noexcept
88 # elif defined(_MSC_VER) && _MSC_VER >= 1900
89 # define PUGIXML_NOEXCEPT noexcept
91 # define PUGIXML_NOEXCEPT
96 #ifdef PUGIXML_COMPACT
97 # define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
99 # define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
103 #ifndef PUGIXML_OVERRIDE
104 # if __cplusplus >= 201103
105 # define PUGIXML_OVERRIDE override
106 # elif defined(_MSC_VER) && _MSC_VER >= 1700
107 # define PUGIXML_OVERRIDE override
109 # define PUGIXML_OVERRIDE
114 #ifdef PUGIXML_WCHAR_MODE
115 # define PUGIXML_TEXT(t) L ## t
116 # define PUGIXML_CHAR wchar_t
118 # define PUGIXML_TEXT(t) t
119 # define PUGIXML_CHAR char
125 typedef PUGIXML_CHAR char_t;
127 #ifndef PUGIXML_NO_STL
129 typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t;
154 const unsigned int parse_minimal = 0x0000;
157 const unsigned int parse_pi = 0x0001;
160 const unsigned int parse_comments = 0x0002;
163 const unsigned int parse_cdata = 0x0004;
167 const unsigned int parse_ws_pcdata = 0x0008;
170 const unsigned int parse_escapes = 0x0010;
173 const unsigned int parse_eol = 0x0020;
176 const unsigned int parse_wconv_attribute = 0x0040;
179 const unsigned int parse_wnorm_attribute = 0x0080;
182 const unsigned int parse_declaration = 0x0100;
185 const unsigned int parse_doctype = 0x0200;
190 const unsigned int parse_ws_pcdata_single = 0x0400;
193 const unsigned int parse_trim_pcdata = 0x0800;
197 const unsigned int parse_fragment = 0x1000;
202 const unsigned int parse_embed_pcdata = 0x2000;
207 const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol;
212 const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype;
232 const unsigned int format_indent = 0x01;
235 const unsigned int format_write_bom = 0x02;
238 const unsigned int format_raw = 0x04;
241 const unsigned int format_no_declaration = 0x08;
244 const unsigned int format_no_escapes = 0x10;
247 const unsigned int format_save_file_text = 0x20;
250 const unsigned int format_indent_attributes = 0x40;
253 const unsigned int format_no_empty_element_tags = 0x80;
257 const unsigned int format_default = format_indent;
260 struct xml_attribute_struct;
261 struct xml_node_struct;
263 class xml_node_iterator;
264 class xml_attribute_iterator;
265 class xml_named_node_iterator;
267 class xml_tree_walker;
269 struct xml_parse_result;
275 #ifndef PUGIXML_NO_XPATH
277 class xpath_node_set;
279 class xpath_variable_set;
286 typedef It const_iterator;
293 It begin()
const {
return _begin; }
294 It end()
const {
return _end; }
307 virtual void write(
const void* data,
size_t size) = 0;
317 virtual void write(
const void* data,
size_t size) PUGIXML_OVERRIDE;
323 #ifndef PUGIXML_NO_STL
330 xml_writer_stream(std::basic_ostream<
wchar_t, std::char_traits<wchar_t> >& stream);
332 virtual void write(
const void* data,
size_t size) PUGIXML_OVERRIDE;
335 std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
336 std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
359 operator unspecified_bool_type()
const;
362 bool operator!()
const;
376 const char_t* name()
const;
377 const char_t* value()
const;
380 const char_t* as_string(
const char_t* def = PUGIXML_TEXT(
""))
const;
383 int as_int(
int def = 0)
const;
384 unsigned int as_uint(
unsigned int def = 0)
const;
385 double as_double(
double def = 0)
const;
386 float as_float(
float def = 0)
const;
388 #ifdef PUGIXML_HAS_LONG_LONG
389 long long as_llong(
long long def = 0)
const;
390 unsigned long long as_ullong(
unsigned long long def = 0)
const;
394 bool as_bool(
bool def =
false)
const;
397 bool set_name(
const char_t* rhs);
398 bool set_value(
const char_t* rhs);
401 bool set_value(
int rhs);
402 bool set_value(
unsigned int rhs);
403 bool set_value(
long rhs);
404 bool set_value(
unsigned long rhs);
405 bool set_value(
double rhs);
406 bool set_value(
float rhs);
407 bool set_value(
bool rhs);
409 #ifdef PUGIXML_HAS_LONG_LONG
410 bool set_value(
long long rhs);
411 bool set_value(
unsigned long long rhs);
424 #ifdef PUGIXML_HAS_LONG_LONG
434 size_t hash_value()
const;
442 bool PUGIXML_FUNCTION operator&&(
const xml_attribute& lhs,
bool rhs);
443 bool PUGIXML_FUNCTION operator||(
const xml_attribute& lhs,
bool rhs);
456 typedef void (*unspecified_bool_type)(
xml_node***);
466 operator unspecified_bool_type()
const;
469 bool operator!()
const;
472 bool operator==(
const xml_node& r)
const;
473 bool operator!=(
const xml_node& r)
const;
474 bool operator<(
const xml_node& r)
const;
475 bool operator>(
const xml_node& r)
const;
476 bool operator<=(
const xml_node& r)
const;
477 bool operator>=(
const xml_node& r)
const;
483 xml_node_type type()
const;
486 const char_t* name()
const;
490 const char_t* value()
const;
514 xml_node child(
const char_t* name)
const;
516 xml_node next_sibling(
const char_t* name)
const;
517 xml_node previous_sibling(
const char_t* name)
const;
523 const char_t* child_value()
const;
526 const char_t* child_value(
const char_t* name)
const;
529 bool set_name(
const char_t* rhs);
530 bool set_value(
const char_t* rhs);
545 xml_node append_child(xml_node_type type = node_element);
546 xml_node prepend_child(xml_node_type type = node_element);
551 xml_node append_child(
const char_t* name);
552 xml_node prepend_child(
const char_t* name);
570 bool remove_attribute(
const char_t* name);
573 bool remove_child(
const xml_node& n);
574 bool remove_child(
const char_t* name);
579 xml_parse_result append_buffer(
const void* contents,
size_t size,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
582 template <
typename Predicate>
xml_attribute find_attribute(Predicate pred)
const
586 for (
xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
594 template <
typename Predicate>
xml_node find_child(Predicate pred)
const
598 for (
xml_node node = first_child(); node; node = node.next_sibling())
606 template <
typename Predicate>
xml_node find_node(Predicate pred)
const
612 while (cur._root && cur._root != _root)
614 if (pred(cur))
return cur;
616 if (cur.first_child()) cur = cur.first_child();
617 else if (cur.next_sibling()) cur = cur.next_sibling();
620 while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
622 if (cur._root != _root) cur = cur.next_sibling();
630 xml_node find_child_by_attribute(
const char_t* name,
const char_t* attr_name,
const char_t* attr_value)
const;
631 xml_node find_child_by_attribute(
const char_t* attr_name,
const char_t* attr_value)
const;
633 #ifndef PUGIXML_NO_STL
635 string_t path(char_t delimiter =
'/')
const;
639 xml_node first_element_by_path(
const char_t* path, char_t delimiter =
'/')
const;
644 #ifndef PUGIXML_NO_XPATH
660 void print(
xml_writer& writer,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default, xml_encoding encoding = encoding_auto,
unsigned int depth = 0)
const;
662 #ifndef PUGIXML_NO_STL
664 void print(std::basic_ostream<
char, std::char_traits<char> >& os,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default, xml_encoding encoding = encoding_auto,
unsigned int depth = 0)
const;
665 void print(std::basic_ostream<
wchar_t, std::char_traits<wchar_t> >& os,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default,
unsigned int depth = 0)
const;
686 ptrdiff_t offset_debug()
const;
689 size_t hash_value()
const;
697 bool PUGIXML_FUNCTION operator&&(
const xml_node& lhs,
bool rhs);
698 bool PUGIXML_FUNCTION operator||(
const xml_node& lhs,
bool rhs);
708 typedef void (*unspecified_bool_type)(
xml_text***);
720 operator unspecified_bool_type()
const;
723 bool operator!()
const;
729 const char_t* get()
const;
732 const char_t* as_string(
const char_t* def = PUGIXML_TEXT(
""))
const;
735 int as_int(
int def = 0)
const;
736 unsigned int as_uint(
unsigned int def = 0)
const;
737 double as_double(
double def = 0)
const;
738 float as_float(
float def = 0)
const;
740 #ifdef PUGIXML_HAS_LONG_LONG
741 long long as_llong(
long long def = 0)
const;
742 unsigned long long as_ullong(
unsigned long long def = 0)
const;
746 bool as_bool(
bool def =
false)
const;
749 bool set(
const char_t* rhs);
753 bool set(
unsigned int rhs);
755 bool set(
unsigned long rhs);
756 bool set(
double rhs);
760 #ifdef PUGIXML_HAS_LONG_LONG
761 bool set(
long long rhs);
762 bool set(
unsigned long long rhs);
766 xml_text& operator=(
const char_t* rhs);
768 xml_text& operator=(
unsigned int rhs);
770 xml_text& operator=(
unsigned long rhs);
775 #ifdef PUGIXML_HAS_LONG_LONG
777 xml_text& operator=(
unsigned long long rhs);
786 bool PUGIXML_FUNCTION operator&&(
const xml_text& lhs,
bool rhs);
787 bool PUGIXML_FUNCTION operator||(
const xml_text& lhs,
bool rhs);
803 typedef ptrdiff_t difference_type;
808 #ifndef PUGIXML_NO_STL
809 typedef std::bidirectional_iterator_tag iterator_category;
845 typedef ptrdiff_t difference_type;
850 #ifndef PUGIXML_NO_STL
851 typedef std::bidirectional_iterator_tag iterator_category;
881 typedef ptrdiff_t difference_type;
886 #ifndef PUGIXML_NO_STL
887 typedef std::bidirectional_iterator_tag iterator_category;
937 virtual bool for_each(
xml_node& node) = 0;
944 enum xml_parse_status
948 status_file_not_found,
950 status_out_of_memory,
951 status_internal_error,
953 status_unrecognized_tag,
960 status_bad_start_element,
961 status_bad_attribute,
962 status_bad_end_element,
963 status_end_element_mismatch,
965 status_append_invalid_root,
967 status_no_document_element
974 xml_parse_status status;
980 xml_encoding encoding;
986 operator bool()
const;
989 const char* description()
const;
1006 void _move(
xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
1015 #ifdef PUGIXML_HAS_MOVE
1027 #ifndef PUGIXML_NO_STL
1029 xml_parse_result load(std::basic_istream<
char, std::char_traits<char> >& stream,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1030 xml_parse_result load(std::basic_istream<
wchar_t, std::char_traits<wchar_t> >& stream,
unsigned int options = parse_default);
1034 PUGIXML_DEPRECATED
xml_parse_result load(
const char_t* contents,
unsigned int options = parse_default);
1037 xml_parse_result load_string(
const char_t* contents,
unsigned int options = parse_default);
1040 xml_parse_result load_file(
const char* path,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1041 xml_parse_result load_file(
const wchar_t* path,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1044 xml_parse_result load_buffer(
const void* contents,
size_t size,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1048 xml_parse_result load_buffer_inplace(
void* contents,
size_t size,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1052 xml_parse_result load_buffer_inplace_own(
void* contents,
size_t size,
unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
1055 void save(
xml_writer& writer,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default, xml_encoding encoding = encoding_auto)
const;
1057 #ifndef PUGIXML_NO_STL
1059 void save(std::basic_ostream<
char, std::char_traits<char> >& stream,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default, xml_encoding encoding = encoding_auto)
const;
1060 void save(std::basic_ostream<
wchar_t, std::char_traits<wchar_t> >& stream,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default)
const;
1064 bool save_file(
const char* path,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default, xml_encoding encoding = encoding_auto)
const;
1065 bool save_file(
const wchar_t* path,
const char_t* indent = PUGIXML_TEXT(
"\t"),
unsigned int flags = format_default, xml_encoding encoding = encoding_auto)
const;
1071 #ifndef PUGIXML_NO_XPATH
1073 enum xpath_value_type
1076 xpath_type_node_set,
1095 operator bool()
const;
1098 const char* description()
const;
1107 xpath_value_type _type;
1118 const char_t* name()
const;
1121 xpath_value_type type()
const;
1124 bool get_boolean()
const;
1125 double get_number()
const;
1126 const char_t* get_string()
const;
1130 bool set(
bool value);
1131 bool set(
double value);
1132 bool set(
const char_t* value);
1159 #ifdef PUGIXML_HAS_MOVE
1169 bool set(
const char_t* name,
bool value);
1170 bool set(
const char_t* name,
double value);
1171 bool set(
const char_t* name,
const char_t* value);
1186 typedef void (*unspecified_bool_type)(
xpath_query***);
1203 #ifdef PUGIXML_HAS_MOVE
1210 xpath_value_type return_type()
const;
1214 bool evaluate_boolean(
const xpath_node& n)
const;
1218 double evaluate_number(
const xpath_node& n)
const;
1220 #ifndef PUGIXML_NO_STL
1223 string_t evaluate_string(
const xpath_node& n)
const;
1230 size_t evaluate_string(char_t* buffer,
size_t capacity,
const xpath_node& n)
const;
1247 operator unspecified_bool_type()
const;
1250 bool operator!()
const;
1253 #ifndef PUGIXML_NO_EXCEPTIONS
1265 virtual const char* what()
const throw() PUGIXML_OVERRIDE;
1279 typedef void (*unspecified_bool_type)(
xpath_node***);
1297 operator unspecified_bool_type()
const;
1300 bool operator!()
const;
1309 bool PUGIXML_FUNCTION operator&&(
const xpath_node& lhs,
bool rhs);
1310 bool PUGIXML_FUNCTION operator||(
const xpath_node& lhs,
bool rhs);
1344 #ifdef PUGIXML_HAS_MOVE
1351 type_t type()
const;
1354 size_t size()
const;
1357 const xpath_node& operator[](
size_t index)
const;
1364 void sort(
bool reverse =
false);
1385 #ifndef PUGIXML_NO_STL
1387 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(
const wchar_t* str);
1388 std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(
const std::basic_string<
wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str);
1391 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(
const char* str);
1392 std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(
const std::basic_string<
char, std::char_traits<char>, std::allocator<char> >& str);
1396 typedef void* (*allocation_function)(
size_t size);
1399 typedef void (*deallocation_function)(
void* ptr);
1402 void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
1405 allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
1406 deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
1409 #if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
1419 #if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
1433 #if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
1434 # define PUGIXML_SOURCE "smpugixml.cc"
1435 # include PUGIXML_SOURCE
Definition: smpugixml.hh:834
Definition: smpugixml.hh:342
Definition: smpugixml.hh:994
Definition: smpugixml.hh:876
Definition: smpugixml.hh:792
Definition: smpugixml.hh:448
Definition: smpugixml.hh:284
Definition: smpugixml.hh:703
Definition: smpugixml.hh:919
Definition: smpugixml.hh:312
Definition: smpugixml.hh:326
Definition: smpugixml.hh:302
Definition: smpugixml.hh:1256
Definition: smpugixml.hh:1315
Definition: smpugixml.hh:1274
Definition: smpugixml.hh:1181
Definition: smpugixml.hh:1138
Definition: smpugixml.hh:1103
Definition: smpugixml.cc:1095
Definition: smpugixml.cc:1111
Definition: smpugixml.hh:972
Definition: smpugixml.hh:1084