pugixml.cpp File Reference
`#include "pugixml.hpp"`
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <assert.h>`
`#include <math.h>`
`#include <float.h>`
`#include <istream>`
`#include <ostream>`
`#include <string>`
`#include <new>`
`#include <stdint.h>`
Include dependency graph for pugixml.cpp:

Go to the source code of this file.

## Classes

struct | xml_memory_management_function_storage< T >
struct | buffer_holder
struct | xml_memory_page
struct | xml_memory_string_header
struct | xml_allocator
struct | pugi::xml_attribute_struct
| A 'name=value' XML attribute structure. More...
struct | pugi::xml_node_struct
| An XML document tree node. More...
struct | xml_extra_buffer
struct | xml_document_struct
struct | opt_false
struct | opt_true
struct | utf8_counter
struct | utf8_writer
struct | utf16_counter
struct | utf16_writer
struct | utf32_counter
struct | utf32_writer
struct | latin1_writer
struct | wchar_selector< size >
struct | wchar_selector< 2 >
struct | wchar_selector< 4 >
struct | utf_decoder< Traits, opt_swap >
struct | gap
struct | strconv_pcdata_impl< opt_trim, opt_eol, opt_escape >
struct | strconv_attribute_impl< opt_escape >
struct | xml_parser
class | xml_buffered_writer
struct | xml_stream_chunk< T >
struct | equal_to
struct | not_equal_to
struct | less
struct | less_equal
struct | xpath_memory_block
class | xpath_allocator
struct | xpath_allocator_capture
struct | xpath_stack
struct | xpath_stack_data
class | xpath_string
struct | document_order_comparator
struct | duplicate_comparator
struct | namespace_uri_predicate
struct | xpath_variable_boolean
struct | xpath_variable_number
struct | xpath_variable_string
struct | xpath_variable_node_set
class | xpath_node_set_raw
struct | xpath_context
struct | xpath_lexer_string
class | xpath_lexer
struct | axis_to_type< N >
class | xpath_ast_node
struct | xpath_parser
struct | xpath_parser::binary_op_t
struct | xpath_query_impl

## Namespaces

| pugi

## Macros

#define | SOURCE_PUGIXML_CPP
#define | PUGI__NO_INLINE
#define | PUGI__UNLIKELY(cond) (cond)
#define | PUGI__STATIC_ASSERT(cond) { static const char condition_failed[(cond) ? 1 : -1] = {0}; (void)condition_failed[0]; }
#define | PUGI__DMC_VOLATILE
#define | PUGI__NS_BEGIN namespace pugi { namespace impl { namespace {
#define | PUGI__NS_END } } }
#define | PUGI__FN
#define | PUGI__FN_NO_INLINE PUGI__NO_INLINE
#define | PUGI__IS_CHARTYPE_IMPL(c, ct, table) (table[static_cast<unsigned char>(c)] & (ct))
#define | PUGI__IS_CHARTYPE(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartype_table)
#define | PUGI__IS_CHARTYPEX(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table)
#define | PUGI__ENDSWITH(c, e) ((c) == (e) || ((c) == 0 && endch == (e)))
#define | PUGI__SKIPWS() { while (PUGI__IS_CHARTYPE(*s, ct_space)) ++s; }
#define | PUGI__OPTSET(OPT) ( optmsk & (OPT) )
#define | PUGI__PUSHNODE(TYPE) { cursor = append_new_node(cursor, alloc, TYPE); if (!cursor) PUGI__THROW_ERROR(status_out_of_memory, s); }
#define | PUGI__POPNODE() { cursor = cursor->parent; }
#define | PUGI__SCANFOR(X) { while (*s != 0 && !(X)) ++s; }
#define | PUGI__SCANWHILE(X) { while (X) ++s; }
#define | PUGI__SCANWHILE_UNROLL(X) { while (X) { ++s; if (PUGI__UNLIKELY(!(X))) break; ++s; if (PUGI__UNLIKELY(!(X))) break; ++s; if (PUGI__UNLIKELY(!(X))) break; ++s; } }
#define | PUGI__ENDSEG() { ch = *s; *s = 0; ++s; }
#define | PUGI__THROW_ERROR(err, m) return error_offset = m, error_status = err, static_cast<char_t*>(0)
#define | PUGI__CHECK_ERROR(err, m) { if (*s == 0) PUGI__THROW_ERROR(err, m); }

## Typedefs

typedef xml_memory_management_function_storage< int > | xml_memory
typedef wchar_selector< sizeof(wchar_t)>::counter | wchar_counter
typedef wchar_selector< sizeof(wchar_t)>::writer | wchar_writer
typedef char_t *(* | strconv_pcdata_t) (char_t *)
typedef char_t *(* | strconv_attribute_t) (char_t *, char_t)

## Enumerations

enum | chartype_t { ct_parse_pcdata = 1, ct_parse_attr = 2, ct_parse_attr_ws = 4, ct_space = 8, ct_parse_cdata = 16, ct_parse_comment = 32, ct_symbol = 64, ct_start_symbol = 128 }
enum | chartypex_t { ctx_special_pcdata = 1, ctx_special_attr = 2, ctx_start_symbol = 4, ctx_digit = 8, ctx_symbol = 16 }

enum

lexeme_t {
lex_none = 0, lex_equal, lex_not_equal, lex_less,
lex_greater, lex_less_or_equal, lex_greater_or_equal, lex_plus,
lex_minus, lex_multiply, lex_union, lex_var_ref,
lex_open_brace, lex_close_brace, lex_quoted_string, lex_number,
lex_slash, lex_double_slash, lex_open_square_brace, lex_close_square_brace,
lex_string, lex_comma, lex_axis_attribute, lex_dot,
lex_double_dot, lex_double_colon, lex_eof
}

enum

ast_type_t {
ast_unknown, ast_op_or, ast_op_and, ast_op_equal,
ast_op_not_equal, ast_op_less, ast_op_greater, ast_op_less_or_equal,
ast_op_greater_or_equal, ast_op_add, ast_op_subtract, ast_op_multiply,
ast_op_divide, ast_op_mod, ast_op_negate, ast_op_union,
ast_predicate, ast_filter, ast_filter_posinv, ast_string_constant,
ast_number_constant, ast_variable, ast_func_last, ast_func_position,
ast_func_count, ast_func_id, ast_func_local_name_0, ast_func_local_name_1,
ast_func_namespace_uri_0, ast_func_namespace_uri_1, ast_func_name_0, ast_func_name_1,
ast_func_string_0, ast_func_string_1, ast_func_concat, ast_func_starts_with,
ast_func_contains, ast_func_substring_before, ast_func_substring_after, ast_func_substring_2,
ast_func_substring_3, ast_func_string_length_0, ast_func_string_length_1, ast_func_normalize_space_0,
ast_func_normalize_space_1, ast_func_translate, ast_func_boolean, ast_func_not,
ast_func_true, ast_func_false, ast_func_lang, ast_func_number_0,
ast_func_number_1, ast_func_sum, ast_func_floor, ast_func_ceiling,
ast_func_round, ast_step, ast_step_root
}

enum | axis_t { axis_ancestor, axis_ancestor_or_self, axis_attribute, axis_child, axis_descendant, axis_descendant_or_self, axis_following, axis_following_sibling, axis_namespace, axis_parent, axis_preceding, axis_preceding_sibling, axis_self }
enum | nodetest_t { nodetest_none, nodetest_name, nodetest_type_node, nodetest_type_comment, nodetest_type_pi, nodetest_type_text, nodetest_pi, nodetest_all, nodetest_all_in_namespace }

## Functions

PUGI__NS_BEGIN PUGI__FN void * | default_allocate (size_t size)
PUGI__FN void | default_deallocate (void *ptr)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN size_t | strlength (const char_t *s)
PUGI__FN bool | strequal (const char_t *src, const char_t *dst)
PUGI__FN bool | strequalrange (const char_t *lhs, const char_t *rhs, size_t count)
PUGI__FN size_t | strlength_wide (const wchar_t *s)
xml_allocator & | get_allocator (const xml_node_struct *node)
PUGI__NS_END PUGI__NS_BEGIN xml_attribute_struct * | allocate_attribute (xml_allocator &alloc)
xml_node_struct * | allocate_node (xml_allocator &alloc, xml_node_type type)
void | destroy_attribute (xml_attribute_struct *a, xml_allocator &alloc)
void | destroy_node (xml_node_struct *n, xml_allocator &alloc)
void | append_node (xml_node_struct *child, xml_node_struct *node)
void | prepend_node (xml_node_struct *child, xml_node_struct *node)
void | insert_node_after (xml_node_struct *child, xml_node_struct *node)
void | insert_node_before (xml_node_struct *child, xml_node_struct *node)
void | remove_node (xml_node_struct *node)
PUGI__FN_NO_INLINE xml_node_struct * | append_new_node (xml_node_struct *node, xml_allocator &alloc, xml_node_type type=node_element)
PUGI__FN_NO_INLINE xml_attribute_struct * | append_new_attribute (xml_node_struct *node, xml_allocator &alloc)
PUGI__NS_END PUGI__NS_BEGIN uint16_t | endian_swap (uint16_t value)
uint32_t | endian_swap (uint32_t value)
template<typename T >
PUGI__FN void | convert_utf_endian_swap (T *result, const T *data, size_t length)
PUGI__FN bool | is_little_endian ()
PUGI__FN xml_encoding | get_wchar_encoding ()
PUGI__FN xml_encoding | guess_buffer_encoding (uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
PUGI__FN xml_encoding | get_buffer_encoding (xml_encoding encoding, const void *contents, size_t size)
PUGI__FN bool | get_mutable_buffer (char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, bool is_mutable)
template<typename opt_swap >
PUGI__FN bool | convert_buffer_utf16 (char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, opt_swap)
template<typename opt_swap >
PUGI__FN bool | convert_buffer_utf32 (char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, opt_swap)
PUGI__FN size_t | get_latin1_7bit_prefix_length (const uint8_t *data, size_t size)
PUGI__FN bool | convert_buffer_latin1 (char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, bool is_mutable)
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 size_t | as_utf8_begin (const wchar_t *str, size_t length)
PUGI__FN void | as_utf8_end (char *buffer, size_t size, const wchar_t *str, size_t length)
PUGI__FN std::string | as_utf8_impl (const wchar_t *str, size_t length)
PUGI__FN std::basic_string< wchar_t > | as_wide_impl (const char *str, size_t size)
bool | strcpy_insitu_allow (size_t length, uintptr_t allocated, char_t *target)
PUGI__FN bool | strcpy_insitu (char_t *&dest, uintptr_t &header, uintptr_t header_mask, const char_t *source)
PUGI__FN char_t * | strconv_escape (char_t *s, gap &g)
PUGI__FN char_t * | strconv_comment (char_t *s, char_t endch)
PUGI__FN char_t * | strconv_cdata (char_t *s, char_t endch)
PUGI__FN strconv_pcdata_t | get_strconv_pcdata (unsigned int optmask)
PUGI__FN strconv_attribute_t | get_strconv_attribute (unsigned int optmask)
xml_parse_result | make_parse_result (xml_parse_status status, ptrdiff_t offset=0)
PUGI__FN xml_encoding | get_write_native_encoding ()
PUGI__FN xml_encoding | get_write_encoding (xml_encoding encoding)
PUGI__FN size_t | get_valid_length (const char_t *data, size_t length)
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 void | text_output_escaped (xml_buffered_writer &writer, const char_t *s, chartypex_t type)
PUGI__FN void | text_output (xml_buffered_writer &writer, const char_t *s, chartypex_t type, unsigned int flags)
PUGI__FN void | text_output_cdata (xml_buffered_writer &writer, const char_t *s)
PUGI__FN void | node_output_attributes (xml_buffered_writer &writer, const xml_node &node, unsigned int flags)
PUGI__FN void | node_output (xml_buffered_writer &writer, const xml_node &node, const char_t *indent, unsigned int flags, unsigned int depth)
bool | has_declaration (const xml_node &node)
bool | allow_insert_child (xml_node_type parent, xml_node_type child)
PUGI__FN bool | allow_move (const xml_node &parent, const xml_node &child)
PUGI__FN void | recursive_copy_skip (xml_node &dest, const xml_node &source, const xml_node &skip)
bool | is_text_node (xml_node_struct *node)
PUGI__FN int | get_integer_base (const char_t *value)
PUGI__FN int | get_value_int (const char_t *value, int def)
PUGI__FN unsigned int | get_value_uint (const char_t *value, unsigned int def)
PUGI__FN double | get_value_double (const char_t *value, double def)
PUGI__FN float | get_value_float (const char_t *value, float def)
PUGI__FN bool | get_value_bool (const char_t *value, bool def)
PUGI__FN bool | set_value_buffer (char_t *&dest, uintptr_t &header, uintptr_t header_mask, char(&buf)[128])
PUGI__FN bool | set_value_convert (char_t *&dest, uintptr_t &header, uintptr_t header_mask, int value)
PUGI__FN bool | set_value_convert (char_t *&dest, uintptr_t &header, uintptr_t header_mask, unsigned int value)
PUGI__FN bool | set_value_convert (char_t *&dest, uintptr_t &header, uintptr_t header_mask, double value)
PUGI__FN bool | set_value_convert (char_t *&dest, uintptr_t &header, uintptr_t header_mask, bool value)
PUGI__FN xml_parse_status | get_file_size (FILE *file, size_t &out_result)
PUGI__FN size_t | zero_terminate_buffer (void *buffer, size_t size, xml_encoding encoding)
PUGI__FN xml_parse_result | load_file_impl (xml_document &doc, FILE *file, unsigned int options, xml_encoding encoding)
template<typename T >
PUGI__FN xml_parse_status | load_stream_data_noseek (std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
template<typename T >
PUGI__FN xml_parse_status | load_stream_data_seek (std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
template<typename T >
PUGI__FN xml_parse_result | load_stream_impl (xml_document &doc, std::basic_istream< T > &stream, unsigned int options, xml_encoding encoding)
PUGI__FN char * | convert_path_heap (const wchar_t *str)
PUGI__FN FILE * | open_file_wide (const wchar_t *path, const wchar_t *mode)
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_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)
static PUGI__FN void | pugi::unspecified_bool_xml_attribute (xml_attribute ***)
static PUGI__FN void | pugi::unspecified_bool_xml_node (xml_node ***)
static PUGI__FN void | pugi::unspecified_bool_xml_text (xml_text ***)
PUGI__FN std::string PUGIXML_FUNCTION | pugi::as_utf8 (const wchar_t *str)
PUGI__FN std::string PUGIXML_FUNCTION | pugi::as_utf8 (const std::basic_string< wchar_t > &str)
PUGI__FN std::basic_string< wchar_t > PUGIXML_FUNCTION | pugi::as_wide (const char *str)
PUGI__FN std::basic_string< wchar_t > PUGIXML_FUNCTION | pugi::as_wide (const std::string &str)
PUGI__FN void PUGIXML_FUNCTION | pugi::set_memory_management_functions (allocation_function allocate, deallocation_function deallocate)
PUGI__FN allocation_function PUGIXML_FUNCTION | pugi::get_memory_allocation_function ()
PUGI__FN deallocation_function PUGIXML_FUNCTION | pugi::get_memory_deallocation_function ()
template<typename T >
void | swap (T &lhs, T &rhs)
template<typename I , typename Pred >
I | min_element (I begin, I end, const Pred &pred)
template<typename I >
void | reverse (I begin, I end)
template<typename I >
I | unique (I begin, I end)
template<typename I >
void | copy_backwards (I begin, I end, I target)
template<typename I , typename Pred , typename T >
void | insertion_sort (I begin, I end, const Pred &pred, T *)
template<typename I , typename Pred >
void | partition (I begin, I middle, I end, const Pred &pred, I *out_eqbeg, I *out_eqend)
template<typename I , typename Pred >
void | median3 (I first, I middle, I last, const Pred &pred)
template<typename I , typename Pred >
void | median (I first, I middle, I last, const Pred &pred)
template<typename I , typename Pred >
void | sort (I begin, I end, const Pred &pred)
PUGI__FN xpath_string | xpath_string_const (const char_t *str)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN bool | starts_with (const char_t *string, const char_t *pattern)
const PUGI__FN char_t * | find_char (const char_t *s, char_t c)
const PUGI__FN char_t * | find_substring (const char_t *s, const char_t *p)
PUGI__FN char_t | tolower_ascii (char_t ch)
PUGI__FN xpath_string | string_value (const xpath_node &na, xpath_allocator *alloc)
PUGI__FN unsigned int | node_height (xml_node n)
PUGI__FN bool | node_is_before (xml_node ln, unsigned int lh, xml_node rn, unsigned int rh)
PUGI__FN bool | node_is_ancestor (xml_node parent, xml_node node)
const PUGI__FN void * | document_order (const xpath_node &xnode)
PUGI__FN double | gen_nan ()
PUGI__FN bool | is_nan (double value)
const PUGI__FN char_t * | convert_number_to_string_special (double value)
PUGI__FN bool | convert_number_to_boolean (double value)
PUGI__FN void | truncate_zeros (char *begin, char *end)
PUGI__FN void | convert_number_to_mantissa_exponent (double value, char *buffer, size_t buffer_size, char **out_mantissa, int *out_exponent)
PUGI__FN xpath_string | convert_number_to_string (double value, xpath_allocator *alloc)
PUGI__FN bool | check_string_to_number_format (const char_t *string)
PUGI__FN double | convert_string_to_number (const char_t *string)
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 double | round_nearest (double value)
PUGI__FN double | round_nearest_nzero (double value)
const PUGI__FN char_t * | qualified_name (const xpath_node &node)
const PUGI__FN char_t * | local_name (const xpath_node &node)
const PUGI__FN char_t * | namespace_uri (const xml_node &node)
const PUGI__FN char_t * | namespace_uri (const xml_attribute &attr, const xml_node &parent)
const PUGI__FN char_t * | namespace_uri (const xpath_node &node)
PUGI__FN void | normalize_space (char_t *buffer)
PUGI__FN void | translate (char_t *buffer, const char_t *from, const char_t *to)
PUGI__FN unsigned int | hash_string (const char_t *str)
template<typename T >
PUGI__FN T * | new_xpath_variable (const char_t *name)
PUGI__FN xpath_variable * | new_xpath_variable (xpath_value_type type, const char_t *name)
template<typename T >
PUGI__FN void | delete_xpath_variable (T *var)
PUGI__FN void | delete_xpath_variable (xpath_value_type type, xpath_variable *var)
PUGI__FN xpath_variable * | get_variable_scratch (char_t(&buffer)[32], xpath_variable_set *set, const char_t *begin, const char_t *end)
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)
PUGI__FN xpath_node | xpath_first (const xpath_node *begin, const xpath_node *end, xpath_node_set::type_t type)
PUGI__FN xpath_string | evaluate_string_impl (xpath_query_impl *impl, const xpath_node &n, xpath_stack_data &sd)
static PUGI__FN void | pugi::unspecified_bool_xpath_node (xpath_node ***)
static PUGI__FN void | pugi::unspecified_bool_xpath_query (xpath_query ***)

## Variables

PUGI__NS_END static const PUGI__NS_BEGIN size_t | xml_memory_page_size
static const uintptr_t | xml_memory_page_alignment = 32
static const uintptr_t | xml_memory_page_pointer_mask = ~(xml_memory_page_alignment - 1)
static const uintptr_t | xml_memory_page_name_allocated_mask = 16
static const uintptr_t | xml_memory_page_value_allocated_mask = 8
static const uintptr_t | xml_memory_page_type_mask = 7
static const unsigned char | chartype_table [256]
static const unsigned char | chartypex_table [256]
static const xpath_node_set | dummy_node_set

## Macro Definition Documentation

## PUGI__CHECK_ERROR

#define PUGI__CHECK_ERROR | ( |  | err,
|  |  | m
| ) |  | { if (*s == 0) PUGI__THROW_ERROR(err, m); }

Definition at line 1909 of file pugixml.cpp.

## PUGI__DMC_VOLATILE

#define PUGI__DMC_VOLATILE

Definition at line 101 of file pugixml.cpp.

## PUGI__ENDSEG

#define PUGI__ENDSEG | ( |  | ) | { ch = *s; *s = 0; ++s; }

Definition at line 1907 of file pugixml.cpp.

## PUGI__ENDSWITH

#define PUGI__ENDSWITH | ( |  | c,
|  |  | e
| ) |  | ((c) == (e) || ((c) == 0 && endch == (e)))

Definition at line 1899 of file pugixml.cpp.

## PUGI__FN

#define PUGI__FN

Definition at line 128 of file pugixml.cpp.

## PUGI__FN_NO_INLINE

#define PUGI__FN_NO_INLINE PUGI__NO_INLINE

Definition at line 129 of file pugixml.cpp.

## PUGI__IS_CHARTYPE

#define PUGI__IS_CHARTYPE | ( |  | c,
|  |  | ct
| ) |  | PUGI__IS_CHARTYPE_IMPL(c, ct, chartype_table)

Definition at line 1195 of file pugixml.cpp.

## PUGI__IS_CHARTYPE_IMPL

#define PUGI__IS_CHARTYPE_IMPL | ( |  | c,
|  |  | ct,
|  |  | table
| ) |  | (table[static_cast<unsigned char>(c)] & (ct))

Definition at line 1192 of file pugixml.cpp.

## PUGI__IS_CHARTYPEX

#define PUGI__IS_CHARTYPEX | ( |  | c,
|  |  | ct
| ) |  | PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table)

Definition at line 1196 of file pugixml.cpp.

## PUGI__NO_INLINE

#define PUGI__NO_INLINE

Definition at line 84 of file pugixml.cpp.

## PUGI__NS_BEGIN

#define PUGI__NS_BEGIN namespace pugi { namespace impl { namespace {

Definition at line 125 of file pugixml.cpp.

## PUGI__NS_END

#define PUGI__NS_END } } }

Definition at line 126 of file pugixml.cpp.

## PUGI__OPTSET

#define PUGI__OPTSET | ( |  | OPT | ) | ( optmsk & (OPT) )

Definition at line 1901 of file pugixml.cpp.

## PUGI__POPNODE

#define PUGI__POPNODE | ( |  | ) | { cursor = cursor->parent; }

Definition at line 1903 of file pugixml.cpp.

## PUGI__PUSHNODE

#define PUGI__PUSHNODE | ( |  | TYPE | ) | { cursor = append_new_node(cursor, alloc, TYPE); if (!cursor) PUGI__THROW_ERROR(status_out_of_memory, s); }

Definition at line 1902 of file pugixml.cpp.

## PUGI__SCANFOR

#define PUGI__SCANFOR | ( |  | X | ) | { while (*s != 0 && !(X)) ++s; }

Definition at line 1904 of file pugixml.cpp.

## PUGI__SCANWHILE

#define PUGI__SCANWHILE | ( |  | X | ) | { while (X) ++s; }

Definition at line 1905 of file pugixml.cpp.

## PUGI__SCANWHILE_UNROLL

#define PUGI__SCANWHILE_UNROLL | ( |  | X | ) | { while (X) { ++s; if (PUGI__UNLIKELY(!(X))) break; ++s; if (PUGI__UNLIKELY(!(X))) break; ++s; if (PUGI__UNLIKELY(!(X))) break; ++s; } }

Definition at line 1906 of file pugixml.cpp.

## PUGI__SKIPWS

#define PUGI__SKIPWS | ( |  | ) | { while (PUGI__IS_CHARTYPE(*s, ct_space)) ++s; }

Definition at line 1900 of file pugixml.cpp.

## PUGI__STATIC_ASSERT

#define PUGI__STATIC_ASSERT | ( |  | cond | ) | { static const char condition_failed[(cond) ? 1 : -1] = {0}; (void)condition_failed[0]; }

Definition at line 95 of file pugixml.cpp.

## PUGI__THROW_ERROR

#define PUGI__THROW_ERROR | ( |  | err,
|  |  | m
| ) |  | return error_offset = m, error_status = err, static_cast<char_t*>(0)

Definition at line 1908 of file pugixml.cpp.

## PUGI__UNLIKELY

#define PUGI__UNLIKELY | ( |  | cond | ) | (cond)

Definition at line 91 of file pugixml.cpp.

## SOURCE_PUGIXML_CPP

#define SOURCE_PUGIXML_CPP

## pugixml parser - version 1.4

Copyright (C) 2006-2014, by Arseny Kapoulkine (arsen.nosp@m.y.ka.nosp@m.poulk.nosp@m.ine@.nosp@m.gmail.nosp@m..com) Report bugs and download new versions at http://pugixml.org/

This library is distributed under the MIT License. See notice at the end of this file.

This work is based on the pugxml parser, which is: Copyright (C) 2003, by Kristen Wegner (krist.nosp@m.en@t.nosp@m.ima.n.nosp@m.et)

Definition at line 15 of file pugixml.cpp.

## Typedef Documentation

## strconv_attribute_t

typedef char_t*(* strconv_attribute_t) (char_t *, char_t)

Definition at line 2038 of file pugixml.cpp.

## strconv_pcdata_t

typedef char_t*(* strconv_pcdata_t) (char_t *)

Definition at line 1967 of file pugixml.cpp.

## wchar_counter

typedef wchar_selector<sizeof(wchar_t)>::counter wchar_counter

Definition at line 949 of file pugixml.cpp.

## wchar_writer

typedef wchar_selector<sizeof(wchar_t)>::writer wchar_writer

Definition at line 950 of file pugixml.cpp.

## xml_memory

typedef xml_memory_management_function_storage<int> xml_memory

Definition at line 170 of file pugixml.cpp.

## Enumeration Type Documentation

## ast_type_t

enum ast_type_t

Enumerator
ast_unknown |
ast_op_or |
ast_op_and |
ast_op_equal |
ast_op_not_equal |
ast_op_less |
ast_op_greater |
ast_op_less_or_equal |
ast_op_greater_or_equal |
ast_op_add |
ast_op_subtract |
ast_op_multiply |
ast_op_divide |
ast_op_mod |
ast_op_negate |
ast_op_union |
ast_predicate |
ast_filter |
ast_filter_posinv |
ast_string_constant |
ast_number_constant |
ast_variable |
ast_func_last |
ast_func_position |
ast_func_count |
ast_func_id |
ast_func_local_name_0 |
ast_func_local_name_1 |
ast_func_namespace_uri_0 |
ast_func_namespace_uri_1 |
ast_func_name_0 |
ast_func_name_1 |
ast_func_string_0 |
ast_func_string_1 |
ast_func_concat |
ast_func_starts_with |
ast_func_contains |
ast_func_substring_before |
ast_func_substring_after |
ast_func_substring_2 |
ast_func_substring_3 |
ast_func_string_length_0 |
ast_func_string_length_1 |
ast_func_normalize_space_0 |
ast_func_normalize_space_1 |
ast_func_translate |
ast_func_boolean |
ast_func_not |
ast_func_true |
ast_func_false |
ast_func_lang |
ast_func_number_0 |
ast_func_number_1 |
ast_func_sum |
ast_func_floor |
ast_func_ceiling |
ast_func_round |
ast_step |
ast_step_root |

Definition at line 7818 of file pugixml.cpp.

{
ast_unknown,
ast_op_or, // left or right
ast_op_and, // left and right
ast_op_equal, // left = right
ast_op_not_equal, // left != right
ast_op_less, // left < right
ast_op_greater, // left > right
ast_op_less_or_equal, // left <= right
ast_op_greater_or_equal, // left >= right
ast_op_add, // left + right
ast_op_subtract, // left - right
ast_op_multiply, // left * right
ast_op_divide, // left / right
ast_op_mod, // left % right
ast_op_negate, // left - right
ast_op_union, // left | right
ast_predicate, // apply predicate to set; next points to next predicate
ast_filter, // select * from left where right
ast_filter_posinv, // select * from left where right; proximity position invariant
ast_string_constant, // string constant
ast_number_constant, // number constant
ast_variable, // variable
ast_func_last, // last()
ast_func_position, // position()
ast_func_count, // count(left)
ast_func_id, // id(left)
ast_func_local_name_0, // local-name()
ast_func_local_name_1, // local-name(left)
ast_func_namespace_uri_0, // namespace-uri()
ast_func_namespace_uri_1, // namespace-uri(left)
ast_func_name_0, // name()
ast_func_name_1, // name(left)
ast_func_string_0, // string()
ast_func_string_1, // string(left)
ast_func_concat, // concat(left, right, siblings)
ast_func_starts_with, // starts_with(left, right)
ast_func_contains, // contains(left, right)
ast_func_substring_before, // substring-before(left, right)
ast_func_substring_after, // substring-after(left, right)
ast_func_substring_2, // substring(left, right)
ast_func_substring_3, // substring(left, right, third)
ast_func_string_length_0, // string-length()
ast_func_string_length_1, // string-length(left)
ast_func_normalize_space_0, // normalize-space()
ast_func_normalize_space_1, // normalize-space(left)
ast_func_translate, // translate(left, right, third)
ast_func_boolean, // boolean(left)
ast_func_not, // not(left)
ast_func_true, // true()
ast_func_false, // false()
ast_func_lang, // lang(left)
ast_func_number_0, // number()
ast_func_number_1, // number(left)
ast_func_sum, // sum(left)
ast_func_floor, // floor(left)
ast_func_ceiling, // ceiling(left)
ast_func_round, // round(left)
ast_step, // process set left with step
ast_step_root // select root node
};

## axis_t

enum axis_t

Enumerator
axis_ancestor |
axis_ancestor_or_self |
axis_attribute |
axis_child |
axis_descendant |
axis_descendant_or_self |
axis_following |
axis_following_sibling |
axis_namespace |
axis_parent |
axis_preceding |
axis_preceding_sibling |
axis_self |

Definition at line 7881 of file pugixml.cpp.

{
axis_ancestor,
axis_ancestor_or_self,
axis_attribute,
axis_child,
axis_descendant,
axis_descendant_or_self,
axis_following,
axis_following_sibling,
axis_namespace,
axis_parent,
axis_preceding,
axis_preceding_sibling,
axis_self
};

## chartype_t

enum chartype_t

Enumerator
ct_parse_pcdata |
ct_parse_attr |
ct_parse_attr_ws |
ct_space |
ct_parse_cdata |
ct_parse_comment |
ct_symbol |
ct_start_symbol |

Definition at line 1125 of file pugixml.cpp.

{
ct_parse_pcdata = 1, // \0, &, \r, <
ct_parse_attr = 2, // \0, &, \r, ', "
ct_parse_attr_ws = 4, // \0, &, \r, ', ", \n, tab
ct_space = 8, // \r, \n, space, tab
ct_parse_cdata = 16, // \0, ], >, \r
ct_parse_comment = 32, // \0, -, >, \r
ct_symbol = 64, // Any symbol > 127, a-z, A-Z, 0-9, _, :, -, .
ct_start_symbol = 128 // Any symbol > 127, a-z, A-Z, _, :
};

## chartypex_t

enum chartypex_t

Enumerator
ctx_special_pcdata |
ctx_special_attr |
ctx_start_symbol |
ctx_digit |
ctx_symbol |

Definition at line 1158 of file pugixml.cpp.

{
ctx_special_pcdata = 1, // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, >
ctx_special_attr = 2, // Any symbol >= 0 and < 32 (except \t), &, <, >, "
ctx_start_symbol = 4, // Any symbol > 127, a-z, A-Z, _
ctx_digit = 8, // 0-9
ctx_symbol = 16 // Any symbol > 127, a-z, A-Z, 0-9, _, -, .
};

## lexeme_t

enum lexeme_t

Enumerator
lex_none |
lex_equal |
lex_not_equal |
lex_less |
lex_greater |
lex_less_or_equal |
lex_greater_or_equal |
lex_plus |
lex_minus |
lex_multiply |
lex_union |
lex_var_ref |
lex_open_brace |
lex_close_brace |
lex_quoted_string |
lex_number |
lex_slash |
lex_double_slash |
lex_open_square_brace |
lex_close_square_brace |
lex_string |
lex_comma |
lex_axis_attribute |
lex_dot |
lex_double_dot |
lex_double_colon |
lex_eof |

Definition at line 7464 of file pugixml.cpp.

{
lex_none = 0,
lex_equal,
lex_not_equal,
lex_less,
lex_greater,
lex_less_or_equal,
lex_greater_or_equal,
lex_plus,
lex_minus,
lex_multiply,
lex_union,
lex_var_ref,
lex_open_brace,
lex_close_brace,
lex_quoted_string,
lex_number,
lex_slash,
lex_double_slash,
lex_open_square_brace,
lex_close_square_brace,
lex_string,
lex_comma,
lex_axis_attribute,
lex_dot,
lex_double_dot,
lex_double_colon,
lex_eof
};

## nodetest_t

enum nodetest_t

Enumerator
nodetest_none |
nodetest_name |
nodetest_type_node |
nodetest_type_comment |
nodetest_type_pi |
nodetest_type_text |
nodetest_pi |
nodetest_all |
nodetest_all_in_namespace |

Definition at line 7898 of file pugixml.cpp.

{
nodetest_none,
nodetest_name,
nodetest_type_node,
nodetest_type_comment,
nodetest_type_pi,
nodetest_type_text,
nodetest_pi,
nodetest_all,
nodetest_all_in_namespace
};

## Function Documentation

## allocate_attribute()

PUGI__NS_END PUGI__NS_BEGIN xml_attribute_struct* allocate_attribute | ( | xml_allocator & | alloc | ) |

inline

Definition at line 558 of file pugixml.cpp.

{
xml_memory_page* page;
void* memory = alloc.allocate_memory(sizeof(xml_attribute_struct), page);
return new (memory) xml_attribute_struct(page);
}

References xml_allocator::allocate_memory().

Referenced by append_new_attribute().

## allocate_node()

xml_node_struct* allocate_node | ( | xml_allocator & | alloc,
|  | xml_node_type | type
| ) |  |

inline

Definition at line 566 of file pugixml.cpp.

{
xml_memory_page* page;
void* memory = alloc.allocate_memory(sizeof(xml_node_struct), page);
return new (memory) xml_node_struct(page, type);
}

References xml_allocator::allocate_memory().

Referenced by append_new_node().

## allow_insert_child()

bool allow_insert_child | ( | xml_node_type | parent,
|  | xml_node_type | child
| ) |  |

inline

Definition at line 3430 of file pugixml.cpp.

{
if (parent != node_document && parent != node_element) return false;
if (child == node_document || child == node_null) return false;
if (parent != node_document && (child == node_declaration || child == node_doctype)) return false;
return true;
}

Referenced by allow_move().

## allow_move()

PUGI__FN bool allow_move | ( | const xml_node & | parent,
|  | const xml_node & | child
| ) |  |

Definition at line 3439 of file pugixml.cpp.

{
// check that child can be a child of parent
if (!allow_insert_child(parent.type(), child.type()))
return false;
// check that node is not moved between documents
if (parent.root() != child.root())
return false;
// check that new parent is not in the child subtree
xml_node cur = parent;
while (cur)
{
if (cur == child)
return false;
cur = cur.parent();
}
return true;
}

References allow_insert_child().

## append_new_attribute()

PUGI__FN_NO_INLINE xml_attribute_struct* append_new_attribute | ( | xml_node_struct * | node,
|  | xml_allocator & | alloc
| ) |  |

Definition at line 712 of file pugixml.cpp.

{
xml_attribute_struct* a = allocate_attribute(alloc);
if (!a) return 0;
xml_attribute_struct* first_attribute = node->first_attribute;
if (first_attribute)
{
xml_attribute_struct* last_attribute = first_attribute->prev_attribute_c;
last_attribute->next_attribute = a;
a->prev_attribute_c = last_attribute;
first_attribute->prev_attribute_c = a;
}
else
{
node->first_attribute = a;
a->prev_attribute_c = a;
}
return a;
}

References allocate_attribute().

Referenced by xml_parser::parse_tree().

## append_new_node()

PUGI__FN_NO_INLINE xml_node_struct* append_new_node | ( | xml_node_struct * | node,
|  | xml_allocator & | alloc,
|  | xml_node_type | type = `node_element`
| ) |  |

Definition at line 702 of file pugixml.cpp.

{
xml_node_struct* child = allocate_node(alloc, type);
if (!child) return 0;
append_node(child, node);
return child;
}

References allocate_node(), and append_node().

## append_node()

void append_node | ( | xml_node_struct * | child,
|  | xml_node_struct * | node
| ) |  |

inline

Definition at line 612 of file pugixml.cpp.

{
child->parent = node;
xml_node_struct* head = node->first_child;
if (head)
{
xml_node_struct* tail = head->prev_sibling_c;
tail->next_sibling = child;
child->prev_sibling_c = tail;
head->prev_sibling_c = child;
}
else
{
node->first_child = child;
child->prev_sibling_c = child;
}
child->next_sibling = 0;
}

Referenced by append_new_node().

## as_utf8_begin()

PUGI__FN size_t as_utf8_begin | ( | const wchar_t * | str,
|  | size_t | length
| ) |  |

Definition at line 1594 of file pugixml.cpp.

{
// get length in utf8 characters
return utf_decoder<utf8_counter>::decode_wchar_block(str, length, 0);
}

References utf_decoder< Traits, opt_swap >::decode_wchar_block().

Referenced by as_utf8_impl(), and convert_path_heap().

## as_utf8_end()

PUGI__FN void as_utf8_end | ( | char * | buffer,
|  | size_t | size,
|  | const wchar_t * | str,
|  | size_t | length
| ) |  |

Definition at line 1600 of file pugixml.cpp.

{
// convert to utf8
uint8_t* begin = reinterpret_cast<uint8_t*>(buffer);
uint8_t* end = utf_decoder<utf8_writer>::decode_wchar_block(str, length, begin);
assert(begin + size == end);
(void)!end;
// zero-terminate
buffer[size] = 0;
}

References utf_decoder< Traits, opt_swap >::decode_wchar_block().

Referenced by as_utf8_impl(), and convert_path_heap().

## as_utf8_impl()

PUGI__FN std::string as_utf8_impl | ( | const wchar_t * | str,
|  | size_t | length
| ) |  |

Definition at line 1614 of file pugixml.cpp.

{
// first pass: get length in utf8 characters
size_t size = as_utf8_begin(str, length);
// allocate resulting string
std::string result;
result.resize(size);
// second pass: convert to utf8
if (size > 0) as_utf8_end(&result[0], size, str, length);
return result;
}

References as_utf8_begin(), and as_utf8_end().

Referenced by pugi::as_utf8().

## as_wide_impl()

PUGI__FN std::basic_string<wchar_t> as_wide_impl | ( | const char * | str,
|  | size_t | size
| ) |  |

Definition at line 1629 of file pugixml.cpp.

{
const uint8_t* data = reinterpret_cast<const uint8_t*>(str);
// first pass: get length in wchar_t units
size_t length = utf_decoder<wchar_counter>::decode_utf8_block(data, size, 0);
// allocate resulting string
std::basic_string<wchar_t> result;
result.resize(length);
// second pass: convert to wchar_t
if (length > 0)
{
wchar_writer::value_type begin = reinterpret_cast<wchar_writer::value_type>(&result[0]);
wchar_writer::value_type end = utf_decoder<wchar_writer>::decode_utf8_block(data, size, begin);
assert(begin + length == end);
(void)!end;
}
return result;
}

References utf_decoder< Traits, opt_swap >::decode_utf8_block().

Referenced by pugi::as_wide().

## check_string_to_number_format()

PUGI__FN bool check_string_to_number_format | ( | const char_t * | string | ) |

Definition at line 6938 of file pugixml.cpp.

{
// parse leading whitespace
while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string;
// parse sign
if (*string == '-') ++string;
if (!*string) return false;
// if there is no integer part, there should be a decimal part with at least one digit
if (!PUGI__IS_CHARTYPEX(string[0], ctx_digit) && (string[0] != '.' || !PUGI__IS_CHARTYPEX(string[1], ctx_digit))) return false;
// parse integer part
while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string;
// parse decimal part
if (*string == '.')
{
++string;
while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string;
}
// parse trailing whitespace
while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string;
return *string == 0;
}

References ct_space, ctx_digit, PUGI__IS_CHARTYPE, and PUGI__IS_CHARTYPEX.

Referenced by convert_string_to_number().

## convert_buffer()

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
| ) |  |

Definition at line 1561 of file pugixml.cpp.

{
// fast path: no conversion required
if (encoding == encoding_utf8) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable);
// source encoding is utf16
if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
{
xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
return (native_encoding == encoding) ?
convert_buffer_utf16(out_buffer, out_length, contents, size, opt_false()) :
convert_buffer_utf16(out_buffer, out_length, contents, size, opt_true());
}
// source encoding is utf32
if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
{
xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
return (native_encoding == encoding) ?
convert_buffer_utf32(out_buffer, out_length, contents, size, opt_false()) :
convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true());
}
// source encoding is latin1
if (encoding == encoding_latin1) return convert_buffer_latin1(out_buffer, out_length, contents, size, is_mutable);
assert(!"Invalid encoding");
return false;
}

References convert_buffer_latin1(), convert_buffer_utf16(), convert_buffer_utf32(), get_mutable_buffer(), and is_little_endian().

Referenced by load_buffer_impl().

## convert_buffer_latin1()

PUGI__FN bool convert_buffer_latin1 | ( | char_t *& | out_buffer,
|  | size_t & | out_length,
|  | const void * | contents,
|  | size_t | size,
|  | bool | is_mutable
| ) |  |

Definition at line 1524 of file pugixml.cpp.

{
const uint8_t* data = static_cast<const uint8_t*>(contents);
size_t data_length = size;
// get size of prefix that does not need utf8 conversion
size_t prefix_length = get_latin1_7bit_prefix_length(data, data_length);
assert(prefix_length <= data_length);
const uint8_t* postfix = data + prefix_length;
size_t postfix_length = data_length - prefix_length;
// if no conversion is needed, just return the original buffer
if (postfix_length == 0) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable);
// first pass: get length in utf8 units
size_t length = prefix_length + utf_decoder<utf8_counter>::decode_latin1_block(postfix, postfix_length, 0);
// allocate buffer of suitable length
char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!buffer) return false;
// second pass: convert latin1 input to utf8
memcpy(buffer, data, prefix_length);
uint8_t* obegin = reinterpret_cast<uint8_t*>(buffer);
uint8_t* oend = utf_decoder<utf8_writer>::decode_latin1_block(postfix, postfix_length, obegin + prefix_length);
assert(oend == obegin + length);
*oend = 0;
out_buffer = buffer;
out_length = length + 1;
return true;
}

References xml_memory_management_function_storage< T >::allocate, utf_decoder< Traits, opt_swap >::decode_latin1_block(), get_latin1_7bit_prefix_length(), and get_mutable_buffer().

Referenced by convert_buffer().

## convert_buffer_output()

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
| ) |  |

Definition at line 2977 of file pugixml.cpp.

{
if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
{
uint16_t* dest = r_u16;
// convert to native utf16
uint16_t* end = utf_decoder<utf16_writer>::decode_utf8_block(reinterpret_cast<const uint8_t*>(data), length, dest);
// swap if necessary
xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast<size_t>(end - dest));
return static_cast<size_t>(end - dest) * sizeof(uint16_t);
}
if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
{
uint32_t* dest = r_u32;
// convert to native utf32
uint32_t* end = utf_decoder<utf32_writer>::decode_utf8_block(reinterpret_cast<const uint8_t*>(data), length, dest);
// swap if necessary
xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast<size_t>(end - dest));
return static_cast<size_t>(end - dest) * sizeof(uint32_t);
}
if (encoding == encoding_latin1)
{
uint8_t* dest = r_u8;
uint8_t* end = utf_decoder<latin1_writer>::decode_utf8_block(reinterpret_cast<const uint8_t*>(data), length, dest);
return static_cast<size_t>(end - dest);
}
assert(!"Invalid encoding");
return 0;
}

References convert_utf_endian_swap(), utf_decoder< Traits, opt_swap >::decode_utf8_block(), and is_little_endian().

Referenced by xml_buffered_writer::flush().

## convert_buffer_utf16()

template<typename opt_swap >

PUGI__FN bool convert_buffer_utf16 | ( | char_t *& | out_buffer,
|  | size_t & | out_length,
|  | const void * | contents,
|  | size_t | size,
|  | opt_swap |
| ) |  |

Definition at line 1465 of file pugixml.cpp.

{
const uint16_t* data = static_cast<const uint16_t*>(contents);
size_t data_length = size / sizeof(uint16_t);
// first pass: get length in utf8 units
size_t length = utf_decoder<utf8_counter, opt_swap>::decode_utf16_block(data, data_length, 0);
// allocate buffer of suitable length
char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!buffer) return false;
// second pass: convert utf16 input to utf8
uint8_t* obegin = reinterpret_cast<uint8_t*>(buffer);
uint8_t* oend = utf_decoder<utf8_writer, opt_swap>::decode_utf16_block(data, data_length, obegin);
assert(oend == obegin + length);
*oend = 0;
out_buffer = buffer;
out_length = length + 1;
return true;
}

References xml_memory_management_function_storage< T >::allocate, and utf_decoder< Traits, opt_swap >::decode_utf16_block().

Referenced by convert_buffer().

## convert_buffer_utf32()

template<typename opt_swap >

PUGI__FN bool convert_buffer_utf32 | ( | char_t *& | out_buffer,
|  | size_t & | out_length,
|  | const void * | contents,
|  | size_t | size,
|  | opt_swap |
| ) |  |

Definition at line 1490 of file pugixml.cpp.

{
const uint32_t* data = static_cast<const uint32_t*>(contents);
size_t data_length = size / sizeof(uint32_t);
// first pass: get length in utf8 units
size_t length = utf_decoder<utf8_counter, opt_swap>::decode_utf32_block(data, data_length, 0);
// allocate buffer of suitable length
char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!buffer) return false;
// second pass: convert utf32 input to utf8
uint8_t* obegin = reinterpret_cast<uint8_t*>(buffer);
uint8_t* oend = utf_decoder<utf8_writer, opt_swap>::decode_utf32_block(data, data_length, obegin);
assert(oend == obegin + length);
*oend = 0;
out_buffer = buffer;
out_length = length + 1;
return true;
}

References xml_memory_management_function_storage< T >::allocate, and utf_decoder< Traits, opt_swap >::decode_utf32_block().

Referenced by convert_buffer().

## convert_number_to_boolean()

PUGI__FN bool convert_number_to_boolean | ( | double | value | ) |

Definition at line 6812 of file pugixml.cpp.

{
return (value != 0 && !is_nan(value));
}

References is_nan().

Referenced by xpath_ast_node::eval_boolean().

## convert_number_to_mantissa_exponent()

PUGI__FN void convert_number_to_mantissa_exponent | ( | double | value,
|  | char * | buffer,
|  | size_t | buffer_size,
|  | char ** | out_mantissa,
|  | int * | out_exponent
| ) |  |

Definition at line 6840 of file pugixml.cpp.

{
// get a scientific notation value with IEEE DBL_DIG decimals
sprintf(buffer, "%.*e", DBL_DIG, value);
assert(strlen(buffer) < buffer_size);
(void)!buffer_size;
// get the exponent (possibly negative)
char* exponent_string = strchr(buffer, 'e');
assert(exponent_string);
int exponent = atoi(exponent_string + 1);
// extract mantissa string: skip sign
char* mantissa = buffer[0] == '-' ? buffer + 1 : buffer;
assert(mantissa[0] != '0' && mantissa[1] == '.');
// divide mantissa by 10 to eliminate integer part
mantissa[1] = mantissa[0];
mantissa++;
exponent++;
// remove extra mantissa digits and zero-terminate mantissa
truncate_zeros(mantissa, exponent_string);
// fill results
*out_mantissa = mantissa;
*out_exponent = exponent;
}

References truncate_zeros().

Referenced by convert_number_to_string().

## convert_number_to_string()

PUGI__FN xpath_string convert_number_to_string | ( | double | value,
|  | xpath_allocator * | alloc
| ) |  |

Definition at line 6871 of file pugixml.cpp.

{
// try special number conversion
const char_t* special = convert_number_to_string_special(value);
if (special) return xpath_string_const(special);
// get mantissa + exponent form
char mantissa_buffer[32];
char* mantissa;
int exponent;
convert_number_to_mantissa_exponent(value, mantissa_buffer, sizeof(mantissa_buffer), &mantissa, &exponent);
// allocate a buffer of suitable length for the number
size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4;
char_t* result = static_cast<char_t*>(alloc->allocate(sizeof(char_t) * result_size));
assert(result);
// make the number!
char_t* s = result;
// sign
if (value < 0) *s++ = '-';
// integer part
if (exponent <= 0)
{
*s++ = '0';
}
else
{
while (exponent > 0)
{
assert(*mantissa == 0 || static_cast<unsigned int>(static_cast<unsigned int>(*mantissa) - '0') <= 9);
*s++ = *mantissa ? *mantissa++ : '0';
exponent--;
}
}
// fractional part
if (*mantissa)
{
// decimal point
*s++ = '.';
// extra zeroes from negative exponent
while (exponent < 0)
{
*s++ = '0';
exponent++;
}
// extra mantissa digits
while (*mantissa)
{
assert(static_cast<unsigned int>(*mantissa - '0') <= 9);
*s++ = *mantissa++;
}
}
// zero-terminate
assert(s < result + result_size);
*s = 0;
return xpath_string(result, true);
}

References xpath_allocator::allocate(), convert_number_to_mantissa_exponent(), convert_number_to_string_special(), and xpath_string_const().

Referenced by xpath_ast_node::eval_string().

## convert_number_to_string_special()

const PUGI__FN char_t* convert_number_to_string_special | ( | double | value | ) |

Definition at line 6780 of file pugixml.cpp.

{
#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__)
if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0;
if (_isnan(value)) return PUGIXML_TEXT("NaN");
return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");
#elif defined(fpclassify) && defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO)
switch (fpclassify(value))
{
case FP_NAN:
return PUGIXML_TEXT("NaN");
case FP_INFINITE:
return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");
case FP_ZERO:
return PUGIXML_TEXT("0");
default:
return 0;
}
#else
// fallback
const volatile double v = value;
if (v == 0) return PUGIXML_TEXT("0");
if (v != v) return PUGIXML_TEXT("NaN");
if (v * 2 == v) return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");
return 0;
#endif
}

Referenced by convert_number_to_string().

## convert_path_heap()

PUGI__FN char* convert_path_heap | ( | const wchar_t * | str | ) |

Definition at line 3959 of file pugixml.cpp.

{
assert(str);
// first pass: get length in utf8 characters
size_t length = strlength_wide(str);
size_t size = as_utf8_begin(str, length);
// allocate resulting string
char* result = static_cast<char*>(xml_memory::allocate(size + 1));
if (!result) return 0;
// second pass: convert to utf8
as_utf8_end(result, size, str, length);
return result;
}

References xml_memory_management_function_storage< T >::allocate, as_utf8_begin(), as_utf8_end(), and strlength_wide().

Referenced by open_file_wide().

## convert_string_to_number()

PUGI__FN double convert_string_to_number | ( | const char_t * | string | ) |

Definition at line 6968 of file pugixml.cpp.

{
// check string format
if (!check_string_to_number_format(string)) return gen_nan();
// parse string
#ifdef PUGIXML_WCHAR_MODE
return wcstod(string, 0);
#else
return atof(string);
#endif
}

References check_string_to_number_format(), and gen_nan().

Referenced by xpath_ast_node::compare_eq(), xpath_ast_node::compare_rel(), convert_string_to_number_scratch(), and xpath_ast_node::eval_number().

## convert_string_to_number_scratch()

PUGI__FN bool convert_string_to_number_scratch | ( | char_t(&) | buffer[32],
|  | const char_t * | begin,
|  | const char_t * | end,
|  | double * | out_result
| ) |  |

Definition at line 6981 of file pugixml.cpp.

{
size_t length = static_cast<size_t>(end - begin);
char_t* scratch = buffer;
if (length >= sizeof(buffer) / sizeof(buffer[0]))
{
// need to make dummy on-heap copy
scratch = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!scratch) return false;
}
// copy string to zero-terminated buffer and perform conversion
memcpy(scratch, begin, length * sizeof(char_t));
scratch[length] = 0;
*out_result = convert_string_to_number(scratch);
// free dummy buffer
if (scratch != buffer) xml_memory::deallocate(scratch);
return true;
}

References xml_memory_management_function_storage< T >::allocate, convert_string_to_number(), and xml_memory_management_function_storage< T >::deallocate.

Referenced by xpath_parser::parse_primary_expression().

## convert_utf_endian_swap()

template<typename T >

PUGI__FN void convert_utf_endian_swap | ( | T * | result,
|  | const T * | data,
|  | size_t | length
| ) |  |

Definition at line 1111 of file pugixml.cpp.

{
for (size_t i = 0; i < length; ++i) result[i] = endian_swap(data[i]);
}

References endian_swap().

Referenced by convert_buffer_output().

## copy_backwards()

template<typename I >

void copy_backwards | ( | I | begin,
|  | I | end,
|  | I | target
| ) |  |

Definition at line 6037 of file pugixml.cpp.

{
while (begin != end) *--target = *--end;
}

Referenced by insertion_sort().

## default_allocate()

PUGI__NS_BEGIN PUGI__FN void* default_allocate | ( | size_t | size | ) |

Definition at line 150 of file pugixml.cpp.

{
return malloc(size);
}

## default_deallocate()

PUGI__FN void default_deallocate | ( | void * | ptr | ) |

Definition at line 155 of file pugixml.cpp.

{
free(ptr);
}

## delete_xpath_variable() [1/2]

template<typename T >

PUGI__FN void delete_xpath_variable | ( | T * | var | ) |

Definition at line 7244 of file pugixml.cpp.

{
var->~T();
xml_memory::deallocate(var);
}

References xml_memory_management_function_storage< T >::deallocate.

Referenced by delete_xpath_variable().

## delete_xpath_variable() [2/2]

PUGI__FN void delete_xpath_variable | ( | xpath_value_type | type,
|  | xpath_variable * | var
| ) |  |

Definition at line 7250 of file pugixml.cpp.

{
switch (type)
{
case xpath_type_node_set:
delete_xpath_variable(static_cast<xpath_variable_node_set*>(var));
break;
case xpath_type_number:
delete_xpath_variable(static_cast<xpath_variable_number*>(var));
break;
case xpath_type_string:
delete_xpath_variable(static_cast<xpath_variable_string*>(var));
break;
case xpath_type_boolean:
delete_xpath_variable(static_cast<xpath_variable_boolean*>(var));
break;
default:
assert(!"Invalid variable type");
}
}

References delete_xpath_variable().

## destroy_attribute()

void destroy_attribute | ( | xml_attribute_struct * | a,
|  | xml_allocator & | alloc
| ) |  |

inline

Definition at line 574 of file pugixml.cpp.

{
uintptr_t header = a->header;
if (header & impl::xml_memory_page_name_allocated_mask) alloc.deallocate_string(a->name);
if (header & impl::xml_memory_page_value_allocated_mask) alloc.deallocate_string(a->value);
alloc.deallocate_memory(a, sizeof(xml_attribute_struct), reinterpret_cast<xml_memory_page*>(header & xml_memory_page_pointer_mask));
}

References xml_allocator::deallocate_memory(), xml_allocator::deallocate_string(), xml_memory_page_name_allocated_mask, xml_memory_page_pointer_mask, and xml_memory_page_value_allocated_mask.

Referenced by destroy_node().

## destroy_node()

void destroy_node | ( | xml_node_struct * | n,
|  | xml_allocator & | alloc
| ) |  |

inline

Definition at line 584 of file pugixml.cpp.

{
uintptr_t header = n->header;
if (header & impl::xml_memory_page_name_allocated_mask) alloc.deallocate_string(n->name);
if (header & impl::xml_memory_page_value_allocated_mask) alloc.deallocate_string(n->value);
for (xml_attribute_struct* attr = n->first_attribute; attr; )
{
xml_attribute_struct* next = attr->next_attribute;
destroy_attribute(attr, alloc);
attr = next;
}
for (xml_node_struct* child = n->first_child; child; )
{
xml_node_struct* next = child->next_sibling;
destroy_node(child, alloc);
child = next;
}
alloc.deallocate_memory(n, sizeof(xml_node_struct), reinterpret_cast<xml_memory_page*>(header & xml_memory_page_pointer_mask));
}

References xml_allocator::deallocate_memory(), xml_allocator::deallocate_string(), destroy_attribute(), xml_memory_page_name_allocated_mask, xml_memory_page_pointer_mask, and xml_memory_page_value_allocated_mask.

## document_order()

const PUGI__FN void* document_order | ( | const xpath_node & | xnode | ) |

Definition at line 6667 of file pugixml.cpp.

{
xml_node_struct* node = xnode.node().internal_object();
if (node)
{
if (node->name && (node->header & xml_memory_page_name_allocated_mask) == 0) return node->name;
if (node->value && (node->header & xml_memory_page_value_allocated_mask) == 0) return node->value;
return 0;
}
xml_attribute_struct* attr = xnode.attribute().internal_object();
if (attr)
{
if ((attr->header & xml_memory_page_name_allocated_mask) == 0) return attr->name;
if ((attr->header & xml_memory_page_value_allocated_mask) == 0) return attr->value;
return 0;
}
return 0;
}

References xml_memory_page_name_allocated_mask, and xml_memory_page_value_allocated_mask.

Referenced by document_order_comparator::operator()().

## endian_swap() [1/2]

PUGI__NS_END PUGI__NS_BEGIN uint16_t endian_swap | ( | uint16_t | value | ) |

inline

Definition at line 752 of file pugixml.cpp.

{
return static_cast<uint16_t>(((value & 0xff) << 8) | (value >> 8));
}

Referenced by convert_utf_endian_swap(), utf_decoder< Traits, opt_swap >::decode_utf16_block(), and utf_decoder< Traits, opt_swap >::decode_utf32_block().

## endian_swap() [2/2]

uint32_t endian_swap | ( | uint32_t | value | ) |

inline

Definition at line 757 of file pugixml.cpp.

{
return ((value & 0xff) << 24) | ((value & 0xff00) << 8) | ((value & 0xff0000) >> 8) | (value >> 24);
}

## evaluate_string_impl()

PUGI__FN xpath_string evaluate_string_impl | ( | xpath_query_impl * | impl,
|  | const xpath_node & | n,
|  | xpath_stack_data & | sd
| ) |  |

Definition at line 10123 of file pugixml.cpp.

{
if (!impl) return xpath_string();
#ifdef PUGIXML_NO_EXCEPTIONS
if (setjmp(sd.error_handler)) return xpath_string();
#endif
xpath_context c(n, 1, 1);
return impl->root->eval_string(c, sd.stack);
}

References xpath_ast_node::eval_string(), xpath_query_impl::root, and xpath_stack_data::stack.

## find_char()

const PUGI__FN char_t* find_char | ( | const char_t * | s,
|  | char_t | c
| ) |  |

Definition at line 6545 of file pugixml.cpp.

{
#ifdef PUGIXML_WCHAR_MODE
return wcschr(s, c);
#else
return strchr(s, c);
#endif
}

Referenced by local_name(), namespace_uri_predicate::namespace_uri_predicate(), and translate().

## find_substring()

const PUGI__FN char_t* find_substring | ( | const char_t * | s,
|  | const char_t * | p
| ) |  |

Definition at line 6554 of file pugixml.cpp.

{
#ifdef PUGIXML_WCHAR_MODE
// MSVC6 wcsstr bug workaround (if s is empty it always returns 0)
return (*p == 0) ? s : wcsstr(s, p);
#else
return strstr(s, p);
#endif
}

Referenced by xpath_ast_node::eval_boolean(), and xpath_ast_node::eval_string().

## gen_nan()

PUGI__FN double gen_nan | ( |  | ) |

Definition at line 6754 of file pugixml.cpp.

{
#if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24))
union { float f; uint32_t i; } u[sizeof(float) == sizeof(uint32_t) ? 1 : -1];
u[0].i = 0x7fc00000;
return u[0].f;
#else
// fallback
const volatile double zero = 0.0;
return zero / zero;
#endif
}

Referenced by convert_string_to_number().

## get_allocator()

xml_allocator& get_allocator | ( | const xml_node_struct * | node | ) |

inline

Definition at line 548 of file pugixml.cpp.

{
assert(node);
return *reinterpret_cast<xml_memory_page*>(node->header & xml_memory_page_pointer_mask)->allocator;
}

References xml_memory_page_pointer_mask.

## get_buffer_encoding()

PUGI__FN xml_encoding get_buffer_encoding | ( | xml_encoding | encoding,
|  | const void * | contents,
|  | size_t | size
| ) |  |

Definition at line 1239 of file pugixml.cpp.

{
// replace wchar encoding with utf implementation
if (encoding == encoding_wchar) return get_wchar_encoding();
// replace utf16 encoding with utf16 with specific endianness
if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
// replace utf32 encoding with utf32 with specific endianness
if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
// only do autodetection if no explicit encoding is requested
if (encoding != encoding_auto) return encoding;
// skip encoding autodetection if input buffer is too small
if (size < 4) return encoding_utf8;
// try to guess encoding (based on XML specification, Appendix F.1)
const uint8_t* data = static_cast<const uint8_t*>(contents);
PUGI__DMC_VOLATILE uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3];
return guess_buffer_encoding(d0, d1, d2, d3);
}

References get_wchar_encoding(), guess_buffer_encoding(), is_little_endian(), and PUGI__DMC_VOLATILE.

Referenced by load_buffer_impl(), load_file_impl(), and load_stream_impl().

## get_file_size()

PUGI__FN xml_parse_status get_file_size | ( | FILE * | file,
|  | size_t & | out_result
| ) |  |

Definition at line 3701 of file pugixml.cpp.

{
#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE)
// there are 64-bit versions of fseek/ftell, let's use them
typedef __int64 length_type;
_fseeki64(file, 0, SEEK_END);
length_type length = _ftelli64(file);
_fseeki64(file, 0, SEEK_SET);
#elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && !defined(__STRICT_ANSI__)
// there are 64-bit versions of fseek/ftell, let's use them
typedef off64_t length_type;
fseeko64(file, 0, SEEK_END);
length_type length = ftello64(file);
fseeko64(file, 0, SEEK_SET);
#else
// if this is a 32-bit OS, long is enough; if this is a unix system, long is 64-bit, which is enough; otherwise we can't do anything anyway.
typedef long length_type;
fseek(file, 0, SEEK_END);
length_type length = ftell(file);
fseek(file, 0, SEEK_SET);
#endif
// check for I/O errors
if (length < 0) return status_io_error;
// check for overflow
size_t result = static_cast<size_t>(length);
if (static_cast<length_type>(result) != length) return status_out_of_memory;
// finalize
out_result = result;
return status_ok;
}

Referenced by load_file_impl().

## get_integer_base()

PUGI__FN int get_integer_base | ( | const char_t * | value | ) |

Definition at line 3524 of file pugixml.cpp.

{
const char_t* s = value;
while (PUGI__IS_CHARTYPE(*s, ct_space))
s++;
if (*s == '-')
s++;
return (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) ? 16 : 10;
}

References ct_space, and PUGI__IS_CHARTYPE.

Referenced by get_value_int(), and get_value_uint().

## get_latin1_7bit_prefix_length()

PUGI__FN size_t get_latin1_7bit_prefix_length | ( | const uint8_t * | data,
|  | size_t | size
| ) |  |

Definition at line 1515 of file pugixml.cpp.

{
for (size_t i = 0; i < size; ++i)
if (data[i] > 127)
return i;
return size;
}

Referenced by convert_buffer_latin1().

## get_mutable_buffer()

PUGI__FN bool get_mutable_buffer | ( | char_t *& | out_buffer,
|  | size_t & | out_length,
|  | const void * | contents,
|  | size_t | size,
|  | bool | is_mutable
| ) |  |

Definition at line 1264 of file pugixml.cpp.

{
size_t length = size / sizeof(char_t);
if (is_mutable)
{
out_buffer = static_cast<char_t*>(const_cast<void*>(contents));
out_length = length;
}
else
{
char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!buffer) return false;
memcpy(buffer, contents, length * sizeof(char_t));
buffer[length] = 0;
out_buffer = buffer;
out_length = length + 1;
}
return true;
}

References xml_memory_management_function_storage< T >::allocate.

Referenced by convert_buffer(), and convert_buffer_latin1().

## get_strconv_attribute()

PUGI__FN strconv_attribute_t get_strconv_attribute | ( | unsigned int | optmask | ) |

Definition at line 2189 of file pugixml.cpp.

{
PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80);
switch ((optmask >> 4) & 15) // get bitmask for flags (wconv wnorm eol escapes)
{
case 0: return strconv_attribute_impl<opt_false>::parse_simple;
case 1: return strconv_attribute_impl<opt_true>::parse_simple;
case 2: return strconv_attribute_impl<opt_false>::parse_eol;
case 3: return strconv_attribute_impl<opt_true>::parse_eol;
case 4: return strconv_attribute_impl<opt_false>::parse_wconv;
case 5: return strconv_attribute_impl<opt_true>::parse_wconv;
case 6: return strconv_attribute_impl<opt_false>::parse_wconv;
case 7: return strconv_attribute_impl<opt_true>::parse_wconv;
case 8: return strconv_attribute_impl<opt_false>::parse_wnorm;
case 9: return strconv_attribute_impl<opt_true>::parse_wnorm;
case 10: return strconv_attribute_impl<opt_false>::parse_wnorm;
case 11: return strconv_attribute_impl<opt_true>::parse_wnorm;
case 12: return strconv_attribute_impl<opt_false>::parse_wnorm;
case 13: return strconv_attribute_impl<opt_true>::parse_wnorm;
case 14: return strconv_attribute_impl<opt_false>::parse_wnorm;
case 15: return strconv_attribute_impl<opt_true>::parse_wnorm;
default: assert(false); return 0; // should not get here
}
}

References PUGI__STATIC_ASSERT.

Referenced by xml_parser::parse_tree().

## get_strconv_pcdata()

PUGI__FN strconv_pcdata_t get_strconv_pcdata | ( | unsigned int | optmask | ) |

Definition at line 2020 of file pugixml.cpp.

{
PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800);
switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (eol escapes trim)
{
case 0: return strconv_pcdata_impl<opt_false, opt_false, opt_false>::parse;
case 1: return strconv_pcdata_impl<opt_false, opt_false, opt_true>::parse;
case 2: return strconv_pcdata_impl<opt_false, opt_true, opt_false>::parse;
case 3: return strconv_pcdata_impl<opt_false, opt_true, opt_true>::parse;
case 4: return strconv_pcdata_impl<opt_true, opt_false, opt_false>::parse;
case 5: return strconv_pcdata_impl<opt_true, opt_false, opt_true>::parse;
case 6: return strconv_pcdata_impl<opt_true, opt_true, opt_false>::parse;
case 7: return strconv_pcdata_impl<opt_true, opt_true, opt_true>::parse;
default: assert(false); return 0; // should not get here
}
}

References PUGI__STATIC_ASSERT.

Referenced by xml_parser::parse_tree().

## get_valid_length()

PUGI__FN size_t get_valid_length | ( | const char_t * | data,
|  | size_t | length
| ) |  |

Definition at line 2961 of file pugixml.cpp.

{
assert(length > 4);
for (size_t i = 1; i <= 4; ++i)
{
uint8_t ch = static_cast<uint8_t>(data[length - i]);
// either a standalone character or a leading one
if ((ch & 0xc0) != 0x80) return length - i;
}
// there are four non-leading characters at the end, sequence tail is broken so might as well process the whole chunk
return length;
}

Referenced by xml_buffered_writer::write().

## get_value_bool()

PUGI__FN bool get_value_bool | ( | const char_t * | value,
|  | bool | def
| ) |  |

Definition at line 3585 of file pugixml.cpp.

{
if (!value) return def;
// only look at first char
char_t first = *value;
// 1*, t* (true), T* (True), y* (yes), Y* (YES)
return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y');
}

## get_value_double()

PUGI__FN double get_value_double | ( | const char_t * | value,
|  | double | def
| ) |  |

Definition at line 3563 of file pugixml.cpp.

{
if (!value) return def;
#ifdef PUGIXML_WCHAR_MODE
return wcstod(value, 0);
#else
return strtod(value, 0);
#endif
}

## get_value_float()

PUGI__FN float get_value_float | ( | const char_t * | value,
|  | float | def
| ) |  |

Definition at line 3574 of file pugixml.cpp.

{
if (!value) return def;
#ifdef PUGIXML_WCHAR_MODE
return static_cast<float>(wcstod(value, 0));
#else
return static_cast<float>(strtod(value, 0));
#endif
}

## get_value_int()

PUGI__FN int get_value_int | ( | const char_t * | value,
|  | int | def
| ) |  |

Definition at line 3537 of file pugixml.cpp.

{
if (!value) return def;
int base = get_integer_base(value);
#ifdef PUGIXML_WCHAR_MODE
return static_cast<int>(wcstol(value, 0, base));
#else
return static_cast<int>(strtol(value, 0, base));
#endif
}

References get_integer_base().

## get_value_uint()

PUGI__FN unsigned int get_value_uint | ( | const char_t * | value,
|  | unsigned int | def
| ) |  |

Definition at line 3550 of file pugixml.cpp.

{
if (!value) return def;
int base = get_integer_base(value);
#ifdef PUGIXML_WCHAR_MODE
return static_cast<unsigned int>(wcstoul(value, 0, base));
#else
return static_cast<unsigned int>(strtoul(value, 0, base));
#endif
}

References get_integer_base().

## get_variable_scratch()

PUGI__FN xpath_variable* get_variable_scratch | ( | char_t(&) | buffer[32],
|  | xpath_variable_set * | set,
|  | const char_t * | begin,
|  | const char_t * | end
| ) |  |

Definition at line 7275 of file pugixml.cpp.

{
size_t length = static_cast<size_t>(end - begin);
char_t* scratch = buffer;
if (length >= sizeof(buffer) / sizeof(buffer[0]))
{
// need to make dummy on-heap copy
scratch = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!scratch) return 0;
}
// copy string to zero-terminated buffer and perform lookup
memcpy(scratch, begin, length * sizeof(char_t));
scratch[length] = 0;
xpath_variable* result = set->get(scratch);
// free dummy buffer
if (scratch != buffer) xml_memory::deallocate(scratch);
return result;
}

References xml_memory_management_function_storage< T >::allocate, and xml_memory_management_function_storage< T >::deallocate.

Referenced by xpath_parser::parse_primary_expression().

## get_wchar_encoding()

PUGI__FN xml_encoding get_wchar_encoding | ( |  | ) |

Definition at line 1205 of file pugixml.cpp.

{
PUGI__STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4);
if (sizeof(wchar_t) == 2)
return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
else
return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
}

References is_little_endian(), and PUGI__STATIC_ASSERT.

Referenced by get_buffer_encoding(), get_write_encoding(), get_write_native_encoding(), and zero_terminate_buffer().

## get_write_encoding()

PUGI__FN xml_encoding get_write_encoding | ( | xml_encoding | encoding | ) |

Definition at line 2870 of file pugixml.cpp.

{
// replace wchar encoding with utf implementation
if (encoding == encoding_wchar) return get_wchar_encoding();
// replace utf16 encoding with utf16 with specific endianness
if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
// replace utf32 encoding with utf32 with specific endianness
if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
// only do autodetection if no explicit encoding is requested
if (encoding != encoding_auto) return encoding;
// assume utf8 encoding
return encoding_utf8;
}

References get_wchar_encoding(), and is_little_endian().

## get_write_native_encoding()

PUGI__FN xml_encoding get_write_native_encoding | ( |  | ) |

Definition at line 2861 of file pugixml.cpp.

{
#ifdef PUGIXML_WCHAR_MODE
return get_wchar_encoding();
#else
return encoding_utf8;
#endif
}

References get_wchar_encoding().

Referenced by xml_buffered_writer::flush(), and xml_buffered_writer::write().

## guess_buffer_encoding()

PUGI__FN xml_encoding guess_buffer_encoding | ( | uint8_t | d0,
|  | uint8_t | d1,
|  | uint8_t | d2,
|  | uint8_t | d3
| ) |  |

Definition at line 1215 of file pugixml.cpp.

{
// look for BOM in first few bytes
if (d0 == 0 && d1 == 0 && d2 == 0xfe && d3 == 0xff) return encoding_utf32_be;
if (d0 == 0xff && d1 == 0xfe && d2 == 0 && d3 == 0) return encoding_utf32_le;
if (d0 == 0xfe && d1 == 0xff) return encoding_utf16_be;
if (d0 == 0xff && d1 == 0xfe) return encoding_utf16_le;
if (d0 == 0xef && d1 == 0xbb && d2 == 0xbf) return encoding_utf8;
// look for <, <? or <?xm in various encodings
if (d0 == 0 && d1 == 0 && d2 == 0 && d3 == 0x3c) return encoding_utf32_be;
if (d0 == 0x3c && d1 == 0 && d2 == 0 && d3 == 0) return encoding_utf32_le;
if (d0 == 0 && d1 == 0x3c && d2 == 0 && d3 == 0x3f) return encoding_utf16_be;
if (d0 == 0x3c && d1 == 0 && d2 == 0x3f && d3 == 0) return encoding_utf16_le;
if (d0 == 0x3c && d1 == 0x3f && d2 == 0x78 && d3 == 0x6d) return encoding_utf8;
// look for utf16 < followed by node name (this may fail, but is better than utf8 since it's zero terminated so early)
if (d0 == 0 && d1 == 0x3c) return encoding_utf16_be;
if (d0 == 0x3c && d1 == 0) return encoding_utf16_le;
// no known BOM detected, assume utf8
return encoding_utf8;
}

Referenced by get_buffer_encoding().

## has_declaration()

bool has_declaration | ( | const xml_node & | node | ) |

inline

Definition at line 3417 of file pugixml.cpp.

{
for (xml_node child = node.first_child(); child; child = child.next_sibling())
{
xml_node_type type = child.type();
if (type == node_declaration) return true;
if (type == node_element) return false;
}
return false;
}

## hash_string()

PUGI__FN unsigned int hash_string | ( | const char_t * | str | ) |

Definition at line 7188 of file pugixml.cpp.

{
// Jenkins one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time)
unsigned int result = 0;
while (*str)
{
result += static_cast<unsigned int>(*str++);
result += result << 10;
result ^= result >> 6;
}
result += result << 3;
result ^= result >> 11;
result += result << 15;
return result;
}

## insert_node_after()

void insert_node_after | ( | xml_node_struct * | child,
|  | xml_node_struct * | node
| ) |  |

inline

Definition at line 653 of file pugixml.cpp.

{
xml_node_struct* parent = node->parent;
child->parent = parent;
if (node->next_sibling)
node->next_sibling->prev_sibling_c = child;
else
parent->first_child->prev_sibling_c = child;
child->next_sibling = node->next_sibling;
child->prev_sibling_c = node;
node->next_sibling = child;
}

## insert_node_before()

void insert_node_before | ( | xml_node_struct * | child,
|  | xml_node_struct * | node
| ) |  |

inline

Definition at line 670 of file pugixml.cpp.

{
xml_node_struct* parent = node->parent;
child->parent = parent;
if (node->prev_sibling_c->next_sibling)
node->prev_sibling_c->next_sibling = child;
else
parent->first_child = child;
child->prev_sibling_c = node->prev_sibling_c;
child->next_sibling = node;
node->prev_sibling_c = child;
}

## insertion_sort()

template<typename I , typename Pred , typename T >

void insertion_sort | ( | I | begin,
|  | I | end,
|  | const Pred & | pred,
|  | T * |
| ) |  |

Definition at line 6042 of file pugixml.cpp.

{
assert(begin != end);
for (I it = begin + 1; it != end; ++it)
{
T val = *it;
if (pred(val, *begin))
{
// move to front
copy_backwards(begin, it, it + 1);
*begin = val;
}
else
{
I hole = it;
// move hole backwards
while (pred(val, *(hole - 1)))
{
*hole = *(hole - 1);
hole--;
}
// fill hole with element
*hole = val;
}
}
}

References copy_backwards().

Referenced by sort().

## is_little_endian()

PUGI__FN bool is_little_endian | ( |  | ) |

Definition at line 1198 of file pugixml.cpp.

{
unsigned int ui = 1;
return *reinterpret_cast<unsigned char*>(&ui) == 1;
}

Referenced by convert_buffer(), convert_buffer_output(), get_buffer_encoding(), get_wchar_encoding(), and get_write_encoding().

## is_nan()

PUGI__FN bool is_nan | ( | double | value | ) |

Definition at line 6767 of file pugixml.cpp.

{
#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__)
return !!_isnan(value);
#elif defined(fpclassify) && defined(FP_NAN)
return fpclassify(value) == FP_NAN;
#else
// fallback
const volatile double v = value;
return v != v;
#endif
}

Referenced by convert_number_to_boolean(), and xpath_ast_node::eval_string().

## is_text_node()

bool is_text_node | ( | xml_node_struct * | node | ) |

inline

Definition at line 3516 of file pugixml.cpp.

{
xml_node_type type = static_cast<xml_node_type>((node->header & impl::xml_memory_page_type_mask) + 1);
return type == node_pcdata || type == node_cdata;
}

References xml_memory_page_type_mask.

## load_buffer_impl()

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
| ) |  |

Definition at line 4011 of file pugixml.cpp.

{
// check input buffer
assert(contents || size == 0);
// get actual encoding
xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
// get private buffer
char_t* buffer = 0;
size_t length = 0;
if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory);
// delete original buffer if we performed a conversion
if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents);
// store buffer for offset_debug
doc->buffer = buffer;
// parse
xml_parse_result res = impl::xml_parser::parse(buffer, length, doc, root, options);
// remember encoding
res.encoding = buffer_encoding;
// grab onto buffer if it's our buffer, user is responsible for deallocating contents himself
if (own || buffer != contents) *out_buffer = buffer;
return res;
}

References xml_document_struct::buffer, convert_buffer(), get_buffer_encoding(), and make_parse_result().

## load_file_impl()

PUGI__FN xml_parse_result load_file_impl | ( | xml_document & | doc,
|  | FILE * | file,
|  | unsigned int | options,
|  | xml_encoding | encoding
| ) |  |

Definition at line 3764 of file pugixml.cpp.

{
if (!file) return make_parse_result(status_file_not_found);
// get file size (can result in I/O errors)
size_t size = 0;
xml_parse_status size_status = get_file_size(file, size);
if (size_status != status_ok)
{
fclose(file);
return make_parse_result(size_status);
}
size_t max_suffix_size = sizeof(char_t);
// allocate buffer for the whole file
char* contents = static_cast<char*>(xml_memory::allocate(size + max_suffix_size));
if (!contents)
{
fclose(file);
return make_parse_result(status_out_of_memory);
}
// read file in memory
size_t read_size = fread(contents, 1, size, file);
fclose(file);
if (read_size != size)
{
xml_memory::deallocate(contents);
return make_parse_result(status_io_error);
}
xml_encoding real_encoding = get_buffer_encoding(encoding, contents, size);
return doc.load_buffer_inplace_own(contents, zero_terminate_buffer(contents, size, real_encoding), options, real_encoding);
}

References xml_memory_management_function_storage< T >::allocate, xml_memory_management_function_storage< T >::deallocate, get_buffer_encoding(), get_file_size(), make_parse_result(), and zero_terminate_buffer().

## load_stream_data_noseek()

template<typename T >

PUGI__FN xml_parse_status load_stream_data_noseek | ( | std::basic_istream< T > & | stream,
|  | void ** | out_buffer,
|  | size_t * | out_size
| ) |  |

Definition at line 3837 of file pugixml.cpp.

{
buffer_holder chunks(0, xml_stream_chunk<T>::destroy);
// read file to a chunk list
size_t total = 0;
xml_stream_chunk<T>* last = 0;
while (!stream.eof())
{
// allocate new chunk
xml_stream_chunk<T>* chunk = xml_stream_chunk<T>::create();
if (!chunk) return status_out_of_memory;
// append chunk to list
if (last) last = last->next = chunk;
else chunks.data = last = chunk;
// read data to chunk
stream.read(chunk->data, static_cast<std::streamsize>(sizeof(chunk->data) / sizeof(T)));
chunk->size = static_cast<size_t>(stream.gcount()) * sizeof(T);
// read may set failbit | eofbit in case gcount() is less than read length, so check for other I/O errors
if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error;
// guard against huge files (chunk size is small enough to make this overflow check work)
if (total + chunk->size < total) return status_out_of_memory;
total += chunk->size;
}
size_t max_suffix_size = sizeof(char_t);
// copy chunk list to a contiguous buffer
char* buffer = static_cast<char*>(xml_memory::allocate(total + max_suffix_size));
if (!buffer) return status_out_of_memory;
char* write = buffer;
for (xml_stream_chunk<T>* chunk = static_cast<xml_stream_chunk<T>*>(chunks.data); chunk; chunk = chunk->next)
{
assert(write + chunk->size <= buffer + total);
memcpy(write, chunk->data, chunk->size);
write += chunk->size;
}
assert(write == buffer + total);
// return buffer
*out_buffer = buffer;
*out_size = total;
return status_ok;
}

References xml_memory_management_function_storage< T >::allocate, xml_stream_chunk< T >::create(), buffer_holder::data, xml_stream_chunk< T >::data, xml_stream_chunk< T >::next, and xml_stream_chunk< T >::size.

Referenced by load_stream_impl().

## load_stream_data_seek()

template<typename T >

PUGI__FN xml_parse_status load_stream_data_seek | ( | std::basic_istream< T > & | stream,
|  | void ** | out_buffer,
|  | size_t * | out_size
| ) |  |

Definition at line 3891 of file pugixml.cpp.

{
// get length of remaining data in stream
typename std::basic_istream<T>::pos_type pos = stream.tellg();
stream.seekg(0, std::ios::end);
std::streamoff length = stream.tellg() - pos;
stream.seekg(pos);
if (stream.fail() || pos < 0) return status_io_error;
// guard against huge files
size_t read_length = static_cast<size_t>(length);
if (static_cast<std::streamsize>(read_length) != length || length < 0) return status_out_of_memory;
size_t max_suffix_size = sizeof(char_t);
// read stream data into memory (guard against stream exceptions with buffer holder)
buffer_holder buffer(xml_memory::allocate(read_length * sizeof(T) + max_suffix_size), xml_memory::deallocate);
if (!buffer.data) return status_out_of_memory;
stream.read(static_cast<T*>(buffer.data), static_cast<std::streamsize>(read_length));
// read may set failbit | eofbit in case gcount() is less than read_length (i.e. line ending conversion), so check for other I/O errors
if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error;
// return buffer
size_t actual_length = static_cast<size_t>(stream.gcount());
assert(actual_length <= read_length);
*out_buffer = buffer.release();
*out_size = actual_length * sizeof(T);
return status_ok;
}

References xml_memory_management_function_storage< T >::allocate, buffer_holder::data, xml_memory_management_function_storage< T >::deallocate, and buffer_holder::release().

Referenced by load_stream_impl().

## load_stream_impl()

template<typename T >

PUGI__FN xml_parse_result load_stream_impl | ( | xml_document & | doc,
|  | std::basic_istream< T > & | stream,
|  | unsigned int | options,
|  | xml_encoding | encoding
| ) |  |

Definition at line 3927 of file pugixml.cpp.

{
void* buffer = 0;
size_t size = 0;
xml_parse_status status = status_ok;
// if stream has an error bit set, bail out (otherwise tellg() can fail and we'll clear error bits)
if (stream.fail()) return make_parse_result(status_io_error);
// load stream to memory (using seek-based implementation if possible, since it's faster and takes less memory)
if (stream.tellg() < 0)
{
stream.clear(); // clear error flags that could be set by a failing tellg
status = load_stream_data_noseek(stream, &buffer, &size);
}
else
status = load_stream_data_seek(stream, &buffer, &size);
if (status != status_ok) return make_parse_result(status);
xml_encoding real_encoding = get_buffer_encoding(encoding, buffer, size);
return doc.load_buffer_inplace_own(buffer, zero_terminate_buffer(buffer, size, real_encoding), options, real_encoding);
}

References get_buffer_encoding(), load_stream_data_noseek(), load_stream_data_seek(), make_parse_result(), and zero_terminate_buffer().

## local_name()

const PUGI__FN char_t* local_name | ( | const xpath_node & | node | ) |

Definition at line 7022 of file pugixml.cpp.

{
const char_t* name = qualified_name(node);
const char_t* p = find_char(name, ':');
return p ? p + 1 : name;
}

References find_char(), and qualified_name().

Referenced by xpath_ast_node::eval_string().

## make_parse_result()

xml_parse_result make_parse_result | ( | xml_parse_status | status,
|  | ptrdiff_t | offset = `0`
| ) |  |

inline

Definition at line 2215 of file pugixml.cpp.

{
xml_parse_result result;
result.status = status;
result.offset = offset;
return result;
}

Referenced by load_buffer_impl(), load_file_impl(), load_stream_impl(), and xml_parser::parse().

## median()

template<typename I , typename Pred >

void median | ( | I | first,
|  | I | middle,
|  | I | last,
|  | const Pred & | pred
| ) |  |

Definition at line 6134 of file pugixml.cpp.

{
if (last - first <= 40)
{
// median of three for small chunks
median3(first, middle, last, pred);
}
else
{
// median of nine
size_t step = (last - first + 1) / 8;
median3(first, first + step, first + 2 * step, pred);
median3(middle - step, middle, middle + step, pred);
median3(last - 2 * step, last - step, last, pred);
median3(first + step, middle, last - step, pred);
}
}

References median3().

Referenced by sort().

## median3()

template<typename I , typename Pred >

void median3 | ( | I | first,
|  | I | middle,
|  | I | last,
|  | const Pred & | pred
| ) |  |

Definition at line 6127 of file pugixml.cpp.

{
if (pred(*middle, *first)) swap(*middle, *first);
if (pred(*last, *middle)) swap(*last, *middle);
if (pred(*middle, *first)) swap(*middle, *first);
}

References swap().

Referenced by median().

## min_element()

template<typename I , typename Pred >

I min_element | ( | I | begin,
|  | I | end,
|  | const Pred & | pred
| ) |  |

Definition at line 5998 of file pugixml.cpp.

{
I result = begin;
for (I it = begin + 1; it != end; ++it)
if (pred(*it, *result))
result = it;
return result;
}

Referenced by xpath_first().

## namespace_uri() [1/3]

const PUGI__FN char_t* namespace_uri | ( | const xml_attribute & | attr,
|  | const xml_node & | parent
| ) |  |

Definition at line 7071 of file pugixml.cpp.

{
namespace_uri_predicate pred = attr.name();
// Default namespace does not apply to attributes
if (!pred.prefix) return PUGIXML_TEXT("");
xml_node p = parent;
while (p)
{
xml_attribute a = p.find_attribute(pred);
if (a) return a.value();
p = p.parent();
}
return PUGIXML_TEXT("");
}

References namespace_uri_predicate::prefix.

## namespace_uri() [2/3]

const PUGI__FN char_t* namespace_uri | ( | const xml_node & | node | ) |

Definition at line 7053 of file pugixml.cpp.

{
namespace_uri_predicate pred = node.name();
xml_node p = node;
while (p)
{
xml_attribute a = p.find_attribute(pred);
if (a) return a.value();
p = p.parent();
}
return PUGIXML_TEXT("");
}

Referenced by xpath_ast_node::eval_string(), and namespace_uri().

## namespace_uri() [3/3]

const PUGI__FN char_t* namespace_uri | ( | const xpath_node & | node | ) |

Definition at line 7092 of file pugixml.cpp.

{
return node.attribute() ? namespace_uri(node.attribute(), node.parent()) : namespace_uri(node.node());
}

References namespace_uri().

## new_xpath_variable() [1/2]

template<typename T >

PUGI__FN T* new_xpath_variable | ( | const char_t * | name | ) |

Definition at line 7207 of file pugixml.cpp.

{
size_t length = strlength(name);
if (length == 0) return 0; // empty variable names are invalid
// $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters
void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t));
if (!memory) return 0;
T* result = new (memory) T();
memcpy(result->name, name, (length + 1) * sizeof(char_t));
return result;
}

References xml_memory_management_function_storage< T >::allocate, and strlength().

## new_xpath_variable() [2/2]

PUGI__FN xpath_variable* new_xpath_variable | ( | xpath_value_type | type,
|  | const char_t * | name
| ) |  |

Definition at line 7223 of file pugixml.cpp.

{
switch (type)
{
case xpath_type_node_set:
return new_xpath_variable<xpath_variable_node_set>(name);
case xpath_type_number:
return new_xpath_variable<xpath_variable_number>(name);
case xpath_type_string:
return new_xpath_variable<xpath_variable_string>(name);
case xpath_type_boolean:
return new_xpath_variable<xpath_variable_boolean>(name);
default:
return 0;
}
}

## node_height()

PUGI__FN unsigned int node_height | ( | xml_node | n | ) |

Definition at line 6620 of file pugixml.cpp.

{
unsigned int result = 0;
while (n)
{
++result;
n = n.parent();
}
return result;
}

Referenced by document_order_comparator::operator()().

## node_is_ancestor()

PUGI__FN bool node_is_ancestor | ( | xml_node | parent,
|  | xml_node | node
| ) |  |

Definition at line 6660 of file pugixml.cpp.

{
while (node && node != parent) node = node.parent();
return parent && node == parent;
}

Referenced by xpath_ast_node::step_fill().

## node_is_before()

PUGI__FN bool node_is_before | ( | xml_node | ln,
|  | unsigned int | lh,
|  | xml_node | rn,
|  | unsigned int | rh
| ) |  |

Definition at line 6633 of file pugixml.cpp.

{
// normalize heights
for (unsigned int i = rh; i < lh; i++) ln = ln.parent();
for (unsigned int j = lh; j < rh; j++) rn = rn.parent();
// one node is the ancestor of the other
if (ln == rn) return lh < rh;
// find common ancestor
while (ln.parent() != rn.parent())
{
ln = ln.parent();
rn = rn.parent();
}
// there is no common ancestor (the shared parent is null), nodes are from different documents
if (!ln.parent()) return ln < rn;
// determine sibling order
for (; ln; ln = ln.next_sibling())
if (ln == rn)
return true;
return false;
}

Referenced by document_order_comparator::operator()().

## node_output()

PUGI__FN void node_output | ( | xml_buffered_writer & | writer,
|  | const xml_node & | node,
|  | const char_t * | indent,
|  | unsigned int | flags,
|  | unsigned int | depth
| ) |  |

Definition at line 3288 of file pugixml.cpp.

{
const char_t* default_name = PUGIXML_TEXT(":anonymous");
if ((flags & format_indent) != 0 && (flags & format_raw) == 0)
for (unsigned int i = 0; i < depth; ++i) writer.write(indent);
switch (node.type())
{
case node_document:
{
for (xml_node n = node.first_child(); n; n = n.next_sibling())
node_output(writer, n, indent, flags, depth);
break;
}
case node_element:
{
const char_t* name = node.name()[0] ? node.name() : default_name;
writer.write('<');
writer.write(name);
node_output_attributes(writer, node, flags);
if (flags & format_raw)
{
if (!node.first_child())
writer.write(' ', '/', '>');
else
{
writer.write('>');
for (xml_node n = node.first_child(); n; n = n.next_sibling())
node_output(writer, n, indent, flags, depth + 1);
writer.write('<', '/');
writer.write(name);
writer.write('>');
}
}
else if (!node.first_child())
writer.write(' ', '/', '>', '\n');
else if (node.first_child() == node.last_child() && (node.first_child().type() == node_pcdata || node.first_child().type() == node_cdata))
{
writer.write('>');
if (node.first_child().type() == node_pcdata)
text_output(writer, node.first_child().value(), ctx_special_pcdata, flags);
else
text_output_cdata(writer, node.first_child().value());
writer.write('<', '/');
writer.write(name);
writer.write('>', '\n');
}
else
{
writer.write('>', '\n');
for (xml_node n = node.first_child(); n; n = n.next_sibling())
node_output(writer, n, indent, flags, depth + 1);
if ((flags & format_indent) != 0 && (flags & format_raw) == 0)
for (unsigned int i = 0; i < depth; ++i) writer.write(indent);
writer.write('<', '/');
writer.write(name);
writer.write('>', '\n');
}
break;
}
case node_pcdata:
text_output(writer, node.value(), ctx_special_pcdata, flags);
if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_cdata:
text_output_cdata(writer, node.value());
if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_comment:
writer.write('<', '!', '-', '-');
writer.write(node.value());
writer.write('-', '-', '>');
if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_pi:
case node_declaration:
writer.write('<', '?');
writer.write(node.name()[0] ? node.name() : default_name);
if (node.type() == node_declaration)
{
node_output_attributes(writer, node, flags);
}
else if (node.value()[0])
{
writer.write(' ');
writer.write(node.value());
}
writer.write('?', '>');
if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_doctype:
writer.write('<', '!', 'D', 'O', 'C');
writer.write('T', 'Y', 'P', 'E');
if (node.value()[0])
{
writer.write(' ');
writer.write(node.value());
}
writer.write('>');
if ((flags & format_raw) == 0) writer.write('\n');
break;
default:
assert(!"Invalid node type");
}
}

References ctx_special_pcdata, node_output_attributes(), text_output(), text_output_cdata(), and xml_buffered_writer::write().

## node_output_attributes()

PUGI__FN void node_output_attributes | ( | xml_buffered_writer & | writer,
|  | const xml_node & | node,
|  | unsigned int | flags
| ) |  |

Definition at line 3272 of file pugixml.cpp.

{
const char_t* default_name = PUGIXML_TEXT(":anonymous");
for (xml_attribute a = node.first_attribute(); a; a = a.next_attribute())
{
writer.write(' ');
writer.write(a.name()[0] ? a.name() : default_name);
writer.write('=', '"');
text_output(writer, a.value(), ctx_special_attr, flags);
writer.write('"');
}
}

References ctx_special_attr, text_output(), and xml_buffered_writer::write().

Referenced by node_output().

## normalize_space()

PUGI__FN void normalize_space | ( | char_t * | buffer | ) |

Definition at line 7097 of file pugixml.cpp.

{
char_t* write = buffer;
for (char_t* it = buffer; *it; )
{
char_t ch = *it++;
if (PUGI__IS_CHARTYPE(ch, ct_space))
{
// replace whitespace sequence with single space
while (PUGI__IS_CHARTYPE(*it, ct_space)) it++;
// avoid leading spaces
if (write != buffer) *write++ = ' ';
}
else *write++ = ch;
}
// remove trailing space
if (write != buffer && PUGI__IS_CHARTYPE(write[-1], ct_space)) write--;
// zero-terminate
*write = 0;
}

References ct_space, and PUGI__IS_CHARTYPE.

Referenced by xpath_ast_node::eval_string().

## open_file_wide()

PUGI__FN FILE* open_file_wide | ( | const wchar_t * | path,
|  | const wchar_t * | mode
| ) |  |

Definition at line 3977 of file pugixml.cpp.

{
// there is no standard function to open wide paths, so our best bet is to try utf8 path
char* path_utf8 = convert_path_heap(path);
if (!path_utf8) return 0;
// convert mode to ASCII (we mirror _wfopen interface)
char mode_ascii[4] = {0};
for (size_t i = 0; mode[i]; ++i) mode_ascii[i] = static_cast<char>(mode[i]);
// try to open the utf8 path
FILE* result = fopen(path_utf8, mode_ascii);
// free dummy buffer
xml_memory::deallocate(path_utf8);
return result;
}

References convert_path_heap(), and xml_memory_management_function_storage< T >::deallocate.

## partition()

template<typename I , typename Pred >

void partition | ( | I | begin,
|  | I | middle,
|  | I | end,
|  | const Pred & | pred,
|  | I * | out_eqbeg,
|  | I * | out_eqend
| ) |  |

Definition at line 6074 of file pugixml.cpp.

{
I eqbeg = middle, eqend = middle + 1;
// expand equal range
while (eqbeg != begin && *(eqbeg - 1) == *eqbeg) --eqbeg;
while (eqend != end && *eqend == *eqbeg) ++eqend;
// process outer elements
I ltend = eqbeg, gtbeg = eqend;
for (;;)
{
// find the element from the right side that belongs to the left one
for (; gtbeg != end; ++gtbeg)
if (!pred(*eqbeg, *gtbeg))
{
if (*gtbeg == *eqbeg) swap(*gtbeg, *eqend++);
else break;
}
// find the element from the left side that belongs to the right one
for (; ltend != begin; --ltend)
if (!pred(*(ltend - 1), *eqbeg))
{
if (*eqbeg == *(ltend - 1)) swap(*(ltend - 1), *--eqbeg);
else break;
}
// scanned all elements
if (gtbeg == end && ltend == begin)
{
*out_eqbeg = eqbeg;
*out_eqend = eqend;
return;
}
// make room for elements by moving equal area
if (gtbeg == end)
{
if (--ltend != --eqbeg) swap(*ltend, *eqbeg);
swap(*eqbeg, *--eqend);
}
else if (ltend == begin)
{
if (eqend != gtbeg) swap(*eqbeg, *eqend);
++eqend;
swap(*gtbeg++, *eqbeg++);
}
else swap(*gtbeg++, *--ltend);
}
}

References swap().

Referenced by sort().

## prepend_node()

void prepend_node | ( | xml_node_struct * | child,
|  | xml_node_struct * | node
| ) |  |

inline

Definition at line 635 of file pugixml.cpp.

{
child->parent = node;
xml_node_struct* head = node->first_child;
if (head)
{
child->prev_sibling_c = head->prev_sibling_c;
head->prev_sibling_c = child;
}
else
child->prev_sibling_c = child;
child->next_sibling = head;
node->first_child = child;
}

## qualified_name()

const PUGI__FN char_t* qualified_name | ( | const xpath_node & | node | ) |

Definition at line 7017 of file pugixml.cpp.

{
return node.attribute() ? node.attribute().name() : node.node().name();
}

Referenced by xpath_ast_node::eval_string(), and local_name().

## recursive_copy_skip()

PUGI__FN void recursive_copy_skip | ( | xml_node & | dest,
|  | const xml_node & | source,
|  | const xml_node & | skip
| ) |  |

Definition at line 3463 of file pugixml.cpp.

{
assert(dest.type() == source.type());
switch (source.type())
{
case node_element:
{
dest.set_name(source.name());
for (xml_attribute a = source.first_attribute(); a; a = a.next_attribute())
dest.append_attribute(a.name()).set_value(a.value());
for (xml_node c = source.first_child(); c; c = c.next_sibling())
{
if (c == skip) continue;
xml_node cc = dest.append_child(c.type());
assert(cc);
recursive_copy_skip(cc, c, skip);
}
break;
}
case node_pcdata:
case node_cdata:
case node_comment:
case node_doctype:
dest.set_value(source.value());
break;
case node_pi:
dest.set_name(source.name());
dest.set_value(source.value());
break;
case node_declaration:
{
dest.set_name(source.name());
for (xml_attribute a = source.first_attribute(); a; a = a.next_attribute())
dest.append_attribute(a.name()).set_value(a.value());
break;
}
default:
assert(!"Invalid node type");
}
}

## remove_node()

void remove_node | ( | xml_node_struct * | node | ) |

inline

Definition at line 687 of file pugixml.cpp.

{
xml_node_struct* parent = node->parent;
if (node->next_sibling)
node->next_sibling->prev_sibling_c = node->prev_sibling_c;
else if (parent->first_child)
parent->first_child->prev_sibling_c = node->prev_sibling_c;
if (node->prev_sibling_c->next_sibling)
node->prev_sibling_c->next_sibling = node->next_sibling;
else
parent->first_child = node->next_sibling;
}

## reverse()

template<typename I >

void reverse | ( | I | begin,
|  | I | end
| ) |  |

Definition at line 6009 of file pugixml.cpp.

{
while (end - begin > 1) swap(*begin++, *--end);
}

References swap().

Referenced by FIX::Session::lookupSession(), and xpath_sort().

## round_nearest()

PUGI__FN double round_nearest | ( | double | value | ) |

Definition at line 7005 of file pugixml.cpp.

{
return floor(value + 0.5);
}

Referenced by xpath_ast_node::eval_string().

## round_nearest_nzero()

PUGI__FN double round_nearest_nzero | ( | double | value | ) |

Definition at line 7010 of file pugixml.cpp.

{
// same as round_nearest, but returns -0 for [-0.5, -0]
// ceil is used to differentiate between +0 and -0 (we return -0 for [-0.5, -0] and +0 for +0)
return (value >= -0.5 && value <= 0) ? ceil(value) : floor(value + 0.5);
}

Referenced by xpath_ast_node::eval_number().

## save_file_impl()

PUGI__FN bool save_file_impl | ( | const xml_document & | doc,
|  | FILE * | file,
|  | const char_t * | indent,
|  | unsigned int | flags,
|  | xml_encoding | encoding
| ) |  |

Definition at line 3997 of file pugixml.cpp.

{
if (!file) return false;
xml_writer_file writer(file);
doc.save(writer, indent, flags, encoding);
int result = ferror(file);
fclose(file);
return result == 0;
}

## set_value_buffer()

PUGI__FN bool set_value_buffer | ( | char_t *& | dest,
|  | uintptr_t & | header,
|  | uintptr_t | header_mask,
|  | char(&) | buf[128]
| ) |  |

Definition at line 3641 of file pugixml.cpp.

{
#ifdef PUGIXML_WCHAR_MODE
char_t wbuf[128];
impl::widen_ascii(wbuf, buf);
return strcpy_insitu(dest, header, header_mask, wbuf);
#else
return strcpy_insitu(dest, header, header_mask, buf);
#endif
}

References strcpy_insitu().

Referenced by set_value_convert().

## set_value_convert() [1/4]

PUGI__FN bool set_value_convert | ( | char_t *& | dest,
|  | uintptr_t & | header,
|  | uintptr_t | header_mask,
|  | bool | value
| ) |  |

Definition at line 3677 of file pugixml.cpp.

{
return strcpy_insitu(dest, header, header_mask, value ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false"));
}

References strcpy_insitu().

## set_value_convert() [2/4]

PUGI__FN bool set_value_convert | ( | char_t *& | dest,
|  | uintptr_t & | header,
|  | uintptr_t | header_mask,
|  | double | value
| ) |  |

Definition at line 3669 of file pugixml.cpp.

{
char buf[128];
sprintf(buf, "%g", value);
return set_value_buffer(dest, header, header_mask, buf);
}

References set_value_buffer().

## set_value_convert() [3/4]

PUGI__FN bool set_value_convert | ( | char_t *& | dest,
|  | uintptr_t & | header,
|  | uintptr_t | header_mask,
|  | int | value
| ) |  |

Definition at line 3653 of file pugixml.cpp.

{
char buf[128];
sprintf(buf, "%d", value);
return set_value_buffer(dest, header, header_mask, buf);
}

References set_value_buffer().

## set_value_convert() [4/4]

PUGI__FN bool set_value_convert | ( | char_t *& | dest,
|  | uintptr_t & | header,
|  | uintptr_t | header_mask,
|  | unsigned int | value
| ) |  |

Definition at line 3661 of file pugixml.cpp.

{
char buf[128];
sprintf(buf, "%u", value);
return set_value_buffer(dest, header, header_mask, buf);
}

References set_value_buffer().

## sort()

template<typename I , typename Pred >

void sort | ( | I | begin,
|  | I | end,
|  | const Pred & | pred
| ) |  |

Definition at line 6153 of file pugixml.cpp.

{
// sort large chunks
while (end - begin > 32)
{
// find median element
I middle = begin + (end - begin) / 2;
median(begin, middle, end - 1, pred);
// partition in three chunks (< = >)
I eqbeg, eqend;
partition(begin, middle, end, pred, &eqbeg, &eqend);
// loop on larger half
if (eqbeg - begin > end - eqend)
{
sort(eqend, end, pred);
end = eqbeg;
}
else
{
sort(begin, eqbeg, pred);
begin = eqend;
}
}
// insertion sort small chunk
if (begin != end) insertion_sort(begin, end, pred, &*begin);
}

References insertion_sort(), median(), and partition().

Referenced by xpath_node_set_raw::remove_duplicates(), and xpath_sort().

## starts_with()

PUGI__NS_END PUGI__NS_BEGIN PUGI__FN bool starts_with | ( | const char_t * | string,
|  | const char_t * | pattern
| ) |  |

Definition at line 6534 of file pugixml.cpp.

{
while (*pattern && *string == *pattern)
{
string++;
pattern++;
}
return *pattern == 0;
}

Referenced by xpath_ast_node::eval_boolean(), namespace_uri_predicate::operator()(), and xpath_ast_node::step_push().

## strconv_cdata()

PUGI__FN char_t* strconv_cdata | ( | char_t * | s,
|  | char_t | endch
| ) |  |

Definition at line 1939 of file pugixml.cpp.

{
gap g;
while (true)
{
PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(*s, ct_parse_cdata));
if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair
{
*s++ = '\n'; // replace first one with 0x0a
if (*s == '\n') g.push(s, 1);
}
else if (s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')) // CDATA ends here
{
*g.flush(s) = 0;
return s + 1;
}
else if (*s == 0)
{
return 0;
}
else ++s;
}
}

References ct_parse_cdata, gap::flush(), PUGI__ENDSWITH, PUGI__IS_CHARTYPE, PUGI__SCANWHILE_UNROLL, and gap::push().

Referenced by xml_parser::parse_exclamation().

## strconv_comment()

PUGI__FN char_t* strconv_comment | ( | char_t * | s,
|  | char_t | endch
| ) |  |

Definition at line 1911 of file pugixml.cpp.

{
gap g;
while (true)
{
PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(*s, ct_parse_comment));
if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair
{
*s++ = '\n'; // replace first one with 0x0a
if (*s == '\n') g.push(s, 1);
}
else if (s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')) // comment ends here
{
*g.flush(s) = 0;
return s + (s[2] == '>' ? 3 : 2);
}
else if (*s == 0)
{
return 0;
}
else ++s;
}
}

References ct_parse_comment, gap::flush(), PUGI__ENDSWITH, PUGI__IS_CHARTYPE, PUGI__SCANWHILE_UNROLL, and gap::push().

Referenced by xml_parser::parse_exclamation().

## strconv_escape()

PUGI__FN char_t* strconv_escape | ( | char_t * | s,
|  | gap & | g
| ) |  |

Definition at line 1758 of file pugixml.cpp.

{
char_t* stre = s + 1;
switch (*stre)
{
case '#': // &#...
{
unsigned int ucsc = 0;
if (stre[1] == 'x') // &#x... (hex code)
{
stre += 2;
char_t ch = *stre;
if (ch == ';') return stre;
for (;;)
{
if (static_cast<unsigned int>(ch - '0') <= 9)
ucsc = 16 * ucsc + (ch - '0');
else if (static_cast<unsigned int>((ch | ' ') - 'a') <= 5)
ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10);
else if (ch == ';')
break;
else // cancel
return stre;
ch = *++stre;
}
++stre;
}
else // &#... (dec code)
{
char_t ch = *++stre;
if (ch == ';') return stre;
for (;;)
{
if (static_cast<unsigned int>(static_cast<unsigned int>(ch) - '0') <= 9)
ucsc = 10 * ucsc + (ch - '0');
else if (ch == ';')
break;
else // cancel
return stre;
ch = *++stre;
}
++stre;
}
#ifdef PUGIXML_WCHAR_MODE
s = reinterpret_cast<char_t*>(wchar_writer::any(reinterpret_cast<wchar_writer::value_type>(s), ucsc));
#else
s = reinterpret_cast<char_t*>(utf8_writer::any(reinterpret_cast<uint8_t*>(s), ucsc));
#endif
g.push(s, stre - s);
return stre;
}
case 'a': // &a
{
++stre;
if (*stre == 'm') // &am
{
if (*++stre == 'p' && *++stre == ';') // &amp;
{
*s++ = '&';
++stre;
g.push(s, stre - s);
return stre;
}
}
else if (*stre == 'p') // &ap
{
if (*++stre == 'o' && *++stre == 's' && *++stre == ';') // &apos;
{
*s++ = '\'';
++stre;
g.push(s, stre - s);
return stre;
}
}
break;
}
case 'g': // &g
{
if (*++stre == 't' && *++stre == ';') // &gt;
{
*s++ = '>';
++stre;
g.push(s, stre - s);
return stre;
}
break;
}
case 'l': // &l
{
if (*++stre == 't' && *++stre == ';') // &lt;
{
*s++ = '<';
++stre;
g.push(s, stre - s);
return stre;
}
break;
}
case 'q': // &q
{
if (*++stre == 'u' && *++stre == 'o' && *++stre == 't' && *++stre == ';') // &quot;
{
*s++ = '"';
++stre;
g.push(s, stre - s);
return stre;
}
break;
}
default:
break;
}
return stre;
}

References utf8_writer::any(), and gap::push().

Referenced by strconv_pcdata_impl< opt_trim, opt_eol, opt_escape >::parse(), strconv_attribute_impl< opt_escape >::parse_eol(), strconv_attribute_impl< opt_escape >::parse_simple(), strconv_attribute_impl< opt_escape >::parse_wconv(), and strconv_attribute_impl< opt_escape >::parse_wnorm().

## strcpy_insitu()

PUGI__FN bool strcpy_insitu | ( | char_t *& | dest,
|  | uintptr_t & | header,
|  | uintptr_t | header_mask,
|  | const char_t * | source
| ) |  |

Definition at line 1668 of file pugixml.cpp.

{
assert(header);
size_t source_length = strlength(source);
if (source_length == 0)
{
// empty string and null pointer are equivalent, so just deallocate old memory
xml_allocator* alloc = reinterpret_cast<xml_memory_page*>(header & xml_memory_page_pointer_mask)->allocator;
if (header & header_mask) alloc->deallocate_string(dest);
// mark the string as not allocated
dest = 0;
header &= ~header_mask;
return true;
}
else if (dest && strcpy_insitu_allow(source_length, header & header_mask, dest))
{
// we can reuse old buffer, so just copy the new data (including zero terminator)
memcpy(dest, source, (source_length + 1) * sizeof(char_t));
return true;
}
else
{
xml_allocator* alloc = reinterpret_cast<xml_memory_page*>(header & xml_memory_page_pointer_mask)->allocator;
// allocate new buffer
char_t* buf = alloc->allocate_string(source_length + 1);
if (!buf) return false;
// copy the string (including zero terminator)
memcpy(buf, source, (source_length + 1) * sizeof(char_t));
// deallocate old buffer (*after* the above to protect against overlapping memory and/or allocation failures)
if (header & header_mask) alloc->deallocate_string(dest);
// the string is now allocated, so set the flag
dest = buf;
header |= header_mask;
return true;
}
}

References xml_allocator::allocate_string(), xml_allocator::deallocate_string(), strcpy_insitu_allow(), strlength(), and xml_memory_page_pointer_mask.

Referenced by set_value_buffer(), and set_value_convert().

## strcpy_insitu_allow()

bool strcpy_insitu_allow | ( | size_t | length,
|  | uintptr_t | allocated,
|  | char_t * | target
| ) |  |

inline

Definition at line 1654 of file pugixml.cpp.

{
assert(target);
size_t target_length = strlength(target);
// always reuse document buffer memory if possible
if (!allocated) return target_length >= length;
// reuse heap memory if waste is not too great
const size_t reuse_threshold = 32;
return target_length >= length && (target_length < reuse_threshold || target_length - length < target_length / 2);
}

References strlength().

Referenced by strcpy_insitu().

## strequal()

PUGI__FN bool strequal | ( | const char_t * | src,
|  | const char_t * | dst
| ) |  |

Definition at line 188 of file pugixml.cpp.

{
assert(src && dst);
#ifdef PUGIXML_WCHAR_MODE
return wcscmp(src, dst) == 0;
#else
return strcmp(src, dst) == 0;
#endif
}

Referenced by xpath_string::operator!=(), xpath_string::operator==(), and xpath_ast_node::step_push().

## strequalrange()

PUGI__FN bool strequalrange | ( | const char_t * | lhs,
|  | const char_t * | rhs,
|  | size_t | count
| ) |  |

Definition at line 200 of file pugixml.cpp.

{
for (size_t i = 0; i < count; ++i)
if (lhs[i] != rhs[i])
return false;
return lhs[count] == 0;
}

Referenced by namespace_uri_predicate::operator()(), and xpath_lexer_string::operator==().

## string_value()

PUGI__FN xpath_string string_value | ( | const xpath_node & | na,
|  | xpath_allocator * | alloc
| ) |  |

Definition at line 6570 of file pugixml.cpp.

{
if (na.attribute())
return xpath_string_const(na.attribute().value());
else
{
const xml_node& n = na.node();
switch (n.type())
{
case node_pcdata:
case node_cdata:
case node_comment:
case node_pi:
return xpath_string_const(n.value());
case node_document:
case node_element:
{
xpath_string result;
xml_node cur = n.first_child();
while (cur && cur != n)
{
if (cur.type() == node_pcdata || cur.type() == node_cdata)
result.append(xpath_string_const(cur.value()), alloc);
if (cur.first_child())
cur = cur.first_child();
else if (cur.next_sibling())
cur = cur.next_sibling();
else
{
while (!cur.next_sibling() && cur != n)
cur = cur.parent();
if (cur != n) cur = cur.next_sibling();
}
}
return result;
}
default:
return xpath_string();
}
}
}

References xpath_string::append(), and xpath_string_const().

Referenced by xpath_ast_node::compare_eq(), xpath_ast_node::compare_rel(), xpath_ast_node::eval_number(), and xpath_ast_node::eval_string().

## strlength()

PUGI__NS_END PUGI__NS_BEGIN PUGI__FN size_t strlength | ( | const char_t * | s | ) |

Definition at line 176 of file pugixml.cpp.

{
assert(s);
#ifdef PUGIXML_WCHAR_MODE
return wcslen(s);
#else
return strlen(s);
#endif
}

Referenced by xpath_string::append(), xpath_string::duplicate_string(), xpath_string::length(), new_xpath_variable(), strcpy_insitu(), strcpy_insitu_allow(), translate(), and xml_buffered_writer::write().

## strlength_wide()

PUGI__FN size_t strlength_wide | ( | const wchar_t * | s | ) |

Definition at line 210 of file pugixml.cpp.

{
assert(s);
#ifdef PUGIXML_WCHAR_MODE
return wcslen(s);
#else
const wchar_t* end = s;
while (*end) end++;
return static_cast<size_t>(end - s);
#endif
}

Referenced by pugi::as_utf8(), and convert_path_heap().

## swap()

template<typename T >

void swap | ( | T & | lhs,
|  | T & | rhs
| ) |  |

Definition at line 5991 of file pugixml.cpp.

{
T temp = lhs;
lhs = rhs;
rhs = temp;
}

Referenced by xpath_ast_node::compare_eq(), FIX::FieldBase::field_metrics::getCheckSum(), median3(), partition(), and reverse().

## text_output()

PUGI__FN void text_output | ( | xml_buffered_writer & | writer,
|  | const char_t * | s,
|  | chartypex_t | type,
|  | unsigned int | flags
| ) |  |

Definition at line 3242 of file pugixml.cpp.

{
if (flags & format_no_escapes)
writer.write(s);
else
text_output_escaped(writer, s, type);
}

References text_output_escaped(), and xml_buffered_writer::write().

Referenced by node_output(), and node_output_attributes().

## text_output_cdata()

PUGI__FN void text_output_cdata | ( | xml_buffered_writer & | writer,
|  | const char_t * | s
| ) |  |

Definition at line 3250 of file pugixml.cpp.

{
do
{
writer.write('<', '!', '[', 'C', 'D');
writer.write('A', 'T', 'A', '[');
const char_t* prev = s;
// look for ]]> sequence - we can't output it as is since it terminates CDATA
while (*s && !(s[0] == ']' && s[1] == ']' && s[2] == '>')) ++s;
// skip ]] if we stopped at ]]>, > will go to the next CDATA section
if (*s) s += 2;
writer.write(prev, static_cast<size_t>(s - prev));
writer.write(']', ']', '>');
}
while (*s);
}

References xml_buffered_writer::write().

Referenced by node_output().

## text_output_escaped()

PUGI__FN void text_output_escaped | ( | xml_buffered_writer & | writer,
|  | const char_t * | s,
|  | chartypex_t | type
| ) |  |

Definition at line 3201 of file pugixml.cpp.

{
while (*s)
{
const char_t* prev = s;
// While *s is a usual symbol
while (!PUGI__IS_CHARTYPEX(*s, type)) ++s;
writer.write(prev, static_cast<size_t>(s - prev));
switch (*s)
{
case 0: break;
case '&':
writer.write('&', 'a', 'm', 'p', ';');
++s;
break;
case '<':
writer.write('&', 'l', 't', ';');
++s;
break;
case '>':
writer.write('&', 'g', 't', ';');
++s;
break;
case '"':
writer.write('&', 'q', 'u', 'o', 't', ';');
++s;
break;
default: // s is not a usual symbol
{
unsigned int ch = static_cast<unsigned int>(*s++);
assert(ch < 32);
writer.write('&', '#', static_cast<char_t>((ch / 10) + '0'), static_cast<char_t>((ch % 10) + '0'), ';');
}
}
}
}

References PUGI__IS_CHARTYPEX, and xml_buffered_writer::write().

Referenced by text_output().

## tolower_ascii()

PUGI__FN char_t tolower_ascii | ( | char_t | ch | ) |

Definition at line 6565 of file pugixml.cpp.

{
return static_cast<unsigned int>(ch - 'A') < 26 ? static_cast<char_t>(ch | ' ') : ch;
}

Referenced by xpath_ast_node::eval_boolean().

## translate()

PUGI__FN void translate | ( | char_t * | buffer,
|  | const char_t * | from,
|  | const char_t * | to
| ) |  |

Definition at line 7123 of file pugixml.cpp.

{
size_t to_length = strlength(to);
char_t* write = buffer;
while (*buffer)
{
PUGI__DMC_VOLATILE char_t ch = *buffer++;
const char_t* pos = find_char(from, ch);
if (!pos)
*write++ = ch; // do not process
else if (static_cast<size_t>(pos - from) < to_length)
*write++ = to[pos - from]; // replace
}
// zero-terminate
*write = 0;
}

References find_char(), PUGI__DMC_VOLATILE, and strlength().

Referenced by xpath_ast_node::eval_string().

## truncate_zeros()

PUGI__FN void truncate_zeros | ( | char * | begin,
|  | char * | end
| ) |  |

Definition at line 6817 of file pugixml.cpp.

{
while (begin != end && end[-1] == '0') end--;
*end = 0;
}

Referenced by convert_number_to_mantissa_exponent().

## unique()

template<typename I >

I unique | ( | I | begin,
|  | I | end
| ) |  |

Definition at line 6014 of file pugixml.cpp.

{
// fast skip head
while (end - begin > 1 && *begin != *(begin + 1)) begin++;
if (begin == end) return begin;
// last written element
I write = begin++;
// merge unique elements
while (begin != end)
{
if (*begin != *write)
*++write = *begin++;
else
begin++;
}
// past-the-end (write points to live element)
return write + 1;
}

Referenced by xpath_node_set_raw::remove_duplicates().

## xpath_first()

PUGI__FN xpath_node xpath_first | ( | const xpath_node * | begin,
|  | const xpath_node * | end,
|  | xpath_node_set::type_t | type
| ) |  |

Definition at line 7318 of file pugixml.cpp.

{
if (begin == end) return xpath_node();
switch (type)
{
case xpath_node_set::type_sorted:
return *begin;
case xpath_node_set::type_sorted_reverse:
return *(end - 1);
case xpath_node_set::type_unsorted:
return *min_element(begin, end, document_order_comparator());
default:
assert(!"Invalid node set type");
return xpath_node();
}
}

References min_element().

Referenced by xpath_node_set_raw::first().

## xpath_sort()

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
| ) |  |

Definition at line 7302 of file pugixml.cpp.

{
xpath_node_set::type_t order = rev ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted;
if (type == xpath_node_set::type_unsorted)
{
sort(begin, end, document_order_comparator());
type = xpath_node_set::type_sorted;
}
if (type != order) reverse(begin, end);
return order;
}

References reverse(), and sort().

Referenced by xpath_node_set_raw::sort_do().

## xpath_string_const()

PUGI__FN xpath_string xpath_string_const | ( | const char_t * | str | ) |

Definition at line 6527 of file pugixml.cpp.

{
return xpath_string(str, false);
}

Referenced by convert_number_to_string(), xpath_ast_node::eval_string(), and string_value().

## zero_terminate_buffer()

PUGI__FN size_t zero_terminate_buffer | ( | void * | buffer,
|  | size_t | size,
|  | xml_encoding | encoding
| ) |  |

Definition at line 3740 of file pugixml.cpp.

{
// We only need to zero-terminate if encoding conversion does not do it for us
#ifdef PUGIXML_WCHAR_MODE
xml_encoding wchar_encoding = get_wchar_encoding();
if (encoding == wchar_encoding || need_endian_swap_utf(encoding, wchar_encoding))
{
size_t length = size / sizeof(char_t);
static_cast<char_t*>(buffer)[length] = 0;
return (length + 1) * sizeof(char_t);
}
#else
if (encoding == encoding_utf8)
{
static_cast<char*>(buffer)[size] = 0;
return size + 1;
}
#endif
return size;
}

References get_wchar_encoding().

Referenced by load_file_impl(), and load_stream_impl().

## Variable Documentation

## chartype_table

const unsigned char chartype_table[256]

static

Initial value:
=
{
55, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 63, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8, 0, 6, 0, 0, 0, 7, 6, 0, 0, 0, 0, 0, 96, 64, 0,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192, 0, 1, 0, 48, 0,
0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 16, 0, 192,
0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 0,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192
}

Definition at line 1137 of file pugixml.cpp.

## chartypex_table

const unsigned char chartypex_table[256]

static

Initial value:
=
{
3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 3, 3, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 16, 16, 0,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 3, 0,
0, 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, 0, 0, 0, 0, 20,
0, 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, 0, 0, 0, 0, 0,
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, 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, 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, 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,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
}

Definition at line 1167 of file pugixml.cpp.

## dummy_node_set

const xpath_node_set dummy_node_set

static

Definition at line 7186 of file pugixml.cpp.

## xml_memory_page_alignment

const uintptr_t xml_memory_page_alignment = 32

static

Definition at line 269 of file pugixml.cpp.

Referenced by xml_allocator::allocate_page().

## xml_memory_page_name_allocated_mask

const uintptr_t xml_memory_page_name_allocated_mask = 16

static

Definition at line 271 of file pugixml.cpp.

Referenced by destroy_attribute(), destroy_node(), and document_order().

## xml_memory_page_pointer_mask

const uintptr_t xml_memory_page_pointer_mask = ~(xml_memory_page_alignment - 1)

static

Definition at line 270 of file pugixml.cpp.

Referenced by destroy_attribute(), destroy_node(), get_allocator(), and strcpy_insitu().

## xml_memory_page_size

PUGI__NS_END static const PUGI__NS_BEGIN size_t xml_memory_page_size

static

Initial value:
=
32768

Definition at line 261 of file pugixml.cpp.

Referenced by xml_allocator::allocate_memory(), and xml_allocator::allocate_memory_oob().

## xml_memory_page_type_mask

const uintptr_t xml_memory_page_type_mask = 7

static

Definition at line 273 of file pugixml.cpp.

Referenced by xml_parser::has_element_node_siblings(), is_text_node(), and xml_parser::parse_tree().

## xml_memory_page_value_allocated_mask

const uintptr_t xml_memory_page_value_allocated_mask = 8

static

Definition at line 272 of file pugixml.cpp.

Referenced by destroy_attribute(), destroy_node(), and document_order().

xpath_context
Definition: pugixml.cpp:7454
strlength
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN size_t strlength(const char_t *s)
Definition: pugixml.cpp:176
check_string_to_number_format
PUGI__FN bool check_string_to_number_format(const char_t *string)
Definition: pugixml.cpp:6938
namespace_uri
const PUGI__FN char_t * namespace_uri(const xml_node &node)
Definition: pugixml.cpp:7053
axis_descendant
@ axis_descendant
Definition: pugixml.cpp:7887
PUGI__IS_CHARTYPE
#define PUGI__IS_CHARTYPE(c, ct)
Definition: pugixml.cpp:1195
utf_decoder::decode_wchar_block
static Traits::value_type decode_wchar_block(const wchar_t *data, size_t size, typename Traits::value_type result)
Definition: pugixml.cpp:1105
axis_ancestor_or_self
@ axis_ancestor_or_self
Definition: pugixml.cpp:7884
ast_func_translate
@ ast_func_translate
Definition: pugixml.cpp:7865
convert_path_heap
PUGI__FN char * convert_path_heap(const wchar_t *str)
Definition: pugixml.cpp:3959
ast_func_last
@ ast_func_last
Definition: pugixml.cpp:7842
find_char
const PUGI__FN char_t * find_char(const char_t *s, char_t c)
Definition: pugixml.cpp:6545
uint16_t
unsigned short uint16_t
Definition: stdint_msvc.h:80
lex_less
@ lex_less
Definition: pugixml.cpp:7469
PUGI__IS_CHARTYPEX
#define PUGI__IS_CHARTYPEX(c, ct)
Definition: pugixml.cpp:1196
ast_func_starts_with
@ ast_func_starts_with
Definition: pugixml.cpp:7855
ct_space
@ ct_space
Definition: pugixml.cpp:1130
xpath_variable_string
Definition: pugixml.cpp:7165
ast_number_constant
@ ast_number_constant
Definition: pugixml.cpp:7840
destroy_attribute
void destroy_attribute(xml_attribute_struct *a, xml_allocator &alloc)
Definition: pugixml.cpp:574
ast_op_add
@ ast_op_add
Definition: pugixml.cpp:7829
xml_buffered_writer::write
void write(const char_t *data, size_t length)
Definition: pugixml.cpp:3062
ast_op_divide
@ ast_op_divide
Definition: pugixml.cpp:7832
xml_stream_chunk
Definition: pugixml.cpp:3805
lex_axis_attribute
@ lex_axis_attribute
Definition: pugixml.cpp:7488
ast_op_equal
@ ast_op_equal
Definition: pugixml.cpp:7823
ast_func_name_0
@ ast_func_name_0
Definition: pugixml.cpp:7850
zero_terminate_buffer
PUGI__FN size_t zero_terminate_buffer(void *buffer, size_t size, xml_encoding encoding)
Definition: pugixml.cpp:3740
text_output_escaped
PUGI__FN void text_output_escaped(xml_buffered_writer &writer, const char_t *s, chartypex_t type)
Definition: pugixml.cpp:3201
partition
void partition(I begin, I middle, I end, const Pred &pred, I *out_eqbeg, I *out_eqend)
Definition: pugixml.cpp:6074
utf8_writer::any
static value_type any(value_type result, uint32_t ch)
Definition: pugixml.cpp:822
load_stream_data_seek
PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
Definition: pugixml.cpp:3891
lex_quoted_string
@ lex_quoted_string
Definition: pugixml.cpp:7480
destroy_node
void destroy_node(xml_node_struct *n, xml_allocator &alloc)
Definition: pugixml.cpp:584
as_utf8_begin
PUGI__FN size_t as_utf8_begin(const wchar_t *str, size_t length)
Definition: pugixml.cpp:1594
xml_memory_page_type_mask
static const uintptr_t xml_memory_page_type_mask
Definition: pugixml.cpp:273
lex_close_brace
@ lex_close_brace
Definition: pugixml.cpp:7479
lex_double_dot
@ lex_double_dot
Definition: pugixml.cpp:7490
ast_func_local_name_1
@ ast_func_local_name_1
Definition: pugixml.cpp:7847
ast_func_id
@ ast_func_id
Definition: pugixml.cpp:7845
lex_dot
@ lex_dot
Definition: pugixml.cpp:7489
ast_filter_posinv
@ ast_filter_posinv
Definition: pugixml.cpp:7838
ast_op_less
@ ast_op_less
Definition: pugixml.cpp:7825
ast_op_union
@ ast_op_union
Definition: pugixml.cpp:7835
lex_comma
@ lex_comma
Definition: pugixml.cpp:7487
ast_op_not_equal
@ ast_op_not_equal
Definition: pugixml.cpp:7824
copy_backwards
void copy_backwards(I begin, I end, I target)
Definition: pugixml.cpp:6037
ast_func_substring_after
@ ast_func_substring_after
Definition: pugixml.cpp:7858
qualified_name
const PUGI__FN char_t * qualified_name(const xpath_node &node)
Definition: pugixml.cpp:7017
lex_union
@ lex_union
Definition: pugixml.cpp:7476
swap
void swap(T &lhs, T &rhs)
Definition: pugixml.cpp:5991
convert_buffer_latin1
PUGI__FN bool convert_buffer_latin1(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, bool is_mutable)
Definition: pugixml.cpp:1524
lex_plus
@ lex_plus
Definition: pugixml.cpp:7473
ctx_start_symbol
@ ctx_start_symbol
Definition: pugixml.cpp:1162
ast_func_namespace_uri_1
@ ast_func_namespace_uri_1
Definition: pugixml.cpp:7849
make_parse_result
xml_parse_result make_parse_result(xml_parse_status status, ptrdiff_t offset=0)
Definition: pugixml.cpp:2215
xpath_variable_boolean
Definition: pugixml.cpp:7145
ast_func_position
@ ast_func_position
Definition: pugixml.cpp:7843
xml_allocator
Definition: pugixml.cpp:314
xpath_variable_number
Definition: pugixml.cpp:7155
convert_number_to_mantissa_exponent
PUGI__FN void convert_number_to_mantissa_exponent(double value, char *buffer, size_t buffer_size, char **out_mantissa, int *out_exponent)
Definition: pugixml.cpp:6840
axis_ancestor
@ axis_ancestor
Definition: pugixml.cpp:7883
convert_string_to_number
PUGI__FN double convert_string_to_number(const char_t *string)
Definition: pugixml.cpp:6968
xml_allocator::deallocate_memory
void deallocate_memory(void *ptr, size_t size, xml_memory_page *page)
Definition: pugixml.cpp:361
namespace_uri_predicate::prefix
const char_t * prefix
Definition: pugixml.cpp:7032
axis_preceding
@ axis_preceding
Definition: pugixml.cpp:7893
xpath_ast_node::eval_string
xpath_string eval_string(const xpath_context &c, const xpath_stack &stack)
Definition: pugixml.cpp:8876
ast_op_negate
@ ast_op_negate
Definition: pugixml.cpp:7834
lex_none
@ lex_none
Definition: pugixml.cpp:7466
nodetest_none
@ nodetest_none
Definition: pugixml.cpp:7900
lex_equal
@ lex_equal
Definition: pugixml.cpp:7467
strcpy_insitu
PUGI__FN bool strcpy_insitu(char_t *&dest, uintptr_t &header, uintptr_t header_mask, const char_t *source)
Definition: pugixml.cpp:1668
ast_func_local_name_0
@ ast_func_local_name_0
Definition: pugixml.cpp:7846
utf_decoder::decode_utf16_block
static Traits::value_type decode_utf16_block(const uint16_t *data, size_t size, typename Traits::value_type result)
Definition: pugixml.cpp:1016
convert_number_to_string_special
const PUGI__FN char_t * convert_number_to_string_special(double value)
Definition: pugixml.cpp:6780
ast_func_string_1
@ ast_func_string_1
Definition: pugixml.cpp:7853
set_value_buffer
PUGI__FN bool set_value_buffer(char_t *&dest, uintptr_t &header, uintptr_t header_mask, char(&buf)[128])
Definition: pugixml.cpp:3641
axis_namespace
@ axis_namespace
Definition: pugixml.cpp:7891
xml_memory_page_pointer_mask
static const uintptr_t xml_memory_page_pointer_mask
Definition: pugixml.cpp:270
nodetest_all
@ nodetest_all
Definition: pugixml.cpp:7907
lex_not_equal
@ lex_not_equal
Definition: pugixml.cpp:7468
ast_func_number_1
@ ast_func_number_1
Definition: pugixml.cpp:7872
nodetest_type_comment
@ nodetest_type_comment
Definition: pugixml.cpp:7903
ast_func_boolean
@ ast_func_boolean
Definition: pugixml.cpp:7866
xpath_string::append
void append(const xpath_string &o, xpath_allocator *alloc)
Definition: pugixml.cpp:6450
lex_eof
@ lex_eof
Definition: pugixml.cpp:7492
ast_func_concat
@ ast_func_concat
Definition: pugixml.cpp:7854
ct_symbol
@ ct_symbol
Definition: pugixml.cpp:1133
median3
void median3(I first, I middle, I last, const Pred &pred)
Definition: pugixml.cpp:6127
axis_following_sibling
@ axis_following_sibling
Definition: pugixml.cpp:7890
lex_number
@ lex_number
Definition: pugixml.cpp:7481
ast_func_number_0
@ ast_func_number_0
Definition: pugixml.cpp:7871
nodetest_type_node
@ nodetest_type_node
Definition: pugixml.cpp:7902
lex_double_colon
@ lex_double_colon
Definition: pugixml.cpp:7491
lex_open_brace
@ lex_open_brace
Definition: pugixml.cpp:7478
get_mutable_buffer
PUGI__FN bool get_mutable_buffer(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, bool is_mutable)
Definition: pugixml.cpp:1264
xml_memory_page
Definition: pugixml.cpp:277
ast_func_substring_3
@ ast_func_substring_3
Definition: pugixml.cpp:7860
PUGI__DMC_VOLATILE
#define PUGI__DMC_VOLATILE
Definition: pugixml.cpp:101
ast_op_greater
@ ast_op_greater
Definition: pugixml.cpp:7826
is_little_endian
PUGI__FN bool is_little_endian()
Definition: pugixml.cpp:1198
utf_decoder::decode_latin1_block
static Traits::value_type decode_latin1_block(const uint8_t *data, size_t size, typename Traits::value_type result)
Definition: pugixml.cpp:1085
ast_step
@ ast_step
Definition: pugixml.cpp:7877
ctx_symbol
@ ctx_symbol
Definition: pugixml.cpp:1164
ast_func_contains
@ ast_func_contains
Definition: pugixml.cpp:7856
opt_false
Definition: pugixml.cpp:739
lex_close_square_brace
@ lex_close_square_brace
Definition: pugixml.cpp:7485
nodetest_name
@ nodetest_name
Definition: pugixml.cpp:7901
ast_op_greater_or_equal
@ ast_op_greater_or_equal
Definition: pugixml.cpp:7828
ast_variable
@ ast_variable
Definition: pugixml.cpp:7841
sort
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:6153
gen_nan
PUGI__FN double gen_nan()
Definition: pugixml.cpp:6754
convert_buffer
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)
Definition: pugixml.cpp:1561
ast_filter
@ ast_filter
Definition: pugixml.cpp:7837
xml_memory_management_function_storage::deallocate
static deallocation_function deallocate
Definition: pugixml.cpp:164
convert_buffer_utf16
PUGI__FN bool convert_buffer_utf16(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, opt_swap)
Definition: pugixml.cpp:1465
xpath_query_impl::root
xpath_ast_node * root
Definition: pugixml.cpp:10118
as_utf8_end
PUGI__FN void as_utf8_end(char *buffer, size_t size, const wchar_t *str, size_t length)
Definition: pugixml.cpp:1600
ast_op_multiply
@ ast_op_multiply
Definition: pugixml.cpp:7831
axis_following
@ axis_following
Definition: pugixml.cpp:7889
ast_func_lang
@ ast_func_lang
Definition: pugixml.cpp:7870
nodetest_type_text
@ nodetest_type_text
Definition: pugixml.cpp:7905
ast_func_true
@ ast_func_true
Definition: pugixml.cpp:7868
PUGI__STATIC_ASSERT
#define PUGI__STATIC_ASSERT(cond)
Definition: pugixml.cpp:95
get_integer_base
PUGI__FN int get_integer_base(const char_t *value)
Definition: pugixml.cpp:3524
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint_msvc.h:120
delete_xpath_variable
PUGI__FN void delete_xpath_variable(T *var)
Definition: pugixml.cpp:7244
xml_memory_management_function_storage::allocate
static allocation_function allocate
Definition: pugixml.cpp:163
node_output_attributes
PUGI__FN void node_output_attributes(xml_buffered_writer &writer, const xml_node &node, unsigned int flags)
Definition: pugixml.cpp:3272
nodetest_type_pi
@ nodetest_type_pi
Definition: pugixml.cpp:7904
ctx_special_attr
@ ctx_special_attr
Definition: pugixml.cpp:1161
ast_op_less_or_equal
@ ast_op_less_or_equal
Definition: pugixml.cpp:7827
ct_parse_cdata
@ ct_parse_cdata
Definition: pugixml.cpp:1131
document_order_comparator
Definition: pugixml.cpp:6690
strconv_pcdata_impl
Definition: pugixml.cpp:1969
namespace_uri_predicate
Definition: pugixml.cpp:7030
ct_parse_attr_ws
@ ct_parse_attr_ws
Definition: pugixml.cpp:1129
ast_func_substring_2
@ ast_func_substring_2
Definition: pugixml.cpp:7859
lex_greater_or_equal
@ lex_greater_or_equal
Definition: pugixml.cpp:7472
xml_stream_chunk::data
T data[xml_memory_page_size/sizeof(T)]
Definition: pugixml.cpp:3834
append_node
void append_node(xml_node_struct *child, xml_node_struct *node)
Definition: pugixml.cpp:612
ast_func_substring_before
@ ast_func_substring_before
Definition: pugixml.cpp:7857
ast_func_normalize_space_0
@ ast_func_normalize_space_0
Definition: pugixml.cpp:7863
axis_preceding_sibling
@ axis_preceding_sibling
Definition: pugixml.cpp:7894
allocate_attribute
PUGI__NS_END PUGI__NS_BEGIN xml_attribute_struct * allocate_attribute(xml_allocator &alloc)
Definition: pugixml.cpp:558
allocate_node
xml_node_struct * allocate_node(xml_allocator &alloc, xml_node_type type)
Definition: pugixml.cpp:566
get_file_size
PUGI__FN xml_parse_status get_file_size(FILE *file, size_t &out_result)
Definition: pugixml.cpp:3701
uint8_t
unsigned char uint8_t
Definition: stdint_msvc.h:79
xml_allocator::deallocate_string
void deallocate_string(char_t *string)
Definition: pugixml.cpp:424
axis_parent
@ axis_parent
Definition: pugixml.cpp:7892
ast_func_normalize_space_1
@ ast_func_normalize_space_1
Definition: pugixml.cpp:7864
recursive_copy_skip
PUGI__FN void recursive_copy_skip(xml_node &dest, const xml_node &source, const xml_node &skip)
Definition: pugixml.cpp:3463
lex_multiply
@ lex_multiply
Definition: pugixml.cpp:7475
xml_memory_page_value_allocated_mask
static const uintptr_t xml_memory_page_value_allocated_mask
Definition: pugixml.cpp:272
ast_func_not
@ ast_func_not
Definition: pugixml.cpp:7867
xml_allocator::allocate_string
char_t * allocate_string(size_t length)
Definition: pugixml.cpp:396
xml_allocator::allocate_memory
void * allocate_memory(size_t size, xml_memory_page *&out_page)
Definition: pugixml.cpp:348
reverse
void reverse(I begin, I end)
Definition: pugixml.cpp:6009
nodetest_pi
@ nodetest_pi
Definition: pugixml.cpp:7906
ast_func_count
@ ast_func_count
Definition: pugixml.cpp:7844
buffer_holder
Definition: pugixml.cpp:236
lex_string
@ lex_string
Definition: pugixml.cpp:7486
get_buffer_encoding
PUGI__FN xml_encoding get_buffer_encoding(xml_encoding encoding, const void *contents, size_t size)
Definition: pugixml.cpp:1239
truncate_zeros
PUGI__FN void truncate_zeros(char *begin, char *end)
Definition: pugixml.cpp:6817
ct_parse_comment
@ ct_parse_comment
Definition: pugixml.cpp:1132
ast_func_floor
@ ast_func_floor
Definition: pugixml.cpp:7874
utf_decoder::decode_utf32_block
static Traits::value_type decode_utf32_block(const uint32_t *data, size_t size, typename Traits::value_type result)
Definition: pugixml.cpp:1060
ct_parse_attr
@ ct_parse_attr
Definition: pugixml.cpp:1128
lex_minus
@ lex_minus
Definition: pugixml.cpp:7474
ast_func_namespace_uri_0
@ ast_func_namespace_uri_0
Definition: pugixml.cpp:7848
PUGI__ENDSWITH
#define PUGI__ENDSWITH(c, e)
Definition: pugixml.cpp:1899
lex_open_square_brace
@ lex_open_square_brace
Definition: pugixml.cpp:7484
convert_buffer_utf32
PUGI__FN bool convert_buffer_utf32(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, opt_swap)
Definition: pugixml.cpp:1490
xpath_stack_data::stack
xpath_stack stack
Definition: pugixml.cpp:6373
xpath_string_const
PUGI__FN xpath_string xpath_string_const(const char_t *str)
Definition: pugixml.cpp:6527
ast_func_false
@ ast_func_false
Definition: pugixml.cpp:7869
opt_true
Definition: pugixml.cpp:744
nodetest_all_in_namespace
@ nodetest_all_in_namespace
Definition: pugixml.cpp:7908
xpath_allocator::allocate
void * allocate(size_t size)
Definition: pugixml.cpp:6250
ast_func_name_1
@ ast_func_name_1
Definition: pugixml.cpp:7851
xml_stream_chunk::size
size_t size
Definition: pugixml.cpp:3832
median
void median(I first, I middle, I last, const Pred &pred)
Definition: pugixml.cpp:6134
guess_buffer_encoding
PUGI__FN xml_encoding guess_buffer_encoding(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
Definition: pugixml.cpp:1215
ast_func_string_0
@ ast_func_string_0
Definition: pugixml.cpp:7852
text_output
PUGI__FN void text_output(xml_buffered_writer &writer, const char_t *s, chartypex_t type, unsigned int flags)
Definition: pugixml.cpp:3242
ast_func_string_length_0
@ ast_func_string_length_0
Definition: pugixml.cpp:7861
strlength_wide
PUGI__FN size_t strlength_wide(const wchar_t *s)
Definition: pugixml.cpp:210
ast_func_ceiling
@ ast_func_ceiling
Definition: pugixml.cpp:7875
get_latin1_7bit_prefix_length
PUGI__FN size_t get_latin1_7bit_prefix_length(const uint8_t *data, size_t size)
Definition: pugixml.cpp:1515
gap::push
void push(char_t *&s, size_t count)
Definition: pugixml.cpp:1727
ast_func_round
@ ast_func_round
Definition: pugixml.cpp:7876
get_wchar_encoding
PUGI__FN xml_encoding get_wchar_encoding()
Definition: pugixml.cpp:1205
text_output_cdata
PUGI__FN void text_output_cdata(xml_buffered_writer &writer, const char_t *s)
Definition: pugixml.cpp:3250
xpath_variable_node_set
Definition: pugixml.cpp:7180
axis_attribute
@ axis_attribute
Definition: pugixml.cpp:7885
ast_step_root
@ ast_step_root
Definition: pugixml.cpp:7878
lex_var_ref
@ lex_var_ref
Definition: pugixml.cpp:7477
load_stream_data_noseek
PUGI__FN xml_parse_status load_stream_data_noseek(std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
Definition: pugixml.cpp:3837
lex_greater
@ lex_greater
Definition: pugixml.cpp:7470
convert_utf_endian_swap
PUGI__FN void convert_utf_endian_swap(T *result, const T *data, size_t length)
Definition: pugixml.cpp:1111
ast_op_and
@ ast_op_and
Definition: pugixml.cpp:7822
gap::flush
char_t * flush(char_t *s)
Definition: pugixml.cpp:1744
ast_func_sum
@ ast_func_sum
Definition: pugixml.cpp:7873
node_output
PUGI__FN void node_output(xml_buffered_writer &writer, const xml_node &node, const char_t *indent, unsigned int flags, unsigned int depth)
Definition: pugixml.cpp:3288
lex_slash
@ lex_slash
Definition: pugixml.cpp:7482
axis_descendant_or_self
@ axis_descendant_or_self
Definition: pugixml.cpp:7888
uint32_t
unsigned int uint32_t
Definition: stdint_msvc.h:81
lex_less_or_equal
@ lex_less_or_equal
Definition: pugixml.cpp:7471
ast_string_constant
@ ast_string_constant
Definition: pugixml.cpp:7839
ast_unknown
@ ast_unknown
Definition: pugixml.cpp:7820
ast_op_subtract
@ ast_op_subtract
Definition: pugixml.cpp:7830
ast_op_mod
@ ast_op_mod
Definition: pugixml.cpp:7833
ct_start_symbol
@ ct_start_symbol
Definition: pugixml.cpp:1134
xpath_string
Definition: pugixml.cpp:6402
xml_stream_chunk::create
static xml_stream_chunk * create()
Definition: pugixml.cpp:3807
min_element
I min_element(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:5998
utf_decoder::decode_utf8_block
static Traits::value_type decode_utf8_block(const uint8_t *data, size_t size, typename Traits::value_type result)
Definition: pugixml.cpp:954
ast_func_string_length_1
@ ast_func_string_length_1
Definition: pugixml.cpp:7862
xml_memory_page_name_allocated_mask
static const uintptr_t xml_memory_page_name_allocated_mask
Definition: pugixml.cpp:271
strcpy_insitu_allow
bool strcpy_insitu_allow(size_t length, uintptr_t allocated, char_t *target)
Definition: pugixml.cpp:1654
allow_insert_child
bool allow_insert_child(xml_node_type parent, xml_node_type child)
Definition: pugixml.cpp:3430
ct_parse_pcdata
@ ct_parse_pcdata
Definition: pugixml.cpp:1127
ctx_digit
@ ctx_digit
Definition: pugixml.cpp:1163
PUGI__SCANWHILE_UNROLL
#define PUGI__SCANWHILE_UNROLL(X)
Definition: pugixml.cpp:1906
ast_op_or
@ ast_op_or
Definition: pugixml.cpp:7821
lex_double_slash
@ lex_double_slash
Definition: pugixml.cpp:7483
insertion_sort
void insertion_sort(I begin, I end, const Pred &pred, T *)
Definition: pugixml.cpp:6042
axis_self
@ axis_self
Definition: pugixml.cpp:7895
is_nan
PUGI__FN bool is_nan(double value)
Definition: pugixml.cpp:6767
xml_document_struct::buffer
const char_t * buffer
Definition: pugixml.cpp:543
xml_stream_chunk::next
xml_stream_chunk * next
Definition: pugixml.cpp:3831
ctx_special_pcdata
@ ctx_special_pcdata
Definition: pugixml.cpp:1160
strconv_attribute_impl
Definition: pugixml.cpp:2040
ast_predicate
@ ast_predicate
Definition: pugixml.cpp:7836
endian_swap
PUGI__NS_END PUGI__NS_BEGIN uint16_t endian_swap(uint16_t value)
Definition: pugixml.cpp:752
axis_child
@ axis_child
Definition: pugixml.cpp:7886
gap
Definition: pugixml.cpp:1716