diff options
| author | Linus Jahn <lnj@kaidan.im> | 2019-05-14 17:15:11 +0200 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2019-10-23 18:09:17 +0200 |
| commit | 4172b33b1222a586d95dbc7e69dad7a19a307ea1 (patch) | |
| tree | 830008c8dd42d257c8aba3080e35813d37383eb2 /src/base/QXmppElement.cpp | |
| parent | b34ceca75db2791f00d9fa12b8714739bd19eade (diff) | |
| download | qxmpp-4172b33b1222a586d95dbc7e69dad7a19a307ea1.tar.gz | |
Replace Q_FOREACH (foreach) by C++11 ranged for-loops
Q_FOREACH is bad and will be deprecated in the future:
https://www.kdab.com/goodbye-q_foreach/
This also disables Q_FOREACH by defining QT_NO_FOREACH.
Diffstat (limited to 'src/base/QXmppElement.cpp')
| -rw-r--r-- | src/base/QXmppElement.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/base/QXmppElement.cpp b/src/base/QXmppElement.cpp index 7d0e33fa..9b07f851 100644 --- a/src/base/QXmppElement.cpp +++ b/src/base/QXmppElement.cpp @@ -88,7 +88,7 @@ QXmppElementPrivate::QXmppElementPrivate(const QDomElement &element) QXmppElementPrivate::~QXmppElementPrivate() { - foreach (QXmppElementPrivate *child, children) + for (auto *child : children) if (!child->counter.deref()) delete child; } @@ -178,7 +178,7 @@ void QXmppElement::appendChild(const QXmppElement &child) QXmppElement QXmppElement::firstChildElement(const QString &name) const { - foreach (QXmppElementPrivate *child_d, d->children) + for (auto *child_d : d->children) if (name.isEmpty() || child_d->name == name) return QXmppElement(child_d); return QXmppElement(); @@ -238,12 +238,12 @@ void QXmppElement::toXml(QXmlStreamWriter *writer) const writer->writeStartElement(d->name); if (d->attributes.contains("xmlns")) writer->writeAttribute("xmlns", d->attributes.value("xmlns")); - foreach (const QString &attr, d->attributes.keys()) + for (const auto &attr : d->attributes.keys()) if (attr != "xmlns") helperToXmlAddAttribute(writer, attr, d->attributes.value(attr)); if (!d->value.isEmpty()) writer->writeCharacters(d->value); - foreach (const QXmppElement &child, d->children) - child.toXml(writer); + for (auto *childPrivate : d->children) + QXmppElement(childPrivate).toXml(writer); writer->writeEndElement(); } |
