Commit 0da5c841 authored by Murray Cumming's avatar Murray Cumming

C++11: Use nullptr instead of 0.

parent ef56aa25
......@@ -72,7 +72,7 @@ class TestNamespace : public Tests
TestNamespace::TestNamespace()
:
root_(0)
root_(nullptr)
{
nsmap_["ns0"] = "http://default.namespace/root";
nsmap_["ns1"] = "http://default.namespace/child";
......
......@@ -43,7 +43,7 @@ int main (int /* argc */, char** /* argv */)
Element* first_child2 = dynamic_cast<Element*>(child_list2.front());
if (!first_child2)
{
cerr << "first_child2 == 0" << endl;
cerr << "first_child2 == nullptr" << endl;
return EXIT_FAILURE;
}
TextNode* text_to_add = first_child2->get_child_text();
......
......@@ -59,9 +59,9 @@ void Parser::on_start_element(const Glib::ustring& name,
elementName = name.substr(idx + 1);
}
xmlpp::Element* element_normal = 0;
xmlpp::Element* element_normal = nullptr;
// Create a normal libxml++ node:
if (m_doc.get_root_node() == 0)
if (m_doc.get_root_node() == nullptr)
{
// Create the root node if necessary:
element_normal = m_doc.create_root_node(elementName);
......@@ -80,7 +80,7 @@ void Parser::on_start_element(const Glib::ustring& name,
// node with the derived Element object we create below.
xmlNode* node = element_normal->cobj(); //Save it for later.
delete element_normal;
element_normal = 0;
element_normal = nullptr;
// TODO: Again, this requires knowledge of the libxml++ implemenation -
// specifically that the base xmlpp::Node() constructor will reassociate
......@@ -90,7 +90,7 @@ void Parser::on_start_element(const Glib::ustring& name,
// This will then be deleted by libxml++, just as libxml++ would normally have
// deleted its own node.
// TODO: Don't delete the original (above) if it isn't one of these node names.
xmlpp::Element* element_derived = 0;
xmlpp::Element* element_derived = nullptr;
if (elementName == "g")
element_derived = new SVG::Group(node);
else if (elementName == "path")
......
......@@ -37,7 +37,7 @@ Glib::ustring Attribute::get_value() const
return attributeDecl->get_value();
// AttributeNode
xmlChar* value = 0;
xmlChar* value = nullptr;
if (cobj()->ns && cobj()->ns->href)
value = xmlGetNsProp(cobj()->parent, cobj()->name, cobj()->ns->href);
else
......
......@@ -118,7 +118,7 @@ void remove_found_wrappers(xmlNode* node, NodeMap& node_map)
if (iter->second == node->type)
node_map.erase(iter);
else
node->_private = 0; // node->type has changed. The wrapper will be deleted.
node->_private = nullptr; // node->type has changed. The wrapper will be deleted.
}
}
......@@ -226,7 +226,7 @@ void Document::set_internal_subset(const Glib::ustring& name,
Element* Document::get_root_node() const
{
xmlNode* root = xmlDocGetRootElement(impl_);
if(root == 0)
if(root == nullptr)
return 0;
else
{
......@@ -368,7 +368,7 @@ Glib::ustring Document::do_write_to_string(
{
KeepBlanks k(KeepBlanks::Default);
xmlIndentTreeOutput = format?1:0;
xmlChar* buffer = 0;
xmlChar* buffer = nullptr;
int length = 0;
xmlResetLastError();
......
......@@ -87,7 +87,7 @@ Glib::ustring format_xml_error(const _xmlError* error)
Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context)
{
if (!parser_context)
return "Error. xmlpp::format_xml_parser_error() called with parser_context == 0\n";
return "Error. xmlpp::format_xml_parser_error() called with parser_context == nullptr\n";
const _xmlError* error = xmlCtxtGetLastError(const_cast<_xmlParserCtxt*>(parser_context));
......
......@@ -62,7 +62,7 @@ private:
* @returns A formatted text string. If the error struct does not contain an
* error (error->code == XML_ERR_OK), an empty string is returned.
*/
Glib::ustring format_xml_error(const _xmlError* error = 0);
Glib::ustring format_xml_error(const _xmlError* error = nullptr);
/** Format a parser error into a text string, suitable for printing.
*
......
......@@ -38,7 +38,7 @@ namespace xmlpp
// The code is almost cut/paste from xmlSaveFormatFileEnc
// TODO wrap the handler ? I don't think so but...
xmlCharEncodingHandlerPtr handler = 0;
xmlCharEncodingHandlerPtr handler = nullptr;
if( ! encoding.empty() )
{
xmlCharEncoding enc = xmlParseCharEncoding(encoding.c_str());
......@@ -49,7 +49,7 @@ namespace xmlpp
if( enc != XML_CHAR_ENCODING_UTF8 )
{
handler = xmlFindCharEncodingHandler(encoding.c_str());
if(handler == 0)
if(handler == nullptr)
{
throw internal_error("Cannot initialise an encoder to " + encoding);
}
......@@ -61,7 +61,7 @@ namespace xmlpp
&OutputBufferCallback::on_close,
static_cast<void*>(this),
handler);
if(impl_ == 0)
if(impl_ == nullptr)
{
throw internal_error("Cannot initialise underlying xmlOutputBuffer");
}
......@@ -76,7 +76,7 @@ namespace xmlpp
bool result = do_close();
// the underlying structure is being freed by libxml, the pointer will soon be
// invalid.
impl_ = 0;
impl_ = nullptr;
return result;
}
......
......@@ -74,7 +74,7 @@ Glib::ustring Element::get_attribute_value(const Glib::ustring& name, const Glib
Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring& value,
const Glib::ustring& ns_prefix)
{
xmlAttr* attr = 0;
xmlAttr* attr = nullptr;
//Ignore the namespace if none was specified:
if(ns_prefix.empty())
......@@ -218,7 +218,7 @@ TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib::
bool Element::has_child_text() const
{
return get_child_text() != 0;
return get_child_text() != nullptr;
}
void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
......@@ -300,7 +300,7 @@ EntityReference* Element::add_child_entity_reference(const Glib::ustring& name)
// Is it an entity reference or a character reference?
// libxml uses xmlNode::type == XML_ENTITY_REF_NODE for both.
xmlNode* child = 0;
xmlNode* child = nullptr;
if (extended_name[ichar] == '#')
child = xmlNewCharRef(cobj()->doc, (const xmlChar*)name.c_str());
else
......
......@@ -184,7 +184,7 @@ Node* Node::get_previous_sibling()
static Node* _convert_node(xmlNode* node)
{
Node* res = 0;
Node* res = nullptr;
if(node)
{
Node::create_wrapper(node);
......@@ -302,7 +302,7 @@ Element* Node::add_child_before_with_new_ns(xmlpp::Node* next_sibling,
_xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix)
{
xmlNs* ns = 0;
xmlNs* ns = nullptr;
if(impl_->type != XML_ELEMENT_NODE)
{
......@@ -345,7 +345,7 @@ _xmlNode* Node::create_new_child_node_with_new_ns(const Glib::ustring& name,
{
ns = xmlSearchNs(impl_->doc, impl_, (const xmlChar*)ns_prefix.c_str());
if (ns && (ns_uri != (ns->href ? (const char*)ns->href : "")))
ns = 0;
ns = nullptr;
}
if (!ns)
{
......@@ -749,21 +749,21 @@ void Node::free_wrappers(xmlNode* node)
//Node types that have no properties
case XML_DTD_NODE:
delete static_cast<Dtd*>(node->_private);
node->_private = 0;
node->_private = nullptr;
return;
case XML_ATTRIBUTE_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
delete static_cast<Node*>(node->_private);
node->_private = 0;
node->_private = nullptr;
return;
case XML_DOCUMENT_NODE:
//Do not free now. The Document is usually the one who owns the caller.
return;
default:
delete static_cast<Node*>(node->_private);
node->_private = 0;
node->_private = nullptr;
break;
}
......
......@@ -307,7 +307,7 @@ public:
*
* @newin{2,36}
*/
bool eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type = 0) const;
bool eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type = nullptr) const;
/** Evaluate an XPath expression.
......@@ -323,7 +323,7 @@ public:
* @newin{2,36}
*/
bool eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namespaces,
XPathResultType* result_type = 0) const;
XPathResultType* result_type = nullptr) const;
/** Evaluate an XPath expression.
* @param xpath The XPath expression.
......@@ -336,7 +336,7 @@ public:
*
* @newin{2,36}
*/
double eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type = 0) const;
double eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type = nullptr) const;
/** Evaluate an XPath expression.
* @param xpath The XPath expression.
......@@ -351,7 +351,7 @@ public:
* @newin{2,36}
*/
double eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& namespaces,
XPathResultType* result_type = 0) const;
XPathResultType* result_type = nullptr) const;
/** Evaluate an XPath expression.
* @param xpath The XPath expression.
......@@ -364,7 +364,7 @@ public:
*
* @newin{2,36}
*/
Glib::ustring eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type = 0) const;
Glib::ustring eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type = nullptr) const;
/** Evaluate an XPath expression.
* @param xpath The XPath expression.
......@@ -379,7 +379,7 @@ public:
* @newin{2,36}
*/
Glib::ustring eval_to_string(const Glib::ustring& xpath, const PrefixNsMap& namespaces,
XPathResultType* result_type = 0) const;
XPathResultType* result_type = nullptr) const;
///Access the underlying libxml implementation.
_xmlNode* cobj();
......
......@@ -20,14 +20,14 @@ namespace xmlpp
{
DomParser::DomParser()
: doc_(0)
: doc_(nullptr)
{
//Start with an empty document:
doc_ = new Document();
}
DomParser::DomParser(const Glib::ustring& filename, bool validate)
: doc_(0)
: doc_(nullptr)
{
set_validate(validate);
parse_file(filename);
......@@ -53,7 +53,7 @@ void DomParser::parse_file(const Glib::ustring& filename)
throw internal_error("Could not create parser context\n" + format_xml_error());
}
if(context_->directory == 0)
if(context_->directory == nullptr)
{
context_->directory = xmlParserGetDirectory(filename.c_str());
}
......@@ -123,7 +123,7 @@ void DomParser::parse_context()
doc_ = new Document(context_->myDoc);
// This is to indicate to release_underlying that we took the
// ownership on the doc.
context_->myDoc = 0;
context_->myDoc = nullptr;
//Free the parse context, but keep the document alive so people can navigate the DOM tree:
//TODO: Why not keep the context alive too?
......@@ -196,7 +196,7 @@ void DomParser::parse_stream(std::istream& in)
doc_ = new Document(context_->myDoc);
// This is to indicate to release_underlying that we took the
// ownership on the doc.
context_->myDoc = 0;
context_->myDoc = nullptr;
//Free the parse context, but keep the document alive so people can navigate the DOM tree:
......@@ -209,7 +209,7 @@ void DomParser::release_underlying()
if(doc_)
{
delete doc_;
doc_ = 0;
doc_ = nullptr;
}
Parser::release_underlying();
......@@ -217,7 +217,7 @@ void DomParser::release_underlying()
DomParser::operator bool() const
{
return doc_ != 0;
return doc_ != nullptr;
}
Document* DomParser::get_document()
......
......@@ -61,7 +61,7 @@ void on_parser_warning(const xmlpp::Parser* parser, const Glib::ustring& message
namespace xmlpp {
Parser::Parser()
: context_(0), exception_(0), validate_(false), substitute_entities_(false) //See doxygen comment on set_substiute_entities().
: context_(nullptr), exception_(nullptr), validate_(false), substitute_entities_(false) //See doxygen comment on set_substiute_entities().
{
}
......@@ -201,15 +201,15 @@ void Parser::release_underlying()
{
if(context_)
{
context_->_private = 0; //Not really necessary.
context_->_private = nullptr; //Not really necessary.
if( context_->myDoc != 0 )
if( context_->myDoc != nullptr )
{
xmlFreeDoc(context_->myDoc);
}
xmlFreeParserCtxt(context_);
context_ = 0;
context_ = nullptr;
}
}
......@@ -372,7 +372,7 @@ void Parser::check_for_exception()
if(exception_)
{
std::auto_ptr<exception> tmp ( exception_ );
exception_ = 0;
exception_ = nullptr;
tmp->Raise();
}
}
......
......@@ -374,7 +374,7 @@ xmlEntityPtr SaxParserCallback::get_entity(void* context, const xmlChar* name)
{
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
xmlEntityPtr result = 0;
xmlEntityPtr result = nullptr;
try
{
......
......@@ -346,8 +346,8 @@ bool TextReader::is_valid() const
void TextReader::setup_exceptions()
{
xmlTextReaderErrorFunc func = 0;
void* arg = 0;
xmlTextReaderErrorFunc func = nullptr;
void* arg = nullptr;
// We respect any other error handlers already setup:
xmlTextReaderGetErrorHandler(impl_, &func, &arg);
......
......@@ -44,7 +44,7 @@ namespace xmlpp
struct RelaxNGSchema::Impl
{
Impl() : schema(0) {}
Impl() : schema(nullptr) {}
_xmlRelaxNG* schema;
};
......@@ -127,7 +127,7 @@ void RelaxNGSchema::release_underlying()
if (pimpl_->schema)
{
xmlRelaxNGFree(pimpl_->schema);
pimpl_->schema = 0;
pimpl_->schema = nullptr;
}
}
......
......@@ -25,7 +25,7 @@ Schema::Schema(_xmlSchema* schema)
}
Schema::Schema(Document* document, bool embed)
: impl_(0)
: impl_(nullptr)
, embedded_doc_(false)
{
set_document(document, embed);
......@@ -97,7 +97,7 @@ void Schema::release_underlying()
if(impl_)
{
xmlSchemaFree(impl_);
impl_ = 0;
impl_ = nullptr;
}
}
......
......@@ -22,18 +22,18 @@ namespace xmlpp
{
DtdValidator::DtdValidator()
: dtd_(0)
: dtd_(nullptr)
{
}
DtdValidator::DtdValidator(const Glib::ustring& file)
: dtd_(0)
: dtd_(nullptr)
{
parse_subset("",file);
}
DtdValidator::DtdValidator(const Glib::ustring& external,const Glib::ustring& system)
: dtd_(0)
: dtd_(nullptr)
{
parse_subset(external,system);
}
......@@ -102,13 +102,13 @@ void DtdValidator::release_underlying()
xmlDtd* dtd = dtd_->cobj();
Node::free_wrappers(reinterpret_cast<xmlNode*>(dtd));
xmlFreeDtd(dtd);
dtd_ = 0;
dtd_ = nullptr;
}
}
DtdValidator::operator bool() const
{
return dtd_ != 0;
return dtd_ != nullptr;
}
Dtd* DtdValidator::get_dtd()
......
......@@ -29,7 +29,7 @@ namespace xmlpp
struct RelaxNGValidator::Impl
{
Impl() : schema(0), is_schema_owner(false), context(0) {}
Impl() : schema(nullptr), is_schema_owner(false), context(nullptr) {}
RelaxNGSchema* schema;
bool is_schema_owner;
......@@ -94,14 +94,14 @@ void RelaxNGValidator::release_underlying()
if (pimpl_->context)
{
xmlRelaxNGFreeValidCtxt(pimpl_->context);
pimpl_->context = 0;
pimpl_->context = nullptr;
}
if (pimpl_->schema)
{
if (pimpl_->is_schema_owner)
delete pimpl_->schema;
pimpl_->schema = 0;
pimpl_->schema = nullptr;
}
SchemaValidatorBase::release_underlying();
......
......@@ -38,24 +38,24 @@ namespace xmlpp
{
SchemaValidator::SchemaValidator()
: schema_(0)
: schema_(nullptr)
, embbeded_shema_(false)
, ctxt_(0)
, ctxt_(nullptr)
{
}
SchemaValidator::SchemaValidator(const Glib::ustring& file)
: schema_(0)
: schema_(nullptr)
, embbeded_shema_(false)
, ctxt_(0)
, ctxt_(nullptr)
{
parse_file( file );
}
SchemaValidator::SchemaValidator(Document& document)
: schema_(0)
: schema_(nullptr)
, embbeded_shema_(false)
, ctxt_(0)
, ctxt_(nullptr)
{
parse_document( document );
}
......@@ -63,7 +63,7 @@ SchemaValidator::SchemaValidator(Document& document)
SchemaValidator::SchemaValidator(Schema* schema)
: schema_(schema)
, embbeded_shema_(false)
, ctxt_(0)
, ctxt_(nullptr)
{
}
......@@ -126,19 +126,19 @@ void SchemaValidator::release_underlying()
if(ctxt_)
{
xmlSchemaFreeValidCtxt( ctxt_ );
ctxt_ = 0;
ctxt_ = nullptr;
}
if(schema_)
{
if(embbeded_shema_)
delete schema_;
schema_ = 0;
schema_ = nullptr;
}
}
SchemaValidator::operator bool() const
{
return schema_ != 0;
return schema_ != nullptr;
}
Schema* SchemaValidator::get_schema()
......
......@@ -15,7 +15,7 @@
namespace xmlpp {
Validator::Validator()
: valid_(0), exception_(0)
: valid_(nullptr), exception_(nullptr)
{
}
......@@ -47,10 +47,10 @@ void Validator::release_underlying()
{
if(valid_)
{
valid_->userData = 0; //Not really necessary.
valid_->userData = nullptr; //Not really necessary.
xmlFreeValidCtxt(valid_);
valid_ = 0;
valid_ = nullptr;
}
}
......@@ -166,7 +166,7 @@ void Validator::check_for_exception()
if(exception_)
{
std::auto_ptr<exception> tmp(exception_);
exception_ = 0;
exception_ = nullptr;
tmp->Raise();
}
}
......
......@@ -26,7 +26,7 @@ namespace xmlpp
struct XsdValidator::Impl
{
Impl() : schema(0), is_schema_owner(false), context(0) {}
Impl() : schema(nullptr), is_schema_owner(false), context(nullptr) {}
XsdSchema* schema;
bool is_schema_owner;
......@@ -91,14 +91,14 @@ void XsdValidator::release_underlying()
if (pimpl_->context)
{
xmlSchemaFreeValidCtxt(pimpl_->context);
pimpl_->context = 0;
pimpl_->context = nullptr;
}
if (pimpl_->schema)
{
if (pimpl_->is_schema_owner)
delete pimpl_->schema;
pimpl_->schema = 0;
pimpl_->schema = nullptr;
}
SchemaValidatorBase::release_underlying();
......
......@@ -42,7 +42,7 @@ namespace xmlpp
struct XsdSchema::Impl
{
Impl() : schema(0), document(0) {}
Impl() : schema(nullptr), document(nullptr) {}
_xmlSchema* schema;
_xmlDoc* document;
......@@ -137,13 +137,13 @@ void XsdSchema::release_underlying()
if (pimpl_->schema)
{
xmlSchemaFree(pimpl_->schema);
pimpl_->schema = 0;
pimpl_->schema = nullptr;
}
if (pimpl_->document)
{
xmlFreeDoc(pimpl_->document);
pimpl_->document = 0;
pimpl_->document = nullptr;
}
}
......
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