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("");
+ doc.load_string("");
}
// 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("0 0 1 1");
+ pugi::xml_parse_result result = doc.load_string("0 0 1 1");
//]
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 = "<";
// Parsing with default options; note that comment node is not added to the tree, and entity reference < 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; < 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 < 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("text", pugi::parse_default | pugi::parse_comments)) return -1;
+ if (!doc.load_string("text", 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("Simple node")) return -1;
+ if (!doc.load_string("Simple 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("hey");
+ doc.load_string("hey");
// 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("hey");
+ doc.load_string("hey");
// 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("hey");
+ doc.load_string("hey");
//[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("hey");
+ doc.load_string("hey");
// default options; prints
//
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("hey");
+ doc.load_string("hey");
//[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("hey");
+ doc.load_string("hey");
// print document to standard output (prints hey)
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("test1.1yes");
+ doc.load_string("test1.1yes");
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 >& 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("")));
+ CHECK(doc.load_string(STR("")));
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("")));
+ CHECK(doc.load_string(STR("")));
CHECK(doc.first_child());
std::basic_ifstream fs1("filedoesnotexist");
@@ -261,7 +261,7 @@ TEST(document_load_string)
{
pugi::xml_document doc;
- CHECK(doc.load(STR("")));
+ CHECK(doc.load_string(STR("")));
CHECK_NODE(doc, STR(""));
}
@@ -308,7 +308,7 @@ TEST(document_load_file_error)
TEST(document_load_file_error_previous)
{
pugi::xml_document doc;
- CHECK(doc.load(STR("")));
+ CHECK(doc.load_string(STR("")));
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("")));
+ CHECK(!doc.load_string(STR("")));
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("")
CHECK(!doc.first_child());
CHECK_NODE(doc, STR(""));
- CHECK(doc.load(STR("")));
+ CHECK(doc.load_string(STR("")));
CHECK(doc.first_child());
CHECK_NODE(doc, STR(""));
@@ -1268,7 +1268,7 @@ TEST(document_alignment)
{
xml_document* doc = new (buf + offset) xml_document;
- CHECK(doc->load(STR("")));
+ CHECK(doc->load_string(STR("")));
CHECK_NODE(*doc, STR(""));
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("")));
+ CHECK_NODE(doc, STR(""));
+}
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("");
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("pcdata"), parse_full));
+ CHECK(doc.load_string(STR("pcdata"), 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("")));
+ CHECK(doc.load_string(STR("")));
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(""), flags));
+ CHECK(doc.load_string(STR(""), flags));
CHECK(!doc.first_child());
- CHECK(doc.load(STR(" value?>"), flags));
+ CHECK(doc.load_string(STR(" 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(""), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR(""), 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(""), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR(""), 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(""), 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_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(""), parse_fragment | parse_pi).status == status_bad_pi);
- CHECK(doc.load(STR(""), parse_fragment | parse_pi).status == status_bad_pi);
- CHECK(doc.load(STR(""), parse_fragment | parse_pi).status == status_bad_pi);
+ CHECK(doc.load_string(STR(""), parse_fragment | parse_pi).status == status_bad_pi);
+ CHECK(doc.load_string(STR(""), parse_fragment | parse_pi).status == status_bad_pi);
+ CHECK(doc.load_string(STR(""), parse_fragment | parse_pi).status == status_bad_pi);
}
TEST(parse_comments_skip)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_fragment));
+ CHECK(doc.load_string(STR(""), parse_fragment));
CHECK(!doc.first_child());
}
TEST(parse_comments_parse)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_fragment | parse_comments));
+ CHECK(doc.load_string(STR(""), 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(""), parse_fragment | parse_comments));
+ CHECK(doc.load_string(STR(""), 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(""), parse_fragment | parse_comments | parse_eol));
+ CHECK(doc.load_string(STR(""), 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(""), 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(""), parse_fragment));
+ CHECK(doc.load_string(STR(""), parse_fragment));
CHECK(!doc.first_child());
}
TEST(parse_cdata_skip_contents)
{
xml_document doc;
- CHECK(doc.load(STR("hello, world!"), parse_fragment));
+ CHECK(doc.load_string(STR("hello, world!"), parse_fragment));
CHECK_NODE(doc, STR("hello, world!"));
}
TEST(parse_cdata_parse)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_fragment | parse_cdata));
+ CHECK(doc.load_string(STR(""), 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(""), parse_fragment | parse_cdata));
+ CHECK(doc.load_string(STR(""), 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(""), parse_fragment | parse_cdata | parse_eol));
+ CHECK(doc.load_string(STR(""), 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(""), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR(""), flags).status == status_bad_cdata);
+ CHECK(doc.load_string(STR(""), 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(" "), parse_minimal));
+ CHECK(doc.load_string(STR(" "), 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(" "), parse_minimal | parse_ws_pcdata));
+ CHECK(doc.load_string(STR(" "), 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("\r\rval1\rval2\r\nval3\nval4\r\r"), parse_minimal));
+ CHECK(doc.load_string(STR("\r\rval1\rval2\r\nval3\nval4\r\r"), 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("\r\rval1\rval2\r\nval3\nval4\r\r"), parse_minimal | parse_eol));
+ CHECK(doc.load_string(STR("\r\rval1\rval2\r\nval3\nval4\r\r"), 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("prepost"), parse_minimal));
+ CHECK(doc.load_string(STR("prepost"), 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("pcdata"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("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(" "), flags[i] | parse_trim_pcdata));
+ CHECK(doc.load_string(STR(" "), 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("<>&'""), parse_minimal));
+ CHECK(doc.load_string(STR("<>&'""), parse_minimal));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("<>&'""));
}
TEST(parse_escapes_parse)
{
xml_document doc;
- CHECK(doc.load(STR("<>&'""), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("<>&'""), 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(" "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR(" "), 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("/; :;a;A;
"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("/; :;a;A;
"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("/;\x1\x2\x3\x4\x5\x6\x7\x8\x9:;a;A;
"));
}
TEST(parse_escapes_code_exhaustive_hex)
{
xml_document doc;
- CHECK(doc.load(STR("/; :;@;
G;`;
g;"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("/; :;@;
G;`;
g;"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("/;\x1\x2\x3\x4\x5\x6\x7\x8\x9:;@;\xa\xb\xc\xd\xe\xfG;`;\xa\xb\xc\xd\xe\xfg;"));
}
TEST(parse_escapes_code_restore)
{
xml_document doc;
- CHECK(doc.load(STR(" - - "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR(" - - "), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR(" - - "));
}
@@ -529,26 +529,26 @@ TEST(parse_escapes_char_restore)
{
xml_document doc;
- CHECK(doc.load(STR("&q &qu &quo " "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("&q &qu &quo " "), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&q &qu &quo " "));
- CHECK(doc.load(STR("&a &ap &apo &apos "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("&a &ap &apo &apos "), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&a &ap &apo &apos "));
- CHECK(doc.load(STR("&a &am & "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("&a &am & "), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&a &am & "));
- CHECK(doc.load(STR("&l < "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("&l < "), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&l < "));
- CHECK(doc.load(STR("&g > "), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("&g > "), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&g > "));
}
TEST(parse_escapes_unicode)
{
xml_document doc;
- CHECK(doc.load(STR("γγ𤭢"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("γγ𤭢"), 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("g;ab;""), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("g;ab;""), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("g;ab;""));
- CHECK(!doc.load(STR("&;-;-;"), parse_minimal | parse_escapes));
+ CHECK(doc.load_string(STR("&;-;-;"), parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value(STR("node")), STR("&;-;-;"));
}
@@ -598,7 +598,7 @@ TEST(parse_escapes_attribute)
flags |= (eol ? parse_eol : 0);
flags |= (wconv ? parse_wconv_attribute : 0);
- CHECK(doc.load(STR(""), flags));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal | parse_eol));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal | parse_wconv_attribute));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal | parse_eol | parse_wconv_attribute));
+ CHECK(doc.load_string(STR(""), 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(""), flags));
+ CHECK(doc.load_string(STR(""), 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(""), flags));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), 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(""), flags));
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal));
+ CHECK(doc.load_string(STR(""), parse_minimal));
CHECK_NODE(doc, STR(""));
}
TEST(parse_tag_hierarchy)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_minimal));
+ CHECK(doc.load_string(STR(""), parse_minimal));
CHECK_NODE(doc, STR(""));
}
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_bad_start_element);
- CHECK(doc.load(STR(""), 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(""), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR(""), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR("<"), parse_minimal).status == status_unrecognized_tag);
- CHECK(doc.load(STR(""), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR(">"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR(""), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR(">"), parse_minimal).status == status_end_element_mismatch);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_end_element);
- CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element);
- CHECK(doc.load(STR(""), 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_bad_start_element);
+ CHECK(doc.load_string(STR(""), 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(""), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR("<"), parse_minimal).status == status_unrecognized_tag);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR(">"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR(">"), parse_minimal).status == status_end_element_mismatch);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_end_element);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element);
+ CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element);
}
TEST(parse_declaration_cases)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR(""), parse_fragment | parse_pi));
CHECK(!doc.first_child());
}
TEST(parse_declaration_attr_cases)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_fragment | parse_pi));
+ CHECK(doc.load_string(STR(""), 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(""), flags));
+ CHECK(doc.load_string(STR(""), flags));
CHECK(!doc.first_child());
- CHECK(doc.load(STR(" ?>"), flags));
+ CHECK(doc.load_string(STR(" ?>"), flags));
CHECK(!doc.first_child());
}
}
@@ -827,7 +827,7 @@ TEST(parse_declaration_skip)
TEST(parse_declaration_parse)
{
xml_document doc;
- CHECK(doc.load(STR(""), parse_fragment | parse_declaration));
+ CHECK(doc.load_string(STR(""), 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(""), flags).status == status_bad_pi);
- CHECK(doc.load(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(STR(""), parse_fragment | parse_declaration).status == status_bad_attribute);
- CHECK(doc.load(STR(""), parse_fragment | parse_declaration).status == status_bad_pi);
+ CHECK(doc.load_string(STR(""), parse_fragment | parse_declaration).status == status_bad_attribute);
+ CHECK(doc.load_string(STR(""), 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("")).status == status_out_of_memory);
+ CHECK(doc.load_string(STR("")).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&b"), parse_fragment | parse_escapes));
+ CHECK(doc.load_string(STR("a&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(""), decl, STR("")) || !test_node(doc, STR(""), 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(" "), 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(" &a%bc?>"), parse_full | parse_fragment) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child());
+ CHECK(doc.load_string(STR(" "), 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(" &a%bc?>"), 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, " ")).status == status_bad_doctype);
- CHECK(doc.load(STR(""), parse_doctype).status == status_bad_doctype);
+ CHECK(doc.load_string(STR("")).status == status_bad_doctype);
+ CHECK(doc.load_string(STR(""), parse_doctype).status == status_bad_doctype);
}
TEST(parse_doctype_error_ignore)
{
xml_document doc;
- CHECK(doc.load(STR("");
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, "")
TEST(xpath_sort_crossdoc)
{
xml_document doc1;
- CHECK(doc1.load(STR("")));
+ CHECK(doc1.load_string(STR("")));
xml_document doc2;
- CHECK(doc2.load(STR("")));
+ CHECK(doc2.load_string(STR("")));
xpath_node_set ns1 = doc1.select_nodes(STR("*"));
CHECK(ns1.size() == 1);