summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-22 07:51:02 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-22 07:51:02 -0700
commitb87160013b697d9fb1b3b419b9801eecac9b3885 (patch)
treee2b26accb43908b899209ee141c4239689198d20 /src
parent4649914447d2e44a7df3e8d6dc1fc837503e8737 (diff)
Use has_name/has_value in set_name/set_value
Diffstat (limited to 'src')
-rw-r--r--src/pugixml.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 10208e7..49959aa 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -5490,38 +5490,29 @@ namespace pugi
PUGI__FN bool xml_node::set_name(const char_t* rhs)
{
- switch (type())
- {
- case node_pi:
- case node_declaration:
- case node_element:
+ if (!_root) return false;
+
+ if (impl::has_name(_root))
return impl::strcpy_insitu(_root->contents, _root->header, impl::xml_memory_page_contents_allocated_mask, rhs);
- default:
- return false;
- }
+ return false;
}
PUGI__FN bool xml_node::set_value(const char_t* rhs)
{
- switch (type())
- {
- case node_pi:
+ if (!_root) return false;
+
+ if (impl::has_value(_root))
+ return impl::strcpy_insitu(_root->contents, _root->header, impl::xml_memory_page_contents_allocated_mask, rhs);
+
+ if (PUGI__NODETYPE(_root) == node_pi)
{
xml_node_pi_struct* pn = static_cast<xml_node_pi_struct*>(_root);
return impl::strcpy_insitu(pn->pi_value, pn->pi_header, impl::xml_memory_page_contents_allocated_mask, rhs);
}
- case node_cdata:
- case node_pcdata:
- case node_comment:
- case node_doctype:
- return impl::strcpy_insitu(_root->contents, _root->header, impl::xml_memory_page_contents_allocated_mask, rhs);
-
- default:
- return false;
- }
+ return false;
}
PUGI__FN xml_attribute xml_node::append_attribute(const char_t* name_)