[libxml++/libxml++-2-40] More use of nullptr instead of 0
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml++/libxml++-2-40] More use of nullptr instead of 0
- Date: Thu, 8 Oct 2015 14:21:01 +0000 (UTC)
commit f213e683e565d3e93a1982874cc47261734ddacd
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Thu Oct 8 16:14:08 2015 +0200
More use of nullptr instead of 0
Bug #756166 (also the previous commit)
libxml++/document.cc | 12 ++++++------
libxml++/document.h | 8 ++++----
libxml++/nodes/element.h | 4 ++--
libxml++/nodes/node.cc | 28 ++++++++++++++--------------
libxml++/nodes/node.h | 30 +++++++++++++++---------------
libxml++/parsers/textreader.cc | 6 +++---
libxml++/parsers/textreader.h | 8 ++++----
7 files changed, 48 insertions(+), 48 deletions(-)
---
diff --git a/libxml++/document.cc b/libxml++/document.cc
index 739bbc5..a5dfb17 100644
--- a/libxml++/document.cc
+++ b/libxml++/document.cc
@@ -139,7 +139,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";
}
@@ -216,8 +216,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);
@@ -239,7 +239,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);
@@ -412,8 +412,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 eaede6c..630584f 100644
--- a/libxml++/document.h
+++ b/libxml++/document.h
@@ -70,7 +70,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);
@@ -81,7 +81,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;
@@ -99,7 +99,7 @@ public:
//See the patch here: https://bugzilla.gnome.org/show_bug.cgi?id=632522
/** 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() const;
@@ -244,7 +244,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.h b/libxml++/nodes/element.h
index 1cad9bd..7f3365a 100644
--- a/libxml++/nodes/element.h
+++ b/libxml++/nodes/element.h
@@ -60,7 +60,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.
@@ -85,7 +85,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 4cf7184..921bc5b 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -132,7 +132,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;
}
@@ -249,7 +249,7 @@ Element* Node::add_child(xmlpp::Node* previous_sibling,
const Glib::ustring& ns_prefix)
{
if (!previous_sibling)
- return 0;
+ return nullptr;
auto child = create_new_child_node(name, ns_prefix);
auto node = xmlAddNextSibling(previous_sibling->cobj(), child);
@@ -261,7 +261,7 @@ Element* Node::add_child_before(xmlpp::Node* next_sibling,
const Glib::ustring& ns_prefix)
{
if (!next_sibling)
- return 0;
+ return nullptr;
auto child = create_new_child_node(name, ns_prefix);
auto node = xmlAddPrevSibling(next_sibling->cobj(), child);
@@ -281,7 +281,7 @@ Element* Node::add_child_with_new_ns(xmlpp::Node* previous_sibling,
const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
{
if (!previous_sibling)
- return 0;
+ return nullptr;
auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix);
auto node = xmlAddNextSibling(previous_sibling->cobj(), child);
@@ -293,7 +293,7 @@ Element* Node::add_child_before_with_new_ns(xmlpp::Node* next_sibling,
const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
{
if (!next_sibling)
- return 0;
+ return nullptr;
auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix);
auto node = xmlAddPrevSibling(next_sibling->cobj(), child);
@@ -312,7 +312,7 @@ _xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ust
if(ns_prefix.empty())
{
//Retrieve default namespace if it exists
- ns = xmlSearchNs(impl_->doc, impl_, 0);
+ ns = xmlSearchNs(impl_->doc, impl_, nullptr);
}
else
{
@@ -333,12 +333,12 @@ _xmlNode* Node::create_new_child_node_with_new_ns(const Glib::ustring& name,
if (impl_->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")
@@ -385,7 +385,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.
@@ -536,7 +536,7 @@ NodeSet Node::find(const Glib::ustring& xpath,
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,
@@ -547,7 +547,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,
@@ -558,7 +558,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,
@@ -622,7 +622,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 74d0f0e..a21e7f0 100644
--- a/libxml++/nodes/node.h
+++ b/libxml++/nodes/node.h
@@ -55,7 +55,7 @@ class Node : public NonCopyable
public:
typedef std::list<Node*> NodeList;
- /** @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);
~Node() override;
@@ -93,39 +93,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}
*/
@@ -134,7 +134,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}
*/
@@ -299,7 +299,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.
@@ -314,7 +314,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.
@@ -328,7 +328,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.
@@ -342,7 +342,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.
@@ -356,7 +356,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.
@@ -370,7 +370,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 5901894..48901b2 100644
--- a/libxml++/parsers/textreader.h
+++ b/libxml++/parsers/textreader.h
@@ -94,7 +94,7 @@ class TextReader: 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: 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: 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]