|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/**
|
|
|
|
|
* pugixml parser - version 1.6
|
|
|
|
|
* pugixml parser - version 1.9
|
|
|
|
|
* --------------------------------------------------------
|
|
|
|
|
* Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
|
|
|
|
|
* Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
|
|
|
|
|
* Report bugs and download new versions at http://pugixml.org/
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed under the MIT License. See notice at the end
|
|
|
|
@ -13,7 +13,7 @@
|
|
|
|
|
|
|
|
|
|
#ifndef PUGIXML_VERSION
|
|
|
|
|
// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons
|
|
|
|
|
# define PUGIXML_VERSION 160
|
|
|
|
|
# define PUGIXML_VERSION 190
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Include user configuration file (this can define various configuration macros)
|
|
|
|
@ -72,6 +72,44 @@
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// If the platform is known to have move semantics support, compile move ctor/operator implementation
|
|
|
|
|
#ifndef PUGIXML_HAS_MOVE
|
|
|
|
|
# if __cplusplus >= 201103
|
|
|
|
|
# define PUGIXML_HAS_MOVE
|
|
|
|
|
# elif defined(_MSC_VER) && _MSC_VER >= 1600
|
|
|
|
|
# define PUGIXML_HAS_MOVE
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// If C++ is 2011 or higher, add 'noexcept' specifiers
|
|
|
|
|
#ifndef PUGIXML_NOEXCEPT
|
|
|
|
|
# if __cplusplus >= 201103
|
|
|
|
|
# define PUGIXML_NOEXCEPT noexcept
|
|
|
|
|
# elif defined(_MSC_VER) && _MSC_VER >= 1900
|
|
|
|
|
# define PUGIXML_NOEXCEPT noexcept
|
|
|
|
|
# else
|
|
|
|
|
# define PUGIXML_NOEXCEPT
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Some functions can not be noexcept in compact mode
|
|
|
|
|
#ifdef PUGIXML_COMPACT
|
|
|
|
|
# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
|
|
|
|
|
#else
|
|
|
|
|
# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// If C++ is 2011 or higher, add 'override' qualifiers
|
|
|
|
|
#ifndef PUGIXML_OVERRIDE
|
|
|
|
|
# if __cplusplus >= 201103
|
|
|
|
|
# define PUGIXML_OVERRIDE override
|
|
|
|
|
# elif defined(_MSC_VER) && _MSC_VER >= 1700
|
|
|
|
|
# define PUGIXML_OVERRIDE override
|
|
|
|
|
# else
|
|
|
|
|
# define PUGIXML_OVERRIDE
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Character interface macros
|
|
|
|
|
#ifdef PUGIXML_WCHAR_MODE
|
|
|
|
|
# define PUGIXML_TEXT(t) L ## t
|
|
|
|
@ -133,13 +171,13 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
// This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
|
|
|
|
|
const unsigned int parse_eol = 0x0020;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
|
|
|
|
|
const unsigned int parse_wconv_attribute = 0x0040;
|
|
|
|
|
|
|
|
|
|
// This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
|
|
|
|
|
const unsigned int parse_wnorm_attribute = 0x0080;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
|
|
|
|
|
const unsigned int parse_declaration = 0x0100;
|
|
|
|
|
|
|
|
|
@ -158,6 +196,11 @@ namespace pugi
|
|
|
|
|
// is a valid document. This flag is off by default.
|
|
|
|
|
const unsigned int parse_fragment = 0x1000;
|
|
|
|
|
|
|
|
|
|
// This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of
|
|
|
|
|
// the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments.
|
|
|
|
|
// This flag is off by default.
|
|
|
|
|
const unsigned int parse_embed_pcdata = 0x2000;
|
|
|
|
|
|
|
|
|
|
// The default parsing mode.
|
|
|
|
|
// Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
|
|
|
|
|
// End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
|
|
|
|
@ -184,16 +227,16 @@ namespace pugi
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Formatting flags
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Indent the nodes that are written to output stream with as many indentation strings as deep the node is in DOM tree. This flag is on by default.
|
|
|
|
|
const unsigned int format_indent = 0x01;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write encoding-specific BOM to the output stream. This flag is off by default.
|
|
|
|
|
const unsigned int format_write_bom = 0x02;
|
|
|
|
|
|
|
|
|
|
// Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
|
|
|
|
|
const unsigned int format_raw = 0x04;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
|
|
|
|
|
const unsigned int format_no_declaration = 0x08;
|
|
|
|
|
|
|
|
|
@ -206,6 +249,9 @@ namespace pugi
|
|
|
|
|
// Write every attribute on a new line with appropriate indentation. This flag is off by default.
|
|
|
|
|
const unsigned int format_indent_attributes = 0x40;
|
|
|
|
|
|
|
|
|
|
// Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default.
|
|
|
|
|
const unsigned int format_no_empty_element_tags = 0x80;
|
|
|
|
|
|
|
|
|
|
// The default set of formatting flags.
|
|
|
|
|
// Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
|
|
|
|
|
const unsigned int format_default = format_indent;
|
|
|
|
@ -225,7 +271,7 @@ namespace pugi
|
|
|
|
|
class xml_node;
|
|
|
|
|
|
|
|
|
|
class xml_text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PUGIXML_NO_XPATH
|
|
|
|
|
class xpath_node;
|
|
|
|
|
class xpath_node_set;
|
|
|
|
@ -268,7 +314,7 @@ namespace pugi
|
|
|
|
|
// Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio
|
|
|
|
|
xml_writer_file(void* file);
|
|
|
|
|
|
|
|
|
|
virtual void write(const void* data, size_t size);
|
|
|
|
|
virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void* file;
|
|
|
|
@ -283,7 +329,7 @@ namespace pugi
|
|
|
|
|
xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
|
|
|
|
|
xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
|
|
|
|
|
|
|
|
|
|
virtual void write(const void* data, size_t size);
|
|
|
|
|
virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
|
|
|
|
@ -299,13 +345,13 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
xml_attribute_struct* _attr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*unspecified_bool_type)(xml_attribute***);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Default constructor. Constructs an empty attribute.
|
|
|
|
|
xml_attribute();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Constructs attribute from internal pointer
|
|
|
|
|
explicit xml_attribute(xml_attribute_struct* attr);
|
|
|
|
|
|
|
|
|
@ -354,6 +400,8 @@ namespace pugi
|
|
|
|
|
// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
|
|
|
|
|
bool set_value(int rhs);
|
|
|
|
|
bool set_value(unsigned int rhs);
|
|
|
|
|
bool set_value(long rhs);
|
|
|
|
|
bool set_value(unsigned long rhs);
|
|
|
|
|
bool set_value(double rhs);
|
|
|
|
|
bool set_value(float rhs);
|
|
|
|
|
bool set_value(bool rhs);
|
|
|
|
@ -367,6 +415,8 @@ namespace pugi
|
|
|
|
|
xml_attribute& operator=(const char_t* rhs);
|
|
|
|
|
xml_attribute& operator=(int rhs);
|
|
|
|
|
xml_attribute& operator=(unsigned int rhs);
|
|
|
|
|
xml_attribute& operator=(long rhs);
|
|
|
|
|
xml_attribute& operator=(unsigned long rhs);
|
|
|
|
|
xml_attribute& operator=(double rhs);
|
|
|
|
|
xml_attribute& operator=(float rhs);
|
|
|
|
|
xml_attribute& operator=(bool rhs);
|
|
|
|
@ -417,7 +467,7 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
// Borland C++ workaround
|
|
|
|
|
bool operator!() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Comparison operators (compares wrapped node pointers)
|
|
|
|
|
bool operator==(const xml_node& r) const;
|
|
|
|
|
bool operator!=(const xml_node& r) const;
|
|
|
|
@ -438,7 +488,7 @@ namespace pugi
|
|
|
|
|
// Get node value, or "" if node is empty or it has no value
|
|
|
|
|
// Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
|
|
|
|
|
const char_t* value() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get attribute list
|
|
|
|
|
xml_attribute first_attribute() const;
|
|
|
|
|
xml_attribute last_attribute() const;
|
|
|
|
@ -450,7 +500,7 @@ namespace pugi
|
|
|
|
|
// Get next/previous sibling in the children list of the parent node
|
|
|
|
|
xml_node next_sibling() const;
|
|
|
|
|
xml_node previous_sibling() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get parent node
|
|
|
|
|
xml_node parent() const;
|
|
|
|
|
|
|
|
|
@ -478,7 +528,7 @@ namespace pugi
|
|
|
|
|
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
|
|
|
|
|
bool set_name(const char_t* rhs);
|
|
|
|
|
bool set_value(const char_t* rhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
|
|
|
|
|
xml_attribute append_attribute(const char_t* name);
|
|
|
|
|
xml_attribute prepend_attribute(const char_t* name);
|
|
|
|
@ -532,11 +582,11 @@ namespace pugi
|
|
|
|
|
template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
|
|
|
|
|
{
|
|
|
|
|
if (!_root) return xml_attribute();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
|
|
|
|
|
if (pred(attrib))
|
|
|
|
|
return attrib;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return xml_attribute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -544,11 +594,11 @@ namespace pugi
|
|
|
|
|
template <typename Predicate> xml_node find_child(Predicate pred) const
|
|
|
|
|
{
|
|
|
|
|
if (!_root) return xml_node();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (xml_node node = first_child(); node; node = node.next_sibling())
|
|
|
|
|
if (pred(node))
|
|
|
|
|
return node;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return xml_node();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -558,7 +608,7 @@ namespace pugi
|
|
|
|
|
if (!_root) return xml_node();
|
|
|
|
|
|
|
|
|
|
xml_node cur = first_child();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (cur._root && cur._root != _root)
|
|
|
|
|
{
|
|
|
|
|
if (pred(cur)) return cur;
|
|
|
|
@ -590,7 +640,7 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
// Recursively traverse subtree with xml_tree_walker
|
|
|
|
|
bool traverse(xml_tree_walker& walker);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PUGIXML_NO_XPATH
|
|
|
|
|
// Select single node by evaluating XPath query. Returns first node from the resulting node set.
|
|
|
|
|
xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
|
|
|
@ -601,11 +651,11 @@ namespace pugi
|
|
|
|
|
xpath_node_set select_nodes(const xpath_query& query) const;
|
|
|
|
|
|
|
|
|
|
// (deprecated: use select_node instead) Select single node by evaluating XPath query.
|
|
|
|
|
xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
|
|
|
|
xpath_node select_single_node(const xpath_query& query) const;
|
|
|
|
|
PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
|
|
|
|
PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Print subtree using a writer object
|
|
|
|
|
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
|
|
|
|
|
|
|
|
|
@ -701,6 +751,8 @@ namespace pugi
|
|
|
|
|
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
|
|
|
|
|
bool set(int rhs);
|
|
|
|
|
bool set(unsigned int rhs);
|
|
|
|
|
bool set(long rhs);
|
|
|
|
|
bool set(unsigned long rhs);
|
|
|
|
|
bool set(double rhs);
|
|
|
|
|
bool set(float rhs);
|
|
|
|
|
bool set(bool rhs);
|
|
|
|
@ -714,6 +766,8 @@ namespace pugi
|
|
|
|
|
xml_text& operator=(const char_t* rhs);
|
|
|
|
|
xml_text& operator=(int rhs);
|
|
|
|
|
xml_text& operator=(unsigned int rhs);
|
|
|
|
|
xml_text& operator=(long rhs);
|
|
|
|
|
xml_text& operator=(unsigned long rhs);
|
|
|
|
|
xml_text& operator=(double rhs);
|
|
|
|
|
xml_text& operator=(float rhs);
|
|
|
|
|
xml_text& operator=(bool rhs);
|
|
|
|
@ -867,11 +921,11 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int _depth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// Get current traversal depth
|
|
|
|
|
int depth() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
xml_tree_walker();
|
|
|
|
|
virtual ~xml_tree_walker();
|
|
|
|
@ -942,13 +996,14 @@ namespace pugi
|
|
|
|
|
char_t* _buffer;
|
|
|
|
|
|
|
|
|
|
char _memory[192];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Non-copyable semantics
|
|
|
|
|
xml_document(const xml_document&);
|
|
|
|
|
const xml_document& operator=(const xml_document&);
|
|
|
|
|
xml_document& operator=(const xml_document&);
|
|
|
|
|
|
|
|
|
|
void create();
|
|
|
|
|
void destroy();
|
|
|
|
|
void _create();
|
|
|
|
|
void _destroy();
|
|
|
|
|
void _move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Default constructor, makes empty document
|
|
|
|
@ -957,6 +1012,12 @@ namespace pugi
|
|
|
|
|
// Destructor, invalidates all node/attribute handles to this document
|
|
|
|
|
~xml_document();
|
|
|
|
|
|
|
|
|
|
#ifdef PUGIXML_HAS_MOVE
|
|
|
|
|
// Move semantics support
|
|
|
|
|
xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
|
|
|
|
|
xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Removes all nodes, leaving the empty document
|
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
|
@ -970,7 +1031,7 @@ namespace pugi
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
|
|
|
|
|
xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
|
|
|
|
|
PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
|
|
|
|
|
|
|
|
|
|
// Load document from zero-terminated string. No encoding conversions are applied.
|
|
|
|
|
xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
|
|
|
|
@ -1051,7 +1112,7 @@ namespace pugi
|
|
|
|
|
// Non-copyable semantics
|
|
|
|
|
xpath_variable(const xpath_variable&);
|
|
|
|
|
xpath_variable& operator=(const xpath_variable&);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Get variable name
|
|
|
|
|
const char_t* name() const;
|
|
|
|
@ -1095,10 +1156,10 @@ namespace pugi
|
|
|
|
|
xpath_variable_set(const xpath_variable_set& rhs);
|
|
|
|
|
xpath_variable_set& operator=(const xpath_variable_set& rhs);
|
|
|
|
|
|
|
|
|
|
#if __cplusplus >= 201103
|
|
|
|
|
#ifdef PUGIXML_HAS_MOVE
|
|
|
|
|
// Move semantics support
|
|
|
|
|
xpath_variable_set(xpath_variable_set&& rhs);
|
|
|
|
|
xpath_variable_set& operator=(xpath_variable_set&& rhs);
|
|
|
|
|
xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Add a new variable or get the existing one, if the types match
|
|
|
|
@ -1139,29 +1200,29 @@ namespace pugi
|
|
|
|
|
// Destructor
|
|
|
|
|
~xpath_query();
|
|
|
|
|
|
|
|
|
|
#if __cplusplus >= 201103
|
|
|
|
|
#ifdef PUGIXML_HAS_MOVE
|
|
|
|
|
// Move semantics support
|
|
|
|
|
xpath_query(xpath_query&& rhs);
|
|
|
|
|
xpath_query& operator=(xpath_query&& rhs);
|
|
|
|
|
xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Get query expression return type
|
|
|
|
|
xpath_value_type return_type() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
|
|
|
|
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
|
|
|
|
bool evaluate_boolean(const xpath_node& n) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Evaluate expression as double value in the specified context; performs type conversion if necessary.
|
|
|
|
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
|
|
|
|
double evaluate_number(const xpath_node& n) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PUGIXML_NO_STL
|
|
|
|
|
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
|
|
|
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
|
|
|
|
string_t evaluate_string(const xpath_node& n) const;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
|
|
|
|
|
// At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
|
|
|
|
|
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
|
|
|
|
@ -1188,7 +1249,7 @@ namespace pugi
|
|
|
|
|
// Borland C++ workaround
|
|
|
|
|
bool operator!() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PUGIXML_NO_EXCEPTIONS
|
|
|
|
|
// XPath exception class
|
|
|
|
|
class PUGIXML_CLASS xpath_exception: public std::exception
|
|
|
|
@ -1201,26 +1262,26 @@ namespace pugi
|
|
|
|
|
explicit xpath_exception(const xpath_parse_result& result);
|
|
|
|
|
|
|
|
|
|
// Get error message
|
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
|
virtual const char* what() const throw() PUGIXML_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
// Get parse result
|
|
|
|
|
const xpath_parse_result& result() const;
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// XPath node class (either xml_node or xml_attribute)
|
|
|
|
|
class PUGIXML_CLASS xpath_node
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
xml_node _node;
|
|
|
|
|
xml_attribute _attribute;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*unspecified_bool_type)(xpath_node***);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Default constructor; constructs empty XPath node
|
|
|
|
|
xpath_node();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Construct XPath node from XML node/attribute
|
|
|
|
|
xpath_node(const xml_node& node);
|
|
|
|
|
xpath_node(const xml_attribute& attribute, const xml_node& parent);
|
|
|
|
@ -1228,13 +1289,13 @@ namespace pugi
|
|
|
|
|
// Get node/attribute, if any
|
|
|
|
|
xml_node node() const;
|
|
|
|
|
xml_attribute attribute() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get parent of contained node/attribute
|
|
|
|
|
xml_node parent() const;
|
|
|
|
|
|
|
|
|
|
// Safe bool conversion operator
|
|
|
|
|
operator unspecified_bool_type() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Borland C++ workaround
|
|
|
|
|
bool operator!() const;
|
|
|
|
|
|
|
|
|
@ -1260,13 +1321,13 @@ namespace pugi
|
|
|
|
|
type_sorted, // Sorted by document order (ascending)
|
|
|
|
|
type_sorted_reverse // Sorted by document order (descending)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Constant iterator type
|
|
|
|
|
typedef const xpath_node* const_iterator;
|
|
|
|
|
|
|
|
|
|
// We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
|
|
|
|
|
typedef const xpath_node* iterator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Default constructor. Constructs empty set.
|
|
|
|
|
xpath_node_set();
|
|
|
|
|
|
|
|
|
@ -1275,49 +1336,49 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
|
~xpath_node_set();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy constructor/assignment operator
|
|
|
|
|
xpath_node_set(const xpath_node_set& ns);
|
|
|
|
|
xpath_node_set& operator=(const xpath_node_set& ns);
|
|
|
|
|
|
|
|
|
|
#if __cplusplus >= 201103
|
|
|
|
|
#ifdef PUGIXML_HAS_MOVE
|
|
|
|
|
// Move semantics support
|
|
|
|
|
xpath_node_set(xpath_node_set&& rhs);
|
|
|
|
|
xpath_node_set& operator=(xpath_node_set&& rhs);
|
|
|
|
|
xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Get collection type
|
|
|
|
|
type_t type() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get collection size
|
|
|
|
|
size_t size() const;
|
|
|
|
|
|
|
|
|
|
// Indexing operator
|
|
|
|
|
const xpath_node& operator[](size_t index) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Collection iterators
|
|
|
|
|
const_iterator begin() const;
|
|
|
|
|
const_iterator end() const;
|
|
|
|
|
|
|
|
|
|
// Sort the collection in ascending/descending order by document order
|
|
|
|
|
void sort(bool reverse = false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get first node in the collection by document order
|
|
|
|
|
xpath_node first() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if collection is empty
|
|
|
|
|
bool empty() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
type_t _type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xpath_node _storage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xpath_node* _begin;
|
|
|
|
|
xpath_node* _end;
|
|
|
|
|
|
|
|
|
|
void _assign(const_iterator begin, const_iterator end, type_t type);
|
|
|
|
|
void _move(xpath_node_set& rhs);
|
|
|
|
|
void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT;
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -1325,7 +1386,7 @@ namespace pugi
|
|
|
|
|
// Convert wide string to UTF8
|
|
|
|
|
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
|
|
|
|
|
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Convert UTF8 to wide string
|
|
|
|
|
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
|
|
|
|
|
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >& str);
|
|
|
|
@ -1333,13 +1394,13 @@ namespace pugi
|
|
|
|
|
|
|
|
|
|
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure
|
|
|
|
|
typedef void* (*allocation_function)(size_t size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Memory deallocation function interface
|
|
|
|
|
typedef void (*deallocation_function)(void* ptr);
|
|
|
|
|
|
|
|
|
|
// Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
|
|
|
|
|
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get current memory management functions
|
|
|
|
|
allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
|
|
|
|
|
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
|
|
|
|
@ -1375,7 +1436,7 @@ namespace std
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2006-2015 Arseny Kapoulkine
|
|
|
|
|
* Copyright (c) 2006-2018 Arseny Kapoulkine
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
@ -1388,7 +1449,7 @@ namespace std
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|