Skip to content

Commit a101211

Browse files
author
Kjell Ahlstedt
committed
More use of nullptr instead of 0
Bug #756166 (also the previous commit)
1 parent a96e5fa commit a101211

File tree

8 files changed

+52
-52
lines changed

8 files changed

+52
-52
lines changed

libxml++/document.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static const char* get_encoding_or_utf8(const Glib::ustring& encoding)
138138
{
139139
if(encoding.empty())
140140
{
141-
//If we don't specify this to the xmlDocDump* functions (using 0 instead),
141+
//If we don't specify this to the xmlDocDump* functions (using nullptr instead),
142142
//then some other encoding is used, causing them to fail on non-ASCII characters.
143143
return "UTF-8";
144144
}
@@ -215,8 +215,8 @@ void Document::set_internal_subset(const Glib::ustring& name,
215215
{
216216
auto dtd = xmlCreateIntSubset(impl_,
217217
(const xmlChar*)name.c_str(),
218-
external_id.empty() ? (const xmlChar*)0 : (const xmlChar*)external_id.c_str(),
219-
system_id.empty() ? (const xmlChar*)0 : (const xmlChar*)system_id.c_str());
218+
external_id.empty() ? nullptr : (const xmlChar*)external_id.c_str(),
219+
system_id.empty() ? nullptr : (const xmlChar*)system_id.c_str());
220220

221221
if (dtd && !dtd->_private)
222222
dtd->_private = new Dtd(dtd);
@@ -243,7 +243,7 @@ Element* Document::create_root_node(const Glib::ustring& name,
243243
const Glib::ustring& ns_uri,
244244
const Glib::ustring& ns_prefix)
245245
{
246-
auto node = xmlNewDocNode(impl_, 0, (const xmlChar*)name.c_str(), 0);
246+
auto node = xmlNewDocNode(impl_, nullptr, (const xmlChar*)name.c_str(), nullptr);
247247
if (!node)
248248
throw internal_error("Could not create root element node " + name);
249249

@@ -416,8 +416,8 @@ void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType t
416416
const Glib::ustring& content)
417417
{
418418
auto entity = xmlAddDocEntity( impl_, (const xmlChar*) name.c_str(), type,
419-
publicId.empty() ? (const xmlChar*)0 : (const xmlChar*)publicId.c_str(),
420-
systemId.empty() ? (const xmlChar*)0 : (const xmlChar*)systemId.c_str(),
419+
publicId.empty() ? nullptr : (const xmlChar*)publicId.c_str(),
420+
systemId.empty() ? nullptr : (const xmlChar*)systemId.c_str(),
421421
(const xmlChar*) content.c_str() );
422422
if (!entity)
423423
throw internal_error("Could not add entity declaration " + name);

libxml++/document.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Document : public NonCopyable
8080
/** Create a new C++ wrapper for an xmlDoc struct.
8181
* The created xmlpp::Document takes ownership of the xmlDoc.
8282
* When the Document is deleted, so is the xmlDoc and all its nodes.
83-
* @param doc A pointer to an xmlDoc struct. Must not be <tt>0</tt>.
83+
* @param doc A pointer to an xmlDoc struct. Must not be <tt>nullptr</tt>.
8484
*/
8585
explicit Document(_xmlDoc* doc);
8686

@@ -91,7 +91,7 @@ class Document : public NonCopyable
9191
Glib::ustring get_encoding() const;
9292

9393
/** Get the internal subset of this document.
94-
* @returns A pointer to the DTD, or <tt>0</tt> if not found.
94+
* @returns A pointer to the DTD, or <tt>nullptr</tt> if not found.
9595
*/
9696
Dtd* get_internal_subset() const;
9797

@@ -107,13 +107,13 @@ class Document : public NonCopyable
107107

108108
/** Return the root node.
109109
* This function does @b not create a default root node if it doesn't exist.
110-
* @return A pointer to the root node if it exists, <tt>0</tt> otherwise.
110+
* @return A pointer to the root node if it exists, <tt>nullptr</tt> otherwise.
111111
*/
112112
Element* get_root_node();
113113

114114
/** Return the root node.
115115
* This function does @b not create a default root node if it doesn't exist.
116-
* @return A pointer to the root node if it exists, <tt>0</tt> otherwise.
116+
* @return A pointer to the root node if it exists, <tt>nullptr</tt> otherwise.
117117
*/
118118
const Element* get_root_node() const;
119119

@@ -257,7 +257,7 @@ class Document : public NonCopyable
257257
/** Retrieve an Entity.
258258
* The entity can be from an external subset or internally declared.
259259
* @param name The name of the entity to get.
260-
* @returns A pointer to the libxml2 entity structure, or <tt>0</tt> if not found.
260+
* @returns A pointer to the libxml2 entity structure, or <tt>nullptr</tt> if not found.
261261
*/
262262
_xmlEntity* get_entity(const Glib::ustring& name);
263263

libxml++/nodes/element.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name,
7575
// cast to an xmlAttr*, pointing to the declaration of an attribute with a
7676
// default value (XML_ATTRIBUTE_DECL).
7777
auto attr = xmlHasNsProp(const_cast<xmlNode*>(cobj()), (const xmlChar*)name.c_str(),
78-
ns_uri.empty() ? 0 : (const xmlChar*)ns_uri.c_str());
78+
ns_uri.empty() ? nullptr : (const xmlChar*)ns_uri.c_str());
7979
if (attr)
8080
{
8181
Node::create_wrapper(reinterpret_cast<xmlNode*>(attr));
@@ -216,7 +216,7 @@ _xmlNode* Element::create_new_child_element_node(const Glib::ustring& name,
216216
if (ns_prefix.empty())
217217
{
218218
//Retrieve default namespace if it exists
219-
ns = xmlSearchNs(cobj()->doc, cobj(), 0);
219+
ns = xmlSearchNs(cobj()->doc, cobj(), nullptr);
220220
}
221221
else
222222
{
@@ -235,12 +235,12 @@ _xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring
235235
if (cobj()->type != XML_ELEMENT_NODE)
236236
throw internal_error("You can only add child nodes to element nodes.");
237237

238-
auto child = xmlNewNode(0, (const xmlChar*)name.c_str());
238+
auto child = xmlNewNode(nullptr, (const xmlChar*)name.c_str());
239239
if (!child)
240240
throw internal_error("Could not create new element node.");
241241

242-
auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()),
243-
(const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
242+
auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()),
243+
(const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) );
244244
// xmlNewNs() does not create a namespace node for the predefined xml prefix.
245245
// It's usually defined in the document and not in any specific node.
246246
if (!ns && ns_prefix == "xml")
@@ -357,13 +357,13 @@ bool Element::has_child_text() const
357357
void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
358358
{
359359
//Create a new namespace declaration for this element:
360-
auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()),
361-
(const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
360+
auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()),
361+
(const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) );
362362
if (!ns)
363363
{
364364
// Not an error, if we try to assign the same uri to the prefix once again.
365365
ns = xmlSearchNs(cobj()->doc, cobj(),
366-
(const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()));
366+
(const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()));
367367
const char* const previous_href = (ns && ns->href) ? (const char*)ns->href : "";
368368
if (!ns || ns_uri != previous_href)
369369
throw exception("Could not add namespace declaration with URI=" + ns_uri +

libxml++/nodes/element.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Element : public Node
5959
/** Get the attribute with this name, and optionally with this namespace.
6060
* @param name The name of the attribute that will be retrieved.
6161
* @param ns_prefix Namespace prefix.
62-
* @return The attribute, or 0 if no suitable Attribute was found.
62+
* @return The attribute, or <tt>nullptr</tt> if no suitable Attribute was found.
6363
* Is either an AttributeNode*, pointing to an explicitly set
6464
* attribute, or an AttributeDeclaration*, pointing to the declaration
6565
* of an attribute with a default value.
@@ -70,7 +70,7 @@ class Element : public Node
7070
/** Get the attribute with this name, and optionally with this namespace.
7171
* @param name The name of the attribute that will be retrieved.
7272
* @param ns_prefix Namespace prefix.
73-
* @return The attribute, or 0 if no suitable Attribute was found.
73+
* @return The attribute, or <tt>nullptr</tt> if no suitable Attribute was found.
7474
* Is either an AttributeNode*, pointing to an explicitly set
7575
* attribute, or an AttributeDeclaration*, pointing to the declaration
7676
* of an attribute with a default value.
@@ -95,7 +95,7 @@ class Element : public Node
9595
* @param name The name of the attribute whose value will change.
9696
* @param value The new value for the attribute
9797
* @param ns_prefix Namespace prefix. If the prefix has not been declared then this method will throw an exception.
98-
* @return The attribute that was changed, or 0 is no suitable Attribute was found.
98+
* @return The attribute that was changed, or <tt>nullptr</tt> is no suitable Attribute was found.
9999
* @throws xmlpp::exception
100100
*/
101101
Attribute* set_attribute(const Glib::ustring& name, const Glib::ustring& value,

libxml++/nodes/node.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Node::Node(xmlNode* node)
222222
: impl_(node)
223223
{
224224
if (!impl_)
225-
throw internal_error("xmlNode pointer cannot be 0");
225+
throw internal_error("xmlNode pointer cannot be nullptr");
226226

227227
impl_->_private = this;
228228
}
@@ -332,7 +332,7 @@ Node* Node::import_node(const Node* node, bool recursive)
332332
if (imported_node->type == XML_ATTRIBUTE_NODE && impl_->type == XML_ELEMENT_NODE)
333333
{
334334
auto old_attr = xmlHasNsProp(impl_, imported_node->name,
335-
imported_node->ns ? imported_node->ns->href : 0);
335+
imported_node->ns ? imported_node->ns->href : nullptr);
336336
if (old_attr && old_attr->type != XML_ATTRIBUTE_DECL)
337337
{
338338
// *this has an attribute with the same name as the imported attribute.
@@ -396,12 +396,12 @@ Glib::ustring Node::get_path() const
396396

397397
Node::NodeSet Node::find(const Glib::ustring& xpath)
398398
{
399-
return find_common<NodeSet>(xpath, 0, impl_);
399+
return find_common<NodeSet>(xpath, nullptr, impl_);
400400
}
401401

402402
Node::const_NodeSet Node::find(const Glib::ustring& xpath) const
403403
{
404-
return find_common<const_NodeSet>(xpath, 0, impl_);
404+
return find_common<const_NodeSet>(xpath, nullptr, impl_);
405405
}
406406

407407
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
416416

417417
bool Node::eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type) const
418418
{
419-
return eval_common_to_boolean(xpath, 0, result_type, impl_);
419+
return eval_common_to_boolean(xpath, nullptr, result_type, impl_);
420420
}
421421

422422
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
427427

428428
double Node::eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type) const
429429
{
430-
return eval_common_to_number(xpath, 0, result_type, impl_);
430+
return eval_common_to_number(xpath, nullptr, result_type, impl_);
431431
}
432432

433433
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
438438

439439
Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type) const
440440
{
441-
return eval_common_to_string(xpath, 0, result_type, impl_);
441+
return eval_common_to_string(xpath, nullptr, result_type, impl_);
442442
}
443443

444444
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)
502502
}
503503

504504
//Look for the existing namespace to use:
505-
auto ns = xmlSearchNs( cobj()->doc, cobj(), (xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
505+
auto ns = xmlSearchNs( cobj()->doc, cobj(), (xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) );
506506
if(ns)
507507
{
508508
//Use it for this element:

libxml++/nodes/node.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Node : public NonCopyable
5757
typedef std::vector<Node*> NodeSet;
5858
typedef std::vector<const Node*> const_NodeSet;
5959

60-
/** @throws xmlpp::internal_error If @a node is <tt>0</tt>.
60+
/** @throws xmlpp::internal_error If @a node is <tt>nullptr</tt>.
6161
*/
6262
explicit Node(_xmlNode* node);
6363

@@ -100,39 +100,39 @@ class Node : public NonCopyable
100100
int get_line() const;
101101

102102
/** Get the parent element for this node.
103-
* @returns The parent node, or <tt>0</tt> if the node has no parent element.
103+
* @returns The parent node, or <tt>nullptr</tt> if the node has no parent element.
104104
*/
105105
const Element* get_parent() const;
106106

107107
/** Get the parent element for this node.
108-
* @returns The parent node, or <tt>0</tt> if the node has no parent element.
108+
* @returns The parent node, or <tt>nullptr</tt> if the node has no parent element.
109109
*/
110110
Element* get_parent();
111111

112112
/** Get the next sibling for this node.
113-
* @returns The next sibling, or <tt>0</tt> if the node has no next sibling.
113+
* @returns The next sibling, or <tt>nullptr</tt> if the node has no next sibling.
114114
*/
115115
const Node* get_next_sibling() const;
116116

117117
/** Get the next sibling for this node.
118-
* @returns The next sibling, or <tt>0</tt> if the node has no next sibling.
118+
* @returns The next sibling, or <tt>nullptr</tt> if the node has no next sibling.
119119
*/
120120
Node* get_next_sibling();
121121

122122
/** Get the previous sibling for this node .
123-
* @returns The previous sibling, or <tt>0</tt> if the node has no previous sibling.
123+
* @returns The previous sibling, or <tt>nullptr</tt> if the node has no previous sibling.
124124
*/
125125
const Node* get_previous_sibling() const;
126126

127127
/** Get the previous sibling for this node.
128-
* @returns The previous sibling, or <tt>0</tt> if the node has no previous sibling.
128+
* @returns The previous sibling, or <tt>nullptr</tt> if the node has no previous sibling.
129129
*/
130130
Node* get_previous_sibling();
131131

132132
/** Get the first child of this node.
133133
* You may optionally get the first child node which has a certain name.
134134
* @param name The name of the requested child node, or an empty string.
135-
* @returns The first child, or <tt>0</tt> if no child node (with the specified name) exists.
135+
* @returns The first child, or <tt>nullptr</tt> if no child node (with the specified name) exists.
136136
*
137137
* @newin{2,36}
138138
*/
@@ -141,7 +141,7 @@ class Node : public NonCopyable
141141
/** Get the first child of this node.
142142
* You may optionally get the first child node which has a certain name.
143143
* @param name The name of the requested child node, or an empty string.
144-
* @returns The first child, or <tt>0</tt> if no child node (with the specified name) exists.
144+
* @returns The first child, or <tt>nullptr</tt> if no child node (with the specified name) exists.
145145
*
146146
* @newin{2,36}
147147
*/
@@ -233,7 +233,7 @@ class Node : public NonCopyable
233233
/** Evaluate an XPath expression.
234234
* @param xpath The XPath expression.
235235
* @param[out] result_type Result type of the XPath expression before conversion
236-
* to boolean. If 0, the result type is not returned.
236+
* to boolean. If <tt>nullptr</tt>, the result type is not returned.
237237
* @returns The value of the XPath expression. If the value is not of type boolean,
238238
* it is converted to boolean.
239239
* @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -248,7 +248,7 @@ class Node : public NonCopyable
248248
* @param xpath The XPath expression.
249249
* @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating.
250250
* @param[out] result_type Result type of the XPath expression before conversion
251-
* to boolean. If 0, the result type is not returned.
251+
* to boolean. If <tt>nullptr</tt>, the result type is not returned.
252252
* @returns The value of the XPath expression. If the value is not of type boolean,
253253
* it is converted to boolean.
254254
* @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -262,7 +262,7 @@ class Node : public NonCopyable
262262
/** Evaluate an XPath expression.
263263
* @param xpath The XPath expression.
264264
* @param[out] result_type Result type of the XPath expression before conversion
265-
* to number. If 0, the result type is not returned.
265+
* to number. If <tt>nullptr</tt>, the result type is not returned.
266266
* @returns The value of the XPath expression. If the value is not of type number,
267267
* it is converted to number.
268268
* @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -276,7 +276,7 @@ class Node : public NonCopyable
276276
* @param xpath The XPath expression.
277277
* @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating.
278278
* @param[out] result_type Result type of the XPath expression before conversion
279-
* to number. If 0, the result type is not returned.
279+
* to number. If <tt>nullptr</tt>, the result type is not returned.
280280
* @returns The value of the XPath expression. If the value is not of type number,
281281
* it is converted to number.
282282
* @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -290,7 +290,7 @@ class Node : public NonCopyable
290290
/** Evaluate an XPath expression.
291291
* @param xpath The XPath expression.
292292
* @param[out] result_type Result type of the XPath expression before conversion
293-
* to string. If 0, the result type is not returned.
293+
* to string. If <tt>nullptr</tt>, the result type is not returned.
294294
* @returns The value of the XPath expression. If the value is not of type string,
295295
* it is converted to string.
296296
* @throws xmlpp::exception If the XPath expression cannot be evaluated.
@@ -304,7 +304,7 @@ class Node : public NonCopyable
304304
* @param xpath The XPath expression.
305305
* @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating.
306306
* @param[out] result_type Result type of the XPath expression before conversion
307-
* to string. If 0, the result type is not returned.
307+
* to string. If <tt>nullptr</tt>, the result type is not returned.
308308
* @returns The value of the XPath expression. If the value is not of type string,
309309
* it is converted to string.
310310
* @throws xmlpp::exception If the XPath expression cannot be evaluated.

libxml++/parsers/textreader.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TextReader::TextReader(
3838
size_type size,
3939
const Glib::ustring& uri)
4040
: propertyreader(new PropertyReader(*this)),
41-
impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), 0, 0) ),
41+
impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), nullptr, 0) ),
4242
severity_( 0 )
4343
{
4444
if( ! impl_ )
@@ -407,7 +407,7 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar* value, bool free)
407407
{
408408
owner_.check_for_exceptions();
409409

410-
if(value == (xmlChar *)0)
410+
if (!value)
411411
return Glib::ustring();
412412

413413
const Glib::ustring result = (char *)value;
@@ -422,7 +422,7 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar const* value)
422422
{
423423
owner_.check_for_exceptions();
424424

425-
if(value == (xmlChar *)0)
425+
if (!value)
426426
return Glib::ustring();
427427

428428
return (const char*)value;

0 commit comments

Comments
 (0)