aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFerenc Géczi <ferenc.gm@gmail.com>2022-09-29 00:00:00 +0000
committerFerenc Géczi <ferenc.gm@gmail.com>2022-09-29 18:26:05 +0000
commitf327371219a452facc5806c20b43ced04b7254a6 (patch)
treef61faf5033e298f8304b66c37130033bb183bde0 /src
parenteffc46f0ed35a70a53db7f56e37141ae3cb3a92a (diff)
downloadpugixml-f327371219a452facc5806c20b43ced04b7254a6.zip
pugixml-f327371219a452facc5806c20b43ced04b7254a6.tar.gz
pugixml-f327371219a452facc5806c20b43ced04b7254a6.tar.bz2
Add overloads with size_t type argument
* xml_node::set_value(const char_t* rhs, size_t sz) * xml_text::set(const char_t* rhs, size_t sz) Signed-off-by: Ferenc Géczi <ferenc.gm@gmail.com>
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 aada2ac..f264362 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -5691,6 +5691,16 @@ namespace pugi
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
}
+ PUGI__FN bool xml_node::set_value(const char_t* rhs, size_t sz)
+ {
+ xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null;
+
+ if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype)
+ return false;
+
+ return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
+ }
+
PUGI__FN bool xml_node::set_value(const char_t* rhs)
{
xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null;
@@ -6544,6 +6554,13 @@ namespace pugi
}
#endif
+ PUGI__FN bool xml_text::set(const char_t* rhs, size_t sz)
+ {
+ xml_node_struct* dn = _data_new();
+
+ return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, sz) : false;
+ }
+
PUGI__FN bool xml_text::set(const char_t* rhs)
{
xml_node_struct* dn = _data_new();
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index f9ffaa2..82b2d1f 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -551,6 +551,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_value(const char_t* rhs, size_t sz);
bool set_value(const char_t* rhs);
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
@@ -776,6 +777,7 @@ namespace pugi
bool as_bool(bool def = false) const;
// Set text (returns false if object is empty or there is not enough memory)
+ bool set(const char_t* rhs, size_t sz);
bool set(const char_t* rhs);
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")