Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
pugixml.cc File Reference
#include "pugixml.hpp"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include <istream>
#include <ostream>
#include <string>
#include <new>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  xml_memory_management_function_storage< T >
struct  auto_deleter< T >
struct  xml_memory_page
struct  xml_memory_string_header
struct  xml_allocator
struct  pugi::xml_attribute_struct
struct  pugi::xml_node_struct
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  utf8_decoder
struct  utf16_decoder< opt_swap >
struct  utf32_decoder< opt_swap >
struct  latin1_decoder
struct  wchar_selector< 2 >
struct  wchar_selector< 4 >
struct  wchar_decoder
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  name_null_sentry
struct  equal_to
struct  not_equal_to
struct  less
struct  less_equal
struct  xpath_memory_block
struct  xpath_allocator
struct  xpath_allocator_capture
struct  xpath_stack
struct  xpath_stack_data
class  xpath_string
struct  document_order_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

namespace  pugi

Macros

#define SOURCE_PUGIXML_CPP
#define PUGI__NO_INLINE
#define PUGI__UNLIKELY(cond)
#define PUGI__STATIC_ASSERT(cond)
#define PUGI__DMC_VOLATILE
#define PUGI__UNSIGNED_OVERFLOW
#define PUGI__SNPRINTF   sprintf
#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__GETHEADER_IMPL(object, page, flags)
#define PUGI__GETPAGE_IMPL(header)
#define PUGI__GETPAGE(n)
#define PUGI__NODETYPE(n)
#define PUGI__IS_CHARTYPE_IMPL(c, ct, table)
#define PUGI__IS_CHARTYPE(c, ct)
#define PUGI__IS_CHARTYPEX(c, ct)
#define PUGI__SCANCHAR(ch)
#define PUGI__SCANCHARTYPE(ct)
#define PUGI__ENDSWITH(c, e)
#define PUGI__SKIPWS()
#define PUGI__OPTSET(OPT)
#define PUGI__PUSHNODE(TYPE)
#define PUGI__POPNODE()
#define PUGI__SCANFOR(X)
#define PUGI__SCANWHILE(X)
#define PUGI__SCANWHILE_UNROLL(X)
#define PUGI__ENDSEG()
#define PUGI__THROW_ERROR(err, m)
#define PUGI__CHECK_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  indent_flags_t { indent_newline = 1 , indent_indent = 2 }
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_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 , ast_opt_translate_table , ast_opt_compare_attribute
}
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
}
enum  predicate_t { predicate_default , predicate_posinv , predicate_constant , predicate_constant_one }
enum  nodeset_eval_t { nodeset_eval_all , nodeset_eval_any , nodeset_eval_first }

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)
template<typename Object>
xml_allocatorget_allocator (const Object *object)
template<typename Object>
xml_document_structget_document (const Object *object)
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)
void append_attribute (xml_attribute_struct *attr, xml_node_struct *node)
void prepend_attribute (xml_attribute_struct *attr, xml_node_struct *node)
void insert_attribute_after (xml_attribute_struct *attr, xml_attribute_struct *place, xml_node_struct *node)
void insert_attribute_before (xml_attribute_struct *attr, xml_attribute_struct *place, xml_node_struct *node)
void remove_attribute (xml_attribute_struct *attr, 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)
PUGI__FN bool is_little_endian ()
PUGI__FN xml_encoding get_wchar_encoding ()
PUGI__FN bool parse_declaration_encoding (const uint8_t *data, size_t size, const uint8_t *&out_encoding, size_t &out_length)
PUGI__FN xml_encoding guess_buffer_encoding (const uint8_t *data, size_t size)
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 D>
PUGI__FN bool convert_buffer_generic (char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, D)
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)
template<typename Header>
bool strcpy_insitu_allow (size_t length, const Header &header, uintptr_t header_mask, char_t *target)
template<typename String, typename Header>
PUGI__FN bool strcpy_insitu (String &dest, Header &header, uintptr_t header_mask, const char_t *source, size_t source_length)
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)
template<typename D, typename T>
PUGI__FN size_t convert_buffer_output_generic (typename T::value_type dest, const char_t *data, size_t length, D, T)
template<typename D, typename T>
PUGI__FN size_t convert_buffer_output_generic (typename T::value_type dest, const char_t *data, size_t length, D, T, bool opt_swap)
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, unsigned int flags)
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 text_output_indent (xml_buffered_writer &writer, const char_t *indent, size_t indent_length, unsigned int depth)
PUGI__FN void node_output_comment (xml_buffered_writer &writer, const char_t *s)
PUGI__FN void node_output_pi_value (xml_buffered_writer &writer, const char_t *s)
PUGI__FN void node_output_attributes (xml_buffered_writer &writer, xml_node_struct *node, const char_t *indent, size_t indent_length, unsigned int flags, unsigned int depth)
PUGI__FN bool node_output_start (xml_buffered_writer &writer, xml_node_struct *node, const char_t *indent, size_t indent_length, unsigned int flags, unsigned int depth)
PUGI__FN void node_output_end (xml_buffered_writer &writer, xml_node_struct *node)
PUGI__FN void node_output_simple (xml_buffered_writer &writer, xml_node_struct *node, unsigned int flags)
PUGI__FN void node_output (xml_buffered_writer &writer, xml_node_struct *root, const char_t *indent, unsigned int flags, unsigned int depth)
PUGI__FN bool has_declaration (xml_node_struct *node)
PUGI__FN bool is_attribute_of (xml_attribute_struct *attr, xml_node_struct *node)
PUGI__FN bool allow_insert_attribute (xml_node_type parent)
PUGI__FN bool allow_insert_child (xml_node_type parent, xml_node_type child)
PUGI__FN bool allow_move (xml_node parent, xml_node child)
template<typename String, typename Header>
PUGI__FN void node_copy_string (String &dest, Header &header, uintptr_t header_mask, char_t *source, Header &source_header, xml_allocator *alloc)
PUGI__FN void node_copy_contents (xml_node_struct *dn, xml_node_struct *sn, xml_allocator *shared_alloc)
PUGI__FN void node_copy_tree (xml_node_struct *dn, xml_node_struct *sn)
PUGI__FN void node_copy_attribute (xml_attribute_struct *da, xml_attribute_struct *sa)
bool is_text_node (xml_node_struct *node)
template<typename U>
PUGI__FN PUGI__UNSIGNED_OVERFLOWstring_to_integer (const char_t *value, U minv, U maxv)
PUGI__FN int get_value_int (const char_t *value)
PUGI__FN unsigned int get_value_uint (const char_t *value)
PUGI__FN double get_value_double (const char_t *value)
PUGI__FN float get_value_float (const char_t *value)
PUGI__FN bool get_value_bool (const char_t *value)
template<typename U>
PUGI__FN PUGI__UNSIGNED_OVERFLOW char_t * integer_to_string (char_t *begin, char_t *end, U value, bool negative)
template<typename String, typename Header>
PUGI__FN bool set_value_ascii (String &dest, Header &header, uintptr_t header_mask, char *buf)
template<typename U, typename String, typename Header>
PUGI__FN bool set_value_integer (String &dest, Header &header, uintptr_t header_mask, U value, bool negative)
template<typename String, typename Header>
PUGI__FN bool set_value_convert (String &dest, Header &header, uintptr_t header_mask, float value, int precision)
template<typename String, typename Header>
PUGI__FN bool set_value_convert (String &dest, Header &header, uintptr_t header_mask, double value, int precision)
template<typename String, typename Header>
PUGI__FN bool set_value_bool (String &dest, Header &header, uintptr_t header_mask, bool value)
PUGI__FN xml_parse_result load_buffer_impl (xml_document_struct *doc, xml_node_struct *root, void *contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t **out_buffer)
PUGI__FN 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_struct *doc, FILE *file, unsigned int options, xml_encoding encoding, char_t **out_buffer)
PUGI__FN void close_file (FILE *file)
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_struct *doc, std::basic_istream< T > &stream, unsigned int options, xml_encoding encoding, char_t **out_buffer)
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 FILE * open_file (const char *path, const char *mode)
PUGI__FN bool save_file_impl (const xml_document &doc, FILE *file, const char_t *indent, unsigned int flags, xml_encoding encoding)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > 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)
std::basic_string< wchar_t, std::char_traits< wchar_t >, std::allocator< 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)
void PUGIXML_FUNCTION pugi::set_memory_management_functions (allocation_function allocate, deallocation_function deallocate)
allocation_function PUGIXML_FUNCTION pugi::get_memory_allocation_function ()
deallocation_function PUGIXML_FUNCTION pugi::get_memory_deallocation_function ()
template<typename T>
void swap (T &lhs, T &rhs)
template<typename I, typename Pred>
PUGI__FNmin_element (I begin, I end, const Pred &pred)
template<typename I>
PUGI__FN void reverse (I begin, I end)
template<typename I>
PUGI__FNunique (I begin, I end)
template<typename T, typename Pred>
PUGI__FN void insertion_sort (T *begin, T *end, const Pred &pred)
template<typename I, typename Pred>
median3 (I first, I middle, I last, const Pred &pred)
template<typename T, typename Pred>
PUGI__FN void partition3 (T *begin, T *end, T pivot, const Pred &pred, T **out_eqbeg, T **out_eqend)
template<typename I, typename Pred>
PUGI__FN void sort (I begin, I end, const Pred &pred)
PUGI__FN bool hash_insert (const void **table, size_t size, const void *key)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN bool starts_with (const char_t *string, const char_t *pattern)
PUGI__FN const char_t * find_char (const char_t *s, char_t c)
PUGI__FN const 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 bool node_is_before_sibling (xml_node_struct *ln, xml_node_struct *rn)
PUGI__FN bool node_is_before (xml_node_struct *ln, xml_node_struct *rn)
PUGI__FN bool node_is_ancestor (xml_node_struct *parent, xml_node_struct *node)
PUGI__FN const void * document_buffer_order (const xpath_node &xnode)
PUGI__FN double gen_nan ()
PUGI__FN bool is_nan (double value)
PUGI__FN const 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)[32], 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)
PUGI__FN const char_t * qualified_name (const xpath_node &node)
PUGI__FN const char_t * local_name (const xpath_node &node)
PUGI__FN const char_t * namespace_uri (xml_node node)
PUGI__FN const char_t * namespace_uri (xml_attribute attr, xml_node parent)
PUGI__FN const char_t * namespace_uri (const xpath_node &node)
PUGI__FN char_t * normalize_space (char_t *buffer)
PUGI__FN char_t * translate (char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
PUGI__FN unsigned char * translate_table_generate (xpath_allocator *alloc, const char_t *from, const char_t *to)
PUGI__FN char_t * translate_table (char_t *buffer, const unsigned char *table)
bool is_xpath_attribute (const char_t *name)
PUGI__FN PUGI__UNSIGNED_OVERFLOW 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 bool copy_xpath_variable (xpath_variable *lhs, const xpath_variable *rhs)
PUGI__FN bool get_variable_scratch (char_t(&buffer)[32], xpath_variable_set *set, const char_t *begin, const char_t *end, xpath_variable **out_result)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN xpath_node_set::type_t xpath_get_order (const xpath_node *begin, const xpath_node *end)
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 impl::xpath_ast_node * evaluate_node_set_prepare (xpath_query_impl *impl)

Variables

template<typename T>
allocation_function xml_memory_management_function_storage< T >::allocate = default_allocate
template<typename T>
deallocation_function xml_memory_management_function_storage< T >::deallocate = default_deallocate
template<axis_t N>
const axis_t axis_to_type< N >::axis = N

Macro Definition Documentation

◆ PUGI__CHECK_ERROR

#define PUGI__CHECK_ERROR ( err,
m )
Value:
{ if (*s == 0) PUGI__THROW_ERROR(err, m); }
#define PUGI__THROW_ERROR(err, m)
Definition pugixml.cc:2613

Definition at line 2614 of file pugixml.cc.

Referenced by xml_parser::parse_exclamation(), and xml_parser::parse_question().

◆ PUGI__DMC_VOLATILE

#define PUGI__DMC_VOLATILE

Definition at line 106 of file pugixml.cc.

Referenced by translate().

◆ PUGI__ENDSEG

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

Definition at line 2612 of file pugixml.cc.

Referenced by xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__ENDSWITH

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

Definition at line 2604 of file pugixml.cc.

Referenced by xml_parser::parse_exclamation(), xml_parser::parse_question(), xml_parser::parse_tree(), strconv_cdata(), and strconv_comment().

◆ PUGI__FN

#define PUGI__FN

Definition at line 164 of file pugixml.cc.

Referenced by pugi::xpath_variable_set::add(), allow_insert_attribute(), allow_insert_child(), allow_move(), pugi::xml_node::append_attribute(), pugi::xml_node::append_buffer(), pugi::xml_node::append_child(), pugi::xml_node::append_child(), pugi::xml_node::append_copy(), pugi::xml_node::append_copy(), pugi::xml_node::append_move(), pugi::xml_attribute::as_bool(), pugi::xml_text::as_bool(), pugi::xml_attribute::as_double(), pugi::xml_text::as_double(), pugi::xml_attribute::as_float(), pugi::xml_text::as_float(), pugi::xml_attribute::as_int(), pugi::xml_text::as_int(), pugi::xml_attribute::as_string(), pugi::xml_text::as_string(), pugi::xml_attribute::as_uint(), pugi::xml_text::as_uint(), pugi::as_utf8(), pugi::as_utf8(), as_utf8_begin(), as_utf8_end(), as_utf8_impl(), pugi::as_wide(), pugi::as_wide(), as_wide_impl(), pugi::xml_node::attribute(), pugi::xml_node::attribute(), pugi::xpath_node::attribute(), pugi::xml_node::attributes(), pugi::xml_node::attributes_begin(), pugi::xml_node::attributes_end(), pugi::xml_node::begin(), pugi::xml_tree_walker::begin(), pugi::xpath_node_set::begin(), check_string_to_number_format(), pugi::xml_node::child(), pugi::xml_node::child_value(), pugi::xml_node::child_value(), pugi::xml_node::children(), pugi::xml_node::children(), close_file(), convert_buffer(), convert_buffer_generic(), convert_buffer_latin1(), convert_buffer_output(), convert_buffer_output_generic(), convert_buffer_output_generic(), convert_number_to_boolean(), convert_number_to_mantissa_exponent(), convert_number_to_string(), convert_number_to_string_special(), convert_path_heap(), convert_string_to_number(), convert_string_to_number_scratch(), copy_xpath_variable(), pugi::xml_text::data(), default_allocate(), default_deallocate(), delete_xpath_variable(), delete_xpath_variable(), pugi::xml_tree_walker::depth(), pugi::xml_parse_result::description(), pugi::xpath_parse_result::description(), document_buffer_order(), pugi::xml_document::document_element(), pugi::xml_attribute::empty(), pugi::xml_node::empty(), pugi::xml_text::empty(), pugi::xpath_node_set::empty(), pugi::xml_node::end(), pugi::xml_tree_walker::end(), pugi::xpath_node_set::end(), pugi::xpath_query::evaluate_boolean(), pugi::xpath_query::evaluate_node(), pugi::xpath_query::evaluate_node_set(), evaluate_node_set_prepare(), pugi::xpath_query::evaluate_number(), pugi::xpath_query::evaluate_string(), pugi::xpath_query::evaluate_string(), find_char(), pugi::xml_node::find_child_by_attribute(), pugi::xml_node::find_child_by_attribute(), find_substring(), pugi::xpath_node_set::first(), pugi::xml_node::first_attribute(), pugi::xml_node::first_child(), pugi::xml_node::first_element_by_path(), gen_nan(), pugi::xml_text::get(), pugi::xpath_variable_set::get(), pugi::xpath_variable_set::get(), pugi::xpath_variable::get_boolean(), get_buffer_encoding(), get_file_size(), get_latin1_7bit_prefix_length(), pugi::get_memory_allocation_function(), pugi::get_memory_deallocation_function(), get_mutable_buffer(), pugi::xpath_variable::get_node_set(), pugi::xpath_variable::get_number(), get_strconv_attribute(), get_strconv_pcdata(), pugi::xpath_variable::get_string(), get_valid_length(), get_value_bool(), get_value_double(), get_value_float(), get_value_int(), get_value_uint(), get_variable_scratch(), get_wchar_encoding(), get_write_encoding(), get_write_native_encoding(), guess_buffer_encoding(), has_declaration(), hash_insert(), hash_string(), pugi::xml_attribute::hash_value(), pugi::xml_node::hash_value(), pugi::xml_node::insert_attribute_after(), pugi::xml_node::insert_attribute_before(), pugi::xml_node::insert_child_after(), pugi::xml_node::insert_child_after(), pugi::xml_node::insert_child_before(), pugi::xml_node::insert_child_before(), pugi::xml_node::insert_copy_after(), pugi::xml_node::insert_copy_after(), pugi::xml_node::insert_copy_before(), pugi::xml_node::insert_copy_before(), pugi::xml_node::insert_move_after(), pugi::xml_node::insert_move_before(), insertion_sort(), integer_to_string(), pugi::xml_attribute::internal_object(), pugi::xml_node::internal_object(), is_attribute_of(), is_little_endian(), is_nan(), pugi::xml_node::last_attribute(), pugi::xml_node::last_child(), pugi::xml_document::load(), pugi::xml_document::load(), pugi::xml_document::load(), pugi::xml_document::load_buffer(), load_buffer_impl(), pugi::xml_document::load_buffer_inplace(), pugi::xml_document::load_buffer_inplace_own(), pugi::xml_document::load_file(), pugi::xml_document::load_file(), load_file_impl(), load_stream_data_noseek(), load_stream_data_seek(), load_stream_impl(), pugi::xml_document::load_string(), local_name(), min_element(), pugi::xml_attribute::name(), pugi::xml_node::name(), pugi::xpath_variable::name(), namespace_uri(), namespace_uri(), namespace_uri(), new_xpath_variable(), new_xpath_variable(), pugi::xml_attribute::next_attribute(), pugi::xml_node::next_sibling(), pugi::xml_node::next_sibling(), pugi::xpath_node::node(), node_copy_attribute(), node_copy_contents(), node_copy_string(), node_copy_tree(), node_is_ancestor(), node_is_before(), node_is_before_sibling(), node_output(), node_output_attributes(), node_output_comment(), node_output_end(), node_output_pi_value(), node_output_simple(), node_output_start(), normalize_space(), pugi::xml_node::offset_debug(), open_file(), open_file_wide(), pugi::xml_parse_result::operator bool(), pugi::xpath_parse_result::operator bool(), pugi::xml_attribute::operator unspecified_bool_type(), pugi::xml_node::operator unspecified_bool_type(), pugi::xml_text::operator unspecified_bool_type(), pugi::xpath_node::operator unspecified_bool_type(), pugi::xpath_query::operator unspecified_bool_type(), pugi::xml_attribute::operator!(), pugi::xml_node::operator!(), pugi::xml_text::operator!(), pugi::xpath_node::operator!(), pugi::xpath_query::operator!(), pugi::xml_attribute::operator!=(), pugi::xml_attribute_iterator::operator!=(), pugi::xml_named_node_iterator::operator!=(), pugi::xml_node::operator!=(), pugi::xml_node_iterator::operator!=(), pugi::xpath_node::operator!=(), pugi::xml_attribute_iterator::operator*(), pugi::xml_named_node_iterator::operator*(), pugi::xml_node_iterator::operator*(), pugi::xml_attribute_iterator::operator++(), pugi::xml_attribute_iterator::operator++(), pugi::xml_named_node_iterator::operator++(), pugi::xml_named_node_iterator::operator++(), pugi::xml_node_iterator::operator++(), pugi::xml_node_iterator::operator++(), pugi::xml_attribute_iterator::operator--(), pugi::xml_attribute_iterator::operator--(), pugi::xml_named_node_iterator::operator--(), pugi::xml_named_node_iterator::operator--(), pugi::xml_node_iterator::operator--(), pugi::xml_node_iterator::operator--(), pugi::xml_attribute_iterator::operator->(), pugi::xml_named_node_iterator::operator->(), pugi::xml_node_iterator::operator->(), pugi::xml_attribute::operator<(), pugi::xml_node::operator<(), pugi::xml_attribute::operator<=(), pugi::xml_node::operator<=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_attribute::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xml_text::operator=(), pugi::xpath_node_set::operator=(), pugi::xpath_variable_set::operator=(), pugi::xml_attribute::operator==(), pugi::xml_attribute_iterator::operator==(), pugi::xml_named_node_iterator::operator==(), pugi::xml_node::operator==(), pugi::xml_node_iterator::operator==(), pugi::xpath_node::operator==(), pugi::xml_attribute::operator>(), pugi::xml_node::operator>(), pugi::xml_attribute::operator>=(), pugi::xml_node::operator>=(), pugi::xpath_node_set::operator[](), pugi::xml_node::parent(), pugi::xpath_node::parent(), parse_declaration_encoding(), partition3(), pugi::xml_node::path(), pugi::xml_node::prepend_attribute(), pugi::xml_node::prepend_child(), pugi::xml_node::prepend_child(), pugi::xml_node::prepend_copy(), pugi::xml_node::prepend_copy(), pugi::xml_node::prepend_move(), pugi::xml_attribute::previous_attribute(), pugi::xml_node::previous_sibling(), pugi::xml_node::previous_sibling(), pugi::xml_node::print(), pugi::xml_node::print(), pugi::xml_node::print(), qualified_name(), pugi::xml_node::remove_attribute(), pugi::xml_node::remove_attribute(), pugi::xml_node::remove_attributes(), pugi::xml_node::remove_child(), pugi::xml_node::remove_child(), pugi::xml_node::remove_children(), pugi::xml_document::reset(), pugi::xml_document::reset(), pugi::xpath_exception::result(), pugi::xpath_query::result(), pugi::xpath_query::return_type(), reverse(), pugi::xml_node::root(), round_nearest(), round_nearest_nzero(), pugi::xml_document::save(), pugi::xml_document::save(), pugi::xml_document::save(), pugi::xml_document::save_file(), pugi::xml_document::save_file(), save_file_impl(), pugi::xml_node::select_node(), pugi::xml_node::select_node(), pugi::xml_node::select_nodes(), pugi::xml_node::select_nodes(), pugi::xml_node::select_single_node(), pugi::xml_node::select_single_node(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xml_text::set(), pugi::xpath_variable::set(), pugi::xpath_variable::set(), pugi::xpath_variable::set(), pugi::xpath_variable::set(), pugi::xpath_variable_set::set(), pugi::xpath_variable_set::set(), pugi::xpath_variable_set::set(), pugi::xpath_variable_set::set(), pugi::set_memory_management_functions(), pugi::xml_attribute::set_name(), pugi::xml_node::set_name(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_attribute::set_value(), pugi::xml_node::set_value(), pugi::xml_node::set_value(), set_value_ascii(), set_value_bool(), set_value_convert(), set_value_convert(), set_value_integer(), pugi::xpath_node_set::size(), pugi::xpath_node_set::sort(), sort(), starts_with(), strconv_cdata(), strconv_comment(), strconv_escape(), strcpy_insitu(), strequal(), strequalrange(), string_to_integer(), string_value(), strlength(), strlength_wide(), pugi::xml_node::text(), text_output(), text_output_cdata(), text_output_escaped(), text_output_indent(), tolower_ascii(), translate(), translate_table(), translate_table_generate(), pugi::xml_node::traverse(), truncate_zeros(), pugi::xml_node::type(), pugi::xpath_node_set::type(), pugi::xpath_variable::type(), unique(), pugi::xml_attribute::value(), pugi::xml_node::value(), pugi::xpath_exception::what(), pugi::xml_writer_file::write(), pugi::xml_writer_stream::write(), pugi::xml_attribute::xml_attribute(), pugi::xml_attribute::xml_attribute(), pugi::xml_attribute_iterator::xml_attribute_iterator(), pugi::xml_attribute_iterator::xml_attribute_iterator(), pugi::xml_document::xml_document(), pugi::xml_named_node_iterator::xml_named_node_iterator(), pugi::xml_named_node_iterator::xml_named_node_iterator(), pugi::xml_node::xml_node(), pugi::xml_node::xml_node(), pugi::xml_node_iterator::xml_node_iterator(), pugi::xml_node_iterator::xml_node_iterator(), pugi::xml_parse_result::xml_parse_result(), pugi::xml_text::xml_text(), pugi::xml_tree_walker::xml_tree_walker(), pugi::xml_writer_file::xml_writer_file(), pugi::xml_writer_stream::xml_writer_stream(), pugi::xml_writer_stream::xml_writer_stream(), pugi::xpath_exception::xpath_exception(), xpath_first(), xpath_get_order(), pugi::xpath_node::xpath_node(), pugi::xpath_node::xpath_node(), pugi::xpath_node::xpath_node(), pugi::xpath_node_set::xpath_node_set(), pugi::xpath_node_set::xpath_node_set(), pugi::xpath_node_set::xpath_node_set(), pugi::xpath_parse_result::xpath_parse_result(), pugi::xpath_query::xpath_query(), pugi::xpath_query::xpath_query(), xpath_sort(), pugi::xpath_variable::xpath_variable(), pugi::xpath_variable_set::xpath_variable_set(), pugi::xpath_variable_set::xpath_variable_set(), zero_terminate_buffer(), pugi::xml_document::~xml_document(), pugi::xml_tree_walker::~xml_tree_walker(), pugi::xpath_node_set::~xpath_node_set(), pugi::xpath_query::~xpath_query(), and pugi::xpath_variable_set::~xpath_variable_set().

◆ PUGI__FN_NO_INLINE

◆ PUGI__GETHEADER_IMPL

#define PUGI__GETHEADER_IMPL ( object,
page,
flags )
Value:
(((reinterpret_cast<char*>(object) - reinterpret_cast<char*>(page)) << 8) | (flags))

Definition at line 450 of file pugixml.cc.

Referenced by pugi::xml_attribute_struct::xml_attribute_struct(), and pugi::xml_node_struct::xml_node_struct().

◆ PUGI__GETPAGE

#define PUGI__GETPAGE ( n)
Value:
PUGI__GETPAGE_IMPL((n)->header)
#define PUGI__GETPAGE_IMPL(header)
Definition pugixml.cc:452

Definition at line 455 of file pugixml.cc.

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

◆ PUGI__GETPAGE_IMPL

#define PUGI__GETPAGE_IMPL ( header)
Value:
static_cast<impl::xml_memory_page*>(const_cast<void*>(static_cast<const void*>(reinterpret_cast<const char*>(&header) - (header >> 8))))

Definition at line 452 of file pugixml.cc.

Referenced by strcpy_insitu().

◆ PUGI__IS_CHARTYPE

◆ PUGI__IS_CHARTYPE_IMPL

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

Definition at line 1912 of file pugixml.cc.

◆ PUGI__IS_CHARTYPEX

#define PUGI__IS_CHARTYPEX ( c,
ct )
Value:
PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table)

Definition at line 1916 of file pugixml.cc.

Referenced by check_string_to_number_format(), xpath_lexer::next(), and text_output_escaped().

◆ PUGI__NO_INLINE

#define PUGI__NO_INLINE

Definition at line 89 of file pugixml.cc.

◆ PUGI__NODETYPE

◆ PUGI__NS_BEGIN

#define PUGI__NS_BEGIN   namespace pugi { namespace impl { namespace {

Definition at line 161 of file pugixml.cc.

◆ PUGI__NS_END

#define PUGI__NS_END   } } }

Definition at line 162 of file pugixml.cc.

◆ PUGI__OPTSET

#define PUGI__OPTSET ( OPT)
Value:
( optmsk & (OPT) )

Definition at line 2606 of file pugixml.cc.

Referenced by xml_parser::parse(), xml_parser::parse_exclamation(), xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__POPNODE

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

Definition at line 2608 of file pugixml.cc.

Referenced by xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__PUSHNODE

#define PUGI__PUSHNODE ( TYPE)
Value:
{ cursor = append_new_node(cursor, *alloc, TYPE); if (!cursor) PUGI__THROW_ERROR(status_out_of_memory, s); }
@ TYPE
Definition inflate.h:32
PUGI__FN_NO_INLINE xml_node_struct * append_new_node(xml_node_struct *node, xml_allocator &alloc, xml_node_type type=node_element)
Definition pugixml.cc:1415

Definition at line 2607 of file pugixml.cc.

Referenced by xml_parser::parse_exclamation(), xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__SCANCHAR

#define PUGI__SCANCHAR ( ch)
Value:
{ if (offset >= size || data[offset] != ch) return false; offset++; }
G4ThreadLocal T * G4GeomSplitter< T >::offset

Referenced by parse_declaration_encoding().

◆ PUGI__SCANCHARTYPE

#define PUGI__SCANCHARTYPE ( ct)
Value:
{ while (offset < size && PUGI__IS_CHARTYPE(data[offset], ct)) offset++; }
#define PUGI__IS_CHARTYPE(c, ct)
Definition pugixml.cc:1915

Referenced by parse_declaration_encoding().

◆ PUGI__SCANFOR

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

Definition at line 2609 of file pugixml.cc.

Referenced by xml_parser::parse_doctype_primitive(), xml_parser::parse_exclamation(), xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__SCANWHILE

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

Definition at line 2610 of file pugixml.cc.

Referenced by xml_parser::parse_question().

◆ PUGI__SCANWHILE_UNROLL

#define PUGI__SCANWHILE_UNROLL ( X)
Value:
{ for (;;) { char_t ss = s[0]; if (PUGI__UNLIKELY(!(X))) { break; } ss = s[1]; if (PUGI__UNLIKELY(!(X))) { s += 1; break; } ss = s[2]; if (PUGI__UNLIKELY(!(X))) { s += 2; break; } ss = s[3]; if (PUGI__UNLIKELY(!(X))) { s += 3; break; } s += 4; } }
#define PUGI__UNLIKELY(cond)
Definition pugixml.cc:96

Definition at line 2611 of file pugixml.cc.

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(), xml_parser::parse_tree(), strconv_attribute_impl< opt_escape >::parse_wconv(), strconv_attribute_impl< opt_escape >::parse_wnorm(), strconv_cdata(), strconv_comment(), and text_output_escaped().

◆ PUGI__SKIPWS

#define PUGI__SKIPWS ( )
Value:
{ while (PUGI__IS_CHARTYPE(*s, ct_space)) ++s; }
@ ct_space
Definition pugixml.cc:1850

Definition at line 2605 of file pugixml.cc.

Referenced by xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__SNPRINTF

#define PUGI__SNPRINTF   sprintf

◆ PUGI__STATIC_ASSERT

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

Definition at line 100 of file pugixml.cc.

Referenced by xml_allocator::allocate_string(), convert_buffer_output_generic(), convert_buffer_output_generic(), gen_nan(), get_strconv_attribute(), get_strconv_pcdata(), get_wchar_encoding(), string_to_integer(), and xml_buffered_writer::xml_buffered_writer().

◆ PUGI__THROW_ERROR

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

Definition at line 2613 of file pugixml.cc.

Referenced by xml_parser::parse_doctype_group(), xml_parser::parse_doctype_ignore(), xml_parser::parse_doctype_primitive(), xml_parser::parse_exclamation(), xml_parser::parse_question(), and xml_parser::parse_tree().

◆ PUGI__UNLIKELY

#define PUGI__UNLIKELY ( cond)
Value:
(cond)

Definition at line 96 of file pugixml.cc.

Referenced by xml_allocator::allocate_memory().

◆ PUGI__UNSIGNED_OVERFLOW

#define PUGI__UNSIGNED_OVERFLOW

Definition at line 117 of file pugixml.cc.

Referenced by hash_string(), integer_to_string(), and string_to_integer().

◆ SOURCE_PUGIXML_CPP

#define SOURCE_PUGIXML_CPP

pugixml parser - version 1.13

Copyright (C) 2006-2022, 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 https://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.cc.

Typedef Documentation

◆ strconv_attribute_t

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

Definition at line 2743 of file pugixml.cc.

◆ strconv_pcdata_t

typedef char_t *(* strconv_pcdata_t) (char_t *)

Definition at line 2672 of file pugixml.cc.

◆ wchar_counter

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

Definition at line 1820 of file pugixml.cc.

◆ wchar_writer

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

Definition at line 1821 of file pugixml.cc.

◆ xml_memory

Definition at line 208 of file pugixml.cc.

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_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 
ast_opt_translate_table 
ast_opt_compare_attribute 

Definition at line 9553 of file pugixml.cc.

9554 {
9556 ast_op_or, // left or right
9557 ast_op_and, // left and right
9558 ast_op_equal, // left = right
9559 ast_op_not_equal, // left != right
9560 ast_op_less, // left < right
9561 ast_op_greater, // left > right
9562 ast_op_less_or_equal, // left <= right
9563 ast_op_greater_or_equal, // left >= right
9564 ast_op_add, // left + right
9565 ast_op_subtract, // left - right
9566 ast_op_multiply, // left * right
9567 ast_op_divide, // left / right
9568 ast_op_mod, // left % right
9569 ast_op_negate, // left - right
9570 ast_op_union, // left | right
9571 ast_predicate, // apply predicate to set; next points to next predicate
9572 ast_filter, // select * from left where right
9573 ast_string_constant, // string constant
9574 ast_number_constant, // number constant
9575 ast_variable, // variable
9576 ast_func_last, // last()
9577 ast_func_position, // position()
9578 ast_func_count, // count(left)
9579 ast_func_id, // id(left)
9580 ast_func_local_name_0, // local-name()
9581 ast_func_local_name_1, // local-name(left)
9582 ast_func_namespace_uri_0, // namespace-uri()
9583 ast_func_namespace_uri_1, // namespace-uri(left)
9584 ast_func_name_0, // name()
9585 ast_func_name_1, // name(left)
9586 ast_func_string_0, // string()
9587 ast_func_string_1, // string(left)
9588 ast_func_concat, // concat(left, right, siblings)
9589 ast_func_starts_with, // starts_with(left, right)
9590 ast_func_contains, // contains(left, right)
9591 ast_func_substring_before, // substring-before(left, right)
9592 ast_func_substring_after, // substring-after(left, right)
9593 ast_func_substring_2, // substring(left, right)
9594 ast_func_substring_3, // substring(left, right, third)
9595 ast_func_string_length_0, // string-length()
9596 ast_func_string_length_1, // string-length(left)
9597 ast_func_normalize_space_0, // normalize-space()
9598 ast_func_normalize_space_1, // normalize-space(left)
9599 ast_func_translate, // translate(left, right, third)
9600 ast_func_boolean, // boolean(left)
9601 ast_func_not, // not(left)
9602 ast_func_true, // true()
9603 ast_func_false, // false()
9604 ast_func_lang, // lang(left)
9605 ast_func_number_0, // number()
9606 ast_func_number_1, // number(left)
9607 ast_func_sum, // sum(left)
9608 ast_func_floor, // floor(left)
9609 ast_func_ceiling, // ceiling(left)
9610 ast_func_round, // round(left)
9611 ast_step, // process set left with step
9612 ast_step_root, // select root node
9613
9614 ast_opt_translate_table, // translate(left, right, third) where right/third are constants
9615 ast_opt_compare_attribute // @name = 'string'
9616 };
@ ast_op_and
Definition pugixml.cc:9557
@ ast_number_constant
Definition pugixml.cc:9574
@ ast_filter
Definition pugixml.cc:9572
@ ast_func_substring_3
Definition pugixml.cc:9594
@ ast_func_sum
Definition pugixml.cc:9607
@ ast_func_name_1
Definition pugixml.cc:9585
@ ast_func_floor
Definition pugixml.cc:9608
@ ast_op_divide
Definition pugixml.cc:9567
@ ast_opt_translate_table
Definition pugixml.cc:9614
@ ast_func_concat
Definition pugixml.cc:9588
@ ast_op_equal
Definition pugixml.cc:9558
@ ast_unknown
Definition pugixml.cc:9555
@ ast_func_name_0
Definition pugixml.cc:9584
@ ast_predicate
Definition pugixml.cc:9571
@ ast_func_not
Definition pugixml.cc:9601
@ ast_variable
Definition pugixml.cc:9575
@ ast_func_string_1
Definition pugixml.cc:9587
@ ast_func_string_0
Definition pugixml.cc:9586
@ ast_opt_compare_attribute
Definition pugixml.cc:9615
@ ast_func_number_0
Definition pugixml.cc:9605
@ ast_op_union
Definition pugixml.cc:9570
@ ast_func_substring_before
Definition pugixml.cc:9591
@ ast_func_string_length_0
Definition pugixml.cc:9595
@ ast_func_local_name_1
Definition pugixml.cc:9581
@ ast_func_namespace_uri_0
Definition pugixml.cc:9582
@ ast_func_lang
Definition pugixml.cc:9604
@ ast_func_true
Definition pugixml.cc:9602
@ ast_func_normalize_space_1
Definition pugixml.cc:9598
@ ast_op_not_equal
Definition pugixml.cc:9559
@ ast_func_contains
Definition pugixml.cc:9590
@ ast_op_greater
Definition pugixml.cc:9561
@ ast_op_negate
Definition pugixml.cc:9569
@ ast_func_substring_2
Definition pugixml.cc:9593
@ ast_func_position
Definition pugixml.cc:9577
@ ast_string_constant
Definition pugixml.cc:9573
@ ast_func_ceiling
Definition pugixml.cc:9609
@ ast_op_subtract
Definition pugixml.cc:9565
@ ast_func_last
Definition pugixml.cc:9576
@ ast_func_normalize_space_0
Definition pugixml.cc:9597
@ ast_func_boolean
Definition pugixml.cc:9600
@ ast_op_less_or_equal
Definition pugixml.cc:9562
@ ast_step
Definition pugixml.cc:9611
@ ast_op_multiply
Definition pugixml.cc:9566
@ ast_func_count
Definition pugixml.cc:9578
@ ast_func_substring_after
Definition pugixml.cc:9592
@ ast_func_namespace_uri_1
Definition pugixml.cc:9583
@ ast_step_root
Definition pugixml.cc:9612
@ ast_func_translate
Definition pugixml.cc:9599
@ ast_func_round
Definition pugixml.cc:9610
@ ast_func_number_1
Definition pugixml.cc:9606
@ ast_func_string_length_1
Definition pugixml.cc:9596
@ ast_func_starts_with
Definition pugixml.cc:9589
@ ast_op_add
Definition pugixml.cc:9564
@ ast_op_or
Definition pugixml.cc:9556
@ ast_op_greater_or_equal
Definition pugixml.cc:9563
@ ast_func_false
Definition pugixml.cc:9603
@ ast_func_local_name_0
Definition pugixml.cc:9580
@ ast_op_mod
Definition pugixml.cc:9568
@ ast_func_id
Definition pugixml.cc:9579
@ ast_op_less
Definition pugixml.cc:9560

◆ 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 9618 of file pugixml.cc.

9619 {
9623 axis_child,
9632 axis_self
9633 };
@ axis_preceding
Definition pugixml.cc:9630
@ axis_ancestor_or_self
Definition pugixml.cc:9621
@ axis_attribute
Definition pugixml.cc:9622
@ axis_following_sibling
Definition pugixml.cc:9627
@ axis_child
Definition pugixml.cc:9623
@ axis_descendant
Definition pugixml.cc:9624
@ axis_descendant_or_self
Definition pugixml.cc:9625
@ axis_self
Definition pugixml.cc:9632
@ axis_following
Definition pugixml.cc:9626
@ axis_ancestor
Definition pugixml.cc:9620
@ axis_preceding_sibling
Definition pugixml.cc:9631
@ axis_namespace
Definition pugixml.cc:9628
@ axis_parent
Definition pugixml.cc:9629

◆ 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 1845 of file pugixml.cc.

1846 {
1847 ct_parse_pcdata = 1, // \0, &, \r, <
1848 ct_parse_attr = 2, // \0, &, \r, ', "
1849 ct_parse_attr_ws = 4, // \0, &, \r, ', ", \n, tab
1850 ct_space = 8, // \r, \n, space, tab
1851 ct_parse_cdata = 16, // \0, ], >, \r
1852 ct_parse_comment = 32, // \0, -, >, \r
1853 ct_symbol = 64, // Any symbol > 127, a-z, A-Z, 0-9, _, :, -, .
1854 ct_start_symbol = 128 // Any symbol > 127, a-z, A-Z, _, :
1855 };
@ ct_parse_comment
Definition pugixml.cc:1852
@ ct_start_symbol
Definition pugixml.cc:1854
@ ct_parse_attr
Definition pugixml.cc:1848
@ ct_parse_attr_ws
Definition pugixml.cc:1849
@ ct_parse_cdata
Definition pugixml.cc:1851
@ ct_parse_pcdata
Definition pugixml.cc:1847
@ ct_symbol
Definition pugixml.cc:1853

◆ chartypex_t

Enumerator
ctx_special_pcdata 
ctx_special_attr 
ctx_start_symbol 
ctx_digit 
ctx_symbol 

Definition at line 1878 of file pugixml.cc.

1879 {
1880 ctx_special_pcdata = 1, // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, >
1881 ctx_special_attr = 2, // Any symbol >= 0 and < 32, &, <, ", '
1882 ctx_start_symbol = 4, // Any symbol > 127, a-z, A-Z, _
1883 ctx_digit = 8, // 0-9
1884 ctx_symbol = 16 // Any symbol > 127, a-z, A-Z, 0-9, _, -, .
1885 };
@ ctx_digit
Definition pugixml.cc:1883
@ ctx_special_attr
Definition pugixml.cc:1881
@ ctx_symbol
Definition pugixml.cc:1884
@ ctx_start_symbol
Definition pugixml.cc:1882
@ ctx_special_pcdata
Definition pugixml.cc:1880

◆ indent_flags_t

Enumerator
indent_newline 
indent_indent 

Definition at line 4247 of file pugixml.cc.

4248 {
4249 indent_newline = 1,
4250 indent_indent = 2
4251 };
@ indent_indent
Definition pugixml.cc:4250
@ indent_newline
Definition pugixml.cc:4249

◆ 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 9199 of file pugixml.cc.

9200 {
9201 lex_none = 0,
9202 lex_equal,
9204 lex_less,
9208 lex_plus,
9209 lex_minus,
9211 lex_union,
9216 lex_number,
9217 lex_slash,
9221 lex_string,
9222 lex_comma,
9224 lex_dot,
9227 lex_eof
9228 };
@ lex_multiply
Definition pugixml.cc:9210
@ lex_double_slash
Definition pugixml.cc:9218
@ lex_quoted_string
Definition pugixml.cc:9215
@ lex_not_equal
Definition pugixml.cc:9203
@ lex_axis_attribute
Definition pugixml.cc:9223
@ lex_less
Definition pugixml.cc:9204
@ lex_equal
Definition pugixml.cc:9202
@ lex_greater_or_equal
Definition pugixml.cc:9207
@ lex_none
Definition pugixml.cc:9201
@ lex_union
Definition pugixml.cc:9211
@ lex_comma
Definition pugixml.cc:9222
@ lex_close_brace
Definition pugixml.cc:9214
@ lex_slash
Definition pugixml.cc:9217
@ lex_var_ref
Definition pugixml.cc:9212
@ lex_dot
Definition pugixml.cc:9224
@ lex_minus
Definition pugixml.cc:9209
@ lex_string
Definition pugixml.cc:9221
@ lex_eof
Definition pugixml.cc:9227
@ lex_plus
Definition pugixml.cc:9208
@ lex_number
Definition pugixml.cc:9216
@ lex_greater
Definition pugixml.cc:9205
@ lex_double_dot
Definition pugixml.cc:9225
@ lex_less_or_equal
Definition pugixml.cc:9206
@ lex_close_square_brace
Definition pugixml.cc:9220
@ lex_open_square_brace
Definition pugixml.cc:9219
@ lex_open_brace
Definition pugixml.cc:9213
@ lex_double_colon
Definition pugixml.cc:9226

◆ nodeset_eval_t

Enumerator
nodeset_eval_all 
nodeset_eval_any 
nodeset_eval_first 

Definition at line 9656 of file pugixml.cc.

9657 {
9661 };
@ nodeset_eval_first
Definition pugixml.cc:9660
@ nodeset_eval_any
Definition pugixml.cc:9659
@ nodeset_eval_all
Definition pugixml.cc:9658

◆ 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 9635 of file pugixml.cc.

9636 {
9646 };
@ nodetest_all
Definition pugixml.cc:9644
@ nodetest_name
Definition pugixml.cc:9638
@ nodetest_none
Definition pugixml.cc:9637
@ nodetest_type_text
Definition pugixml.cc:9642
@ nodetest_all_in_namespace
Definition pugixml.cc:9645
@ nodetest_pi
Definition pugixml.cc:9643
@ nodetest_type_comment
Definition pugixml.cc:9640
@ nodetest_type_node
Definition pugixml.cc:9639
@ nodetest_type_pi
Definition pugixml.cc:9641

◆ predicate_t

Enumerator
predicate_default 
predicate_posinv 
predicate_constant 
predicate_constant_one 

Definition at line 9648 of file pugixml.cc.

9649 {
9654 };
@ predicate_constant
Definition pugixml.cc:9652
@ predicate_constant_one
Definition pugixml.cc:9653
@ predicate_default
Definition pugixml.cc:9650
@ predicate_posinv
Definition pugixml.cc:9651

Function Documentation

◆ allocate_attribute()

PUGI__NS_END PUGI__NS_BEGIN xml_attribute_struct * allocate_attribute ( xml_allocator & alloc)
inline

Definition at line 1176 of file pugixml.cc.

1177 {
1178 xml_memory_page* page;
1179 void* memory = alloc.allocate_object(sizeof(xml_attribute_struct), page);
1180 if (!memory) return 0;
1181
1182 return new (memory) xml_attribute_struct(page);
1183 }
void * allocate_object(size_t size, xml_memory_page *&out_page)
Definition pugixml.cc:590

Referenced by append_new_attribute().

◆ allocate_node()

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

Definition at line 1185 of file pugixml.cc.

1186 {
1187 xml_memory_page* page;
1188 void* memory = alloc.allocate_object(sizeof(xml_node_struct), page);
1189 if (!memory) return 0;
1190
1191 return new (memory) xml_node_struct(page, type);
1192 }

Referenced by append_new_node().

◆ allow_insert_attribute()

PUGI__FN bool allow_insert_attribute ( xml_node_type parent)

Definition at line 4368 of file pugixml.cc.

4369 {
4370 return parent == node_element || parent == node_declaration;
4371 }
@ node_element
Definition pugixml.hpp:153
@ node_declaration
Definition pugixml.hpp:158

◆ allow_insert_child()

PUGI__FN bool allow_insert_child ( xml_node_type parent,
xml_node_type child )

Definition at line 4373 of file pugixml.cc.

4374 {
4375 if (parent != node_document && parent != node_element) return false;
4376 if (child == node_document || child == node_null) return false;
4377 if (parent != node_document && (child == node_declaration || child == node_doctype)) return false;
4378
4379 return true;
4380 }

Referenced by allow_move().

◆ allow_move()

PUGI__FN bool allow_move ( xml_node parent,
xml_node child )

Definition at line 4382 of file pugixml.cc.

4383 {
4384 // check that child can be a child of parent
4385 if (!allow_insert_child(parent.type(), child.type()))
4386 return false;
4387
4388 // check that node is not moved between documents
4389 if (parent.root() != child.root())
4390 return false;
4391
4392 // check that new parent is not in the child subtree
4393 xml_node cur = parent;
4394
4395 while (cur)
4396 {
4397 if (cur == child)
4398 return false;
4399
4400 cur = cur.parent();
4401 }
4402
4403 return true;
4404 }
PUGI__FN bool allow_insert_child(xml_node_type parent, xml_node_type child)
Definition pugixml.cc:4373

◆ append_attribute()

void append_attribute ( xml_attribute_struct * attr,
xml_node_struct * node )
inline

Definition at line 1333 of file pugixml.cc.

1334 {
1335 xml_attribute_struct* head = node->first_attribute;
1336
1337 if (head)
1338 {
1339 xml_attribute_struct* tail = head->prev_attribute_c;
1340
1341 tail->next_attribute = attr;
1342 attr->prev_attribute_c = tail;
1343 head->prev_attribute_c = attr;
1344 }
1345 else
1346 {
1347 node->first_attribute = attr;
1348 attr->prev_attribute_c = attr;
1349 }
1350 }

Referenced by append_new_attribute().

◆ append_new_attribute()

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

Definition at line 1427 of file pugixml.cc.

1428 {
1429 if (!alloc.reserve()) return 0;
1430
1431 xml_attribute_struct* attr = allocate_attribute(alloc);
1432 if (!attr) return 0;
1433
1434 append_attribute(attr, node);
1435
1436 return attr;
1437 }
PUGI__NS_END PUGI__NS_BEGIN xml_attribute_struct * allocate_attribute(xml_allocator &alloc)
Definition pugixml.cc:1176
void append_attribute(xml_attribute_struct *attr, xml_node_struct *node)
Definition pugixml.cc:1333
bool reserve()
Definition pugixml.cc:693

Referenced by node_copy_contents(), and 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 1415 of file pugixml.cc.

1416 {
1417 if (!alloc.reserve()) return 0;
1418
1419 xml_node_struct* child = allocate_node(alloc, type);
1420 if (!child) return 0;
1421
1422 append_node(child, node);
1423
1424 return child;
1425 }
xml_node_struct * allocate_node(xml_allocator &alloc, xml_node_type type)
Definition pugixml.cc:1185
void append_node(xml_node_struct *child, xml_node_struct *node)
Definition pugixml.cc:1234

Referenced by node_copy_tree().

◆ append_node()

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

Definition at line 1234 of file pugixml.cc.

1235 {
1236 child->parent = node;
1237
1238 xml_node_struct* head = node->first_child;
1239
1240 if (head)
1241 {
1242 xml_node_struct* tail = head->prev_sibling_c;
1243
1244 tail->next_sibling = child;
1245 child->prev_sibling_c = tail;
1246 head->prev_sibling_c = child;
1247 }
1248 else
1249 {
1250 node->first_child = child;
1251 child->prev_sibling_c = child;
1252 }
1253 }

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 2297 of file pugixml.cc.

2298 {
2299 // get length in utf8 characters
2300 return wchar_decoder::process(str, length, 0, utf8_counter());
2301 }
static Traits::value_type process(const wchar_t *data, size_t size, typename Traits::value_type result, Traits traits)
Definition pugixml.cc:1827

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 2303 of file pugixml.cc.

2304 {
2305 // convert to utf8
2306 uint8_t* begin = reinterpret_cast<uint8_t*>(buffer);
2307 uint8_t* end = wchar_decoder::process(str, length, begin, utf8_writer());
2308
2309 assert(begin + size == end);
2310 (void)!end;
2311 (void)!size;
2312 }

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 2315 of file pugixml.cc.

2316 {
2317 // first pass: get length in utf8 characters
2318 size_t size = as_utf8_begin(str, length);
2319
2320 // allocate resulting string
2321 std::string result;
2322 result.resize(size);
2323
2324 // second pass: convert to utf8
2325 if (size > 0) as_utf8_end(&result[0], size, str, length);
2326
2327 return result;
2328 }
PUGI__FN void as_utf8_end(char *buffer, size_t size, const wchar_t *str, size_t length)
Definition pugixml.cc:2303
PUGI__FN size_t as_utf8_begin(const wchar_t *str, size_t length)
Definition pugixml.cc:2297

◆ as_wide_impl()

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

Definition at line 2330 of file pugixml.cc.

2331 {
2332 const uint8_t* data = reinterpret_cast<const uint8_t*>(str);
2333
2334 // first pass: get length in wchar_t units
2335 size_t length = utf8_decoder::process(data, size, 0, wchar_counter());
2336
2337 // allocate resulting string
2338 std::basic_string<wchar_t> result;
2339 result.resize(length);
2340
2341 // second pass: convert to wchar_t
2342 if (length > 0)
2343 {
2344 wchar_writer::value_type begin = reinterpret_cast<wchar_writer::value_type>(&result[0]);
2345 wchar_writer::value_type end = utf8_decoder::process(data, size, begin, wchar_writer());
2346
2347 assert(begin + length == end);
2348 (void)!end;
2349 }
2350
2351 return result;
2352 }
wchar_selector< sizeof(wchar_t)>::writer wchar_writer
Definition pugixml.cc:1821
wchar_selector< sizeof(wchar_t)>::counter wchar_counter
Definition pugixml.cc:1820
static Traits::value_type process(const uint8_t *data, size_t size, typename Traits::value_type result, Traits)
Definition pugixml.cc:1640

◆ check_string_to_number_format()

PUGI__FN bool check_string_to_number_format ( const char_t * string)

Definition at line 8515 of file pugixml.cc.

8516 {
8517 // parse leading whitespace
8518 while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string;
8519
8520 // parse sign
8521 if (*string == '-') ++string;
8522
8523 if (!*string) return false;
8524
8525 // if there is no integer part, there should be a decimal part with at least one digit
8526 if (!PUGI__IS_CHARTYPEX(string[0], ctx_digit) && (string[0] != '.' || !PUGI__IS_CHARTYPEX(string[1], ctx_digit))) return false;
8527
8528 // parse integer part
8529 while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string;
8530
8531 // parse decimal part
8532 if (*string == '.')
8533 {
8534 ++string;
8535
8536 while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string;
8537 }
8538
8539 // parse trailing whitespace
8540 while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string;
8541
8542 return *string == 0;
8543 }
#define PUGI__IS_CHARTYPEX(c, ct)
Definition pugixml.cc:1916

Referenced by convert_string_to_number().

◆ close_file()

PUGI__FN void close_file ( FILE * file)

Definition at line 4849 of file pugixml.cc.

4850 {
4851 fclose(file);
4852 }

◆ 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 2262 of file pugixml.cc.

2263 {
2264 // fast path: no conversion required
2265 if (encoding == encoding_utf8)
2266 return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable);
2267
2268 // source encoding is utf16
2269 if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
2270 {
2272
2273 return (native_encoding == encoding) ?
2274 convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder<opt_false>()) :
2275 convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder<opt_true>());
2276 }
2277
2278 // source encoding is utf32
2279 if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
2280 {
2282
2283 return (native_encoding == encoding) ?
2284 convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder<opt_false>()) :
2285 convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder<opt_true>());
2286 }
2287
2288 // source encoding is latin1
2289 if (encoding == encoding_latin1)
2290 return convert_buffer_latin1(out_buffer, out_length, contents, size, is_mutable);
2291
2292 assert(false && "Invalid encoding"); // unreachable
2293 return false;
2294 }
xml_encoding
Definition pugixml.hpp:228
@ encoding_utf16_le
Definition pugixml.hpp:231
@ encoding_utf32_be
Definition pugixml.hpp:235
@ encoding_utf16_be
Definition pugixml.hpp:232
@ encoding_utf32_le
Definition pugixml.hpp:234
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.cc:2057
PUGI__FN bool convert_buffer_generic(char_t *&out_buffer, size_t &out_length, const void *contents, size_t size, D)
Definition pugixml.cc:2191
PUGI__FN bool is_little_endian()
Definition pugixml.cc:1918
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.cc:2225

◆ convert_buffer_generic()

template<typename D>
PUGI__FN bool convert_buffer_generic ( char_t *& out_buffer,
size_t & out_length,
const void * contents,
size_t size,
D  )

Definition at line 2191 of file pugixml.cc.

2192 {
2193 const typename D::type* data = static_cast<const typename D::type*>(contents);
2194 size_t data_length = size / sizeof(typename D::type);
2195
2196 // first pass: get length in utf8 units
2197 size_t length = D::process(data, data_length, 0, utf8_counter());
2198
2199 // allocate buffer of suitable length
2200 char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
2201 if (!buffer) return false;
2202
2203 // second pass: convert utf16 input to utf8
2204 uint8_t* obegin = reinterpret_cast<uint8_t*>(buffer);
2205 uint8_t* oend = D::process(data, data_length, obegin, utf8_writer());
2206
2207 assert(oend == obegin + length);
2208 *oend = 0;
2209
2210 out_buffer = buffer;
2211 out_length = length + 1;
2212
2213 return true;
2214 }
PUGIXML_CHAR char_t
Definition pugixml.hpp:137
static allocation_function allocate
Definition pugixml.cc:199

Referenced by convert_buffer().

◆ 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 2225 of file pugixml.cc.

2226 {
2227 const uint8_t* data = static_cast<const uint8_t*>(contents);
2228 size_t data_length = size;
2229
2230 // get size of prefix that does not need utf8 conversion
2231 size_t prefix_length = get_latin1_7bit_prefix_length(data, data_length);
2232 assert(prefix_length <= data_length);
2233
2234 const uint8_t* postfix = data + prefix_length;
2235 size_t postfix_length = data_length - prefix_length;
2236
2237 // if no conversion is needed, just return the original buffer
2238 if (postfix_length == 0) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable);
2239
2240 // first pass: get length in utf8 units
2241 size_t length = prefix_length + latin1_decoder::process(postfix, postfix_length, 0, utf8_counter());
2242
2243 // allocate buffer of suitable length
2244 char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
2245 if (!buffer) return false;
2246
2247 // second pass: convert latin1 input to utf8
2248 memcpy(buffer, data, prefix_length);
2249
2250 uint8_t* obegin = reinterpret_cast<uint8_t*>(buffer);
2251 uint8_t* oend = latin1_decoder::process(postfix, postfix_length, obegin + prefix_length, utf8_writer());
2252
2253 assert(oend == obegin + length);
2254 *oend = 0;
2255
2256 out_buffer = buffer;
2257 out_length = length + 1;
2258
2259 return true;
2260 }
PUGI__FN size_t get_latin1_7bit_prefix_length(const uint8_t *data, size_t size)
Definition pugixml.cc:2216
static Traits::value_type process(const uint8_t *data, size_t size, typename Traits::value_type result, Traits)
Definition pugixml.cc:1789

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 3685 of file pugixml.cc.

3686 {
3687 if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
3688 {
3690
3691 return convert_buffer_output_generic(r_u16, data, length, utf8_decoder(), utf16_writer(), native_encoding != encoding);
3692 }
3693
3694 if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
3695 {
3697
3698 return convert_buffer_output_generic(r_u32, data, length, utf8_decoder(), utf32_writer(), native_encoding != encoding);
3699 }
3700
3701 if (encoding == encoding_latin1)
3702 return convert_buffer_output_generic(r_u8, data, length, utf8_decoder(), latin1_writer());
3703
3704 assert(false && "Invalid encoding"); // unreachable
3705 return 0;
3706 }
PUGI__FN size_t convert_buffer_output_generic(typename T::value_type dest, const char_t *data, size_t length, D, T)
Definition pugixml.cc:3598

Referenced by xml_buffered_writer::flush().

◆ convert_buffer_output_generic() [1/2]

template<typename D, typename T>
PUGI__FN size_t convert_buffer_output_generic ( typename T::value_type dest,
const char_t * data,
size_t length,
D ,
T  )

Definition at line 3598 of file pugixml.cc.

3599 {
3600 PUGI__STATIC_ASSERT(sizeof(char_t) == sizeof(typename D::type));
3601
3602 typename T::value_type end = D::process(reinterpret_cast<const typename D::type*>(data), length, dest, T());
3603
3604 return static_cast<size_t>(end - dest) * sizeof(*dest);
3605 }
#define PUGI__STATIC_ASSERT(cond)
Definition pugixml.cc:100

Referenced by convert_buffer_output().

◆ convert_buffer_output_generic() [2/2]

template<typename D, typename T>
PUGI__FN size_t convert_buffer_output_generic ( typename T::value_type dest,
const char_t * data,
size_t length,
D ,
T ,
bool opt_swap )

Definition at line 3607 of file pugixml.cc.

3608 {
3609 PUGI__STATIC_ASSERT(sizeof(char_t) == sizeof(typename D::type));
3610
3611 typename T::value_type end = D::process(reinterpret_cast<const typename D::type*>(data), length, dest, T());
3612
3613 if (opt_swap)
3614 {
3615 for (typename T::value_type i = dest; i != end; ++i)
3616 *i = endian_swap(*i);
3617 }
3618
3619 return static_cast<size_t>(end - dest) * sizeof(*dest);
3620 }
PUGI__NS_END PUGI__NS_BEGIN uint16_t endian_swap(uint16_t value)
Definition pugixml.cc:1455

◆ convert_number_to_boolean()

PUGI__FN bool convert_number_to_boolean ( double value)

Definition at line 8391 of file pugixml.cc.

8392 {
8393 return (value != 0 && !is_nan(value));
8394 }
PUGI__FN bool is_nan(double value)
Definition pugixml.cc:8346

Referenced by xpath_ast_node::eval_boolean().

◆ convert_number_to_mantissa_exponent()

PUGI__FN void convert_number_to_mantissa_exponent ( double value,
char(&) buffer[32],
char ** out_mantissa,
int * out_exponent )

Definition at line 8419 of file pugixml.cc.

8420 {
8421 // get a scientific notation value with IEEE DBL_DIG decimals
8422 PUGI__SNPRINTF(buffer, "%.*e", DBL_DIG, value);
8423
8424 // get the exponent (possibly negative)
8425 char* exponent_string = strchr(buffer, 'e');
8426 assert(exponent_string);
8427
8428 int exponent = atoi(exponent_string + 1);
8429
8430 // extract mantissa string: skip sign
8431 char* mantissa = buffer[0] == '-' ? buffer + 1 : buffer;
8432 assert(mantissa[0] != '0' && mantissa[1] == '.');
8433
8434 // divide mantissa by 10 to eliminate integer part
8435 mantissa[1] = mantissa[0];
8436 mantissa++;
8437 exponent++;
8438
8439 // remove extra mantissa digits and zero-terminate mantissa
8440 truncate_zeros(mantissa, exponent_string);
8441
8442 // fill results
8443 *out_mantissa = mantissa;
8444 *out_exponent = exponent;
8445 }
#define PUGI__SNPRINTF
Definition pugixml.cc:147
PUGI__FN void truncate_zeros(char *begin, char *end)
Definition pugixml.cc:8396
#define DBL_DIG
Definition templates.hh:58

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 8448 of file pugixml.cc.

8449 {
8450 // try special number conversion
8451 const char_t* special = convert_number_to_string_special(value);
8452 if (special) return xpath_string::from_const(special);
8453
8454 // get mantissa + exponent form
8455 char mantissa_buffer[32];
8456
8457 char* mantissa;
8458 int exponent;
8459 convert_number_to_mantissa_exponent(value, mantissa_buffer, &mantissa, &exponent);
8460
8461 // allocate a buffer of suitable length for the number
8462 size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4;
8463 char_t* result = static_cast<char_t*>(alloc->allocate(sizeof(char_t) * result_size));
8464 if (!result) return xpath_string();
8465
8466 // make the number!
8467 char_t* s = result;
8468
8469 // sign
8470 if (value < 0) *s++ = '-';
8471
8472 // integer part
8473 if (exponent <= 0)
8474 {
8475 *s++ = '0';
8476 }
8477 else
8478 {
8479 while (exponent > 0)
8480 {
8481 assert(*mantissa == 0 || static_cast<unsigned int>(*mantissa - '0') <= 9);
8482 *s++ = *mantissa ? *mantissa++ : '0';
8483 exponent--;
8484 }
8485 }
8486
8487 // fractional part
8488 if (*mantissa)
8489 {
8490 // decimal point
8491 *s++ = '.';
8492
8493 // extra zeroes from negative exponent
8494 while (exponent < 0)
8495 {
8496 *s++ = '0';
8497 exponent++;
8498 }
8499
8500 // extra mantissa digits
8501 while (*mantissa)
8502 {
8503 assert(static_cast<unsigned int>(*mantissa - '0') <= 9);
8504 *s++ = *mantissa++;
8505 }
8506 }
8507
8508 // zero-terminate
8509 assert(s < result + result_size);
8510 *s = 0;
8511
8512 return xpath_string::from_heap_preallocated(result, s);
8513 }
static xpath_string from_heap_preallocated(const char_t *begin, const char_t *end)
Definition pugixml.cc:7972
static xpath_string from_const(const char_t *str)
Definition pugixml.cc:7967
PUGI__FN const char_t * convert_number_to_string_special(double value)
Definition pugixml.cc:8359
PUGI__FN void convert_number_to_mantissa_exponent(double value, char(&buffer)[32], char **out_mantissa, int *out_exponent)
Definition pugixml.cc:8419
void * allocate(size_t size)
Definition pugixml.cc:7778

Referenced by xpath_ast_node::eval_string().

◆ convert_number_to_string_special()

PUGI__FN const char_t * convert_number_to_string_special ( double value)

Definition at line 8359 of file pugixml.cc.

8360 {
8361 #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__)
8362 if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0;
8363 if (_isnan(value)) return PUGIXML_TEXT("NaN");
8364 return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");
8365 #elif defined(fpclassify) && defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO)
8366 switch (fpclassify(value))
8367 {
8368 case FP_NAN:
8369 return PUGIXML_TEXT("NaN");
8370
8371 case FP_INFINITE:
8372 return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");
8373
8374 case FP_ZERO:
8375 return PUGIXML_TEXT("0");
8376
8377 default:
8378 return 0;
8379 }
8380 #else
8381 // fallback
8382 const volatile double v = value;
8383
8384 if (v == 0) return PUGIXML_TEXT("0");
8385 if (v != v) return PUGIXML_TEXT("NaN");
8386 if (v * 2 == v) return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");
8387 return 0;
8388 #endif
8389 }
#define PUGIXML_TEXT(t)
Definition pugixml.hpp:130

Referenced by convert_number_to_string().

◆ convert_path_heap()

PUGI__FN char * convert_path_heap ( const wchar_t * str)

Definition at line 5015 of file pugixml.cc.

5016 {
5017 assert(str);
5018
5019 // first pass: get length in utf8 characters
5020 size_t length = strlength_wide(str);
5021 size_t size = as_utf8_begin(str, length);
5022
5023 // allocate resulting string
5024 char* result = static_cast<char*>(xml_memory::allocate(size + 1));
5025 if (!result) return 0;
5026
5027 // second pass: convert to utf8
5028 as_utf8_end(result, size, str, length);
5029
5030 // zero-terminate
5031 result[size] = 0;
5032
5033 return result;
5034 }
PUGI__FN size_t strlength_wide(const wchar_t *s)
Definition pugixml.cc:248

Referenced by open_file_wide().

◆ convert_string_to_number()

PUGI__FN double convert_string_to_number ( const char_t * string)

Definition at line 8545 of file pugixml.cc.

8546 {
8547 // check string format
8548 if (!check_string_to_number_format(string)) return gen_nan();
8549
8550 // parse string
8551 #ifdef PUGIXML_WCHAR_MODE
8552 return wcstod(string, 0);
8553 #else
8554 return strtod(string, 0);
8555 #endif
8556 }
PUGI__FN double gen_nan()
Definition pugixml.cc:8331
PUGI__FN bool check_string_to_number_format(const char_t *string)
Definition pugixml.cc:8515

Referenced by 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 8558 of file pugixml.cc.

8559 {
8560 size_t length = static_cast<size_t>(end - begin);
8561 char_t* scratch = buffer;
8562
8563 if (length >= sizeof(buffer) / sizeof(buffer[0]))
8564 {
8565 // need to make dummy on-heap copy
8566 scratch = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
8567 if (!scratch) return false;
8568 }
8569
8570 // copy string to zero-terminated buffer and perform conversion
8571 memcpy(scratch, begin, length * sizeof(char_t));
8572 scratch[length] = 0;
8573
8574 *out_result = convert_string_to_number(scratch);
8575
8576 // free dummy buffer
8577 if (scratch != buffer) xml_memory::deallocate(scratch);
8578
8579 return true;
8580 }
PUGI__FN double convert_string_to_number(const char_t *string)
Definition pugixml.cc:8545
static deallocation_function deallocate
Definition pugixml.cc:200

Referenced by xpath_parser::parse_primary_expression().

◆ copy_xpath_variable()

PUGI__FN bool copy_xpath_variable ( xpath_variable * lhs,
const xpath_variable * rhs )

Definition at line 8925 of file pugixml.cc.

8926 {
8927 switch (rhs->type())
8928 {
8930 return lhs->set(static_cast<const xpath_variable_node_set*>(rhs)->value);
8931
8932 case xpath_type_number:
8933 return lhs->set(static_cast<const xpath_variable_number*>(rhs)->value);
8934
8935 case xpath_type_string:
8936 return lhs->set(static_cast<const xpath_variable_string*>(rhs)->value);
8937
8938 case xpath_type_boolean:
8939 return lhs->set(static_cast<const xpath_variable_boolean*>(rhs)->value);
8940
8941 default:
8942 assert(false && "Invalid variable type"); // unreachable
8943 return false;
8944 }
8945 }
@ xpath_type_number
Definition pugixml.hpp:1113
@ xpath_type_boolean
Definition pugixml.hpp:1115
@ xpath_type_string
Definition pugixml.hpp:1114
@ xpath_type_node_set
Definition pugixml.hpp:1112

◆ default_allocate()

PUGI__NS_BEGIN PUGI__FN void * default_allocate ( size_t size)

Definition at line 186 of file pugixml.cc.

187 {
188 return malloc(size);
189 }
voidp malloc(uInt size)

◆ default_deallocate()

PUGI__FN void default_deallocate ( void * ptr)

Definition at line 191 of file pugixml.cc.

192 {
193 free(ptr);
194 }
void free(voidpf ptr)

◆ delete_xpath_variable() [1/2]

template<typename T>
PUGI__FN void delete_xpath_variable ( T * var)

Definition at line 8894 of file pugixml.cc.

8895 {
8896 var->~T();
8898 }

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 8900 of file pugixml.cc.

8901 {
8902 switch (type)
8903 {
8906 break;
8907
8908 case xpath_type_number:
8909 delete_xpath_variable(static_cast<xpath_variable_number*>(var));
8910 break;
8911
8912 case xpath_type_string:
8913 delete_xpath_variable(static_cast<xpath_variable_string*>(var));
8914 break;
8915
8916 case xpath_type_boolean:
8918 break;
8919
8920 default:
8921 assert(false && "Invalid variable type"); // unreachable
8922 }
8923 }
PUGI__FN void delete_xpath_variable(T *var)
Definition pugixml.cc:8894

◆ destroy_attribute()

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

Definition at line 1194 of file pugixml.cc.

1195 {
1196 if (a->header & impl::xml_memory_page_name_allocated_mask)
1197 alloc.deallocate_string(a->name);
1198
1199 if (a->header & impl::xml_memory_page_value_allocated_mask)
1200 alloc.deallocate_string(a->value);
1201
1202 alloc.deallocate_memory(a, sizeof(xml_attribute_struct), PUGI__GETPAGE(a));
1203 }
#define PUGI__GETPAGE(n)
Definition pugixml.cc:455
void deallocate_memory(void *ptr, size_t size, xml_memory_page *page)
Definition pugixml.cc:596
void deallocate_string(char_t *string)
Definition pugixml.cc:674

Referenced by destroy_node().

◆ destroy_node()

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

Definition at line 1205 of file pugixml.cc.

1206 {
1207 if (n->header & impl::xml_memory_page_name_allocated_mask)
1208 alloc.deallocate_string(n->name);
1209
1210 if (n->header & impl::xml_memory_page_value_allocated_mask)
1211 alloc.deallocate_string(n->value);
1212
1213 for (xml_attribute_struct* attr = n->first_attribute; attr; )
1214 {
1215 xml_attribute_struct* next = attr->next_attribute;
1216
1217 destroy_attribute(attr, alloc);
1218
1219 attr = next;
1220 }
1221
1222 for (xml_node_struct* child = n->first_child; child; )
1223 {
1224 xml_node_struct* next = child->next_sibling;
1225
1226 destroy_node(child, alloc);
1227
1228 child = next;
1229 }
1230
1231 alloc.deallocate_memory(n, sizeof(xml_node_struct), PUGI__GETPAGE(n));
1232 }
void destroy_node(xml_node_struct *n, xml_allocator &alloc)
Definition pugixml.cc:1205
void destroy_attribute(xml_attribute_struct *a, xml_allocator &alloc)
Definition pugixml.cc:1194

Referenced by destroy_node().

◆ document_buffer_order()

PUGI__FN const void * document_buffer_order ( const xpath_node & xnode)

Definition at line 8246 of file pugixml.cc.

8247 {
8248 xml_node_struct* node = xnode.node().internal_object();
8249
8250 if (node)
8251 {
8252 if ((get_document(node).header & xml_memory_page_contents_shared_mask) == 0)
8253 {
8254 if (node->name && (node->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return node->name;
8255 if (node->value && (node->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return node->value;
8256 }
8257
8258 return 0;
8259 }
8260
8261 xml_attribute_struct* attr = xnode.attribute().internal_object();
8262
8263 if (attr)
8264 {
8265 if ((get_document(attr).header & xml_memory_page_contents_shared_mask) == 0)
8266 {
8267 if ((attr->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return attr->name;
8268 if ((attr->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return attr->value;
8269 }
8270
8271 return 0;
8272 }
8273
8274 return 0;
8275 }
xml_document_struct & get_document(const Object *object)
Definition pugixml.cc:1166

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 1455 of file pugixml.cc.

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

Referenced by convert_buffer_output_generic(), utf16_decoder< opt_false >::process(), and utf32_decoder< opt_false >::process().

◆ endian_swap() [2/2]

uint32_t endian_swap ( uint32_t value)
inline

Definition at line 1460 of file pugixml.cc.

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

◆ evaluate_node_set_prepare()

PUGI__FN impl::xpath_ast_node * evaluate_node_set_prepare ( xpath_query_impl * impl)

Definition at line 12283 of file pugixml.cc.

12284 {
12285 if (!impl) return 0;
12286
12287 if (impl->root->rettype() != xpath_type_node_set)
12288 {
12289 #ifdef PUGIXML_NO_EXCEPTIONS
12290 return 0;
12291 #else
12292 xpath_parse_result res;
12293 res.error = "Expression does not evaluate to node set";
12294
12295 throw xpath_exception(res);
12296 #endif
12297 }
12298
12299 return impl->root;
12300 }
xpath_value_type rettype() const
Definition pugixml.cc:11291
xpath_ast_node * root
Definition pugixml.cc:12277

◆ find_char()

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

Definition at line 8093 of file pugixml.cc.

8094 {
8095 #ifdef PUGIXML_WCHAR_MODE
8096 return wcschr(s, c);
8097 #else
8098 return strchr(s, c);
8099 #endif
8100 }

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

◆ find_substring()

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

Definition at line 8102 of file pugixml.cc.

8103 {
8104 #ifdef PUGIXML_WCHAR_MODE
8105 // MSVC6 wcsstr bug workaround (if s is empty it always returns 0)
8106 return (*p == 0) ? s : wcsstr(s, p);
8107 #else
8108 return strstr(s, p);
8109 #endif
8110 }

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

◆ gen_nan()

PUGI__FN double gen_nan ( )

Definition at line 8331 of file pugixml.cc.

8332 {
8333 #if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24))
8334 PUGI__STATIC_ASSERT(sizeof(float) == sizeof(uint32_t));
8335 typedef uint32_t UI; // BCC5 workaround
8336 union { float f; UI i; } u;
8337 u.i = 0x7fc00000;
8338 return double(u.f);
8339 #else
8340 // fallback
8341 const volatile double zero = 0.0;
8342 return zero / zero;
8343 #endif
8344 }

Referenced by convert_string_to_number().

◆ get_allocator()

template<typename Object>
xml_allocator & get_allocator ( const Object * object)
inline

Definition at line 1159 of file pugixml.cc.

1160 {
1161 assert(object);
1162
1163 return *PUGI__GETPAGE(object)->allocator;
1164 }

Referenced by node_copy_attribute(), node_copy_contents(), and node_copy_tree().

◆ get_buffer_encoding()

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

Definition at line 2037 of file pugixml.cc.

2038 {
2039 // replace wchar encoding with utf implementation
2040 if (encoding == encoding_wchar) return get_wchar_encoding();
2041
2042 // replace utf16 encoding with utf16 with specific endianness
2043 if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
2044
2045 // replace utf32 encoding with utf32 with specific endianness
2046 if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
2047
2048 // only do autodetection if no explicit encoding is requested
2049 if (encoding != encoding_auto) return encoding;
2050
2051 // try to guess encoding (based on XML specification, Appendix F.1)
2052 const uint8_t* data = static_cast<const uint8_t*>(contents);
2053
2054 return guess_buffer_encoding(data, size);
2055 }
PUGI__FN xml_encoding get_wchar_encoding()
Definition pugixml.cc:1925
PUGI__FN xml_encoding guess_buffer_encoding(const uint8_t *data, size_t size)
Definition pugixml.cc:1989

Referenced by load_file_impl(), and load_stream_impl().

◆ get_document()

template<typename Object>
xml_document_struct & get_document ( const Object * object)
inline

Definition at line 1166 of file pugixml.cc.

1167 {
1168 assert(object);
1169
1170 return *static_cast<xml_document_struct*>(PUGI__GETPAGE(object)->allocator);
1171 }

Referenced by document_buffer_order().

◆ get_file_size()

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

Definition at line 4756 of file pugixml.cc.

4757 {
4758 #if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
4759 // there are 64-bit versions of fseek/ftell, let's use them
4760 typedef __int64 length_type;
4761
4762 _fseeki64(file, 0, SEEK_END);
4763 length_type length = _ftelli64(file);
4764 _fseeki64(file, 0, SEEK_SET);
4765 #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))
4766 // there are 64-bit versions of fseek/ftell, let's use them
4767 typedef off64_t length_type;
4768
4769 fseeko64(file, 0, SEEK_END);
4770 length_type length = ftello64(file);
4771 fseeko64(file, 0, SEEK_SET);
4772 #else
4773 // 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.
4774 typedef long length_type;
4775
4776 fseek(file, 0, SEEK_END);
4777 length_type length = ftell(file);
4778 fseek(file, 0, SEEK_SET);
4779 #endif
4780
4781 // check for I/O errors
4782 if (length < 0) return status_io_error;
4783
4784 // check for overflow
4785 size_t result = static_cast<size_t>(length);
4786
4787 if (static_cast<length_type>(result) != length) return status_out_of_memory;
4788
4789 // finalize
4790 out_result = result;
4791
4792 return status_ok;
4793 }
@ status_io_error
Definition pugixml.hpp:985
@ status_ok
Definition pugixml.hpp:982
@ status_out_of_memory
Definition pugixml.hpp:986

Referenced by load_file_impl().

◆ get_latin1_7bit_prefix_length()

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

Definition at line 2216 of file pugixml.cc.

2217 {
2218 for (size_t i = 0; i < size; ++i)
2219 if (data[i] > 127)
2220 return i;
2221
2222 return size;
2223 }

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 2057 of file pugixml.cc.

2058 {
2059 size_t length = size / sizeof(char_t);
2060
2061 if (is_mutable)
2062 {
2063 out_buffer = static_cast<char_t*>(const_cast<void*>(contents));
2064 out_length = length;
2065 }
2066 else
2067 {
2068 char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
2069 if (!buffer) return false;
2070
2071 if (contents)
2072 memcpy(buffer, contents, length * sizeof(char_t));
2073 else
2074 assert(length == 0);
2075
2076 buffer[length] = 0;
2077
2078 out_buffer = buffer;
2079 out_length = length + 1;
2080 }
2081
2082 return true;
2083 }

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 2894 of file pugixml.cc.

2895 {
2896 PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80);
2897
2898 switch ((optmask >> 4) & 15) // get bitmask for flags (wnorm wconv eol escapes); this simultaneously checks 4 options from assertion above
2899 {
2916 default: assert(false); return 0; // unreachable
2917 }
2918 }
static char_t * parse_eol(char_t *s, char_t end_quote)
Definition pugixml.cc:2835
static char_t * parse_simple(char_t *s, char_t end_quote)
Definition pugixml.cc:2867
static char_t * parse_wnorm(char_t *s, char_t end_quote)
Definition pugixml.cc:2747
static char_t * parse_wconv(char_t *s, char_t end_quote)
Definition pugixml.cc:2799

Referenced by xml_parser::parse_tree().

◆ get_strconv_pcdata()

PUGI__FN strconv_pcdata_t get_strconv_pcdata ( unsigned int optmask)

Definition at line 2725 of file pugixml.cc.

2726 {
2727 PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800);
2728
2729 switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (trim eol escapes); this simultaneously checks 3 options from assertion above
2730 {
2739 default: assert(false); return 0; // unreachable
2740 }
2741 }
static char_t * parse(char_t *s)
Definition pugixml.cc:2676

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 3669 of file pugixml.cc.

3670 {
3671 if (length < 5) return 0;
3672
3673 for (size_t i = 1; i <= 4; ++i)
3674 {
3675 uint8_t ch = static_cast<uint8_t>(data[length - i]);
3676
3677 // either a standalone character or a leading one
3678 if ((ch & 0xc0) != 0x80) return length - i;
3679 }
3680
3681 // there are four non-leading characters at the end, sequence tail is broken so might as well process the whole chunk
3682 return length;
3683 }

Referenced by xml_buffered_writer::write_direct(), and xml_buffered_writer::write_string().

◆ get_value_bool()

PUGI__FN bool get_value_bool ( const char_t * value)

Definition at line 4624 of file pugixml.cc.

4625 {
4626 // only look at first char
4627 char_t first = *value;
4628
4629 // 1*, t* (true), T* (True), y* (yes), Y* (YES)
4630 return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y');
4631 }

◆ get_value_double()

PUGI__FN double get_value_double ( const char_t * value)

Definition at line 4606 of file pugixml.cc.

4607 {
4608 #ifdef PUGIXML_WCHAR_MODE
4609 return wcstod(value, 0);
4610 #else
4611 return strtod(value, 0);
4612 #endif
4613 }

◆ get_value_float()

PUGI__FN float get_value_float ( const char_t * value)

Definition at line 4615 of file pugixml.cc.

4616 {
4617 #ifdef PUGIXML_WCHAR_MODE
4618 return static_cast<float>(wcstod(value, 0));
4619 #else
4620 return static_cast<float>(strtod(value, 0));
4621 #endif
4622 }

◆ get_value_int()

PUGI__FN int get_value_int ( const char_t * value)

Definition at line 4596 of file pugixml.cc.

4597 {
4598 return string_to_integer<unsigned int>(value, static_cast<unsigned int>(INT_MIN), INT_MAX);
4599 }
PUGI__FN PUGI__UNSIGNED_OVERFLOW U string_to_integer(const char_t *value, U minv, U maxv)
Definition pugixml.cc:4514
#define INT_MIN
Definition templates.hh:94
#define INT_MAX
Definition templates.hh:90

◆ get_value_uint()

PUGI__FN unsigned int get_value_uint ( const char_t * value)

Definition at line 4601 of file pugixml.cc.

4602 {
4603 return string_to_integer<unsigned int>(value, 0, UINT_MAX);
4604 }

◆ get_variable_scratch()

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

Definition at line 8947 of file pugixml.cc.

8948 {
8949 size_t length = static_cast<size_t>(end - begin);
8950 char_t* scratch = buffer;
8951
8952 if (length >= sizeof(buffer) / sizeof(buffer[0]))
8953 {
8954 // need to make dummy on-heap copy
8955 scratch = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
8956 if (!scratch) return false;
8957 }
8958
8959 // copy string to zero-terminated buffer and perform lookup
8960 memcpy(scratch, begin, length * sizeof(char_t));
8961 scratch[length] = 0;
8962
8963 *out_result = set->get(scratch);
8964
8965 // free dummy buffer
8966 if (scratch != buffer) xml_memory::deallocate(scratch);
8967
8968 return true;
8969 }

Referenced by xpath_parser::parse_primary_expression().

◆ get_wchar_encoding()

PUGI__FN xml_encoding get_wchar_encoding ( )

Definition at line 1925 of file pugixml.cc.

1926 {
1927 PUGI__STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4);
1928
1929 if (sizeof(wchar_t) == 2)
1931 else
1933 }

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 3580 of file pugixml.cc.

3581 {
3582 // replace wchar encoding with utf implementation
3583 if (encoding == encoding_wchar) return get_wchar_encoding();
3584
3585 // replace utf16 encoding with utf16 with specific endianness
3586 if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
3587
3588 // replace utf32 encoding with utf32 with specific endianness
3589 if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
3590
3591 // only do autodetection if no explicit encoding is requested
3592 if (encoding != encoding_auto) return encoding;
3593
3594 // assume utf8 encoding
3595 return encoding_utf8;
3596 }
@ encoding_utf8
Definition pugixml.hpp:230

Referenced by xml_buffered_writer::xml_buffered_writer().

◆ get_write_native_encoding()

PUGI__FN xml_encoding get_write_native_encoding ( )

Definition at line 3571 of file pugixml.cc.

3572 {
3573 #ifdef PUGIXML_WCHAR_MODE
3574 return get_wchar_encoding();
3575 #else
3576 return encoding_utf8;
3577 #endif
3578 }

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

◆ guess_buffer_encoding()

PUGI__FN xml_encoding guess_buffer_encoding ( const uint8_t * data,
size_t size )

Definition at line 1989 of file pugixml.cc.

1990 {
1991 // skip encoding autodetection if input buffer is too small
1992 if (size < 4) return encoding_utf8;
1993
1994 uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3];
1995
1996 // look for BOM in first few bytes
1997 if (d0 == 0 && d1 == 0 && d2 == 0xfe && d3 == 0xff) return encoding_utf32_be;
1998 if (d0 == 0xff && d1 == 0xfe && d2 == 0 && d3 == 0) return encoding_utf32_le;
1999 if (d0 == 0xfe && d1 == 0xff) return encoding_utf16_be;
2000 if (d0 == 0xff && d1 == 0xfe) return encoding_utf16_le;
2001 if (d0 == 0xef && d1 == 0xbb && d2 == 0xbf) return encoding_utf8;
2002
2003 // look for <, <? or <?xm in various encodings
2004 if (d0 == 0 && d1 == 0 && d2 == 0 && d3 == 0x3c) return encoding_utf32_be;
2005 if (d0 == 0x3c && d1 == 0 && d2 == 0 && d3 == 0) return encoding_utf32_le;
2006 if (d0 == 0 && d1 == 0x3c && d2 == 0 && d3 == 0x3f) return encoding_utf16_be;
2007 if (d0 == 0x3c && d1 == 0 && d2 == 0x3f && d3 == 0) return encoding_utf16_le;
2008
2009 // look for utf16 < followed by node name (this may fail, but is better than utf8 since it's zero terminated so early)
2010 if (d0 == 0 && d1 == 0x3c) return encoding_utf16_be;
2011 if (d0 == 0x3c && d1 == 0) return encoding_utf16_le;
2012
2013 // no known BOM detected; parse declaration
2014 const uint8_t* enc = 0;
2015 size_t enc_length = 0;
2016
2017 if (d0 == 0x3c && d1 == 0x3f && d2 == 0x78 && d3 == 0x6d && parse_declaration_encoding(data, size, enc, enc_length))
2018 {
2019 // iso-8859-1 (case-insensitive)
2020 if (enc_length == 10
2021 && (enc[0] | ' ') == 'i' && (enc[1] | ' ') == 's' && (enc[2] | ' ') == 'o'
2022 && enc[3] == '-' && enc[4] == '8' && enc[5] == '8' && enc[6] == '5' && enc[7] == '9'
2023 && enc[8] == '-' && enc[9] == '1')
2024 return encoding_latin1;
2025
2026 // latin1 (case-insensitive)
2027 if (enc_length == 6
2028 && (enc[0] | ' ') == 'l' && (enc[1] | ' ') == 'a' && (enc[2] | ' ') == 't'
2029 && (enc[3] | ' ') == 'i' && (enc[4] | ' ') == 'n'
2030 && enc[5] == '1')
2031 return encoding_latin1;
2032 }
2033
2034 return encoding_utf8;
2035 }
@ encoding_latin1
Definition pugixml.hpp:238
PUGI__FN bool parse_declaration_encoding(const uint8_t *data, size_t size, const uint8_t *&out_encoding, size_t &out_length)
Definition pugixml.cc:1935

Referenced by get_buffer_encoding().

◆ has_declaration()

PUGI__FN bool has_declaration ( xml_node_struct * node)

Definition at line 4346 of file pugixml.cc.

4347 {
4348 for (xml_node_struct* child = node->first_child; child; child = child->next_sibling)
4349 {
4350 xml_node_type type = PUGI__NODETYPE(child);
4351
4352 if (type == node_declaration) return true;
4353 if (type == node_element) return false;
4354 }
4355
4356 return false;
4357 }
xml_node_type
Definition pugixml.hpp:150
#define PUGI__NODETYPE(n)
Definition pugixml.cc:456

◆ hash_insert()

PUGI__FN bool hash_insert ( const void ** table,
size_t size,
const void * key )

Definition at line 7708 of file pugixml.cc.

7709 {
7710 assert(key);
7711
7712 unsigned int h = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(key));
7713
7714 // MurmurHash3 32-bit finalizer
7715 h ^= h >> 16;
7716 h *= 0x85ebca6bu;
7717 h ^= h >> 13;
7718 h *= 0xc2b2ae35u;
7719 h ^= h >> 16;
7720
7721 size_t hashmod = size - 1;
7722 size_t bucket = h & hashmod;
7723
7724 for (size_t probe = 0; probe <= hashmod; ++probe)
7725 {
7726 if (table[bucket] == 0)
7727 {
7728 table[bucket] = key;
7729 return true;
7730 }
7731
7732 if (table[bucket] == key)
7733 return false;
7734
7735 // hash collision, quadratic probing
7736 bucket = (bucket + probe + 1) & hashmod;
7737 }
7738
7739 assert(false && "Hash table is full"); // unreachable
7740 return false;
7741 }

Referenced by xpath_node_set_raw::remove_duplicates().

◆ hash_string()

PUGI__FN PUGI__UNSIGNED_OVERFLOW unsigned int hash_string ( const char_t * str)

Definition at line 8838 of file pugixml.cc.

8839 {
8840 // Jenkins one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time)
8841 unsigned int result = 0;
8842
8843 while (*str)
8844 {
8845 result += static_cast<unsigned int>(*str++);
8846 result += result << 10;
8847 result ^= result >> 6;
8848 }
8849
8850 result += result << 3;
8851 result ^= result >> 11;
8852 result += result << 15;
8853
8854 return result;
8855 }

◆ insert_attribute_after()

void insert_attribute_after ( xml_attribute_struct * attr,
xml_attribute_struct * place,
xml_node_struct * node )
inline

Definition at line 1368 of file pugixml.cc.

1369 {
1370 xml_attribute_struct* next = place->next_attribute;
1371
1372 if (next)
1373 next->prev_attribute_c = attr;
1374 else
1375 node->first_attribute->prev_attribute_c = attr;
1376
1377 attr->next_attribute = next;
1378 attr->prev_attribute_c = place;
1379 place->next_attribute = attr;
1380 }

◆ insert_attribute_before()

void insert_attribute_before ( xml_attribute_struct * attr,
xml_attribute_struct * place,
xml_node_struct * node )
inline

Definition at line 1382 of file pugixml.cc.

1383 {
1384 xml_attribute_struct* prev = place->prev_attribute_c;
1385
1386 if (prev->next_attribute)
1387 prev->next_attribute = attr;
1388 else
1389 node->first_attribute = attr;
1390
1391 attr->prev_attribute_c = prev;
1392 attr->next_attribute = place;
1393 place->prev_attribute_c = attr;
1394 }

◆ insert_node_after()

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

Definition at line 1273 of file pugixml.cc.

1274 {
1275 xml_node_struct* parent = node->parent;
1276
1277 child->parent = parent;
1278
1279 xml_node_struct* next = node->next_sibling;
1280
1281 if (next)
1282 next->prev_sibling_c = child;
1283 else
1284 parent->first_child->prev_sibling_c = child;
1285
1286 child->next_sibling = next;
1287 child->prev_sibling_c = node;
1288
1289 node->next_sibling = child;
1290 }

◆ insert_node_before()

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

Definition at line 1292 of file pugixml.cc.

1293 {
1294 xml_node_struct* parent = node->parent;
1295
1296 child->parent = parent;
1297
1298 xml_node_struct* prev = node->prev_sibling_c;
1299
1300 if (prev->next_sibling)
1301 prev->next_sibling = child;
1302 else
1303 parent->first_child = child;
1304
1305 child->prev_sibling_c = prev;
1306 child->next_sibling = node;
1307
1308 node->prev_sibling_c = child;
1309 }

◆ insertion_sort()

template<typename T, typename Pred>
PUGI__FN void insertion_sort ( T * begin,
T * end,
const Pred & pred )

Definition at line 7617 of file pugixml.cc.

7618 {
7619 if (begin == end)
7620 return;
7621
7622 for (T* it = begin + 1; it != end; ++it)
7623 {
7624 T val = *it;
7625 T* hole = it;
7626
7627 // move hole backwards
7628 while (hole > begin && pred(val, *(hole - 1)))
7629 {
7630 *hole = *(hole - 1);
7631 hole--;
7632 }
7633
7634 // fill hole with element
7635 *hole = val;
7636 }
7637 }

Referenced by sort().

◆ integer_to_string()

template<typename U>
PUGI__FN PUGI__UNSIGNED_OVERFLOW char_t * integer_to_string ( char_t * begin,
char_t * end,
U value,
bool negative )

Definition at line 4645 of file pugixml.cc.

4646 {
4647 char_t* result = end - 1;
4648 U rest = negative ? 0 - value : value;
4649
4650 do
4651 {
4652 *result-- = static_cast<char_t>('0' + (rest % 10));
4653 rest /= 10;
4654 }
4655 while (rest);
4656
4657 assert(result >= begin);
4658 (void)begin;
4659
4660 *result = '-';
4661
4662 return result + !negative;
4663 }

Referenced by set_value_integer().

◆ is_attribute_of()

PUGI__FN bool is_attribute_of ( xml_attribute_struct * attr,
xml_node_struct * node )

Definition at line 4359 of file pugixml.cc.

4360 {
4361 for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute)
4362 if (a == attr)
4363 return true;
4364
4365 return false;
4366 }

◆ is_little_endian()

PUGI__FN bool is_little_endian ( )

Definition at line 1918 of file pugixml.cc.

1919 {
1920 unsigned int ui = 1;
1921
1922 return *reinterpret_cast<unsigned char*>(&ui) == 1;
1923 }

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 8346 of file pugixml.cc.

8347 {
8348 #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__)
8349 return !!_isnan(value);
8350 #elif defined(fpclassify) && defined(FP_NAN)
8351 return fpclassify(value) == FP_NAN;
8352 #else
8353 // fallback
8354 const volatile double v = value;
8355 return v != v;
8356 #endif
8357 }

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 4506 of file pugixml.cc.

4507 {
4508 xml_node_type type = PUGI__NODETYPE(node);
4509
4510 return type == node_pcdata || type == node_cdata;
4511 }
@ node_pcdata
Definition pugixml.hpp:154
@ node_cdata
Definition pugixml.hpp:155

◆ is_xpath_attribute()

bool is_xpath_attribute ( const char_t * name)
inline

Definition at line 8786 of file pugixml.cc.

8787 {
8788 return !(starts_with(name, PUGIXML_TEXT("xmlns")) && (name[5] == 0 || name[5] == ':'));
8789 }
const char * name(G4int ptype)
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN bool starts_with(const char_t *string, const char_t *pattern)
Definition pugixml.cc:8082

Referenced by xpath_ast_node::eval_boolean().

◆ 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 4716 of file pugixml.cc.

4717 {
4718 // check input buffer
4719 if (!contents && size) return make_parse_result(status_io_error);
4720
4721 // get actual encoding
4722 xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
4723
4724 // if convert_buffer below throws bad_alloc, we still need to deallocate contents if we own it
4725 auto_deleter<void> contents_guard(own ? contents : 0, xml_memory::deallocate);
4726
4727 // get private buffer
4728 char_t* buffer = 0;
4729 size_t length = 0;
4730
4731 // coverity[var_deref_model]
4732 if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory);
4733
4734 // after this we either deallocate contents (below) or hold on to it via doc->buffer, so we don't need to guard it
4735 contents_guard.release();
4736
4737 // delete original buffer if we performed a conversion
4738 if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents);
4739
4740 // grab onto buffer if it's our buffer, user is responsible for deallocating contents himself
4741 if (own || buffer != contents) *out_buffer = buffer;
4742
4743 // store buffer for offset_debug
4744 doc->buffer = buffer;
4745
4746 // parse
4747 xml_parse_result res = impl::xml_parser::parse(buffer, length, doc, root, options);
4748
4749 // remember encoding
4750 res.encoding = buffer_encoding;
4751
4752 return res;
4753 }
xml_parse_result make_parse_result(xml_parse_status status, ptrdiff_t offset=0)
Definition pugixml.cc:2920
const char_t * buffer
Definition pugixml.cc:1150

Referenced by load_file_impl(), and load_stream_impl().

◆ load_file_impl()

PUGI__FN xml_parse_result load_file_impl ( xml_document_struct * doc,
FILE * file,
unsigned int options,
xml_encoding encoding,
char_t ** out_buffer )

Definition at line 4820 of file pugixml.cc.

4821 {
4822 if (!file) return make_parse_result(status_file_not_found);
4823
4824 // get file size (can result in I/O errors)
4825 size_t size = 0;
4826 xml_parse_status size_status = get_file_size(file, size);
4827 if (size_status != status_ok) return make_parse_result(size_status);
4828
4829 size_t max_suffix_size = sizeof(char_t);
4830
4831 // allocate buffer for the whole file
4832 char* contents = static_cast<char*>(xml_memory::allocate(size + max_suffix_size));
4833 if (!contents) return make_parse_result(status_out_of_memory);
4834
4835 // read file in memory
4836 size_t read_size = fread(contents, 1, size, file);
4837
4838 if (read_size != size)
4839 {
4840 xml_memory::deallocate(contents);
4841 return make_parse_result(status_io_error);
4842 }
4843
4844 xml_encoding real_encoding = get_buffer_encoding(encoding, contents, size);
4845
4846 return load_buffer_impl(doc, doc, contents, zero_terminate_buffer(contents, size, real_encoding), options, real_encoding, true, true, out_buffer);
4847 }
xml_parse_status
Definition pugixml.hpp:981
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 pugixml.cc:4716
PUGI__FN size_t zero_terminate_buffer(void *buffer, size_t size, xml_encoding encoding)
Definition pugixml.cc:4796
PUGI__FN xml_parse_status get_file_size(FILE *file, size_t &out_result)
Definition pugixml.cc:4756
PUGI__FN xml_encoding get_buffer_encoding(xml_encoding encoding, const void *contents, size_t size)
Definition pugixml.cc:2037

◆ 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 4888 of file pugixml.cc.

4889 {
4891
4892 // read file to a chunk list
4893 size_t total = 0;
4894 xml_stream_chunk<T>* last = 0;
4895
4896 while (!stream.eof())
4897 {
4898 // allocate new chunk
4900 if (!chunk) return status_out_of_memory;
4901
4902 // append chunk to list
4903 if (last) last = last->next = chunk;
4904 else chunks.data = last = chunk;
4905
4906 // read data to chunk
4907 stream.read(chunk->data, static_cast<std::streamsize>(sizeof(chunk->data) / sizeof(T)));
4908 chunk->size = static_cast<size_t>(stream.gcount()) * sizeof(T);
4909
4910 // read may set failbit | eofbit in case gcount() is less than read length, so check for other I/O errors
4911 if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error;
4912
4913 // guard against huge files (chunk size is small enough to make this overflow check work)
4914 if (total + chunk->size < total) return status_out_of_memory;
4915 total += chunk->size;
4916 }
4917
4918 size_t max_suffix_size = sizeof(char_t);
4919
4920 // copy chunk list to a contiguous buffer
4921 char* buffer = static_cast<char*>(xml_memory::allocate(total + max_suffix_size));
4922 if (!buffer) return status_out_of_memory;
4923
4924 char* write = buffer;
4925
4926 for (xml_stream_chunk<T>* chunk = chunks.data; chunk; chunk = chunk->next)
4927 {
4928 assert(write + chunk->size <= buffer + total);
4929 memcpy(write, chunk->data, chunk->size);
4930 write += chunk->size;
4931 }
4932
4933 assert(write == buffer + total);
4934
4935 // return buffer
4936 *out_buffer = buffer;
4937 *out_size = total;
4938
4939 return status_ok;
4940 }
G4double total(Particle const *const p1, Particle const *const p2)
static xml_stream_chunk * create()
Definition pugixml.cc:4857
T data[xml_memory_page_size/sizeof(T)]
Definition pugixml.cc:4885
static void destroy(xml_stream_chunk *chunk)
Definition pugixml.cc:4865
xml_stream_chunk * next
Definition pugixml.cc:4882

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 4942 of file pugixml.cc.

4943 {
4944 // get length of remaining data in stream
4945 typename std::basic_istream<T>::pos_type pos = stream.tellg();
4946 stream.seekg(0, std::ios::end);
4947 std::streamoff length = stream.tellg() - pos;
4948 stream.seekg(pos);
4949
4950 if (stream.fail() || pos < 0) return status_io_error;
4951
4952 // guard against huge files
4953 size_t read_length = static_cast<size_t>(length);
4954
4955 if (static_cast<std::streamsize>(read_length) != length || length < 0) return status_out_of_memory;
4956
4957 size_t max_suffix_size = sizeof(char_t);
4958
4959 // read stream data into memory (guard against stream exceptions with buffer holder)
4960 auto_deleter<void> buffer(xml_memory::allocate(read_length * sizeof(T) + max_suffix_size), xml_memory::deallocate);
4961 if (!buffer.data) return status_out_of_memory;
4962
4963 stream.read(static_cast<T*>(buffer.data), static_cast<std::streamsize>(read_length));
4964
4965 // 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
4966 if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error;
4967
4968 // return buffer
4969 size_t actual_length = static_cast<size_t>(stream.gcount());
4970 assert(actual_length <= read_length);
4971
4972 *out_buffer = buffer.release();
4973 *out_size = actual_length * sizeof(T);
4974
4975 return status_ok;
4976 }

Referenced by load_stream_impl().

◆ load_stream_impl()

template<typename T>
PUGI__FN xml_parse_result load_stream_impl ( xml_document_struct * doc,
std::basic_istream< T > & stream,
unsigned int options,
xml_encoding encoding,
char_t ** out_buffer )

Definition at line 4978 of file pugixml.cc.

4979 {
4980 void* buffer = 0;
4981 size_t size = 0;
4982 xml_parse_status status = status_ok;
4983
4984 // if stream has an error bit set, bail out (otherwise tellg() can fail and we'll clear error bits)
4985 if (stream.fail()) return make_parse_result(status_io_error);
4986
4987 // load stream to memory (using seek-based implementation if possible, since it's faster and takes less memory)
4988 if (stream.tellg() < 0)
4989 {
4990 stream.clear(); // clear error flags that could be set by a failing tellg
4991 status = load_stream_data_noseek(stream, &buffer, &size);
4992 }
4993 else
4994 status = load_stream_data_seek(stream, &buffer, &size);
4995
4996 if (status != status_ok) return make_parse_result(status);
4997
4998 xml_encoding real_encoding = get_buffer_encoding(encoding, buffer, size);
4999
5000 return load_buffer_impl(doc, doc, buffer, zero_terminate_buffer(buffer, size, real_encoding), options, real_encoding, true, true, out_buffer);
5001 }
PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
Definition pugixml.cc:4942
PUGI__FN xml_parse_status load_stream_data_noseek(std::basic_istream< T > &stream, void **out_buffer, size_t *out_size)
Definition pugixml.cc:4888

◆ local_name()

PUGI__FN const char_t * local_name ( const xpath_node & node)

Definition at line 8599 of file pugixml.cc.

8600 {
8601 const char_t* name = qualified_name(node);
8602 const char_t* p = find_char(name, ':');
8603
8604 return p ? p + 1 : name;
8605 }
PUGI__FN const char_t * qualified_name(const xpath_node &node)
Definition pugixml.cc:8594
PUGI__FN const char_t * find_char(const char_t *s, char_t c)
Definition pugixml.cc:8093

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 2920 of file pugixml.cc.

2921 {
2922 xml_parse_result result;
2923 result.status = status;
2924 result.offset = offset;
2925
2926 return result;
2927 }

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

◆ median3()

template<typename I, typename Pred>
I median3 ( I first,
I middle,
I last,
const Pred & pred )
inline

Definition at line 7639 of file pugixml.cc.

7640 {
7641 if (pred(*middle, *first))
7642 swap(middle, first);
7643 if (pred(*last, *middle))
7644 swap(last, middle);
7645 if (pred(*middle, *first))
7646 swap(middle, first);
7647
7648 return middle;
7649 }
void swap(T &lhs, T &rhs)
Definition pugixml.cc:7568

Referenced by sort().

◆ min_element()

template<typename I, typename Pred>
PUGI__FN I min_element ( I begin,
I end,
const Pred & pred )

Definition at line 7575 of file pugixml.cc.

7576 {
7577 I result = begin;
7578
7579 for (I it = begin + 1; it != end; ++it)
7580 if (pred(*it, *result))
7581 result = it;
7582
7583 return result;
7584 }

Referenced by xpath_first().

◆ namespace_uri() [1/3]

PUGI__FN const char_t * namespace_uri ( const xpath_node & node)

Definition at line 8669 of file pugixml.cc.

8670 {
8671 return node.attribute() ? namespace_uri(node.attribute(), node.parent()) : namespace_uri(node.node());
8672 }
PUGI__FN const char_t * namespace_uri(xml_node node)
Definition pugixml.cc:8630

◆ namespace_uri() [2/3]

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

Definition at line 8648 of file pugixml.cc.

8649 {
8650 namespace_uri_predicate pred = attr.name();
8651
8652 // Default namespace does not apply to attributes
8653 if (!pred.prefix) return PUGIXML_TEXT("");
8654
8655 xml_node p = parent;
8656
8657 while (p)
8658 {
8659 xml_attribute a = p.find_attribute(pred);
8660
8661 if (a) return a.value();
8662
8663 p = p.parent();
8664 }
8665
8666 return PUGIXML_TEXT("");
8667 }
const char_t * prefix
Definition pugixml.cc:8609

◆ namespace_uri() [3/3]

PUGI__FN const char_t * namespace_uri ( xml_node node)

Definition at line 8630 of file pugixml.cc.

8631 {
8632 namespace_uri_predicate pred = node.name();
8633
8634 xml_node p = node;
8635
8636 while (p)
8637 {
8638 xml_attribute a = p.find_attribute(pred);
8639
8640 if (a) return a.value();
8641
8642 p = p.parent();
8643 }
8644
8645 return PUGIXML_TEXT("");
8646 }

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

◆ new_xpath_variable() [1/2]

template<typename T>
PUGI__FN T * new_xpath_variable ( const char_t * name)

Definition at line 8857 of file pugixml.cc.

8858 {
8859 size_t length = strlength(name);
8860 if (length == 0) return 0; // empty variable names are invalid
8861
8862 // $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters
8863 void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t));
8864 if (!memory) return 0;
8865
8866 T* result = new (memory) T();
8867
8868 memcpy(result->name, name, (length + 1) * sizeof(char_t));
8869
8870 return result;
8871 }
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN size_t strlength(const char_t *s)
Definition pugixml.cc:214

Referenced by new_xpath_variable().

◆ new_xpath_variable() [2/2]

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

Definition at line 8873 of file pugixml.cc.

8874 {
8875 switch (type)
8876 {
8879
8880 case xpath_type_number:
8882
8883 case xpath_type_string:
8885
8886 case xpath_type_boolean:
8888
8889 default:
8890 return 0;
8891 }
8892 }
PUGI__FN T * new_xpath_variable(const char_t *name)
Definition pugixml.cc:8857

◆ node_copy_attribute()

PUGI__FN void node_copy_attribute ( xml_attribute_struct * da,
xml_attribute_struct * sa )

Definition at line 4497 of file pugixml.cc.

4498 {
4499 xml_allocator& alloc = get_allocator(da);
4500 xml_allocator* shared_alloc = (&alloc == &get_allocator(sa)) ? &alloc : 0;
4501
4502 node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc);
4503 node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc);
4504 }
PUGI__FN void node_copy_string(String &dest, Header &header, uintptr_t header_mask, char_t *source, Header &source_header, xml_allocator *alloc)
Definition pugixml.cc:4407
xml_allocator & get_allocator(const Object *object)
Definition pugixml.cc:1159

◆ node_copy_contents()

PUGI__FN void node_copy_contents ( xml_node_struct * dn,
xml_node_struct * sn,
xml_allocator * shared_alloc )

Definition at line 4426 of file pugixml.cc.

4427 {
4428 node_copy_string(dn->name, dn->header, xml_memory_page_name_allocated_mask, sn->name, sn->header, shared_alloc);
4429 node_copy_string(dn->value, dn->header, xml_memory_page_value_allocated_mask, sn->value, sn->header, shared_alloc);
4430
4431 for (xml_attribute_struct* sa = sn->first_attribute; sa; sa = sa->next_attribute)
4432 {
4433 xml_attribute_struct* da = append_new_attribute(dn, get_allocator(dn));
4434
4435 if (da)
4436 {
4437 node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc);
4438 node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc);
4439 }
4440 }
4441 }
PUGI__FN_NO_INLINE xml_attribute_struct * append_new_attribute(xml_node_struct *node, xml_allocator &alloc)
Definition pugixml.cc:1427

Referenced by node_copy_tree().

◆ node_copy_string()

template<typename String, typename Header>
PUGI__FN void node_copy_string ( String & dest,
Header & header,
uintptr_t header_mask,
char_t * source,
Header & source_header,
xml_allocator * alloc )

Definition at line 4407 of file pugixml.cc.

4408 {
4409 assert(!dest && (header & header_mask) == 0);
4410
4411 if (source)
4412 {
4413 if (alloc && (source_header & header_mask) == 0)
4414 {
4415 dest = source;
4416
4417 // since strcpy_insitu can reuse document buffer memory we need to mark both source and dest as shared
4418 header |= xml_memory_page_contents_shared_mask;
4419 source_header |= xml_memory_page_contents_shared_mask;
4420 }
4421 else
4422 strcpy_insitu(dest, header, header_mask, source, strlength(source));
4423 }
4424 }
PUGI__FN bool strcpy_insitu(String &dest, Header &header, uintptr_t header_mask, const char_t *source, size_t source_length)
Definition pugixml.cc:2373

Referenced by node_copy_attribute(), and node_copy_contents().

◆ node_copy_tree()

PUGI__FN void node_copy_tree ( xml_node_struct * dn,
xml_node_struct * sn )

Definition at line 4443 of file pugixml.cc.

4444 {
4445 xml_allocator& alloc = get_allocator(dn);
4446 xml_allocator* shared_alloc = (&alloc == &get_allocator(sn)) ? &alloc : 0;
4447
4448 node_copy_contents(dn, sn, shared_alloc);
4449
4450 xml_node_struct* dit = dn;
4451 xml_node_struct* sit = sn->first_child;
4452
4453 while (sit && sit != sn)
4454 {
4455 // loop invariant: dit is inside the subtree rooted at dn
4456 assert(dit);
4457
4458 // when a tree is copied into one of the descendants, we need to skip that subtree to avoid an infinite loop
4459 if (sit != dn)
4460 {
4461 xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit));
4462
4463 if (copy)
4464 {
4465 node_copy_contents(copy, sit, shared_alloc);
4466
4467 if (sit->first_child)
4468 {
4469 dit = copy;
4470 sit = sit->first_child;
4471 continue;
4472 }
4473 }
4474 }
4475
4476 // continue to the next node
4477 do
4478 {
4479 if (sit->next_sibling)
4480 {
4481 sit = sit->next_sibling;
4482 break;
4483 }
4484
4485 sit = sit->parent;
4486 dit = dit->parent;
4487
4488 // loop invariant: dit is inside the subtree rooted at dn while sit is inside sn
4489 assert(sit == sn || dit);
4490 }
4491 while (sit != sn);
4492 }
4493
4494 assert(!sit || dit == dn->parent);
4495 }
void copy(G4double dst[], const G4double src[], std::size_t size=G4FieldTrack::ncompSVEC)
PUGI__FN void node_copy_contents(xml_node_struct *dn, xml_node_struct *sn, xml_allocator *shared_alloc)
Definition pugixml.cc:4426

◆ node_is_ancestor()

PUGI__FN bool node_is_ancestor ( xml_node_struct * parent,
xml_node_struct * node )

Definition at line 8239 of file pugixml.cc.

8240 {
8241 while (node && node != parent) node = node->parent;
8242
8243 return parent && node == parent;
8244 }

◆ node_is_before()

PUGI__FN bool node_is_before ( xml_node_struct * ln,
xml_node_struct * rn )

Definition at line 8196 of file pugixml.cc.

8197 {
8198 // find common ancestor at the same depth, if any
8199 xml_node_struct* lp = ln;
8200 xml_node_struct* rp = rn;
8201
8202 while (lp && rp && lp->parent != rp->parent)
8203 {
8204 lp = lp->parent;
8205 rp = rp->parent;
8206 }
8207
8208 // parents are the same!
8209 if (lp && rp) return node_is_before_sibling(lp, rp);
8210
8211 // nodes are at different depths, need to normalize heights
8212 bool left_higher = !lp;
8213
8214 while (lp)
8215 {
8216 lp = lp->parent;
8217 ln = ln->parent;
8218 }
8219
8220 while (rp)
8221 {
8222 rp = rp->parent;
8223 rn = rn->parent;
8224 }
8225
8226 // one node is the ancestor of the other
8227 if (ln == rn) return left_higher;
8228
8229 // find common ancestor... again
8230 while (ln->parent != rn->parent)
8231 {
8232 ln = ln->parent;
8233 rn = rn->parent;
8234 }
8235
8236 return node_is_before_sibling(ln, rn);
8237 }
PUGI__FN bool node_is_before_sibling(xml_node_struct *ln, xml_node_struct *rn)
Definition pugixml.cc:8172

Referenced by document_order_comparator::operator()().

◆ node_is_before_sibling()

PUGI__FN bool node_is_before_sibling ( xml_node_struct * ln,
xml_node_struct * rn )

Definition at line 8172 of file pugixml.cc.

8173 {
8174 assert(ln->parent == rn->parent);
8175
8176 // there is no common ancestor (the shared parent is null), nodes are from different documents
8177 if (!ln->parent) return ln < rn;
8178
8179 // determine sibling order
8180 xml_node_struct* ls = ln;
8181 xml_node_struct* rs = rn;
8182
8183 while (ls && rs)
8184 {
8185 if (ls == rn) return true;
8186 if (rs == ln) return false;
8187
8188 ls = ls->next_sibling;
8189 rs = rs->next_sibling;
8190 }
8191
8192 // if rn sibling chain ended ln must be before rn
8193 return !rs;
8194 }

Referenced by node_is_before().

◆ node_output()

PUGI__FN void node_output ( xml_buffered_writer & writer,
xml_node_struct * root,
const char_t * indent,
unsigned int flags,
unsigned int depth )

Definition at line 4253 of file pugixml.cc.

4254 {
4255 size_t indent_length = ((flags & (format_indent | format_indent_attributes)) && (flags & format_raw) == 0) ? strlength(indent) : 0;
4256 unsigned int indent_flags = indent_indent;
4257
4258 xml_node_struct* node = root;
4259
4260 do
4261 {
4262 assert(node);
4263
4264 // begin writing current node
4265 if (PUGI__NODETYPE(node) == node_pcdata || PUGI__NODETYPE(node) == node_cdata)
4266 {
4267 node_output_simple(writer, node, flags);
4268
4269 indent_flags = 0;
4270 }
4271 else
4272 {
4273 if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
4274 writer.write('\n');
4275
4276 if ((indent_flags & indent_indent) && indent_length)
4277 text_output_indent(writer, indent, indent_length, depth);
4278
4279 if (PUGI__NODETYPE(node) == node_element)
4280 {
4281 indent_flags = indent_newline | indent_indent;
4282
4283 if (node_output_start(writer, node, indent, indent_length, flags, depth))
4284 {
4285 // element nodes can have value if parse_embed_pcdata was used
4286 if (node->value)
4287 indent_flags = 0;
4288
4289 node = node->first_child;
4290 depth++;
4291 continue;
4292 }
4293 }
4294 else if (PUGI__NODETYPE(node) == node_document)
4295 {
4296 indent_flags = indent_indent;
4297
4298 if (node->first_child)
4299 {
4300 node = node->first_child;
4301 continue;
4302 }
4303 }
4304 else
4305 {
4306 node_output_simple(writer, node, flags);
4307
4308 indent_flags = indent_newline | indent_indent;
4309 }
4310 }
4311
4312 // continue to the next node
4313 while (node != root)
4314 {
4315 if (node->next_sibling)
4316 {
4317 node = node->next_sibling;
4318 break;
4319 }
4320
4321 node = node->parent;
4322
4323 // write closing node
4324 if (PUGI__NODETYPE(node) == node_element)
4325 {
4326 depth--;
4327
4328 if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
4329 writer.write('\n');
4330
4331 if ((indent_flags & indent_indent) && indent_length)
4332 text_output_indent(writer, indent, indent_length, depth);
4333
4334 node_output_end(writer, node);
4335
4336 indent_flags = indent_newline | indent_indent;
4337 }
4338 }
4339 }
4340 while (node != root);
4341
4342 if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
4343 writer.write('\n');
4344 }
const unsigned int format_raw
Definition pugixml.hpp:250
const unsigned int format_indent_attributes
Definition pugixml.hpp:262
const unsigned int format_indent
Definition pugixml.hpp:244
PUGI__FN void node_output_simple(xml_buffered_writer &writer, xml_node_struct *node, unsigned int flags)
Definition pugixml.cc:4191
PUGI__FN void text_output_indent(xml_buffered_writer &writer, const char_t *indent, size_t indent_length, unsigned int depth)
Definition pugixml.cc:4005
PUGI__FN void node_output_end(xml_buffered_writer &writer, xml_node_struct *node)
Definition pugixml.cc:4181
PUGI__FN bool node_output_start(xml_buffered_writer &writer, xml_node_struct *node, const char_t *indent, size_t indent_length, unsigned int flags, unsigned int depth)
Definition pugixml.cc:4119

◆ node_output_attributes()

PUGI__FN void node_output_attributes ( xml_buffered_writer & writer,
xml_node_struct * node,
const char_t * indent,
size_t indent_length,
unsigned int flags,
unsigned int depth )

Definition at line 4091 of file pugixml.cc.

4092 {
4093 const char_t* default_name = PUGIXML_TEXT(":anonymous");
4094 const char_t enquotation_char = (flags & format_attribute_single_quote) ? '\'' : '"';
4095
4096 for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute)
4097 {
4098 if ((flags & (format_indent_attributes | format_raw)) == format_indent_attributes)
4099 {
4100 writer.write('\n');
4101
4102 text_output_indent(writer, indent, indent_length, depth + 1);
4103 }
4104 else
4105 {
4106 writer.write(' ');
4107 }
4108
4109 writer.write_string(a->name ? a->name + 0 : default_name);
4110 writer.write('=', enquotation_char);
4111
4112 if (a->value)
4113 text_output(writer, a->value, ctx_special_attr, flags);
4114
4115 writer.write(enquotation_char);
4116 }
4117 }
const unsigned int format_attribute_single_quote
Definition pugixml.hpp:271
PUGI__FN void text_output(xml_buffered_writer &writer, const char_t *s, chartypex_t type, unsigned int flags)
Definition pugixml.cc:3975

Referenced by node_output_simple(), and node_output_start().

◆ node_output_comment()

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

Definition at line 4045 of file pugixml.cc.

4046 {
4047 writer.write('<', '!', '-', '-');
4048
4049 while (*s)
4050 {
4051 const char_t* prev = s;
4052
4053 // look for -\0 or -- sequence - we can't output it since -- is illegal in comment body
4054 while (*s && !(s[0] == '-' && (s[1] == '-' || s[1] == 0))) ++s;
4055
4056 writer.write_buffer(prev, static_cast<size_t>(s - prev));
4057
4058 if (*s)
4059 {
4060 assert(*s == '-');
4061
4062 writer.write('-', ' ');
4063 ++s;
4064 }
4065 }
4066
4067 writer.write('-', '-', '>');
4068 }

Referenced by node_output_simple().

◆ node_output_end()

PUGI__FN void node_output_end ( xml_buffered_writer & writer,
xml_node_struct * node )

Definition at line 4181 of file pugixml.cc.

4182 {
4183 const char_t* default_name = PUGIXML_TEXT(":anonymous");
4184 const char_t* name = node->name ? node->name + 0 : default_name;
4185
4186 writer.write('<', '/');
4187 writer.write_string(name);
4188 writer.write('>');
4189 }

Referenced by node_output().

◆ node_output_pi_value()

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

Definition at line 4070 of file pugixml.cc.

4071 {
4072 while (*s)
4073 {
4074 const char_t* prev = s;
4075
4076 // look for ?> sequence - we can't output it since ?> terminates PI
4077 while (*s && !(s[0] == '?' && s[1] == '>')) ++s;
4078
4079 writer.write_buffer(prev, static_cast<size_t>(s - prev));
4080
4081 if (*s)
4082 {
4083 assert(s[0] == '?' && s[1] == '>');
4084
4085 writer.write('?', ' ', '>');
4086 s += 2;
4087 }
4088 }
4089 }

Referenced by node_output_simple().

◆ node_output_simple()

PUGI__FN void node_output_simple ( xml_buffered_writer & writer,
xml_node_struct * node,
unsigned int flags )

Definition at line 4191 of file pugixml.cc.

4192 {
4193 const char_t* default_name = PUGIXML_TEXT(":anonymous");
4194
4195 switch (PUGI__NODETYPE(node))
4196 {
4197 case node_pcdata:
4198 text_output(writer, node->value ? node->value + 0 : PUGIXML_TEXT(""), ctx_special_pcdata, flags);
4199 break;
4200
4201 case node_cdata:
4202 text_output_cdata(writer, node->value ? node->value + 0 : PUGIXML_TEXT(""));
4203 break;
4204
4205 case node_comment:
4206 node_output_comment(writer, node->value ? node->value + 0 : PUGIXML_TEXT(""));
4207 break;
4208
4209 case node_pi:
4210 writer.write('<', '?');
4211 writer.write_string(node->name ? node->name + 0 : default_name);
4212
4213 if (node->value)
4214 {
4215 writer.write(' ');
4216 node_output_pi_value(writer, node->value);
4217 }
4218
4219 writer.write('?', '>');
4220 break;
4221
4222 case node_declaration:
4223 writer.write('<', '?');
4224 writer.write_string(node->name ? node->name + 0 : default_name);
4225 node_output_attributes(writer, node, PUGIXML_TEXT(""), 0, flags | format_raw, 0);
4226 writer.write('?', '>');
4227 break;
4228
4229 case node_doctype:
4230 writer.write('<', '!', 'D', 'O', 'C');
4231 writer.write('T', 'Y', 'P', 'E');
4232
4233 if (node->value)
4234 {
4235 writer.write(' ');
4236 writer.write_string(node->value);
4237 }
4238
4239 writer.write('>');
4240 break;
4241
4242 default:
4243 assert(false && "Invalid node type"); // unreachable
4244 }
4245 }
@ node_comment
Definition pugixml.hpp:156
@ node_doctype
Definition pugixml.hpp:159
@ node_pi
Definition pugixml.hpp:157
PUGI__FN void text_output_cdata(xml_buffered_writer &writer, const char_t *s)
Definition pugixml.cc:3983
PUGI__FN void node_output_comment(xml_buffered_writer &writer, const char_t *s)
Definition pugixml.cc:4045
PUGI__FN void node_output_pi_value(xml_buffered_writer &writer, const char_t *s)
Definition pugixml.cc:4070
PUGI__FN void node_output_attributes(xml_buffered_writer &writer, xml_node_struct *node, const char_t *indent, size_t indent_length, unsigned int flags, unsigned int depth)
Definition pugixml.cc:4091

Referenced by node_output().

◆ node_output_start()

PUGI__FN bool node_output_start ( xml_buffered_writer & writer,
xml_node_struct * node,
const char_t * indent,
size_t indent_length,
unsigned int flags,
unsigned int depth )

Definition at line 4119 of file pugixml.cc.

4120 {
4121 const char_t* default_name = PUGIXML_TEXT(":anonymous");
4122 const char_t* name = node->name ? node->name + 0 : default_name;
4123
4124 writer.write('<');
4125 writer.write_string(name);
4126
4127 if (node->first_attribute)
4128 node_output_attributes(writer, node, indent, indent_length, flags, depth);
4129
4130 // element nodes can have value if parse_embed_pcdata was used
4131 if (!node->value)
4132 {
4133 if (!node->first_child)
4134 {
4135 if (flags & format_no_empty_element_tags)
4136 {
4137 writer.write('>', '<', '/');
4138 writer.write_string(name);
4139 writer.write('>');
4140
4141 return false;
4142 }
4143 else
4144 {
4145 if ((flags & format_raw) == 0)
4146 writer.write(' ');
4147
4148 writer.write('/', '>');
4149
4150 return false;
4151 }
4152 }
4153 else
4154 {
4155 writer.write('>');
4156
4157 return true;
4158 }
4159 }
4160 else
4161 {
4162 writer.write('>');
4163
4164 text_output(writer, node->value, ctx_special_pcdata, flags);
4165
4166 if (!node->first_child)
4167 {
4168 writer.write('<', '/');
4169 writer.write_string(name);
4170 writer.write('>');
4171
4172 return false;
4173 }
4174 else
4175 {
4176 return true;
4177 }
4178 }
4179 }

Referenced by node_output().

◆ normalize_space()

PUGI__FN char_t * normalize_space ( char_t * buffer)

Definition at line 8674 of file pugixml.cc.

8675 {
8676 char_t* write = buffer;
8677
8678 for (char_t* it = buffer; *it; )
8679 {
8680 char_t ch = *it++;
8681
8682 if (PUGI__IS_CHARTYPE(ch, ct_space))
8683 {
8684 // replace whitespace sequence with single space
8685 while (PUGI__IS_CHARTYPE(*it, ct_space)) it++;
8686
8687 // avoid leading spaces
8688 if (write != buffer) *write++ = ' ';
8689 }
8690 else *write++ = ch;
8691 }
8692
8693 // remove trailing space
8694 if (write != buffer && PUGI__IS_CHARTYPE(write[-1], ct_space)) write--;
8695
8696 // zero-terminate
8697 *write = 0;
8698
8699 return write;
8700 }

Referenced by xpath_ast_node::eval_string().

◆ open_file()

PUGI__FN FILE * open_file ( const char * path,
const char * mode )

Definition at line 5056 of file pugixml.cc.

5057 {
5058#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
5059 FILE* file = 0;
5060 return fopen_s(&file, path, mode) == 0 ? file : 0;
5061#else
5062 return fopen(path, mode);
5063#endif
5064 }

◆ open_file_wide()

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

Definition at line 5036 of file pugixml.cc.

5037 {
5038 // there is no standard function to open wide paths, so our best bet is to try utf8 path
5039 char* path_utf8 = convert_path_heap(path);
5040 if (!path_utf8) return 0;
5041
5042 // convert mode to ASCII (we mirror _wfopen interface)
5043 char mode_ascii[4] = {0};
5044 for (size_t i = 0; mode[i]; ++i) mode_ascii[i] = static_cast<char>(mode[i]);
5045
5046 // try to open the utf8 path
5047 FILE* result = fopen(path_utf8, mode_ascii);
5048
5049 // free dummy buffer
5050 xml_memory::deallocate(path_utf8);
5051
5052 return result;
5053 }
PUGI__FN char * convert_path_heap(const wchar_t *str)
Definition pugixml.cc:5015

◆ parse_declaration_encoding()

PUGI__FN bool parse_declaration_encoding ( const uint8_t * data,
size_t size,
const uint8_t *& out_encoding,
size_t & out_length )

Definition at line 1935 of file pugixml.cc.

1936 {
1937 #define PUGI__SCANCHAR(ch) { if (offset >= size || data[offset] != ch) return false; offset++; }
1938 #define PUGI__SCANCHARTYPE(ct) { while (offset < size && PUGI__IS_CHARTYPE(data[offset], ct)) offset++; }
1939
1940 // check if we have a non-empty XML declaration
1941 if (size < 6 || !((data[0] == '<') & (data[1] == '?') & (data[2] == 'x') & (data[3] == 'm') & (data[4] == 'l') && PUGI__IS_CHARTYPE(data[5], ct_space)))
1942 return false;
1943
1944 // scan XML declaration until the encoding field
1945 for (size_t i = 6; i + 1 < size; ++i)
1946 {
1947 // declaration can not contain ? in quoted values
1948 if (data[i] == '?')
1949 return false;
1950
1951 if (data[i] == 'e' && data[i + 1] == 'n')
1952 {
1953 size_t offset = i;
1954
1955 // encoding follows the version field which can't contain 'en' so this has to be the encoding if XML is well formed
1958
1959 // S? = S?
1961 PUGI__SCANCHAR('=');
1963
1964 // the only two valid delimiters are ' and "
1965 uint8_t delimiter = (offset < size && data[offset] == '"') ? '"' : '\'';
1966
1967 PUGI__SCANCHAR(delimiter);
1968
1969 size_t start = offset;
1970
1971 out_encoding = data + offset;
1972
1974
1975 out_length = offset - start;
1976
1977 PUGI__SCANCHAR(delimiter);
1978
1979 return true;
1980 }
1981 }
1982
1983 return false;
1984
1985 #undef PUGI__SCANCHAR
1986 #undef PUGI__SCANCHARTYPE
1987 }
#define PUGI__SCANCHARTYPE(ct)
#define PUGI__SCANCHAR(ch)

Referenced by guess_buffer_encoding().

◆ partition3()

template<typename T, typename Pred>
PUGI__FN void partition3 ( T * begin,
T * end,
T pivot,
const Pred & pred,
T ** out_eqbeg,
T ** out_eqend )

Definition at line 7651 of file pugixml.cc.

7652 {
7653 // invariant: array is split into 4 groups: = < ? > (each variable denotes the boundary between the groups)
7654 T* eq = begin;
7655 T* lt = begin;
7656 T* gt = end;
7657
7658 while (lt < gt)
7659 {
7660 if (pred(*lt, pivot))
7661 lt++;
7662 else if (*lt == pivot)
7663 swap(*eq++, *lt++);
7664 else
7665 swap(*lt, *--gt);
7666 }
7667
7668 // we now have just 4 groups: = < >; move equal elements to the middle
7669 T* eqbeg = gt;
7670
7671 for (T* it = begin; it != eq; ++it)
7672 swap(*it, *--eqbeg);
7673
7674 *out_eqbeg = eqbeg;
7675 *out_eqend = gt;
7676 }

Referenced by sort().

◆ prepend_attribute()

void prepend_attribute ( xml_attribute_struct * attr,
xml_node_struct * node )
inline

Definition at line 1352 of file pugixml.cc.

1353 {
1354 xml_attribute_struct* head = node->first_attribute;
1355
1356 if (head)
1357 {
1358 attr->prev_attribute_c = head->prev_attribute_c;
1359 head->prev_attribute_c = attr;
1360 }
1361 else
1362 attr->prev_attribute_c = attr;
1363
1364 attr->next_attribute = head;
1365 node->first_attribute = attr;
1366 }

◆ prepend_node()

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

Definition at line 1255 of file pugixml.cc.

1256 {
1257 child->parent = node;
1258
1259 xml_node_struct* head = node->first_child;
1260
1261 if (head)
1262 {
1263 child->prev_sibling_c = head->prev_sibling_c;
1264 head->prev_sibling_c = child;
1265 }
1266 else
1267 child->prev_sibling_c = child;
1268
1269 child->next_sibling = head;
1270 node->first_child = child;
1271 }

◆ qualified_name()

PUGI__FN const char_t * qualified_name ( const xpath_node & node)

Definition at line 8594 of file pugixml.cc.

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

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

◆ remove_attribute()

void remove_attribute ( xml_attribute_struct * attr,
xml_node_struct * node )
inline

Definition at line 1396 of file pugixml.cc.

1397 {
1398 xml_attribute_struct* next = attr->next_attribute;
1399 xml_attribute_struct* prev = attr->prev_attribute_c;
1400
1401 if (next)
1402 next->prev_attribute_c = prev;
1403 else
1404 node->first_attribute->prev_attribute_c = prev;
1405
1406 if (prev->next_attribute)
1407 prev->next_attribute = next;
1408 else
1409 node->first_attribute = next;
1410
1411 attr->prev_attribute_c = 0;
1412 attr->next_attribute = 0;
1413 }

◆ remove_node()

void remove_node ( xml_node_struct * node)
inline

Definition at line 1311 of file pugixml.cc.

1312 {
1313 xml_node_struct* parent = node->parent;
1314
1315 xml_node_struct* next = node->next_sibling;
1316 xml_node_struct* prev = node->prev_sibling_c;
1317
1318 if (next)
1319 next->prev_sibling_c = prev;
1320 else
1321 parent->first_child->prev_sibling_c = prev;
1322
1323 if (prev->next_sibling)
1324 prev->next_sibling = next;
1325 else
1326 parent->first_child = next;
1327
1328 node->parent = 0;
1329 node->prev_sibling_c = 0;
1330 node->next_sibling = 0;
1331 }

◆ reverse()

template<typename I>
PUGI__FN void reverse ( I begin,
I end )

Definition at line 7586 of file pugixml.cc.

7587 {
7588 while (end - begin > 1)
7589 swap(*begin++, *--end);
7590 }

Referenced by pugi::xpath_node_set::sort(), and xpath_sort().

◆ round_nearest()

PUGI__FN double round_nearest ( double value)

Definition at line 8582 of file pugixml.cc.

8583 {
8584 return floor(value + 0.5);
8585 }

Referenced by xpath_ast_node::eval_string().

◆ round_nearest_nzero()

PUGI__FN double round_nearest_nzero ( double value)

Definition at line 8587 of file pugixml.cc.

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

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 5066 of file pugixml.cc.

5067 {
5068 if (!file) return false;
5069
5070 xml_writer_file writer(file);
5071 doc.save(writer, indent, flags, encoding);
5072
5073 return fflush(file) == 0 && ferror(file) == 0;
5074 }

◆ set_value_ascii()

template<typename String, typename Header>
PUGI__FN bool set_value_ascii ( String & dest,
Header & header,
uintptr_t header_mask,
char * buf )

Definition at line 4667 of file pugixml.cc.

4668 {
4669 #ifdef PUGIXML_WCHAR_MODE
4670 char_t wbuf[128];
4671 assert(strlen(buf) < sizeof(wbuf) / sizeof(wbuf[0]));
4672
4673 size_t offset = 0;
4674 for (; buf[offset]; ++offset) wbuf[offset] = buf[offset];
4675
4676 return strcpy_insitu(dest, header, header_mask, wbuf, offset);
4677 #else
4678 return strcpy_insitu(dest, header, header_mask, buf, strlen(buf));
4679 #endif
4680 }

Referenced by set_value_convert(), and set_value_convert().

◆ set_value_bool()

template<typename String, typename Header>
PUGI__FN bool set_value_bool ( String & dest,
Header & header,
uintptr_t header_mask,
bool value )

Definition at line 4711 of file pugixml.cc.

4712 {
4713 return strcpy_insitu(dest, header, header_mask, value ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false"), value ? 4 : 5);
4714 }

◆ set_value_convert() [1/2]

template<typename String, typename Header>
PUGI__FN bool set_value_convert ( String & dest,
Header & header,
uintptr_t header_mask,
double value,
int precision )

Definition at line 4702 of file pugixml.cc.

4703 {
4704 char buf[128];
4705 PUGI__SNPRINTF(buf, "%.*g", precision, value);
4706
4707 return set_value_ascii(dest, header, header_mask, buf);
4708 }
PUGI__FN bool set_value_ascii(String &dest, Header &header, uintptr_t header_mask, char *buf)
Definition pugixml.cc:4667

◆ set_value_convert() [2/2]

template<typename String, typename Header>
PUGI__FN bool set_value_convert ( String & dest,
Header & header,
uintptr_t header_mask,
float value,
int precision )

Definition at line 4693 of file pugixml.cc.

4694 {
4695 char buf[128];
4696 PUGI__SNPRINTF(buf, "%.*g", precision, double(value));
4697
4698 return set_value_ascii(dest, header, header_mask, buf);
4699 }

◆ set_value_integer()

template<typename U, typename String, typename Header>
PUGI__FN bool set_value_integer ( String & dest,
Header & header,
uintptr_t header_mask,
U value,
bool negative )

Definition at line 4683 of file pugixml.cc.

4684 {
4685 char_t buf[64];
4686 char_t* end = buf + sizeof(buf) / sizeof(buf[0]);
4687 char_t* begin = integer_to_string(buf, end, value, negative);
4688
4689 return strcpy_insitu(dest, header, header_mask, begin, end - begin);
4690 }
PUGI__FN PUGI__UNSIGNED_OVERFLOW char_t * integer_to_string(char_t *begin, char_t *end, U value, bool negative)
Definition pugixml.cc:4645

◆ sort()

template<typename I, typename Pred>
PUGI__FN void sort ( I begin,
I end,
const Pred & pred )

Definition at line 7678 of file pugixml.cc.

7679 {
7680 // sort large chunks
7681 while (end - begin > 16)
7682 {
7683 // find median element
7684 I middle = begin + (end - begin) / 2;
7685 I median = median3(begin, middle, end - 1, pred);
7686
7687 // partition in three chunks (< = >)
7688 I eqbeg, eqend;
7689 partition3(begin, end, *median, pred, &eqbeg, &eqend);
7690
7691 // loop on larger half
7692 if (eqbeg - begin > end - eqend)
7693 {
7694 sort(eqend, end, pred);
7695 end = eqbeg;
7696 }
7697 else
7698 {
7699 sort(begin, eqbeg, pred);
7700 begin = eqend;
7701 }
7702 }
7703
7704 // insertion sort small chunk
7705 insertion_sort(begin, end, pred);
7706 }
I median3(I first, I middle, I last, const Pred &pred)
Definition pugixml.cc:7639
PUGI__FN void sort(I begin, I end, const Pred &pred)
Definition pugixml.cc:7678
PUGI__FN void partition3(T *begin, T *end, T pivot, const Pred &pred, T **out_eqbeg, T **out_eqend)
Definition pugixml.cc:7651
PUGI__FN void insertion_sort(T *begin, T *end, const Pred &pred)
Definition pugixml.cc:7617

Referenced by G4gl2ps::beginPage(), __1DSortOut::Sort(), sort(), 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 8082 of file pugixml.cc.

8083 {
8084 while (*pattern && *string == *pattern)
8085 {
8086 string++;
8087 pattern++;
8088 }
8089
8090 return *pattern == 0;
8091 }

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

◆ strconv_cdata()

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

Definition at line 2644 of file pugixml.cc.

2645 {
2646 gap g;
2647
2648 while (true)
2649 {
2651
2652 if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair
2653 {
2654 *s++ = '\n'; // replace first one with 0x0a
2655
2656 if (*s == '\n') g.push(s, 1);
2657 }
2658 else if (s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')) // CDATA ends here
2659 {
2660 *g.flush(s) = 0;
2661
2662 return s + 1;
2663 }
2664 else if (*s == 0)
2665 {
2666 return 0;
2667 }
2668 else ++s;
2669 }
2670 }
#define PUGI__SCANWHILE_UNROLL(X)
Definition pugixml.cc:2611
#define PUGI__ENDSWITH(c, e)
Definition pugixml.cc:2604
char_t * flush(char_t *s)
Definition pugixml.cc:2449
void push(char_t *&s, size_t count)
Definition pugixml.cc:2432

Referenced by xml_parser::parse_exclamation().

◆ strconv_comment()

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

Definition at line 2616 of file pugixml.cc.

2617 {
2618 gap g;
2619
2620 while (true)
2621 {
2623
2624 if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair
2625 {
2626 *s++ = '\n'; // replace first one with 0x0a
2627
2628 if (*s == '\n') g.push(s, 1);
2629 }
2630 else if (s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')) // comment ends here
2631 {
2632 *g.flush(s) = 0;
2633
2634 return s + (s[2] == '>' ? 3 : 2);
2635 }
2636 else if (*s == 0)
2637 {
2638 return 0;
2639 }
2640 else ++s;
2641 }
2642 }

Referenced by xml_parser::parse_exclamation().

◆ strconv_escape()

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

Definition at line 2463 of file pugixml.cc.

2464 {
2465 char_t* stre = s + 1;
2466
2467 switch (*stre)
2468 {
2469 case '#': // &#...
2470 {
2471 unsigned int ucsc = 0;
2472
2473 if (stre[1] == 'x') // &#x... (hex code)
2474 {
2475 stre += 2;
2476
2477 char_t ch = *stre;
2478
2479 if (ch == ';') return stre;
2480
2481 for (;;)
2482 {
2483 if (static_cast<unsigned int>(ch - '0') <= 9)
2484 ucsc = 16 * ucsc + (ch - '0');
2485 else if (static_cast<unsigned int>((ch | ' ') - 'a') <= 5)
2486 ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10);
2487 else if (ch == ';')
2488 break;
2489 else // cancel
2490 return stre;
2491
2492 ch = *++stre;
2493 }
2494
2495 ++stre;
2496 }
2497 else // &#... (dec code)
2498 {
2499 char_t ch = *++stre;
2500
2501 if (ch == ';') return stre;
2502
2503 for (;;)
2504 {
2505 if (static_cast<unsigned int>(ch - '0') <= 9)
2506 ucsc = 10 * ucsc + (ch - '0');
2507 else if (ch == ';')
2508 break;
2509 else // cancel
2510 return stre;
2511
2512 ch = *++stre;
2513 }
2514
2515 ++stre;
2516 }
2517
2518 #ifdef PUGIXML_WCHAR_MODE
2519 s = reinterpret_cast<char_t*>(wchar_writer::any(reinterpret_cast<wchar_writer::value_type>(s), ucsc));
2520 #else
2521 s = reinterpret_cast<char_t*>(utf8_writer::any(reinterpret_cast<uint8_t*>(s), ucsc));
2522 #endif
2523
2524 g.push(s, stre - s);
2525 return stre;
2526 }
2527
2528 case 'a': // &a
2529 {
2530 ++stre;
2531
2532 if (*stre == 'm') // &am
2533 {
2534 if (*++stre == 'p' && *++stre == ';') // &amp;
2535 {
2536 *s++ = '&';
2537 ++stre;
2538
2539 g.push(s, stre - s);
2540 return stre;
2541 }
2542 }
2543 else if (*stre == 'p') // &ap
2544 {
2545 if (*++stre == 'o' && *++stre == 's' && *++stre == ';') // &apos;
2546 {
2547 *s++ = '\'';
2548 ++stre;
2549
2550 g.push(s, stre - s);
2551 return stre;
2552 }
2553 }
2554 break;
2555 }
2556
2557 case 'g': // &g
2558 {
2559 if (*++stre == 't' && *++stre == ';') // &gt;
2560 {
2561 *s++ = '>';
2562 ++stre;
2563
2564 g.push(s, stre - s);
2565 return stre;
2566 }
2567 break;
2568 }
2569
2570 case 'l': // &l
2571 {
2572 if (*++stre == 't' && *++stre == ';') // &lt;
2573 {
2574 *s++ = '<';
2575 ++stre;
2576
2577 g.push(s, stre - s);
2578 return stre;
2579 }
2580 break;
2581 }
2582
2583 case 'q': // &q
2584 {
2585 if (*++stre == 'u' && *++stre == 'o' && *++stre == 't' && *++stre == ';') // &quot;
2586 {
2587 *s++ = '"';
2588 ++stre;
2589
2590 g.push(s, stre - s);
2591 return stre;
2592 }
2593 break;
2594 }
2595
2596 default:
2597 break;
2598 }
2599
2600 return stre;
2601 }
static value_type any(value_type result, uint32_t ch)
Definition pugixml.cc:1525

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

template<typename String, typename Header>
PUGI__FN bool strcpy_insitu ( String & dest,
Header & header,
uintptr_t header_mask,
const char_t * source,
size_t source_length )

Definition at line 2373 of file pugixml.cc.

2374 {
2375 if (source_length == 0)
2376 {
2377 // empty string and null pointer are equivalent, so just deallocate old memory
2378 xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator;
2379
2380 if (header & header_mask) alloc->deallocate_string(dest);
2381
2382 // mark the string as not allocated
2383 dest = 0;
2384 header &= ~header_mask;
2385
2386 return true;
2387 }
2388 else if (dest && strcpy_insitu_allow(source_length, header, header_mask, dest))
2389 {
2390 // we can reuse old buffer, so just copy the new data (including zero terminator)
2391 memcpy(dest, source, source_length * sizeof(char_t));
2392 dest[source_length] = 0;
2393
2394 return true;
2395 }
2396 else
2397 {
2398 xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator;
2399
2400 if (!alloc->reserve()) return false;
2401
2402 // allocate new buffer
2403 char_t* buf = alloc->allocate_string(source_length + 1);
2404 if (!buf) return false;
2405
2406 // copy the string (including zero terminator)
2407 memcpy(buf, source, source_length * sizeof(char_t));
2408 buf[source_length] = 0;
2409
2410 // deallocate old buffer (*after* the above to protect against overlapping memory and/or allocation failures)
2411 if (header & header_mask) alloc->deallocate_string(dest);
2412
2413 // the string is now allocated, so set the flag
2414 dest = buf;
2415 header |= header_mask;
2416
2417 return true;
2418 }
2419 }
bool strcpy_insitu_allow(size_t length, const Header &header, uintptr_t header_mask, char_t *target)
Definition pugixml.cc:2356
char_t * allocate_string(size_t length)
Definition pugixml.cc:640

Referenced by node_copy_string(), set_value_ascii(), set_value_bool(), and set_value_integer().

◆ strcpy_insitu_allow()

template<typename Header>
bool strcpy_insitu_allow ( size_t length,
const Header & header,
uintptr_t header_mask,
char_t * target )
inline

Definition at line 2356 of file pugixml.cc.

2357 {
2358 // never reuse shared memory
2359 if (header & xml_memory_page_contents_shared_mask) return false;
2360
2361 size_t target_length = strlength(target);
2362
2363 // always reuse document buffer memory if possible
2364 if ((header & header_mask) == 0) return target_length >= length;
2365
2366 // reuse heap memory if waste is not too great
2367 const size_t reuse_threshold = 32;
2368
2369 return target_length >= length && (target_length < reuse_threshold || target_length - length < target_length / 2);
2370 }

Referenced by strcpy_insitu().

◆ strequal()

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

Definition at line 226 of file pugixml.cc.

227 {
228 assert(src && dst);
229
230 #ifdef PUGIXML_WCHAR_MODE
231 return wcscmp(src, dst) == 0;
232 #else
233 return strcmp(src, dst) == 0;
234 #endif
235 }

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

◆ strequalrange()

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

Definition at line 238 of file pugixml.cc.

239 {
240 for (size_t i = 0; i < count; ++i)
241 if (lhs[i] != rhs[i])
242 return false;
243
244 return lhs[count] == 0;
245 }

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

◆ string_to_integer()

template<typename U>
PUGI__FN PUGI__UNSIGNED_OVERFLOW U string_to_integer ( const char_t * value,
U minv,
U maxv )

Definition at line 4514 of file pugixml.cc.

4515 {
4516 U result = 0;
4517 const char_t* s = value;
4518
4519 while (PUGI__IS_CHARTYPE(*s, ct_space))
4520 s++;
4521
4522 bool negative = (*s == '-');
4523
4524 s += (*s == '+' || *s == '-');
4525
4526 bool overflow = false;
4527
4528 if (s[0] == '0' && (s[1] | ' ') == 'x')
4529 {
4530 s += 2;
4531
4532 // since overflow detection relies on length of the sequence skip leading zeros
4533 while (*s == '0')
4534 s++;
4535
4536 const char_t* start = s;
4537
4538 for (;;)
4539 {
4540 if (static_cast<unsigned>(*s - '0') < 10)
4541 result = result * 16 + (*s - '0');
4542 else if (static_cast<unsigned>((*s | ' ') - 'a') < 6)
4543 result = result * 16 + ((*s | ' ') - 'a' + 10);
4544 else
4545 break;
4546
4547 s++;
4548 }
4549
4550 size_t digits = static_cast<size_t>(s - start);
4551
4552 overflow = digits > sizeof(U) * 2;
4553 }
4554 else
4555 {
4556 // since overflow detection relies on length of the sequence skip leading zeros
4557 while (*s == '0')
4558 s++;
4559
4560 const char_t* start = s;
4561
4562 for (;;)
4563 {
4564 if (static_cast<unsigned>(*s - '0') < 10)
4565 result = result * 10 + (*s - '0');
4566 else
4567 break;
4568
4569 s++;
4570 }
4571
4572 size_t digits = static_cast<size_t>(s - start);
4573
4574 PUGI__STATIC_ASSERT(sizeof(U) == 8 || sizeof(U) == 4 || sizeof(U) == 2);
4575
4576 const size_t max_digits10 = sizeof(U) == 8 ? 20 : sizeof(U) == 4 ? 10 : 5;
4577 const char_t max_lead = sizeof(U) == 8 ? '1' : sizeof(U) == 4 ? '4' : '6';
4578 const size_t high_bit = sizeof(U) * 8 - 1;
4579
4580 overflow = digits >= max_digits10 && !(digits == max_digits10 && (*start < max_lead || (*start == max_lead && result >> high_bit)));
4581 }
4582
4583 if (negative)
4584 {
4585 // Workaround for crayc++ CC-3059: Expected no overflow in routine.
4586 #ifdef _CRAYC
4587 return (overflow || result > ~minv + 1) ? minv : ~result + 1;
4588 #else
4589 return (overflow || result > 0 - minv) ? minv : 0 - result;
4590 #endif
4591 }
4592 else
4593 return (overflow || result > maxv) ? maxv : result;
4594 }

Referenced by get_value_int(), and get_value_uint().

◆ string_value()

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

Definition at line 8118 of file pugixml.cc.

8119 {
8120 if (na.attribute())
8121 return xpath_string::from_const(na.attribute().value());
8122 else
8123 {
8124 xml_node n = na.node();
8125
8126 switch (n.type())
8127 {
8128 case node_pcdata:
8129 case node_cdata:
8130 case node_comment:
8131 case node_pi:
8132 return xpath_string::from_const(n.value());
8133
8134 case node_document:
8135 case node_element:
8136 {
8137 xpath_string result;
8138
8139 // element nodes can have value if parse_embed_pcdata was used
8140 if (n.value()[0])
8141 result.append(xpath_string::from_const(n.value()), alloc);
8142
8143 xml_node cur = n.first_child();
8144
8145 while (cur && cur != n)
8146 {
8147 if (cur.type() == node_pcdata || cur.type() == node_cdata)
8148 result.append(xpath_string::from_const(cur.value()), alloc);
8149
8150 if (cur.first_child())
8151 cur = cur.first_child();
8152 else if (cur.next_sibling())
8153 cur = cur.next_sibling();
8154 else
8155 {
8156 while (!cur.next_sibling() && cur != n)
8157 cur = cur.parent();
8158
8159 if (cur != n) cur = cur.next_sibling();
8160 }
8161 }
8162
8163 return result;
8164 }
8165
8166 default:
8167 return xpath_string();
8168 }
8169 }
8170 }
void append(const xpath_string &o, xpath_allocator *alloc)
Definition pugixml.cc:7996
@ node_document
Definition pugixml.hpp:152

Referenced by 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 214 of file pugixml.cc.

215 {
216 assert(s);
217
218 #ifdef PUGIXML_WCHAR_MODE
219 return wcslen(s);
220 #else
221 return strlen(s);
222 #endif
223 }

Referenced by xpath_string::data(), xpath_string::length(), new_xpath_variable(), node_copy_string(), node_output(), strcpy_insitu_allow(), and xml_buffered_writer::write_string().

◆ strlength_wide()

PUGI__FN size_t strlength_wide ( const wchar_t * s)

Definition at line 248 of file pugixml.cc.

249 {
250 assert(s);
251
252 #ifdef PUGIXML_WCHAR_MODE
253 return wcslen(s);
254 #else
255 const wchar_t* end = s;
256 while (*end) end++;
257 return static_cast<size_t>(end - s);
258 #endif
259 }

Referenced by convert_path_heap().

◆ swap()

template<typename T>
void swap ( T & lhs,
T & rhs )
inline

Definition at line 7568 of file pugixml.cc.

7569 {
7570 T temp = lhs;
7571 lhs = rhs;
7572 rhs = temp;
7573 }

Referenced by median3(), partition3(), reverse(), and G4OpBoundaryProcess::~G4OpBoundaryProcess().

◆ text_output()

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

Definition at line 3975 of file pugixml.cc.

3976 {
3977 if (flags & format_no_escapes)
3978 writer.write_string(s);
3979 else
3980 text_output_escaped(writer, s, type, flags);
3981 }
PUGI__FN void text_output_escaped(xml_buffered_writer &writer, const char_t *s, chartypex_t type, unsigned int flags)
Definition pugixml.cc:3923

Referenced by node_output_attributes(), node_output_simple(), and node_output_start().

◆ text_output_cdata()

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

Definition at line 3983 of file pugixml.cc.

3984 {
3985 do
3986 {
3987 writer.write('<', '!', '[', 'C', 'D');
3988 writer.write('A', 'T', 'A', '[');
3989
3990 const char_t* prev = s;
3991
3992 // look for ]]> sequence - we can't output it as is since it terminates CDATA
3993 while (*s && !(s[0] == ']' && s[1] == ']' && s[2] == '>')) ++s;
3994
3995 // skip ]] if we stopped at ]]>, > will go to the next CDATA section
3996 if (*s) s += 2;
3997
3998 writer.write_buffer(prev, static_cast<size_t>(s - prev));
3999
4000 writer.write(']', ']', '>');
4001 }
4002 while (*s);
4003 }

Referenced by node_output_simple().

◆ text_output_escaped()

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

Definition at line 3923 of file pugixml.cc.

3924 {
3925 while (*s)
3926 {
3927 const char_t* prev = s;
3928
3929 // While *s is a usual symbol
3931
3932 writer.write_buffer(prev, static_cast<size_t>(s - prev));
3933
3934 switch (*s)
3935 {
3936 case 0: break;
3937 case '&':
3938 writer.write('&', 'a', 'm', 'p', ';');
3939 ++s;
3940 break;
3941 case '<':
3942 writer.write('&', 'l', 't', ';');
3943 ++s;
3944 break;
3945 case '>':
3946 writer.write('&', 'g', 't', ';');
3947 ++s;
3948 break;
3949 case '"':
3950 if (flags & format_attribute_single_quote)
3951 writer.write('"');
3952 else
3953 writer.write('&', 'q', 'u', 'o', 't', ';');
3954 ++s;
3955 break;
3956 case '\'':
3957 if (flags & format_attribute_single_quote)
3958 writer.write('&', 'a', 'p', 'o', 's', ';');
3959 else
3960 writer.write('\'');
3961 ++s;
3962 break;
3963 default: // s is not a usual symbol
3964 {
3965 unsigned int ch = static_cast<unsigned int>(*s++);
3966 assert(ch < 32);
3967
3968 if (!(flags & format_skip_control_chars))
3969 writer.write('&', '#', static_cast<char_t>((ch / 10) + '0'), static_cast<char_t>((ch % 10) + '0'), ';');
3970 }
3971 }
3972 }
3973 }

Referenced by text_output().

◆ text_output_indent()

PUGI__FN void text_output_indent ( xml_buffered_writer & writer,
const char_t * indent,
size_t indent_length,
unsigned int depth )

Definition at line 4005 of file pugixml.cc.

4006 {
4007 switch (indent_length)
4008 {
4009 case 1:
4010 {
4011 for (unsigned int i = 0; i < depth; ++i)
4012 writer.write(indent[0]);
4013 break;
4014 }
4015
4016 case 2:
4017 {
4018 for (unsigned int i = 0; i < depth; ++i)
4019 writer.write(indent[0], indent[1]);
4020 break;
4021 }
4022
4023 case 3:
4024 {
4025 for (unsigned int i = 0; i < depth; ++i)
4026 writer.write(indent[0], indent[1], indent[2]);
4027 break;
4028 }
4029
4030 case 4:
4031 {
4032 for (unsigned int i = 0; i < depth; ++i)
4033 writer.write(indent[0], indent[1], indent[2], indent[3]);
4034 break;
4035 }
4036
4037 default:
4038 {
4039 for (unsigned int i = 0; i < depth; ++i)
4040 writer.write_buffer(indent, indent_length);
4041 }
4042 }
4043 }

Referenced by node_output(), and node_output_attributes().

◆ tolower_ascii()

PUGI__FN char_t tolower_ascii ( char_t ch)

Definition at line 8113 of file pugixml.cc.

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

Referenced by xpath_ast_node::eval_boolean().

◆ translate()

PUGI__FN char_t * translate ( char_t * buffer,
const char_t * from,
const char_t * to,
size_t to_length )

Definition at line 8702 of file pugixml.cc.

8703 {
8704 char_t* write = buffer;
8705
8706 while (*buffer)
8707 {
8708 PUGI__DMC_VOLATILE char_t ch = *buffer++;
8709
8710 const char_t* pos = find_char(from, ch);
8711
8712 if (!pos)
8713 *write++ = ch; // do not process
8714 else if (static_cast<size_t>(pos - from) < to_length)
8715 *write++ = to[pos - from]; // replace
8716 }
8717
8718 // zero-terminate
8719 *write = 0;
8720
8721 return write;
8722 }
#define PUGI__DMC_VOLATILE
Definition pugixml.cc:106

Referenced by xpath_ast_node::eval_string(), G4GDMLWriteStructure::PhysvolWrite(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ translate_table()

PUGI__FN char_t * translate_table ( char_t * buffer,
const unsigned char * table )

Definition at line 8756 of file pugixml.cc.

8757 {
8758 char_t* write = buffer;
8759
8760 while (*buffer)
8761 {
8762 char_t ch = *buffer++;
8763 unsigned int index = static_cast<unsigned int>(ch);
8764
8765 if (index < 128)
8766 {
8767 unsigned char code = table[index];
8768
8769 // code=128 means "skip character" (table size is 128 so 128 can be a special value)
8770 // this code skips these characters without extra branches
8771 *write = static_cast<char_t>(code);
8772 write += 1 - (code >> 7);
8773 }
8774 else
8775 {
8776 *write++ = ch;
8777 }
8778 }
8779
8780 // zero-terminate
8781 *write = 0;
8782
8783 return write;
8784 }

Referenced by xpath_ast_node::eval_string().

◆ translate_table_generate()

PUGI__FN unsigned char * translate_table_generate ( xpath_allocator * alloc,
const char_t * from,
const char_t * to )

Definition at line 8724 of file pugixml.cc.

8725 {
8726 unsigned char table[128] = {0};
8727
8728 while (*from)
8729 {
8730 unsigned int fc = static_cast<unsigned int>(*from);
8731 unsigned int tc = static_cast<unsigned int>(*to);
8732
8733 if (fc >= 128 || tc >= 128)
8734 return 0;
8735
8736 // code=128 means "skip character"
8737 if (!table[fc])
8738 table[fc] = static_cast<unsigned char>(tc ? tc : 128);
8739
8740 from++;
8741 if (tc) to++;
8742 }
8743
8744 for (int i = 0; i < 128; ++i)
8745 if (!table[i])
8746 table[i] = static_cast<unsigned char>(i);
8747
8748 void* result = alloc->allocate(sizeof(table));
8749 if (!result) return 0;
8750
8751 memcpy(result, table, sizeof(table));
8752
8753 return static_cast<unsigned char*>(result);
8754 }

Referenced by xpath_ast_node::optimize_self().

◆ truncate_zeros()

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

Definition at line 8396 of file pugixml.cc.

8397 {
8398 while (begin != end && end[-1] == '0') end--;
8399
8400 *end = 0;
8401 }

Referenced by convert_number_to_mantissa_exponent().

◆ unique()

template<typename I>
PUGI__FN I unique ( I begin,
I end )

Definition at line 7592 of file pugixml.cc.

7593 {
7594 // fast skip head
7595 while (end - begin > 1 && *begin != *(begin + 1))
7596 begin++;
7597
7598 if (begin == end)
7599 return begin;
7600
7601 // last written element
7602 I write = begin++;
7603
7604 // merge unique elements
7605 while (begin != end)
7606 {
7607 if (*begin != *write)
7608 *++write = *begin++;
7609 else
7610 begin++;
7611 }
7612
7613 // past-the-end (write points to live element)
7614 return write + 1;
7615 }

Referenced by G4Region::GetParentRegion(), G4Region::GetWorldPhysical(), G4FastSimulationManager::ListModels(), and 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 9013 of file pugixml.cc.

9014 {
9015 if (begin == end) return xpath_node();
9016
9017 switch (type)
9018 {
9019 case xpath_node_set::type_sorted:
9020 return *begin;
9021
9022 case xpath_node_set::type_sorted_reverse:
9023 return *(end - 1);
9024
9025 case xpath_node_set::type_unsorted:
9026 return *min_element(begin, end, document_order_comparator());
9027
9028 default:
9029 assert(false && "Invalid node set type"); // unreachable
9030 return xpath_node();
9031 }
9032 }
PUGI__FN I min_element(I begin, I end, const Pred &pred)
Definition pugixml.cc:7575

Referenced by xpath_node_set_raw::first().

◆ xpath_get_order()

PUGI__NS_END PUGI__NS_BEGIN PUGI__FN xpath_node_set::type_t xpath_get_order ( const xpath_node * begin,
const xpath_node * end )

Definition at line 8974 of file pugixml.cc.

8975 {
8976 if (end - begin < 2)
8977 return xpath_node_set::type_sorted;
8978
8980
8981 bool first = cmp(begin[0], begin[1]);
8982
8983 for (const xpath_node* it = begin + 1; it + 1 < end; ++it)
8984 if (cmp(it[0], it[1]) != first)
8985 return xpath_node_set::type_unsorted;
8986
8987 return first ? xpath_node_set::type_sorted : xpath_node_set::type_sorted_reverse;
8988 }

Referenced by xpath_sort().

◆ xpath_sort()

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 8990 of file pugixml.cc.

8991 {
8992 xpath_node_set::type_t order = rev ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted;
8993
8994 if (type == xpath_node_set::type_unsorted)
8995 {
8996 xpath_node_set::type_t sorted = xpath_get_order(begin, end);
8997
8998 if (sorted == xpath_node_set::type_unsorted)
8999 {
9000 sort(begin, end, document_order_comparator());
9001
9002 type = xpath_node_set::type_sorted;
9003 }
9004 else
9005 type = sorted;
9006 }
9007
9008 if (type != order) reverse(begin, end);
9009
9010 return order;
9011 }
PUGI__FN void reverse(I begin, I end)
Definition pugixml.cc:7586
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN xpath_node_set::type_t xpath_get_order(const xpath_node *begin, const xpath_node *end)
Definition pugixml.cc:8974

Referenced by xpath_node_set_raw::sort_do().

◆ zero_terminate_buffer()

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

Definition at line 4796 of file pugixml.cc.

4797 {
4798 // We only need to zero-terminate if encoding conversion does not do it for us
4799 #ifdef PUGIXML_WCHAR_MODE
4800 xml_encoding wchar_encoding = get_wchar_encoding();
4801
4802 if (encoding == wchar_encoding || need_endian_swap_utf(encoding, wchar_encoding))
4803 {
4804 size_t length = size / sizeof(char_t);
4805
4806 static_cast<char_t*>(buffer)[length] = 0;
4807 return (length + 1) * sizeof(char_t);
4808 }
4809 #else
4810 if (encoding == encoding_utf8)
4811 {
4812 static_cast<char*>(buffer)[size] = 0;
4813 return size + 1;
4814 }
4815 #endif
4816
4817 return size;
4818 }

Referenced by load_file_impl(), and load_stream_impl().

Variable Documentation

◆ axis_to_type< N >::axis

template<axis_t N>
const axis_t axis_to_type< N >::axis = N

Definition at line 9668 of file pugixml.cc.

Referenced by G4GMocrenFileSceneHandler::AddSolid(), xpath_parser::alloc_node(), G4AffineTransform::ApplyAxisTransform(), GIDI::Axes::Axes(), G4GDMLReadStructure::AxisRead(), CLHEP::Hep3Vector::azimAngle(), G4ClippablePolygon::BehindOf(), CLHEP::boostOf(), CLHEP::HepLorentzVector::boostOf, G4tgbVolume::BuildSolidForDivision(), G4PolyconeSide::CalculateExtent(), G4PolyhedraSide::CalculateExtent(), G4PolyPhiFace::CalculateExtent(), G4VCSGface::CalculateExtent(), G4VCSGfaceted::CalculateExtent(), G4VExternalPhysicalVolume::CheckOverlaps(), G4ClippablePolygon::ClipAlongOneAxis(), MCGIDI::Distributions::CoherentElasticTNSL::CoherentElasticTNSL(), G4ParameterisedNavigation::ComputeSafety(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeTransformation(), G4ReplicaNavigation::ComputeTransformation(), G4PVDivisionFactory::CreatePVDivision(), CLHEP::HepLorentzVector::delta2Euclidean(), G4Voxelizer::DisplayBoundaries(), G4Voxelizer::DisplayListNodes(), G4ReplicaNavigation::DistanceToOut(), G4ReplicaNavigation::DistanceToOut(), G4ReflectionFactory::Divide(), G4ReflectionFactory::Divide(), G4ReflectionFactory::Divide(), G4GDMLReadStructure::DivisionvolRead(), G4GDMLWriteStructure::DivisionvolWrite(), G4tgbGeometryDumper::DumpPVParameterised(), G4tgbGeometryDumper::DumpPVReplica(), G4ClippablePolygon::Empty(), G4PolyconeSide::Extent(), G4PolyhedraSide::Extent(), G4PolyPhiFace::Extent(), G4QuadrangularFacet::Extent(), G4TriangularFacet::Extent(), G4VCSGface::Extent(), G4VFacet::Extent(), G4ParameterisationBoxX::G4ParameterisationBoxX(), G4ParameterisationBoxY::G4ParameterisationBoxY(), G4ParameterisationBoxZ::G4ParameterisationBoxZ(), G4ParameterisationConsPhi::G4ParameterisationConsPhi(), G4ParameterisationConsRho::G4ParameterisationConsRho(), G4ParameterisationConsZ::G4ParameterisationConsZ(), G4ParameterisationParaX::G4ParameterisationParaX(), G4ParameterisationParaY::G4ParameterisationParaY(), G4ParameterisationParaZ::G4ParameterisationParaZ(), G4ParameterisationPolyconePhi::G4ParameterisationPolyconePhi(), G4ParameterisationPolyconeRho::G4ParameterisationPolyconeRho(), G4ParameterisationPolyconeZ::G4ParameterisationPolyconeZ(), G4ParameterisationPolyhedraPhi::G4ParameterisationPolyhedraPhi(), G4ParameterisationPolyhedraRho::G4ParameterisationPolyhedraRho(), G4ParameterisationPolyhedraZ::G4ParameterisationPolyhedraZ(), G4ParameterisationTrdX::G4ParameterisationTrdX(), G4ParameterisationTrdY::G4ParameterisationTrdY(), G4ParameterisationTrdZ::G4ParameterisationTrdZ(), G4ParameterisationTubsPhi::G4ParameterisationTubsPhi(), G4ParameterisationTubsRho::G4ParameterisationTubsRho(), G4ParameterisationTubsZ::G4ParameterisationTubsZ(), G4VDivisionParameterisation::G4VDivisionParameterisation(), G4VParameterisationBox::G4VParameterisationBox(), G4VParameterisationCons::G4VParameterisationCons(), G4VParameterisationPara::G4VParameterisationPara(), G4VParameterisationPolycone::G4VParameterisationPolycone(), G4VParameterisationPolyhedra::G4VParameterisationPolyhedra(), G4VParameterisationTrd::G4VParameterisationTrd(), G4VParameterisationTubs::G4VParameterisationTubs(), G4VTwistSurface::GetBoundaryAxis(), G4VTwistSurface::GetCorner(), G4ClippablePolygon::GetExtent(), G4VCSGfaceted::GetExtent(), G4HnInformation::GetIsLogAxis(), G4ClippablePolygon::GetMaxPoint(), G4ClippablePolygon::GetMinPoint(), GetRegularStructureId(), G4PVParameterised::GetReplicationData(), G4VPhysicalVolume::GetReplicationData(), GetReplicationData(), G4Voxelizer::GetTotalCandidates(), GIDI::Functions::Gridded1d::Gridded1d(), MCGIDI::Distributions::IncoherentElasticTNSL::IncoherentElasticTNSL(), G4ClippablePolygon::InFrontOf(), G4ReplicaNavigation::Inside(), G4AffineTransform::InverseTransformAxis(), G4OpenInventorQtExaminerViewer::loadViewPts(), G4OpenInventorXtExaminerViewer::loadViewPts(), G4ReflectionFactory::operator=(), GIDI::Axes::operator=(), xpath_parser::parse_step(), G4GDMLReadStructure::ReplicaRead(), G4ReflectionFactory::Replicate(), G4GDMLWriteStructure::ReplicavolWrite(), G4ASCIITreeSceneHandler::RequestPrimitives(), CLHEP::Hep3Vector::rotate(), CLHEP::HepLorentzRotation::rotate(), CLHEP::HepLorentzRotation::rotate(), G4INCL::ThreeVector::rotate(), G4INCL::Cluster::rotateMomentum(), G4INCL::Particle::rotateMomentum(), G4INCL::ParticleList::rotateMomentum(), G4INCL::Cluster::rotatePosition(), G4INCL::Particle::rotatePosition(), G4INCL::ParticleList::rotatePosition(), G4INCL::Particle::rotatePositionAndMomentum(), G4INCL::ParticleList::rotatePositionAndMomentum(), CLHEP::rotationOf(), G4OpenInventorQtExaminerViewer::saveViewPt(), G4tgrPlaceDivRep::SetAxis(), G4VTwistSurface::SetAxis(), G4tgbVolume::SetCutsInEnergy(), G4HnInformation::SetIsLogAxis(), G4ClippablePolygon::SetNormal(), G4OpenInventorQtExaminerViewer::sortViewPts(), G4AffineTransform::TransformAxis(), G4PhysicalVolumeModel::VisitGeometryAndGetVisReps(), xpath_ast_node::xpath_ast_node(), G4PVParameterised::~G4PVParameterised(), and G4QuadrangularFacet::~G4QuadrangularFacet().

◆ xml_memory_management_function_storage< T >::allocate

◆ xml_memory_management_function_storage< T >::deallocate

template<typename T>
deallocation_function xml_memory_management_function_storage< T >::deallocate = default_deallocate

Definition at line 206 of file pugixml.cc.

Referenced by pugi::set_memory_management_functions().