14#ifndef SOURCE_PUGIXML_CPP
15#define SOURCE_PUGIXML_CPP
27#ifdef PUGIXML_WCHAR_MODE
31#ifndef PUGIXML_NO_XPATH
34#ifdef PUGIXML_NO_EXCEPTIONS
50#pragma warning(disable : 4127)
51#pragma warning(disable : 4324)
52#pragma warning(disable : 4611)
53#pragma warning(disable : 4702)
54#pragma warning(disable : 4996)
55#pragma warning(disable : 4793)
58#ifdef __INTEL_COMPILER
59#pragma warning(disable : 177)
60#pragma warning(disable : 279)
61#pragma warning(disable : 1478 1786)
62#pragma warning(disable : 1684)
65#if defined(__BORLANDC__) && defined(PUGIXML_HEADER_ONLY)
78#pragma diag_suppress = 178
79#pragma diag_suppress = 237
83#if defined(_MSC_VER) && _MSC_VER >= 1300
84#define PUGI__NO_INLINE __declspec(noinline)
85#elif defined(__GNUC__)
86#define PUGI__NO_INLINE __attribute__((noinline))
88#define PUGI__NO_INLINE
92#define PUGI__STATIC_ASSERT(cond) \
94 static const char condition_failed[(cond) ? 1 : -1] = { 0 }; \
95 (void)condition_failed[0]; \
92#define PUGI__STATIC_ASSERT(cond) \ …
100#define PUGI__DMC_VOLATILE volatile
102#define PUGI__DMC_VOLATILE
107#if defined(__BORLANDC__) && !defined(__MEM_H_USING_LIST)
114#if defined(_MSC_VER) && !defined(__S3E__)
115#define PUGI__MSVC_CRT_VERSION _MSC_VER
118#ifdef PUGIXML_HEADER_ONLY
119#define PUGI__NS_BEGIN \
124#define PUGI__NS_END \
127#define PUGI__FN inline
128#define PUGI__FN_NO_INLINE inline
130#if defined(_MSC_VER) && \
132#define PUGI__NS_BEGIN \
137#define PUGI__NS_END \
141#define PUGI__NS_BEGIN \
141#define PUGI__NS_BEGIN \ …
148#define PUGI__NS_END \
148#define PUGI__NS_END \ …
154#define PUGI__FN_NO_INLINE PUGI__NO_INLINE
158#if !defined(_MSC_VER) || _MSC_VER >= 1600
161#ifndef _UINTPTR_T_DEFINED
164#define _UINTPTR_T_DEFINED
167typedef unsigned __int8
uint8_t;
207#ifdef PUGIXML_WCHAR_MODE
219#ifdef PUGIXML_WCHAR_MODE
220 return wcscmp(src, dst) == 0;
222 return strcmp(src, dst) == 0;
229 for (
size_t i = 0; i < count; ++i)
230 if (lhs[i] != rhs[i])
233 return lhs[count] == 0;
241#ifdef PUGIXML_WCHAR_MODE
244 const wchar_t *end =
s;
247 return static_cast<size_t>(end -
s);
251#ifdef PUGIXML_WCHAR_MODE
253PUGI__FN void widen_ascii(
wchar_t *dest,
const char *source)
255 for (
const char *i = source; *i; ++i)
262#if !defined(PUGIXML_NO_STL) || !defined(PUGIXML_NO_XPATH)
290#ifdef PUGIXML_MEMORY_PAGE_SIZE
291 PUGIXML_MEMORY_PAGE_SIZE
357 void *page_memory =
reinterpret_cast<void *
>(
393 assert(ptr >= page->
data && ptr < page->data + page->
busy_size);
403 assert(
_root == page);
411 assert(
_root != page);
430 size_t full_size = (size + (
sizeof(
void *) - 1)) & ~(
sizeof(
void *) - 1);
439 ptrdiff_t page_offset =
reinterpret_cast<char *
>(header) - page->
data;
441 assert(page_offset >= 0 && page_offset < (1 << 16));
445 assert(full_size < (1 << 16) || (page->
busy_size == full_size && page_offset == 0));
446 header->
full_size =
static_cast<uint16_t>(full_size < (1 << 16) ? full_size : 0);
450 return static_cast<char_t *
>(
static_cast<void *
>(header + 1));
465 reinterpret_cast<xml_memory_page *
>(
static_cast<void *
>(
reinterpret_cast<char *
>(header) - page_offset));
487 if (size <= large_allocation_threshold)
603 void *memory = alloc.
allocate_memory(
sizeof(xml_attribute_struct), page);
605 return new (memory) xml_attribute_struct(page);
620 if (header & impl::xml_memory_page_name_allocated_mask)
622 if (header & impl::xml_memory_page_value_allocated_mask)
633 if (header & impl::xml_memory_page_name_allocated_mask)
635 if (header & impl::xml_memory_page_value_allocated_mask)
638 for (xml_attribute_struct *attr = n->first_attribute; attr;)
640 xml_attribute_struct *next = attr->next_attribute;
661 xml_node_type type = node_element)
667 child->parent = node;
675 last_child->next_sibling = child;
676 child->prev_sibling_c = last_child;
677 first_child->prev_sibling_c = child;
681 node->first_child = child;
682 child->prev_sibling_c = child;
694 xml_attribute_struct *first_attribute = node->first_attribute;
698 xml_attribute_struct *last_attribute = first_attribute->prev_attribute_c;
700 last_attribute->next_attribute = a;
701 a->prev_attribute_c = last_attribute;
702 first_attribute->prev_attribute_c = a;
706 node->first_attribute = a;
707 a->prev_attribute_c = a;
737 return static_cast<uint16_t>(((value & 0xff) << 8) | (value >> 8));
742 return ((value & 0xff) << 24) | ((value & 0xff00) << 8) | ((value & 0xff0000) >> 8) | (value >> 24);
778 *result =
static_cast<uint8_t>(ch);
784 result[0] =
static_cast<uint8_t>(0xC0 | (ch >> 6));
785 result[1] =
static_cast<uint8_t>(0x80 | (ch & 0x3F));
791 result[0] =
static_cast<uint8_t>(0xE0 | (ch >> 12));
792 result[1] =
static_cast<uint8_t>(0x80 | ((ch >> 6) & 0x3F));
793 result[2] =
static_cast<uint8_t>(0x80 | (ch & 0x3F));
801 result[0] =
static_cast<uint8_t>(0xF0 | (ch >> 18));
802 result[1] =
static_cast<uint8_t>(0x80 | ((ch >> 12) & 0x3F));
803 result[2] =
static_cast<uint8_t>(0x80 | ((ch >> 6) & 0x3F));
804 result[3] =
static_cast<uint8_t>(0x80 | (ch & 0x3F));
810 return (ch < 0x10000) ?
low(result, ch) :
high(result, ch);
829 *result =
static_cast<uint16_t>(ch);
839 result[0] =
static_cast<uint16_t>(0xD800 + msh);
840 result[1] =
static_cast<uint16_t>(0xDC00 + lsh);
847 return (ch < 0x10000) ?
low(result, ch) :
high(result, ch);
892 *result =
static_cast<uint8_t>(ch > 255 ?
'?' : ch);
907template <
size_t size>
929template <
typename Traits,
typename opt_swap = opt_false>
933 typename Traits::value_type result)
935 const uint8_t utf8_byte_mask = 0x3f;
944 result = Traits::low(result, lead);
949 if ((
reinterpret_cast<uintptr_t>(data) & 3) == 0)
953 (*
static_cast<const uint32_t *
>(
static_cast<const void *
>(data)) & 0x80808080) == 0)
955 result = Traits::low(result, data[0]);
956 result = Traits::low(result, data[1]);
957 result = Traits::low(result, data[2]);
958 result = Traits::low(result, data[3]);
965 else if (
static_cast<unsigned int>(lead - 0xC0) < 0x20 && size >= 2 && (data[1] & 0xc0) == 0x80)
967 result = Traits::low(result, ((lead & ~0xC0) << 6) | (data[1] & utf8_byte_mask));
972 else if (
static_cast<unsigned int>(lead - 0xE0) < 0x10 && size >= 3 && (data[1] & 0xc0) == 0x80 &&
973 (data[2] & 0xc0) == 0x80)
975 result = Traits::low(result, ((lead & ~0xE0) << 12) | ((data[1] & utf8_byte_mask) << 6) |
976 (data[2] & utf8_byte_mask));
981 else if (
static_cast<unsigned int>(lead - 0xF0) < 0x08 && size >= 4 && (data[1] & 0xc0) == 0x80 &&
982 (data[2] & 0xc0) == 0x80 && (data[3] & 0xc0) == 0x80)
984 result = Traits::high(result, ((lead & ~0xF0) << 18) | ((data[1] & utf8_byte_mask) << 12) |
985 ((data[2] & utf8_byte_mask) << 6) | (data[3] & utf8_byte_mask));
1001 typename Traits::value_type result)
1007 unsigned int lead = opt_swap::value ?
endian_swap(*data) : *data;
1012 result = Traits::low(result, lead);
1016 else if (
static_cast<unsigned int>(lead - 0xE000) < 0x2000)
1018 result = Traits::low(result, lead);
1022 else if (
static_cast<unsigned int>(lead - 0xD800) < 0x400 && data + 1 < end)
1026 if (
static_cast<unsigned int>(next - 0xDC00) < 0x400)
1028 result = Traits::high(result, 0x10000 + ((lead & 0x3ff) << 10) + (next & 0x3ff));
1046 typename Traits::value_type result)
1057 result = Traits::low(result, lead);
1063 result = Traits::high(result, lead);
1072 typename Traits::value_type result)
1074 for (
size_t i = 0; i < size; ++i)
1076 result = Traits::low(result, data[i]);
1083 typename Traits::value_type result)
1089 typename Traits::value_type result)
1095 typename Traits::value_type result)
1102template <
typename T>
1105 for (
size_t i = 0; i <
length; ++i)
1109#ifdef PUGIXML_WCHAR_MODE
1110PUGI__FN void convert_wchar_endian_swap(
wchar_t *result,
const wchar_t *data,
size_t length)
1112 for (
size_t i = 0; i <
length; ++i)
1132 55, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 63, 0, 0,
1133 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1134 8, 0, 6, 0, 0, 0, 7, 6, 0, 0, 0, 0, 0, 96, 64, 0,
1135 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192, 0, 1, 0, 48, 0,
1136 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1137 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 16, 0, 192,
1138 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1139 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 0,
1141 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1142 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1143 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1144 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1145 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1146 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192
1159 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 3, 3, 2, 3, 3,
1160 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1161 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 16, 16, 0,
1162 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 3, 0,
1164 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
1165 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 20,
1166 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
1167 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0,
1169 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
1170 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
1171 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
1172 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
1173 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
1176#ifdef PUGIXML_WCHAR_MODE
1177#define PUGI__IS_CHARTYPE_IMPL(c, ct, table) \
1178 ((static_cast<unsigned int>(c) < 128 ? table[static_cast<unsigned int>(c)] : table[128]) & (ct))
1180#define PUGI__IS_CHARTYPE_IMPL(c, ct, table) (table[static_cast<unsigned char>(c)] & (ct))
1183#define PUGI__IS_CHARTYPE(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartype_table)
1184#define PUGI__IS_CHARTYPEX(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table)
1188 unsigned int ui = 1;
1190 return *
reinterpret_cast<unsigned char *
>(&ui) == 1;
1197 if (
sizeof(
wchar_t) == 2)
1206 if (d0 == 0 && d1 == 0 && d2 == 0xfe && d3 == 0xff)
1207 return encoding_utf32_be;
1208 if (d0 == 0xff && d1 == 0xfe && d2 == 0 && d3 == 0)
1209 return encoding_utf32_le;
1210 if (d0 == 0xfe && d1 == 0xff)
1211 return encoding_utf16_be;
1212 if (d0 == 0xff && d1 == 0xfe)
1213 return encoding_utf16_le;
1214 if (d0 == 0xef && d1 == 0xbb && d2 == 0xbf)
1215 return encoding_utf8;
1218 if (d0 == 0 && d1 == 0 && d2 == 0 && d3 == 0x3c)
1219 return encoding_utf32_be;
1220 if (d0 == 0x3c && d1 == 0 && d2 == 0 && d3 == 0)
1221 return encoding_utf32_le;
1222 if (d0 == 0 && d1 == 0x3c && d2 == 0 && d3 == 0x3f)
1223 return encoding_utf16_be;
1224 if (d0 == 0x3c && d1 == 0 && d2 == 0x3f && d3 == 0)
1225 return encoding_utf16_le;
1226 if (d0 == 0x3c && d1 == 0x3f && d2 == 0x78 && d3 == 0x6d)
1227 return encoding_utf8;
1231 if (d0 == 0 && d1 == 0x3c)
1232 return encoding_utf16_be;
1233 if (d0 == 0x3c && d1 == 0)
1234 return encoding_utf16_le;
1237 return encoding_utf8;
1243 if (encoding == encoding_wchar)
1247 if (encoding == encoding_utf16)
1251 if (encoding == encoding_utf32)
1255 if (encoding != encoding_auto)
1260 return encoding_utf8;
1273 size_t length = size /
sizeof(char_t);
1277 out_buffer =
static_cast<char_t *
>(
const_cast<void *
>(contents));
1289 out_buffer = buffer;
1296#ifdef PUGIXML_WCHAR_MODE
1297PUGI__FN bool need_endian_swap_utf(xml_encoding le, xml_encoding re)
1299 return (le == encoding_utf16_be && re == encoding_utf16_le) ||
1304PUGI__FN bool convert_buffer_endian_swap(char_t *&out_buffer,
size_t &out_length,
const void *contents,
size_t size,
1307 const char_t *data =
static_cast<const char_t *
>(contents);
1314 convert_wchar_endian_swap(buffer, data,
length);
1316 out_buffer = buffer;
1325 convert_wchar_endian_swap(buffer, data,
length);
1328 out_buffer = buffer;
1335PUGI__FN bool convert_buffer_utf8(char_t *&out_buffer,
size_t &out_length,
const void *contents,
size_t size)
1338 size_t data_length = size;
1349 wchar_writer::value_type obegin =
reinterpret_cast<wchar_writer::value_type
>(buffer);
1352 assert(oend == obegin +
length);
1355 out_buffer = buffer;
1361template <
typename opt_swap>
1365 size_t data_length = size /
sizeof(
uint16_t);
1376 wchar_writer::value_type obegin =
reinterpret_cast<wchar_writer::value_type
>(buffer);
1379 assert(oend == obegin +
length);
1382 out_buffer = buffer;
1388template <
typename opt_swap>
1392 size_t data_length = size /
sizeof(
uint32_t);
1403 wchar_writer::value_type obegin =
reinterpret_cast<wchar_writer::value_type
>(buffer);
1406 assert(oend == obegin +
length);
1409 out_buffer = buffer;
1418 size_t data_length = size;
1421 size_t length = data_length;
1429 wchar_writer::value_type obegin =
reinterpret_cast<wchar_writer::value_type
>(buffer);
1432 assert(oend == obegin +
length);
1435 out_buffer = buffer;
1441PUGI__FN bool convert_buffer(char_t *&out_buffer,
size_t &out_length, xml_encoding encoding,
const void *contents,
1442 size_t size,
bool is_mutable)
1448 if (encoding == wchar_encoding)
1452 if (need_endian_swap_utf(encoding, wchar_encoding))
1453 return convert_buffer_endian_swap(out_buffer, out_length, contents, size, is_mutable);
1456 if (encoding == encoding_utf8)
1457 return convert_buffer_utf8(out_buffer, out_length, contents, size);
1460 if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
1469 if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
1478 if (encoding == encoding_latin1)
1481 assert(!
"Invalid encoding");
1485template <
typename opt_swap>
1489 size_t data_length = size /
sizeof(
uint16_t);
1503 assert(oend == obegin +
length);
1506 out_buffer = buffer;
1512template <
typename opt_swap>
1516 size_t data_length = size /
sizeof(
uint32_t);
1530 assert(oend == obegin +
length);
1533 out_buffer = buffer;
1541 for (
size_t i = 0; i < size; ++i)
1552 size_t data_length = size;
1556 assert(prefix_length <= data_length);
1558 const uint8_t *postfix = data + prefix_length;
1559 size_t postfix_length = data_length - prefix_length;
1562 if (postfix_length == 0)
1574 memcpy(buffer, data, prefix_length);
1579 assert(oend == obegin +
length);
1582 out_buffer = buffer;
1589 size_t size,
bool is_mutable)
1592 if (encoding == encoding_utf8)
1596 if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
1598 xml_encoding native_encoding =
is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
1605 if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
1607 xml_encoding native_encoding =
is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
1614 if (encoding == encoding_latin1)
1617 assert(!
"Invalid encoding");
1634 assert(begin + size == end);
1641#ifndef PUGIXML_NO_STL
1649 result.resize(size);
1666 std::basic_string<wchar_t> result;
1672 wchar_writer::value_type begin =
reinterpret_cast<wchar_writer::value_type
>(&result[0]);
1675 assert(begin +
length == end);
1686 size_t target_length =
strlength(target);
1690 return target_length >=
length;
1693 const size_t reuse_threshold = 32;
1695 return target_length >=
length && (target_length < reuse_threshold || target_length -
length < target_length / 2);
1702 size_t source_length =
strlength(source);
1704 if (source_length == 0)
1709 if (header & header_mask)
1714 header &= ~header_mask;
1721 memcpy(dest, source, (source_length + 1) *
sizeof(char_t));
1735 memcpy(buf, source, (source_length + 1) *
sizeof(char_t));
1738 if (header & header_mask)
1743 header |= header_mask;
1764 memmove(
end -
size,
end,
reinterpret_cast<char *
>(
s) -
reinterpret_cast<char *
>(
end));
1781 memmove(
end -
size,
end,
reinterpret_cast<char *
>(
s) -
reinterpret_cast<char *
>(
end));
1792 char_t *stre =
s + 1;
1798 unsigned int ucsc = 0;
1811 if (
static_cast<unsigned int>(ch -
'0') <= 9)
1812 ucsc = 16 * ucsc + (ch -
'0');
1813 else if (
static_cast<unsigned int>((ch |
' ') -
'a') <= 5)
1814 ucsc = 16 * ucsc + ((ch |
' ') -
'a' + 10);
1827 char_t ch = *++stre;
1834 if (
static_cast<unsigned int>(
static_cast<unsigned int>(ch) -
'0') <= 9)
1835 ucsc = 10 * ucsc + (ch -
'0');
1847#ifdef PUGIXML_WCHAR_MODE
1848 s =
reinterpret_cast<char_t *
>(wchar_writer::any(
reinterpret_cast<wchar_writer::value_type
>(
s), ucsc));
1863 if (*++stre ==
'p' && *++stre ==
';')
1872 else if (*stre ==
'p')
1874 if (*++stre ==
'o' && *++stre ==
's' && *++stre ==
';')
1888 if (*++stre ==
't' && *++stre ==
';')
1901 if (*++stre ==
't' && *++stre ==
';')
1914 if (*++stre ==
'u' && *++stre ==
'o' && *++stre ==
't' && *++stre ==
';')
1933#define ENDSWITH(c, e) ((c) == (e) || ((c) == 0 && endch == (e)))
1951 else if (
s[0] ==
'-' &&
s[1] ==
'-' &&
ENDSWITH(
s[2],
'>'))
1955 return s + (
s[2] ==
'>' ? 3 : 2);
1982 else if (
s[0] ==
']' &&
s[1] ==
']' &&
ENDSWITH(
s[2],
'>'))
1997typedef char_t *(*strconv_pcdata_t)(char_t *);
1999template <
typename opt_trim,
typename opt_eol,
typename opt_escape>
2015 char_t *end = g.
flush(
s);
2017 if (opt_trim::value)
2025 else if (opt_eol::value && *
s ==
'\r')
2032 else if (opt_escape::value && *
s ==
'&')
2038 char_t *end = g.
flush(
s);
2040 if (opt_trim::value)
2056 PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800);
2058 switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4))
2082typedef char_t *(*strconv_attribute_t)(char_t *, char_t);
2084template <
typename opt_escape>
2108 if (*
s == end_quote)
2110 char_t *str = g.
flush(
s);
2124 char_t *str =
s + 1;
2131 else if (opt_escape::value && *
s ==
'&')
2153 if (*
s == end_quote)
2171 else if (opt_escape::value && *
s ==
'&')
2193 if (*
s == end_quote)
2199 else if (*
s ==
'\r')
2206 else if (opt_escape::value && *
s ==
'&')
2228 if (*
s == end_quote)
2234 else if (opt_escape::value && *
s ==
'&')
2250 PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 &&
2251 parse_wnorm_attribute == 0x80);
2253 switch ((optmask >> 4) & 15)
2295 xml_parse_result result;
2296 result.status = status;
2297 result.offset = offset;
2309#define PUGI__SKIPWS() \
2311 while (PUGI__IS_CHARTYPE(*s, ct_space)) \
2309#define PUGI__SKIPWS() \ …
2314#define PUGI__OPTSET(OPT) (optmsk & (OPT))
2315#define PUGI__PUSHNODE(TYPE) \
2317 cursor = append_node(cursor, alloc, TYPE); \
2319 PUGI__THROW_ERROR(status_out_of_memory, s); \
2315#define PUGI__PUSHNODE(TYPE) \ …
2321#define PUGI__POPNODE() \
2323 cursor = cursor->parent; \
2321#define PUGI__POPNODE() \ …
2325#define PUGI__SCANFOR(X) \
2327 while (*s != 0 && !(X)) \
2325#define PUGI__SCANFOR(X) \ …
2330#define PUGI__SCANWHILE(X) \
2330#define PUGI__SCANWHILE(X) \ …
2335#define PUGI__ENDSEG() \
2335#define PUGI__ENDSEG() \ …
2341#define PUGI__THROW_ERROR(err, m) return error_offset = m, error_status = err, static_cast<char_t *>(0)
2342#define PUGI__CHECK_ERROR(err, m) \
2345 PUGI__THROW_ERROR(err, m); \
2342#define PUGI__CHECK_ERROR(err, m) \ …
2359 if (*
s ==
'"' || *
s ==
'\'')
2369 else if (
s[0] ==
'<' &&
s[1] ==
'?')
2379 else if (
s[0] ==
'<' &&
s[1] ==
'!' &&
s[2] ==
'-' &&
s[3] ==
'-')
2397 assert(
s[0] ==
'<' &&
s[1] ==
'!' &&
s[2] ==
'[');
2402 if (
s[0] ==
'<' &&
s[1] ==
'!' &&
s[2] ==
'[')
2409 else if (
s[0] ==
']' &&
s[1] ==
']' &&
s[2] ==
'>')
2425 assert((
s[0] ==
'<' ||
s[0] == 0) &&
s[1] ==
'!');
2430 if (
s[0] ==
'<' &&
s[1] ==
'!' &&
s[2] !=
'-')
2451 else if (
s[0] ==
'<' ||
s[0] ==
'"' ||
s[0] ==
'\'')
2466 if (!toplevel || endch !=
'>')
2507 s += (
s[2] ==
'>' ? 3 : 2);
2516 if (*++
s ==
'C' && *++
s ==
'D' && *++
s ==
'A' && *++
s ==
'T' && *++
s ==
'A' && *++
s ==
'[')
2550 s += (
s[1] ==
'>' ? 2 : 1);
2555 else if (
s[0] ==
'D' &&
s[1] ==
'O' &&
s[2] ==
'C' &&
s[3] ==
'T' &&
s[4] ==
'Y' &&
s[5] ==
'P' &&
2563 char_t *mark =
s + 9;
2569 assert((*
s == 0 && endch ==
'>') || *
s ==
'>');
2580 cursor->value = mark;
2585 else if (*
s == 0 && endch ==
'-')
2587 else if (*
s == 0 && endch ==
'[')
2615 (target[0] |
' ') ==
'x' && (target[1] |
' ') ==
'm' && (target[2] |
' ') ==
'l' && target + 3 ==
s;
2632 cursor->name = target;
2668 cursor->value = value;
2685 s += (
s[1] ==
'>' ? 2 : 1);
2689 ref_cursor = cursor;
2732 xml_attribute_struct *a =
2758 if (*
s ==
'"' || *
s ==
'\'')
2764 s = strconv_attribute(
s, ch);
2791 else if (*
s == 0 && endch ==
'>')
2805 else if (*
s == 0 && endch ==
'>')
2839 char_t *name = cursor->name;
2845 if (*
s++ != *name++)
2851 if (*
s == 0 && name[0] == endch && name[1] == 0)
2881 goto LOC_ATTRIBUTES;
2889 else if (*
s == 0 && endch ==
'?')
2900 if (*
s ==
'<' || !*
s)
2912 if (
s[0] !=
'<' ||
s[1] !=
'/' || cursor->first_child)
2925 s = strconv_pcdata(
s);
2953#ifdef PUGIXML_WCHAR_MODE
2956 unsigned int bom = 0xfeff;
2957 return (
s[0] ==
static_cast<wchar_t>(bom)) ?
s + 1 :
s;
2962 return (
s[0] ==
'\xef' &&
s[1] ==
'\xbb' &&
s[2] ==
'\xbf') ?
s + 3 :
s;
2970 xml_node_type type =
static_cast<xml_node_type
>((node->header & impl::xml_memory_page_type_mask) + 1);
2971 if (type == node_element)
2974 node = node->next_sibling;
2981 unsigned int optmsk)
2991 xml_node_struct *last_root_child = root->first_child ? root->first_child->prev_sibling_c : 0;
2997 char_t endch = buffer[
length - 1];
3004 parser.parse_tree(buffer_data, root, optmsk, endch);
3007 alloc = parser.alloc;
3009 xml_parse_result result =
3010 make_parse_result(parser.error_status, parser.error_offset ? parser.error_offset - buffer : 0);
3011 assert(result.offset >= 0 &&
static_cast<size_t>(result.offset) <=
length);
3021 last_root_child ? last_root_child->next_sibling : root->first_child;
3029 if (result.offset > 0 &&
static_cast<size_t>(result.offset) ==
length - 1 && endch == 0)
3040#ifdef PUGIXML_WCHAR_MODE
3043 return encoding_utf8;
3050 if (encoding == encoding_wchar)
3054 if (encoding == encoding_utf16)
3058 if (encoding == encoding_utf32)
3062 if (encoding != encoding_auto)
3066 return encoding_utf8;
3069#ifdef PUGIXML_WCHAR_MODE
3075 return (
sizeof(
wchar_t) == 2 &&
static_cast<unsigned int>(
static_cast<uint16_t>(data[
length - 1]) - 0xD800) < 0x400)
3081 const char_t *data,
size_t length, xml_encoding encoding)
3086 convert_wchar_endian_swap(r_char, data,
length);
3092 if (encoding == encoding_utf8)
3097 return static_cast<size_t>(end - dest);
3101 if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
3111 if (native_encoding != encoding)
3114 return static_cast<size_t>(end - dest) *
sizeof(
uint16_t);
3118 if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
3128 if (native_encoding != encoding)
3131 return static_cast<size_t>(end - dest) *
sizeof(
uint32_t);
3135 if (encoding == encoding_latin1)
3140 return static_cast<size_t>(end - dest);
3143 assert(!
"Invalid encoding");
3151 for (
size_t i = 1; i <= 4; ++i)
3156 if ((ch & 0xc0) != 0x80)
3166 const char_t *data,
size_t length, xml_encoding encoding)
3168 if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
3177 xml_encoding native_encoding =
is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
3179 if (native_encoding != encoding)
3182 return static_cast<size_t>(end - dest) *
sizeof(
uint16_t);
3185 if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
3194 xml_encoding native_encoding =
is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
3196 if (native_encoding != encoding)
3199 return static_cast<size_t>(end - dest) *
sizeof(
uint32_t);
3202 if (encoding == encoding_latin1)
3208 return static_cast<size_t>(end - dest);
3211 assert(!
"Invalid encoding");
3236 void flush(
const char_t *data,
size_t size)
3243 writer.write(data, size *
sizeof(char_t));
3249 assert(result <=
sizeof(
scratch));
3236 void flush(
const char_t *data,
size_t size) {
…}
3281 flush(data, chunk_size);
3318 void write(char_t d0, char_t d1, char_t d2)
3318 void write(char_t d0, char_t d1, char_t d2) {
…}
3329 void write(char_t d0, char_t d1, char_t d2, char_t d3)
3329 void write(char_t d0, char_t d1, char_t d2, char_t d3) {
…}
3341 void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4)
3341 void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4) {
…}
3354 void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5)
3354 void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5) {
…}
3374#ifdef PUGIXML_MEMORY_OUTPUT_STACK
3375 PUGIXML_MEMORY_OUTPUT_STACK
3401 const char_t *prev =
s;
3407 writer.write(prev,
static_cast<size_t>(
s - prev));
3414 writer.write(
'&',
'a',
'm',
'p',
';');
3418 writer.write(
'&',
'l',
't',
';');
3422 writer.write(
'&',
'g',
't',
';');
3426 writer.write(
'&',
'q',
'u',
'o',
't',
';');
3431 unsigned int ch =
static_cast<unsigned int>(*
s++);
3434 writer.write(
'&',
'#',
static_cast<char_t
>((ch / 10) +
'0'),
static_cast<char_t
>((ch % 10) +
'0'),
';');
3442 if (flags & format_no_escapes)
3452 writer.write(
'<',
'!',
'[',
'C',
'D');
3453 writer.write(
'A',
'T',
'A',
'[');
3455 const char_t *prev =
s;
3458 while (*
s && !(
s[0] ==
']' &&
s[1] ==
']' &&
s[2] ==
'>'))
3465 writer.write(prev,
static_cast<size_t>(
s - prev));
3467 writer.write(
']',
']',
'>');
3473 const char_t *default_name =
PUGIXML_TEXT(
":anonymous");
3475 for (xml_attribute a = node.first_attribute(); a; a = a.next_attribute())
3478 writer.write(a.name()[0] ? a.name() : default_name);
3479 writer.write(
'=',
'"');
3490 const char_t *default_name =
PUGIXML_TEXT(
":anonymous");
3492 if ((flags & format_indent) != 0 && (flags & format_raw) == 0)
3493 for (
unsigned int i = 0; i < depth; ++i)
3494 writer.write(indent);
3496 switch (node.type())
3500 for (xml_node n = node.first_child(); n; n = n.next_sibling())
3507 const char_t *name = node.name()[0] ? node.name() : default_name;
3514 if (flags & format_raw)
3516 if (!node.first_child())
3517 writer.write(
' ',
'/',
'>');
3522 for (xml_node n = node.first_child(); n; n = n.next_sibling())
3525 writer.write(
'<',
'/');
3530 else if (!node.first_child())
3531 writer.write(
' ',
'/',
'>',
'\n');
3532 else if (node.first_child() == node.last_child() &&
3533 (node.first_child().type() == node_pcdata || node.first_child().type() == node_cdata))
3537 if (node.first_child().type() == node_pcdata)
3542 writer.write(
'<',
'/');
3544 writer.write(
'>',
'\n');
3548 writer.write(
'>',
'\n');
3550 for (xml_node n = node.first_child(); n; n = n.next_sibling())
3553 if ((flags & format_indent) != 0 && (flags & format_raw) == 0)
3554 for (
unsigned int i = 0; i < depth; ++i)
3555 writer.write(indent);
3557 writer.write(
'<',
'/');
3559 writer.write(
'>',
'\n');
3567 if ((flags & format_raw) == 0)
3573 if ((flags & format_raw) == 0)
3578 writer.write(
'<',
'!',
'-',
'-');
3579 writer.write(node.value());
3580 writer.write(
'-',
'-',
'>');
3581 if ((flags & format_raw) == 0)
3586 case node_declaration:
3587 writer.write(
'<',
'?');
3588 writer.write(node.name()[0] ? node.name() : default_name);
3590 if (node.type() == node_declaration)
3594 else if (node.value()[0])
3597 writer.write(node.value());
3600 writer.write(
'?',
'>');
3601 if ((flags & format_raw) == 0)
3606 writer.write(
'<',
'!',
'D',
'O',
'C');
3607 writer.write(
'T',
'Y',
'P',
'E');
3609 if (node.value()[0])
3612 writer.write(node.value());
3616 if ((flags & format_raw) == 0)
3621 assert(!
"Invalid node type");
3627 for (xml_node child = node.first_child(); child; child = child.next_sibling())
3629 xml_node_type type = child.type();
3631 if (type == node_declaration)
3633 if (type == node_element)
3642 if (parent != node_document && parent != node_element)
3644 if (child == node_document || child == node_null)
3646 if (parent != node_document && (child == node_declaration || child == node_doctype))
3654 assert(dest.type() == source.type());
3656 switch (source.type())
3660 dest.set_name(source.name());
3662 for (xml_attribute a = source.first_attribute(); a; a = a.next_attribute())
3663 dest.append_attribute(a.name()).set_value(a.value());
3665 for (xml_node
c = source.first_child();
c;
c =
c.next_sibling())
3670 xml_node cc = dest.append_child(
c.type());
3683 dest.set_value(source.value());
3687 dest.set_name(source.name());
3688 dest.set_value(source.value());
3691 case node_declaration:
3693 dest.set_name(source.name());
3695 for (xml_attribute a = source.first_attribute(); a; a = a.next_attribute())
3696 dest.append_attribute(a.name()).set_value(a.value());
3702 assert(!
"Invalid node type");
3708 xml_node_type type =
static_cast<xml_node_type
>((node->header & impl::xml_memory_page_type_mask) + 1);
3710 return type == node_pcdata || type == node_cdata;
3716 const char_t *
s = value;
3724 return (
s[0] ==
'0' && (
s[1] ==
'x' ||
s[1] ==
'X')) ? 16 : 10;
3734#ifdef PUGIXML_WCHAR_MODE
3735 return static_cast<int>(wcstol(value, 0, base));
3737 return static_cast<int>(strtol(value, 0, base));
3748#ifdef PUGIXML_WCHAR_MODE
3749 return static_cast<unsigned int>(wcstoul(value, 0, base));
3751 return static_cast<unsigned int>(strtoul(value, 0, base));
3760#ifdef PUGIXML_WCHAR_MODE
3761 return wcstod(value, 0);
3763 return strtod(value, 0);
3772#ifdef PUGIXML_WCHAR_MODE
3773 return static_cast<float>(wcstod(value, 0));
3775 return static_cast<float>(strtod(value, 0));
3785 char_t first = *value;
3788 return (first ==
'1' || first ==
't' || first ==
'T' || first ==
'y' || first ==
'Y');
3791#ifdef PUGIXML_HAS_LONG_LONG
3792PUGI__FN long long get_value_llong(
const char_t *value,
long long def)
3799#ifdef PUGIXML_WCHAR_MODE
3800#ifdef PUGI__MSVC_CRT_VERSION
3801 return _wcstoi64(value, 0, base);
3803 return wcstoll(value, 0, base);
3806#ifdef PUGI__MSVC_CRT_VERSION
3807 return _strtoi64(value, 0, base);
3809 return strtoll(value, 0, base);
3814PUGI__FN unsigned long long get_value_ullong(
const char_t *value,
unsigned long long def)
3821#ifdef PUGIXML_WCHAR_MODE
3822#ifdef PUGI__MSVC_CRT_VERSION
3823 return _wcstoui64(value, 0, base);
3825 return wcstoull(value, 0, base);
3828#ifdef PUGI__MSVC_CRT_VERSION
3829 return _strtoui64(value, 0, base);
3831 return strtoull(value, 0, base);
3840#ifdef PUGIXML_WCHAR_MODE
3842 impl::widen_ascii(wbuf, buf);
3853 sprintf(buf,
"%d", value);
3861 sprintf(buf,
"%u", value);
3869 sprintf(buf,
"%g", value);
3879#ifdef PUGIXML_HAS_LONG_LONG
3883 sprintf(buf,
"%lld", value);
3891 sprintf(buf,
"%llu", value);
3901#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE)
3903 typedef __int64 length_type;
3905 _fseeki64(file, 0, SEEK_END);
3906 length_type
length = _ftelli64(file);
3907 _fseeki64(file, 0, SEEK_SET);
3908#elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && !defined(__STRICT_ANSI__)
3910 typedef off64_t length_type;
3912 fseeko64(file, 0, SEEK_END);
3913 length_type
length = ftello64(file);
3914 fseeko64(file, 0, SEEK_SET);
3918 typedef long length_type;
3920 fseek(file, 0, SEEK_END);
3921 length_type
length = ftell(file);
3922 fseek(file, 0, SEEK_SET);
3927 return status_io_error;
3930 size_t result =
static_cast<size_t>(
length);
3932 if (
static_cast<length_type
>(result) !=
length)
3933 return status_out_of_memory;
3936 out_result = result;
3944#ifdef PUGIXML_WCHAR_MODE
3947 if (encoding == wchar_encoding || need_endian_swap_utf(encoding, wchar_encoding))
3949 size_t length = size /
sizeof(char_t);
3951 static_cast<char_t *
>(buffer)[
length] = 0;
3952 return (
length + 1) *
sizeof(char_t);
3955 if (encoding == encoding_utf8)
3957 static_cast<char *
>(buffer)[size] = 0;
3974 if (size_status != status_ok)
3980 size_t max_suffix_size =
sizeof(char_t);
3992 size_t read_size = fread(contents, 1, size, file);
3995 if (read_size != size)
4007#ifndef PUGIXML_NO_STL
4008template <
typename T>
4039template <
typename T>
4048 while (!stream.eof())
4053 return status_out_of_memory;
4057 last = last->
next = chunk;
4059 chunks.
data = last = chunk;
4062 stream.read(chunk->
data,
static_cast<std::streamsize
>(
sizeof(chunk->
data) /
sizeof(T)));
4063 chunk->
size =
static_cast<size_t>(stream.gcount()) *
sizeof(T);
4066 if (stream.bad() || (!stream.eof() && stream.fail()))
4067 return status_io_error;
4070 if (total + chunk->
size < total)
4071 return status_out_of_memory;
4072 total += chunk->
size;
4075 size_t max_suffix_size =
sizeof(char_t);
4080 return status_out_of_memory;
4082 char *write = buffer;
4086 assert(write + chunk->size <= buffer + total);
4087 memcpy(write, chunk->data, chunk->size);
4088 write += chunk->size;
4091 assert(write == buffer + total);
4094 *out_buffer = buffer;
4100template <
typename T>
4104 typename std::basic_istream<T>::pos_type pos = stream.tellg();
4105 stream.seekg(0, std::ios::end);
4106 std::streamoff
length = stream.tellg() - pos;
4109 if (stream.fail() || pos < 0)
4110 return status_io_error;
4113 size_t read_length =
static_cast<size_t>(
length);
4115 if (
static_cast<std::streamsize
>(read_length) !=
length ||
length < 0)
4116 return status_out_of_memory;
4118 size_t max_suffix_size =
sizeof(char_t);
4123 return status_out_of_memory;
4125 stream.read(
static_cast<T *
>(buffer.
data),
static_cast<std::streamsize
>(read_length));
4129 if (stream.bad() || (!stream.eof() && stream.fail()))
4130 return status_io_error;
4133 size_t actual_length =
static_cast<size_t>(stream.gcount());
4134 assert(actual_length <= read_length);
4136 *out_buffer = buffer.
release();
4137 *out_size = actual_length *
sizeof(T);
4142template <
typename T>
4144 xml_encoding encoding)
4148 xml_parse_status status = status_ok;
4155 if (stream.tellg() < 0)
4163 if (status != status_ok)
4173#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && !defined(__STRICT_ANSI__))
4176 return _wfopen(path, mode);
4206 char mode_ascii[4] = { 0 };
4207 for (
size_t i = 0; mode[i]; ++i)
4208 mode_ascii[i] =
static_cast<char>(mode[i]);
4211 FILE *result = fopen(path_utf8, mode_ascii);
4221 xml_encoding encoding)
4226 xml_writer_file writer(file);
4227 doc.save(writer, indent, flags, encoding);
4229 int result = ferror(file);
4237 unsigned int options, xml_encoding encoding,
bool is_mutable,
bool own,
4238 char_t **out_buffer)
4241 assert(contents || size == 0);
4244 xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
4250 if (!impl::convert_buffer(buffer,
length, buffer_encoding, contents, size, is_mutable))
4251 return impl::make_parse_result(status_out_of_memory);
4254 if (own && buffer != contents && contents)
4255 impl::xml_memory::deallocate(contents);
4261 xml_parse_result res = impl::xml_parser::parse(buffer,
length, doc, root,
options);
4264 res.encoding = buffer_encoding;
4267 if (own || buffer != contents)
4268 *out_buffer = buffer;
4280 size_t result = fwrite(data, 1, size,
static_cast<FILE *
>(
file));
4284#ifndef PUGIXML_NO_STL
4286 : narrow_stream(&stream), wide_stream(0)
4291 : narrow_stream(0), wide_stream(&stream)
4300 narrow_stream->write(
reinterpret_cast<const char *
>(data),
static_cast<std::streamsize
>(size));
4305 assert(size %
sizeof(
wchar_t) == 0);
4307 wide_stream->write(
reinterpret_cast<const wchar_t *
>(data),
4308 static_cast<std::streamsize
>(size /
sizeof(
wchar_t)));
4418#ifdef PUGIXML_HAS_LONG_LONG
4419PUGI__FN long long xml_attribute::as_llong(
long long def)
const
4424PUGI__FN unsigned long long xml_attribute::as_ullong(
unsigned long long def)
const
4485#ifdef PUGIXML_HAS_LONG_LONG
4504 return impl::strcpy_insitu(
_attr->
name,
_attr->
header, impl::xml_memory_page_name_allocated_mask, rhs);
4512 return impl::strcpy_insitu(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4520 return impl::set_value_convert(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4528 return impl::set_value_convert(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4536 return impl::set_value_convert(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4544 return impl::set_value_convert(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4547#ifdef PUGIXML_HAS_LONG_LONG
4553 return impl::set_value_convert(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4561 return impl::set_value_convert(
_attr->
value,
_attr->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4566PUGI__FN bool operator&&(
const xml_attribute &lhs,
bool rhs)
4568 return (
bool)lhs && rhs;
4571PUGI__FN bool operator||(
const xml_attribute &lhs,
bool rhs)
4573 return (
bool)lhs || rhs;
4685 if (i->name && impl::strequal(name_, i->name))
4697 if (i->name && impl::strequal(name_, i->name))
4709 if (i->name && impl::strequal(name_, i->name))
4732 if (i->name && impl::strequal(name_, i->name))
4759 impl::xml_memory_page *page =
4760 reinterpret_cast<impl::xml_memory_page *
>(
_root->
header & impl::xml_memory_page_pointer_mask);
4762 return xml_node(
static_cast<impl::xml_document_struct *
>(page->allocator));
4776 if (i->value && impl::is_text_node(i))
4814 return impl::strcpy_insitu(
_root->
name,
_root->
header, impl::xml_memory_page_name_allocated_mask, rhs);
4830 return impl::strcpy_insitu(
_root->
value,
_root->
header, impl::xml_memory_page_value_allocated_mask, rhs);
4985 if (!impl::allow_insert_child(this->
type(), type_))
4998 if (!impl::allow_insert_child(this->
type(), type_))
5001 xml_node n(impl::allocate_node(impl::get_allocator(
_root), type_));
5028 if (!impl::allow_insert_child(this->
type(), type_))
5033 xml_node n(impl::allocate_node(impl::get_allocator(
_root), type_));
5056 if (!impl::allow_insert_child(this->
type(), type_))
5061 xml_node n(impl::allocate_node(impl::get_allocator(
_root), type_));
5123 impl::recursive_copy_skip(result, proto, result);
5133 impl::recursive_copy_skip(result, proto, result);
5143 impl::recursive_copy_skip(result, proto, result);
5153 impl::recursive_copy_skip(result, proto, result);
5187 impl::destroy_attribute(a.
_attr, impl::get_allocator(
_root));
5212 impl::destroy_node(n.
_root, impl::get_allocator(
_root));
5225 impl::xml_document_struct *doc =
static_cast<impl::xml_document_struct *
>(
root().
_root);
5229 impl::xml_memory_page *page = 0;
5230 impl::xml_extra_buffer *extra =
5231 static_cast<impl::xml_extra_buffer *
>(doc->allocate_memory(
sizeof(impl::xml_extra_buffer), page));
5245 false,
false, &buffer);
5251 extra->buffer = buffer;
5252 extra->next = doc->extra_buffers;
5253 doc->extra_buffers = extra;
5259 const char_t *attr_value)
const
5265 if (i->name && impl::strequal(name_, i->name))
5268 if (a->name && impl::strequal(attr_name, a->name) &&
5269 impl::strequal(attr_value, a->value ? a->value :
PUGIXML_TEXT(
"")))
5283 if (a->name && impl::strequal(attr_name, a->name) &&
5284 impl::strequal(attr_value, a->value ? a->value :
PUGIXML_TEXT(
"")))
5290#ifndef PUGIXML_NO_STL
5299 cursor = cursor.
parent();
5315 if (!
_root || !path_ || !path_[0])
5318 if (path_[0] == delimiter)
5321 found = found.
root();
5325 const char_t *path_segment = path_;
5327 while (*path_segment == delimiter)
5330 const char_t *path_segment_end = path_segment;
5332 while (*path_segment_end && *path_segment_end != delimiter)
5335 if (path_segment == path_segment_end)
5338 const char_t *next_segment = path_segment_end;
5340 while (*next_segment == delimiter)
5343 if (*path_segment ==
'.' && path_segment + 1 == path_segment_end)
5345 else if (*path_segment ==
'.' && *(path_segment + 1) ==
'.' && path_segment + 2 == path_segment_end)
5352 impl::strequalrange(j->name, path_segment,
static_cast<size_t>(path_segment_end - path_segment)))
5370 if (!walker.
begin(arg_begin))
5382 if (!walker.
for_each(arg_for_each))
5404 }
while (cur && cur != *
this);
5407 assert(walker.
_depth == -1);
5410 return walker.
end(arg_end);
5424 unsigned int depth)
const
5429 impl::xml_buffered_writer buffered_writer(writer, encoding);
5431 impl::node_output(buffered_writer, *
this, indent, flags, depth);
5434#ifndef PUGIXML_NO_STL
5436 unsigned int flags,
xml_encoding encoding,
unsigned int depth)
const
5440 print(writer, indent, flags, encoding, depth);
5444 unsigned int flags,
unsigned int depth)
const
5459 const char_t *buffer =
static_cast<impl::xml_document_struct *
>(r)->buffer;
5472 return (
_root->
header & impl::xml_memory_page_name_allocated_mask) ? -1 :
_root->
name - buffer;
5488 return (
bool)lhs && rhs;
5491PUGI__FN bool operator||(
const xml_node &lhs,
bool rhs)
5493 return (
bool)lhs || rhs;
5505 if (impl::is_text_node(node))
5536 return _data() == 0;
5550 return (d && d->value) ? d->value : def;
5557 return impl::get_value_int(d ? d->value : 0, def);
5564 return impl::get_value_uint(d ? d->value : 0, def);
5571 return impl::get_value_double(d ? d->value : 0, def);
5578 return impl::get_value_float(d ? d->value : 0, def);
5585 return impl::get_value_bool(d ? d->value : 0, def);
5588#ifdef PUGIXML_HAS_LONG_LONG
5589PUGI__FN long long xml_text::as_llong(
long long def)
const
5593 return impl::get_value_llong(d ? d->value : 0, def);
5596PUGI__FN unsigned long long xml_text::as_ullong(
unsigned long long def)
const
5600 return impl::get_value_ullong(d ? d->value : 0, def);
5608 return dn ? impl::strcpy_insitu(dn->
value, dn->
header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5615 return dn ? impl::set_value_convert(dn->
value, dn->
header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5622 return dn ? impl::set_value_convert(dn->
value, dn->
header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5629 return dn ? impl::set_value_convert(dn->
value, dn->
header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5636 return dn ? impl::set_value_convert(dn->
value, dn->
header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5639#ifdef PUGIXML_HAS_LONG_LONG
5644 return dn ? impl::set_value_convert(dn->
value, dn->
header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5651 return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) :
false;
5685#ifdef PUGIXML_HAS_LONG_LONG
5707 return (
bool)lhs && rhs;
5710PUGI__FN bool operator||(
const xml_text &lhs,
bool rhs)
5712 return (
bool)lhs || rhs;
5721 : _wrap(ref), _parent(parent)
5777 : _wrap(attr), _parent(parent)
5782 : _wrap(ref), _parent(parent)
5838 : _wrap(node), _parent(node.parent()), _name(name)
5844 : _wrap(ref), _parent(parent), _name(name)
5921 return "File was not found";
5923 return "Error reading from file/stream";
5925 return "Could not allocate memory";
5927 return "Internal error occurred";
5930 return "Could not determine tag type";
5933 return "Error parsing document declaration/processing instruction";
5935 return "Error parsing comment";
5937 return "Error parsing CDATA section";
5939 return "Error parsing document type declaration";
5941 return "Error parsing PCDATA section";
5943 return "Error parsing start element tag";
5945 return "Error parsing element attribute";
5947 return "Error parsing end element tag";
5949 return "Start-end tags mismatch";
5952 return "Unable to append nodes: root is not an element or document";
5955 return "No document element found";
5958 return "Unknown error";
5992 impl::xml_memory_page_alignment <=
5997 reinterpret_cast<void *
>((
reinterpret_cast<uintptr_t>(
_memory) + (impl::xml_memory_page_alignment - 1)) &
5998 ~(impl::xml_memory_page_alignment - 1));
6001 impl::xml_memory_page *page = impl::xml_memory_page::construct(page_memory);
6004 page->busy_size = impl::xml_memory_page_size;
6007 _root =
new (page->data) impl::xml_document_struct(page);
6011 page->allocator =
static_cast<impl::xml_document_struct *
>(
_root);
6021 impl::xml_memory::deallocate(
_buffer);
6026 for (impl::xml_extra_buffer *extra =
static_cast<impl::xml_document_struct *
>(
_root)->extra_buffers; extra;
6027 extra = extra->next)
6030 impl::xml_memory::deallocate(extra->buffer);
6034 impl::xml_memory_page *root_page =
6035 reinterpret_cast<impl::xml_memory_page *
>(
_root->
header & impl::xml_memory_page_pointer_mask);
6036 assert(root_page && !root_page->prev && !root_page->memory);
6038 for (impl::xml_memory_page *page = root_page->next; page;)
6040 impl::xml_memory_page *next = page->next;
6042 impl::xml_allocator::deallocate_page(page);
6050#ifndef PUGIXML_NO_STL
6056 return impl::load_stream_impl(*
this, stream,
options, encoding);
6071#ifdef PUGIXML_WCHAR_MODE
6084 FILE *file = fopen(path_,
"rb");
6086 return impl::load_file_impl(*
this, file,
options, encoding);
6093 FILE *file = impl::open_file_wide(path_, L
"rb");
6095 return impl::load_file_impl(*
this, file,
options, encoding);
6103 return impl::load_buffer_impl(
static_cast<impl::xml_document_struct *
>(
_root),
_root,
const_cast<void *
>(contents),
6112 return impl::load_buffer_impl(
static_cast<impl::xml_document_struct *
>(
_root),
_root, contents, size,
options,
6113 encoding,
true,
false, &
_buffer);
6121 return impl::load_buffer_impl(
static_cast<impl::xml_document_struct *
>(
_root),
_root, contents, size,
options,
6122 encoding,
true,
true, &
_buffer);
6128 impl::xml_buffered_writer buffered_writer(writer, encoding);
6133#ifdef PUGIXML_WCHAR_MODE
6134 unsigned int bom = 0xfeff;
6135 buffered_writer.write(
static_cast<wchar_t>(bom));
6137 buffered_writer.write(
'\xef',
'\xbb',
'\xbf');
6143 buffered_writer.write(
PUGIXML_TEXT(
"<?xml version=\"1.0\""));
6145 buffered_writer.write(
PUGIXML_TEXT(
" encoding=\"ISO-8859-1\""));
6146 buffered_writer.write(
'?',
'>');
6148 buffered_writer.write(
'\n');
6151 impl::node_output(buffered_writer, *
this, indent, flags, 0);
6154#ifndef PUGIXML_NO_STL
6160 save(writer, indent, flags, encoding);
6164 unsigned int flags)
const
6176 return impl::save_file_impl(*
this, file, indent, flags, encoding);
6183 return impl::save_file_impl(*
this, file, indent, flags, encoding);
6191 if ((i->header & impl::xml_memory_page_type_mask) + 1 ==
node_element)
6197#ifndef PUGIXML_NO_STL
6202 return impl::as_utf8_impl(str, impl::strlength_wide(str));
6207 return impl::as_utf8_impl(str.c_str(), str.size());
6214 return impl::as_wide_impl(str, strlen(str));
6219 return impl::as_wide_impl(str.c_str(), str.size());
6226 impl::xml_memory::allocate = allocate;
6227 impl::xml_memory::deallocate = deallocate;
6232 return impl::xml_memory::allocate;
6237 return impl::xml_memory::deallocate;
6241#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
6247 return std::bidirectional_iterator_tag();
6252 return std::bidirectional_iterator_tag();
6257 return std::bidirectional_iterator_tag();
6262#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
6268 return std::bidirectional_iterator_tag();
6273 return std::bidirectional_iterator_tag();
6278 return std::bidirectional_iterator_tag();
6283#ifndef PUGIXML_NO_XPATH
6289 template <
typename T>
6298 template <
typename T>
6307 template <
typename T>
6316 template <
typename T>
6323template <
typename T>
6331template <
typename I,
typename Pred>
6336 for (I it = begin + 1; it != end; ++it)
6337 if (pred(*it, *result))
6343template <
typename I>
6346 while (end - begin > 1)
6347 swap(*begin++, *--end);
6350template <
typename I>
6354 while (end - begin > 1 && *begin != *(begin + 1))
6364 while (begin != end)
6366 if (*begin != *write)
6367 *++write = *begin++;
6376template <
typename I>
6379 while (begin != end)
6383template <
typename I,
typename Pred,
typename T>
6386 assert(begin != end);
6388 for (I it = begin + 1; it != end; ++it)
6392 if (pred(val, *begin))
6403 while (pred(val, *(hole - 1)))
6405 *hole = *(hole - 1);
6416template <
typename I,
typename Pred>
6417void partition(I begin, I middle, I end,
const Pred &pred, I *out_eqbeg, I *out_eqend)
6419 I eqbeg = middle, eqend = middle + 1;
6422 while (eqbeg != begin && *(eqbeg - 1) == *eqbeg)
6424 while (eqend != end && *eqend == *eqbeg)
6428 I ltend = eqbeg, gtbeg = eqend;
6433 for (; gtbeg != end; ++gtbeg)
6434 if (!pred(*eqbeg, *gtbeg))
6436 if (*gtbeg == *eqbeg)
6437 swap(*gtbeg, *eqend++);
6443 for (; ltend != begin; --ltend)
6444 if (!pred(*(ltend - 1), *eqbeg))
6446 if (*eqbeg == *(ltend - 1))
6447 swap(*(ltend - 1), *--eqbeg);
6453 if (gtbeg == end && ltend == begin)
6463 if (--ltend != --eqbeg)
6464 swap(*ltend, *eqbeg);
6465 swap(*eqbeg, *--eqend);
6467 else if (ltend == begin)
6470 swap(*eqbeg, *eqend);
6472 swap(*gtbeg++, *eqbeg++);
6475 swap(*gtbeg++, *--ltend);
6417void partition(I begin, I middle, I end,
const Pred &pred, I *out_eqbeg, I *out_eqend) {
…}
6479template <
typename I,
typename Pred>
6480void median3(I first, I middle, I last,
const Pred &pred)
6482 if (pred(*middle, *first))
6483 swap(*middle, *first);
6484 if (pred(*last, *middle))
6485 swap(*last, *middle);
6486 if (pred(*middle, *first))
6487 swap(*middle, *first);
6480void median3(I first, I middle, I last,
const Pred &pred) {
…}
6490template <
typename I,
typename Pred>
6491void median(I first, I middle, I last,
const Pred &pred)
6493 if (last - first <= 40)
6496 median3(first, middle, last, pred);
6501 size_t step = (last - first + 1) / 8;
6491void median(I first, I middle, I last,
const Pred &pred) {
…}
6510template <
typename I,
typename Pred>
6511void sort(I begin, I end,
const Pred &pred)
6514 while (end - begin > 32)
6517 I middle = begin + (end - begin) / 2;
6518 median(begin, middle, end - 1, pred);
6522 partition(begin, middle, end, pred, &eqbeg, &eqend);
6525 if (eqbeg - begin > end - eqend)
6527 sort(eqend, end, pred);
6532 sort(begin, eqbeg, pred);
6511void sort(I begin, I end,
const Pred &pred) {
…}
6550#ifdef PUGIXML_MEMORY_XPATH_PAGE_SIZE
6551 PUGIXML_MEMORY_XPATH_PAGE_SIZE
6564#ifdef PUGIXML_NO_EXCEPTIONS
6565 jmp_buf *error_handler;
6570#ifdef PUGIXML_NO_EXCEPTIONS
6577 const size_t block_capacity =
sizeof(
_root->
data);
6580 size = (size +
sizeof(
void *) - 1) & ~(
sizeof(
void *) - 1);
6590 size_t block_data_size = (size > block_capacity) ? size : block_capacity;
6612#ifdef PUGIXML_NO_EXCEPTIONS
6613 assert(error_handler);
6614 longjmp(*error_handler, 1);
6616 throw std::bad_alloc();
6626 old_size = (old_size +
sizeof(
void *) - 1) & ~(
sizeof(
void *) - 1);
6627 new_size = (new_size +
sizeof(
void *) - 1) & ~(
sizeof(
void *) - 1);
6643 if (result != ptr && ptr)
6646 assert(new_size >= old_size);
6647 memcpy(result, ptr, old_size);
6674 while (cur != state.
_root)
6727#ifdef PUGIXML_NO_EXCEPTIONS
6728 jmp_buf error_handler;
6738#ifdef PUGIXML_NO_EXCEPTIONS
6739 result.error_handler =
temp.error_handler = &error_handler;
6760 char_t *result =
static_cast<char_t *
>(alloc->
allocate((
length + 1) *
sizeof(char_t)));
6779 bool empty_ = (*str == 0);
6789 assert(begin <= end);
6791 bool empty_ = (begin == end);
6813 size_t result_length = target_length + source_length;
6817 (target_length + 1) *
sizeof(char_t),
6818 (result_length + 1) *
sizeof(char_t)));
6826 memcpy(result + target_length, o.
_buffer, source_length *
sizeof(char_t));
6827 result[result_length] = 0;
6848 return const_cast<char_t *
>(
_buffer);
6869 while (*pattern && *
string == *pattern)
6875 return *pattern == 0;
6880#ifdef PUGIXML_WCHAR_MODE
6881 return wcschr(
s,
c);
6883 return strchr(
s,
c);
6889#ifdef PUGIXML_WCHAR_MODE
6891 return (*p == 0) ?
s : wcsstr(
s, p);
6893 return strstr(
s, p);
6900 return static_cast<unsigned int>(ch -
'A') < 26 ?
static_cast<char_t
>(ch |
' ') : ch;
6909 const xml_node &n = na.node();
6924 xml_node cur = n.first_child();
6926 while (cur && cur != n)
6928 if (cur.type() == node_pcdata || cur.type() == node_cdata)
6931 if (cur.first_child())
6932 cur = cur.first_child();
6933 else if (cur.next_sibling())
6934 cur = cur.next_sibling();
6937 while (!cur.next_sibling() && cur != n)
6941 cur = cur.next_sibling();
6956 unsigned int result = 0;
6970 for (
unsigned int i = rh; i < lh; i++)
6972 for (
unsigned int j = lh; j < rh; j++)
6980 while (ln.parent() != rn.parent())
6991 for (; ln; ln = ln.next_sibling())
7000 while (node && node != parent)
7001 node = node.parent();
7003 return parent && node == parent;
7019 xml_attribute_struct *attr = xnode.attribute().internal_object();
7035 bool operator()(
const xpath_node &lhs,
const xpath_node &rhs)
const
7045 xml_node ln = lhs.node(), rn = rhs.node();
7048 if (lhs.attribute() && rhs.attribute())
7051 if (lhs.parent() == rhs.parent())
7054 for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute())
7055 if (a == rhs.attribute())
7065 else if (lhs.attribute())
7068 if (lhs.parent() == rhs.node())
7073 else if (rhs.attribute())
7076 if (rhs.parent() == lhs.node())
7035 bool operator()(
const xpath_node &lhs,
const xpath_node &rhs)
const {
…}
7094 bool operator()(
const xpath_node &lhs,
const xpath_node &rhs)
const
7096 if (lhs.attribute())
7097 return rhs.attribute() ? lhs.attribute() < rhs.attribute() :
true;
7099 return rhs.attribute() ?
false : lhs.node() < rhs.node();
7094 bool operator()(
const xpath_node &lhs,
const xpath_node &rhs)
const {
…}
7105#if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24))
7110 u[0].i = 0x7fc00000;
7114 const volatile double zero = 0.0;
7121#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__)
7122 return !!_isnan(value);
7123#elif defined(fpclassify) && defined(FP_NAN)
7127 const volatile double v = value;
7134#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__)
7140#elif defined(fpclassify) && defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO)
7157 const volatile double v = value;
7171 return (value != 0 && !
is_nan(value));
7176 while (begin != end && end[-1] ==
'0')
7183#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE)
7189 _ecvt_s(buffer, buffer_size, value,
DBL_DIG + 1, &exponent, &
sign);
7195 *out_mantissa = buffer;
7196 *out_exponent = exponent;
7203 sprintf(buffer,
"%.*e",
DBL_DIG, value);
7204 assert(strlen(buffer) < buffer_size);
7208 char *exponent_string = strchr(buffer,
'e');
7209 assert(exponent_string);
7211 int exponent = atoi(exponent_string + 1);
7214 char *mantissa = buffer[0] ==
'-' ? buffer + 1 : buffer;
7215 assert(mantissa[0] !=
'0' && mantissa[1] ==
'.');
7218 mantissa[1] = mantissa[0];
7226 *out_mantissa = mantissa;
7227 *out_exponent = exponent;
7239 char mantissa_buffer[32];
7246 size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4;
7247 char_t *result =
static_cast<char_t *
>(alloc->
allocate(
sizeof(char_t) * result_size));
7264 while (exponent > 0)
7266 assert(*mantissa == 0 ||
static_cast<unsigned int>(
static_cast<unsigned int>(*mantissa) -
'0') <= 9);
7267 *
s++ = *mantissa ? *mantissa++ :
'0';
7279 while (exponent < 0)
7288 assert(
static_cast<unsigned int>(*mantissa -
'0') <= 9);
7294 assert(
s < result + result_size);
7334 return *
string == 0;
7344#ifdef PUGIXML_WCHAR_MODE
7345 return wcstod(
string, 0);
7347 return atof(
string);
7354 size_t length =
static_cast<size_t>(end - begin);
7355 char_t *scratch = buffer;
7357 if (
length >=
sizeof(buffer) /
sizeof(buffer[0]))
7372 if (scratch != buffer)
7380 return floor(value + 0.5);
7387 return (value >= -0.5 && value <= 0) ?
ceil(value) :
floor(value + 0.5);
7392 return node.attribute() ? node.attribute().name() : node.node().name();
7400 return p ? p + 1 : name;
7410 const char_t *pos =
find_char(name,
':');
7418 const char_t *name = a.name();
7435 xml_attribute a = p.find_attribute(pred);
7454 xml_node p = parent;
7458 xml_attribute a = p.find_attribute(pred);
7476 char_t *write = buffer;
7478 for (char_t *it = buffer; *it;)
7489 if (write != buffer)
7508 char_t *write = buffer;
7514 const char_t *pos =
find_char(from, ch);
7518 else if (
static_cast<size_t>(pos - from) < to_length)
7519 *write++ = to[pos - from];
7567 unsigned int result = 0;
7571 result +=
static_cast<unsigned int>(*str++);
7572 result += result << 10;
7573 result ^= result >> 6;
7576 result += result << 3;
7577 result ^= result >> 11;
7578 result += result << 15;
7583template <
typename T>
7595 T *result =
new (memory) T();
7597 memcpy(result->name, name, (
length + 1) *
sizeof(char_t));
7606 case xpath_type_node_set:
7607 return new_xpath_variable<xpath_variable_node_set>(name);
7609 case xpath_type_number:
7610 return new_xpath_variable<xpath_variable_number>(name);
7612 case xpath_type_string:
7613 return new_xpath_variable<xpath_variable_string>(name);
7615 case xpath_type_boolean:
7616 return new_xpath_variable<xpath_variable_boolean>(name);
7623template <
typename T>
7634 case xpath_type_node_set:
7638 case xpath_type_number:
7642 case xpath_type_string:
7646 case xpath_type_boolean:
7651 assert(!
"Invalid variable type");
7658 size_t length =
static_cast<size_t>(end - begin);
7659 char_t *scratch = buffer;
7661 if (
length >=
sizeof(buffer) /
sizeof(buffer[0]))
7676 if (scratch != buffer)
7685PUGI__FN xpath_node_set::type_t
xpath_sort(xpath_node *begin, xpath_node *end, xpath_node_set::type_t type,
bool rev)
7687 xpath_node_set::type_t order = rev ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted;
7689 if (type == xpath_node_set::type_unsorted)
7693 type = xpath_node_set::type_sorted;
7685PUGI__FN xpath_node_set::type_t
xpath_sort(xpath_node *begin, xpath_node *end, xpath_node_set::type_t type,
bool rev) {
…}
7705 return xpath_node();
7709 case xpath_node_set::type_sorted:
7712 case xpath_node_set::type_sorted_reverse:
7715 case xpath_node_set::type_unsorted:
7719 assert(!
"Invalid node set type");
7720 return xpath_node();
7749 size_t capacity =
static_cast<size_t>(
_eos -
_begin);
7752 size_t new_capacity = capacity + capacity / 2 + 1;
7755 xpath_node *data =
static_cast<xpath_node *
>(
7756 alloc->
reallocate(
_begin, capacity *
sizeof(xpath_node), new_capacity *
sizeof(xpath_node)));
7761 _end = data + capacity;
7762 _eos = data + new_capacity;
7770 size_t size_ =
static_cast<size_t>(
_end -
_begin);
7771 size_t capacity =
static_cast<size_t>(
_eos -
_begin);
7772 size_t count =
static_cast<size_t>(end_ - begin_);
7774 if (size_ + count > capacity)
7777 xpath_node *data =
static_cast<xpath_node *
>(
7778 alloc->
reallocate(
_begin, capacity *
sizeof(xpath_node), (size_ + count) *
sizeof(xpath_node)));
7783 _end = data + size_;
7784 _eos = data + size_ + count;
7787 memcpy(
_end, begin_, count *
sizeof(xpath_node));
7802 if (
_type == xpath_node_set::type_unsorted)
7884 const char_t *cur =
_cur;
7899 if (*(cur + 1) ==
'=')
7912 if (*(cur + 1) ==
'=')
7925 if (*(cur + 1) ==
'=')
8026 if (*(cur + 1) ==
'/')
8039 if (*(cur + 1) ==
'.')
8073 char_t terminator = *cur;
8078 while (*cur && *cur != terminator)
8094 if (*(cur + 1) ==
':')
8305 template <
class Comp>
8311 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
8313 if (lt == xpath_type_boolean || rt == xpath_type_boolean)
8315 else if (lt == xpath_type_number || rt == xpath_type_number)
8317 else if (lt == xpath_type_string || rt == xpath_type_string)
8324 return comp(ls, rs);
8327 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
8334 for (
const xpath_node *li = ls.
begin(); li != ls.
end(); ++li)
8335 for (
const xpath_node *ri = rs.
begin(); ri != rs.
end(); ++ri)
8347 if (lt == xpath_type_node_set)
8353 if (lt == xpath_type_boolean)
8355 else if (lt == xpath_type_number)
8362 for (
const xpath_node *ri = rs.
begin(); ri != rs.
end(); ++ri)
8372 else if (lt == xpath_type_string)
8379 for (
const xpath_node *ri = rs.
begin(); ri != rs.
end(); ++ri)
8391 assert(!
"Wrong types");
8395 template <
class Comp>
8401 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
8403 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
8410 for (
const xpath_node *li = ls.
begin(); li != ls.
end(); ++li)
8416 for (
const xpath_node *ri = rs.
begin(); ri != rs.
end(); ++ri)
8427 else if (lt != xpath_type_node_set && rt == xpath_type_node_set)
8434 for (
const xpath_node *ri = rs.
begin(); ri != rs.
end(); ++ri)
8444 else if (lt == xpath_type_node_set && rt != xpath_type_node_set)
8451 for (
const xpath_node *li = ls.
begin(); li != ls.
end(); ++li)
8463 assert(!
"Wrong types");
8470 assert(ns.
size() >= first);
8473 size_t size = ns.
size() - first;
8475 xpath_node *last = ns.
begin() + first;
8478 for (xpath_node *it = last; it != ns.
end(); ++it, ++i)
8482 if (expr->
rettype() == xpath_type_number)
8496 if (ns.
size() == first)
8510 const char_t *name = a.name();
8521 ns.
push_back(xpath_node(a, parent), alloc);
8526 ns.
push_back(xpath_node(a, parent), alloc);
8531 ns.
push_back(xpath_node(a, parent), alloc);
8546 if (n.type() == node_element &&
strequal(n.name(),
_data.nodetest))
8555 if (n.type() == node_comment)
8560 if (n.type() == node_pcdata || n.type() == node_cdata)
8565 if (n.type() == node_pi)
8570 if (n.type() == node_pi &&
strequal(n.name(),
_data.nodetest))
8575 if (n.type() == node_element)
8585 assert(!
"Unknown axis");
8592 const axis_t axis = T::axis;
8598 for (xml_attribute a = n.first_attribute(); a; a = a.next_attribute())
8606 for (xml_node
c = n.first_child();
c;
c =
c.next_sibling())
8618 xml_node cur = n.first_child();
8620 while (cur && cur != n)
8624 if (cur.first_child())
8625 cur = cur.first_child();
8626 else if (cur.next_sibling())
8627 cur = cur.next_sibling();
8630 while (!cur.next_sibling() && cur != n)
8634 cur = cur.next_sibling();
8643 for (xml_node
c = n.next_sibling();
c;
c =
c.next_sibling())
8651 for (xml_node
c = n.previous_sibling();
c;
c =
c.previous_sibling())
8662 while (cur && !cur.next_sibling())
8664 cur = cur.next_sibling();
8670 if (cur.first_child())
8671 cur = cur.first_child();
8672 else if (cur.next_sibling())
8673 cur = cur.next_sibling();
8676 while (cur && !cur.next_sibling())
8678 cur = cur.next_sibling();
8692 while (cur && !cur.previous_sibling())
8694 cur = cur.previous_sibling();
8698 if (cur.last_child())
8699 cur = cur.last_child();
8705 if (cur.previous_sibling())
8706 cur = cur.previous_sibling();
8717 }
while (!cur.previous_sibling());
8719 cur = cur.previous_sibling();
8736 xml_node cur = n.parent();
8764 assert(!
"Unimplemented axis");
8771 const axis_t axis = T::axis;
8809 if (cur.first_child())
8810 cur = cur.first_child();
8811 else if (cur.next_sibling())
8812 cur = cur.next_sibling();
8815 while (cur && !cur.next_sibling())
8817 cur = cur.next_sibling();
8845 assert(!
"Unimplemented axis");
8852 const axis_t axis = T::axis;
8860 ? xpath_node_set::type_sorted_reverse
8861 : xpath_node_set::type_sorted);
8871 for (
const xpath_node *it =
s.begin(); it !=
s.end(); ++it)
8873 size_t size = ns.
size();
8878 ns.
set_type(xpath_node_set::type_unsorted);
8882 else if (attributes)
8892 else if (attributes)
8902 ns.
type() == xpath_node_set::type_unsorted)
8910 :
_type(static_cast<char>(type))
8911 ,
_rettype(static_cast<char>(rettype_))
8919 _data.string = value;
8923 :
_type(static_cast<char>(type))
8924 ,
_rettype(static_cast<char>(rettype_))
8932 _data.number = value;
8936 :
_type(static_cast<char>(type))
8937 ,
_rettype(static_cast<char>(rettype_))
8945 _data.variable = value;
8949 :
_type(static_cast<char>(type))
8950 ,
_rettype(static_cast<char>(rettype_))
8960 :
_type(static_cast<char>(type))
8962 ,
_axis(static_cast<char>(axis))
8963 ,
_test(static_cast<char>(test))
9037 if (
c.n.attribute())
9044 for (xml_node n =
c.n.node(); n; n = n.parent())
9046 xml_attribute a = n.attribute(
PUGIXML_TEXT(
"xml:lang"));
9050 const char_t *value = a.value();
9053 for (
const char_t *lit = lang.
c_str(); *lit; ++lit)
9060 return *value == 0 || *value ==
'-';
9071 if (
_rettype == xpath_type_boolean)
9072 return _data.variable->get_boolean();
9081 case xpath_type_number:
9084 case xpath_type_string:
9091 case xpath_type_node_set:
9099 assert(!
"Wrong expression for return type boolean");
9129 return _data.number;
9132 return static_cast<double>(
c.size);
9135 return static_cast<double>(
c.position);
9176 for (
const xpath_node *it = ns.
begin(); it != ns.
end(); ++it)
9190 return r == r ?
floor(r) : r;
9197 return r == r ?
ceil(r) : r;
9208 return _data.variable->get_number();
9217 case xpath_type_boolean:
9220 case xpath_type_string:
9227 case xpath_type_node_set:
9235 assert(!
"Wrong expression for return type number");
9258 if (count >
sizeof(static_buffer) /
sizeof(static_buffer[0]))
9271 buffer[pos] = n->eval_string(
c, swapped_stack);
9272 assert(pos == count);
9276 for (
size_t i = 0; i < count; ++i)
9283 char_t *ri = result;
9285 for (
size_t j = 0; j < count; ++j)
9286 for (
const char_t *bi = buffer[j].c_str(); *bi; ++bi)
9303 xpath_node na =
c.n;
9313 xpath_node na = ns.
first();
9320 xpath_node na =
c.n;
9330 xpath_node na = ns.
first();
9337 xpath_node na =
c.n;
9347 xpath_node na = ns.
first();
9388 const char_t *result = pos + p.
length();
9406 else if (first >= s_length + 1)
9409 size_t pos = first < 1 ? 1 : static_cast<size_t>(first);
9410 assert(1 <= pos && pos <= s_length + 1);
9412 const char_t *rbegin =
s.c_str() + (pos - 1);
9431 else if (first >= s_length + 1)
9433 else if (first >= last)
9438 size_t pos = first < 1 ? 1 : static_cast<size_t>(first);
9439 size_t end = last >= s_length + 1 ? s_length + 1 :
static_cast<size_t>(last);
9441 assert(1 <= pos && pos <= end && end <= s_length + 1);
9442 const char_t *rbegin =
s.c_str() + (pos - 1);
9443 const char_t *rend =
s.c_str() + (end - 1);
9496 case xpath_type_boolean:
9499 case xpath_type_number:
9502 case xpath_type_node_set:
9513 assert(!
"Wrong expression for return type string");
9534 rs.
set_type(xpath_node_set::type_unsorted);
9604 assert(!
"Unknown axis");
9615 ns.
set_type(xpath_node_set::type_sorted);
9619 else if (
c.n.attribute())
9629 if (
_rettype == xpath_type_node_set)
9631 const xpath_node_set &
s =
_data.variable->get_node_set();
9645 assert(!
"Wrong expression for return type node set");
9676 if (!n->is_posinv())
9698#ifdef PUGIXML_NO_EXCEPTIONS
9699 jmp_buf _error_handler;
9707#ifdef PUGIXML_NO_EXCEPTIONS
9708 longjmp(_error_handler, 1);
9710 throw xpath_exception(*
_result);
9716#ifdef PUGIXML_NO_EXCEPTIONS
9719 throw std::bad_alloc();
9757 if (argc == 1 && args[0]->rettype() != xpath_type_node_set)
9758 throw_error(
"Function has to be applied to node set");
9765 switch (name.
begin[0])
9776 if (args[0]->rettype() != xpath_type_node_set)
9777 throw_error(
"Function has to be applied to node set");
9780 else if (name ==
PUGIXML_TEXT(
"contains") && argc == 2)
9808 else if (name ==
PUGIXML_TEXT(
"local-name") && argc <= 1)
9816 else if (name ==
PUGIXML_TEXT(
"namespace-uri") && argc <= 1)
9818 else if (name ==
PUGIXML_TEXT(
"normalize-space") && argc <= 1)
9821 xpath_type_string, args[0], args[1]);
9846 else if (name ==
PUGIXML_TEXT(
"string-length") && argc <= 1)
9849 else if (name ==
PUGIXML_TEXT(
"starts-with") && argc == 2)
9851 else if (name ==
PUGIXML_TEXT(
"substring-before") && argc == 2)
9854 else if (name ==
PUGIXML_TEXT(
"substring-after") && argc == 2)
9856 else if (name ==
PUGIXML_TEXT(
"substring") && (argc == 2 || argc == 3))
9858 xpath_type_string, args[0], args[1]);
9861 if (args[0]->rettype() != xpath_type_node_set)
9862 throw_error(
"Function has to be applied to node set");
9880 throw_error(
"Unrecognized function or wrong parameter count");
9889 switch (name.
begin[0])
9955 switch (name.
begin[0])
9998 throw_error(
"Unknown variable: variable set is not provided");
10003 throw_error(
"Unknown variable: variable set does not contain the given name");
10067 throw_error(
"No comma between function arguments");
10087 throw_error(
"Unrecognizable primary expression");
10106 if (n->
rettype() != xpath_type_node_set)
10107 throw_error(
"Predicate has to be applied to node set");
10130 if (set && set->
rettype() != xpath_type_node_set)
10131 throw_error(
"Step has to be applied to node set");
10133 bool axis_specified =
false;
10139 axis_specified =
true;
10169 if (axis_specified)
10174 if (!axis_specified)
10213 else if (nt_name ==
PUGIXML_TEXT(
"processing-instruction"))
10216 throw_error(
"Only literals are allowed as arguments to processing-instruction()");
10223 throw_error(
"Unmatched brace near processing-instruction()");
10227 throw_error(
"Unmatched brace near node type test");
10232 if (nt_name.
end - nt_name.
begin > 2 && nt_name.
end[-2] ==
':' && nt_name.
end[-1] ==
'*')
10374 if (n->
rettype() != xpath_type_node_set)
10375 throw_error(
"Step has to be applied to node set");
10484 (lhs->
rettype() != xpath_type_node_set || rhs->
rettype() != xpath_type_node_set))
10485 throw_error(
"Union operator has to be applied to node sets");
10534 xpath_parse_result *result)
10538#ifdef PUGIXML_NO_EXCEPTIONS
10539 int error = setjmp(parser._error_handler);
10541 return (error == 0) ? parser.parse() : 0;
10543 return parser.parse();
10581#ifdef PUGIXML_NO_EXCEPTIONS
10582 if (setjmp(sd.error_handler))
10594#ifndef PUGIXML_NO_EXCEPTIONS
10616 : _node(attribute_ ? parent_ :
xml_node()), _attribute(attribute_)
10660 return (
bool)lhs && rhs;
10663PUGI__FN bool operator||(
const xpath_node &lhs,
bool rhs)
10665 return (
bool)lhs || rhs;
10671 assert(begin_ <= end_);
10673 size_t size_ =
static_cast<size_t>(end_ - begin_);
10679 impl::xml_memory::deallocate(
_begin);
10682 if (begin_ != end_)
10695#ifdef PUGIXML_NO_EXCEPTIONS
10698 throw std::bad_alloc();
10706 impl::xml_memory::deallocate(
_begin);
10710 _end = storage + size_;
10717 : _type(type_), _begin(&_storage), _end(&_storage)
10725 impl::xml_memory::deallocate(
_begin);
10761 assert(index <
size());
10804 return static_cast<const impl::xpath_variable_node_set *
>(
this)->
name;
10807 return static_cast<const impl::xpath_variable_number *
>(
this)->
name;
10810 return static_cast<const impl::xpath_variable_string *
>(
this)->
name;
10813 return static_cast<const impl::xpath_variable_boolean *
>(
this)->
name;
10816 assert(!
"Invalid variable type");
10828 return (
_type ==
xpath_type_boolean) ?
static_cast<const impl::xpath_variable_boolean *
>(
this)->value :
false;
10847 : impl::dummy_node_set;
10855 static_cast<impl::xpath_variable_boolean *
>(
this)->value = value;
10864 static_cast<impl::xpath_variable_number *
>(
this)->value = value;
10873 impl::xpath_variable_string *var =
static_cast<impl::xpath_variable_string *
>(
this);
10876 size_t size = (impl::strlength(value) + 1) *
sizeof(
char_t);
10878 char_t *copy =
static_cast<char_t *
>(impl::xml_memory::allocate(size));
10882 memcpy(copy, value, size);
10886 impl::xml_memory::deallocate(var->value);
10897 static_cast<impl::xpath_variable_node_set *
>(
this)->value = value;
10903 for (
size_t i = 0; i <
sizeof(
_data) /
sizeof(
_data[0]); ++i)
10909 for (
size_t i = 0; i <
sizeof(
_data) /
sizeof(
_data[0]); ++i)
10917 impl::delete_xpath_variable(var->
_type, var);
10926 const size_t hash_size =
sizeof(
_data) /
sizeof(
_data[0]);
10927 size_t hash = impl::hash_string(name) % hash_size;
10931 if (impl::strequal(var->name(), name))
10939 const size_t hash_size =
sizeof(
_data) /
sizeof(
_data[0]);
10940 size_t hash = impl::hash_string(name) % hash_size;
10944 if (impl::strequal(var->name(), name))
10945 return var->
type() == type ? var : 0;
10952 result->
_type = type;
10955 _data[hash] = result;
10964 return var ? var->
set(value) :
false;
10970 return var ? var->
set(value) :
false;
10976 return var ? var->
set(value) :
false;
10982 return var ? var->
set(value) :
false;
10997 impl::xpath_query_impl *qimpl = impl::xpath_query_impl::create();
11001#ifdef PUGIXML_NO_EXCEPTIONS
11004 throw std::bad_alloc();
11009 impl::buffer_holder impl_holder(qimpl, impl::xpath_query_impl::destroy);
11011 qimpl->root = impl::xpath_parser::parse(query, variables, &qimpl->alloc, &
_result);
11015 _impl =
static_cast<impl::xpath_query_impl *
>(impl_holder.release());
11023 impl::xpath_query_impl::destroy(
_impl);
11031 return static_cast<impl::xpath_query_impl *
>(
_impl)->root->rettype();
11039 impl::xpath_context
c(n, 1, 1);
11040 impl::xpath_stack_data sd;
11042#ifdef PUGIXML_NO_EXCEPTIONS
11043 if (setjmp(sd.error_handler))
11047 return static_cast<impl::xpath_query_impl *
>(
_impl)->root->eval_boolean(
c, sd.stack);
11053 return impl::gen_nan();
11055 impl::xpath_context
c(n, 1, 1);
11056 impl::xpath_stack_data sd;
11058#ifdef PUGIXML_NO_EXCEPTIONS
11059 if (setjmp(sd.error_handler))
11060 return impl::gen_nan();
11063 return static_cast<impl::xpath_query_impl *
>(
_impl)->root->eval_number(
c, sd.stack);
11066#ifndef PUGIXML_NO_STL
11069 impl::xpath_stack_data sd;
11071 return impl::evaluate_string_impl(
static_cast<impl::xpath_query_impl *
>(
_impl), n, sd).c_str();
11077 impl::xpath_stack_data sd;
11079 impl::xpath_string r = impl::evaluate_string_impl(
static_cast<impl::xpath_query_impl *
>(
_impl), n, sd);
11081 size_t full_size = r.length() + 1;
11085 size_t size = (full_size < capacity) ? full_size : capacity;
11088 memcpy(buffer, r.c_str(), (size - 1) *
sizeof(
char_t));
11089 buffer[size - 1] = 0;
11100 impl::xpath_ast_node *root =
static_cast<impl::xpath_query_impl *
>(
_impl)->root;
11104#ifdef PUGIXML_NO_EXCEPTIONS
11108 res.
error =
"Expression does not evaluate to node set";
11114 impl::xpath_context
c(n, 1, 1);
11115 impl::xpath_stack_data sd;
11117#ifdef PUGIXML_NO_EXCEPTIONS
11118 if (setjmp(sd.error_handler))
11122 impl::xpath_node_set_raw r = root->eval_node_set(
c, sd.stack);
11177#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
11178#pragma warning(pop)
11183#undef PUGI__NO_INLINE
11184#undef PUGI__STATIC_ASSERT
11185#undef PUGI__DMC_VOLATILE
11186#undef PUGI__MSVC_CRT_VERSION
11187#undef PUGI__NS_BEGIN
11190#undef PUGI__FN_NO_INLINE
11191#undef PUGI__IS_CHARTYPE_IMPL
11192#undef PUGI__IS_CHARTYPE
11193#undef PUGI__IS_CHARTYPEX
11196#undef PUGI__PUSHNODE
11197#undef PUGI__POPNODE
11198#undef PUGI__SCANFOR
11199#undef PUGI__SCANWHILE
11201#undef PUGI__THROW_ERROR
11202#undef PUGI__CHECK_ERROR
ETISS_PLUGIN_EXPORT etiss::CPUArch std::map< std::string, std::string > options
create new instance of the CPUArch type at index
__DEVICE__ int fpclassify(float __x)
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__device__ __2f16 float c
__device__ __2f16 float bool s
static __inline__ uint32_t
static __inline__ uint8_t
static __inline__ uint16_t
bool operator!=(const xml_attribute_iterator &rhs) const
const xml_attribute_iterator & operator--()
xml_attribute * operator->() const
xml_attribute & operator*() const
bool operator==(const xml_attribute_iterator &rhs) const
const xml_attribute_iterator & operator++()
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const
bool operator>=(const xml_attribute &r) const
bool as_bool(bool def=false) const
bool operator!=(const xml_attribute &r) const
bool operator<(const xml_attribute &r) const
int as_int(int def=0) const
float as_float(float def=0) const
bool operator==(const xml_attribute &r) const
size_t hash_value() const
const char_t * name() const
xml_attribute & operator=(const char_t *rhs)
xml_attribute previous_attribute() const
xml_attribute_struct * _attr
xml_attribute next_attribute() const
bool operator<=(const xml_attribute &r) const
double as_double(double def=0) const
void(* unspecified_bool_type)(xml_attribute ***)
bool set_name(const char_t *rhs)
bool set_value(const char_t *rhs)
unsigned int as_uint(unsigned int def=0) const
xml_attribute_struct * internal_object() const
bool operator>(const xml_attribute &r) const
const char_t * value() const
xml_parse_result load_buffer_inplace(void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_node document_element() const
bool save_file(const char *path, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
xml_parse_result load_buffer_inplace_own(void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_parse_result load_file(const char *path, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_parse_result load_buffer(const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_parse_result load(std::basic_istream< char, std::char_traits< char > > &stream, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
void save(xml_writer &writer, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
xml_named_node_iterator()
bool operator!=(const xml_named_node_iterator &rhs) const
xml_node * operator->() const
const xml_named_node_iterator & operator--()
bool operator==(const xml_named_node_iterator &rhs) const
xml_node & operator*() const
const xml_named_node_iterator & operator++()
bool operator==(const xml_node_iterator &rhs) const
const xml_node_iterator & operator--()
xml_node * operator->() const
bool operator!=(const xml_node_iterator &rhs) const
const xml_node_iterator & operator++()
xml_node & operator*() const
string_t path(char_t delimiter='/') const
size_t hash_value() const
xpath_node select_single_node(const char_t *query, xpath_variable_set *variables=0) const
bool set_value(const char_t *rhs)
xml_node_type type() const
xml_node append_child(xml_node_type type=node_element)
xml_node child(const char_t *name) const
friend class xml_named_node_iterator
xml_node last_child() const
xml_node first_child() const
bool operator>(const xml_node &r) const
xml_object_range< xml_node_iterator > children() const
xml_attribute append_attribute(const char_t *name)
xml_node next_sibling() const
xml_node_struct * internal_object() const
xml_object_range< xml_attribute_iterator > attributes() const
bool remove_child(const xml_node &n)
xml_attribute append_copy(const xml_attribute &proto)
xml_node insert_child_after(xml_node_type type, const xml_node &node)
xml_attribute last_attribute() const
attribute_iterator attributes_end() const
xml_node previous_sibling() const
ptrdiff_t offset_debug() const
xml_attribute insert_attribute_before(const char_t *name, const xml_attribute &attr)
xml_attribute insert_attribute_after(const char_t *name, const xml_attribute &attr)
bool operator!=(const xml_node &r) const
bool operator<(const xml_node &r) const
xml_attribute prepend_attribute(const char_t *name)
xml_parse_result append_buffer(const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
const char_t * value() const
void(* unspecified_bool_type)(xml_node ***)
xml_attribute_iterator attribute_iterator
bool traverse(xml_tree_walker &walker)
xml_node find_child_by_attribute(const char_t *name, const char_t *attr_name, const char_t *attr_value) const
const char_t * child_value() const
bool set_name(const char_t *rhs)
xml_node prepend_child(xml_node_type type=node_element)
xml_attribute first_attribute() const
bool operator>=(const xml_node &r) const
xml_attribute insert_copy_after(const xml_attribute &proto, const xml_attribute &attr)
xml_attribute prepend_copy(const xml_attribute &proto)
xml_node first_element_by_path(const char_t *path, char_t delimiter='/') const
xml_attribute attribute(const char_t *name) const
const char_t * name() const
xml_attribute insert_copy_before(const xml_attribute &proto, const xml_attribute &attr)
attribute_iterator attributes_begin() const
xpath_node_set select_nodes(const char_t *query, xpath_variable_set *variables=0) const
xml_node_iterator iterator
bool operator<=(const xml_node &r) const
bool remove_attribute(const xml_attribute &a)
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
xml_node insert_child_before(xml_node_type type, const xml_node &node)
bool operator==(const xml_node &r) const
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const
double as_double(double def=0) const
xml_text & operator=(const char_t *rhs)
float as_float(float def=0) const
xml_node_struct * _data_new()
bool as_bool(bool def=false) const
bool set(const char_t *rhs)
int as_int(int def=0) const
unsigned int as_uint(unsigned int def=0) const
void(* unspecified_bool_type)(xml_text ***)
const char_t * get() const
xml_node_struct * _data() const
virtual bool end(xml_node &node)
virtual bool for_each(xml_node &node)=0
virtual bool begin(xml_node &node)
virtual ~xml_tree_walker()
virtual void write(const void *data, size_t size)
xml_writer_file(void *file)
xml_writer_stream(std::basic_ostream< char, std::char_traits< char > > &stream)
std::basic_ostream< wchar_t, std::char_traits< wchar_t > > * wide_stream
virtual void write(const void *data, size_t size)
std::basic_ostream< char, std::char_traits< char > > * narrow_stream
virtual const char * what() const
const xpath_parse_result & result() const
xpath_exception(const xpath_parse_result &result)
xpath_parse_result _result
xpath_node_set & operator=(const xpath_node_set &ns)
void _assign(const_iterator begin, const_iterator end)
const_iterator end() const
void sort(bool reverse=false)
const_iterator begin() const
const xpath_node & operator[](size_t index) const
void(* unspecified_bool_type)(xpath_node ***)
xml_attribute attribute() const
bool operator!=(const xpath_node &n) const
bool operator==(const xpath_node &n) const
string_t evaluate_string(const xpath_node &n) const
void(* unspecified_bool_type)(xpath_query ***)
double evaluate_number(const xpath_node &n) const
xpath_node_set evaluate_node_set(const xpath_node &n) const
xpath_value_type return_type() const
xpath_parse_result _result
xpath_query(const xpath_query &)
const xpath_parse_result & result() const
bool evaluate_boolean(const xpath_node &n) const
xpath_variable * add(const char_t *name, xpath_value_type type)
xpath_variable * find(const char_t *name) const
bool set(const char_t *name, bool value)
xpath_variable * get(const char_t *name)
xpath_variable * _data[64]
double get_number() const
const char_t * get_string() const
const xpath_node_set & get_node_set() const
xpath_value_type type() const
const char_t * name() const
xml_buffered_writer(xml_writer &writer_, xml_encoding user_encoding)
void write(char_t d0, char_t d1)
xml_buffered_writer(const xml_buffered_writer &)
char_t data_char[bufcapacity]
xml_buffered_writer & operator=(const xml_buffered_writer &)
char_t buffer[bufcapacity]
void flush(const char_t *data, size_t size)
uint16_t data_u16[2 *bufcapacity]
union xml_buffered_writer::@9 scratch
void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4)
uint8_t data_u8[4 *bufcapacity]
void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5)
void write(const char_t *data)
void write(char_t d0, char_t d1, char_t d2, char_t d3)
void write(char_t d0, char_t d1, char_t d2)
void write(const char_t *data, size_t length)
uint32_t data_u32[bufcapacity]
xpath_allocator(xpath_memory_block *root, size_t root_size=0)
void * reallocate(void *ptr, size_t old_size, size_t new_size)
void * allocate(size_t size)
void * allocate_nothrow(size_t size)
xpath_memory_block * _root
void revert(const xpath_allocator &state)
xpath_variable * variable
void set_next(xpath_ast_node *value)
xpath_value_type rettype() const
xpath_node_set_raw eval_node_set(const xpath_context &c, const xpath_stack &stack)
xpath_string eval_string(const xpath_context &c, const xpath_stack &stack)
void step_push(xpath_node_set_raw &ns, const xml_node &n, xpath_allocator *alloc)
void step_fill(xpath_node_set_raw &ns, const xml_node &n, xpath_allocator *alloc, T)
xpath_ast_node(ast_type_t type, xpath_ast_node *left, axis_t axis, nodetest_t test, const char_t *contents)
xpath_node_set_raw step_do(const xpath_context &c, const xpath_stack &stack, T v)
xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_variable *value)
double eval_number(const xpath_context &c, const xpath_stack &stack)
static bool compare_eq(xpath_ast_node *lhs, xpath_ast_node *rhs, const xpath_context &c, const xpath_stack &stack, const Comp &comp)
void step_push(xpath_node_set_raw &ns, const xml_attribute &a, const xml_node &parent, xpath_allocator *alloc)
void step_fill(xpath_node_set_raw &ns, const xml_attribute &a, const xml_node &p, xpath_allocator *alloc, T v)
xpath_string eval_string_concat(const xpath_context &c, const xpath_stack &stack)
bool eval_boolean(const xpath_context &c, const xpath_stack &stack)
static bool compare_rel(xpath_ast_node *lhs, xpath_ast_node *rhs, const xpath_context &c, const xpath_stack &stack, const Comp &comp)
xpath_ast_node & operator=(const xpath_ast_node &)
xpath_ast_node(ast_type_t type, xpath_value_type rettype_, double value)
union xpath_ast_node::@10 _data
xpath_ast_node(const xpath_ast_node &)
void apply_predicates(xpath_node_set_raw &ns, size_t first, const xpath_stack &stack)
xpath_ast_node(ast_type_t type, xpath_value_type rettype_, const char_t *value)
xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_ast_node *left=0, xpath_ast_node *right=0)
void apply_predicate(xpath_node_set_raw &ns, size_t first, xpath_ast_node *expr, const xpath_stack &stack)
void set_right(xpath_ast_node *value)
const char_t * _cur_lexeme_pos
const char_t * current_pos() const
xpath_lexer_string _cur_lexeme_contents
const xpath_lexer_string & contents() const
xpath_lexer(const char_t *query)
const char_t * state() const
xpath_node_set::type_t _type
void append(const xpath_node *begin_, const xpath_node *end_, xpath_allocator *alloc)
xpath_node_set::type_t type() const
void push_back(const xpath_node &node, xpath_allocator *alloc)
xpath_node * begin() const
void truncate(xpath_node *pos)
void set_type(xpath_node_set::type_t value)
static char_t * duplicate_string(const char_t *string, xpath_allocator *alloc)
bool operator!=(const xpath_string &o) const
void append(const xpath_string &o, xpath_allocator *alloc)
xpath_string(const char_t *str, xpath_allocator *alloc)
char_t * data(xpath_allocator *alloc)
bool operator==(const xpath_string &o) const
xpath_string(const char_t *begin, const char_t *end, xpath_allocator *alloc)
xpath_string(const char_t *str, bool use_heap)
static char_t * duplicate_string(const char_t *string, size_t length, xpath_allocator *alloc)
const char_t * c_str() const
std::basic_string< PUGIXML_CHAR, std::char_traits< PUGIXML_CHAR >, std::allocator< PUGIXML_CHAR > > string_t
const unsigned int format_no_declaration
const unsigned int format_raw
void(* deallocation_function)(void *ptr)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > PUGIXML_FUNCTION as_utf8(const wchar_t *str)
static PUGI__FN void unspecified_bool_xpath_query(xpath_query ***)
static PUGI__FN void unspecified_bool_xml_node(xml_node ***)
void *(* allocation_function)(size_t size)
static PUGI__FN void unspecified_bool_xml_attribute(xml_attribute ***)
@ status_append_invalid_root
@ status_end_element_mismatch
@ status_bad_start_element
@ status_unrecognized_tag
@ status_no_document_element
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate)
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function()
std::basic_string< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > PUGIXML_FUNCTION as_wide(const char *str)
const unsigned int format_save_file_text
allocation_function PUGIXML_FUNCTION get_memory_allocation_function()
const unsigned int format_write_bom
static PUGI__FN void unspecified_bool_xpath_node(xpath_node ***)
static PUGI__FN void unspecified_bool_xml_text(xml_text ***)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
float __ovld __cnfn sign(float x)
Returns 1.0 if x > 0, -0.0 if x = -0.0, +0.0 if x = +0.0, or -1.0 if x < 0.
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
float __ovld __cnfn step(float edge, float x)
Returns 0.0 if x < edge, otherwise it returns 1.0.
void destroy_node(xml_node_struct *n, xml_allocator &alloc)
#define PUGI__CHECK_ERROR(err, m)
PUGI__FN void default_deallocate(void *ptr)
PUGI__FN size_t strlength_wide(const wchar_t *s)
#define PUGI__OPTSET(OPT)
PUGI__FN double round_nearest_nzero(double value)
PUGI__FN size_t get_latin1_7bit_prefix_length(const uint8_t *data, size_t size)
PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct *doc, xml_node_struct *root, void *contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t **out_buffer)
PUGI__FN xpath_string evaluate_string_impl(xpath_query_impl *impl, const xpath_node &n, xpath_stack_data &sd)
@ ast_func_substring_before
@ ast_func_string_length_0
@ ast_func_namespace_uri_0
@ ast_func_normalize_space_1
@ ast_func_normalize_space_0
@ ast_func_substring_after
@ ast_func_namespace_uri_1
@ ast_func_string_length_1
@ ast_op_greater_or_equal
PUGI__FN xml_encoding get_write_native_encoding()
PUGI__FN const char_t * qualified_name(const xpath_node &node)
PUGI__FN bool convert_number_to_boolean(double value)
char_t *(* strconv_attribute_t)(char_t *, char_t)
PUGI__FN void as_utf8_end(char *buffer, size_t size, const wchar_t *str, size_t length)
wchar_selector< sizeof(wchar_t)>::writer wchar_writer
PUGI__FN xml_encoding get_wchar_encoding()
PUGI__FN FILE * open_file_wide(const wchar_t *path, const wchar_t *mode)
PUGI__FN void text_output_cdata(xml_buffered_writer &writer, const char_t *s)
bool strcpy_insitu_allow(size_t length, uintptr_t allocated, char_t *target)
PUGI__FN bool get_mutable_buffer(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, bool is_mutable)
static const uintptr_t xml_memory_page_type_mask
PUGI__FN xpath_string convert_number_to_string(double value, xpath_allocator *alloc)
PUGI__FN bool is_little_endian()
PUGI__FN unsigned int hash_string(const char_t *str)
PUGI__FN size_t zero_terminate_buffer(void *buffer, size_t size, xml_encoding encoding)
PUGI__FN char_t * strconv_comment(char_t *s, char_t endch)
#define PUGI__IS_CHARTYPE(c, ct)
PUGI__FN double gen_nan()
PUGI__FN strconv_attribute_t get_strconv_attribute(unsigned int optmask)
PUGI__FN strconv_pcdata_t get_strconv_pcdata(unsigned int optmask)
PUGI__FN bool convert_buffer(char_t *&out_buffer, size_t &out_length, xml_encoding encoding, const void *contents, size_t size, bool is_mutable)
PUGI__FN void convert_utf_endian_swap(T *result, const T *data, size_t length)
PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
PUGI__FN xml_parse_result load_stream_impl(xml_document &doc, std::basic_istream< T > &stream, unsigned int options, xml_encoding encoding)
PUGI__FN bool set_value_convert(char_t *&dest, uintptr_t &header, uintptr_t header_mask, int value)
I min_element(I begin, I end, const Pred &pred)
static const uintptr_t xml_memory_page_pointer_mask
PUGI__FN char_t * strconv_escape(char_t *s, gap &g)
void sort(I begin, I end, const Pred &pred)
void destroy_attribute(xml_attribute_struct *a, xml_allocator &alloc)
PUGI__FN bool convert_buffer_utf32(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, opt_swap)
wchar_selector< sizeof(wchar_t)>::counter wchar_counter
void median(I first, I middle, I last, const Pred &pred)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN bool starts_with(const char_t *string, const char_t *pattern)
#define PUGI__IS_CHARTYPEX(c, ct)
PUGI__FN_NO_INLINE xml_attribute_struct * append_attribute_ll(xml_node_struct *node, xml_allocator &alloc)
bool has_declaration(const xml_node &node)
void insertion_sort(I begin, I end, const Pred &pred, T *)
static const unsigned char chartypex_table[256]
PUGI__FN bool check_string_to_number_format(const char_t *string)
PUGI__FN T * new_xpath_variable(const char_t *name)
PUGI__FN const char_t * find_char(const char_t *s, char_t c)
PUGI__FN size_t get_valid_length(const char_t *data, size_t length)
PUGI__FN std::string as_utf8_impl(const wchar_t *str, size_t length)
xml_allocator & get_allocator(const xml_node_struct *node)
xml_memory_management_function_storage< int > xml_memory
PUGI__FN xml_parse_status get_file_size(FILE *file, size_t &out_result)
PUGI__FN bool node_is_before(xml_node ln, unsigned int lh, xml_node rn, unsigned int rh)
char_t *(* strconv_pcdata_t)(char_t *)
PUGI__FN_NO_INLINE xml_node_struct * append_node(xml_node_struct *node, xml_allocator &alloc, xml_node_type type=node_element)
static const unsigned char chartype_table[256]
PUGI__NS_END PUGI__NS_BEGIN uint16_t endian_swap(uint16_t value)
void copy_backwards(I begin, I end, I target)
PUGI__FN unsigned int node_height(xml_node n)
bool is_text_node(xml_node_struct *node)
PUGI__FN xpath_string string_value(const xpath_node &na, xpath_allocator *alloc)
PUGI__FN xml_parse_result load_file_impl(xml_document &doc, FILE *file, unsigned int options, xml_encoding encoding)
void reverse(I begin, I end)
#define PUGI__FN_NO_INLINE
#define PUGI__STATIC_ASSERT(cond)
PUGI__FN void node_output(xml_buffered_writer &writer, const xml_node &node, const char_t *indent, unsigned int flags, unsigned int depth)
PUGI__FN xml_parse_status load_stream_data_noseek(std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
PUGI__FN bool get_value_bool(const char_t *value, bool def)
#define PUGI__DMC_VOLATILE
PUGI__NS_END PUGI__NS_BEGIN xml_attribute_struct * allocate_attribute(xml_allocator &alloc)
PUGI__FN double get_value_double(const char_t *value, double def)
#define PUGI__THROW_ERROR(err, m)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN xpath_node_set::type_t xpath_sort(xpath_node *begin, xpath_node *end, xpath_node_set::type_t type, bool rev)
xml_parse_result make_parse_result(xml_parse_status status, ptrdiff_t offset=0)
PUGI__FN const char_t * namespace_uri(const xml_node &node)
PUGI__FN size_t convert_buffer_output(char_t *, uint8_t *r_u8, uint16_t *r_u16, uint32_t *r_u32, const char_t *data, size_t length, xml_encoding encoding)
PUGI__FN const char_t * convert_number_to_string_special(double value)
bool allow_insert_child(xml_node_type parent, xml_node_type child)
static const uintptr_t xml_memory_page_name_allocated_mask
PUGI__NS_END static PUGI__NS_BEGIN const size_t xml_memory_page_size
PUGI__FN bool convert_string_to_number_scratch(char_t(&buffer)[32], const char_t *begin, const char_t *end, double *out_result)
PUGI__FN xml_encoding get_write_encoding(xml_encoding encoding)
PUGI__FN void convert_number_to_mantissa_exponent(double value, char *buffer, size_t buffer_size, char **out_mantissa, int *out_exponent)
PUGI__FN void delete_xpath_variable(T *var)
PUGI__FN bool convert_buffer_latin1(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, bool is_mutable)
void swap(T &lhs, T &rhs)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN size_t strlength(const char_t *s)
PUGI__FN char * convert_path_heap(const wchar_t *str)
PUGI__FN void recursive_copy_skip(xml_node &dest, const xml_node &source, const xml_node &skip)
PUGI__FN double round_nearest(double value)
PUGI__FN void node_output_attributes(xml_buffered_writer &writer, const xml_node &node, unsigned int flags)
@ nodetest_all_in_namespace
static const uintptr_t xml_memory_page_alignment
PUGI__FN bool set_value_buffer(char_t *&dest, uintptr_t &header, uintptr_t header_mask, char(&buf)[128])
PUGI__FN bool strcpy_insitu(char_t *&dest, uintptr_t &header, uintptr_t header_mask, const char_t *source)
void partition(I begin, I middle, I end, const Pred &pred, I *out_eqbeg, I *out_eqend)
PUGI__FN void normalize_space(char_t *buffer)
PUGI__FN const char_t * find_substring(const char_t *s, const char_t *p)
PUGI__FN bool strequalrange(const char_t *lhs, const char_t *rhs, size_t count)
PUGI__FN bool save_file_impl(const xml_document &doc, FILE *file, const char_t *indent, unsigned int flags, xml_encoding encoding)
PUGI__FN xml_encoding guess_buffer_encoding(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
PUGI__FN double convert_string_to_number(const char_t *string)
PUGI__FN bool is_nan(double value)
static const uintptr_t xml_memory_page_value_allocated_mask
PUGI__FN xpath_node xpath_first(const xpath_node *begin, const xpath_node *end, xpath_node_set::type_t type)
#define PUGI__PUSHNODE(TYPE)
static const xpath_node_set dummy_node_set
PUGI__FN size_t as_utf8_begin(const wchar_t *str, size_t length)
PUGI__FN xpath_variable * get_variable_scratch(char_t(&buffer)[32], xpath_variable_set *set, const char_t *begin, const char_t *end)
PUGI__FN void text_output(xml_buffered_writer &writer, const char_t *s, chartypex_t type, unsigned int flags)
PUGI__FN void translate(char_t *buffer, const char_t *from, const char_t *to)
xml_node_struct * allocate_node(xml_allocator &alloc, xml_node_type type)
#define PUGI__SCANWHILE(X)
PUGI__FN void truncate_zeros(char *begin, char *end)
PUGI__FN unsigned int get_value_uint(const char_t *value, unsigned int def)
@ axis_descendant_or_self
PUGI__FN xml_encoding get_buffer_encoding(xml_encoding encoding, const void *contents, size_t size)
PUGI__FN float get_value_float(const char_t *value, float def)
PUGI__FN const char_t * local_name(const xpath_node &node)
void median3(I first, I middle, I last, const Pred &pred)
PUGI__FN bool strequal(const char_t *src, const char_t *dst)
PUGI__FN bool convert_buffer_utf16(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, opt_swap)
PUGI__FN std::basic_string< wchar_t > as_wide_impl(const char *str, size_t size)
PUGI__FN const void * document_order(const xpath_node &xnode)
PUGI__FN char_t * strconv_cdata(char_t *s, char_t endch)
PUGI__FN xpath_string xpath_string_const(const char_t *str)
PUGI__NS_BEGIN PUGI__FN void * default_allocate(size_t size)
PUGI__FN bool node_is_ancestor(xml_node parent, xml_node node)
PUGI__FN int get_value_int(const char_t *value, int def)
PUGI__FN char_t tolower_ascii(char_t ch)
PUGI__FN int get_integer_base(const char_t *value)
PUGI__FN void text_output_escaped(xml_buffered_writer &writer, const char_t *s, chartypex_t type)
buffer_holder(void *data_, void(*deleter_)(void *))
bool operator()(const xpath_node &lhs, const xpath_node &rhs) const
bool operator()(const xpath_node &lhs, const xpath_node &rhs) const
bool operator()(const T &lhs, const T &rhs) const
char_t * flush(char_t *s)
void push(char_t *&s, size_t count)
static value_type high(value_type result, uint32_t ch)
static value_type low(value_type result, uint32_t ch)
bool operator()(const T &lhs, const T &rhs) const
bool operator()(const T &lhs, const T &rhs) const
namespace_uri_predicate(const char_t *name)
bool operator()(const xml_attribute &a) const
bool operator()(const T &lhs, const T &rhs) const
A 'name=value' XML attribute structure.
xml_attribute_struct * prev_attribute_c
Previous attribute (cyclic list)
xml_attribute_struct(impl::xml_memory_page *page)
Default ctor.
xml_attribute_struct * next_attribute
Next attribute.
char_t * name
Pointer to attribute name.
char_t * value
Pointer to attribute value.
An XML document tree node.
char_t * value
Pointer to any associated string data.
xml_attribute_struct * first_attribute
First attribute.
xml_node_struct * prev_sibling_c
Left brother (cyclic list)
xml_node_struct * next_sibling
Right brother.
char_t * name
Pointer to element name.
xml_node_struct * parent
Pointer to parent.
xml_node_struct * first_child
First child.
xml_node_struct(impl::xml_memory_page *page, xml_node_type type)
Default ctor.
const char * description() const
const char * description() const
static char_t * parse_eol(char_t *s, char_t end_quote)
static char_t * parse_simple(char_t *s, char_t end_quote)
static char_t * parse_wnorm(char_t *s, char_t end_quote)
static char_t * parse_wconv(char_t *s, char_t end_quote)
static char_t * parse(char_t *s)
static value_type low(value_type result, uint32_t)
static value_type high(value_type result, uint32_t)
static value_type high(value_type result, uint32_t ch)
static value_type low(value_type result, uint32_t ch)
static value_type any(value_type result, uint32_t ch)
static value_type low(value_type result, uint32_t)
static value_type high(value_type result, uint32_t)
static value_type low(value_type result, uint32_t ch)
static value_type high(value_type result, uint32_t ch)
static value_type any(value_type result, uint32_t ch)
static value_type low(value_type result, uint32_t ch)
static value_type high(value_type result, uint32_t)
static value_type any(value_type result, uint32_t ch)
static value_type high(value_type result, uint32_t ch)
static value_type low(value_type result, uint32_t ch)
static Traits::value_type decode_wchar_block_impl(const uint32_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_latin1_block(const uint8_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_wchar_block_impl(const uint16_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_wchar_block(const wchar_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_utf8_block(const uint8_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_utf32_block(const uint32_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_utf16_block(const uint16_t *data, size_t size, typename Traits::value_type result)
void * allocate_memory(size_t size, xml_memory_page *&out_page)
char_t * allocate_string(size_t length)
static void deallocate_page(xml_memory_page *page)
void * allocate_memory_oob(size_t size, xml_memory_page *&out_page)
void deallocate_memory(void *ptr, size_t size, xml_memory_page *page)
xml_memory_page * allocate_page(size_t data_size)
xml_allocator(xml_memory_page *root)
void deallocate_string(char_t *string)
xml_document_struct(xml_memory_page *page)
xml_extra_buffer * extra_buffers
static deallocation_function deallocate
static allocation_function allocate
static xml_memory_page * construct(void *memory)
xml_allocator * allocator
static char_t * parse_skip_bom(char_t *s)
xml_parse_status error_status
char_t * parse_doctype_primitive(char_t *s)
char_t * parse_tree(char_t *s, xml_node_struct *root, unsigned int optmsk, char_t endch)
static xml_parse_result parse(char_t *buffer, size_t length, xml_document_struct *xmldoc, xml_node_struct *root, unsigned int optmsk)
static bool has_element_node_siblings(xml_node_struct *node)
char_t * parse_question(char_t *s, xml_node_struct *&ref_cursor, unsigned int optmsk, char_t endch)
char_t * parse_doctype_ignore(char_t *s)
xml_parser(const xml_allocator &alloc_)
char_t * parse_doctype_group(char_t *s, char_t endch, bool toplevel)
char_t * parse_exclamation(char_t *s, xml_node_struct *cursor, unsigned int optmsk, char_t endch)
static xml_stream_chunk * create()
T data[xml_memory_page_size/sizeof(T)]
static void destroy(void *ptr)
~xpath_allocator_capture()
xpath_allocator * _target
xpath_allocator_capture(xpath_allocator *alloc)
xpath_context(const xpath_node &n_, size_t position_, size_t size_)
bool operator==(const char_t *other) const
xpath_memory_block * next
binary_op_t(ast_type_t asttype_, xpath_value_type rettype_, int precedence_)
static binary_op_t parse(xpath_lexer &lexer)
void throw_error(const char *message)
xpath_ast_node * parse_step(xpath_ast_node *set)
xpath_ast_node * parse_function_helper(ast_type_t type0, ast_type_t type1, size_t argc, xpath_ast_node *args[2])
xpath_variable_set * _variables
xpath_parser(const char_t *query, xpath_variable_set *variables, xpath_allocator *alloc, xpath_parse_result *result)
xpath_ast_node * parse_primary_expression()
xpath_ast_node * parse_filter_expression()
nodetest_t parse_node_test_type(const xpath_lexer_string &name)
xpath_ast_node * parse_expression()
const char_t * alloc_string(const xpath_lexer_string &value)
xpath_parse_result * _result
xpath_ast_node * parse_function(const xpath_lexer_string &name, size_t argc, xpath_ast_node *args[2])
static xpath_ast_node * parse(const char_t *query, xpath_variable_set *variables, xpath_allocator *alloc, xpath_parse_result *result)
xpath_ast_node * parse_path_or_unary_expression()
axis_t parse_axis_name(const xpath_lexer_string &name, bool &specified)
xpath_ast_node * parse_expression_rec(xpath_ast_node *lhs, int limit)
xpath_ast_node * parse_relative_location_path(xpath_ast_node *set)
xpath_ast_node * parse_location_path()
static void destroy(void *ptr)
static xpath_query_impl * create()
xpath_memory_block blocks[2]