"Framework/git@code.ornl.gov:mantidproject/mantid.git" did not exist on "b0fcaac3dd7ac41917373e544ac9bc28631c844b"
Newer
Older
PUGIXML_DEPRECATED xml_node next_sibling_w(const char_t* name) const;
arseny.kapoulkine
committed
/**
* Get following sibling
*
* \return following sibling node, if any; empty node otherwise
*/
xml_node next_sibling() const;
/**
* Get first of preceding sibling nodes with the specified name
*
* \param name - sibling name
* \return node with the specified name, if any; empty node otherwise
*/
xml_node previous_sibling(const char_t* name) const;
arseny.kapoulkine
committed
/**
* Get first of the preceding sibling nodes with the name that matches specified pattern
*
* \param name - sibling name pattern
* \return node with the name that matches pattern, if any; empty node otherwise
*
* \deprecated This function is deprecated
arseny.kapoulkine
committed
*/
PUGIXML_DEPRECATED xml_node previous_sibling_w(const char_t* name) const;
arseny.kapoulkine
committed
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
/**
* Get preceding sibling
*
* \return preceding sibling node, if any; empty node otherwise
*/
xml_node previous_sibling() const;
/**
* Get parent node
*
* \return parent node if any; empty node otherwise
*/
xml_node parent() const;
/**
* Get root of DOM tree this node belongs to.
*
* \return tree root
*/
xml_node root() const;
/**
* Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
*
* \return child value of current node, if any; "" otherwise
*/
const char_t* child_value() const;
arseny.kapoulkine
committed
/**
* Get child value of child with specified name. \see child_value
* node.child_value(name) is equivalent to node.child(name).child_value()
*
* \param name - child name
* \return child value of specified child node, if any; "" otherwise
*/
const char_t* child_value(const char_t* name) const;
arseny.kapoulkine
committed
/**
* Get child value of child with name that matches the specified pattern. \see child_value
* node.child_value_w(name) is equivalent to node.child_w(name).child_value()
*
* \param name - child name pattern
* \return child value of specified child node, if any; "" otherwise
*
* \deprecated This function is deprecated
arseny.kapoulkine
committed
*/
PUGIXML_DEPRECATED const char_t* child_value_w(const char_t* name) const;
arseny.kapoulkine
committed
public:
/**
* Set node name to \a rhs (for PI/element nodes). \see name
*
* \param rhs - new node name
* \return success flag (call fails if node is of the wrong type or there is not enough memory)
*/
bool set_name(const char_t* rhs);
arseny.kapoulkine
committed
/**
* Set node value to \a rhs (for PI/PCDATA/CDATA/comment nodes). \see value
*
* \param rhs - new node value
* \return success flag (call fails if node is of the wrong type or there is not enough memory)
*/
bool set_value(const char_t* rhs);
arseny.kapoulkine
committed
/**
* Add attribute with specified name (for element nodes)
*
* \param name - attribute name
* \return added attribute, or empty attribute if there was an error (wrong node type)
*/
xml_attribute append_attribute(const char_t* name);
arseny.kapoulkine
committed
/**
* Insert attribute with specified name after \a attr (for element nodes)
*
* \param name - attribute name
* \param attr - attribute to insert a new one after
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
arseny.kapoulkine
committed
/**
* Insert attribute with specified name before \a attr (for element nodes)
*
* \param name - attribute name
* \param attr - attribute to insert a new one before
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
arseny.kapoulkine
committed
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
/**
* Add a copy of the specified attribute (for element nodes)
*
* \param proto - attribute prototype which is to be copied
* \return inserted attribute, or empty attribute if there was an error (wrong node type)
*/
xml_attribute append_copy(const xml_attribute& proto);
/**
* Insert a copy of the specified attribute after \a attr (for element nodes)
*
* \param proto - attribute prototype which is to be copied
* \param attr - attribute to insert a new one after
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
/**
* Insert a copy of the specified attribute before \a attr (for element nodes)
*
* \param proto - attribute prototype which is to be copied
* \param attr - attribute to insert a new one before
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
/**
* Add child node with specified type (for element nodes)
*
* \param type - node type
* \return added node, or empty node if there was an error (wrong node type)
*/
xml_node append_child(xml_node_type type = node_element);
/**
* Insert child node with specified type after \a node (for element nodes)
*
* \param type - node type
* \param node - node to insert a new one after
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_child_after(xml_node_type type, const xml_node& node);
/**
* Insert child node with specified type before \a node (for element nodes)
*
* \param type - node type
* \param node - node to insert a new one before
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_child_before(xml_node_type type, const xml_node& node);
/**
* Add a copy of the specified node as a child (for element nodes)
*
* \param proto - node prototype which is to be copied
* \return inserted node, or empty node if there was an error (wrong node type)
*/
xml_node append_copy(const xml_node& proto);
/**
* Insert a copy of the specified node after \a node (for element nodes)
*
* \param proto - node prototype which is to be copied
* \param node - node to insert a new one after
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
/**
* Insert a copy of the specified node before \a node (for element nodes)
*
* \param proto - node prototype which is to be copied
* \param node - node to insert a new one before
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
/**
* Remove specified attribute
*
* \param a - attribute to be removed
*/
void remove_attribute(const xml_attribute& a);
/**
* Remove attribute with the specified name, if any
*
* \param name - attribute name
*/
void remove_attribute(const char_t* name);
arseny.kapoulkine
committed
/**
* Remove specified child
*
* \param n - child node to be removed
*/
void remove_child(const xml_node& n);
/**
* Remove child with the specified name, if any
*
* \param name - child name
*/
void remove_child(const char_t* name);
arseny.kapoulkine
committed
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
public:
/**
* Get first attribute
*
* \return first attribute, if any; empty attribute otherwise
*/
xml_attribute first_attribute() const;
/**
* Get last attribute
*
* \return last attribute, if any; empty attribute otherwise
*/
xml_attribute last_attribute() const;
/**
* Get all elements from subtree with given name
*
* \param name - node name
* \param it - output iterator (for example, std::back_insert_iterator (result of std::back_inserter))
*/
template <typename OutputIterator> void all_elements_by_name(const char_t* name, OutputIterator it) const
{
if (!_root) return;
for (xml_node node = first_child(); node; node = node.next_sibling())
{
if (node.type() == node_element)
{
if (impl::strequal(name, node.name()))
{
*it = node;
++it;
}
if (node.first_child()) node.all_elements_by_name(name, it);
}
}
}
arseny.kapoulkine
committed
/**
* Get all elements from subtree with name that matches given pattern
*
* \param name - node name pattern
* \param it - output iterator (for example, std::back_insert_iterator (result of std::back_inserter))
*
* \deprecated This function is deprecated
arseny.kapoulkine
committed
*/
template <typename OutputIterator> PUGIXML_DEPRECATED void all_elements_by_name_w(const char_t* name, OutputIterator it) const
all_elements_by_name_w_helper(name, it);
arseny.kapoulkine
committed
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
/**
* Get first child
*
* \return first child, if any; empty node otherwise
*/
xml_node first_child() const;
/**
* Get last child
*
* \return last child, if any; empty node otherwise
*/
xml_node last_child() const;
/**
* Find attribute using predicate
*
* \param pred - predicate, that takes xml_attribute and returns bool
* \return first attribute for which predicate returned true, or empty attribute
*/
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();
}
arseny.kapoulkine
committed
/**
* Find child node using predicate
*
* \param pred - predicate, that takes xml_node and returns bool
* \return first child node for which predicate returned true, or empty node
*/
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();
}
arseny.kapoulkine
committed
/**
* Find node from subtree using predicate
*
* \param pred - predicate, that takes xml_node and returns bool
* \return first node from subtree for which predicate returned true, or empty node
*/
template <typename Predicate> xml_node find_node(Predicate pred) const
{
if (!_root) return xml_node();
for (xml_node node = first_child(); node; node = node.next_sibling())
{
if (pred(node))
return node;
if (node.first_child())
{
xml_node found = node.find_node(pred);
if (found) return found;
}
}
return xml_node();
}
arseny.kapoulkine
committed
/**
* Find child node with the specified name that has specified attribute
*
* \param name - child node name
* \param attr_name - attribute name of child node
* \param attr_value - attribute value of child node
* \return first matching child node, or empty node
*/
xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
arseny.kapoulkine
committed
/**
* Find child node with the specified name that has specified attribute (use pattern matching for node name and attribute name/value)
*
* \param name - pattern for child node name
* \param attr_name - pattern for attribute name of child node
* \param attr_value - pattern for attribute value of child node
* \return first matching child node, or empty node
*
* \deprecated This function is deprecated
arseny.kapoulkine
committed
*/
PUGIXML_DEPRECATED xml_node find_child_by_attribute_w(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
arseny.kapoulkine
committed
/**
* Find child node that has specified attribute
*
* \param attr_name - attribute name of child node
* \param attr_value - attribute value of child node
* \return first matching child node, or empty node
*/
xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
arseny.kapoulkine
committed
/**
* Find child node that has specified attribute (use pattern matching for attribute name/value)
*
* \param attr_name - pattern for attribute name of child node
* \param attr_value - pattern for attribute value of child node
* \return first matching child node, or empty node
*
* \deprecated This function is deprecated
arseny.kapoulkine
committed
*/
PUGIXML_DEPRECATED xml_node find_child_by_attribute_w(const char_t* attr_name, const char_t* attr_value) const;
arseny.kapoulkine
committed
#ifndef PUGIXML_NO_STL
/**
* Get the absolute node path from root as a text string.
*
* \param delimiter - delimiter character to insert between element names
* \return path string (e.g. '/bookstore/book/author').
*/
string_t path(char_t delimiter = '/') const;
arseny.kapoulkine
committed
#endif
/**
* Search for a node by path.
* \param path - path string; e.g. './foo/bar' (relative to node), '/foo/bar' (relative
* to root), '../foo/bar'.
* \param delimiter - delimiter character to use while tokenizing path
* \return matching node, if any; empty node otherwise
*/
xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
arseny.kapoulkine
committed
/**
* Recursively traverse subtree with xml_tree_walker
* \see xml_tree_walker::begin
* \see xml_tree_walker::for_each
* \see xml_tree_walker::end
*
* \param walker - tree walker to traverse subtree with
* \return traversal result
*/
bool traverse(xml_tree_walker& walker);
#ifndef PUGIXML_NO_XPATH
/**
* Select single node by evaluating XPath query
*
* \param query - query string
* \return first node from the resulting node set by document order, or empty node if none found
*/
xpath_node select_single_node(const char_t* query) const;
arseny.kapoulkine
committed
/**
* Select single node by evaluating XPath query
*
* \param query - compiled query
* \return first node from the resulting node set by document order, or empty node if none found
*/
arseny.kapoulkine
committed
xpath_node select_single_node(const xpath_query& query) const;
arseny.kapoulkine
committed
/**
* Select node set by evaluating XPath query
*
* \param query - query string
* \return resulting node set
*/
xpath_node_set select_nodes(const char_t* query) const;
arseny.kapoulkine
committed
/**
* Select node set by evaluating XPath query
*
* \param query - compiled query
* \return resulting node set
*/
arseny.kapoulkine
committed
xpath_node_set select_nodes(const xpath_query& query) const;
arseny.kapoulkine
committed
#endif
/// \internal Document order or 0 if not set
/// \deprecated This function is deprecated
arseny.kapoulkine
committed
PUGIXML_DEPRECATED unsigned int document_order() const;
arseny.kapoulkine
committed
/**
* Print subtree to writer
*
* \param writer - writer object
* \param indent - indentation string
* \param flags - formatting flags
* \param encoding - encoding used for writing
arseny.kapoulkine
committed
* \param depth - starting depth (used for indentation)
*/
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto, unsigned int depth = 0) const;
arseny.kapoulkine
committed
#ifndef PUGIXML_NO_STL
/**
* Print subtree to stream
*
* \param os - output stream
* \param indent - indentation string
* \param flags - formatting flags
* \param encoding - encoding used for writing
arseny.kapoulkine
committed
* \param depth - starting depth (used for indentation)
*/
void print(std::basic_ostream<char, std::char_traits<char> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto, unsigned int depth = 0) const;
/**
* Print subtree to stream
*
* \param os - output stream
* \param indent - indentation string
* \param flags - formatting flags
* \param encoding - encoding used for writing
* \param depth - starting depth (used for indentation)
*/
void print(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const;
arseny.kapoulkine
committed
#endif
/**
* Get node offset in parsed file/string (in bytes) for debugging purposes
*
* \return offset in bytes to start of node data, or -1 in case of error
* \note This will return -1 if node information changed to the extent that it's no longer possible to calculate offset, for example
* if element node name has significantly changed; this is guaranteed to return correct offset only for nodes that have not changed
* since parsing.
*/
arseny.kapoulkine
committed
ptrdiff_t offset_debug() const;
arseny.kapoulkine
committed
};
#ifdef __BORLANDC__
// Borland C++ workaround
bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs);
bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs);
#endif
/**
* Child node iterator.
* It's a bidirectional iterator with value type 'xml_node'.
*/
class PUGIXML_CLASS xml_node_iterator
{
friend class xml_node;
private:
xml_node _prev;
xml_node _wrap;
arseny.kapoulkine
committed
explicit xml_node_iterator(xml_node_struct* ref);
/// \internal Initializing constructor (for past-the-end)
arseny.kapoulkine
committed
xml_node_iterator(xml_node_struct* ref, xml_node_struct* prev);
arseny.kapoulkine
committed
public:
/**
* Iterator traits
*/
typedef ptrdiff_t difference_type;
typedef xml_node value_type;
typedef xml_node* pointer;
typedef xml_node& reference;
#ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category;
#endif
arseny.kapoulkine
committed
/**
arseny.kapoulkine
committed
*/
xml_node_iterator();
/**
arseny.kapoulkine
committed
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
*
* \param node - node that iterator will point at
*/
xml_node_iterator(const xml_node& node);
/**
* Check if this iterator is equal to \a rhs
*
* \param rhs - other iterator
* \return comparison result
*/
bool operator==(const xml_node_iterator& rhs) const;
/**
* Check if this iterator is not equal to \a rhs
*
* \param rhs - other iterator
* \return comparison result
*/
bool operator!=(const xml_node_iterator& rhs) const;
/**
* Dereferencing operator
*
* \return reference to the node iterator points at
*/
xml_node& operator*();
/**
* Member access operator
*
arseny.kapoulkine
committed
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
*/
xml_node* operator->();
/**
* Pre-increment operator
*
* \return self
*/
const xml_node_iterator& operator++();
/**
* Post-increment operator
*
* \return old value
*/
xml_node_iterator operator++(int);
/**
* Pre-decrement operator
*
* \return self
*/
const xml_node_iterator& operator--();
/**
* Post-decrement operator
*
* \return old value
*/
xml_node_iterator operator--(int);
};
/**
* Attribute iterator.
* It's a bidirectional iterator with value type 'xml_attribute'.
*/
class PUGIXML_CLASS xml_attribute_iterator
{
friend class xml_node;
private:
xml_attribute _prev;
xml_attribute _wrap;
arseny.kapoulkine
committed
explicit xml_attribute_iterator(xml_attribute_struct* ref);
/// \internal Initializing constructor (for past-the-end)
arseny.kapoulkine
committed
xml_attribute_iterator(xml_attribute_struct* ref, xml_attribute_struct* prev);
arseny.kapoulkine
committed
public:
/**
* Iterator traits
*/
typedef ptrdiff_t difference_type;
typedef xml_attribute value_type;
typedef xml_attribute* pointer;
typedef xml_attribute& reference;
#ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category;
#endif
arseny.kapoulkine
committed
/**
arseny.kapoulkine
committed
*/
xml_attribute_iterator();
/**
arseny.kapoulkine
committed
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
*
* \param node - node that iterator will point at
*/
xml_attribute_iterator(const xml_attribute& node);
/**
* Check if this iterator is equal to \a rhs
*
* \param rhs - other iterator
* \return comparison result
*/
bool operator==(const xml_attribute_iterator& rhs) const;
/**
* Check if this iterator is not equal to \a rhs
*
* \param rhs - other iterator
* \return comparison result
*/
bool operator!=(const xml_attribute_iterator& rhs) const;
/**
* Dereferencing operator
*
* \return reference to the node iterator points at
*/
xml_attribute& operator*();
/**
* Member access operator
*
arseny.kapoulkine
committed
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
*/
xml_attribute* operator->();
/**
* Pre-increment operator
*
* \return self
*/
const xml_attribute_iterator& operator++();
/**
* Post-increment operator
*
* \return old value
*/
xml_attribute_iterator operator++(int);
/**
* Pre-decrement operator
*
* \return self
*/
const xml_attribute_iterator& operator--();
/**
* Post-decrement operator
*
* \return old value
*/
xml_attribute_iterator operator--(int);
};
/**
* Abstract tree walker class
* \see xml_node::traverse
*/
class PUGIXML_CLASS xml_tree_walker
{
friend class xml_node;
private:
int _depth;
protected:
/**
* Get node depth
*
* \return node depth
*/
int depth() const;
public:
/**
arseny.kapoulkine
committed
*/
xml_tree_walker();
/**
arseny.kapoulkine
committed
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
*/
virtual ~xml_tree_walker();
public:
/**
* Callback that is called when traversal of node begins.
*
* \return returning false will abort the traversal
*/
virtual bool begin(xml_node&);
/**
* Callback that is called for each node traversed
*
* \return returning false will abort the traversal
*/
virtual bool for_each(xml_node&) = 0;
/**
* Callback that is called when traversal of node ends.
*
* \return returning false will abort the traversal
*/
virtual bool end(xml_node&);
};
/**
* Struct used to distinguish parsing with ownership transfer from parsing without it.
* \see xml_document::parse
*/
struct transfer_ownership_tag {};
arseny.kapoulkine
committed
/**
* Parsing status enumeration, returned as part of xml_parse_result struct
*/
enum xml_parse_status
{
status_ok = 0, ///< No error
status_file_not_found, ///< File was not found during load_file()
status_io_error, ///< Error reading from file/stream
status_out_of_memory, ///< Could not allocate memory
arseny.kapoulkine
committed
status_unrecognized_tag, ///< Parser could not determine tag type
status_bad_pi, ///< Parsing error occurred while parsing document declaration/processing instruction (<?...?>)
status_bad_comment, ///< Parsing error occurred while parsing comment (<!--...-->)
status_bad_cdata, ///< Parsing error occurred while parsing CDATA section (<![CDATA[...]]>)
status_bad_doctype, ///< Parsing error occurred while parsing document type declaration
status_bad_pcdata, ///< Parsing error occurred while parsing PCDATA section (>...<)
status_bad_start_element, ///< Parsing error occurred while parsing start element tag (<name ...>)
status_bad_attribute, ///< Parsing error occurred while parsing element attribute
status_bad_end_element, ///< Parsing error occurred while parsing end element tag (</name>)
arseny.kapoulkine
committed
status_end_element_mismatch ///< There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag)
};
/**
* Parser result
*/
struct PUGIXML_CLASS xml_parse_result
{
/// Parsing status (\see xml_parse_status)
xml_parse_status status;
/// Last parsed offset (in bytes from file/string start)
arseny.kapoulkine
committed
ptrdiff_t offset;
arseny.kapoulkine
committed
/// Source document encoding
encoding_t encoding;
arseny.kapoulkine
committed
/// Cast to bool operator
operator bool() const
{
return status == status_ok;
}
/// Get error description
const char* description() const;
};
/**
* Document class (DOM tree root).
* This class has non-copyable semantics (private copy constructor/assignment operator).
arseny.kapoulkine
committed
*/
class PUGIXML_CLASS xml_document: public xml_node
{
private:
arseny.kapoulkine
committed
char_t* _buffer;
arseny.kapoulkine
committed
arseny.kapoulkine
committed
char _memory[192];
arseny.kapoulkine
committed
xml_document(const xml_document&);
const xml_document& operator=(const xml_document&);
void create();
void destroy();
xml_parse_result load_buffer_impl(void* contents, size_t size, unsigned int options, encoding_t encoding, bool is_mutable, bool own);
arseny.kapoulkine
committed
public:
/**
arseny.kapoulkine
committed
*/
xml_document();
/**
arseny.kapoulkine
committed
*/
~xml_document();
public:
#ifndef PUGIXML_NO_STL
arseny.kapoulkine
committed
/**
* Load document from stream.
*
arseny.kapoulkine
committed
* \param options - parsing options
* \param encoding - source data encoding
arseny.kapoulkine
committed
* \return parsing result
*/
xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
/**
* Load document from stream.
*
* \param options - parsing options
* \return parsing result
*/
xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
#endif
arseny.kapoulkine
committed
/**
* Load document from string. String has to be zero-terminated. No encoding conversions are applied.
arseny.kapoulkine
committed
*
* \param contents - input string
* \param options - parsing options
* \return parsing result
*/
xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
arseny.kapoulkine
committed
/**
* Parse the given XML string in-situ.
* The string is modified; you should ensure that string data will persist throughout the
* document's lifetime. Although, document does not gain ownership over the string, so you
* should free the memory occupied by it manually.
*
* \param options - parsing options
* \return parsing result
*
* \deprecated This function is deprecated and will be removed in future versions; use xml_document::load_buffer_inplace instead
PUGIXML_DEPRECATED xml_parse_result parse(char* xmlstr, unsigned int options = parse_default);
/**
* Parse the given XML string in-situ (gains ownership).
* The string is modified; document gains ownership over the string, so you don't have to worry
* about it's lifetime.
* Call example: doc.parse(transfer_ownership_tag(), string, options);
*
* \param options - parsing options
* \return parsing result
*
* \deprecated This function is deprecated and will be removed in future versions; use xml_document::load_buffer_inplace_own instead
PUGIXML_DEPRECATED xml_parse_result parse(const transfer_ownership_tag&, char* xmlstr, unsigned int options = parse_default);
arseny.kapoulkine
committed
/**
* Load document from file
*
* \param path - file path
arseny.kapoulkine
committed
* \param options - parsing options
* \param encoding - source data encoding
arseny.kapoulkine
committed
* \return parsing result
*/
xml_parse_result load_file(const char* path, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
arseny.kapoulkine
committed
/**
* Load document from buffer
arseny.kapoulkine
committed
*
* \param contents - buffer contents
* \param size - buffer size in bytes
arseny.kapoulkine
committed
* \param options - parsing options
* \param encoding - source data encoding
arseny.kapoulkine
committed
* \return parsing result
*/
xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
arseny.kapoulkine
committed
/**
* Load document from buffer in-situ.
* The buffer is modified; you should ensure that buffer data will persist throughout the document's
* lifetime. Document does not gain ownership over the buffer, so you should free the buffer memory manually.
arseny.kapoulkine
committed
*
* \param contents - buffer contents
* \param size - buffer size in bytes
arseny.kapoulkine
committed
* \param options - parsing options
* \param encoding - source data encoding
arseny.kapoulkine
committed
* \return parsing result
*/
xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
/**
* Load document from buffer in-situ (gains buffer ownership).
* The buffer is modified; you should ensure that buffer data will persist throughout the document's
* lifetime. Document gains ownership over the buffer, so you should allocate the buffer with pugixml
* allocation function.
*
* \param contents - buffer contents
* \param size - buffer size in bytes
* \param options - parsing options
* \param encoding - source data encoding
* \return parsing result
*/
xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
arseny.kapoulkine
committed
/**
* Save XML to writer
*
* \param writer - writer object
* \param indent - indentation string
* \param flags - formatting flags
* \param encoding - encoding used for writing
arseny.kapoulkine
committed
*/
void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto) const;
#ifndef PUGIXML_NO_STL
/**
* Save XML to stream
*
* \param stream - output stream
* \param indent - indentation string
* \param flags - formatting flags
* \param encoding - encoding used for writing
*/
void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto) const;
/**
* Save XML to stream
*
* \param stream - output stream
* \param indent - indentation string
* \param flags - formatting flags
*/
void save(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
#endif
arseny.kapoulkine
committed
/**
* Save XML to file
*
* \param path - file path
arseny.kapoulkine
committed
* \param indent - indentation string
* \param flags - formatting flags
* \param encoding - encoding used for writing
arseny.kapoulkine
committed
* \return success flag