Commit 737e638a authored by Gaurav Gupta's avatar Gaurav Gupta Committed by Murray Cumming

Use nullptr instead of 0 at missing places - C++-11

parent c10e8342
......@@ -202,7 +202,7 @@ Dtd* Document::get_internal_subset() const
{
auto dtd = xmlGetIntSubset(impl_);
if(!dtd)
return 0;
return nullptr;
if(!dtd->_private)
dtd->_private = new Dtd(dtd);
......@@ -227,7 +227,7 @@ Element* Document::get_root_node() const
{
auto root = xmlDocGetRootElement(impl_);
if(root == nullptr)
return 0;
return nullptr;
else
{
Node::create_wrapper(root);
......@@ -266,7 +266,7 @@ Element* Document::create_root_node_by_import(const Node* node,
bool recursive)
{
if (!node)
return 0;
return nullptr;
//Create the node, by copying:
auto imported_node = xmlDocCopyNode(const_cast<xmlNode*>(node->cobj()), impl_, recursive);
......
......@@ -47,7 +47,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name,
{
ns_uri = get_namespace_uri_for_prefix(ns_prefix);
if (ns_uri.empty())
return 0; // No such prefix.
return nullptr; // No such prefix.
}
// The return value of xmlHasNsProp() may be either an xmlAttr*, pointing to an
......@@ -55,14 +55,14 @@ Attribute* Element::get_attribute(const Glib::ustring& name,
// cast to an xmlAttr*, pointing to the declaration of an attribute with a
// default value (XML_ATTRIBUTE_DECL).
auto attr = xmlHasNsProp(const_cast<xmlNode*>(cobj()), (const xmlChar*)name.c_str(),
ns_uri.empty() ? 0 : (const xmlChar*)ns_uri.c_str());
ns_uri.empty() ? nullptr : (const xmlChar*)ns_uri.c_str());
if (attr)
{
Node::create_wrapper(reinterpret_cast<xmlNode*>(attr));
return reinterpret_cast<Attribute*>(attr->_private);
}
return 0;
return nullptr;
}
Glib::ustring Element::get_attribute_value(const Glib::ustring& name, const Glib::ustring& ns_prefix) const
......@@ -102,7 +102,7 @@ Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring
return reinterpret_cast<Attribute*>(attr->_private);
}
else
return 0;
return nullptr;
}
void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& ns_prefix)
......@@ -127,7 +127,7 @@ const TextNode* Element::get_child_text() const
return static_cast<TextNode*>(child->_private);
}
return 0;
return nullptr;
}
TextNode* Element::get_child_text()
......@@ -141,7 +141,7 @@ TextNode* Element::get_child_text()
return static_cast<TextNode*>(child->_private);
}
return 0;
return nullptr;
}
void Element::set_child_text(const Glib::ustring& content)
......@@ -169,13 +169,13 @@ TextNode* Element::add_child_text(const Glib::ustring& content)
Node::create_wrapper(node);
return static_cast<TextNode*>(node->_private);
}
return 0;
return nullptr;
}
TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ustring& content)
{
if(!previous_sibling)
return 0;
return nullptr;
if(cobj()->type == XML_ELEMENT_NODE)
{
......@@ -191,13 +191,13 @@ TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ust
Node::create_wrapper(node);
return static_cast<TextNode*>(node->_private);
}
return 0;
return nullptr;
}
TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content)
{
if(!next_sibling)
return 0;
return nullptr;
if(cobj()->type == XML_ELEMENT_NODE)
{
......@@ -213,7 +213,7 @@ TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib::
Node::create_wrapper(node);
return static_cast<TextNode*>(node->_private);
}
return 0;
return nullptr;
}
bool Element::has_child_text() const
......@@ -224,13 +224,13 @@ bool Element::has_child_text() const
void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
{
//Create a new namespace declaration for this element:
auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()),
(const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()),
(const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) );
if (!ns)
{
// Not an error, if we try to assign the same uri to the prefix once again.
ns = xmlSearchNs(cobj()->doc, cobj(),
(const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()));
(const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()));
const char* const previous_href = (ns && ns->href) ? (const char*)ns->href : "";
if (!ns || ns_uri != previous_href)
throw exception("Could not add namespace declaration with URI=" + ns_uri +
......
......@@ -148,7 +148,7 @@ const Element* Node::get_parent() const
Element* Node::get_parent()
{
if(!(cobj()->parent && cobj()->parent->type == XML_ELEMENT_NODE))
return 0;
return nullptr;
Node::create_wrapper(cobj()->parent);
return static_cast<Element*>(cobj()->parent->_private);
......@@ -162,7 +162,7 @@ const Node* Node::get_next_sibling() const
Node* Node::get_next_sibling()
{
if(!cobj()->next)
return 0;
return nullptr;
Node::create_wrapper(cobj()->next);
return static_cast<Node*>(cobj()->next->_private);
......@@ -176,7 +176,7 @@ const Node* Node::get_previous_sibling() const
Node* Node::get_previous_sibling()
{
if(!cobj()->prev)
return 0;
return nullptr;
Node::create_wrapper(cobj()->prev);
return static_cast<Node*>(cobj()->prev->_private);
......@@ -197,7 +197,7 @@ Node* Node::get_first_child(const Glib::ustring& name)
{
auto child = impl_->children;
if(!child)
return 0;
return nullptr;
do
{
......@@ -206,7 +206,7 @@ Node* Node::get_first_child(const Glib::ustring& name)
}
while((child = child->next));
return 0;
return nullptr;
}
const Node* Node::get_first_child(const Glib::ustring& name) const
......@@ -373,7 +373,7 @@ void Node::remove_child(Node* node)
Node* Node::import_node(const Node* node, bool recursive)
{
if (!node)
return 0;
return nullptr;
//Create the node, by copying:
auto imported_node = xmlDocCopyNode(const_cast<xmlNode*>(node->cobj()), impl_->doc, recursive);
......
......@@ -301,7 +301,7 @@ Node* TextReader::get_current_node()
}
check_for_exceptions();
return 0;
return nullptr;
}
const Node* TextReader::get_current_node() const
......@@ -329,7 +329,7 @@ Node* TextReader::expand()
}
check_for_exceptions();
return 0;
return nullptr;
}
bool TextReader::next()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment