[libxml++] More use of nullptr instead of 0



commit a1012116d0deaeeb32a60606f4af3c2b71837230
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Oct 8 15:36:13 2015 +0200

    More use of nullptr instead of 0
    
    Bug #756166 (also the previous commit)

 libxml++/document.cc           |   12 ++++++------
 libxml++/document.h            |   10 +++++-----
 libxml++/nodes/element.cc      |   16 ++++++++--------
 libxml++/nodes/element.h       |    6 +++---
 libxml++/nodes/node.cc         |   16 ++++++++--------
 libxml++/nodes/node.h          |   30 +++++++++++++++---------------
 libxml++/parsers/textreader.cc |    6 +++---
 libxml++/parsers/textreader.h  |    8 ++++----
 8 files changed, 52 insertions(+), 52 deletions(-)
---
diff --git a/libxml++/document.cc b/libxml++/document.cc
index f85d70e..c6e4339 100644
--- a/libxml++/document.cc
+++ b/libxml++/document.cc
@@ -138,7 +138,7 @@ static const char* get_encoding_or_utf8(const Glib::ustring& encoding)
 {
   if(encoding.empty())
   {
-    //If we don't specify this to the xmlDocDump* functions (using 0 instead),
+    //If we don't specify this to the xmlDocDump* functions (using nullptr instead),
     //then some other encoding is used, causing them to fail on non-ASCII characters.
     return "UTF-8";
   }
@@ -215,8 +215,8 @@ void Document::set_internal_subset(const Glib::ustring& name,
 {
   auto dtd = xmlCreateIntSubset(impl_,
                                   (const xmlChar*)name.c_str(),
-                                  external_id.empty() ? (const xmlChar*)0 : (const 
xmlChar*)external_id.c_str(),
-                                  system_id.empty() ? (const xmlChar*)0 : (const xmlChar*)system_id.c_str());
+                                  external_id.empty() ? nullptr : (const xmlChar*)external_id.c_str(),
+                                  system_id.empty() ? nullptr : (const xmlChar*)system_id.c_str());
 
   if (dtd && !dtd->_private)
     dtd->_private = new Dtd(dtd);
@@ -243,7 +243,7 @@ Element* Document::create_root_node(const Glib::ustring& name,
                                     const Glib::ustring& ns_uri,
                                     const Glib::ustring& ns_prefix)
 {
-  auto node = xmlNewDocNode(impl_, 0, (const xmlChar*)name.c_str(), 0);
+  auto node = xmlNewDocNode(impl_, nullptr, (const xmlChar*)name.c_str(), nullptr);
   if (!node)
     throw internal_error("Could not create root element node " + name);
 
@@ -416,8 +416,8 @@ void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType t
                               const Glib::ustring& content)
 {
   auto entity = xmlAddDocEntity( impl_, (const xmlChar*) name.c_str(), type,
-    publicId.empty() ? (const xmlChar*)0 : (const xmlChar*)publicId.c_str(),
-    systemId.empty() ? (const xmlChar*)0 : (const xmlChar*)systemId.c_str(),
+    publicId.empty() ? nullptr : (const xmlChar*)publicId.c_str(),
+    systemId.empty() ? nullptr : (const xmlChar*)systemId.c_str(),
     (const xmlChar*) content.c_str() );
   if (!entity)
     throw internal_error("Could not add entity declaration " + name);
diff --git a/libxml++/document.h b/libxml++/document.h
index 73ca18f..ea81b3f 100644
--- a/libxml++/document.h
+++ b/libxml++/document.h
@@ -80,7 +80,7 @@ public:
   /** Create a new C++ wrapper for an xmlDoc struct.
    * The created xmlpp::Document takes ownership of the xmlDoc.
    * When the Document is deleted, so is the xmlDoc and all its nodes.
-   * @param doc A pointer to an xmlDoc struct. Must not be <tt>0</tt>.
+   * @param doc A pointer to an xmlDoc struct. Must not be <tt>nullptr</tt>.
    */
   explicit Document(_xmlDoc* doc);
     
@@ -91,7 +91,7 @@ public:
   Glib::ustring get_encoding() const;
 
   /** Get the internal subset of this document.
-   * @returns A pointer to the DTD, or <tt>0</tt> if not found.
+   * @returns A pointer to the DTD, or <tt>nullptr</tt> if not found.
    */
   Dtd* get_internal_subset() const;
 
@@ -107,13 +107,13 @@ public:
 
   /** Return the root node.
    * This function does @b not create a default root node if it doesn't exist.
-   * @return A pointer to the root node if it exists, <tt>0</tt> otherwise.
+   * @return A pointer to the root node if it exists, <tt>nullptr</tt> otherwise.
    */
   Element* get_root_node();
 
   /** Return the root node.
    * This function does @b not create a default root node if it doesn't exist.
-   * @return A pointer to the root node if it exists, <tt>0</tt> otherwise.
+   * @return A pointer to the root node if it exists, <tt>nullptr</tt> otherwise.
    */
   const Element* get_root_node() const;
 
@@ -257,7 +257,7 @@ protected:
   /** Retrieve an Entity.
    * The entity can be from an external subset or internally declared.
    * @param name The name of the entity to get.
-   * @returns A pointer to the libxml2 entity structure, or <tt>0</tt> if not found.
+   * @returns A pointer to the libxml2 entity structure, or <tt>nullptr</tt> if not found.
    */
   _xmlEntity* get_entity(const Glib::ustring& name);
 
diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc
index 62a6605..3cc3697 100644
--- a/libxml++/nodes/element.cc
+++ b/libxml++/nodes/element.cc
@@ -75,7 +75,7 @@ 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));
@@ -216,7 +216,7 @@ _xmlNode* Element::create_new_child_element_node(const Glib::ustring& name,
    if (ns_prefix.empty())
    {
      //Retrieve default namespace if it exists
-     ns = xmlSearchNs(cobj()->doc, cobj(), 0);
+     ns = xmlSearchNs(cobj()->doc, cobj(), nullptr);
    }
    else
    {
@@ -235,12 +235,12 @@ _xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring
   if (cobj()->type != XML_ELEMENT_NODE)
     throw internal_error("You can only add child nodes to element nodes.");
 
-  auto child = xmlNewNode(0, (const xmlChar*)name.c_str());
+  auto child = xmlNewNode(nullptr, (const xmlChar*)name.c_str());
   if (!child)
     throw internal_error("Could not create new element node.");
 
-  auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()),
-                       (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
+  auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()),
+                       (const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) );
   // xmlNewNs() does not create a namespace node for the predefined xml prefix.
   // It's usually defined in the document and not in any specific node.
   if (!ns && ns_prefix == "xml")
@@ -357,13 +357,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 +
diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h
index bc879d9..e013828 100644
--- a/libxml++/nodes/element.h
+++ b/libxml++/nodes/element.h
@@ -59,7 +59,7 @@ public:
   /** Get the attribute with this name, and optionally with this namespace.
    * @param name The name of the attribute that will be retrieved.
    * @param ns_prefix Namespace prefix.
-   * @return The attribute, or 0 if no suitable Attribute was found.
+   * @return The attribute, or <tt>nullptr</tt> if no suitable Attribute was found.
    *         Is either an AttributeNode*, pointing to an explicitly set
    *         attribute, or an AttributeDeclaration*, pointing to the declaration
    *         of an attribute with a default value.
@@ -70,7 +70,7 @@ public:
   /** Get the attribute with this name, and optionally with this namespace.
    * @param name The name of the attribute that will be retrieved.
    * @param ns_prefix Namespace prefix.
-   * @return The attribute, or 0 if no suitable Attribute was found.
+   * @return The attribute, or <tt>nullptr</tt> if no suitable Attribute was found.
    *         Is either an AttributeNode*, pointing to an explicitly set
    *         attribute, or an AttributeDeclaration*, pointing to the declaration
    *         of an attribute with a default value.
@@ -95,7 +95,7 @@ public:
    * @param name The name of the attribute whose value will change.
    * @param value The new value for the attribute
    * @param ns_prefix Namespace prefix. If the prefix has not been declared then this method will throw an 
exception.
-   * @return The attribute that was changed, or 0 is no suitable Attribute was found.
+   * @return The attribute that was changed, or <tt>nullptr</tt> is no suitable Attribute was found.
    * @throws xmlpp::exception
    */
   Attribute* set_attribute(const Glib::ustring& name, const Glib::ustring& value,
diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc
index 177ca9f..71eab85 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -222,7 +222,7 @@ Node::Node(xmlNode* node)
   : impl_(node)
 {
   if (!impl_)
-    throw internal_error("xmlNode pointer cannot be 0");
+    throw internal_error("xmlNode pointer cannot be nullptr");
 
   impl_->_private = this;
 }
@@ -332,7 +332,7 @@ Node* Node::import_node(const Node* node, bool recursive)
   if (imported_node->type == XML_ATTRIBUTE_NODE && impl_->type == XML_ELEMENT_NODE)
   {
     auto old_attr = xmlHasNsProp(impl_, imported_node->name,
-      imported_node->ns ? imported_node->ns->href : 0);
+      imported_node->ns ? imported_node->ns->href : nullptr);
     if (old_attr && old_attr->type != XML_ATTRIBUTE_DECL)
     {
       // *this has an attribute with the same name as the imported attribute.
@@ -396,12 +396,12 @@ Glib::ustring Node::get_path() const
 
 Node::NodeSet Node::find(const Glib::ustring& xpath)
 {
-  return find_common<NodeSet>(xpath, 0, impl_);
+  return find_common<NodeSet>(xpath, nullptr, impl_);
 }
 
 Node::const_NodeSet Node::find(const Glib::ustring& xpath) const
 {
-  return find_common<const_NodeSet>(xpath, 0, impl_);
+  return find_common<const_NodeSet>(xpath, nullptr, impl_);
 }
 
 Node::NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces)
@@ -416,7 +416,7 @@ Node::const_NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& na
 
 bool Node::eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type) const
 {
-  return eval_common_to_boolean(xpath, 0, result_type, impl_);
+  return eval_common_to_boolean(xpath, nullptr, result_type, impl_);
 }
 
 bool Node::eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namespaces,
@@ -427,7 +427,7 @@ bool Node::eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namesp
 
 double Node::eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type) const
 {
-  return eval_common_to_number(xpath, 0, result_type, impl_);
+  return eval_common_to_number(xpath, nullptr, result_type, impl_);
 }
 
 double Node::eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& namespaces,
@@ -438,7 +438,7 @@ double Node::eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& names
 
 Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type) const
 {
-  return eval_common_to_string(xpath, 0, result_type, impl_);
+  return eval_common_to_string(xpath, nullptr, result_type, impl_);
 }
 
 Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, const PrefixNsMap& namespaces,
@@ -502,7 +502,7 @@ void Node::set_namespace(const Glib::ustring& ns_prefix)
   }
 
   //Look for the existing namespace to use:
-  auto ns = xmlSearchNs( cobj()->doc, cobj(), (xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
+  auto ns = xmlSearchNs( cobj()->doc, cobj(), (xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) );
   if(ns)
   {
       //Use it for this element:
diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h
index 8966b8d..577505d 100644
--- a/libxml++/nodes/node.h
+++ b/libxml++/nodes/node.h
@@ -57,7 +57,7 @@ public:
   typedef std::vector<Node*> NodeSet;
   typedef std::vector<const Node*> const_NodeSet;
 
-  /** @throws xmlpp::internal_error If @a node is <tt>0</tt>.
+  /** @throws xmlpp::internal_error If @a node is <tt>nullptr</tt>.
    */
   explicit Node(_xmlNode* node);
 
@@ -100,39 +100,39 @@ public:
   int get_line() const;
   
   /** Get the parent element for this node.
-   * @returns The parent node, or <tt>0</tt> if the node has no parent element.
+   * @returns The parent node, or <tt>nullptr</tt> if the node has no parent element.
    */
   const Element* get_parent() const;  
 
   /** Get the parent element for this node.
-   * @returns The parent node, or <tt>0</tt> if the node has no parent element.
+   * @returns The parent node, or <tt>nullptr</tt> if the node has no parent element.
    */
   Element* get_parent();  
 
   /** Get the next sibling for this node.
-   * @returns The next sibling, or <tt>0</tt> if the node has no next sibling.
+   * @returns The next sibling, or <tt>nullptr</tt> if the node has no next sibling.
    */
   const Node* get_next_sibling() const;  
 
   /** Get the next sibling for this node.
-   * @returns The next sibling, or <tt>0</tt> if the node has no next sibling.
+   * @returns The next sibling, or <tt>nullptr</tt> if the node has no next sibling.
    */
   Node* get_next_sibling();  
 
   /** Get the previous sibling for this node .
-   * @returns The previous sibling, or <tt>0</tt> if the node has no previous sibling.
+   * @returns The previous sibling, or <tt>nullptr</tt> if the node has no previous sibling.
    */
   const Node* get_previous_sibling() const;  
 
   /** Get the previous sibling for this node.
-   * @returns The previous sibling, or <tt>0</tt> if the node has no previous sibling.
+   * @returns The previous sibling, or <tt>nullptr</tt> if the node has no previous sibling.
    */
   Node* get_previous_sibling();  
 
   /** Get the first child of this node.
    * You may optionally get the first child node which has a certain name.
    * @param name The name of the requested child node, or an empty string.
-   * @returns The first child, or <tt>0</tt> if no child node (with the specified name) exists.
+   * @returns The first child, or <tt>nullptr</tt> if no child node (with the specified name) exists.
    *
    * @newin{2,36}
    */
@@ -141,7 +141,7 @@ public:
   /** Get the first child of this node.
    * You may optionally get the first child node which has a certain name.
    * @param name The name of the requested child node, or an empty string.
-   * @returns The first child, or <tt>0</tt> if no child node (with the specified name) exists.
+   * @returns The first child, or <tt>nullptr</tt> if no child node (with the specified name) exists.
    *
    * @newin{2,36}
    */
@@ -233,7 +233,7 @@ public:
   /** Evaluate an XPath expression.
    * @param xpath The XPath expression.
    * @param[out] result_type Result type of the XPath expression before conversion
-   *             to boolean. If 0, the result type is not returned.
+   *             to boolean. If <tt>nullptr</tt>, the result type is not returned.
    * @returns The value of the XPath expression. If the value is not of type boolean,
    *          it is converted to boolean.
    * @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -248,7 +248,7 @@ public:
    * @param xpath The XPath expression.
    * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating.
    * @param[out] result_type Result type of the XPath expression before conversion
-   *             to boolean. If 0, the result type is not returned.
+   *             to boolean. If <tt>nullptr</tt>, the result type is not returned.
    * @returns The value of the XPath expression. If the value is not of type boolean,
    *          it is converted to boolean.
    * @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -262,7 +262,7 @@ public:
   /** Evaluate an XPath expression.
    * @param xpath The XPath expression.
    * @param[out] result_type Result type of the XPath expression before conversion
-   *             to number. If 0, the result type is not returned.
+   *             to number. If <tt>nullptr</tt>, the result type is not returned.
    * @returns The value of the XPath expression. If the value is not of type number,
    *          it is converted to number.
    * @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -276,7 +276,7 @@ public:
    * @param xpath The XPath expression.
    * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating.
    * @param[out] result_type Result type of the XPath expression before conversion
-   *             to number. If 0, the result type is not returned.
+   *             to number. If <tt>nullptr</tt>, the result type is not returned.
    * @returns The value of the XPath expression. If the value is not of type number,
    *          it is converted to number.
    * @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -290,7 +290,7 @@ public:
   /** Evaluate an XPath expression.
    * @param xpath The XPath expression.
    * @param[out] result_type Result type of the XPath expression before conversion
-   *             to string. If 0, the result type is not returned.
+   *             to string. If <tt>nullptr</tt>, the result type is not returned.
    * @returns The value of the XPath expression. If the value is not of type string,
    *          it is converted to string.
    * @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -304,7 +304,7 @@ public:
    * @param xpath The XPath expression.
    * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating.
    * @param[out] result_type Result type of the XPath expression before conversion
-   *             to string. If 0, the result type is not returned.
+   *             to string. If <tt>nullptr</tt>, the result type is not returned.
    * @returns The value of the XPath expression. If the value is not of type string,
    *          it is converted to string.
    * @throws xmlpp::exception If the XPath expression cannot be evaluated.
diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc
index 74804e3..223dd9a 100644
--- a/libxml++/parsers/textreader.cc
+++ b/libxml++/parsers/textreader.cc
@@ -38,7 +38,7 @@ TextReader::TextReader(
        size_type size,
        const Glib::ustring& uri)
        : propertyreader(new PropertyReader(*this)), 
-         impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), 0, 0) ),
+         impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), nullptr, 0) ),
     severity_( 0 )
 {
   if( ! impl_ )
@@ -407,7 +407,7 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar* value, bool free)
 {
   owner_.check_for_exceptions();
   
-  if(value == (xmlChar *)0)
+  if (!value)
     return Glib::ustring();
     
   const Glib::ustring result = (char *)value;
@@ -422,7 +422,7 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar const* value)
 {
   owner_.check_for_exceptions();
 
-  if(value == (xmlChar *)0)
+  if (!value)
     return Glib::ustring();
 
   return (const char*)value;
diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h
index 1ebd81a..15a67f0 100644
--- a/libxml++/parsers/textreader.h
+++ b/libxml++/parsers/textreader.h
@@ -94,7 +94,7 @@ class TextReader: public NonCopyable
      */
     TextReader(const unsigned char* data, size_type size, const Glib::ustring& uri = Glib::ustring());
 
-    ~TextReader();
+    ~TextReader() override;
 
     /** Moves the position of the current instance to the next node in the stream, exposing its properties.
      * @return true if the node was read successfully, false if there are no more nodes to read.
@@ -221,13 +221,13 @@ class TextReader: public NonCopyable
      * The C++ wrapper is not deleted. Using this method causes memory leaks,
      * unless you call xmlpp::Node::free_wrappers(), which is not intended to be
      * called by the application.
-     * @returns A pointer to the current node, or 0 in case of error.
+     * @returns A pointer to the current node, or <tt>nullptr</tt> in case of error.
      */
     Node* get_current_node();
 
     /** Get a pointer to the current node.
      * @warning See the non-const get_current_node().
-     * @returns A pointer to the current node, or 0 in case of error.
+     * @returns A pointer to the current node, or <tt>nullptr</tt> in case of error.
      */
     const Node* get_current_node() const;
 
@@ -239,7 +239,7 @@ class TextReader: public NonCopyable
      * @warning The C++ wrappers are not deleted. Using this method causes memory leaks,
      * unless you call xmlpp::Node::free_wrappers(), which is not intended to be
      * called by the application.
-     * @returns A pointer to the current node, or 0 in case of error.
+     * @returns A pointer to the current node, or <tt>nullptr</tt> in case of error.
      * @throws xmlpp::parse_error
      * @throws xmlpp::validity_error
      */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]