Added xml_document::reset() function with document parameter
git-svn-id: http://pugixml.googlecode.com/svn/trunk@786 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
a73424aeff
commit
4920e4fec9
@ -4505,6 +4505,14 @@ namespace pugi
|
|||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xml_document::reset(const xml_document& proto)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
|
for (xml_node cur = proto.first_child(); cur; cur = cur.next_sibling())
|
||||||
|
append_copy(cur);
|
||||||
|
}
|
||||||
|
|
||||||
void xml_document::create()
|
void xml_document::create()
|
||||||
{
|
{
|
||||||
// initialize sentinel page
|
// initialize sentinel page
|
||||||
|
|||||||
@ -740,6 +740,9 @@ namespace pugi
|
|||||||
// Removes all nodes, leaving the empty document
|
// Removes all nodes, leaving the empty document
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
// Removes all nodes, then copies the entire contents of the specified document
|
||||||
|
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_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||||
|
|||||||
@ -906,3 +906,22 @@ TEST(document_reset_empty)
|
|||||||
CHECK(!doc.first_child());
|
CHECK(!doc.first_child());
|
||||||
CHECK_NODE(doc, STR(""));
|
CHECK_NODE(doc, STR(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_XML(document_reset_copy, "<node><child/></node>")
|
||||||
|
{
|
||||||
|
xml_document doc2;
|
||||||
|
|
||||||
|
CHECK_NODE(doc2, STR(""));
|
||||||
|
|
||||||
|
doc2.reset(doc);
|
||||||
|
|
||||||
|
CHECK_NODE(doc2, STR("<node><child /></node>"));
|
||||||
|
CHECK(doc.first_child() != doc2.first_child());
|
||||||
|
|
||||||
|
doc.reset(doc2);
|
||||||
|
|
||||||
|
CHECK_NODE(doc, STR("<node><child /></node>"));
|
||||||
|
CHECK(doc.first_child() != doc2.first_child());
|
||||||
|
|
||||||
|
CHECK(doc.first_child().offset_debug() == -1);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user