From b4ead572501179244aa036e7a590fa7536929f2b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 May 2019 15:04:18 +0200 Subject: Move away from using 0 as a pointer constant Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira --- src/xml/dom/qdom.cpp | 220 +++++++++++++++++++++++++-------------------------- src/xml/sax/qxml.cpp | 110 +++++++++++++------------- 2 files changed, 165 insertions(+), 165 deletions(-) (limited to 'src/xml') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 6498d53b96..25655c09b2 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -136,7 +136,7 @@ public: class QDomNodePrivate { public: - QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); + QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = nullptr); QDomNodePrivate(QDomNodePrivate* n, bool deep); virtual ~QDomNodePrivate(); @@ -159,11 +159,11 @@ public: virtual void normalize(); virtual void clear(); - inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : 0; } + inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : nullptr; } inline void setParent(QDomNodePrivate *p) { ownerNode = p; hasParent = true; } void setNoParent() { - ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : 0; + ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : nullptr; hasParent = false; } @@ -289,7 +289,7 @@ public: class QDomDocumentTypePrivate : public QDomNodePrivate { public: - QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); + QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = nullptr); QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep); ~QDomDocumentTypePrivate(); void init(); @@ -317,7 +317,7 @@ public: class QDomDocumentFragmentPrivate : public QDomNodePrivate { public: - QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); + QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = nullptr); QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep); // Reimplemented from QDomNodePrivate @@ -907,7 +907,7 @@ QDomImplementationPrivate* QDomImplementationPrivate::clone() */ QDomImplementation::QDomImplementation() { - impl = 0; + impl = nullptr; } /*! @@ -1036,7 +1036,7 @@ QDomDocumentType QDomImplementation::createDocumentType(const QString& qName, co if (!ok) return QDomDocumentType(); - QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0); + QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(nullptr); dt->name = fixedName; if (systemId.isNull()) { dt->publicId.clear(); @@ -1070,7 +1070,7 @@ QDomDocument QDomImplementation::createDocument(const QString& nsURI, const QStr */ bool QDomImplementation::isNull() { - return (impl == 0); + return (impl == nullptr); } /*! @@ -1244,14 +1244,14 @@ void QDomNodeListPrivate::createList() QDomNodePrivate* QDomNodeListPrivate::item(int index) { if (!node_impl) - return 0; + return nullptr; const QDomDocumentPrivate *const doc = node_impl->ownerDocument(); if (!doc || timestamp != doc->nodeListTime) createList(); if (index >= list.size()) - return 0; + return nullptr; return list.at(index); } @@ -1305,13 +1305,13 @@ int QDomNodeListPrivate::length() const Creates an empty node list. */ QDomNodeList::QDomNodeList() + : impl(nullptr) { - impl = 0; } QDomNodeList::QDomNodeList(QDomNodeListPrivate* p) + : impl(p) { - impl = p; } /*! @@ -1443,10 +1443,10 @@ QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) setParent(par); else setOwnerDocument(doc); - prev = 0; - next = 0; - first = 0; - last = 0; + prev = nullptr; + next = nullptr; + first = nullptr; + last = nullptr; createdWithDom1Interface = true; lineNumber = -1; columnNumber = -1; @@ -1455,10 +1455,10 @@ QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1) { setOwnerDocument(n->ownerDocument()); - prev = 0; - next = 0; - first = 0; - last = 0; + prev = nullptr; + next = nullptr; + first = nullptr; + last = nullptr; name = n->name; value = n->value; @@ -1488,8 +1488,8 @@ QDomNodePrivate::~QDomNodePrivate() p->setNoParent(); p = n; } - first = 0; - last = 0; + first = nullptr; + last = nullptr; } void QDomNodePrivate::clear() @@ -1503,8 +1503,8 @@ void QDomNodePrivate::clear() delete p; p = n; } - first = 0; - last = 0; + first = nullptr; + last = nullptr; } QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n) @@ -1515,7 +1515,7 @@ QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n) return p; p = p->next; } - return 0; + return nullptr; } @@ -1523,15 +1523,15 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo { // Error check if (!newChild) - return 0; + return nullptr; // Error check if (newChild == refChild) - return 0; + return nullptr; // Error check if (refChild && refChild->parent() != this) - return 0; + return nullptr; // "mark lists as dirty" QDomDocumentPrivate *const doc = ownerDocument(); @@ -1542,7 +1542,7 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? - if (newChild->first == 0) + if (newChild->first == nullptr) return newChild; // New parent @@ -1553,7 +1553,7 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo } // Insert at the beginning ? - if (!refChild || refChild->prev == 0) { + if (!refChild || refChild->prev == nullptr) { if (first) first->prev = newChild->last; newChild->last->next = first; @@ -1572,8 +1572,8 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo // does not decrease the reference. // Remove the nodes from the fragment - newChild->first = 0; - newChild->last = 0; + newChild->first = nullptr; + newChild->last = nullptr; return newChild; } @@ -1596,7 +1596,7 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo return newChild; } - if (refChild->prev == 0) { + if (refChild->prev == nullptr) { if (first) first->prev = newChild; newChild->next = first; @@ -1618,15 +1618,15 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod { // Error check if (!newChild) - return 0; + return nullptr; // Error check if (newChild == refChild) - return 0; + return nullptr; // Error check if (refChild && refChild->parent() != this) - return 0; + return nullptr; // "mark lists as dirty" QDomDocumentPrivate *const doc = ownerDocument(); @@ -1637,7 +1637,7 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? - if (newChild->first == 0) + if (newChild->first == nullptr) return newChild; // New parent @@ -1648,7 +1648,7 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod } // Insert at the end - if (!refChild || refChild->next == 0) { + if (!refChild || refChild->next == nullptr) { if (last) last->next = newChild->first; newChild->first->prev = last; @@ -1666,8 +1666,8 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod // does not decrease the reference. // Remove the nodes from the fragment - newChild->first = 0; - newChild->last = 0; + newChild->first = nullptr; + newChild->last = nullptr; return newChild; } @@ -1692,7 +1692,7 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod return newChild; } - if (refChild->next == 0) { + if (refChild->next == nullptr) { if (last) last->next = newChild; newChild->prev = last; @@ -1713,11 +1713,11 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild) { if (!newChild || !oldChild) - return 0; + return nullptr; if (oldChild->parent() != this) - return 0; + return nullptr; if (newChild == oldChild) - return 0; + return nullptr; // mark lists as dirty QDomDocumentPrivate *const doc = ownerDocument(); @@ -1728,7 +1728,7 @@ QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNo // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? - if (newChild->first == 0) + if (newChild->first == nullptr) return newChild; // New parent @@ -1753,15 +1753,15 @@ QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNo last = newChild->last; oldChild->setNoParent(); - oldChild->next = 0; - oldChild->prev = 0; + oldChild->next = nullptr; + oldChild->prev = nullptr; // No need to increase the reference since QDomDocumentFragment // does not decrease the reference. // Remove the nodes from the fragment - newChild->first = 0; - newChild->last = 0; + newChild->first = nullptr; + newChild->last = nullptr; // We are no longer interested in the old node if (oldChild) @@ -1794,8 +1794,8 @@ QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNo last = newChild; oldChild->setNoParent(); - oldChild->next = 0; - oldChild->prev = 0; + oldChild->next = nullptr; + oldChild->prev = nullptr; // We are no longer interested in the old node if (oldChild) @@ -1808,7 +1808,7 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) { // Error check if (oldChild->parent() != this) - return 0; + return nullptr; // "mark lists as dirty" QDomDocumentPrivate *const doc = ownerDocument(); @@ -1817,8 +1817,8 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) // Perhaps oldChild was just created with "createElement" or that. In this case // its parent is QDomDocument but it is not part of the documents child list. - if (oldChild->next == 0 && oldChild->prev == 0 && first != oldChild) - return 0; + if (oldChild->next == nullptr && oldChild->prev == nullptr && first != oldChild) + return nullptr; if (oldChild->next) oldChild->next->prev = oldChild->prev; @@ -1831,8 +1831,8 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) first = oldChild->next; oldChild->setNoParent(); - oldChild->next = 0; - oldChild->prev = 0; + oldChild->next = nullptr; + oldChild->prev = nullptr; // We are no longer interested in the old node oldChild->ref.deref(); @@ -1843,7 +1843,7 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild) { // No reference manipulation needed. Done in insertAfter. - return insertAfter(newChild, 0); + return insertAfter(newChild, nullptr); } QDomDocumentPrivate* QDomNodePrivate::ownerDocument() @@ -1869,7 +1869,7 @@ QDomNodePrivate* QDomNodePrivate::cloneNode(bool deep) static void qNormalizeNode(QDomNodePrivate* n) { QDomNodePrivate* p = n->first; - QDomTextPrivate* t = 0; + QDomTextPrivate* t = nullptr; while (p) { if (p->isText()) { @@ -1884,7 +1884,7 @@ static void qNormalizeNode(QDomNodePrivate* n) } } else { p = p->next; - t = 0; + t = nullptr; } } } @@ -2009,8 +2009,8 @@ void QDomNodePrivate::setLocation(int lineNumber, int columnNumber) Constructs a \l{isNull()}{null} node. */ QDomNode::QDomNode() + : impl(nullptr) { - impl = 0; } /*! @@ -2619,7 +2619,7 @@ bool QDomNode::hasChildNodes() const { if (!impl) return false; - return IMPL->first != 0; + return IMPL->first != nullptr; } /*! @@ -2628,7 +2628,7 @@ bool QDomNode::hasChildNodes() const */ bool QDomNode::isNull() const { - return (impl == 0); + return (impl == nullptr); } /*! @@ -2641,7 +2641,7 @@ void QDomNode::clear() { if (impl && !impl->ref.deref()) delete impl; - impl = 0; + impl = nullptr; } /*! @@ -3094,13 +3094,13 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, cons return n; } } - return 0; + return nullptr; } QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg) { if (readonly || !arg) - return 0; + return nullptr; if (appendToParent) return parent->appendChild(arg); @@ -3115,7 +3115,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg) QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg) { if (readonly || !arg) - return 0; + return nullptr; if (appendToParent) return parent->appendChild(arg); @@ -3136,11 +3136,11 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg) QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(const QString& name) { if (readonly) - return 0; + return nullptr; QDomNodePrivate* p = namedItem(name); - if (p == 0) - return 0; + if (p == nullptr) + return nullptr; if (appendToParent) return parent->removeChild(p); @@ -3153,7 +3153,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(const QString& name) QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const { if (index >= length() || index < 0) - return 0; + return nullptr; return *(map.constBegin() + index); } @@ -3164,12 +3164,12 @@ int QDomNamedNodeMapPrivate::length() const bool QDomNamedNodeMapPrivate::contains(const QString& name) const { - return map.value(name) != 0; + return map.contains(name); } bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & localName) const { - return namedItemNS(nsURI, localName) != 0; + return namedItemNS(nsURI, localName) != nullptr; } /************************************************************** @@ -3222,8 +3222,8 @@ bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & l Constructs an empty named node map. */ QDomNamedNodeMap::QDomNamedNodeMap() + : impl(nullptr) { - impl = 0; } /*! @@ -3570,7 +3570,7 @@ QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild) QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild) { - return insertAfter(newChild, 0); + return insertAfter(newChild, nullptr); } static QString quotedValue(const QString &data) @@ -4115,7 +4115,7 @@ QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n, bool deep) void QDomAttrPrivate::setNodeValue(const QString& v) { value = v; - QDomTextPrivate *t = new QDomTextPrivate(0, this, v); + QDomTextPrivate *t = new QDomTextPrivate(nullptr, this, v); // keep the refcount balanced: appendChild() does a ref anyway. t->ref.deref(); if (first) { @@ -4517,7 +4517,7 @@ QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr) QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr) { - QDomNodePrivate* n = 0; + QDomNodePrivate* n = nullptr; if (!newAttr->prefix.isNull()) n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name); @@ -5184,10 +5184,10 @@ QDomTextPrivate* QDomTextPrivate::splitText(int offset) { if (!parent()) { qWarning("QDomText::splitText The node has no parent. So I cannot split"); - return 0; + return nullptr; } - QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), 0, value.mid(offset)); + QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), nullptr, value.mid(offset)); value.truncate(offset); parent()->insertAfter(t, this); @@ -6144,7 +6144,7 @@ void QDomProcessingInstruction::setData(const QString& d) **************************************************************/ QDomDocumentPrivate::QDomDocumentPrivate() - : QDomNodePrivate(0), + : QDomNodePrivate(nullptr), impl(new QDomImplementationPrivate), nodeListTime(1) { @@ -6155,7 +6155,7 @@ QDomDocumentPrivate::QDomDocumentPrivate() } QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname) - : QDomNodePrivate(0), + : QDomNodePrivate(nullptr), impl(new QDomImplementationPrivate), nodeListTime(1) { @@ -6167,11 +6167,11 @@ QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname) } QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt) - : QDomNodePrivate(0), + : QDomNodePrivate(nullptr), impl(new QDomImplementationPrivate), nodeListTime(1) { - if (dt != 0) { + if (dt != nullptr) { type = dt; } else { type = new QDomDocumentTypePrivate(this, this); @@ -6267,9 +6267,9 @@ QDomElementPrivate* QDomDocumentPrivate::createElement(const QString &tagName) bool ok; QString fixedName = fixedXmlName(tagName, &ok); if (!ok) - return 0; + return nullptr; - QDomElementPrivate *e = new QDomElementPrivate(this, 0, fixedName); + QDomElementPrivate *e = new QDomElementPrivate(this, nullptr, fixedName); e->ref.deref(); return e; } @@ -6279,16 +6279,16 @@ QDomElementPrivate* QDomDocumentPrivate::createElementNS(const QString &nsURI, c bool ok; QString fixedName = fixedXmlName(qName, &ok, true); if (!ok) - return 0; + return nullptr; - QDomElementPrivate *e = new QDomElementPrivate(this, 0, nsURI, fixedName); + QDomElementPrivate *e = new QDomElementPrivate(this, nullptr, nsURI, fixedName); e->ref.deref(); return e; } QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment() { - QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)0); + QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)nullptr); f->ref.deref(); return f; } @@ -6298,9 +6298,9 @@ QDomTextPrivate* QDomDocumentPrivate::createTextNode(const QString &data) bool ok; QString fixedData = fixedCharData(data, &ok); if (!ok) - return 0; + return nullptr; - QDomTextPrivate *t = new QDomTextPrivate(this, 0, fixedData); + QDomTextPrivate *t = new QDomTextPrivate(this, nullptr, fixedData); t->ref.deref(); return t; } @@ -6310,9 +6310,9 @@ QDomCommentPrivate* QDomDocumentPrivate::createComment(const QString &data) bool ok; QString fixedData = fixedComment(data, &ok); if (!ok) - return 0; + return nullptr; - QDomCommentPrivate *c = new QDomCommentPrivate(this, 0, fixedData); + QDomCommentPrivate *c = new QDomCommentPrivate(this, nullptr, fixedData); c->ref.deref(); return c; } @@ -6322,9 +6322,9 @@ QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(const QString & bool ok; QString fixedData = fixedCDataSection(data, &ok); if (!ok) - return 0; + return nullptr; - QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, 0, fixedData); + QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, nullptr, fixedData); c->ref.deref(); return c; } @@ -6335,13 +6335,13 @@ QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstructi bool ok; QString fixedData = fixedPIData(data, &ok); if (!ok) - return 0; + return nullptr; // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) QString fixedTarget = fixedXmlName(target, &ok); if (!ok) - return 0; + return nullptr; - QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, 0, fixedTarget, fixedData); + QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, nullptr, fixedTarget, fixedData); p->ref.deref(); return p; } @@ -6350,9 +6350,9 @@ QDomAttrPrivate* QDomDocumentPrivate::createAttribute(const QString &aname) bool ok; QString fixedName = fixedXmlName(aname, &ok); if (!ok) - return 0; + return nullptr; - QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, fixedName); + QDomAttrPrivate *a = new QDomAttrPrivate(this, nullptr, fixedName); a->ref.deref(); return a; } @@ -6362,9 +6362,9 @@ QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(const QString &nsURI, co bool ok; QString fixedName = fixedXmlName(qName, &ok, true); if (!ok) - return 0; + return nullptr; - QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, nsURI, fixedName); + QDomAttrPrivate *a = new QDomAttrPrivate(this, nullptr, nsURI, fixedName); a->ref.deref(); return a; } @@ -6374,16 +6374,16 @@ QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(const QSt bool ok; QString fixedName = fixedXmlName(aname, &ok); if (!ok) - return 0; + return nullptr; - QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, 0, fixedName); + QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, nullptr, fixedName); e->ref.deref(); return e; } QDomNodePrivate* QDomDocumentPrivate::importNode(QDomNodePrivate *importedNode, bool deep) { - QDomNodePrivate *node = 0; + QDomNodePrivate *node = nullptr; switch (importedNode->nodeType()) { case QDomNode::AttributeNode: node = new QDomAttrPrivate((QDomAttrPrivate*)importedNode, true); @@ -6435,7 +6435,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod #if QT_CONFIG(textcodec) && QT_CONFIG(regularexpression) const QDomNodePrivate* n = first; - QTextCodec *codec = 0; + QTextCodec *codec = nullptr; if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) { // we have an XML declaration @@ -6593,7 +6593,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod */ QDomDocument::QDomDocument() { - impl = 0; + impl = nullptr; } /*! @@ -6822,7 +6822,7 @@ bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QStri { if (!impl) impl = new QDomDocumentPrivate(); - return IMPL->setContent(source, reader, 0, errorMsg, errorLine, errorColumn); + return IMPL->setContent(source, reader, nullptr, errorMsg, errorLine, errorColumn); } /*! @@ -7369,7 +7369,7 @@ QDomComment QDomNode::toComment() const QDomHandler::QDomHandler(QDomDocumentPrivate* adoc, QXmlSimpleReader* areader, bool namespaceProcessing) : errorLine(0), errorColumn(0), doc(adoc), node(adoc), cdata(false), - nsProcessing(namespaceProcessing), locator(0), reader(areader) + nsProcessing(namespaceProcessing), locator(nullptr), reader(areader) { } @@ -7443,7 +7443,7 @@ bool QDomHandler::characters(const QString& ch) if (cdata) { n.reset(doc->createCDATASection(ch)); } else if (!entityName.isEmpty()) { - QScopedPointer e(new QDomEntityPrivate(doc, 0, entityName, + QScopedPointer e(new QDomEntityPrivate(doc, nullptr, entityName, QString(), QString(), QString())); e->value = ch; e->ref.deref(); @@ -7528,7 +7528,7 @@ bool QDomHandler::comment(const QString& ch) bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString ¬ationName) { - QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name, + QDomEntityPrivate* e = new QDomEntityPrivate(doc, nullptr, name, publicId, systemId, notationName); // keep the refcount balanced: appendChild() does a ref anyway. e->ref.deref(); @@ -7543,7 +7543,7 @@ bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicI bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId) { - QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId); + QDomNotationPrivate* n = new QDomNotationPrivate(doc, nullptr, name, publicId, systemId); // keep the refcount balanced: appendChild() does a ref anyway. n->ref.deref(); doc->doctype()->appendChild(n); diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index b2fff5b61f..1c45118fb1 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1079,12 +1079,12 @@ void QXmlInputSource::init() d = new QXmlInputSourcePrivate; QT_TRY { - d->inputDevice = 0; - d->inputStream = 0; + d->inputDevice = nullptr; + d->inputStream = nullptr; setData(QString()); #if QT_CONFIG(textcodec) - d->encMapper = 0; + d->encMapper = nullptr; #endif d->nextReturnedEndOfData = true; // first call to next() will call fetchData() @@ -1357,13 +1357,13 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) return QString(); if (beginning) { delete d->encMapper; - d->encMapper = 0; + d->encMapper = nullptr; } int mib = 106; // UTF-8 // This is the initial UTF codec we will read the encoding declaration with - if (d->encMapper == 0) { + if (d->encMapper == nullptr) { d->encodingDeclBytes.clear(); d->encodingDeclChars.clear(); d->lookingForEncodingDecl = true; @@ -2377,7 +2377,7 @@ bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&, bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&, QXmlInputSource*& ret) { - ret = 0; + ret = nullptr; return true; } @@ -2520,15 +2520,15 @@ inline void QXmlSimpleReaderPrivate::refClear() QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader) { q_ptr = reader; - parseStack = 0; + parseStack = nullptr; locator.reset(new QXmlSimpleReaderLocator(reader)); - entityRes = 0; - dtdHnd = 0; - contentHnd = 0; - errorHnd = 0; - lexicalHnd = 0; - declHnd = 0; + entityRes = nullptr; + dtdHnd = nullptr; + contentHnd = nullptr; + errorHnd = nullptr; + lexicalHnd = nullptr; + declHnd = nullptr; // default feature settings useNamespaces = true; @@ -2932,7 +2932,7 @@ bool QXmlSimpleReader::feature(const QString& name, bool *ok) const { const QXmlSimpleReaderPrivate *d = d_func(); - if (ok != 0) + if (ok) *ok = true; if (name == QLatin1String("http://xml.org/sax/features/namespaces")) { return d->useNamespaces; @@ -2946,7 +2946,7 @@ bool QXmlSimpleReader::feature(const QString& name, bool *ok) const return d->reportEntities; } else { qWarning("Unknown feature %s", name.toLatin1().data()); - if (ok != 0) + if (ok) *ok = false; } return false; @@ -3023,9 +3023,9 @@ bool QXmlSimpleReader::hasFeature(const QString& name) const */ void* QXmlSimpleReader::property(const QString&, bool *ok) const { - if (ok != 0) + if (ok) *ok = false; - return 0; + return nullptr; } /*! \reimp @@ -3206,7 +3206,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) d->initIncrementalParsing(); } else { delete d->parseStack; - d->parseStack = 0; + d->parseStack = nullptr; } d->init(input); @@ -3251,7 +3251,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) bool QXmlSimpleReader::parseContinue() { Q_D(QXmlSimpleReader); - if (d->parseStack == 0 || d->parseStack->isEmpty()) + if (d->parseStack == nullptr || d->parseStack->isEmpty()) return false; d->initData(); int state = d->parseStack->pop().state; @@ -3268,7 +3268,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) if (state==0) { if (!parseProlog()) { if (incremental && error.isNull()) { - pushParseState(0, 0); + pushParseState(nullptr, 0); return true; } else { clear(tags); @@ -3280,7 +3280,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) if (state==1) { if (!parseElement()) { if (incremental && error.isNull()) { - pushParseState(0, 1); + pushParseState(nullptr, 1); return true; } else { clear(tags); @@ -3293,7 +3293,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) while (!atEnd()) { if (!parseMisc()) { if (incremental && error.isNull()) { - pushParseState(0, 2); + pushParseState(nullptr, 2); return true; } else { clear(tags); @@ -3303,7 +3303,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) } if (!atEndOrig && incremental) { // we parsed something at all, so be prepared to come back later - pushParseState(0, 2); + pushParseState(nullptr, 2); return true; } // is stack empty? @@ -3315,7 +3315,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) // call the handler if (contentHnd) { delete parseStack; - parseStack = 0; + parseStack = nullptr; if (!contentHnd->endDocument()) { reportParseError(contentHnd->errorString()); return false; @@ -3350,7 +3350,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) signed char state; signed char input; -(4) if (d->parseStack == 0 || d->parseStack->isEmpty()) { +(4) if (d->parseStack == nullptr || d->parseStack->isEmpty()) { (4a) ... } else { (4b) ... @@ -3440,7 +3440,7 @@ bool QXmlSimpleReaderPrivate::parseProlog() signed char state; signed char input; - if (parseStack == 0 || parseStack->isEmpty()) { + if (parseStack == nullptr|| parseStack->isEmpty()) { xmldecl_possible = true; doctype_read = false; state = Init; @@ -3631,7 +3631,7 @@ bool QXmlSimpleReaderPrivate::parseElement() int state; int input; - if (parseStack == 0 || parseStack->isEmpty()) { + if (parseStack == nullptr|| parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -4000,7 +4000,7 @@ bool QXmlSimpleReaderPrivate::parseContent() signed char state; signed char input; - if (parseStack == 0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { contentCharDataRead = false; state = Init; } else { @@ -4303,7 +4303,7 @@ bool QXmlSimpleReaderPrivate::parseMisc() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -4458,7 +4458,7 @@ bool QXmlSimpleReaderPrivate::parsePI() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -4685,7 +4685,7 @@ bool QXmlSimpleReaderPrivate::parseDoctype() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { startDTDwasReported = false; systemId.clear(); publicId.clear(); @@ -4896,7 +4896,7 @@ bool QXmlSimpleReaderPrivate::parseExternalID() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { systemId.clear(); publicId.clear(); state = Init; @@ -5060,7 +5060,7 @@ bool QXmlSimpleReaderPrivate::parseMarkupdecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5218,7 +5218,7 @@ bool QXmlSimpleReaderPrivate::parsePEReference() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5255,7 +5255,7 @@ bool QXmlSimpleReaderPrivate::parsePEReference() } else if (entityRes) { QMap::Iterator it2; it2 = externParameterEntities.find(ref()); - QXmlInputSource *ret = 0; + QXmlInputSource *ret = nullptr; if (it2 != externParameterEntities.end()) { if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) { delete ret; @@ -5396,7 +5396,7 @@ bool QXmlSimpleReaderPrivate::parseAttlistDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5612,7 +5612,7 @@ bool QXmlSimpleReaderPrivate::parseAttType() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5833,7 +5833,7 @@ bool QXmlSimpleReaderPrivate::parseAttValue() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5975,7 +5975,7 @@ bool QXmlSimpleReaderPrivate::parseElementDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6184,7 +6184,7 @@ bool QXmlSimpleReaderPrivate::parseNotationDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6328,7 +6328,7 @@ bool QXmlSimpleReaderPrivate::parseChoiceSeq() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6557,7 +6557,7 @@ bool QXmlSimpleReaderPrivate::parseEntityDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6832,7 +6832,7 @@ bool QXmlSimpleReaderPrivate::parseEntityValue() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6951,7 +6951,7 @@ bool QXmlSimpleReaderPrivate::parseComment() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7063,7 +7063,7 @@ bool QXmlSimpleReaderPrivate::parseAttribute() int state; int input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7162,7 +7162,7 @@ bool QXmlSimpleReaderPrivate::parseName() }; int state; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7248,7 +7248,7 @@ bool QXmlSimpleReaderPrivate::parseNmtoken() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7356,7 +7356,7 @@ bool QXmlSimpleReaderPrivate::parseReference() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { parseReference_charDataRead = false; state = Init; } else { @@ -7582,7 +7582,7 @@ bool QXmlSimpleReaderPrivate::processReference() if (parseReference_context == InContent) { if (contentCharDataRead) { if (reportWhitespaceCharData || !string().simplified().isEmpty()) { - if (contentHnd != 0 && !contentHnd->characters(string())) { + if (contentHnd != nullptr && !contentHnd->characters(string())) { reportParseError(contentHnd->errorString()); return false; } @@ -7610,7 +7610,7 @@ bool QXmlSimpleReaderPrivate::processReference() // Included if validating bool skipIt = true; if (entityRes) { - QXmlInputSource *ret = 0; + QXmlInputSource *ret = nullptr; if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) { delete ret; reportParseError(entityRes->errorString()); @@ -7696,7 +7696,7 @@ bool QXmlSimpleReaderPrivate::parseString() signed char state; // state in this function is the position in the string s signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { Done = parseString_s.length(); state = 0; } else { @@ -7800,7 +7800,7 @@ void QXmlSimpleReaderPrivate::next() c = inputSource->next(); // If we are not incremental parsing, we just skip over EndOfData chars to give the // parser an uninterrupted stream of document chars. - if (c == QXmlInputSource::EndOfData && parseStack == 0) + if (c == QXmlInputSource::EndOfData && parseStack == nullptr) c = inputSource->next(); if (uc == '\n') { lineNr++; @@ -7832,7 +7832,7 @@ bool QXmlSimpleReaderPrivate::eat_ws() } next(); } - if (parseStack != 0) { + if (parseStack != nullptr) { unexpectedEof(&QXmlSimpleReaderPrivate::eat_ws, 0); return false; } @@ -7922,7 +7922,7 @@ void QXmlSimpleReaderPrivate::reportParseError(const QString& error) */ void QXmlSimpleReaderPrivate::unexpectedEof(ParseFunction where, int state) { - if (parseStack == 0) { + if (parseStack == nullptr) { reportParseError(QLatin1String(XMLERR_UNEXPECTEDEOF)); } else { if (c == QXmlInputSource::EndOfDocument) { @@ -7942,7 +7942,7 @@ void QXmlSimpleReaderPrivate::unexpectedEof(ParseFunction where, int state) */ void QXmlSimpleReaderPrivate::parseFailed(ParseFunction where, int state) { - if (parseStack!=0 && error.isNull()) { + if (parseStack != nullptr && error.isNull()) { pushParseState(where, state); } } -- cgit v1.2.3 From 0e2c013a4523915a0af37fe1f338a4f66b07f91d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 7 May 2019 10:56:08 +0200 Subject: doc: Add dontdocument.qdoc files Each module that has publically declared classes or structs that are not meant to be documented is given a dontdocument.qdoc file to tell qdoc that these classes are not meant to be documentented. Then qdoc will not print warnings about missing \class comments for these classes and structs. Change-Id: I9195f0b546032e1c7642c9da34d85a0a4a9bfb08 Reviewed-by: Paul Wicking --- src/xml/doc/src/dontdocument.qdoc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/xml/doc/src/dontdocument.qdoc (limited to 'src/xml') diff --git a/src/xml/doc/src/dontdocument.qdoc b/src/xml/doc/src/dontdocument.qdoc new file mode 100644 index 0000000000..0193ace4b4 --- /dev/null +++ b/src/xml/doc/src/dontdocument.qdoc @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \dontdocument (QTypeInfo) +*/ -- cgit v1.2.3 From 4ad915425d804df798e12031c9b2fc13534dcb97 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 3 May 2019 14:17:19 +0200 Subject: Doc: Replace example file lists with links to code.qt.io Instead of generating .html page for each file in an example project, generate links to code.qt.io, under the correct path and branch, where the user can browse the example source. Store all URLs under QT_INSTALL_DOCS/config where other qt5 submodules can access them. The repository name appears in the URL, so we cannot define a single URL for all modules. Task-number: QTBUG-74391 Change-Id: I63d4d6d2c352877797b1ee8e057d48c0cd789bff Reviewed-by: Paul Wicking --- src/xml/doc/qtxml.qdocconf | 1 + 1 file changed, 1 insertion(+) (limited to 'src/xml') diff --git a/src/xml/doc/qtxml.qdocconf b/src/xml/doc/qtxml.qdocconf index a23915487f..25a463fecd 100644 --- a/src/xml/doc/qtxml.qdocconf +++ b/src/xml/doc/qtxml.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtXml description = Qt XML Reference Documentation -- cgit v1.2.3 From 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 11:08:29 +0200 Subject: Port from QAtomic::load() to loadRelaxed() Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz --- src/xml/dom/qdom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xml') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 25655c09b2..8d232237bf 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -4489,7 +4489,7 @@ void QDomElementPrivate::setAttributeNS(const QString& nsURI, const QString& qNa void QDomElementPrivate::removeAttribute(const QString& aname) { QDomNodePrivate* p = m_attr->removeNamedItem(aname); - if (p && p->ref.load() == 0) + if (p && p->ref.loadRelaxed() == 0) delete p; } -- cgit v1.2.3