From b87160013b697d9fb1b3b419b9801eecac9b3885 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 22 Apr 2015 07:51:02 -0700 Subject: Use has_name/has_value in set_name/set_value --- src/pugixml.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'src/pugixml.cpp') 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(_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_) -- cgit v1.2.3