summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-09-19 15:36:48 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-09-25 09:29:53 +0000
commit33d5e53f865d0950dc390afbe4ded442289c3090 (patch)
treebe2b88e32e01c9481d3b309483efba6322589dd3 /tools
parentb83922861ce7214eb5a2b192ab040c3cc8a42a96 (diff)
Replace Q_FOREACH/foreach with ranged-for
Change-Id: I7b4d13a49577a7d984727722ff2ae4458eab2d6e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qscxmlc/qscxmlc.cpp10
-rw-r--r--tools/qscxmlc/scxmlcppdumper.cpp16
2 files changed, 14 insertions, 12 deletions
diff --git a/tools/qscxmlc/qscxmlc.cpp b/tools/qscxmlc/qscxmlc.cpp
index 47db6fb..03edf5c 100644
--- a/tools/qscxmlc/qscxmlc.cpp
+++ b/tools/qscxmlc/qscxmlc.cpp
@@ -93,7 +93,7 @@ static void collectAllDocuments(DocumentModel::ScxmlDocument *doc,
QList<DocumentModel::ScxmlDocument *> *docs)
{
docs->append(doc);
- foreach (DocumentModel::ScxmlDocument *subDoc, doc->allSubDocuments)
+ for (DocumentModel::ScxmlDocument *subDoc : qAsConst(doc->allSubDocuments))
collectAllDocuments(subDoc, docs);
}
@@ -178,7 +178,8 @@ int run(const QStringList &arguments)
parser.setFileName(file.fileName());
parser.parse();
if (!parser.errors().isEmpty()) {
- foreach (const QScxmlError &error, parser.errors()) {
+ const auto errors = parser.errors();
+ for (const QScxmlError &error : errors) {
errs << error.toString() << endl;
}
return ParseError;
@@ -187,7 +188,8 @@ int run(const QStringList &arguments)
auto mainDoc = QScxmlParserPrivate::get(&parser)->scxmlDocument();
if (mainDoc == nullptr) {
Q_ASSERT(!parser.errors().isEmpty());
- foreach (const QScxmlError &error, parser.errors()) {
+ const auto errors = parser.errors();
+ for (const QScxmlError &error : errors) {
errs << error.toString() << endl;
}
return ScxmlVerificationError;
@@ -215,7 +217,7 @@ int run(const QStringList &arguments)
docs.pop_front();
- foreach (DocumentModel::ScxmlDocument *doc, docs) {
+ for (DocumentModel::ScxmlDocument *doc : qAsConst(docs)) {
auto name = doc->root->name;
auto prefix = name;
if (name.isEmpty()) {
diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp
index a8941d5..56133a5 100644
--- a/tools/qscxmlc/scxmlcppdumper.cpp
+++ b/tools/qscxmlc/scxmlcppdumper.cpp
@@ -404,7 +404,7 @@ int createFactoryId(QStringList &factories, const QString &className,
line += QStringLiteral("%1, ").arg(QString::number(idlocation));
{
QStringList l;
- foreach (auto name, namelist) {
+ for (auto name : namelist) {
l.append(QString::number(name));
}
line += QStringLiteral("%1, ").arg(
@@ -414,7 +414,7 @@ int createFactoryId(QStringList &factories, const QString &className,
: QStringLiteral("false"));
{
QStringList l;
- foreach (const auto &param, params) {
+ for (const auto &param : params) {
l += QStringLiteral("QScxmlExecutableContent::Param(%1, %2, %3)")
.arg(QString::number(param.name),
QString::number(param.expr),
@@ -522,7 +522,7 @@ void CppDumper::writeHeaderStart(const QString &headerGuard, const QStringList &
h << l("namespace ") << m_translationUnit->namespaceName << l(" {") << endl << endl;
if (!forwardDecls.isEmpty()) {
- foreach (const QString &forwardDecl, forwardDecls)
+ for (const QString &forwardDecl : forwardDecls)
h << QStringLiteral("class %1;").arg(forwardDecl) << endl;
h << endl;
}
@@ -545,7 +545,7 @@ void CppDumper::writeHeaderEnd(const QString &headerGuard, const QStringList &me
ns = QStringLiteral("::%1").arg(m_translationUnit->namespaceName);
}
- foreach (const QString &name, metatypeDecls) {
+ for (const QString &name : metatypeDecls) {
h << QStringLiteral("Q_DECLARE_METATYPE(%1::%2*)").arg(ns, name) << endl;
}
h << endl;
@@ -561,7 +561,7 @@ void CppDumper::writeImplStart()
<< endl;
QStringList includes;
- foreach (DocumentModel::ScxmlDocument *doc, m_translationUnit->allDocuments) {
+ for (DocumentModel::ScxmlDocument *doc : qAsConst(m_translationUnit->allDocuments)) {
switch (doc->root->dataModel) {
case DocumentModel::Scxml::NullDataModel:
includes += l("QScxmlNullDataModel");
@@ -583,7 +583,7 @@ void CppDumper::writeImplStart()
cpp << endl
<< QStringLiteral("#include <qscxmlinvokableservice.h>") << endl
<< QStringLiteral("#include <qscxmltabledata.h>") << endl;
- foreach (const QString &inc, includes) {
+ for (const QString &inc : qAsConst(includes)) {
cpp << l("#include <") << inc << l(">") << endl;
}
cpp << endl
@@ -725,7 +725,7 @@ QString CppDumper::generatePropertyDecls(const GeneratedTableData::MetaDataInfo
{
QString decls;
- foreach (const QString &stateName, info.stateNames) {
+ for (const QString &stateName : info.stateNames) {
if (!stateName.isEmpty()) {
const QString decl = QString::fromLatin1(
" Q_PROPERTY(bool %1 NOTIFY %2Changed)\n");
@@ -747,7 +747,7 @@ QString CppDumper::generateMetaObject(const QString &className,
// stateNames:
int stateIdx = 0;
- foreach (const QString &stateName, info.stateNames) {
+ for (const QString &stateName : info.stateNames) {
if (stateName.isEmpty())
continue;