From ce9c08a2d82bcebaadbca1aafedce95e656d2b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Thu, 26 Sep 2024 09:14:44 +0200 Subject: [PATCH] chore(XML): modernization: use nullptr instead of 0 --- XML/src/AbstractContainerNode.cpp | 36 +++++++++++++++--------------- XML/src/DOMBuilder.cpp | 22 +++++++++--------- XML/src/Element.cpp | 10 ++++----- XML/src/EventDispatcher.cpp | 2 +- XML/src/NodeAppender.cpp | 2 +- XML/src/NodeIterator.cpp | 6 ++--- XML/src/ParserEngine.cpp | 6 ++--- XML/src/TreeWalker.cpp | 2 +- XML/testsuite/src/NamePoolTest.cpp | 2 +- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/XML/src/AbstractContainerNode.cpp b/XML/src/AbstractContainerNode.cpp index 29b5b6a50..9232b83d9 100644 --- a/XML/src/AbstractContainerNode.cpp +++ b/XML/src/AbstractContainerNode.cpp @@ -51,8 +51,8 @@ AbstractContainerNode::~AbstractContainerNode() { AbstractNode* pDelNode = pChild; pChild = pChild->_pNext; - pDelNode->_pNext = 0; - pDelNode->_pParent = 0; + pDelNode->_pNext = nullptr; + pDelNode->_pParent = nullptr; pDelNode->release(); } } @@ -89,8 +89,8 @@ Node* AbstractContainerNode::insertBefore(Node* newChild, Node* refChild) if (this == newChild) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR); - AbstractNode* pFirst = 0; - AbstractNode* pLast = 0; + AbstractNode* pFirst = nullptr; + AbstractNode* pLast = nullptr; if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE) { AbstractContainerNode* pFrag = static_cast(newChild); @@ -105,7 +105,7 @@ Node* AbstractContainerNode::insertBefore(Node* newChild, Node* refChild) } pLast->_pParent = this; } - pFrag->_pFirstChild = 0; + pFrag->_pFirstChild = nullptr; } else { @@ -165,8 +165,8 @@ Node* AbstractContainerNode::insertAfterNP(Node* newChild, Node* refChild) if (this == newChild) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR); - AbstractNode* pFirst = 0; - AbstractNode* pLast = 0; + AbstractNode* pFirst = nullptr; + AbstractNode* pLast = nullptr; if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE) { AbstractContainerNode* pFrag = static_cast(newChild); @@ -181,7 +181,7 @@ Node* AbstractContainerNode::insertAfterNP(Node* newChild, Node* refChild) } pLast->_pParent = this; } - pFrag->_pFirstChild = 0; + pFrag->_pFirstChild = nullptr; } else { @@ -259,8 +259,8 @@ Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild) } static_cast(newChild)->_pNext = static_cast(oldChild)->_pNext; static_cast(newChild)->_pParent = this; - _pFirstChild->_pNext = 0; - _pFirstChild->_pParent = 0; + _pFirstChild->_pNext = nullptr; + _pFirstChild->_pParent = nullptr; _pFirstChild = static_cast(newChild); if (doEvents) { @@ -283,8 +283,8 @@ Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild) } static_cast(newChild)->_pNext = static_cast(oldChild)->_pNext; static_cast(newChild)->_pParent = this; - static_cast(oldChild)->_pNext = 0; - static_cast(oldChild)->_pParent = 0; + static_cast(oldChild)->_pNext = nullptr; + static_cast(oldChild)->_pParent = nullptr; pCur->_pNext = static_cast(newChild); if (doEvents) { @@ -315,8 +315,8 @@ Node* AbstractContainerNode::removeChild(Node* oldChild) static_cast(oldChild)->dispatchNodeRemovedFromDocument(); } _pFirstChild = _pFirstChild->_pNext; - static_cast(oldChild)->_pNext = 0; - static_cast(oldChild)->_pParent = 0; + static_cast(oldChild)->_pNext = nullptr; + static_cast(oldChild)->_pParent = nullptr; } else { @@ -330,8 +330,8 @@ Node* AbstractContainerNode::removeChild(Node* oldChild) static_cast(oldChild)->dispatchNodeRemovedFromDocument(); } pCur->_pNext = pCur->_pNext->_pNext; - static_cast(oldChild)->_pNext = 0; - static_cast(oldChild)->_pParent = 0; + static_cast(oldChild)->_pNext = nullptr; + static_cast(oldChild)->_pParent = nullptr; } else throw DOMException(DOMException::NOT_FOUND_ERR); } @@ -373,7 +373,7 @@ void AbstractContainerNode::dispatchNodeInsertedIntoDocument() bool AbstractContainerNode::hasChildNodes() const { - return _pFirstChild != 0; + return _pFirstChild != nullptr; } @@ -516,7 +516,7 @@ const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const while (it != end && *it != '/' && *it != '[') key += *it++; XMLString::const_iterator itStart(it); - const Node* pFound = 0; + const Node* pFound = nullptr; const Node* pElem = findElement(key, pNode->firstChild(), pNSMap); while (!pFound && pElem) { diff --git a/XML/src/DOMBuilder.cpp b/XML/src/DOMBuilder.cpp index 4074ea59c..846e810d3 100644 --- a/XML/src/DOMBuilder.cpp +++ b/XML/src/DOMBuilder.cpp @@ -74,9 +74,9 @@ Document* DOMBuilder::parse(const XMLString& uri) catch (...) { _pDocument->release(); - _pDocument = 0; - _pParent = 0; - _pPrevious = 0; + _pDocument = nullptr; + _pParent = nullptr; + _pPrevious = nullptr; throw; } _pDocument->resumeEvents(); @@ -96,9 +96,9 @@ Document* DOMBuilder::parse(InputSource* pInputSource) catch (...) { _pDocument->release(); - _pDocument = 0; - _pParent = 0; - _pPrevious = 0; + _pDocument = nullptr; + _pParent = nullptr; + _pPrevious = nullptr; throw; } _pDocument->resumeEvents(); @@ -118,9 +118,9 @@ Document* DOMBuilder::parseMemoryNP(const char* xml, std::size_t size) catch (...) { _pDocument->release(); - _pDocument = 0; - _pParent = 0; - _pPrevious = 0; + _pDocument = nullptr; + _pParent = nullptr; + _pPrevious = nullptr; throw; } _pDocument->resumeEvents(); @@ -133,7 +133,7 @@ void DOMBuilder::setupParse() { _pDocument = new Document(_pNamePool); _pParent = _pDocument; - _pPrevious = 0; + _pPrevious = nullptr; _inCDATA = false; _namespaces = _xmlReader.getFeature(XMLReader::FEATURE_NAMESPACES); } @@ -197,7 +197,7 @@ void DOMBuilder::startElement(const XMLString& uri, const XMLString& localName, AutoPtr pElem = _namespaces ? _pDocument->createElementNS(uri, qname.empty() ? localName : qname) : _pDocument->createElement(qname); const AttributesImpl& attrs = dynamic_cast(attributes); - Attr* pPrevAttr = 0; + Attr* pPrevAttr = nullptr; for (const auto& attr: attrs) { AutoPtr pAttr = new Attr(_pDocument, 0, attr.namespaceURI, attr.localName, attr.qname, attr.value, attr.specified); diff --git a/XML/src/Element.cpp b/XML/src/Element.cpp index 056466e3c..1485bed07 100644 --- a/XML/src/Element.cpp +++ b/XML/src/Element.cpp @@ -143,8 +143,8 @@ Attr* Element::removeAttributeNode(Attr* oldAttr) else throw DOMException(DOMException::NOT_FOUND_ERR); } else _pFirstAttr = static_cast(_pFirstAttr->_pNext); - oldAttr->_pNext = 0; - oldAttr->_pParent = 0; + oldAttr->_pNext = nullptr; + oldAttr->_pParent = nullptr; oldAttr->autoRelease(); return oldAttr; @@ -298,13 +298,13 @@ Attr* Element::setAttributeNodeNS(Attr* newAttr) bool Element::hasAttribute(const XMLString& name) const { - return getAttributeNode(name) != 0; + return getAttributeNode(name) != nullptr; } bool Element::hasAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const { - return getAttributeNodeNS(namespaceURI, localName) != 0; + return getAttributeNodeNS(namespaceURI, localName) != nullptr; } @@ -328,7 +328,7 @@ const XMLString& Element::localName() const bool Element::hasAttributes() const { - return _pFirstAttr != 0; + return _pFirstAttr != nullptr; } diff --git a/XML/src/EventDispatcher.cpp b/XML/src/EventDispatcher.cpp index 9ef7a0aba..93133061e 100644 --- a/XML/src/EventDispatcher.cpp +++ b/XML/src/EventDispatcher.cpp @@ -71,7 +71,7 @@ void EventDispatcher::removeEventListener(const XMLString& type, EventListener* { if (it->type == type && it->pListener == listener && it->useCapture == useCapture) { - it->pListener = 0; + it->pListener = nullptr; } if (!_inDispatch && !it->pListener) { diff --git a/XML/src/NodeAppender.cpp b/XML/src/NodeAppender.cpp index 4e8bbe391..41d874c7e 100644 --- a/XML/src/NodeAppender.cpp +++ b/XML/src/NodeAppender.cpp @@ -60,7 +60,7 @@ void NodeAppender::appendChild(Node* newChild) pChild->_pParent = _pParent; pChild = pChild->_pNext; } - pFrag->_pFirstChild = 0; + pFrag->_pFirstChild = nullptr; } } else diff --git a/XML/src/NodeIterator.cpp b/XML/src/NodeIterator.cpp index f4d5f2c85..80cfe66f2 100644 --- a/XML/src/NodeIterator.cpp +++ b/XML/src/NodeIterator.cpp @@ -88,8 +88,8 @@ Node* NodeIterator::previousNode() void NodeIterator::detach() { - _pRoot = 0; - _pCurrent = 0; + _pRoot = nullptr; + _pCurrent = nullptr; } @@ -163,7 +163,7 @@ Node* NodeIterator::previous() const Node* NodeIterator::last() { _pCurrent = _pRoot; - Node* pLast = 0; + Node* pLast = nullptr; while (_pCurrent) { pLast = _pCurrent; diff --git a/XML/src/ParserEngine.cpp b/XML/src/ParserEngine.cpp index 60cd120d3..191084be0 100644 --- a/XML/src/ParserEngine.cpp +++ b/XML/src/ParserEngine.cpp @@ -748,8 +748,8 @@ int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* con if (!context && !pThis->_externalParameterEntities) return XML_STATUS_ERROR; if (context && !pThis->_externalGeneralEntities) return XML_STATUS_ERROR; - InputSource* pInputSource = 0; - EntityResolver* pEntityResolver = 0; + InputSource* pInputSource = nullptr; + EntityResolver* pEntityResolver = nullptr; EntityResolverImpl defaultResolver; XMLString sysId(systemId); @@ -798,7 +798,7 @@ int ParserEngine::handleUnknownEncoding(void* encodingHandlerData, const XML_Cha ParserEngine* pThis = reinterpret_cast(encodingHandlerData); XMLString encoding(name); - TextEncoding* knownEncoding = 0; + TextEncoding* knownEncoding = nullptr; EncodingMap::const_iterator it = pThis->_encodings.find(encoding); if (it != pThis->_encodings.end()) diff --git a/XML/src/TreeWalker.cpp b/XML/src/TreeWalker.cpp index f4c960a4a..ef67eb620 100644 --- a/XML/src/TreeWalker.cpp +++ b/XML/src/TreeWalker.cpp @@ -73,7 +73,7 @@ Node* TreeWalker::parentNode() if (pParent && accept(pParent) == NodeFilter::FILTER_ACCEPT) _pCurrent = pParent; else - pParent = 0; + pParent = nullptr; return pParent; } diff --git a/XML/testsuite/src/NamePoolTest.cpp b/XML/testsuite/src/NamePoolTest.cpp index 896beb866..dbf9f6f4c 100644 --- a/XML/testsuite/src/NamePoolTest.cpp +++ b/XML/testsuite/src/NamePoolTest.cpp @@ -34,7 +34,7 @@ NamePoolTest::~NamePoolTest() void NamePoolTest::testNamePool() { AutoPtr pool = new NamePool; - const Name* pName = 0; + const Name* pName = nullptr; Name name("pre:local", "http://www.appinf.com"); pName = &pool->insert(name);