aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Roellin <stefan@roellin-baumann.ch>2022-11-24 08:45:51 +0100
committerStefan Roellin <stefan@roellin-baumann.ch>2023-08-26 11:30:49 +0200
commitf4d4316eba8f2d26a8f78b87fb474a2fe238801f (patch)
tree749bbb17501f5d22aa673270bebd1159d0f79cfc /src
parentc72a210ff78afcb16c1f06285644bab89d78a9b2 (diff)
downloadpugixml-f4d4316eba8f2d26a8f78b87fb474a2fe238801f.zip
pugixml-f4d4316eba8f2d26a8f78b87fb474a2fe238801f.tar.gz
pugixml-f4d4316eba8f2d26a8f78b87fb474a2fe238801f.tar.bz2
Add overloads with size_t type argument
* bool xml_attribute::set_name(const char_t* rhs, size_t sz) * bool xml_node::set_name(const char_t* rhs, size_t sz)
Diffstat (limited to 'src')
-rw-r--r--src/pugixml.cpp17
-rw-r--r--src/pugixml.hpp2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index e02a137..00cd64a 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -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));
}
+ 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)
{
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));
}
+ 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)
{
xml_node_type type_ = _root ? PUGI_IMPL_NODETYPE(_root) : node_null;
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 8749759..42414c3 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -418,6 +418,7 @@ namespace pugi
// 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, size_t sz);
bool set_value(const char_t* rhs, size_t sz);
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)
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);