| pugixml.hpp | | pugixml.hpp | |
| /** | | /** | |
|
| * pugixml parser - version 1.4 | | * pugixml parser - version 1.5 | |
| * -------------------------------------------------------- | | * -------------------------------------------------------- | |
| * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.c
om) | | * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.c
om) | |
| * Report bugs and download new versions at http://pugixml.org/ | | * Report bugs and download new versions at http://pugixml.org/ | |
| * | | * | |
| * This library is distributed under the MIT License. See notice at the end | | * This library is distributed under the MIT License. See notice at the end | |
| * of this file. | | * of this file. | |
| * | | * | |
| * This work is based on the pugxml parser, which is: | | * This work is based on the pugxml parser, which is: | |
| * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) | | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) | |
| */ | | */ | |
| | | | |
| #ifndef PUGIXML_VERSION | | #ifndef PUGIXML_VERSION | |
| // Define version macro; evaluates to major * 100 + minor so that it's safe
to use in less-than comparisons | | // Define version macro; evaluates to major * 100 + minor so that it's safe
to use in less-than comparisons | |
|
| # define PUGIXML_VERSION 140 | | # define PUGIXML_VERSION 150 | |
| #endif | | #endif | |
| | | | |
| // Include user configuration file (this can define various configuration m
acros) | | // Include user configuration file (this can define various configuration m
acros) | |
| #include "pugiconfig.hpp" | | #include "pugiconfig.hpp" | |
| | | | |
| #ifndef HEADER_PUGIXML_HPP | | #ifndef HEADER_PUGIXML_HPP | |
| #define HEADER_PUGIXML_HPP | | #define HEADER_PUGIXML_HPP | |
| | | | |
| // Include stddef.h for size_t and ptrdiff_t | | // Include stddef.h for size_t and ptrdiff_t | |
| #include <stddef.h> | | #include <stddef.h> | |
| | | | |
| skipping to change at line 504 | | skipping to change at line 504 | |
| xml_node prepend_child(const char_t* name); | | xml_node prepend_child(const char_t* name); | |
| xml_node insert_child_after(const char_t* name, const xml_no
de& node); | | xml_node insert_child_after(const char_t* name, const xml_no
de& node); | |
| xml_node insert_child_before(const char_t* name, const xml_n
ode& node); | | xml_node insert_child_before(const char_t* name, const xml_n
ode& node); | |
| | | | |
| // Add a copy of the specified node as a child. Returns adde
d node, or empty node on errors. | | // Add a copy of the specified node as a child. Returns adde
d node, or empty node on errors. | |
| xml_node append_copy(const xml_node& proto); | | xml_node append_copy(const xml_node& proto); | |
| xml_node prepend_copy(const xml_node& proto); | | xml_node prepend_copy(const xml_node& proto); | |
| xml_node insert_copy_after(const xml_node& proto, const xml_
node& node); | | xml_node insert_copy_after(const xml_node& proto, const xml_
node& node); | |
| xml_node insert_copy_before(const xml_node& proto, const xml
_node& node); | | xml_node insert_copy_before(const xml_node& proto, const xml
_node& node); | |
| | | | |
|
| | | // Move the specified node to become a child of this node. R | |
| | | eturns moved node, or empty node on errors. | |
| | | xml_node append_move(const xml_node& moved); | |
| | | xml_node prepend_move(const xml_node& moved); | |
| | | xml_node insert_move_after(const xml_node& moved, const xml_ | |
| | | node& node); | |
| | | xml_node insert_move_before(const xml_node& moved, const xml | |
| | | _node& node); | |
| | | | |
| // Remove specified attribute | | // Remove specified attribute | |
| bool remove_attribute(const xml_attribute& a); | | bool remove_attribute(const xml_attribute& a); | |
| bool remove_attribute(const char_t* name); | | bool remove_attribute(const char_t* name); | |
| | | | |
| // Remove specified child | | // Remove specified child | |
| bool remove_child(const xml_node& n); | | bool remove_child(const xml_node& n); | |
| bool remove_child(const char_t* name); | | bool remove_child(const char_t* name); | |
| | | | |
| // Parses buffer as an XML document fragment and appends all
nodes as children of the current node. | | // Parses buffer as an XML document fragment and appends all
nodes as children of the current node. | |
| // Copies/converts the buffer, so it may be deleted or chang
ed after the function returns. | | // Copies/converts the buffer, so it may be deleted or chang
ed after the function returns. | |
| | | | |
| skipping to change at line 582 | | skipping to change at line 588 | |
| #endif | | #endif | |
| | | | |
| // Search for a node by path consisting of node names and .
or .. elements. | | // Search for a node by path consisting of node names and .
or .. elements. | |
| xml_node first_element_by_path(const char_t* path, char_t de
limiter = '/') const; | | xml_node first_element_by_path(const char_t* path, char_t de
limiter = '/') const; | |
| | | | |
| // Recursively traverse subtree with xml_tree_walker | | // Recursively traverse subtree with xml_tree_walker | |
| bool traverse(xml_tree_walker& walker); | | bool traverse(xml_tree_walker& walker); | |
| | | | |
| #ifndef PUGIXML_NO_XPATH | | #ifndef PUGIXML_NO_XPATH | |
| // Select single node by evaluating XPath query. Returns fir
st node from the resulting node set. | | // Select single node by evaluating XPath query. Returns fir
st node from the resulting node set. | |
|
| xpath_node select_single_node(const char_t* query, xpath_var | | xpath_node select_node(const char_t* query, xpath_variable_s | |
| iable_set* variables = 0) const; | | et* variables = 0) const; | |
| xpath_node select_single_node(const xpath_query& query) cons | | xpath_node select_node(const xpath_query& query) const; | |
| t; | | | |
| | | | |
| // Select node set by evaluating XPath query | | // Select node set by evaluating XPath query | |
| xpath_node_set select_nodes(const char_t* query, xpath_varia
ble_set* variables = 0) const; | | xpath_node_set select_nodes(const char_t* query, xpath_varia
ble_set* variables = 0) const; | |
| xpath_node_set select_nodes(const xpath_query& query) const; | | 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_var | |
| | | iable_set* variables = 0) const; | |
| | | xpath_node select_single_node(const xpath_query& query) cons | |
| | | t; | |
| | | | |
| #endif | | #endif | |
| | | | |
| // Print subtree using a writer object | | // Print subtree using a writer object | |
| void print(xml_writer& writer, const char_t* indent = PUGIXM
L_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding =
encoding_auto, unsigned int depth = 0) const; | | void print(xml_writer& writer, const char_t* indent = PUGIXM
L_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding =
encoding_auto, unsigned int depth = 0) const; | |
| | | | |
| #ifndef PUGIXML_NO_STL | | #ifndef PUGIXML_NO_STL | |
| // Print subtree to stream | | // Print subtree to stream | |
| void print(std::basic_ostream<char, std::char_traits<char> >
& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = forma
t_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) c
onst; | | void print(std::basic_ostream<char, std::char_traits<char> >
& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = forma
t_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) c
onst; | |
| void print(std::basic_ostream<wchar_t, std::char_traits<wcha
r_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags =
format_default, unsigned int depth = 0) const; | | void print(std::basic_ostream<wchar_t, std::char_traits<wcha
r_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags =
format_default, unsigned int depth = 0) const; | |
| #endif | | #endif | |
| | | | |
| skipping to change at line 951 | | skipping to change at line 962 | |
| | | | |
| // Removes all nodes, then copies the entire contents of the
specified document | | // Removes all nodes, then copies the entire contents of the
specified document | |
| void reset(const xml_document& proto); | | void reset(const xml_document& proto); | |
| | | | |
| #ifndef PUGIXML_NO_STL | | #ifndef PUGIXML_NO_STL | |
| // Load document from stream. | | // Load document from stream. | |
| xml_parse_result load(std::basic_istream<char, std::char_tra
its<char> >& stream, unsigned int options = parse_default, xml_encoding enc
oding = encoding_auto); | | xml_parse_result load(std::basic_istream<char, std::char_tra
its<char> >& stream, unsigned int options = parse_default, xml_encoding enc
oding = encoding_auto); | |
| xml_parse_result load(std::basic_istream<wchar_t, std::char_
traits<wchar_t> >& stream, unsigned int options = parse_default); | | xml_parse_result load(std::basic_istream<wchar_t, std::char_
traits<wchar_t> >& stream, unsigned int options = parse_default); | |
| #endif | | #endif | |
| | | | |
|
| // Load document from zero-terminated string. No encoding co
nversions are applied. | | // (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 o
ptions = parse_default); | | xml_parse_result load(const char_t* contents, unsigned int o
ptions = parse_default); | |
| | | | |
|
| | | // Load document from zero-terminated string. No encoding co | |
| | | nversions are applied. | |
| | | xml_parse_result load_string(const char_t* contents, unsigne | |
| | | d int options = parse_default); | |
| | | | |
| // Load document from file | | // Load document from file | |
| xml_parse_result load_file(const char* path, unsigned int op
tions = parse_default, xml_encoding encoding = encoding_auto); | | xml_parse_result load_file(const char* path, unsigned int op
tions = parse_default, xml_encoding encoding = encoding_auto); | |
| xml_parse_result load_file(const wchar_t* path, unsigned int
options = parse_default, xml_encoding encoding = encoding_auto); | | xml_parse_result load_file(const wchar_t* path, unsigned int
options = parse_default, xml_encoding encoding = encoding_auto); | |
| | | | |
| // Load document from buffer. Copies/converts the buffer, so
it may be deleted or changed after the function returns. | | // Load document from buffer. Copies/converts the buffer, so
it may be deleted or changed after the function returns. | |
| xml_parse_result load_buffer(const void* contents, size_t si
ze, unsigned int options = parse_default, xml_encoding encoding = encoding_
auto); | | xml_parse_result load_buffer(const void* contents, size_t si
ze, unsigned int options = parse_default, xml_encoding encoding = encoding_
auto); | |
| | | | |
| // Load document from buffer, using the buffer for in-place
parsing (the buffer is modified and used for storage of document data). | | // Load document from buffer, using the buffer for in-place
parsing (the buffer is modified and used for storage of document data). | |
| // You should ensure that buffer data will persist throughou
t the document's lifetime, and free the buffer memory manually once documen
t is destroyed. | | // You should ensure that buffer data will persist throughou
t the document's lifetime, and free the buffer memory manually once documen
t is destroyed. | |
| xml_parse_result load_buffer_inplace(void* contents, size_t
size, unsigned int options = parse_default, xml_encoding encoding = encodin
g_auto); | | xml_parse_result load_buffer_inplace(void* contents, size_t
size, unsigned int options = parse_default, xml_encoding encoding = encodin
g_auto); | |
| | | | |
| skipping to change at line 1131 | | skipping to change at line 1145 | |
| // At most capacity characters are written to the destinatio
n buffer, full result size is returned (includes terminating zero). | | // At most capacity characters are written to the destinatio
n 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. | | // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_
alloc on out of memory errors. | |
| // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set i
nstead. | | // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set i
nstead. | |
| size_t evaluate_string(char_t* buffer, size_t capacity, cons
t xpath_node& n) const; | | size_t evaluate_string(char_t* buffer, size_t capacity, cons
t xpath_node& n) const; | |
| | | | |
| // Evaluate expression as node set in the specified context. | | // Evaluate expression as node set in the specified context. | |
| // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exc
eption on type mismatch and std::bad_alloc on out of memory errors. | | // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exc
eption on type mismatch and std::bad_alloc on out of memory errors. | |
| // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node s
et instead. | | // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node s
et instead. | |
| xpath_node_set evaluate_node_set(const xpath_node& n) const; | | xpath_node_set evaluate_node_set(const xpath_node& n) const; | |
| | | | |
|
| | | // Evaluate expression as node set in the specified context. | |
| | | // Return first node in document order, or empty node if nod | |
| | | e set is empty. | |
| | | // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exc | |
| | | eption on type mismatch and std::bad_alloc on out of memory errors. | |
| | | // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node i | |
| | | nstead. | |
| | | xpath_node evaluate_node(const xpath_node& n) const; | |
| | | | |
| // Get parsing result (used to get compilation errors in PUG
IXML_NO_EXCEPTIONS mode) | | // Get parsing result (used to get compilation errors in PUG
IXML_NO_EXCEPTIONS mode) | |
| const xpath_parse_result& result() const; | | const xpath_parse_result& result() const; | |
| | | | |
| // Safe bool conversion operator | | // Safe bool conversion operator | |
| operator unspecified_bool_type() const; | | operator unspecified_bool_type() const; | |
| | | | |
| // Borland C++ workaround | | // Borland C++ workaround | |
| bool operator!() const; | | bool operator!() const; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 1216 | | skipping to change at line 1236 | |
| enum type_t | | enum type_t | |
| { | | { | |
| type_unsorted, // Not ordered | | type_unsorted, // Not ordered | |
| type_sorted, // Sorted by documen
t order (ascending) | | type_sorted, // Sorted by documen
t order (ascending) | |
| type_sorted_reverse // Sorted by documen
t order (descending) | | type_sorted_reverse // Sorted by documen
t order (descending) | |
| }; | | }; | |
| | | | |
| // Constant iterator type | | // Constant iterator type | |
| typedef const xpath_node* const_iterator; | | typedef const xpath_node* const_iterator; | |
| | | | |
|
| | | // We define non-constant iterator to be the same as constan | |
| | | t iterator so that various generic algorithms (i.e. boost foreach) work | |
| | | typedef const xpath_node* iterator; | |
| | | | |
| // Default constructor. Constructs empty set. | | // Default constructor. Constructs empty set. | |
| xpath_node_set(); | | xpath_node_set(); | |
| | | | |
| // Constructs a set from iterator range; data is not checked
for duplicates and is not sorted according to provided type, so be careful | | // Constructs a set from iterator range; data is not checked
for duplicates and is not sorted according to provided type, so be careful | |
| xpath_node_set(const_iterator begin, const_iterator end, typ
e_t type = type_unsorted); | | xpath_node_set(const_iterator begin, const_iterator end, typ
e_t type = type_unsorted); | |
| | | | |
| // Destructor | | // Destructor | |
| ~xpath_node_set(); | | ~xpath_node_set(); | |
| | | | |
| // Copy constructor/assignment operator | | // Copy constructor/assignment operator | |
| | | | |
End of changes. 9 change blocks. |
| 7 lines changed or deleted | | 41 lines changed or added | |
|