mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-27 13:33:17 +08:00
Merge pull request #537 from stefanroellin/size-t-overloads
Add overloads with size_t type argument
This commit is contained in:
commit
08a5048f15
@ -1275,6 +1275,7 @@ As discussed before, nodes can have name and value, both of which are strings. D
|
|||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
bool xml_node::set_name(const char_t* rhs);
|
bool xml_node::set_name(const char_t* rhs);
|
||||||
|
bool xml_node::set_name(const char_t* rhs, size_t sz)
|
||||||
bool xml_node::set_value(const char_t* rhs);
|
bool xml_node::set_value(const char_t* rhs);
|
||||||
bool xml_node::set_value(const char_t* rhs, size_t size);
|
bool xml_node::set_value(const char_t* rhs, size_t size);
|
||||||
----
|
----
|
||||||
@ -1297,6 +1298,7 @@ All attributes have name and value, both of which are strings (value may be empt
|
|||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
bool xml_attribute::set_name(const char_t* rhs);
|
bool xml_attribute::set_name(const char_t* rhs);
|
||||||
|
bool xml_attribute::set_name(const char_t* rhs, size_t sz)
|
||||||
bool xml_attribute::set_value(const char_t* rhs);
|
bool xml_attribute::set_value(const char_t* rhs);
|
||||||
bool xml_attribute::set_value(const char_t* rhs, size_t size);
|
bool xml_attribute::set_value(const char_t* rhs, size_t size);
|
||||||
----
|
----
|
||||||
|
@ -5401,6 +5401,13 @@ namespace pugi
|
|||||||
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
|
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PUGI_IMPL_FN bool xml_attribute::set_name(const char_t* rhs, size_t sz)
|
||||||
|
{
|
||||||
|
if (!_attr) return false;
|
||||||
|
|
||||||
|
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, sz);
|
||||||
|
}
|
||||||
|
|
||||||
PUGI_IMPL_FN bool xml_attribute::set_value(const char_t* rhs, size_t sz)
|
PUGI_IMPL_FN bool xml_attribute::set_value(const char_t* rhs, size_t sz)
|
||||||
{
|
{
|
||||||
if (!_attr) return false;
|
if (!_attr) return false;
|
||||||
@ -5798,6 +5805,16 @@ namespace pugi
|
|||||||
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
|
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PUGI_IMPL_FN bool xml_node::set_name(const char_t* rhs, size_t sz)
|
||||||
|
{
|
||||||
|
xml_node_type type_ = _root ? PUGI_IMPL_NODETYPE(_root) : node_null;
|
||||||
|
|
||||||
|
if (type_ != node_element && type_ != node_pi && type_ != node_declaration)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, sz);
|
||||||
|
}
|
||||||
|
|
||||||
PUGI_IMPL_FN bool xml_node::set_value(const char_t* rhs, size_t sz)
|
PUGI_IMPL_FN bool xml_node::set_value(const char_t* rhs, size_t sz)
|
||||||
{
|
{
|
||||||
xml_node_type type_ = _root ? PUGI_IMPL_NODETYPE(_root) : node_null;
|
xml_node_type type_ = _root ? PUGI_IMPL_NODETYPE(_root) : node_null;
|
||||||
|
@ -418,6 +418,7 @@ namespace pugi
|
|||||||
|
|
||||||
// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
|
// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
|
||||||
bool set_name(const char_t* rhs);
|
bool set_name(const char_t* rhs);
|
||||||
|
bool set_name(const char_t* rhs, size_t sz);
|
||||||
bool set_value(const char_t* rhs, size_t sz);
|
bool set_value(const char_t* rhs, size_t sz);
|
||||||
bool set_value(const char_t* rhs);
|
bool set_value(const char_t* rhs);
|
||||||
|
|
||||||
@ -553,6 +554,7 @@ namespace pugi
|
|||||||
|
|
||||||
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
|
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
|
||||||
bool set_name(const char_t* rhs);
|
bool set_name(const char_t* rhs);
|
||||||
|
bool set_name(const char_t* rhs, size_t sz);
|
||||||
bool set_value(const char_t* rhs, size_t sz);
|
bool set_value(const char_t* rhs, size_t sz);
|
||||||
bool set_value(const char_t* rhs);
|
bool set_value(const char_t* rhs);
|
||||||
|
|
||||||
|
@ -46,6 +46,16 @@ TEST_XML(dom_attr_set_name, "<node attr='value' />")
|
|||||||
CHECK_NODE(doc, STR("<node n=\"value\"/>"));
|
CHECK_NODE(doc, STR("<node n=\"value\"/>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_XML(dom_attr_set_name_with_size, "<node attr='value' />")
|
||||||
|
{
|
||||||
|
xml_attribute attr = doc.child(STR("node")).attribute(STR("attr"));
|
||||||
|
|
||||||
|
CHECK(attr.set_name(STR("n1234"), 1));
|
||||||
|
CHECK(!xml_attribute().set_name(STR("nfail"), 1));
|
||||||
|
|
||||||
|
CHECK_NODE(doc, STR("<node n=\"value\"/>"));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_XML(dom_attr_set_value, "<node/>")
|
TEST_XML(dom_attr_set_value, "<node/>")
|
||||||
{
|
{
|
||||||
xml_node node = doc.child(STR("node"));
|
xml_node node = doc.child(STR("node"));
|
||||||
@ -206,6 +216,15 @@ TEST_XML(dom_node_set_name, "<node>text</node>")
|
|||||||
CHECK_NODE(doc, STR("<n>text</n>"));
|
CHECK_NODE(doc, STR("<n>text</n>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_XML(dom_node_set_name_with_size, "<node>text</node>")
|
||||||
|
{
|
||||||
|
CHECK(doc.child(STR("node")).set_name(STR("nlongname"), 1));
|
||||||
|
CHECK(!doc.child(STR("node")).first_child().set_name(STR("n42"), 1));
|
||||||
|
CHECK(!xml_node().set_name(STR("nanothername"), 1));
|
||||||
|
|
||||||
|
CHECK_NODE(doc, STR("<n>text</n>"));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_XML(dom_node_set_value, "<node>text</node>")
|
TEST_XML(dom_node_set_value, "<node>text</node>")
|
||||||
{
|
{
|
||||||
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text")));
|
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user