summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/manual.qbk4
-rw-r--r--docs/samples/custom_memory_management.cpp2
-rw-r--r--docs/samples/load_error_handling.cpp2
-rw-r--r--docs/samples/load_memory.cpp2
-rw-r--r--docs/samples/load_options.cpp8
-rw-r--r--docs/samples/modify_base.cpp2
-rw-r--r--docs/samples/modify_remove.cpp2
-rw-r--r--docs/samples/save_custom_writer.cpp2
-rw-r--r--docs/samples/save_declaration.cpp2
-rw-r--r--docs/samples/save_file.cpp2
-rw-r--r--docs/samples/save_options.cpp2
-rw-r--r--docs/samples/save_stream.cpp2
-rw-r--r--docs/samples/save_subtree.cpp2
-rw-r--r--docs/samples/text.cpp2
-rw-r--r--src/pugixml.cpp7
-rw-r--r--src/pugixml.hpp5
-rw-r--r--tests/test.hpp2
-rw-r--r--tests/test_document.cpp23
-rw-r--r--tests/test_dom_modify.cpp4
-rw-r--r--tests/test_memory.cpp2
-rw-r--r--tests/test_parse.cpp328
-rw-r--r--tests/test_parse_doctype.cpp20
-rw-r--r--tests/test_write.cpp2
-rw-r--r--tests/test_xpath.cpp6
24 files changed, 225 insertions, 210 deletions
diff --git a/docs/manual.qbk b/docs/manual.qbk
index 617a971..6d7f4e1 100644
--- a/docs/manual.qbk
+++ b/docs/manual.qbk
@@ -602,7 +602,7 @@ The best way from the performance/memory point of view is to load document using
[#xml_document::load_string]
There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:
- xml_parse_result xml_document::load(const char_t* contents, unsigned int options = parse_default);
+ xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options = parse_default);
It is equivalent to calling `load_buffer` with `size` being either `strlen(contents)` or `wcslen(contents) * sizeof(wchar_t)`, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.
@@ -2503,7 +2503,7 @@ Classes:
* `xml_parse_result `[link xml_document::load_stream load]`(std::wistream& stream, unsigned int options = parse_default);`
[lbr]
- * `xml_parse_result `[link xml_document::load_string load]`(const char_t* contents, unsigned int options = parse_default);`
+ * `xml_parse_result `[link xml_document::load_string load_string]`(const char_t* contents, unsigned int options = parse_default);`
[lbr]
* `xml_parse_result `[link xml_document::load_file load_file]`(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
diff --git a/docs/samples/custom_memory_management.cpp b/docs/samples/custom_memory_management.cpp
index 92ccb71..f11d27e 100644
--- a/docs/samples/custom_memory_management.cpp
+++ b/docs/samples/custom_memory_management.cpp
@@ -21,7 +21,7 @@ int main()
//]
pugi::xml_document doc;
- doc.load("<node/>");
+ doc.load_string("<node/>");
}
// vim:et
diff --git a/docs/samples/load_error_handling.cpp b/docs/samples/load_error_handling.cpp
index 18dd331..8dceb99 100644
--- a/docs/samples/load_error_handling.cpp
+++ b/docs/samples/load_error_handling.cpp
@@ -6,7 +6,7 @@ void check_xml(const char* source)
{
//[code_load_error_handling
pugi::xml_document doc;
- pugi::xml_parse_result result = doc.load(source);
+ pugi::xml_parse_result result = doc.load_string(source);
if (result)
std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n\n";
diff --git a/docs/samples/load_memory.cpp b/docs/samples/load_memory.cpp
index 1185944..490f7e4 100644
--- a/docs/samples/load_memory.cpp
+++ b/docs/samples/load_memory.cpp
@@ -55,7 +55,7 @@ int main()
{
//[code_load_memory_string
// You can use load to load document from null-terminated strings, for example literals:
- pugi::xml_parse_result result = doc.load("<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>");
+ pugi::xml_parse_result result = doc.load_string("<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>");
//]
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
diff --git a/docs/samples/load_options.cpp b/docs/samples/load_options.cpp
index 04b4b46..2589348 100644
--- a/docs/samples/load_options.cpp
+++ b/docs/samples/load_options.cpp
@@ -10,19 +10,19 @@ int main()
const char* source = "<!--comment--><node>&lt;</node>";
// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded
- doc.load(source);
+ doc.load_string(source);
std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
// Parsing with additional parse_comments option; comment node is now added to the tree
- doc.load(source, pugi::parse_default | pugi::parse_comments);
+ doc.load_string(source, pugi::parse_default | pugi::parse_comments);
std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
// Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded
- doc.load(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes);
+ doc.load_string(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes);
std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded
- doc.load(source, pugi::parse_minimal);
+ doc.load_string(source, pugi::parse_minimal);
std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
//]
}
diff --git a/docs/samples/modify_base.cpp b/docs/samples/modify_base.cpp
index 7d0959a..bd63708 100644
--- a/docs/samples/modify_base.cpp
+++ b/docs/samples/modify_base.cpp
@@ -6,7 +6,7 @@
int main()
{
pugi::xml_document doc;
- if (!doc.load("<node id='123'>text</node><!-- comment -->", pugi::parse_default | pugi::parse_comments)) return -1;
+ if (!doc.load_string("<node id='123'>text</node><!-- comment -->", pugi::parse_default | pugi::parse_comments)) return -1;
//[code_modify_base_node
pugi::xml_node node = doc.child("node");
diff --git a/docs/samples/modify_remove.cpp b/docs/samples/modify_remove.cpp
index 28c2f6b..53020e1 100644
--- a/docs/samples/modify_remove.cpp
+++ b/docs/samples/modify_remove.cpp
@@ -5,7 +5,7 @@
int main()
{
pugi::xml_document doc;
- if (!doc.load("<node><description>Simple node</description><param name='id' value='123'/></node>")) return -1;
+ if (!doc.load_string("<node><description>Simple node</description><param name='id' value='123'/></node>")) return -1;
//[code_modify_remove
// remove description node with the whole subtree
diff --git a/docs/samples/save_custom_writer.cpp b/docs/samples/save_custom_writer.cpp
index 6ea4300..9e9ee34 100644
--- a/docs/samples/save_custom_writer.cpp
+++ b/docs/samples/save_custom_writer.cpp
@@ -94,7 +94,7 @@ int main()
{
// get a test document
pugi::xml_document doc;
- doc.load("<foo bar='baz'>hey</foo>");
+ doc.load_string("<foo bar='baz'>hey</foo>");
// get contents as std::string (single pass)
std::cout << "contents: [" << node_to_string(doc) << "]\n";
diff --git a/docs/samples/save_declaration.cpp b/docs/samples/save_declaration.cpp
index 6c82061..a45831f 100644
--- a/docs/samples/save_declaration.cpp
+++ b/docs/samples/save_declaration.cpp
@@ -7,7 +7,7 @@ int main()
//[code_save_declaration
// get a test document
pugi::xml_document doc;
- doc.load("<foo bar='baz'><call>hey</call></foo>");
+ doc.load_string("<foo bar='baz'><call>hey</call></foo>");
// add a custom declaration node
pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
diff --git a/docs/samples/save_file.cpp b/docs/samples/save_file.cpp
index 30c1aa1..21413a2 100644
--- a/docs/samples/save_file.cpp
+++ b/docs/samples/save_file.cpp
@@ -6,7 +6,7 @@ int main()
{
// get a test document
pugi::xml_document doc;
- doc.load("<foo bar='baz'>hey</foo>");
+ doc.load_string("<foo bar='baz'>hey</foo>");
//[code_save_file
// save document to file
diff --git a/docs/samples/save_options.cpp b/docs/samples/save_options.cpp
index 6a49f66..82abdcd 100644
--- a/docs/samples/save_options.cpp
+++ b/docs/samples/save_options.cpp
@@ -7,7 +7,7 @@ int main()
//[code_save_options
// get a test document
pugi::xml_document doc;
- doc.load("<foo bar='baz'><call>hey</call></foo>");
+ doc.load_string("<foo bar='baz'><call>hey</call></foo>");
// default options; prints
// <?xml version="1.0"?>
diff --git a/docs/samples/save_stream.cpp b/docs/samples/save_stream.cpp
index d01965d..eba1863 100644
--- a/docs/samples/save_stream.cpp
+++ b/docs/samples/save_stream.cpp
@@ -6,7 +6,7 @@ int main()
{
// get a test document
pugi::xml_document doc;
- doc.load("<foo bar='baz'><call>hey</call></foo>");
+ doc.load_string("<foo bar='baz'><call>hey</call></foo>");
//[code_save_stream
// save document to standard output
diff --git a/docs/samples/save_subtree.cpp b/docs/samples/save_subtree.cpp
index 0091b3d..a94e10a 100644
--- a/docs/samples/save_subtree.cpp
+++ b/docs/samples/save_subtree.cpp
@@ -7,7 +7,7 @@ int main()
//[code_save_subtree
// get a test document
pugi::xml_document doc;
- doc.load("<foo bar='baz'><call>hey</call></foo>");
+ doc.load_string("<foo bar='baz'><call>hey</call></foo>");
// print document to standard output (prints <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>)
doc.save(std::cout, "", pugi::format_raw);
diff --git a/docs/samples/text.cpp b/docs/samples/text.cpp
index 9b1cf69..a0d591b 100644
--- a/docs/samples/text.cpp
+++ b/docs/samples/text.cpp
@@ -7,7 +7,7 @@ int main()
pugi::xml_document doc;
// get a test document
- doc.load("<project><name>test</name><version>1.1</version><public>yes</public></project>");
+ doc.load_string("<project><name>test</name><version>1.1</version><public>yes</public></project>");
pugi::xml_node project = doc.child("project");
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 884184c..852ccb9 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -5995,7 +5995,7 @@ namespace pugi
}
#endif
- PUGI__FN xml_parse_result xml_document::load(const char_t* contents, unsigned int options)
+ PUGI__FN xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options)
{
// Force native encoding (skip autodetection)
#ifdef PUGIXML_WCHAR_MODE
@@ -6007,6 +6007,11 @@ namespace pugi
return load_buffer(contents, impl::strlength(contents) * sizeof(char_t), options, encoding);
}
+ PUGI__FN xml_parse_result xml_document::load(const char_t* contents, unsigned int options)
+ {
+ return load_string(contents, options);
+ }
+
PUGI__FN xml_parse_result xml_document::load_file(const char* path_, unsigned int options, xml_encoding encoding)
{
reset();
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index e252e16..7f52975 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -959,9 +959,12 @@ namespace pugi
xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
#endif
- // Load document from zero-terminated string. No encoding conversions 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 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);
+
// Load document from file
xml_parse_result load_file(const char* 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);
diff --git a/tests/test.hpp b/tests/test.hpp
index 509b0cd..4222638 100644
--- a/tests/test.hpp
+++ b/tests/test.hpp
@@ -95,7 +95,7 @@ struct dummy_fixture {};
\
test_fixture_##name() \
{ \
- CHECK(doc.load(PUGIXML_TEXT(xml), flags)); \
+ CHECK(doc.load_string(PUGIXML_TEXT(xml), flags)); \
} \
\
private: \
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index 2cc39a6..4228602 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -158,7 +158,7 @@ TEST(document_load_stream_exceptions)
TEST(document_load_stream_error_previous)
{
pugi::xml_document doc;
- CHECK(doc.load(STR("<node/>")));
+ CHECK(doc.load_string(STR("<node/>")));
CHECK(doc.first_child());
std::ifstream fs1("filedoesnotexist");
@@ -169,7 +169,7 @@ TEST(document_load_stream_error_previous)
TEST(document_load_stream_wide_error_previous)
{
pugi::xml_document doc;
- CHECK(doc.load(STR("<node/>")));
+ CHECK(doc.load_string(STR("<node/>")));
CHECK(doc.first_child());
std::basic_ifstream<wchar_t> fs1("filedoesnotexist");
@@ -261,7 +261,7 @@ TEST(document_load_string)
{
pugi::xml_document doc;
- CHECK(doc.load(STR("<node/>")));
+ CHECK(doc.load_string(STR("<node/>")));
CHECK_NODE(doc, STR("<node />"));
}
@@ -308,7 +308,7 @@ TEST(document_load_file_error)
TEST(document_load_file_error_previous)
{
pugi::xml_document doc;
- CHECK(doc.load(STR("<node/>")));
+ CHECK(doc.load_string(STR("<node/>")));
CHECK(doc.first_child());
CHECK(doc.load_file("filedoesnotexist").status == status_file_not_found);
@@ -590,7 +590,7 @@ TEST(document_parse_result_description)
TEST(document_load_fail)
{
xml_document doc;
- CHECK(!doc.load(STR("<foo><bar/>")));
+ CHECK(!doc.load_string(STR("<foo><bar/>")));
CHECK(doc.child(STR("foo")).child(STR("bar")));
}
@@ -1079,7 +1079,7 @@ TEST(document_load_exceptions)
try
{
pugi::xml_document doc;
- if (!doc.load(STR("<node attribute='value"))) throw std::bad_alloc();
+ if (!doc.load_string(STR("<node attribute='value"))) throw std::bad_alloc();
CHECK_FORCE_FAIL("Expected parsing failure");
}
@@ -1114,7 +1114,7 @@ TEST_XML(document_reset, "<node><child/></node>")
CHECK(!doc.first_child());
CHECK_NODE(doc, STR(""));
- CHECK(doc.load(STR("<node/>")));
+ CHECK(doc.load_string(STR("<node/>")));
CHECK(doc.first_child());
CHECK_NODE(doc, STR("<node />"));
@@ -1268,7 +1268,7 @@ TEST(document_alignment)
{
xml_document* doc = new (buf + offset) xml_document;
- CHECK(doc->load(STR("<node />")));
+ CHECK(doc->load_string(STR("<node />")));
CHECK_NODE(*doc, STR("<node />"));
doc->~xml_document();
@@ -1308,3 +1308,10 @@ TEST(document_convert_out_of_memory)
delete[] files[j].data;
}
}
+
+TEST(document_deprecated_load)
+{
+ xml_document doc;
+ CHECK(doc.load(STR("<node/>")));
+ CHECK_NODE(doc, STR("<node />"));
+}
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp
index 45cf3ea..8665af9 100644
--- a/tests/test_dom_modify.cpp
+++ b/tests/test_dom_modify.cpp
@@ -1289,7 +1289,7 @@ TEST(dom_node_copy_stackless)
data += STR("</a>");
xml_document doc;
- CHECK(doc.load(data.c_str()));
+ CHECK(doc.load_string(data.c_str()));
xml_document copy;
CHECK(copy.append_copy(doc.first_child()));
@@ -1324,7 +1324,7 @@ TEST(dom_node_copy_copyless)
TEST(dom_node_copy_copyless_mix)
{
xml_document doc;
- CHECK(doc.load(STR("<node>pcdata<?name value?><child attr1=\"\" attr2=\"value2\" /></node>"), parse_full));
+ CHECK(doc.load_string(STR("<node>pcdata<?name value?><child attr1=\"\" attr2=\"value2\" /></node>"), parse_full));
xml_node child = doc.child(STR("node")).child(STR("child"));
diff --git a/tests/test_memory.cpp b/tests/test_memory.cpp
index 32d395b..bd80ca1 100644
--- a/tests/test_memory.cpp
+++ b/tests/test_memory.cpp
@@ -39,7 +39,7 @@ TEST(memory_custom_memory_management)
CHECK(allocate_count == 0 && deallocate_count == 0);
- CHECK(doc.load(STR("<node />")));
+ CHECK(doc.load_string(STR("<node />")));
CHECK(allocate_count == 2 && deallocate_count == 0);
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index c45b783..321b84c 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -12,10 +12,10 @@ TEST(parse_pi_skip)
{
unsigned int flags = flag_sets[i];
- CHECK(doc.load(STR("<?pi?><?pi value?>"), flags));
+ CHECK(doc.load_string(STR("<?pi?><?pi value?>"), flags));
CHECK(!doc.first_child());
- CHECK(doc.load(STR("<?pi <tag/> value?>"), flags));
+ CHECK(doc.load_string(STR("<?pi <tag/> value?>"), flags));
CHECK(!doc.first_child());
}
}
@@ -23,7 +23,7 @@ TEST(parse_pi_skip)
TEST(parse_pi_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<?pi1?><?pi2 value?>"), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR("<?pi1?><?pi2 value?>"), parse_fragment | parse_pi));
xml_node pi1 = doc.first_child();
xml_node pi2 = doc.last_child();
@@ -40,7 +40,7 @@ TEST(parse_pi_parse)
TEST(parse_pi_parse_spaces)
{
xml_document doc;
- CHECK(doc.load(STR("<?target \r\n\t value ?>"), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR("<?target \r\n\t value ?>"), parse_fragment | parse_pi));
xml_node pi = doc.first_child();
@@ -59,46 +59,46 @@ TEST(parse_pi_error)
{
unsigned int flags = flag_sets[i];
- CHECK(doc.load(STR("<?"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<??"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?>"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?#?>"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name>"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name ?"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name?"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name? "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name? "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value ?"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value ? "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value ? >"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name value ? > "), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name&"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?name&?"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<??"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?>"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?#?>"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name>"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name ?"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name?"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name? "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name? "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value ?"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value ? "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value ? >"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name value ? > "), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name&"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name&?"), flags).status == status_bad_pi);
}
- CHECK(doc.load(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi);
- CHECK(doc.load(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi);
- CHECK(doc.load(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi);
}
TEST(parse_comments_skip)
{
xml_document doc;
- CHECK(doc.load(STR("<!----><!--value-->"), parse_fragment));
+ CHECK(doc.load_string(STR("<!----><!--value-->"), parse_fragment));
CHECK(!doc.first_child());
}
TEST(parse_comments_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<!----><!--value-->"), parse_fragment | parse_comments));
+ CHECK(doc.load_string(STR("<!----><!--value-->"), parse_fragment | parse_comments));
xml_node c1 = doc.first_child();
xml_node c2 = doc.last_child();
@@ -115,7 +115,7 @@ TEST(parse_comments_parse)
TEST(parse_comments_parse_no_eol)
{
xml_document doc;
- CHECK(doc.load(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments));
+ CHECK(doc.load_string(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments));
xml_node c = doc.first_child();
CHECK(c.type() == node_comment);
@@ -125,7 +125,7 @@ TEST(parse_comments_parse_no_eol)
TEST(parse_comments_parse_eol)
{
xml_document doc;
- CHECK(doc.load(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments | parse_eol));
+ CHECK(doc.load_string(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments | parse_eol));
xml_node c = doc.first_child();
CHECK(c.type() == node_comment);
@@ -142,33 +142,33 @@ TEST(parse_comments_error)
{
unsigned int flags = flag_sets[i];
- CHECK(doc.load(STR("<!-"), flags).status == status_bad_comment);
- CHECK(doc.load(STR("<!--"), flags).status == status_bad_comment);
- CHECK(doc.load(STR("<!--v"), flags).status == status_bad_comment);
- CHECK(doc.load(STR("<!-->"), flags).status == status_bad_comment);
- CHECK(doc.load(STR("<!--->"), flags).status == status_bad_comment);
- CHECK(doc.load(STR("<!-- <!-- --><!- -->"), flags).status == status_bad_comment);
+ CHECK(doc.load_string(STR("<!-"), flags).status == status_bad_comment);
+ CHECK(doc.load_string(STR("<!--"), flags).status == status_bad_comment);
+ CHECK(doc.load_string(STR("<!--v"), flags).status == status_bad_comment);
+ CHECK(doc.load_string(STR("<!-->"), flags).status == status_bad_comment);
+ CHECK(doc.load_string(STR("<!--->"), flags).status == status_bad_comment);
+ CHECK(doc.load_string(STR("<!-- <!-- --><!- -->"), flags).status == status_bad_comment);
}
}
TEST(parse_cdata_skip)
{
xml_document doc;
- CHECK(doc.load(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment));
+ CHECK(doc.load_string(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment));
CHECK(!doc.first_child());
}
TEST(parse_cdata_skip_contents)
{
xml_document doc;
- CHECK(doc.load(STR("<node><![CDATA[]]>hello<![CDATA[value]]>, world!</node>"), parse_fragment));
+ CHECK(doc.load_string(STR("<node><![CDATA[]]>hello<![CDATA[value]]>, world!</node>"), parse_fragment));
CHECK_NODE(doc, STR("<node>hello, world!</node>"));
}
TEST(parse_cdata_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment | parse_cdata));
+ CHECK(doc.load_string(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment | parse_cdata));
xml_node c1 = doc.first_child();
xml_node c2 = doc.last_child();
@@ -185,7 +185,7 @@ TEST(parse_cdata_parse)
TEST(parse_cdata_parse_no_eol)
{
xml_document doc;
- CHECK(doc.load(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata));
+ CHECK(doc.load_string(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata));
xml_node c = doc.first_child();
CHECK(c.type() == node_cdata);
@@ -195,7 +195,7 @@ TEST(parse_cdata_parse_no_eol)
TEST(parse_cdata_parse_eol)
{
xml_document doc;
- CHECK(doc.load(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata | parse_eol));
+ CHECK(doc.load_string(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata | parse_eol));
xml_node c = doc.first_child();
CHECK(c.type() == node_cdata);
@@ -212,29 +212,29 @@ TEST(parse_cdata_error)
{
unsigned int flags = flag_sets[i];
- CHECK(doc.load(STR("<!["), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![C"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CD"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDA"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDAT"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA["), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA[]"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA[data"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA[data]"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA[data]]"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA[>"), flags).status == status_bad_cdata);
- CHECK(doc.load(STR("<![CDATA[ <![CDATA[]]><![CDATA ]]>"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<!["), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![C"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CD"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDA"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDAT"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA["), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA[]"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA[data"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA[data]"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA[data]]"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA[>"), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR("<![CDATA[ <![CDATA[]]><![CDATA ]]>"), flags).status == status_bad_cdata);
}
}
TEST(parse_ws_pcdata_skip)
{
xml_document doc;
- CHECK(doc.load(STR(" "), parse_fragment));
+ CHECK(doc.load_string(STR(" "), parse_fragment));
CHECK(!doc.first_child());
- CHECK(doc.load(STR("<root> <node> </node> </root>"), parse_minimal));
+ CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal));
xml_node root = doc.child(STR("root"));
@@ -245,7 +245,7 @@ TEST(parse_ws_pcdata_skip)
TEST(parse_ws_pcdata_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<root> <node> </node> </root>"), parse_minimal | parse_ws_pcdata));
+ CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal | parse_ws_pcdata));
xml_node root = doc.child(STR("root"));
@@ -334,7 +334,7 @@ TEST(parse_ws_pcdata_permutations)
unsigned int flags[] = {parse_default, parse_default | parse_ws_pcdata, parse_default | parse_ws_pcdata_single};
xml_document doc;
- CHECK((td.nodes > 0) == doc.load(td.source, flags[flag]));
+ CHECK((td.nodes > 0) == doc.load_string(td.source, flags[flag]));
CHECK_NODE(doc, td.result);
int nodes = get_tree_node_count(doc);
@@ -385,7 +385,7 @@ TEST(parse_ws_pcdata_fragment_permutations)
unsigned int flags[] = {parse_default, parse_default | parse_ws_pcdata, parse_default | parse_ws_pcdata_single};
xml_document doc;
- CHECK((td.nodes > 0) == doc.load(td.source, flags[flag] | parse_fragment));
+ CHECK((td.nodes > 0) == doc.load_string(td.source, flags[flag] | parse_fragment));
CHECK_NODE(doc, td.result);
int nodes = get_tree_node_count(doc);
@@ -398,7 +398,7 @@ TEST(parse_ws_pcdata_fragment_permutations)
TEST(parse_pcdata_no_eol)
{
xml_document doc;
- CHECK(doc.load(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal));
+ CHECK(doc.load_string(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal));
CHECK_STRING(doc.child_value(STR("root")), STR("\r\rval1\rval2\r\nval3\nval4\r\r"));
}
@@ -406,7 +406,7 @@ TEST(parse_pcdata_no_eol)
TEST(parse_pcdata_eol)
{
xml_document doc;
- CHECK(doc.load(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal | parse_eol));
+ CHECK(doc.load_string(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal | parse_eol));
CHECK_STRING(doc.child_value(STR("root")), STR("\n\nval1\nval2\nval3\nval4\n\n"));
}
@@ -414,7 +414,7 @@ TEST(parse_pcdata_eol)
TEST(parse_pcdata_skip_ext)
{
xml_document doc;
- CHECK(doc.load(STR("pre<root/>post"), parse_minimal));
+ CHECK(doc.load_string(STR("pre<root/>post"), parse_minimal));
CHECK(doc.first_child() == doc.last_child());
CHECK(doc.first_child().type() == node_element);
}
@@ -422,7 +422,7 @@ TEST(parse_pcdata_skip_ext)
TEST(parse_pcdata_error)
{
xml_document doc;
- CHECK(doc.load(STR("<root>pcdata"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<root>pcdata"), parse_minimal).status == status_end_element_mismatch);
}
TEST(parse_pcdata_trim)
@@ -460,7 +460,7 @@ TEST(parse_pcdata_trim)
const test_data_t& td = test_data[i];
xml_document doc;
- CHECK(doc.load(td.source, td.flags | parse_trim_pcdata));
+ CHECK(doc.load_string(td.source, td.flags | parse_trim_pcdata));
const pugi::char_t* value = doc.child(STR("node")) ? doc.child_value(STR("node")) : doc.text().get();
CHECK_STRING(value, td.result);
@@ -474,7 +474,7 @@ TEST(parse_pcdata_trim_empty)
for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i)
{
xml_document doc;
- CHECK(doc.load(STR("<node> </node>"), flags[i] | parse_trim_pcdata));
+ CHECK(doc.load_string(STR("<node> </node>"), flags[i] | parse_trim_pcdata));
xml_node node = doc.child(STR("node"));
CHECK(node);
@@ -485,14 +485,14 @@ TEST(parse_pcdata_trim_empty)
TEST(parse_escapes_skip)
{
xml_document doc;
- CHECK(doc.load(STR("<node id='&lt;&gt;&amp;&apos;&quot;'>&lt;&gt;&amp;&apos;&quot;</node>"), parse_minimal));
+ CHECK(doc.load_string(STR("<node id='&lt;&gt;&amp;&apos;&quot;'>&lt;&gt;&amp;&apos;&quot;</node>"), parse_minimal));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("&lt;&gt;&amp;&apos;&quot;"));
}
TEST(parse_escapes_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<node id='&lt;&gt;&amp;&apos;&quot;'>&lt;&gt;&amp;&apos;&quot;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node id='&lt;&gt;&amp;&apos;&quot;'>&lt;&gt;&amp;&apos;&quot;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("<>&'\""));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("<>&'\""));
}
@@ -500,28 +500,28 @@ TEST(parse_escapes_parse)
TEST(parse_escapes_code)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#1;&#32;&#x20;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#1;&#32;&#x20;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("\01 "));
}
TEST(parse_escapes_code_exhaustive_dec)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#/;&#01;&#2;&#3;&#4;&#5;&#6;&#7;&#8;&#9;&#:;&#a;&#A;&#XA;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#/;&#01;&#2;&#3;&#4;&#5;&#6;&#7;&#8;&#9;&#:;&#a;&#A;&#XA;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&#/;\x1\x2\x3\x4\x5\x6\x7\x8\x9&#:;&#a;&#A;&#XA;"));
}
TEST(parse_escapes_code_exhaustive_hex)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#x/;&#x01;&#x2;&#x3;&#x4;&#x5;&#x6;&#x7;&#x8;&#x9;&#x:;&#x@;&#xA;&#xB;&#xC;&#xD;&#xE;&#xF;&#xG;&#x`;&#xa;&#xb;&#xc;&#xd;&#xe;&#xf;&#xg;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#x/;&#x01;&#x2;&#x3;&#x4;&#x5;&#x6;&#x7;&#x8;&#x9;&#x:;&#x@;&#xA;&#xB;&#xC;&#xD;&#xE;&#xF;&#xG;&#x`;&#xa;&#xb;&#xc;&#xd;&#xe;&#xf;&#xg;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&#x/;\x1\x2\x3\x4\x5\x6\x7\x8\x9&#x:;&#x@;\xa\xb\xc\xd\xe\xf&#xG;&#x`;\xa\xb\xc\xd\xe\xf&#xg;"));
}
TEST(parse_escapes_code_restore)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#1&#32;&#x1&#32;&#1-&#32;&#x1-&#32;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#1&#32;&#x1&#32;&#1-&#32;&#x1-&#32;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&#1 &#x1 &#1- &#x1- "));
}
@@ -529,26 +529,26 @@ TEST(parse_escapes_char_restore)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&q&#32;&qu&#32;&quo&#32;&quot&#32;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&q&#32;&qu&#32;&quo&#32;&quot&#32;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&q &qu &quo &quot "));
- CHECK(doc.load(STR("<node>&a&#32;&ap&#32;&apo&#32;&apos&#32;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&a&#32;&ap&#32;&apo&#32;&apos&#32;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&a &ap &apo &apos "));
- CHECK(doc.load(STR("<node>&a&#32;&am&#32;&amp&#32;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&a&#32;&am&#32;&amp&#32;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&a &am &amp "));
- CHECK(doc.load(STR("<node>&l&#32;&lt&#32;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&l&#32;&lt&#32;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&l &lt "));
- CHECK(doc.load(STR("<node>&g&#32;&gt&#32;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&g&#32;&gt&#32;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&g &gt "));
}
TEST(parse_escapes_unicode)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#x03B3;&#x03b3;&#x24B62;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#x03B3;&#x03b3;&#x24B62;</node>"), parse_minimal | parse_escapes));
#ifdef PUGIXML_WCHAR_MODE
const pugi::char_t* v = doc.child_value(STR("node"));
@@ -564,23 +564,23 @@ TEST(parse_escapes_unicode)
TEST(parse_escapes_error)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#x03g;&#ab;&quot</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#x03g;&#ab;&quot</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&#x03g;&#ab;&quot"));
- CHECK(!doc.load(STR("<node id='&#x12")));
- CHECK(!doc.load(STR("<node id='&g")));
- CHECK(!doc.load(STR("<node id='&gt")));
- CHECK(!doc.load(STR("<node id='&l")));
- CHECK(!doc.load(STR("<node id='&lt")));
- CHECK(!doc.load(STR("<node id='&a")));
- CHECK(!doc.load(STR("<node id='&amp")));
- CHECK(!doc.load(STR("<node id='&apos")));
+ CHECK(!doc.load_string(STR("<node id='&#x12")));
+ CHECK(!doc.load_string(STR("<node id='&g")));
+ CHECK(!doc.load_string(STR("<node id='&gt")));
+ CHECK(!doc.load_string(STR("<node id='&l")));
+ CHECK(!doc.load_string(STR("<node id='&lt")));
+ CHECK(!doc.load_string(STR("<node id='&a")));
+ CHECK(!doc.load_string(STR("<node id='&amp")));
+ CHECK(!doc.load_string(STR("<node id='&apos")));
}
TEST(parse_escapes_code_invalid)
{
xml_document doc;
- CHECK(doc.load(STR("<node>&#;&#x;&;&#x-;&#-;</node>"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<node>&#;&#x;&;&#x-;&#-;</node>"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&#;&#x;&;&#x-;&#-;"));
}
@@ -598,7 +598,7 @@ TEST(parse_escapes_attribute)
flags |= (eol ? parse_eol : 0);
flags |= (wconv ? parse_wconv_attribute : 0);
- CHECK(doc.load(STR("<node id='&quot;'/>"), flags));
+ CHECK(doc.load_string(STR("<node id='&quot;'/>"), flags));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("\""));
}
}
@@ -606,7 +606,7 @@ TEST(parse_escapes_attribute)
TEST(parse_attribute_spaces)
{
xml_document doc;
- CHECK(doc.load(STR("<node id1='v1' id2 ='v2' id3= 'v3' id4 = 'v4' id5 \n\r\t = \r\t\n 'v5' />"), parse_minimal));
+ CHECK(doc.load_string(STR("<node id1='v1' id2 ='v2' id3= 'v3' id4 = 'v4' id5 \n\r\t = \r\t\n 'v5' />"), parse_minimal));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("v1"));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("v2"));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id3")).value(), STR("v3"));
@@ -617,7 +617,7 @@ TEST(parse_attribute_spaces)
TEST(parse_attribute_quot)
{
xml_document doc;
- CHECK(doc.load(STR("<node id1='v1' id2=\"v2\"/>"), parse_minimal));
+ CHECK(doc.load_string(STR("<node id1='v1' id2=\"v2\"/>"), parse_minimal));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("v1"));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("v2"));
}
@@ -625,28 +625,28 @@ TEST(parse_attribute_quot)
TEST(parse_attribute_no_eol_no_wconv)
{
xml_document doc;
- CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal));
+ CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" \t\r\rval1 \rval2\r\nval3\nval4\r\r"));
}
TEST(parse_attribute_eol_no_wconv)
{
xml_document doc;
- CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol));
+ CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" \t\n\nval1 \nval2\nval3\nval4\n\n"));
}
TEST(parse_attribute_no_eol_wconv)
{
xml_document doc;
- CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_wconv_attribute));
+ CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_wconv_attribute));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" val1 val2 val3 val4 "));
}
TEST(parse_attribute_eol_wconv)
{
xml_document doc;
- CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol | parse_wconv_attribute));
+ CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol | parse_wconv_attribute));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" val1 val2 val3 val4 "));
}
@@ -658,7 +658,7 @@ TEST(parse_attribute_wnorm)
for (int wconv = 0; wconv < 2; ++wconv)
{
unsigned int flags = parse_minimal | parse_wnorm_attribute | (eol ? parse_eol : 0) | (wconv ? parse_wconv_attribute : 0);
- CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), flags));
+ CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), flags));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("val1 val2 val3 val4"));
}
}
@@ -679,7 +679,7 @@ TEST(parse_attribute_variations)
flags |= (wconv ? parse_wconv_attribute : 0);
flags |= (escapes ? parse_escapes : 0);
- CHECK(doc.load(STR("<node id='1'/>"), flags));
+ CHECK(doc.load_string(STR("<node id='1'/>"), flags));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("1"));
}
}
@@ -688,24 +688,24 @@ TEST(parse_attribute_variations)
TEST(parse_attribute_error)
{
xml_document doc;
- CHECK(doc.load(STR("<node id"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id "), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id "), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id "), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id/"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id?/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id=/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id='/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id=\"/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id=\"'/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node #/>"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node#/>"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node id1='1'id2='2'/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node id&='1'/>"), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR("<node &='1'/>"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node id"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id "), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id "), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id "), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id/"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id?/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id=/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id='/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id=\"/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id=\"'/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node #/>"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node#/>"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node id1='1'id2='2'/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id&='1'/>"), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node &='1'/>"), parse_minimal).status == status_bad_start_element);
}
TEST(parse_attribute_termination_error)
@@ -722,7 +722,7 @@ TEST(parse_attribute_termination_error)
flags |= (eol ? parse_eol : 0);
flags |= (wconv ? parse_wconv_attribute : 0);
- CHECK(doc.load(STR("<node id='value"), flags).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<node id='value"), flags).status == status_bad_attribute);
}
}
@@ -740,7 +740,7 @@ TEST(parse_attribute_quot_inside)
flags |= (eol ? parse_eol : 0);
flags |= (wconv ? parse_wconv_attribute : 0);
- CHECK(doc.load(STR("<node id1='\"' id2=\"'\"/>"), flags));
+ CHECK(doc.load_string(STR("<node id1='\"' id2=\"'\"/>"), flags));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("\""));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("'"));
}
@@ -749,60 +749,60 @@ TEST(parse_attribute_quot_inside)
TEST(parse_tag_single)
{
xml_document doc;
- CHECK(doc.load(STR("<node/><node /><node\n/>"), parse_minimal));
+ CHECK(doc.load_string(STR("<node/><node /><node\n/>"), parse_minimal));
CHECK_NODE(doc, STR("<node /><node /><node />"));
}
TEST(parse_tag_hierarchy)
{
xml_document doc;
- CHECK(doc.load(STR("<node><n1><n2/></n1><n3><n4><n5></n5></n4></n3 \r\n></node>"), parse_minimal));
+ CHECK(doc.load_string(STR("<node><n1><n2/></n1><n3><n4><n5></n5></n4></n3 \r\n></node>"), parse_minimal));
CHECK_NODE(doc, STR("<node><n1><n2 /></n1><n3><n4><n5 /></n4></n3></node>"));
}
TEST(parse_tag_error)
{
xml_document doc;
- CHECK(doc.load(STR("<"), parse_minimal).status == status_unrecognized_tag);
- CHECK(doc.load(STR("<!"), parse_minimal).status == status_unrecognized_tag);
- CHECK(doc.load(STR("<!D"), parse_minimal).status == status_unrecognized_tag);
- CHECK(doc.load(STR("<#"), parse_minimal).status == status_unrecognized_tag);
- CHECK(doc.load(STR("<node#"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node/"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node /"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node / "), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node / >"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node/ >"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("</ node>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("</node"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("</node "), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("<node></ node>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("<node></node"), parse_minimal).status == status_bad_end_element);
- CHECK(doc.load(STR("<node></node "), parse_minimal).status == status_bad_end_element);
- CHECK(doc.load(STR("<node></nodes>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("<node>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("<node/><"), parse_minimal).status == status_unrecognized_tag);
- CHECK(doc.load(STR("<node attr='value'>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("</></node>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("</node>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("</>"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("<node></node v>"), parse_minimal).status == status_bad_end_element);
- CHECK(doc.load(STR("<node&/>"), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR("<node& v='1'/>"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<"), parse_minimal).status == status_unrecognized_tag);
+ CHECK(doc.load_string(STR("<!"), parse_minimal).status == status_unrecognized_tag);
+ CHECK(doc.load_string(STR("<!D"), parse_minimal).status == status_unrecognized_tag);
+ CHECK(doc.load_string(STR("<#"), parse_minimal).status == status_unrecognized_tag);
+ CHECK(doc.load_string(STR("<node#"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node/"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node /"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node / "), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node / >"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node/ >"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("</ node>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("</node"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("</node "), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<node></ node>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<node></node"), parse_minimal).status == status_bad_end_element);
+ CHECK(doc.load_string(STR("<node></node "), parse_minimal).status == status_bad_end_element);
+ CHECK(doc.load_string(STR("<node></nodes>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<node>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<node/><"), parse_minimal).status == status_unrecognized_tag);
+ CHECK(doc.load_string(STR("<node attr='value'>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("</></node>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("</node>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("</>"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<node></node v>"), parse_minimal).status == status_bad_end_element);
+ CHECK(doc.load_string(STR("<node&/>"), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR("<node& v='1'/>"), parse_minimal).status == status_bad_start_element);
}
TEST(parse_declaration_cases)
{
xml_document doc;
- CHECK(doc.load(STR("<?xml?><?xmL?><?xMl?><?xML?><?Xml?><?XmL?><?XMl?><?XML?>"), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR("<?xml?><?xmL?><?xMl?><?xML?><?Xml?><?XmL?><?XMl?><?XML?>"), parse_fragment | parse_pi));
CHECK(!doc.first_child());
}
TEST(parse_declaration_attr_cases)
{
xml_document doc;
- CHECK(doc.load(STR("<?xml ?><?xmL ?><?xMl ?><?xML ?><?Xml ?><?XmL ?><?XMl ?><?XML ?>"), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR("<?xml ?><?xmL ?><?xMl ?><?xML ?><?Xml ?><?XmL ?><?XMl ?><?XML ?>"), parse_fragment | parse_pi));
CHECK(!doc.first_child());
}
@@ -816,10 +816,10 @@ TEST(parse_declaration_skip)
{
unsigned int flags = flag_sets[i];
- CHECK(doc.load(STR("<?xml?><?xml version='1.0'?>"), flags));
+ CHECK(doc.load_string(STR("<?xml?><?xml version='1.0'?>"), flags));
CHECK(!doc.first_child());
- CHECK(doc.load(STR("<?xml <tag/> ?>"), flags));
+ CHECK(doc.load_string(STR("<?xml <tag/> ?>"), flags));
CHECK(!doc.first_child());
}
}
@@ -827,7 +827,7 @@ TEST(parse_declaration_skip)
TEST(parse_declaration_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<?xml?><?xml version='1.0'?>"), parse_fragment | parse_declaration));
+ CHECK(doc.load_string(STR("<?xml?><?xml version='1.0'?>"), parse_fragment | parse_declaration));
xml_node d1 = doc.first_child();
xml_node d2 = doc.last_child();
@@ -850,21 +850,21 @@ TEST(parse_declaration_error)
{
unsigned int flags = flag_sets[i];
- CHECK(doc.load(STR("<?xml"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?xml?"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?xml>"), flags).status == status_bad_pi);
- CHECK(doc.load(STR("<?xml version='1>"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?xml"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?xml?"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?xml>"), flags).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?xml version='1>"), flags).status == status_bad_pi);
}
- CHECK(doc.load(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute);
- CHECK(doc.load(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi);
+ CHECK(doc.load_string(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute);
+ CHECK(doc.load_string(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi);
}
TEST(parse_empty)
{
xml_document doc;
- CHECK(doc.load(STR("")).status == status_no_document_element && !doc.first_child());
- CHECK(doc.load(STR(""), parse_fragment) && !doc.first_child());
+ CHECK(doc.load_string(STR("")).status == status_no_document_element && !doc.first_child());
+ CHECK(doc.load_string(STR(""), parse_fragment) && !doc.first_child());
}
TEST(parse_out_of_memory)
@@ -872,7 +872,7 @@ TEST(parse_out_of_memory)
test_runner::_memory_fail_threshold = 256;
xml_document doc;
- CHECK(doc.load(STR("<foo a='1'/>")).status == status_out_of_memory);
+ CHECK(doc.load_string(STR("<foo a='1'/>")).status == status_out_of_memory);
CHECK(!doc.first_child());
}
@@ -928,7 +928,7 @@ TEST(parse_out_of_memory_halfway_attr)
static bool test_offset(const char_t* contents, unsigned int options, pugi::xml_parse_status status, ptrdiff_t offset)
{
xml_document doc;
- xml_parse_result res = doc.load(contents, options);
+ xml_parse_result res = doc.load_string(contents, options);
return res.status == status && res.offset == offset;
}
@@ -1065,7 +1065,7 @@ TEST(parse_bom_fragment_invalid_utf32)
TEST(parse_pcdata_gap_fragment)
{
xml_document doc;
- CHECK(doc.load(STR("a&amp;b"), parse_fragment | parse_escapes));
+ CHECK(doc.load_string(STR("a&amp;b"), parse_fragment | parse_escapes));
CHECK_STRING(doc.text().get(), STR("a&b"));
}
diff --git a/tests/test_parse_doctype.cpp b/tests/test_parse_doctype.cpp
index f8619fd..14268f6 100644
--- a/tests/test_parse_doctype.cpp
+++ b/tests/test_parse_doctype.cpp
@@ -20,7 +20,7 @@ static xml_parse_result load_concat(xml_document& doc, const char_t* a, const ch
strcat(buffer, c);
#endif
- return doc.load(buffer, parse_fragment);
+ return doc.load_string(buffer, parse_fragment);
}
static bool test_doctype_wf(const char_t* decl)
@@ -41,7 +41,7 @@ static bool test_doctype_wf(const char_t* decl)
if (!load_concat(doc, STR("<nodea/>"), decl, STR("<nodeb/>")) || !test_node(doc, STR("<nodea /><nodeb />"), STR(""), format_raw)) return false;
// check load-store contents preservation
- CHECK(doc.load(decl, parse_doctype | parse_fragment));
+ CHECK(doc.load_string(decl, parse_doctype | parse_fragment));
CHECK_NODE(doc, decl);
return true;
@@ -281,8 +281,8 @@ TEST(parse_doctype_xmlconf_oasis_1)
// not actually a doctype :)
xml_document doc;
- CHECK(doc.load(STR("<!--a <!DOCTYPE <?- ]]>-<[ CDATA [ \"- -'- -<doc>--> <!---->"), parse_full | parse_fragment) && doc.first_child().type() == node_comment && doc.last_child().type() == node_comment && doc.first_child().next_sibling() == doc.last_child());
- CHECK(doc.load(STR("<?xmla <!DOCTYPE <[ CDATA [</doc> &a%b&#c?>"), parse_full | parse_fragment) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child());
+ CHECK(doc.load_string(STR("<!--a <!DOCTYPE <?- ]]>-<[ CDATA [ \"- -'- -<doc>--> <!---->"), parse_full | parse_fragment) && doc.first_child().type() == node_comment && doc.last_child().type() == node_comment && doc.first_child().next_sibling() == doc.last_child());
+ CHECK(doc.load_string(STR("<?xmla <!DOCTYPE <[ CDATA [</doc> &a%b&#c?>"), parse_full | parse_fragment) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child());
}
TEST(parse_doctype_xmlconf_xmltest_1)
@@ -310,15 +310,15 @@ TEST_XML_FLAGS(parse_doctype_value, "<!DOCTYPE doc [ <!ELEMENT doc (#PCDATA)> <!
TEST(parse_doctype_error_toplevel)
{
xml_document doc;
- CHECK(doc.load(STR("<node><!DOCTYPE></node>")).status == status_bad_doctype);
- CHECK(doc.load(STR("<node><!DOCTYPE></node>"), parse_doctype).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("<node><!DOCTYPE></node>")).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("<node><!DOCTYPE></node>"), parse_doctype).status == status_bad_doctype);
}
TEST(parse_doctype_error_ignore)
{
xml_document doc;
- CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ ")).status == status_bad_doctype);
- CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ "), parse_doctype).status == status_bad_doctype);
- CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE[")).status == status_bad_doctype);
- CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE["), parse_doctype).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ ")).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ "), parse_doctype).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE[")).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE["), parse_doctype).status == status_bad_doctype);
}
diff --git a/tests/test_write.cpp b/tests/test_write.cpp
index 8fc88e1..ca230c3 100644
--- a/tests/test_write.cpp
+++ b/tests/test_write.cpp
@@ -483,7 +483,7 @@ TEST(write_stackless)
data += STR("</a>");
xml_document doc;
- CHECK(doc.load(data.c_str()));
+ CHECK(doc.load_string(data.c_str()));
CHECK_NODE(doc, data.c_str());
}
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index a65ee37..e410882 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -13,7 +13,7 @@
static void load_document_copy(xml_document& doc, const char_t* text)
{
xml_document source;
- CHECK(source.load(text));
+ CHECK(source.load_string(text));
doc.append_copy(source.first_child());
}
@@ -551,10 +551,10 @@ TEST_XML(xpath_sort_append_buffer, "<node /><node />")
TEST(xpath_sort_crossdoc)
{
xml_document doc1;
- CHECK(doc1.load(STR("<node />")));
+ CHECK(doc1.load_string(STR("<node />")));
xml_document doc2;
- CHECK(doc2.load(STR("<node />")));
+ CHECK(doc2.load_string(STR("<node />")));
xpath_node_set ns1 = doc1.select_nodes(STR("*"));
CHECK(ns1.size() == 1);