[libxml++] Node: Move the null-pointer check to the constructor.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml++] Node: Move the null-pointer check to the constructor.
- Date: Mon, 12 Aug 2013 14:39:23 +0000 (UTC)
commit dab34672a5a06641a9f56922a7d4eaefa55b9627
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Mon Aug 12 16:35:03 2013 +0200
Node: Move the null-pointer check to the constructor.
* libxml++/nodes/node.[h|cc]: Let the constructor throw xmlpp:internal_error
if impl_ == 0. Remove other null-pointer checks. Bug #705187.
libxml++/nodes/node.cc | 11 ++++-------
libxml++/nodes/node.h | 2 ++
2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc
index 325b9d0..c35bd16 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -119,7 +119,10 @@ namespace xmlpp
Node::Node(xmlNode* node)
: impl_(node)
{
- impl_->_private = this;
+ if (!impl_)
+ throw internal_error("xmlNode pointer cannot be 0");
+
+ impl_->_private = this;
}
Node::~Node()
@@ -510,9 +513,6 @@ Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, const PrefixNsMap
Glib::ustring Node::get_namespace_prefix() const
{
- if(!impl_)
- return Glib::ustring();
-
if(impl_->type == XML_DOCUMENT_NODE || impl_->type == XML_ENTITY_DECL)
{
//impl_ is actually of type xmlDoc or xmlEntity, instead of just xmlNode.
@@ -538,9 +538,6 @@ Glib::ustring Node::get_namespace_prefix() const
Glib::ustring Node::get_namespace_uri() const
{
- if(!impl_)
- return Glib::ustring();
-
if(impl_->type == XML_DOCUMENT_NODE ||
impl_->type == XML_ENTITY_DECL ||
impl_->type == XML_ATTRIBUTE_DECL)
diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h
index a60107e..6a02ecf 100644
--- a/libxml++/nodes/node.h
+++ b/libxml++/nodes/node.h
@@ -55,6 +55,8 @@ class Node : public NonCopyable
public:
typedef std::list<Node*> NodeList;
+ /** @throws xmlpp::internal_error If @a node is <tt>0</tt>.
+ */
explicit Node(_xmlNode* node);
virtual ~Node();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]