Reorder set_value/set size_t overloads and change sz to size

This makes the source order and naming match documentation.
This commit is contained in:
Arseny Kapoulkine 2023-08-26 08:40:34 -07:00
parent 5a33d2b1d7
commit bf42c4c568
2 changed files with 33 additions and 33 deletions

View File

@ -5401,18 +5401,11 @@ 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)
PUGI_IMPL_FN bool xml_attribute::set_name(const char_t* rhs, size_t size)
{
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;
return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, size);
}
PUGI_IMPL_FN bool xml_attribute::set_value(const char_t* rhs)
@ -5422,6 +5415,13 @@ namespace pugi
return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs));
}
PUGI_IMPL_FN bool xml_attribute::set_value(const char_t* rhs, size_t size)
{
if (!_attr) return false;
return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, size);
}
PUGI_IMPL_FN bool xml_attribute::set_value(int rhs)
{
if (!_attr) return false;
@ -5805,24 +5805,14 @@ 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)
PUGI_IMPL_FN bool xml_node::set_name(const char_t* rhs, size_t size)
{
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;
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);
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, size);
}
PUGI_IMPL_FN bool xml_node::set_value(const char_t* rhs)
@ -5835,6 +5825,16 @@ namespace pugi
return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs));
}
PUGI_IMPL_FN bool xml_node::set_value(const char_t* rhs, size_t size)
{
xml_node_type type_ = _root ? PUGI_IMPL_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, size);
}
PUGI_IMPL_FN xml_attribute xml_node::append_attribute(const char_t* name_)
{
if (!impl::allow_insert_attribute(type())) return xml_attribute();
@ -6707,13 +6707,6 @@ namespace pugi
}
#endif
PUGI_IMPL_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_IMPL_FN bool xml_text::set(const char_t* rhs)
{
xml_node_struct* dn = _data_new();
@ -6721,6 +6714,13 @@ namespace pugi
return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)) : false;
}
PUGI_IMPL_FN bool xml_text::set(const char_t* rhs, size_t size)
{
xml_node_struct* dn = _data_new();
return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, size) : false;
}
PUGI_IMPL_FN bool xml_text::set(int rhs)
{
xml_node_struct* dn = _data_new();

View File

@ -418,9 +418,9 @@ 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_name(const char_t* rhs, size_t size);
bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
bool set_value(int rhs);
@ -554,9 +554,9 @@ 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_name(const char_t* rhs, size_t size);
bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
xml_attribute append_attribute(const char_t* name);
@ -784,8 +784,8 @@ 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);
bool set(const char_t* rhs, size_t size);
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
bool set(int rhs);