diff options
author | Paul Wicking <paul.wicking@qt.io> | 2019-12-09 18:42:56 +0100 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2019-12-10 20:00:26 +0100 |
commit | 77f9699a7c336e67a2ae6d37b75411528954c705 (patch) | |
tree | d55d3781088208df4b850f7528a46dd243db884d | |
parent | 88b135fb74689484dfa60ee0efd378d85a9f0a75 (diff) | |
download | qttools-77f9699a7c336e67a2ae6d37b75411528954c705.tar.gz |
QDoc: Clean up loops with iterators
- Use ranged-based fors where applicable.
- Use auto keyword for iterators.
- Move a few variable declarations to where they're to be used.
- Update docs where applicable.
Fixes: QTBUG-80536
Change-Id: I859440b96428dec4ef108b01d391479d3f8dbd83
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 15 | ||||
-rw-r--r-- | src/qdoc/codemarker.cpp | 39 | ||||
-rw-r--r-- | src/qdoc/config.cpp | 200 | ||||
-rw-r--r-- | src/qdoc/cppcodemarker.cpp | 8 | ||||
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 41 | ||||
-rw-r--r-- | src/qdoc/doc.cpp | 34 | ||||
-rw-r--r-- | src/qdoc/editdistance.cpp | 10 | ||||
-rw-r--r-- | src/qdoc/generator.cpp | 141 | ||||
-rw-r--r-- | src/qdoc/helpprojectwriter.cpp | 5 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 516 | ||||
-rw-r--r-- | src/qdoc/main.cpp | 42 | ||||
-rw-r--r-- | src/qdoc/node.cpp | 163 | ||||
-rw-r--r-- | src/qdoc/qdocdatabase.cpp | 92 | ||||
-rw-r--r-- | src/qdoc/qdocindexfiles.cpp | 30 | ||||
-rw-r--r-- | src/qdoc/qmlcodemarker.cpp | 8 | ||||
-rw-r--r-- | src/qdoc/qmlvisitor.cpp | 16 | ||||
-rw-r--r-- | src/qdoc/quoter.cpp | 7 | ||||
-rw-r--r-- | src/qdoc/sections.cpp | 148 | ||||
-rw-r--r-- | src/qdoc/tree.cpp | 192 | ||||
-rw-r--r-- | src/qdoc/webxmlgenerator.cpp | 3 |
20 files changed, 692 insertions, 1018 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 5d95c9c7e..605edeb86 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1156,7 +1156,7 @@ void ClangCodeParser::getDefaultArgs() static QVector<QByteArray> includePathsFromHeaders(const QHash<QString, QString> &allHeaders) { QVector<QByteArray> result; - for (auto it = allHeaders.cbegin(), end = allHeaders.cend(); it != end; ++it) { + for (auto it = allHeaders.cbegin(); it != allHeaders.cend(); ++it) { const QByteArray path = "-I" + it.value().toLatin1(); const QByteArray parent = "-I" + QDir::cleanPath(it.value() + QLatin1String("/../")).toLatin1(); @@ -1284,13 +1284,12 @@ void ClangCodeParser::buildPCH() if (tmpHeaderFile.open(QIODevice::Text | QIODevice::WriteOnly)) { QTextStream out(&tmpHeaderFile); if (header.isEmpty()) { - QList<QString> keys = allHeaders_.keys(); - QList<QString> values = allHeaders_.values(); - for (int i = 0; i < keys.size(); i++) { - if (!keys.at(i).endsWith(QLatin1String("_p.h")) && - !keys.at(i).startsWith(QLatin1String("moc_"))) { - QString line = QLatin1String("#include \"") + values.at(i) + - QLatin1String("/") + keys.at(i) + QLatin1String("\""); + for (auto it = allHeaders_.constKeyValueBegin(); + it != allHeaders_.constKeyValueEnd(); ++it) { + if (!(*it).first.endsWith(QLatin1String("_p.h")) && + !(*it).first.startsWith(QLatin1String("moc_"))) { + QString line = QLatin1String("#include \"") + (*it).second + + QLatin1String("/") + (*it).first + QLatin1String("\""); out << line << "\n"; } } diff --git a/src/qdoc/codemarker.cpp b/src/qdoc/codemarker.cpp index 7c8843c65..fc0f69470 100644 --- a/src/qdoc/codemarker.cpp +++ b/src/qdoc/codemarker.cpp @@ -85,11 +85,8 @@ void CodeMarker::terminateMarker() void CodeMarker::initialize(const Config &config) { defaultLang = config.getString(CONFIG_LANGUAGE); - QList<CodeMarker *>::ConstIterator m = markers.constBegin(); - while (m != markers.constEnd()) { - (*m)->initializeMarker(config); - ++m; - } + for (const auto &marker : qAsConst(markers)) + marker->initializeMarker(config); } /*! @@ -97,11 +94,8 @@ void CodeMarker::initialize(const Config &config) */ void CodeMarker::terminate() { - QList<CodeMarker *>::ConstIterator m = markers.constBegin(); - while (m != markers.constEnd()) { - (*m)->terminateMarker(); - ++m; - } + for (const auto &marker : qAsConst(markers)) + marker->terminateMarker(); } CodeMarker *CodeMarker::markerForCode(const QString &code) @@ -110,12 +104,11 @@ CodeMarker *CodeMarker::markerForCode(const QString &code) if (defaultMarker != nullptr && defaultMarker->recognizeCode(code)) return defaultMarker; - QList<CodeMarker *>::ConstIterator m = markers.constBegin(); - while (m != markers.constEnd()) { - if ((*m)->recognizeCode(code)) - return *m; - ++m; + for (const auto &marker : qAsConst(markers)) { + if (marker->recognizeCode(code)) + return marker; } + return defaultMarker; } @@ -127,11 +120,9 @@ CodeMarker *CodeMarker::markerForFileName(const QString &fileName) QString ext = fileName.mid(dot + 1); if (defaultMarker != nullptr && defaultMarker->recognizeExtension(ext)) return defaultMarker; - QList<CodeMarker *>::ConstIterator m = markers.constBegin(); - while (m != markers.constEnd()) { - if ((*m)->recognizeExtension(ext)) - return *m; - ++m; + for (const auto &marker : qAsConst(markers)) { + if (marker->recognizeExtension(ext)) + return marker; } --dot; } @@ -140,11 +131,9 @@ CodeMarker *CodeMarker::markerForFileName(const QString &fileName) CodeMarker *CodeMarker::markerForLanguage(const QString &lang) { - QList<CodeMarker *>::ConstIterator m = markers.constBegin(); - while (m != markers.constEnd()) { - if ((*m)->recognizeLanguage(lang)) - return *m; - ++m; + for (const auto &marker : qAsConst(markers)) { + if (marker->recognizeLanguage(lang)) + return marker; } return nullptr; } diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index 1ffcdd39a..ed80af464 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -200,18 +200,13 @@ void MetaStack::process(QChar ch, const Location &location) location.fatal(tr("Unexpected '}'")); top().close(); - QStringList suffixes = pop().accum; - QStringList prefixes = top().next; + const QStringList suffixes = pop().accum; + const QStringList prefixes = top().next; top().next.clear(); - QStringList::ConstIterator pre = prefixes.constBegin(); - while (pre != prefixes.constEnd()) { - QStringList::ConstIterator suf = suffixes.constBegin(); - while (suf != suffixes.constEnd()) { - top().next << (*pre + *suf); - ++suf; - } - ++pre; + for (const auto &prefix : prefixes) { + for (const auto &suffix: suffixes) + top().next << prefix + suffix; } } else if (ch == QLatin1Char(',') && count() > 1) { top().close(); @@ -220,11 +215,8 @@ void MetaStack::process(QChar ch, const Location &location) /* This is where all the processing is done. */ - QStringList::Iterator pre = top().next.begin(); - while (pre != top().next.end()) { - *pre += ch; - ++pre; - } + for (auto it = top().next.begin(); it != top().next.end(); ++it) + *it += ch; } } @@ -452,17 +444,13 @@ bool Config::getBool(const QString &var) const */ int Config::getInt(const QString &var) const { - QStringList strs = getStringList(var); + const QStringList strs = getStringList(var); if (strs.isEmpty()) return -1; - QStringList::ConstIterator s = strs.constBegin(); int sum = 0; - - while (s != strs.constEnd()) { - sum += (*s).toInt(); - ++s; - } + for (const auto &str : strs) + sum += str.toInt(); return sum; } @@ -655,16 +643,14 @@ QStringList Config::getCanonicalPathList(const QString &var, bool validate) cons QRegExp Config::getRegExp(const QString &var) const { QString pattern; - QList<QRegExp> subRegExps = getRegExpList(var); - QList<QRegExp>::ConstIterator s = subRegExps.constBegin(); + const QList<QRegExp> subRegExps = getRegExpList(var); - while (s != subRegExps.constEnd()) { - if (!(*s).isValid()) - return *s; + for (const auto ®Exp : subRegExps) { + if (!regExp.isValid()) + return regExp; if (!pattern.isEmpty()) pattern += QLatin1Char('|'); - pattern += QLatin1String("(?:") + (*s).pattern() + QLatin1Char(')'); - ++s; + pattern += QLatin1String("(?:") + regExp.pattern() + QLatin1Char(')'); } if (pattern.isEmpty()) pattern = QLatin1String("$x"); // cannot match @@ -678,14 +664,10 @@ QRegExp Config::getRegExp(const QString &var) const */ QList<QRegExp> Config::getRegExpList(const QString &var) const { - QStringList strs = getStringList(var); - QStringList::ConstIterator s = strs.constBegin(); + const QStringList strs = getStringList(var); QList<QRegExp> regExps; - - while (s != strs.constEnd()) { - regExps += QRegExp(*s); - ++s; - } + for (const auto &str : strs) + regExps += QRegExp(str); return regExps; } @@ -699,17 +681,15 @@ QSet<QString> Config::subVars(const QString &var) const { QSet<QString> result; QString varDot = var + QLatin1Char('.'); - ConfigVarMultimap::ConstIterator i = configVars_.constBegin(); - while (i != configVars_.constEnd()) { - if (i.key().startsWith(varDot)) { - QString subVar = i.key().mid(varDot.length()); + for (auto it = configVars_.constBegin(); it != configVars_.constEnd(); ++it) { + if (it.key().startsWith(varDot)) { + QString subVar = it.key().mid(varDot.length()); int dot = subVar.indexOf(QLatin1Char('.')); if (dot != -1) subVar.truncate(dot); if (!result.contains(subVar)) result.insert(subVar); } - ++i; } return result; } @@ -722,16 +702,14 @@ QSet<QString> Config::subVars(const QString &var) const void Config::subVarsAndValues(const QString &var, ConfigVarMultimap &t) const { QString varDot = var + QLatin1Char('.'); - ConfigVarMultimap::ConstIterator v = configVars_.constBegin(); - while (v != configVars_.constEnd()) { - if (v.key().startsWith(varDot)) { - QString subVar = v.key().mid(varDot.length()); + for (auto it = configVars_.constBegin(); it != configVars_.constEnd(); ++it) { + if (it.key().startsWith(varDot)) { + QString subVar = it.key().mid(varDot.length()); int dot = subVar.indexOf(QLatin1Char('.')); if (dot != -1) subVar.truncate(dot); - t.insert(subVar,v.value()); + t.insert(subVar, it.value()); } - ++v; } } @@ -746,18 +724,15 @@ QString Config::getIncludeFilePath(const QString &fileName) const if (!includeFilesMap_.contains(ext)) { QSet<QString> t; QStringList result; - QStringList dirs = getCanonicalPathList(CONFIG_SOURCEDIRS); - QStringList::ConstIterator d = dirs.constBegin(); - while (d != dirs.constEnd()) { - result += getFilesHere(*d, ext, location(), t, t); - ++d; - } + const QStringList dirs = getCanonicalPathList(CONFIG_SOURCEDIRS); + for (const auto &dir : dirs) + result += getFilesHere(dir, ext, location(), t, t); includeFilesMap_.insert(ext, result); } const QStringList &paths = (*includeFilesMap_.find(ext)); - for (int i=0; i<paths.size(); ++i) { - if (paths[i].endsWith(fileName)) - return paths[i]; + for (const auto &path : paths) { + if (path.endsWith(fileName)) + return path; } return QString(); } @@ -777,15 +752,12 @@ QStringList Config::getAllFiles(const QString &filesVar, const QSet<QString> &excludedFiles) { QStringList result = getCanonicalPathList(filesVar, true); - QStringList dirs = getCanonicalPathList(dirsVar, true); + const QStringList dirs = getCanonicalPathList(dirsVar, true); - QString nameFilter = getString(filesVar + dot + CONFIG_FILEEXTENSIONS); + const QString nameFilter = getString(filesVar + dot + CONFIG_FILEEXTENSIONS); - QStringList::ConstIterator d = dirs.constBegin(); - while (d != dirs.constEnd()) { - result += getFilesHere(*d, nameFilter, location(), excludedDirs, excludedFiles); - ++d; - } + for (const auto &dir : dirs) + result += getFilesHere(dir, nameFilter, location(), excludedDirs, excludedFiles); return result; } @@ -793,14 +765,11 @@ QStringList Config::getExampleQdocFiles(const QSet<QString> &excludedDirs, const QSet<QString> &excludedFiles) { QStringList result; - QStringList dirs = getCanonicalPathList("exampledirs"); - QString nameFilter = " *.qdoc"; + const QStringList dirs = getCanonicalPathList("exampledirs"); + const QString nameFilter = " *.qdoc"; - QStringList::ConstIterator d = dirs.constBegin(); - while (d != dirs.constEnd()) { - result += getFilesHere(*d, nameFilter, location(), excludedDirs, excludedFiles); - ++d; - } + for (const auto &dir : dirs) + result += getFilesHere(dir, nameFilter, location(), excludedDirs, excludedFiles); return result; } @@ -808,14 +777,11 @@ QStringList Config::getExampleImageFiles(const QSet<QString> &excludedDirs, const QSet<QString> &excludedFiles) { QStringList result; - QStringList dirs = getCanonicalPathList("exampledirs"); - QString nameFilter = getString(CONFIG_EXAMPLES + dot + CONFIG_IMAGEEXTENSIONS); + const QStringList dirs = getCanonicalPathList("exampledirs"); + const QString nameFilter = getString(CONFIG_EXAMPLES + dot + CONFIG_IMAGEEXTENSIONS); - QStringList::ConstIterator d = dirs.constBegin(); - while (d != dirs.constEnd()) { - result += getFilesHere(*d, nameFilter, location(), excludedDirs, excludedFiles); - ++d; - } + for (const auto &dir : dirs) + result += getFilesHere(dir, nameFilter, location(), excludedDirs, excludedFiles); return result; } @@ -844,25 +810,21 @@ QString Config::findFile(const Location &location, QStringList components = fileName.split(QLatin1Char('?')); QString firstComponent = components.first(); - QStringList::ConstIterator f = files.constBegin(); - while (f != files.constEnd()) { - if (*f == firstComponent || - (*f).endsWith(QLatin1Char('/') + firstComponent)) { - fileInfo.setFile(*f); + for (const auto &file : files) { + if (file == firstComponent || + file.endsWith(QLatin1Char('/') + firstComponent)) { + fileInfo.setFile(file); if (!fileInfo.exists()) - location.fatal(tr("File '%1' does not exist").arg(*f)); + location.fatal(tr("File '%1' does not exist").arg(file)); break; } - ++f; } if (fileInfo.fileName().isEmpty()) { - QStringList::ConstIterator d = dirs.constBegin(); - while (d != dirs.constEnd()) { - fileInfo.setFile(QDir(*d), firstComponent); + for (const auto &dir : dirs) { + fileInfo.setFile(QDir(dir), firstComponent); if (fileInfo.exists()) break; - ++d; } } @@ -872,8 +834,7 @@ QString Config::findFile(const Location &location, return QString(); if (userFriendlyFilePath) { - QStringList::ConstIterator c = components.constBegin(); - for (;;) { + for (auto c = components.constBegin();;) { bool isArchive = (c != components.constEnd() - 1); userFriendlyFilePath->append(*c); @@ -900,16 +861,14 @@ QString Config::findFile(const Location &location, const QStringList &fileExtensions, QString *userFriendlyFilePath) { - QStringList::ConstIterator e = fileExtensions.constBegin(); - while (e != fileExtensions.constEnd()) { + for (const auto &extension : fileExtensions) { QString filePath = findFile(location, files, dirs, - fileBase + QLatin1Char('.') + *e, + fileBase + QLatin1Char('.') + extension, userFriendlyFilePath); if (!filePath.isEmpty()) return filePath; - ++e; } return findFile(location, files, dirs, fileBase, userFriendlyFilePath); } @@ -978,28 +937,25 @@ int Config::numParams(const QString &value) bool Config::removeDirContents(const QString &dir) { QDir dirInfo(dir); - QFileInfoList entries = dirInfo.entryInfoList(); + const QFileInfoList entries = dirInfo.entryInfoList(); bool ok = true; - QFileInfoList::Iterator it = entries.begin(); - while (it != entries.end()) { - if ((*it).isFile()) { - if (!dirInfo.remove((*it).fileName())) + for (const auto &entry : entries) { + if (entry.isFile()) { + if (!dirInfo.remove(entry.fileName())) ok = false; } - else if ((*it).isDir()) { - if ((*it).fileName() != QLatin1String(".") && (*it).fileName() != QLatin1String("..")) { - if (removeDirContents((*it).absoluteFilePath())) { - if (!dirInfo.rmdir((*it).fileName())) + else if (entry.isDir()) { + if (entry.fileName() != QLatin1String(".") && entry.fileName() != QLatin1String("..")) { + if (removeDirContents(entry.absoluteFilePath())) { + if (!dirInfo.rmdir(entry.fileName())) ok = false; - } - else { + } else { ok = false; } } } - ++it; } return ok; } @@ -1131,7 +1087,7 @@ void Config::load(Location location, const QString &fileName) SKIP_CHAR(); } while (isMetaKeyChar(c)); - QStringList keys = stack.getExpanded(location); + const QStringList keys = stack.getExpanded(location); SKIP_SPACES(); if (keys.count() == 1 && keys.first() == QLatin1String("include")) { @@ -1270,16 +1226,13 @@ void Config::load(Location location, const QString &fileName) PUT_CHAR(); } } - - QStringList::ConstIterator key = keys.constBegin(); - while (key != keys.constEnd()) { - if (!keySyntax.exactMatch(*key)) - keyLoc.fatal(tr("Invalid key '%1'").arg(*key)); + for (const auto &key : keys) { + if (!keySyntax.exactMatch(key)) + keyLoc.fatal(tr("Invalid key '%1'").arg(key)); ConfigVarMultimap::Iterator i; - i = configVars_.insert(*key, ConfigVar(*key, rhsValues, QDir::currentPath(), keyLoc)); + i = configVars_.insert(key, ConfigVar(key, rhsValues, QDir::currentPath(), keyLoc)); i.value().plus_ = plus; - ++key; } } } else { @@ -1315,32 +1268,25 @@ QStringList Config::getFilesHere(const QString &uncleanDir, return result; QDir dirInfo(dir); - QStringList fileNames; - QStringList::const_iterator fn; dirInfo.setNameFilters(nameFilter.split(QLatin1Char(' '))); dirInfo.setSorting(QDir::Name); dirInfo.setFilter(QDir::Files); - fileNames = dirInfo.entryList(); - fn = fileNames.constBegin(); - while (fn != fileNames.constEnd()) { - if (!fn->startsWith(QLatin1Char('~'))) { - QString s = dirInfo.filePath(*fn); + QStringList fileNames = dirInfo.entryList(); + for (const auto &file: qAsConst(fileNames)) { + if (!file.startsWith(QLatin1Char('~'))) { + QString s = dirInfo.filePath(file); QString c = QDir::cleanPath(s); if (!isFileExcluded(c, excludedFiles)) result.append(c); } - ++fn; } dirInfo.setNameFilters(QStringList(QLatin1String("*"))); dirInfo.setFilter(QDir::Dirs|QDir::NoDotAndDotDot); fileNames = dirInfo.entryList(); - fn = fileNames.constBegin(); - while (fn != fileNames.constEnd()) { - result += getFilesHere(dirInfo.filePath(*fn), nameFilter, location, excludedDirs, excludedFiles); - ++fn; - } + for (const auto &file : fileNames) + result += getFilesHere(dirInfo.filePath(file), nameFilter, location, excludedDirs, excludedFiles); return result; } diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp index a26dedc76..251f0cef6 100644 --- a/src/qdoc/cppcodemarker.cpp +++ b/src/qdoc/cppcodemarker.cpp @@ -422,11 +422,9 @@ QString CppCodeMarker::markedUpIncludes(const QStringList &includes) { QString code; - QStringList::ConstIterator inc = includes.constBegin(); - while (inc != includes.constEnd()) { - code += "<@preprocessor>#include <<@headerfile>" + *inc + "</@headerfile>></@preprocessor>\n"; - ++inc; - } + for (const auto &include : includes) + code += "<@preprocessor>#include <<@headerfile>" + + include + "</@headerfile>></@preprocessor>\n"; return code; } diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index b05e2ab3c..84e383fc2 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -712,15 +712,10 @@ void CppCodeParser::processMetaCommands(const Doc &doc, Node *node) { QStringList metaCommandsUsed = doc.metaCommandsUsed().values(); metaCommandsUsed.sort(); // TODO: why are these sorted? mws 24/12/2018 - QStringList::ConstIterator cmd = metaCommandsUsed.constBegin(); - while (cmd != metaCommandsUsed.constEnd()) { - ArgList args = doc.metaCommandArgs(*cmd); - ArgList::ConstIterator arg = args.constBegin(); - while (arg != args.constEnd()) { - processMetaCommand(doc, *cmd, *arg, node); - ++arg; - } - ++cmd; + for (const auto &command : metaCommandsUsed) { + const ArgList args = doc.metaCommandArgs(command); + for (const auto &arg : args) + processMetaCommand(doc, command, arg, node); } } @@ -986,18 +981,17 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL } } else if (args.size() > 1) { QVector<SharedCommentNode *> sharedCommentNodes; - ArgList::ConstIterator arg = args.constBegin(); - while (arg != args.constEnd()) { + for (const auto &arg : qAsConst(args)) { node = nullptr; if (topic == COMMAND_FN) { if (showInternal() || !doc.isInternal()) - node = parserForLanguage("Clang")->parseFnArg(doc.location(), arg->first); + node = parserForLanguage("Clang")->parseFnArg(doc.location(), arg.first); } else if (topic == COMMAND_MACRO) { - node = parseMacroArg(doc.location(), arg->first); + node = parseMacroArg(doc.location(), arg.first); } else if (isQMLMethodTopic(topic) || isJSMethodTopic(topic)) { - node = parseOtherFuncArg(topic, doc.location(), arg->first); + node = parseOtherFuncArg(topic, doc.location(), arg.first); } else { - node = processTopicCommand(doc, topic, *arg); + node = processTopicCommand(doc, topic, arg); } if (node != nullptr) { bool found = false; @@ -1015,7 +1009,6 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL docs.append(doc); } } - ++arg; } } } @@ -1023,15 +1016,14 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) { - NodeList::Iterator n = nodes.begin(); QList<Doc>::Iterator d = docs.begin(); - while (n != nodes.end()) { - if (*n != nullptr) { - processMetaCommands(*d, *n); - (*n)->setDoc(*d); - checkModuleInclusion(*n); - if ((*n)->isAggregate()) { - Aggregate *aggregate = static_cast<Aggregate *>(*n); + for (const auto &node : nodes) { + if (node != nullptr) { + processMetaCommands(*d, node); + node->setDoc(*d); + checkModuleInclusion(node); + if (node->isAggregate()) { + Aggregate *aggregate = static_cast<Aggregate *>(node); if (aggregate->includeFiles().isEmpty()) { Aggregate *parent = aggregate; while (parent->physicalModuleName().isEmpty() && (parent->parent() != nullptr)) @@ -1044,7 +1036,6 @@ void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) } } ++d; - ++n; } } diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp index 7510fba97..8c82e0693 100644 --- a/src/qdoc/doc.cpp +++ b/src/qdoc/doc.cpp @@ -1350,20 +1350,16 @@ void DocParser::parse(const QString &source, } else if (macroHash()->contains(cmdStr)) { const Macro ¯o = macroHash()->value(cmdStr); int numPendingFi = 0; - QStringMap::ConstIterator d; int numFormatDefs = 0; QString matchExpr; - d = macro.otherDefs.constBegin(); - while (d != macro.otherDefs.constEnd()) { - if (d.key() == "match") { - matchExpr = d.value(); - ++d; + for (auto it = macro.otherDefs.constBegin(); it != macro.otherDefs.constEnd(); ++it) { + if (it.key() == "match") { + matchExpr = it.value(); } else { - append(Atom::FormatIf, d.key()); - expandMacro(cmdStr, *d, macro.numParams); - ++d; + append(Atom::FormatIf, it.key()); + expandMacro(cmdStr, *it, macro.numParams); ++numFormatDefs; - if (d == macro.otherDefs.constEnd()) { + if (it == macro.otherDefs.constEnd()) { append(Atom::FormatEndif); } else { append(Atom::FormatElse); @@ -1463,16 +1459,16 @@ void DocParser::parse(const QString &source, braceDepth--; pos++; - QMap<int, QString>::Iterator f = pendingFormats.find(braceDepth); - if (f == pendingFormats.end()) { + auto format = pendingFormats.find(braceDepth); + if (format == pendingFormats.end()) { enterPara(); appendChar('}'); } else { - append(Atom::FormattingRight, *f); - if (*f == ATOM_FORMATTING_INDEX) { + append(Atom::FormattingRight, *format); + if (*format == ATOM_FORMATTING_INDEX) { if (indexStartedPara) skipAllSpaces(); - } else if (*f == ATOM_FORMATTING_LINK) { + } else if (*format == ATOM_FORMATTING_LINK) { // hack for C++ to support links like // \l{QString::}{count()} if (currentLinkAtom && @@ -1483,7 +1479,7 @@ void DocParser::parse(const QString &source, } currentLinkAtom = nullptr; } - pendingFormats.erase(f); + pendingFormats.erase(format); } break; } @@ -1761,14 +1757,12 @@ void DocParser::startFormat(const QString &format, int cmd) { enterPara(); - QMap<int, QString>::ConstIterator f = pendingFormats.constBegin(); - while (f != pendingFormats.constEnd()) { - if (*f == format) { + for (const auto &item : qAsConst(pendingFormats)) { + if (item == format) { location().warning(tr("Cannot nest '\\%1' commands") .arg(cmdName(cmd))); return; } - ++f; } append(Atom::FormattingLeft, format); diff --git a/src/qdoc/editdistance.cpp b/src/qdoc/editdistance.cpp index c96071bf0..c8451f3c2 100644 --- a/src/qdoc/editdistance.cpp +++ b/src/qdoc/editdistance.cpp @@ -75,19 +75,17 @@ QString nearestName(const QString &actual, const QSet<QString> &candidates) int numBest = 0; QString best; - QSet<QString>::ConstIterator c = candidates.constBegin(); - while (c != candidates.constEnd()) { - if ((*c)[0] == actual[0]) { - int delta = editDistance(actual, *c); + for (const auto &candidate : candidates) { + if (candidate[0] == actual[0]) { + int delta = editDistance(actual, candidate); if (delta < deltaBest) { deltaBest = delta; numBest = 1; - best = *c; + best = candidate; } else if (delta == deltaBest) { numBest++; } } - ++c; } if (numBest == 1 && deltaBest <= 2 && actual.length() + best.length() >= 5) diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index 82d7c0127..0b2d24f27 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -145,12 +145,10 @@ void Generator::appendFullName(Text &text, void Generator::appendFullNames(Text &text, const NodeList &nodes, const Node *relative) { - NodeList::ConstIterator n = nodes.constBegin(); int index = 0; - while (n != nodes.constEnd()) { - appendFullName(text,*n,relative); + for (const auto &node : nodes) { + appendFullName(text, node, relative); text << comma(index++,nodes.count()); - ++n; } } @@ -177,13 +175,11 @@ void Generator::signatureList(const NodeList &nodes, const Node *relative, CodeM Text text; int count = 0; text << Atom(Atom::ListLeft, QString("bullet")); - NodeList::ConstIterator n = nodes.constBegin(); - while (n != nodes.constEnd()) { + for (const auto &node: nodes) { text << Atom(Atom::ListItemNumber, QString::number(++count)); text << Atom(Atom::ListItemLeft, QString("bullet")); - appendSignature(text, *n); + appendSignature(text, node); text << Atom(Atom::ListItemRight, QString("bullet")); - ++n; } text << Atom(Atom::ListRight, QString("bullet")); generateText(text, relative, marker); @@ -191,21 +187,17 @@ void Generator::signatureList(const NodeList &nodes, const Node *relative, CodeM int Generator::appendSortedNames(Text &text, const ClassNode *cn, const QList<RelatedClass> &rc) { - QList<RelatedClass>::ConstIterator r; QMap<QString,Text> classMap; - int index = 0; - - r = rc.constBegin(); - while (r != rc.constEnd()) { - ClassNode *rcn = (*r).node_; + for (const auto &relatedClass : rc) { + ClassNode *rcn = relatedClass.node_; if (rcn && rcn->isInAPI()) { Text className; appendFullName(className, rcn, cn); classMap[className.toString().toLower()] = className; } - ++r; } + int index = 0; const QStringList classNames = classMap.keys(); for (const auto &className : classNames) { text << classMap[className]; @@ -217,17 +209,17 @@ int Generator::appendSortedNames(Text &text, const ClassNode *cn, const QList<Re int Generator::appendSortedQmlNames(Text &text, const Node *base, const NodeList &subs) { QMap<QString,Text> classMap; - int index = 0; - for (int i = 0; i < subs.size(); ++i) { - Text t; - if (!base->isQtQuickNode() || !subs[i]->isQtQuickNode() || - (base->logicalModuleName() == subs[i]->logicalModuleName())) { - appendFullName(t, subs[i], base); - classMap[t.toString().toLower()] = t; + for (const auto sub : subs) { + Text text; + if (!base->isQtQuickNode() || !sub->isQtQuickNode() || + (base->logicalModuleName() == sub->logicalModuleName())) { + appendFullName(text, sub, base); + classMap[text.toString().toLower()] = text; } } + int index = 0; const QStringList names = classMap.keys(); for (const auto &name : names) { text << classMap[name]; @@ -887,65 +879,56 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) const EnumNode *enume = static_cast<const EnumNode *>(node); QSet<QString> definedItems; - QList<EnumItem>::ConstIterator it = enume->items().constBegin(); - while (it != enume->items().constEnd()) { - definedItems.insert((*it).name()); - ++it; - } + const QList<EnumItem> &items = enume->items(); + for (const auto &item : items) + definedItems.insert(item.name()); const auto &documentedItemList = enume->doc().enumItemNames(); QSet<QString> documentedItems(documentedItemList.cbegin(), documentedItemList.cend()); - QSet<QString> allItems = definedItems + documentedItems; + const QSet<QString> allItems = definedItems + documentedItems; if (allItems.count() > definedItems.count() || allItems.count() > documentedItems.count()) { - QSet<QString>::ConstIterator a = allItems.constBegin(); - while (a != allItems.constEnd()) { - if (!definedItems.contains(*a)) { + for (const auto &it : allItems) { + if (!definedItems.contains(it)) { QString details; - QString best = nearestName(*a, definedItems); + QString best = nearestName(it, definedItems); if (!best.isEmpty() && !documentedItems.contains(best)) details = tr("Maybe you meant '%1'?").arg(best); node->doc().location().warning(tr("No such enum item '%1' in %2") - .arg(*a).arg(node->plainFullName()), details); - } - else if (!documentedItems.contains(*a)) { + .arg(it).arg(node->plainFullName()), details); + } else if (!documentedItems.contains(it)) { node->doc().location().warning(tr("Undocumented enum item '%1' in %2") - .arg(*a).arg(node->plainFullName())); + .arg(it).arg(node->plainFullName())); } - ++a; } } } else if (node->isFunction()) { const FunctionNode *fn = static_cast<const FunctionNode *>(node); const QSet<QString> declaredNames = fn->parameters().getNames(); - QSet<QString> documentedNames = fn->doc().parameterNames(); + const QSet<QString> documentedNames = fn->doc().parameterNames(); if (declaredNames != documentedNames) { - QSet<QString>::const_iterator i = declaredNames.constBegin(); - while (i != declaredNames.constEnd()) { - if (!documentedNames.contains(*i)) { + for (const auto &name : declaredNames) { + if (!documentedNames.contains(name)) { if (fn->isActive() || fn->isPreliminary()) { if (!fn->isMarkedReimp() && !fn->isOverload()) { fn->doc().location().warning( tr("Undocumented parameter '%1' in %2") - .arg(*i).arg(node->plainFullName())); + .arg(name).arg(node->plainFullName())); } } } - ++i; } - i = documentedNames.constBegin(); - while (i != documentedNames.constEnd()) { - if (!declaredNames.contains(*i)) { - QString best = nearestName(*i, declaredNames); + for (const auto &name : documentedNames) { + if (!declaredNames.contains(name)) { + QString best = nearestName(name, declaredNames); QString details; if (!best.isEmpty()) details = tr("Maybe you meant '%1'?").arg(best); fn->doc().location().warning(tr("No such parameter '%1' in %2") - .arg(*i).arg(fn->plainFullName()), + .arg(name).arg(fn->plainFullName()), details); } - ++i; } } /* @@ -1123,9 +1106,6 @@ void Generator::generateInheritedBy(const ClassNode *classe, CodeMarker *marker) void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker) { - QList<RelatedClass>::ConstIterator r; - int index; - if (!classe->baseClasses().isEmpty()) { Text text; text << Atom::ParaLeft @@ -1133,21 +1113,20 @@ void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker) << "Inherits: " << Atom(Atom::FormattingRight,ATOM_FORMATTING_BOLD); - r = classe->baseClasses().constBegin(); - index = 0; - while (r != classe->baseClasses().constEnd()) { - if ((*r).node_) { - appendFullName(text, (*r).node_, classe); + int index = 0; + const QList<RelatedClass> &baseClasses = classe->baseClasses(); + for (const auto &cls : baseClasses) { + if (cls.node_) { + appendFullName(text, cls.node_, classe); - if ((*r).access_ == Node::Protected) { + if (cls.access_ == Node::Protected) { text << " (protected)"; } - else if ((*r).access_ == Node::Private) { + else if (cls.access_ == Node::Private) { text << " (private)"; } text << separator(index++, classe->baseClasses().count()); } - ++r; } text << Atom::ParaRight; generateText(text, classe, marker); @@ -1728,32 +1707,29 @@ void Generator::generateDocs() Generator *Generator::generatorForFormat(const QString &format) { - QList<Generator *>::ConstIterator g = generators.constBegin(); - while (g != generators.constEnd()) { - if ((*g)->format() == format) - return *g; - ++g; + for (const auto &generator : qAsConst(generators)) { + if (generator->format() == format) + return generator; } return nullptr; } /*! - Looks up the tag \a t in the map of metadata values for the + Looks up the tag \a tag in the map of metadata values for the current topic in \a inner. If a value for the tag is found, the value is returned. - \note If \a t is found in the metadata map, it is erased. - i.e. Once you call this function for a particular \a t, - you consume \a t. + \note If \a tag is found in the metadata map, it is erased. + i.e. Once you call this function for a particular \a tag, + you consume \a tag. */ -QString Generator::getMetadataElement(const Aggregate *inner, const QString &t) +QString Generator::getMetadataElement(const Aggregate *inner, const QString &tag) { QString s; - QStringMultiMap& metaTagMap = const_cast<QStringMultiMap&>(inner->doc().metaTagMap()); - QStringMultiMap::iterator i = metaTagMap.find(t); - if (i != metaTagMap.end()) { - s = i.value(); - metaTagMap.erase(i); + QStringMultiMap &metaTagMap = const_cast<QStringMultiMap &>(inner->doc().metaTagMap()); + for (auto it = metaTagMap.find(tag); it != metaTagMap.end();) { + s = it.value(); + metaTagMap.erase(it); } return s; } @@ -1986,11 +1962,8 @@ void Generator::augmentImageDirs(QSet<QString> &moreImageDirs) { if (moreImageDirs.isEmpty()) return; - QSet<QString>::const_iterator i = moreImageDirs.begin(); - while (i != moreImageDirs.end()) { - imageDirs.append(*i); - ++i; - } + for (const auto &it : moreImageDirs) + imageDirs.append(it); } /*! @@ -2243,11 +2216,9 @@ void Generator::supplementAlsoList(const Node *node, QList<Text> &alsoList) void Generator::terminate() { - QList<Generator *>::ConstIterator g = generators.constBegin(); - while (g != generators.constEnd()) { - if (outputFormats.contains((*g)->format())) - (*g)->terminateGenerator(); - ++g; + for (const auto &generator : qAsConst(generators)) { + if (outputFormats.contains(generator->format())) + generator->terminateGenerator(); } fmtLeftMaps.clear(); diff --git a/src/qdoc/helpprojectwriter.cpp b/src/qdoc/helpprojectwriter.cpp index 3d45b60a4..4ef77f06a 100644 --- a/src/qdoc/helpprojectwriter.cpp +++ b/src/qdoc/helpprojectwriter.cpp @@ -157,7 +157,7 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList NodeTypeSet fullSubset; - for (auto it = pageTypeHash.cbegin(), end = pageTypeHash.cend(); it != end; ++it) + for (auto it = pageTypeHash.constBegin(); it != pageTypeHash.constEnd(); ++it) fullSubset.insert(it.value()); for (const QString &selector : selectors) { @@ -689,8 +689,7 @@ void HelpProjectWriter::generateProject(HelpProject &project) writer.writeEndElement(); // Write customFilter elements. - QHash<QString, QSet<QString> >::ConstIterator it; - for (it = project.customFilters.constBegin(); it != project.customFilters.constEnd(); ++it) { + for (auto it = project.customFilters.constBegin(); it != project.customFilters.constEnd(); ++it) { writer.writeStartElement("customFilter"); writer.writeAttribute("name", it.key()); QStringList sortedAttributes = it.value().values(); diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index b994dfeea..95cf63bd7 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -199,10 +199,8 @@ void HtmlGenerator::initializeGenerator(const Config &config) if (naturalLanguage.isEmpty()) naturalLanguage = QLatin1String("en"); - QSet<QString> editionNames = config.subVars(CONFIG_EDITION); - QSet<QString>::ConstIterator edition = editionNames.constBegin(); - while (edition != editionNames.constEnd()) { - QString editionName = *edition; + const QSet<QString> editionNames = config.subVars(CONFIG_EDITION); + for (const auto &editionName : editionNames) { QStringList editionModules = config.getStringList(CONFIG_EDITION + Config::dot + editionName + @@ -218,8 +216,6 @@ void HtmlGenerator::initializeGenerator(const Config &config) editionModuleMap[editionName] = editionModules; if (!editionGroups.isEmpty()) editionGroupMap[editionName] = editionGroups; - - ++edition; } codeIndent = config.getInt(CONFIG_CODEINDENT); // QTBUG-27798 @@ -787,28 +783,26 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark Sections sections(nsmap); out() << "<ul>\n"; - QVector<Section>::ConstIterator s = sections.sinceSections().constBegin(); - while (s != sections.sinceSections().constEnd()) { - if (!s->members().isEmpty()) { + const QVector<Section> sinceSections = sections.sinceSections(); + for (const auto §ion : sinceSections) { + if (!section.members().isEmpty()) { out() << "<li>" << "<a href=\"#" - << Doc::canonicalTitle(s->title()) + << Doc::canonicalTitle(section.title()) << "\">" - << s->title() + << section.title() << "</a></li>\n"; } - ++s; } out() << "</ul>\n"; int idx = 0; - s = sections.sinceSections().constBegin(); - while (s != sections.sinceSections().constEnd()) { - if (!s->members().isEmpty()) { + for (const auto §ion : sinceSections) { + if (!section.members().isEmpty()) { out() << "<a name=\"" - << Doc::canonicalTitle(s->title()) + << Doc::canonicalTitle(section.title()) << "\"></a>\n"; - out() << "<h3>" << protectEnc(s->title()) << "</h3>\n"; + out() << "<h3>" << protectEnc(section.title()) << "</h3>\n"; if (idx == Sections::SinceClasses) generateCompactList(Generic, nullptr, ncmap, false, QStringLiteral("Q")); else if (idx == Sections::SinceQmlTypes) @@ -816,37 +810,33 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark else if (idx == Sections::SinceMemberFunctions) { ParentMaps parentmaps; ParentMaps::iterator pmap; - NodeVector::const_iterator i = s->members().constBegin(); - while (i != s->members().constEnd()) { - Node *p = (*i)->parent(); - pmap = parentmaps.find(p); + const QVector<Node *> members = section.members(); + for (const auto &member : members) { + Node *parent = (*member).parent(); + pmap = parentmaps.find(parent); if (pmap == parentmaps.end()) - pmap = parentmaps.insert(p,NodeMultiMap()); - pmap->insert((*i)->name(),(*i)); - ++i; + pmap = parentmaps.insert(parent,NodeMultiMap()); + pmap->insert(member->name(), member); } - pmap = parentmaps.begin(); - while (pmap != parentmaps.end()) { - NodeVector nv = pmap->values().toVector(); + for (auto map = parentmaps.begin(); map != parentmaps.end(); ++map) { + NodeVector nv = map->values().toVector(); out() << "<p>Class "; out() << "<a href=\"" - << linkForNode(pmap.key(), nullptr) + << linkForNode(map.key(), nullptr) << "\">"; - QStringList pieces = pmap.key()->fullName().split("::"); + QStringList pieces = map.key()->fullName().split("::"); out() << protectEnc(pieces.last()); out() << "</a>" << ":</p>\n"; generateSection(nv, nullptr, marker); out() << "<br/>"; - ++pmap; } + } else { + generateSection(section.members(), nullptr, marker); } - else - generateSection(s->members(), nullptr, marker); } ++idx; - ++s; } } break; @@ -1365,45 +1355,40 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m bool needOtherSection = false; - SectionVector::ConstIterator s = summarySections->constBegin(); - while (s != summarySections->constEnd()) { - if (s->members().isEmpty() && s->reimplementedMembers().isEmpty()) { - if (!s->inheritedMembers().isEmpty()) + for (const auto §ion : qAsConst(*summarySections)) { + if (section.members().isEmpty() && section.reimplementedMembers().isEmpty()) { + if (!section.inheritedMembers().isEmpty()) needOtherSection = true; - } - else { - if (!s->members().isEmpty()) { - QString ref = registerRef(s->title().toLower()); + } else { + if (!section.members().isEmpty()) { + QString ref = registerRef(section.title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateSection(s->members(), aggregate, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n"; + generateSection(section.members(), aggregate, marker); } - if (!s->reimplementedMembers().isEmpty()) { - QString name = QString("Reimplemented ") + s->title(); + if (!section.reimplementedMembers().isEmpty()) { + QString name = QString("Reimplemented ") + section.title(); QString ref = registerRef(name.toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; out() << "<h2 id=\"" << ref << "\">" << protectEnc(name) << "</h2>\n"; - generateSection(s->reimplementedMembers(), aggregate, marker); + generateSection(section.reimplementedMembers(), aggregate, marker); } - if (!s->inheritedMembers().isEmpty()) { + if (!section.inheritedMembers().isEmpty()) { out() << "<ul>\n"; - generateSectionInheritedList(*s, aggregate); + generateSectionInheritedList(section, aggregate); out() << "</ul>\n"; } } - ++s; } if (needOtherSection) { out() << "<h3>Additional Inherited Members</h3>\n" "<ul>\n"; - s = summarySections->constBegin(); - while (s != summarySections->constEnd()) { - if (s->members().isEmpty() && !s->inheritedMembers().isEmpty()) - generateSectionInheritedList(*s, aggregate); - ++s; + for (const auto §ion : qAsConst(*summarySections)) { + if (section.members().isEmpty() && !section.inheritedMembers().isEmpty()) + generateSectionInheritedList(section, aggregate); } out() << "</ul>\n"; } @@ -1427,42 +1412,38 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m generateExtractionMark(aggregate, EndMark); } - s = detailsSections->constBegin(); - while (s != detailsSections->constEnd()) { + for (const auto §ion :qAsConst(*detailsSections)) { bool headerGenerated = false; - if (s->isEmpty()) { - ++s; + if (section.isEmpty()) continue; - } - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - if ((*m)->access() == Node::Private) { // ### check necessary? - ++m; + + const QVector<Node *> members = section.members(); + for (const auto &member : members) { + if (member->access() == Node::Private) // ### check necessary? continue; - } if (!headerGenerated) { - if (!s->divClass().isEmpty()) - out() << "<div class=\"" << s->divClass() << "\">\n"; // QTBUG-9504 - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; + if (!section.divClass().isEmpty()) + out() << "<div class=\"" << section.divClass() << "\">\n"; // QTBUG-9504 + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; headerGenerated = true; } - if (!(*m)->isClassNode()) - generateDetailedMember(*m, aggregate, marker); + if (!member->isClassNode()) + generateDetailedMember(member, aggregate, marker); else { out() << "<h3> class "; - generateFullName(*m, aggregate); + generateFullName(member, aggregate); out() << "</h3>"; - generateBrief(*m, marker, aggregate); + generateBrief(member, marker, aggregate); } QStringList names; - names << (*m)->name(); - if ((*m)->isFunction()) { - const FunctionNode *func = reinterpret_cast<const FunctionNode *>(*m); + names << member->name(); + if (member->isFunction()) { + const FunctionNode *func = reinterpret_cast<const FunctionNode *>(member); if (func->isSomeCtor() || func->isDtor() || func->overloadNumber() != 0) names.clear(); - } else if ((*m)->isProperty()) { - const PropertyNode *prop = reinterpret_cast<const PropertyNode *>(*m); + } else if (member->isProperty()) { + const PropertyNode *prop = reinterpret_cast<const PropertyNode *>(member); if (!prop->getters().isEmpty() && !names.contains(prop->getters().first()->name())) names << prop->getters().first()->name(); @@ -1472,8 +1453,8 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m names << prop->resetters().first()->name(); if (!prop->notifiers().isEmpty()) names << prop->notifiers().first()->name(); - } else if ((*m)->isEnumType()) { - const EnumNode *enume = reinterpret_cast<const EnumNode *>(*m); + } else if (member->isEnumType()) { + const EnumNode *enume = reinterpret_cast<const EnumNode *>(member); if (enume->flagsType()) names << enume->flagsType()->name(); const auto &enumItemNameList = enume->doc().enumItemNames(); @@ -1485,11 +1466,9 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m enume)); } } - ++m; } - if (headerGenerated && !s->divClass().isEmpty()) + if (headerGenerated && !section.divClass().isEmpty()) out() << "</div>\n"; // QTBUG-9504 - ++s; } generateFooter(aggregate); } @@ -1514,16 +1493,14 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker) generateHeader(title, aggregate, marker); generateTitle(title, subtitleText, SmallSubTitle, aggregate, marker); generateBrief(aggregate, marker); - SectionVector::ConstIterator s = summarySections->constBegin(); - while (s != summarySections->constEnd()) { - if (!s->members().isEmpty()) { + for (auto it = summarySections->constBegin(); it != summarySections->constEnd(); ++it) { + if (!it->members().isEmpty()) { // out() << "<hr />\n"; - QString ref = registerRef(s->title().toLower()); + QString ref = registerRef(it->title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateSection(s->members(), aggregate, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(it->title()) << "</h2>\n"; + generateSection(it->members(), aggregate, marker); } - ++s; } QString detailsRef = registerRef("details"); @@ -1541,54 +1518,48 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker) generateExtractionMark(aggregate, EndMark); } - s = detailsSections->constBegin(); - while (s != detailsSections->constEnd()) { - if (s->isEmpty()) { - ++s; + for (const auto §ion : qAsConst(*detailsSections)) { + if (section.isEmpty()) continue; - } + //out() << "<hr />\n"; - if (!s->divClass().isEmpty()) - out() << "<div class=\"" << s->divClass() << "\">\n"; // QTBUG-9504 - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; - - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - if (!(*m)->isPrivate()) { // ### check necessary? - if (!(*m)->isClassNode()) - generateDetailedMember(*m, aggregate, marker); + if (!section.divClass().isEmpty()) + out() << "<div class=\"" << section.divClass() << "\">\n"; // QTBUG-9504 + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; + + const QVector<Node *> &members = section.members(); + for (const auto &member : members) { + if (!member->isPrivate()) { // ### check necessary? + if (!member->isClassNode()) + generateDetailedMember(member, aggregate, marker); else { out() << "<h3> class "; - generateFullName(*m, aggregate); + generateFullName(member, aggregate); out() << "</h3>"; - generateBrief(*m, marker, aggregate); + generateBrief(member, marker, aggregate); } QStringList names; - names << (*m)->name(); - if ((*m)->isFunction()) { - const FunctionNode *func = reinterpret_cast<const FunctionNode *>(*m); + names << member->name(); + if (member->isFunction()) { + const FunctionNode *func = reinterpret_cast<const FunctionNode *>(member); if (func->isSomeCtor() || func->isDtor() || func->overloadNumber() != 0) names.clear(); - } else if ((*m)->isEnumType()) { - const EnumNode *enume = reinterpret_cast<const EnumNode *>(*m); + } else if (member->isEnumType()) { + const EnumNode *enume = reinterpret_cast<const EnumNode *>(member); if (enume->flagsType()) names << enume->flagsType()->name(); const auto &enumItemNameList = enume->doc().enumItemNames(); const auto &omitEnumItemNameList = enume->doc().omitEnumItemNames(); const auto items = QSet<QString>(enumItemNameList.cbegin(), enumItemNameList.cend()) - QSet<QString>(omitEnumItemNameList.cbegin(), omitEnumItemNameList.cend()); - for (const QString &enumName : items) { - names << plainCode(marker->markedUpEnumValue(enumName, - enume)); - } + for (const QString &enumName : items) + names << plainCode(marker->markedUpEnumValue(enumName, enume)); } } - ++m; } - if (!s->divClass().isEmpty()) + if (!section.divClass().isEmpty()) out() << "</div>\n"; // QTBUG-9504 - ++s; } generateFooter(aggregate); } @@ -1631,16 +1602,15 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) out() << "</ul>\n"; } - SectionVector::ConstIterator s = sections.stdQmlTypeSummarySections().constBegin(); - while (s != sections.stdQmlTypeSummarySections().constEnd()) { - if (!s->isEmpty()) { - QString ref = registerRef(s->title().toLower()); + const QVector<Section> &stdQmlTypeSummarySections = sections.stdQmlTypeSummarySections(); + for (const auto §ion : stdQmlTypeSummarySections) { + if (!section.isEmpty()) { + QString ref = registerRef(section.title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateQmlSummary(s->members(), qcn, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n"; + generateQmlSummary(section.members(), qcn, marker); } - ++s; } generateExtractionMark(qcn, DetailedDescriptionMark); @@ -1655,18 +1625,16 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) generateExtractionMark(qcn, EndMark); //out() << "<hr />\n"; - s = sections.stdQmlTypeDetailsSections().constBegin(); - while (s != sections.stdQmlTypeDetailsSections().constEnd()) { - if (!s->isEmpty()) { - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - generateDetailedQmlMember(*m, qcn, marker); + const QVector<Section> &stdQmlTypeDetailsSections = sections.stdQmlTypeDetailsSections(); + for (const auto §ion : stdQmlTypeDetailsSections) { + if (!section.isEmpty()) { + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; + const QVector<Node *> members = section.members(); + for (const auto member : members) { + generateDetailedQmlMember(member, qcn, marker); out() << "<br/>\n"; - ++m; } } - ++s; } generateFooter(qcn); Generator::setQmlTypeContext(nullptr); @@ -1697,16 +1665,15 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode *qbtn, CodeMarker qbtn, marker); - SectionVector::const_iterator s = sections.stdQmlTypeSummarySections().constBegin(); - while (s != sections.stdQmlTypeSummarySections().constEnd()) { - if (!s->isEmpty()) { - QString ref = registerRef(s->title().toLower()); + const QVector<Section> &stdQmlTypeSummarySections = sections.stdQmlTypeSummarySections(); + for (const auto §ion : stdQmlTypeSummarySections) { + if (!section.isEmpty()) { + QString ref = registerRef(section.title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateQmlSummary(s->members(), qbtn, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n"; + generateQmlSummary(section.members(), qbtn, marker); } - ++s; } generateExtractionMark(qbtn, DetailedDescriptionMark); @@ -1717,18 +1684,16 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode *qbtn, CodeMarker generateAlsoList(qbtn, marker); generateExtractionMark(qbtn, EndMark); - s = sections.stdQmlTypeDetailsSections().constBegin(); - while (s != sections.stdQmlTypeDetailsSections().constEnd()) { - if (!s->isEmpty()) { - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - generateDetailedQmlMember(*m, qbtn, marker); + const QVector<Section> &stdQmlTypeDetailsSections = sections.stdQmlTypeDetailsSections(); + for (const auto §ion : stdQmlTypeDetailsSections) { + if (!section.isEmpty()) { + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; + const QVector<Node *> members = section.members(); + for (const auto member : members) { + generateDetailedQmlMember(member, qbtn, marker); out() << "<br/>\n"; - ++m; } } - ++s; } generateFooter(qbtn); } @@ -1861,11 +1826,9 @@ void HtmlGenerator::generateGenericCollectionPage(CollectionNode *cn, CodeMarker generateText(brief, cn, marker); out() << "</p>\n"; - NodeList::ConstIterator m = cn->members().constBegin(); - while (m != cn->members().constEnd()) { - generateDetailedMember(*m, cn, marker); - ++m; - } + const QList<Node *> members = cn->members(); + for (const auto &member : members) + generateDetailedMember(member, cn, marker); // generateAnnotatedList(cn, marker, cn->members()); generateFooter(cn); @@ -2254,25 +2217,22 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker) } //add the inherits to the map - QList<RelatedClass>::ConstIterator r; - int index; if (!classe->baseClasses().isEmpty()) { + int index = 0; text.clear(); - r = classe->baseClasses().constBegin(); - index = 0; - while (r != classe->baseClasses().constEnd()) { - if ((*r).node_) { - appendFullName(text, (*r).node_, classe); + const auto baseClasses = classe->baseClasses(); + for (const auto &cls : baseClasses) { + if (cls.node_) { + appendFullName(text, cls.node_, classe); - if ((*r).access_ == Node::Protected) { + if (cls.access_ == Node::Protected) { text << " (protected)"; } - else if ((*r).access_ == Node::Private) { + else if (cls.access_ == Node::Private) { text << " (private)"; } text << comma(index++, classe->baseClasses().count()); } - ++r; } text << Atom::ParaRight; if (index > 0) @@ -2294,19 +2254,18 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker) //generate the table out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; - QStringList::ConstIterator i; - for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { + for (auto it = requisiteorder.constBegin(); it != requisiteorder.constEnd(); ++it) { - if (requisites.contains(*i)) { + if (requisites.contains(*it)) { out() << "<tr>" << "<td class=\"memItemLeft rightAlign topAlign\"> " - << *i << ":" + << *it << ":" "</td><td class=\"memItemRight bottomAlign\"> "; - if (*i == headerText) - out() << requisites.value(*i).toString(); + if (*it == headerText) + out() << requisites.value(*it).toString(); else - generateText(requisites.value(*i), aggregate, marker); + generateText(requisites.value(*it), aggregate, marker); out() << "</td></tr>"; } } @@ -2331,14 +2290,6 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) const QString inheritsText = "Inherits:"; const QString instantiatesText = "Instantiates:"; - //The order of the requisites matter - QStringList requisiteorder; - requisiteorder << importText - << sinceText - << instantiatesText - << inheritsText - << inheritedBytext; - //add the module name and version to the map QString logicalModuleVersion; const CollectionNode *collection = qdb_->getCollectionNode(qcn->logicalModuleName(), qcn->nodeType()); @@ -2414,23 +2365,29 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) requisites.insert(inheritedBytext, text); } + //The order of the requisites matter + const QStringList requisiteorder { + importText, + sinceText, + instantiatesText, + inheritsText, + inheritedBytext }; + if (!requisites.isEmpty()) { //generate the table out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; + for (const auto &requisite : requisiteorder) { - QStringList::ConstIterator i; - for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { - - if (requisites.contains(*i)) { + if (requisites.contains(requisite)) { out() << "<tr>" << "<td class=\"memItemLeft rightAlign topAlign\"> " - << *i + << requisite << "</td><td class=\"memItemRight bottomAlign\"> "; - if (*i == importText) - out()<<requisites.value(*i).toString(); + if (requisite == importText) + out()<<requisites.value(requisite).toString(); else - generateText(requisites.value(*i), qcn, marker); + generateText(requisites.value(requisite), qcn, marker); out() << "</td></tr>"; } } @@ -2524,26 +2481,24 @@ void HtmlGenerator::generateTableOfContents(const Node *node, node->isNamespace() || node->isQmlType() || node->isJsType())) { - SectionVector::ConstIterator s = sections->constBegin(); - while (s != sections->constEnd()) { - if (!s->members().isEmpty()) { + for (const auto §ion : qAsConst(*sections)) { + if (!section.members().isEmpty()) { out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" - << registerRef(s->plural()) - << "\">" << s->title() + << registerRef(section.plural()) + << "\">" << section.title() << "</a></li>\n"; } - if (!s->reimplementedMembers().isEmpty()) { - QString ref = QString("Reimplemented ") + s->plural(); + if (!section.reimplementedMembers().isEmpty()) { + QString ref = QString("Reimplemented ") + section.plural(); out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" << registerRef(ref.toLower()) - << "\">" << QString("Reimplemented ") + s->title() + << "\">" << QString("Reimplemented ") + section.title() << "</a></li>\n"; } - ++s; } if (!node->isNamespace() || node->hasDoc()) { out() << "<li class=\"level" @@ -2560,8 +2515,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, } } - for (int i = 0; i < toc.size(); ++i) { - const Atom *atom = toc.at(i); + for (const auto &atom : toc) { sectionNumber = atom->string().toInt() + detailsBase; //restrict the ToC depth to the one set by the HTML.tocdepth variable or //print all levels if tocDepth is not set. @@ -2722,22 +2676,18 @@ QString HtmlGenerator::generateObsoleteMembersFile(const Sections §ions, Cod << "They are provided to keep old source code working. " << "We strongly advise against using them in new code.</p>\n"; - for (int i = 0; i < summary_spv.size(); ++i) { - out() << "<h2>" << protectEnc(summary_spv.at(i)->title()) << "</h2>\n"; - const Section §ion = *summary_spv.at(i); - generateSectionList(section, aggregate, marker, Section::Obsolete); + for (const auto §ion : summary_spv) { + out() << "<h2>" << protectEnc(section->title()) << "</h2>\n"; + generateSectionList(*section, aggregate, marker, Section::Obsolete); } - for (int i = 0; i < details_spv.size(); ++i) { - //out() << "<hr />\n"; - out() << "<h2>" << protectEnc(details_spv.at(i)->title()) << "</h2>\n"; + for (const auto §ion : details_spv) { + out() << "<h2>" << protectEnc(section->title()) << "</h2>\n"; - const NodeVector &members = details_spv.at(i)->obsoleteMembers(); - NodeVector::ConstIterator m = members.constBegin(); - while (m != members.constEnd()) { - if ((*m)->access() != Node::Private) - generateDetailedMember(*m, aggregate, marker); - ++m; + const NodeVector &members = section->obsoleteMembers(); + for (const auto &member : members) { + if (member->access() != Node::Private) + generateDetailedMember(member, aggregate, marker); } } @@ -2782,22 +2732,20 @@ QString HtmlGenerator::generateObsoleteQmlMembersFile(const Sections §ions, << "They are provided to keep old source code working. " << "We strongly advise against using them in new code.</p>\n"; - for (int i = 0; i < summary_spv.size(); ++i) { - QString ref = registerRef(summary_spv.at(i)->title().toLower()); + for (const auto §ion : summary_spv) { + QString ref = registerRef(section->title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(summary_spv.at(i)->title()) << "</h2>\n"; - generateQmlSummary(summary_spv.at(i)->obsoleteMembers(), aggregate, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section->title()) << "</h2>\n"; + generateQmlSummary(section->obsoleteMembers(), aggregate, marker); } - for (int i = 0; i < details_spv.size(); ++i) { - out() << "<h2>" << protectEnc(details_spv.at(i)->title()) << "</h2>\n"; - const NodeVector &members = details_spv.at(i)->obsoleteMembers(); - NodeVector::ConstIterator m = members.constBegin(); - while (m != members.constEnd()) { - generateDetailedQmlMember(*m, aggregate, marker); + for (const auto §ion : details_spv) { + out() << "<h2>" << protectEnc(section->title()) << "</h2>\n"; + const NodeVector &members = section->obsoleteMembers(); + for (const auto &member : members) { + generateDetailedQmlMember(member, aggregate, marker); out() << "<br/>\n"; - ++m; } } @@ -2812,12 +2760,10 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, NodeMap &classM return; NodeMap topLevel; - NodeMap::Iterator c = classMap.begin(); - while (c != classMap.end()) { - ClassNode *classe = static_cast<ClassNode *>(*c); + for (auto it = classMap.begin(); it != classMap.end(); ++it) { + ClassNode *classe = static_cast<ClassNode *>(*it); if (classe->baseClasses().isEmpty()) topLevel.insert(classe->name(), classe); - ++c; } QStack<NodeMap > stack; @@ -2970,8 +2916,7 @@ void HtmlGenerator::generateCompactList(ListType listType, QString paragraphName[NumParagraphs+1]; QSet<char> usedParagraphNames; - NodeMultiMap::ConstIterator c = nmm.constBegin(); - while (c != nmm.constEnd()) { + for (auto c = nmm.constBegin(); c != nmm.constEnd(); ++c) { QStringList pieces = c.key().split("::"); int idx = commonPrefixLen; if (idx > 0 && !pieces.last().startsWith(commonPrefix, Qt::CaseInsensitive)) @@ -2991,7 +2936,6 @@ void HtmlGenerator::generateCompactList(ListType listType, paragraphName[paragraphNr] = key[0].toUpper(); usedParagraphNames.insert(key[0].toLower().cell()); paragraph[paragraphNr].insert(last, c.value()); - ++c; } /* @@ -3136,26 +3080,22 @@ void HtmlGenerator::generateFunctionIndex(const Node *relative) out() << "<ul>\n"; NodeMapMap &funcIndex = qdb_->getFunctionIndex(); - QMap<QString, NodeMap >::ConstIterator f = funcIndex.constBegin(); - while (f != funcIndex.constEnd()) { + for (auto fnMap = funcIndex.constBegin(); fnMap != funcIndex.constEnd(); ++fnMap) { out() << "<li>"; - out() << protectEnc(f.key()) << ':'; + out() << protectEnc(fnMap.key()) << ':'; - currentLetter = f.key()[0].unicode(); + currentLetter = fnMap.key()[0].unicode(); while (islower(currentLetter) && currentLetter >= nextLetter) { out() << QString("<a name=\"%1\"></a>").arg(nextLetter); nextLetter++; } - NodeMap::ConstIterator s = (*f).constBegin(); - while (s != (*f).constEnd()) { + for (auto it = (*fnMap).constBegin(); it != (*fnMap).constEnd(); ++it) { out() << ' '; - generateFullName((*s)->parent(), relative, *s); - ++s; + generateFullName((*it)->parent(), relative, *it); } out() << "</li>"; out() << '\n'; - ++f; } out() << "</ul>\n"; } @@ -3294,12 +3234,9 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, } int i = 0; - NodeVector::ConstIterator m = nv.constBegin(); - while (m != nv.constEnd()) { - if ((*m)->access() == Node::Private) { - ++m; + for (const auto &member : nv) { + if (member->access() == Node::Private) continue; - } if (alignNames) { out() << "<tr><td class=\"memItemLeft rightAlign topAlign\"> "; @@ -3310,13 +3247,12 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, out() << "<li class=\"fn\">"; } - generateSynopsis(*m, relative, marker, Section::Summary, alignNames); + generateSynopsis(member, relative, marker, Section::Summary, alignNames); if (alignNames) out() << "</td></tr>\n"; else out() << "</li>\n"; i++; - ++m; } if (alignNames) out() << "</table></div>\n"; @@ -3357,12 +3293,9 @@ void HtmlGenerator::generateSectionList(const Section& section, } int i = 0; - NodeVector::ConstIterator m = members.constBegin(); - while (m != members.constEnd()) { - if ((*m)->access() == Node::Private) { - ++m; + for (const auto &member : members) { + if (member->access() == Node::Private) continue; - } if (alignNames) { out() << "<tr><td class=\"memItemLeft topAlign rightAlign\"> "; @@ -3379,9 +3312,9 @@ void HtmlGenerator::generateSectionList(const Section& section, prefix = keys.at(i).mid(1); prefix = prefix.left(keys.at(i).indexOf("::") + 1); } - generateSynopsis(*m, relative, marker, section.style(), alignNames, &prefix); - if ((*m)->isFunction()) { - const FunctionNode *fn = static_cast<const FunctionNode *>(*m); + generateSynopsis(member, relative, marker, section.style(), alignNames, &prefix); + if (member->isFunction()) { + const FunctionNode *fn = static_cast<const FunctionNode *>(member); if (fn->isPrivateSignal()) { hasPrivateSignals = true; if (alignNames) @@ -3398,7 +3331,6 @@ void HtmlGenerator::generateSectionList(const Section& section, else out() << "</li>\n"; i++; - ++m; } if (alignNames) out() << "</table></div>\n"; @@ -3422,21 +3354,20 @@ void HtmlGenerator::generateSectionList(const Section& section, void HtmlGenerator::generateSectionInheritedList(const Section& section, const Node *relative) { - QList<QPair<Aggregate *, int> >::ConstIterator p = section.inheritedMembers().constBegin(); - while (p != section.inheritedMembers().constEnd()) { + const QList<QPair<Aggregate *, int>> &inheritedMembers = section.inheritedMembers(); + for (const auto &member : inheritedMembers) { out() << "<li class=\"fn\">"; - out() << (*p).second << ' '; - if ((*p).second == 1) { + out() << member.second << ' '; + if (member.second == 1) { out() << section.singular(); } else { out() << section.plural(); } - out() << " inherited from <a href=\"" << fileName((*p).first) + out() << " inherited from <a href=\"" << fileName(member.first) << '#' << Generator::cleanRef(section.title().toLower()) << "\">" - << protectEnc((*p).first->plainFullName(relative)) + << protectEnc(member.first->plainFullName(relative)) << "</a></li>\n"; - ++p; } } @@ -3918,28 +3849,25 @@ void HtmlGenerator::generateQmlSummary(const NodeVector &members, { if (!members.isEmpty()) { out() << "<ul>\n"; - NodeVector::const_iterator m = members.constBegin(); - while (m != members.constEnd()) { + for (const auto &member : members) { out() << "<li class=\"fn\">"; - generateQmlItem(*m, relative, marker, true); - if ((*m)->isPropertyGroup()) { - const SharedCommentNode *scn = static_cast<const SharedCommentNode *>(*m); + generateQmlItem(member, relative, marker, true); + if (member->isPropertyGroup()) { + const SharedCommentNode *scn = static_cast<const SharedCommentNode *>(member); if (scn->count() > 0) { - QVector<Node *>::ConstIterator p = scn->collective().constBegin(); out() << "<ul>\n"; - while (p != scn->collective().constEnd()) { - if ((*p)->isQmlProperty() || (*p)->isJsProperty()) { + const QVector<Node *> sharedNodes = scn->collective(); + for (const auto &node : sharedNodes) { + if (node->isQmlProperty() || node->isJsProperty()) { out() << "<li class=\"fn\">"; - generateQmlItem(*p, relative, marker, true); + generateQmlItem(node, relative, marker, true); out() << "</li>\n"; } - ++p; } out() << "</ul>\n"; } } out() << "</li>\n"; - ++m; } out() << "</ul>\n"; } @@ -3973,7 +3901,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, QString nodeRef; if (node->isPropertyGroup()) { const SharedCommentNode *scn = static_cast<const SharedCommentNode*>(node); - QVector<Node *>::ConstIterator p = scn->collective().constBegin(); out() << "<div class=\"qmlproto\">"; out() << "<div class=\"table\"><table class=\"qmlname\">"; if (!scn->name().isEmpty()) { @@ -3985,9 +3912,10 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, out() << "<b>" << heading << "</b>"; out() << "</p></th></tr>"; } - while (p != scn->collective().constEnd()) { - if ((*p)->isQmlProperty() || (*p)->isJsProperty()) { - qpn = static_cast<QmlPropertyNode *>(*p); + const QVector<Node *> sharedNodes = scn->collective(); + for (const auto &node : sharedNodes) { + if (node->isQmlProperty() || node->isJsProperty()) { + qpn = static_cast<QmlPropertyNode *>(node); nodeRef = refForNode(qpn); out() << "<tr valign=\"top\" class=\"odd\" id=\"" << nodeRef << "\">"; out() << "<td class=\"tblQmlPropNode\"><p>"; @@ -4000,7 +3928,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, generateQmlItem(qpn, relative, marker, false); out() << "</p></td></tr>"; } - ++p; } out() << "</table></div>"; out() << "</div>"; @@ -4023,19 +3950,19 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, out() << qmlItemFooter; } else if (node->isSharedCommentNode()) { const SharedCommentNode *scn = reinterpret_cast<const SharedCommentNode *>(node); - const QVector<Node *> &collective = scn->collective(); - if (collective.size() > 1) + const QVector<Node *> &sharedNodes = scn->collective(); + if (sharedNodes.size() > 1) out() << "<div class=\"fngroup\">\n"; out() << qmlItemHeader; - for (const auto m : collective) { - if (m->isFunction(Node::QML) || m->isFunction(Node::JS)) { - out() << qmlItemStart.arg(nodeRef, "tblQmlFuncNode", refForNode(m)); - generateSynopsis(m, relative, marker, Section::Details, false); + for (const auto &node : sharedNodes) { + if (node->isFunction(Node::QML) || node->isFunction(Node::JS)) { + out() << qmlItemStart.arg(nodeRef, "tblQmlFuncNode", refForNode(node)); + generateSynopsis(node, relative, marker, Section::Details, false); out() << qmlItemEnd; } } out() << qmlItemFooter; - if (collective.size() > 1) + if (sharedNodes.size() > 1) out() << "</div>"; } else { // assume the node is a method/signal handler out() << qmlItemHeader; @@ -4212,9 +4139,8 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString demos = true; bool proceed = false; - ExampleNodeMap::Iterator i = exampleNodeMap.begin(); - while (i != exampleNodeMap.end()) { - const ExampleNode *en = i.value(); + for (auto map = exampleNodeMap.begin(); map != exampleNodeMap.end(); ++map) { + const ExampleNode *en = map.value(); if (demos) { if (en->name().startsWith("demos")) { proceed = true; @@ -4225,7 +4151,6 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString proceed = true; break; } - ++i; } if (!proceed || !file.open(QFile::WriteOnly | QFile::Text)) return; @@ -4238,17 +4163,12 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString writer.writeStartElement(manifest); QStringList usedAttributes; - i = exampleNodeMap.begin(); - while (i != exampleNodeMap.end()) { - const ExampleNode *en = i.value(); + for (auto map = exampleNodeMap.begin(); map != exampleNodeMap.end(); ++map) { + const ExampleNode *en = map.value(); if (demos) { - if (!en->name().startsWith("demos")) { - ++i; + if (!en->name().startsWith("demos")) continue; - } - } - else if (en->name().startsWith("demos")) { - ++i; + } else if (en->name().startsWith("demos")) { continue; } // attributes that are always written for the element @@ -4423,8 +4343,7 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString } } - QMap<int, QString>::const_iterator it = filesToOpen.constEnd(); - while (it != filesToOpen.constBegin()) { + for (auto it = filesToOpen.constEnd(); it != filesToOpen.constBegin(); ) { writer.writeStartElement("fileToOpen"); if (--it == filesToOpen.constBegin()) { writer.writeAttribute(QStringLiteral("mainFile"), QStringLiteral("true")); @@ -4434,7 +4353,6 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString } writer.writeEndElement(); // example - ++i; } writer.writeEndElement(); // examples diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index a681231b5..73289986c 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -292,13 +292,12 @@ static void processQdocconfFile(const QString &fileName, Config &config) but only if they haven't already been loaded. This works in both -prepare/-generate mode and -singleexec mode. */ - QStringList fileNames = config.getStringList(CONFIG_TRANSLATORS); - QStringList::ConstIterator fn = fileNames.constBegin(); - while (fn != fileNames.constEnd()) { + const QStringList fileNames = config.getStringList(CONFIG_TRANSLATORS); + for (const auto &fileName : fileNames) { bool found = false; if (!translators.isEmpty()) { for (int i=0; i<translators.size(); ++i) { - if (translators.at(i).first == *fn) { + if (translators.at(i).first == fileName) { found = true; break; } @@ -306,15 +305,14 @@ static void processQdocconfFile(const QString &fileName, Config &config) } if (!found) { QTranslator *translator = new QTranslator(nullptr); - if (!translator->load(*fn)) { - config.lastLocation().error(QCoreApplication::translate("QDoc", "Cannot load translator '%1'").arg(*fn)); + if (!translator->load(fileName)) { + config.lastLocation().error(QCoreApplication::translate("QDoc", "Cannot load translator '%1'").arg(fileName)); } else { QCoreApplication::instance()->installTranslator(translator); - translators.append(Translator(*fn, translator)); + translators.append(Translator(fileName, translator)); } } - ++fn; } #endif @@ -452,15 +450,13 @@ static void processQdocconfFile(const QString &fileName, Config &config) qCDebug(lcQdoc, "Parsing header files"); int parsed = 0; - QMap<QString,QString>::ConstIterator h = headers.constBegin(); - while (h != headers.constEnd()) { - CodeParser *codeParser = CodeParser::parserForHeaderFile(h.key()); + for (auto it = headers.constBegin(); it != headers.constEnd(); ++it) { + CodeParser *codeParser = CodeParser::parserForHeaderFile(it.key()); if (codeParser) { ++parsed; - qCDebug(lcQdoc, "Parsing %s", qPrintable(h.key())); - codeParser->parseHeaderFile(config.location(), h.key()); + qCDebug(lcQdoc, "Parsing %s", qPrintable(it.key())); + codeParser->parseHeaderFile(config.location(), it.key()); } - ++h; } clangParser_->precompileHeaders(); @@ -471,15 +467,13 @@ static void processQdocconfFile(const QString &fileName, Config &config) */ parsed = 0; Location::logToStdErrAlways("Parse source files for " + project); - QMap<QString,QString>::ConstIterator s = sources.constBegin(); - while (s != sources.constEnd()) { - CodeParser *codeParser = CodeParser::parserForSourceFile(s.key()); + for (const auto &key : sources.keys()) { + auto *codeParser = CodeParser::parserForSourceFile(key); if (codeParser) { ++parsed; - qCDebug(lcQdoc, "Parsing %s", qPrintable(s.key())); - codeParser->parseSourceFile(config.location(), s.key()); + qCDebug(lcQdoc, "Parsing %s", qPrintable(key)); + codeParser->parseSourceFile(config.location(), key); } - ++s; } Location::logToStdErrAlways("Source files parsed for " + project); } @@ -499,15 +493,13 @@ static void processQdocconfFile(const QString &fileName, Config &config) one. */ qCDebug(lcQdoc, "Generating docs"); - QSet<QString>::ConstIterator of = outputFormats.constBegin(); - while (of != outputFormats.constEnd()) { - Generator *generator = Generator::generatorForFormat(*of); + for (const auto &format : outputFormats) { + auto *generator = Generator::generatorForFormat(format); if (generator == nullptr) outputFormatsLocation.fatal(QCoreApplication::translate("QDoc", - "Unknown output format '%1'").arg(*of)); + "Unknown output format '%1'").arg(format)); generator->initializeFormat(config); generator->generateDocs(); - ++of; } qdb->clearLinkCounts(); diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 0f3098a04..054b6697f 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -2035,16 +2035,16 @@ void Aggregate::findChildren(const QString &name, NodeVector &nodes) const { nodes.clear(); int nonfunctionCount = nonfunctionMap_.count(name); - FunctionMap::const_iterator i = functionMap_.find(name); - if (i != functionMap_.end()) { + auto it = functionMap_.find(name); + if (it != functionMap_.end()) { int functionCount = 0; - FunctionNode *fn = i.value(); + FunctionNode *fn = it.value(); while (fn != nullptr) { ++functionCount; fn = fn->nextOverload(); } nodes.reserve(nonfunctionCount + functionCount); - fn = i.value(); + fn = it.value(); while (fn != nullptr) { nodes.append(fn); fn = fn->nextOverload(); @@ -2053,10 +2053,9 @@ void Aggregate::findChildren(const QString &name, NodeVector &nodes) const nodes.reserve(nonfunctionCount); } if (nonfunctionCount > 0) { - NodeMap::const_iterator i = nonfunctionMap_.find(name); - while (i != nonfunctionMap_.end() && i.key() == name) { - nodes.append(i.value()); - ++i; + for (auto it = nonfunctionMap_.find(name); + it != nonfunctionMap_.end() && it.key() == name; ++it) { + nodes.append(it.value()); } } } @@ -2088,10 +2087,10 @@ Node *Aggregate::findNonfunctionChild(const QString &name, bool (Node::*isMatch) */ FunctionNode *Aggregate::findFunctionChild(const QString &name, const Parameters ¶meters) { - FunctionMap::iterator i = functionMap_.find(name); - if (i == functionMap_.end()) + auto it = functionMap_.find(name); + if (it == functionMap_.end()) return nullptr; - FunctionNode *fn = i.value(); + FunctionNode *fn = it.value(); if (parameters.isEmpty() && fn->parameters().isEmpty() && !fn->isInternal()) return fn; @@ -2114,10 +2113,10 @@ FunctionNode *Aggregate::findFunctionChild(const QString &name, const Parameters } if (parameters.isEmpty()) { - for (fn = i.value(); fn != nullptr; fn = fn->nextOverload()) + for (fn = it.value(); fn != nullptr; fn = fn->nextOverload()) if (!fn->isInternal()) return fn; - return i.value(); + return it.value(); } return nullptr; } @@ -2184,14 +2183,13 @@ void Aggregate::normalizeOverloads() Ensure that none of the primary functions is inactive, private, or marked \e {overload}. */ - FunctionMap::Iterator i = functionMap_.begin(); - while (i != functionMap_.end()) { - FunctionNode *fn = i.value(); + for (auto it = functionMap_.begin(); it != functionMap_.end(); ++it) { + FunctionNode *fn = it.value(); if (fn->isOverload()) { FunctionNode *primary = fn->findPrimaryFunction(); if (primary) { primary->setNextOverload(fn); - i.value() = primary; + it.value() = primary; fn = primary; } else { fn->clearOverloadFlag(); @@ -2222,7 +2220,7 @@ void Aggregate::normalizeOverloads() internalFn->setOverloadNumber(++count); internalFn = internalFn->nextOverload(); } - ++i; // process next function in function map. + // process next function in function map. } /* Recursive part. @@ -2362,11 +2360,11 @@ bool Aggregate::isSameSignature(const FunctionNode *f1, const FunctionNode *f2) */ void Aggregate::addFunction(FunctionNode *fn) { - FunctionMap::iterator i = functionMap_.find(fn->name()); - if (i == functionMap_.end()) + auto it = functionMap_.find(fn->name()); + if (it == functionMap_.end()) functionMap_.insert(fn->name(), fn); else - i.value()->appendOverload(fn); + it.value()->appendOverload(fn); functionCount_++; } @@ -2382,8 +2380,8 @@ void Aggregate::addFunction(FunctionNode *fn) */ void Aggregate::adoptFunction(FunctionNode *fn) { - FunctionMap::iterator i = functionMap_.find(fn->name()); - if (i == functionMap_.end()) + auto it = functionMap_.find(fn->name()); + if (it == functionMap_.end()) functionMap_.insert(fn->name(), fn); functionCount_++; } @@ -2530,8 +2528,8 @@ QmlPropertyNode *Aggregate::hasQmlProperty(const QString &n, bool attached) cons */ bool Aggregate::hasOverloads(const FunctionNode *fn) const { - FunctionMap::const_iterator i = functionMap_.find(fn->name()); - return (i == functionMap_.end() ? false : (i.value()->nextOverload() != nullptr)); + auto it = functionMap_.find(fn->name()); + return (it == functionMap_.end() ? false : (it.value()->nextOverload() != nullptr)); } /*! @@ -2565,19 +2563,19 @@ void Aggregate::printChildren(const QString &title) */ void Aggregate::removeFunctionNode(FunctionNode *fn) { - FunctionMap::Iterator i = functionMap_.find(fn->name()); - if (i != functionMap_.end()) { - if (i.value() == fn) { + auto it = functionMap_.find(fn->name()); + if (it != functionMap_.end()) { + if (it.value() == fn) { if (fn->nextOverload() != nullptr) { - i.value() = fn->nextOverload(); + it.value() = fn->nextOverload(); fn->setNextOverload(nullptr); fn->setOverloadNumber(0); } else { - functionMap_.erase(i); + functionMap_.erase(it); } } else { - FunctionNode *current = i.value(); + FunctionNode *current = it.value(); while (current != nullptr) { if (current->nextOverload() == fn) { current->setNextOverload(fn->nextOverload()); @@ -2620,9 +2618,8 @@ static bool keep(FunctionNode *fn) */ void Aggregate::findAllFunctions(NodeMapMap &functionIndex) { - FunctionMap::const_iterator i; - for (i = functionMap_.constBegin(); i != functionMap_.constEnd(); ++i) { - FunctionNode *fn = i.value(); + for (auto it = functionMap_.constBegin(); it != functionMap_.constEnd(); ++it) { + FunctionNode *fn = it.value(); if (keep(fn)) functionIndex[fn->name()].insert(fn->parent()->fullDocumentName(), fn); fn = fn->nextOverload(); @@ -2771,15 +2768,15 @@ void Aggregate::findAllSince() QString sinceString = node->since(); // Insert a new entry into each map for each new since string found. if (!node->isPrivate() && !sinceString.isEmpty()) { - NodeMultiMapMap::iterator nsmap = QDocDatabase::newSinceMaps().find(sinceString); + auto nsmap = QDocDatabase::newSinceMaps().find(sinceString); if (nsmap == QDocDatabase::newSinceMaps().end()) nsmap = QDocDatabase::newSinceMaps().insert(sinceString, NodeMultiMap()); - NodeMapMap::iterator ncmap = QDocDatabase::newClassMaps().find(sinceString); + auto ncmap = QDocDatabase::newClassMaps().find(sinceString); if (ncmap == QDocDatabase::newClassMaps().end()) ncmap = QDocDatabase::newClassMaps().insert(sinceString, NodeMap()); - NodeMapMap::iterator nqcmap = QDocDatabase::newQmlTypeMaps().find(sinceString); + auto nqcmap = QDocDatabase::newQmlTypeMaps().find(sinceString); if (nqcmap == QDocDatabase::newQmlTypeMaps().end()) nqcmap = QDocDatabase::newQmlTypeMaps().insert(sinceString, NodeMap()); @@ -2995,9 +2992,8 @@ void ClassNode::removePrivateAndInternalBases() */ void ClassNode::resolvePropertyOverriddenFromPtrs(PropertyNode *pn) { - QList<RelatedClass>::const_iterator bc = baseClasses().constBegin(); - while (bc != baseClasses().constEnd()) { - ClassNode *cn = bc->node_; + for (const auto &baseClass : qAsConst(baseClasses())) { + ClassNode *cn = baseClass.node_; if (cn) { Node *n = cn->findNonfunctionChild(pn->name(), &Node::isProperty); if (n) { @@ -3008,7 +3004,6 @@ void ClassNode::resolvePropertyOverriddenFromPtrs(PropertyNode *pn) else cn->resolvePropertyOverriddenFromPtrs(pn); } - ++bc; } } @@ -3451,12 +3446,11 @@ QmlTypeNode *ClassNode::findQmlBaseNode() */ FunctionNode *ClassNode::findOverriddenFunction(const FunctionNode *fn) { - QList<RelatedClass>::Iterator bc = bases_.begin(); - while (bc != bases_.end()) { - ClassNode *cn = bc->node_; + for (auto &bc : bases_) { + ClassNode *cn = bc.node_; if (cn == nullptr) { - cn = QDocDatabase::qdocDB()->findClassNode(bc->path_); - bc->node_ = cn; + cn = QDocDatabase::qdocDB()->findClassNode(bc.path_); + bc.node_ = cn; } if (cn != nullptr) { FunctionNode *result = cn->findFunctionChild(fn); @@ -3466,7 +3460,6 @@ FunctionNode *ClassNode::findOverriddenFunction(const FunctionNode *fn) if (result != nullptr && !result->isNonvirtual()) return result; } - ++bc; } return nullptr; } @@ -3480,31 +3473,27 @@ FunctionNode *ClassNode::findOverriddenFunction(const FunctionNode *fn) */ PropertyNode *ClassNode::findOverriddenProperty(const FunctionNode *fn) { - QList<RelatedClass>::Iterator bc = bases_.begin(); - while (bc != bases_.end()) { - ClassNode *cn = bc->node_; + for (auto &baseClass : bases_) { + ClassNode *cn = baseClass.node_; if (cn == nullptr) { - cn = QDocDatabase::qdocDB()->findClassNode(bc->path_); - bc->node_ = cn; + cn = QDocDatabase::qdocDB()->findClassNode(baseClass.path_); + baseClass.node_ = cn; } if (cn != nullptr) { const NodeList &children = cn->childNodes(); - NodeList::const_iterator i = children.begin(); - while (i != children.end()) { - if ((*i)->isProperty()) { - PropertyNode *pn = static_cast<PropertyNode *>(*i); + for (const auto &child : children) { + if (child->isProperty()) { + PropertyNode *pn = static_cast<PropertyNode *>(child); if (pn->name() == fn->name() || pn->hasAccessFunction(fn->name())) { if (pn->hasDoc()) return pn; } } - i++; } PropertyNode *result = cn->findOverriddenProperty(fn); if (result != nullptr) return result; } - ++bc; } return nullptr; } @@ -4488,29 +4477,21 @@ QString PropertyNode::qualifiedDataType() const */ bool PropertyNode::hasAccessFunction(const QString &name) const { - NodeList::const_iterator i = getters().begin(); - while (i != getters().end()) { - if ((*i)->name() == name) + for (const auto &getter : getters()) { + if (getter->name() == name) return true; - ++i; } - i = setters().begin(); - while (i != setters().end()) { - if ((*i)->name() == name) + for (const auto &setter : setters()) { + if (setter->name() == name) return true; - ++i; } - i = resetters().begin(); - while (i != resetters().end()) { - if ((*i)->name() == name) + for (const auto &resetter : resetters()) { + if (resetter->name() == name) return true; - ++i; } - i = notifiers().begin(); - while (i != notifiers().end()) { - if ((*i)->name() == name) + for (const auto ¬ifier : notifiers()) { + if (notifier->name() == name) return true; - ++i; } return false; } @@ -4833,11 +4814,9 @@ void CollectionNode::addMember(Node *node) bool CollectionNode::hasNamespaces() const { if (!members_.isEmpty()) { - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { - if ((*i)->isNamespace()) + for (const auto &member : qAsConst(members_)) { + if (member->isNamespace()) return true; - ++i; } } return false; @@ -4850,11 +4829,9 @@ bool CollectionNode::hasNamespaces() const bool CollectionNode::hasClasses() const { if (!members_.isEmpty()) { - NodeList::const_iterator i = members_.cbegin(); - while (i != members_.cend()) { - if ((*i)->isClassNode()) + for (const auto &member : qAsConst(members_)) { + if (member->isClassNode()) return true; - ++i; } } return false; @@ -4867,11 +4844,9 @@ bool CollectionNode::hasClasses() const void CollectionNode::getMemberNamespaces(NodeMap& out) { out.clear(); - NodeList::const_iterator i = members_.cbegin(); - while (i != members_.cend()) { - if ((*i)->isNamespace()) - out.insert((*i)->name(), (*i)); - ++i; + for (const auto &member : qAsConst(members_)) { + if (member->isNamespace()) + out.insert(member->name(), member); } } @@ -4882,11 +4857,9 @@ void CollectionNode::getMemberNamespaces(NodeMap& out) void CollectionNode::getMemberClasses(NodeMap& out) const { out.clear(); - NodeList::const_iterator i = members_.cbegin(); - while (i != members_.cend()) { - if ((*i)->isClassNode()) - out.insert((*i)->name(), (*i)); - ++i; + for (const auto &i : qAsConst(members_)) { + if (i->isClassNode()) + out.insert(i->name(), i); } } @@ -4898,10 +4871,8 @@ void CollectionNode::printMembers(const QString &title) { qDebug() << title << name() << members_.size(); if (members_.size() > 0) { - for (int i=0; i<members_.size(); ++i) { - Node *n = members_.at(i); - qDebug() << " MEMBER:" << n->name() << n->nodeTypeString(); - } + for (const auto &member : qAsConst(members_)) + qDebug() << " MEMBER:" << member->name() << member->nodeTypeString(); } } diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp index 311b19db7..36491fc8f 100644 --- a/src/qdoc/qdocdatabase.cpp +++ b/src/qdoc/qdocdatabase.cpp @@ -186,12 +186,11 @@ void QDocForest::setSearchOrder(const QStringList &t) moduleNames_.append(primaryName); forest_.remove(primaryName); - QMap<QString, Tree *>::iterator i; for (const QString &m : t) { if (primaryName != m) { - i = forest_.find(m); - if (i != forest_.end()) { - searchOrder_.append(i.value()); + auto it = forest_.find(m); + if (it != forest_.end()) { + searchOrder_.append(it.value()); moduleNames_.append(m); forest_.remove(m); } @@ -203,11 +202,9 @@ void QDocForest::setSearchOrder(const QStringList &t) know any better at this point. */ if (!forest_.isEmpty()) { - i = forest_.begin(); - while (i != forest_.end()) { - searchOrder_.append(i.value()); - moduleNames_.append(i.key()); - ++i; + for (auto it = forest_.begin(); it != forest_.end(); ++it) { + searchOrder_.append(it.value()); + moduleNames_.append(it.key()); } forest_.clear(); } @@ -349,17 +346,15 @@ void QDocForest::printLinkCounts(const QString &project) } QString depends = "depends +="; QString module = project.toLower(); - QMultiMap<int, QString>::iterator i = m.begin(); - while (i != m.end()) { - QString line = " " + i.value(); - if (i.value() != module) - depends += QLatin1Char(' ') + i.value(); + for (auto it = m.begin(); it != m.end(); ++it) { + QString line = " " + it.value(); + if (it.value() != module) + depends += QLatin1Char(' ') + it.value(); int pad = 30 - line.length(); for (int k=0; k<pad; ++k) line += QLatin1Char(' '); line += "%1"; - Location::null.report(line.arg(-(i.key()))); - ++i; + Location::null.report(line.arg(-(it.key()))); } Location::null.report("Optimal depends variable:"); Location::null.report(depends); @@ -378,14 +373,12 @@ QString QDocForest::getLinkCounts(QStringList &strings, QVector<int> &counts) } QString depends = "depends +="; QString module = Generator::defaultModuleName().toLower(); - QMultiMap<int, QString>::iterator i = m.begin(); - while (i != m.end()) { - if (i.value() != module) { - counts.append(-(i.key())); - strings.append(i.value()); - depends += QLatin1Char(' ') + i.value(); + for (auto it = m.begin(); it != m.end(); ++it) { + if (it.value() != module) { + counts.append(-(it.key())); + strings.append(it.value()); + depends += QLatin1Char(' ') + it.value(); } - ++i; } return depends; } @@ -1032,15 +1025,13 @@ NodeMapMap &QDocDatabase::getFunctionIndex() */ void QDocDatabase::findAllLegaleseTexts(Aggregate *node) { - NodeList::ConstIterator c = node->constBegin(); - while (c != node->constEnd()) { - if (!(*c)->isPrivate()) { - if (!(*c)->doc().legaleseText().isEmpty()) - legaleseTexts_.insertMulti((*c)->doc().legaleseText(), *c); - if ((*c)->isAggregate()) - findAllLegaleseTexts(static_cast<Aggregate *>(*c)); + for (auto it = node->constBegin(); it != node->constEnd(); ++it) { + if (!(*it)->isPrivate()) { + if (!(*it)->doc().legaleseText().isEmpty()) + legaleseTexts_.insertMulti((*it)->doc().legaleseText(), *it); + if ((*it)->isAggregate()) + findAllLegaleseTexts(static_cast<Aggregate *>(*it)); } - ++c; } } @@ -1072,9 +1063,9 @@ const NodeMap &QDocDatabase::getClassMap(const QString &key) { if (newSinceMaps_.isEmpty() && newClassMaps_.isEmpty() && newQmlTypeMaps_.isEmpty()) processForest(&QDocDatabase::findAllSince); - NodeMapMap::const_iterator i = newClassMaps_.constFind(key); - if (i != newClassMaps_.constEnd()) - return i.value(); + auto it = newClassMaps_.constFind(key); + if (it != newClassMaps_.constEnd()) + return it.value(); return emptyNodeMap_; } @@ -1087,9 +1078,9 @@ const NodeMap &QDocDatabase::getQmlTypeMap(const QString &key) { if (newSinceMaps_.isEmpty() && newClassMaps_.isEmpty() && newQmlTypeMaps_.isEmpty()) processForest(&QDocDatabase::findAllSince); - NodeMapMap::const_iterator i = newQmlTypeMaps_.constFind(key); - if (i != newQmlTypeMaps_.constEnd()) - return i.value(); + auto it = newQmlTypeMaps_.constFind(key); + if (it != newQmlTypeMaps_.constEnd()) + return it.value(); return emptyNodeMap_; } @@ -1102,9 +1093,9 @@ const NodeMap &QDocDatabase::getSinceMap(const QString &key) { if (newSinceMaps_.isEmpty() && newClassMaps_.isEmpty() && newQmlTypeMaps_.isEmpty()) processForest(&QDocDatabase::findAllSince); - NodeMultiMapMap::const_iterator i = newSinceMaps_.constFind(key); - if (i != newSinceMaps_.constEnd()) - return i.value(); + auto it = newSinceMaps_.constFind(key); + if (it != newSinceMaps_.constEnd()) + return it.value(); return emptyNodeMultiMap_; } @@ -1232,12 +1223,11 @@ void QDocDatabase::resolveNamespaces() for (auto *node : namespaces) { auto *nameSpaceNode = static_cast<NamespaceNode *>(node); if (nameSpaceNode != ns) { - NodeList::ConstIterator c = nameSpaceNode->constBegin(); - while (c != nameSpaceNode->constEnd()) { - Node *N = *c; + for (auto it = nameSpaceNode->constBegin(); + it != nameSpaceNode->constEnd(); ++it) { + Node *N = *it; if (N && N->isPublic() && !N->isInternal()) ns->includeChild(N); - ++c; } } } @@ -1326,9 +1316,9 @@ const Node *QDocDatabase::findTypeNode(const QString &type, const Node *relative { QStringList path = type.split("::"); if ((path.size() == 1) && (path.at(0)[0].isLower() || path.at(0) == QString("T"))) { - NodeMap::iterator i = typeNodeMap_.find(path.at(0)); - if (i != typeNodeMap_.end()) - return i.value(); + auto it = typeNodeMap_.find(path.at(0)); + if (it != typeNodeMap_.end()) + return it.value(); } return forest_.findTypeNode(path, relative, genus); } @@ -1445,11 +1435,9 @@ void QDocDatabase::mergeCollections(Node::NodeType type, CNMap &cnm, const Node for (auto *tree : searchOrder()) { CNMap *m = tree->getCollectionMap(type); if (m && !m->isEmpty()) { - CNMap::const_iterator i = m->cbegin(); - while (i != m->cend()) { - if (!i.value()->isInternal()) - cnmm.insert(i.key(), i.value()); - ++i; + for (auto it = m->cbegin(); it != m->cend(); ++it) { + if (!it.value()->isInternal()) + cnmm.insert(it.key(), it.value()); } } } diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp index 9ded66abb..0d284f6bf 100644 --- a/src/qdoc/qdocindexfiles.cpp +++ b/src/qdoc/qdocindexfiles.cpp @@ -1450,14 +1450,12 @@ void QDocIndexFiles::generateFunctionSections(QXmlStreamWriter &writer, Aggregat { FunctionMap &functionMap = aggregate->functionMap(); if (!functionMap.isEmpty()) { - FunctionMap::iterator i = functionMap.begin(); - while (i != functionMap.end()) { - FunctionNode *fn = i.value(); + for (auto it = functionMap.begin(); it != functionMap.end(); ++it) { + FunctionNode *fn = it.value(); while (fn != nullptr) { generateFunctionSection(writer, fn); fn = fn->nextOverload(); } - i++; } } } @@ -1497,41 +1495,33 @@ void QDocIndexFiles::generateIndexSections(QXmlStreamWriter &writer, Node *node, */ const CNMap &groups = qdb_->groups(); if (!groups.isEmpty()) { - CNMap::ConstIterator g = groups.constBegin(); - while (g != groups.constEnd()) { - if (generateIndexSection(writer, g.value(), post)) + for (auto it = groups.constBegin(); it != groups.constEnd(); ++it) { + if (generateIndexSection(writer, it.value(), post)) writer.writeEndElement(); - ++g; } } const CNMap &modules = qdb_->modules(); if (!modules.isEmpty()) { - CNMap::ConstIterator g = modules.constBegin(); - while (g != modules.constEnd()) { - if (generateIndexSection(writer, g.value(), post)) + for (auto it = modules.constBegin(); it != modules.constEnd(); ++it) { + if (generateIndexSection(writer, it.value(), post)) writer.writeEndElement(); - ++g; } } const CNMap &qmlModules = qdb_->qmlModules(); if (!qmlModules.isEmpty()) { - CNMap::ConstIterator g = qmlModules.constBegin(); - while (g != qmlModules.constEnd()) { - if (generateIndexSection(writer, g.value(), post)) + for (auto it = qmlModules.constBegin(); it != qmlModules.constEnd(); ++it) { + if (generateIndexSection(writer, it.value(), post)) writer.writeEndElement(); - ++g; } } const CNMap &jsModules = qdb_->jsModules(); if (!jsModules.isEmpty()) { - CNMap::ConstIterator g = jsModules.constBegin(); - while (g != jsModules.constEnd()) { - if (generateIndexSection(writer, g.value(), post)) + for (auto it = jsModules.constBegin(); it != jsModules.constEnd(); ++it) { + if (generateIndexSection(writer, it.value(), post)) writer.writeEndElement(); - ++g; } } } diff --git a/src/qdoc/qmlcodemarker.cpp b/src/qdoc/qmlcodemarker.cpp index fe39e6e54..cb31b62b0 100644 --- a/src/qdoc/qmlcodemarker.cpp +++ b/src/qdoc/qmlcodemarker.cpp @@ -145,11 +145,9 @@ QString QmlCodeMarker::markedUpIncludes(const QStringList &includes) { QString code; - QStringList::ConstIterator inc = includes.constBegin(); - while (inc != includes.constEnd()) { - code += "import " + *inc + QLatin1Char('\n'); - ++inc; - } + for (const auto &include : includes) + code += "import " + include + QLatin1Char('\n'); + Location location; return addMarkUp(code, nullptr, location); } diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index c7be4b1cf..6eb924570 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -82,7 +82,7 @@ QmlDocVisitor::~QmlDocVisitor() QQmlJS::AST::SourceLocation QmlDocVisitor::precedingComment(quint32 offset) const { const auto comments = engine->comments(); - for (auto it = comments.rbegin(), end = comments.rend(); it != end; ++it) { + for (auto it = comments.rbegin(); it != comments.rend(); ++it) { QQmlJS::AST::SourceLocation loc = *it; if (loc.begin() <= lastEndOffset) { @@ -450,10 +450,8 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation, QSet<QString> metacommands = doc.metaCommandsUsed(); if (metacommands.count() > 0) { metacommands.subtract(topics_); - QSet<QString>::iterator i = metacommands.begin(); - while (i != metacommands.end()) { - QString command = *i; - ArgList args = doc.metaCommandArgs(command); + for (const auto &command : qAsConst(metacommands)) { + const ArgList args = doc.metaCommandArgs(command); if ((command == COMMAND_QMLABSTRACT) || (command == COMMAND_ABSTRACT)) { if (node->isQmlType() || node->isJsType()) { node->setAbstract(true); @@ -480,11 +478,8 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation, node->markReadOnly(1); } else if ((command == COMMAND_INGROUP) && !args.isEmpty()) { - ArgList::ConstIterator argsIter = args.constBegin(); - while (argsIter != args.constEnd()) { - QDocDatabase::qdocDB()->addToGroup(argsIter->first, node); - ++argsIter; - } + for (const auto &argument : args) + QDocDatabase::qdocDB()->addToGroup(argument.first, node); } else if (command == COMMAND_INTERNAL) { node->setStatus(Node::Internal); @@ -508,7 +503,6 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation, else { doc.location().warning(tr("The \\%1 command is ignored in QML files").arg(command)); } - ++i; } } } diff --git a/src/qdoc/quoter.cpp b/src/qdoc/quoter.cpp index b54d959e4..7dd13233e 100644 --- a/src/qdoc/quoter.cpp +++ b/src/qdoc/quoter.cpp @@ -177,11 +177,8 @@ void Quoter::quoteFromFile(const QString &userFriendlyFilePath, /* Squeeze blanks (cat -s). */ - QStringList::Iterator m = markedLines.begin(); - while (m != markedLines.end()) { - replaceMultipleNewlines(*m); - ++m; - } + for (auto &line : markedLines) + replaceMultipleNewlines(line); codeLocation.start(); } diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp index 44eea84ea..b21369aea 100644 --- a/src/qdoc/sections.cpp +++ b/src/qdoc/sections.cpp @@ -348,9 +348,8 @@ Sections::Sections(const NodeMultiMap &nsmap) : aggregate_(nullptr) if (nsmap.isEmpty()) return; SectionVector §ions = sinceSections(); - NodeMultiMap::const_iterator n = nsmap.constBegin(); - while (n != nsmap.constEnd()) { - Node *node = n.value(); + for (auto it = nsmap.constBegin(); it != nsmap.constEnd(); ++it) { + Node *node = it.value(); switch (node->nodeType()) { case Node::JsType: case Node::QmlType: @@ -422,7 +421,6 @@ Sections::Sections(const NodeMultiMap &nsmap) : aggregate_(nullptr) default: break; } - ++n; } } @@ -682,22 +680,17 @@ void Sections::buildStdRefPageSections() if (!ns->hasDoc()) documentAll = false; // only document children that have documentation } - NodeList::ConstIterator c = aggregate_->constBegin(); - while (c != aggregate_->constEnd()) { - Node *n = *c; + for (auto it = aggregate_->constBegin(); it != aggregate_->constEnd(); ++it) { + Node *n = *it; if (documentAll || n->hasDoc()) { stdRefPageSwitch(stdSummarySections(), n); stdRefPageSwitch(stdDetailsSections(), n); } - ++c; } if (!aggregate_->relatedByProxy().isEmpty()) { - c = aggregate_->relatedByProxy().constBegin(); - while (c != aggregate_->relatedByProxy().constEnd()) { - Node *n = *c; - stdRefPageSwitch(stdSummarySections(), n); - ++c; - } + const QList<Node *> &relatedBy = aggregate_->relatedByProxy(); + for (const auto &node : relatedBy) + stdRefPageSwitch(stdSummarySections(), node); } /* If we are building the sections for the reference page @@ -705,12 +698,10 @@ void Sections::buildStdRefPageSections() included children in the sections. */ if (ns && !ns->includedChildren().isEmpty()) { - NodeList::ConstIterator c = ns->includedChildren().constBegin(); - while (c != ns->includedChildren().constEnd()) { - Node *n = *c; - if (documentAll || n->hasDoc()) - stdRefPageSwitch(stdSummarySections(), n); - ++c; + const QList<Node *> &children = ns->includedChildren(); + for (const auto &child : children) { + if (documentAll || child->hasDoc()) + stdRefPageSwitch(stdSummarySections(), child); } } reduce(stdSummarySections()); @@ -939,7 +930,7 @@ void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool if (scn->isPropertyGroup()) { sv[QmlProperties].insert(scn); } else { - for (auto child : scn->collective()) + for (const auto &child : scn->collective()) distributeQmlNodeInSummaryVector(sv, child, true); } } @@ -947,11 +938,10 @@ void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool static void pushBaseClasses(QStack<ClassNode *> &stack, ClassNode *cn) { - QList<RelatedClass>::ConstIterator r = cn->baseClasses().constBegin(); - while (r != cn->baseClasses().constEnd()) { - if (r->node_) - stack.prepend(r->node_); - ++r; + const QList<RelatedClass> &baseClasses = cn->baseClasses(); + for (const auto &cls : baseClasses) { + if (cls.node_) + stack.prepend(cls.node_); } } @@ -961,35 +951,29 @@ static void pushBaseClasses(QStack<ClassNode *> &stack, ClassNode *cn) */ void Sections::buildStdCppClassRefPageSections() { - SectionVector &sv = stdCppClassSummarySections(); - SectionVector &dv = stdCppClassDetailsSections(); + SectionVector &summarySections = stdCppClassSummarySections(); + SectionVector &detailsSections = stdCppClassDetailsSections(); Section &allMembers = allMembersSection(); bool documentAll = true; if (aggregate_->parent() && !aggregate_->name().isEmpty() && !aggregate_->hasDoc()) documentAll = false; - NodeList::ConstIterator c = aggregate_->constBegin(); - while (c != aggregate_->constEnd()) { - Node *n = *c; + for (auto it = aggregate_->constBegin(); it != aggregate_->constEnd();++it) { + Node *n = *it; if (!n->isPrivate() && !n->isProperty() && !n->isRelatedNonmember() && !n->isSharedCommentNode()) allMembers.insert(n); - if (!documentAll && !n->hasDoc()) { - ++c; + if (!documentAll && !n->hasDoc()) continue; - } - distributeNodeInSummaryVector(sv, n); - distributeNodeInDetailsVector(dv, n); - ++c; + + distributeNodeInSummaryVector(summarySections, n); + distributeNodeInDetailsVector(detailsSections, n); } if (!aggregate_->relatedByProxy().isEmpty()) { - c = aggregate_->relatedByProxy().constBegin(); - while (c != aggregate_->relatedByProxy().constEnd()) { - Node *n = *c; - distributeNodeInSummaryVector(sv, n); - ++c; - } + const QList<Node *> relatedBy = aggregate_->relatedByProxy(); + for (const auto &node : relatedBy) + distributeNodeInSummaryVector(summarySections, node); } QStack<ClassNode *> stack; @@ -997,25 +981,21 @@ void Sections::buildStdCppClassRefPageSections() pushBaseClasses(stack, cn); while (!stack.isEmpty()) { ClassNode *cn = stack.pop(); - c = cn->constBegin(); - while (c != cn->constEnd()) { - Node *n = *c; + for (auto it = cn->constBegin(); it != cn->constEnd(); ++it) { + Node *n = *it; if (!n->isPrivate() && !n->isProperty() && !n->isRelatedNonmember() && !n->isSharedCommentNode()) allMembers.insert(n); - if (!documentAll && !n->hasDoc()) { - ++c; + if (!documentAll && !n->hasDoc()) continue; - } //distributeNodeInSummaryVector(sv, n); Why was this here? mws 03/07/2019 - ++c; } pushBaseClasses(stack, cn); } - reduce(sv); - reduce(dv); + reduce(summarySections); + reduce(detailsSections); allMembers.reduce(); } @@ -1027,27 +1007,24 @@ void Sections::buildStdCppClassRefPageSections() void Sections::buildStdQmlTypeRefPageSections() { ClassMap* classMap = nullptr; - SectionVector &sv = stdQmlTypeSummarySections(); - SectionVector &dv = stdQmlTypeDetailsSections(); + SectionVector &summarySections = stdQmlTypeSummarySections(); + SectionVector &detailsSections = stdQmlTypeDetailsSections(); Section &allMembers = allMembersSection(); const Aggregate *qtn = aggregate_; while (true) { if (!qtn->isAbstract() || !classMap) classMap = allMembers.newClassMap(qtn); - NodeList::ConstIterator c = qtn->constBegin(); - while (c != qtn->constEnd()) { - Node *n = *c; - if (n->isInternal()) { - ++c; + for (auto it = qtn->constBegin(); it !=qtn->constEnd(); ++it) { + Node *n = *it; + if (n->isInternal()) continue; - } + if (!n->isSharedCommentNode() || n->isPropertyGroup()) allMembers.add(classMap, n); - distributeQmlNodeInSummaryVector(sv, n); - distributeQmlNodeInDetailsVector(dv, n); - ++c; + distributeQmlNodeInSummaryVector(summarySections, n); + distributeQmlNodeInDetailsVector(detailsSections, n); } if (qtn->qmlBaseNode() == qtn) { qDebug() << "qdoc internal error: circular type definition." @@ -1066,15 +1043,12 @@ void Sections::buildStdQmlTypeRefPageSections() while (qtn != nullptr) { if (!qtn->isAbstract() || !classMap) classMap = allMembers.newClassMap(qtn); - NodeList::ConstIterator c = qtn->constBegin(); - while (c != qtn->constEnd()) { - Node *n = *c; - if (n->isInternal() || n->isSharedCommentNode()) { - ++c; + for (auto it = qtn->constBegin(); it != qtn->constEnd(); ++it) { + Node *n = *it; + if (n->isInternal() || n->isSharedCommentNode()) continue; - } + allMembers.add(classMap, n); - ++c; } if (qtn->qmlBaseNode() == qtn) { qDebug() << "qdoc internal error: circular type definition." @@ -1085,8 +1059,8 @@ void Sections::buildStdQmlTypeRefPageSections() } qtn = static_cast<QmlTypeNode *>(qtn->qmlBaseNode()); } - reduce(sv); - reduce(dv); + reduce(summarySections); + reduce(detailsSections); allMembers.reduce(); } @@ -1098,30 +1072,26 @@ void Sections::buildStdQmlTypeRefPageSections() */ bool Sections::hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const { - const SectionVector *sv = nullptr; + const SectionVector *sections = nullptr; if (aggregate_->isClassNode()) - sv = &stdCppClassSummarySections(); + sections = &stdCppClassSummarySections(); else if (aggregate_->isQmlType() || aggregate_->isQmlBasicType()) - sv = &stdQmlTypeSummarySections(); + sections = &stdQmlTypeSummarySections(); else - sv = &stdSummarySections(); - SectionVector::ConstIterator s = sv->constBegin(); - while (s != sv->constEnd()) { - if (!s->obsoleteMembers().isEmpty()) - summary_spv->append(&(*s)); - ++s; + sections = &stdSummarySections(); + for (const auto §ion : *sections) { + if (!section.obsoleteMembers().isEmpty()) + summary_spv->append(§ion); } if (aggregate_->isClassNode()) - sv = &stdCppClassDetailsSections(); + sections = &stdCppClassDetailsSections(); else if (aggregate_->isQmlType() || aggregate_->isQmlBasicType()) - sv = &stdQmlTypeDetailsSections(); + sections = &stdQmlTypeDetailsSections(); else - sv = &stdDetailsSections(); - s = sv->constBegin(); - while (s != sv->constEnd()) { - if (!s->obsoleteMembers().isEmpty()) - details_spv->append(&(*s)); - ++s; + sections = &stdDetailsSections(); + for (const auto &it : *sections) { + if (!it.obsoleteMembers().isEmpty()) + details_spv->append(&it); } return !summary_spv->isEmpty(); } diff --git a/src/qdoc/tree.cpp b/src/qdoc/tree.cpp index 1ae07c52b..e85952934 100644 --- a/src/qdoc/tree.cpp +++ b/src/qdoc/tree.cpp @@ -100,23 +100,19 @@ Tree::Tree(const QString &camelCaseModuleName, QDocDatabase *qdb) */ Tree::~Tree() { - TargetMap::iterator i = nodesByTargetRef_.begin(); - while (i != nodesByTargetRef_.end()) { + for (auto i = nodesByTargetRef_.begin(); i != nodesByTargetRef_.end(); ++i) { delete i.value(); - ++i; } nodesByTargetRef_.clear(); nodesByTargetTitle_.clear(); if (Generator::writeQaPages() && targetListMap_) { - TargetListMap::iterator i = targetListMap_->begin(); - while (i != targetListMap_->end()) { - TargetList *tlist = i.value(); + for (auto target = targetListMap_->begin(); target != targetListMap_->end(); ++target) { + TargetList *tlist = target.value(); if (tlist) { for (auto *location : qAsConst(*tlist)) delete location; } delete tlist; - ++i; } } } @@ -238,15 +234,13 @@ void Tree::addPropertyFunction(PropertyNode *property, */ void Tree::resolveBaseClasses(Aggregate *n) { - NodeList::ConstIterator c = n->constBegin(); - while (c != n->constEnd()) { - if ((*c)->isClassNode()) { - ClassNode *cn = static_cast<ClassNode *>(*c); + for (auto it = n->constBegin(); it != n->constEnd(); ++it) { + if ((*it)->isClassNode()) { + ClassNode *cn = static_cast<ClassNode *>(*it); QList<RelatedClass> &bases = cn->baseClasses(); - QList<RelatedClass>::iterator b = bases.begin(); - while (b != bases.end()) { - if ((*b).node_ == nullptr) { - Node *n = qdb_->findClassNode((*b).path_); + for (auto &cls : bases) { + if (cls.node_ == nullptr) { + Node *n = qdb_->findClassNode(cls.path_); /* If the node for the base class was not found, the reason might be that the subclass is in a @@ -262,21 +256,19 @@ void Tree::resolveBaseClasses(Aggregate *n) if (parent != nullptr) // Exclude the root namespace if (parent->isNamespace() && !parent->name().isEmpty()) - n = findClassNode((*b).path_, parent); + n = findClassNode(cls.path_, parent); } if (n != nullptr) { ClassNode *bcn = static_cast<ClassNode *>(n); - (*b).node_ = bcn; - bcn->addDerivedClass((*b).access_, cn); + cls.node_ = bcn; + bcn->addDerivedClass(cls.access_, cn); } } - ++b; } resolveBaseClasses(cn); - } else if ((*c)->isNamespace()) { - resolveBaseClasses(static_cast<NamespaceNode *>(*c)); + } else if ((*it)->isNamespace()) { + resolveBaseClasses(static_cast<NamespaceNode *>(*it)); } - ++c; } } @@ -284,21 +276,17 @@ void Tree::resolveBaseClasses(Aggregate *n) */ void Tree::resolvePropertyOverriddenFromPtrs(Aggregate *n) { - NodeList::ConstIterator c = n->constBegin(); - while (c != n->constEnd()) { - if ((*c)->isClassNode()) { - ClassNode *cn = static_cast<ClassNode *>(*c); - NodeList::ConstIterator p = cn->constBegin(); - while (p != cn->constEnd()) { - if ((*p)->isProperty()) - cn->resolvePropertyOverriddenFromPtrs(static_cast<PropertyNode *>(*p)); - ++p; + for (auto node = n->constBegin(); node != n->constEnd(); ++node) { + if ((*node)->isClassNode()) { + ClassNode *cn = static_cast<ClassNode *>(*node); + for (auto property = cn->constBegin(); property != cn->constEnd(); ++property) { + if ((*property)->isProperty()) + cn->resolvePropertyOverriddenFromPtrs(static_cast<PropertyNode *>(*property)); } resolvePropertyOverriddenFromPtrs(cn); - } else if ((*c)->isNamespace()) { - resolvePropertyOverriddenFromPtrs(static_cast<NamespaceNode *>(*c)); + } else if ((*node)->isNamespace()) { + resolvePropertyOverriddenFromPtrs(static_cast<NamespaceNode *>(*node)); } - ++c; } } @@ -306,10 +294,8 @@ void Tree::resolvePropertyOverriddenFromPtrs(Aggregate *n) */ void Tree::resolveProperties() { - PropertyMap::ConstIterator propEntry; - - propEntry = unresolvedPropertyMap.constBegin(); - while (propEntry != unresolvedPropertyMap.constEnd()) { + for (auto propEntry = unresolvedPropertyMap.constBegin(); + propEntry != unresolvedPropertyMap.constEnd(); ++propEntry) { PropertyNode *property = propEntry.key(); Aggregate *parent = property->parent(); QString getterName = (*propEntry)[PropertyNode::Getter]; @@ -317,10 +303,9 @@ void Tree::resolveProperties() QString resetterName = (*propEntry)[PropertyNode::Resetter]; QString notifierName = (*propEntry)[PropertyNode::Notifier]; - NodeList::ConstIterator c = parent->constBegin(); - while (c != parent->constEnd()) { - if ((*c)->isFunction()) { - FunctionNode *function = static_cast<FunctionNode *>(*c); + for (auto it = parent->constBegin(); it != parent->constEnd(); ++it) { + if ((*it)->isFunction()) { + FunctionNode *function = static_cast<FunctionNode *>(*it); if (function->access() == property->access() && (function->status() == property->status() || function->doc().isEmpty())) { @@ -338,18 +323,15 @@ void Tree::resolveProperties() } } } - ++c; } - ++propEntry; } - propEntry = unresolvedPropertyMap.constBegin(); - while (propEntry != unresolvedPropertyMap.constEnd()) { + for (auto propEntry = unresolvedPropertyMap.constBegin(); + propEntry != unresolvedPropertyMap.constEnd(); ++propEntry) { PropertyNode *property = propEntry.key(); // redo it to set the property functions if (property->overriddenFrom()) property->setOverriddenFrom(property->overriddenFrom()); - ++propEntry; } unresolvedPropertyMap.clear(); @@ -385,14 +367,12 @@ void Tree::resolveUsingClauses() if (child->isClassNode()) { ClassNode *cn = static_cast<ClassNode *>(child); QList<UsingClause> &usingClauses = cn->usingClauses(); - QList<UsingClause>::iterator uc = usingClauses.begin(); - while (uc != usingClauses.end()) { - if ((*uc).node() == nullptr) { - const Node *n = qdb_->findFunctionNode((*uc).signature(), cn, Node::CPP); + for (auto &usingClause : usingClauses) { + if (usingClause.node() == nullptr) { + const Node *n = qdb_->findFunctionNode(usingClause.signature(), cn, Node::CPP); if (n != nullptr) - (*uc).setNode(n); + usingClause.setNode(n); } - ++uc; } } } @@ -412,13 +392,11 @@ void Tree::removePrivateAndInternalBases(NamespaceNode *rootNode) if (rootNode == nullptr) rootNode = root(); - NodeList::ConstIterator c = rootNode->constBegin(); - while (c != rootNode->constEnd()) { - if ((*c)->isClassNode()) - static_cast<ClassNode *>(*c)->removePrivateAndInternalBases(); - else if ((*c)->isNamespace()) - removePrivateAndInternalBases(static_cast<NamespaceNode *>(*c)); - ++c; + for (auto node = rootNode->constBegin(); node != rootNode->constEnd(); ++node) { + if ((*node)->isClassNode()) + static_cast<ClassNode *>(*node)->removePrivateAndInternalBases(); + else if ((*node)->isNamespace()) + removePrivateAndInternalBases(static_cast<NamespaceNode *>(*node)); } } @@ -748,22 +726,22 @@ const Node *Tree::findNode(const QStringList &path, */ QString Tree::getRef(const QString &target, const Node *node) const { - TargetMap::const_iterator i = nodesByTargetTitle_.constFind(target); - if (i != nodesByTargetTitle_.constEnd()) { + auto it = nodesByTargetTitle_.constFind(target); + if (it != nodesByTargetTitle_.constEnd()) { do { - if (i.value()->node_ == node) - return i.value()->ref_; - ++i; - } while (i != nodesByTargetTitle_.constEnd() && i.key() == target); + if (it.value()->node_ == node) + return it.value()->ref_; + ++it; + } while (it != nodesByTargetTitle_.constEnd() && it.key() == target); } QString key = Doc::canonicalTitle(target); - i = nodesByTargetRef_.constFind(key); - if (i != nodesByTargetRef_.constEnd()) { + it = nodesByTargetRef_.constFind(key); + if (it != nodesByTargetRef_.constEnd()) { do { - if (i.value()->node_ == node) - return i.value()->ref_; - ++i; - } while (i != nodesByTargetRef_.constEnd() && i.key() == key); + if (it.value()->node_ == node) + return it.value()->ref_; + ++it; + } while (it != nodesByTargetRef_.constEnd() && it.key() == key); } return QString(); } @@ -799,9 +777,9 @@ void Tree::resolveTargets(Aggregate *root) QList<PageNode *> nodes = pageNodesByTitle_.values(key); bool alreadyThere = false; if (!nodes.empty()) { - for (int i=0; i< nodes.size(); ++i) { - if (nodes[i]->isExternalPage()) { - if (node->name() == nodes[i]->name()) { + for (const auto &node_ : nodes) { + if (node_->isExternalPage()) { + if (node->name() == node_->name()) { alreadyThere = true; break; } @@ -868,11 +846,10 @@ Tree::findUnambiguousTarget(const QString &target, Node::Genus genus, QString &r QList<TargetRec *> bestTargetList; QString key = target; - TargetMap::const_iterator i = nodesByTargetTitle_.find(key); - while (i != nodesByTargetTitle_.constEnd()) { - if (i.key() != key) + for (auto it = nodesByTargetTitle_.find(key); it != nodesByTargetTitle_.constEnd(); ++it) { + if (it.key() != key) break; - TargetRec *candidate = i.value(); + TargetRec *candidate = it.value(); if ((genus == Node::DontCare) || (genus == candidate->genus())) { if (!bestTarget || (candidate->priority_ < bestTarget->priority_)) { bestTarget = candidate; @@ -885,7 +862,6 @@ Tree::findUnambiguousTarget(const QString &target, Node::Genus genus, QString &r ++numBestTargets; } } - ++i; } if (bestTarget) { ref = bestTarget->ref_; @@ -895,11 +871,10 @@ Tree::findUnambiguousTarget(const QString &target, Node::Genus genus, QString &r numBestTargets = 0; bestTarget = nullptr; key = Doc::canonicalTitle(target); - i = nodesByTargetRef_.find(key); - while (i != nodesByTargetRef_.constEnd()) { - if (i.key() != key) + for (auto it = nodesByTargetRef_.find(key); it != nodesByTargetRef_.constEnd(); ++it) { + if (it.key() != key) break; - TargetRec *candidate = i.value(); + TargetRec *candidate = it.value(); if ((genus == Node::DontCare) || (genus == candidate->genus())) { if (!bestTarget || (candidate->priority_ < bestTarget->priority_)) { bestTarget = candidate; @@ -912,7 +887,6 @@ Tree::findUnambiguousTarget(const QString &target, Node::Genus genus, QString &r ++numBestTargets; } } - ++i; } if (bestTarget) { ref = bestTarget->ref_; @@ -928,32 +902,32 @@ Tree::findUnambiguousTarget(const QString &target, Node::Genus genus, QString &r */ const PageNode *Tree::findPageNodeByTitle(const QString &title) const { - PageNodeMultiMap::const_iterator i; + PageNodeMultiMap::const_iterator it; if (title.contains(QChar(' '))) - i = pageNodesByTitle_.constFind(Doc::canonicalTitle(title)); + it = pageNodesByTitle_.constFind(Doc::canonicalTitle(title)); else - i = pageNodesByTitle_.constFind(title); - if (i != pageNodesByTitle_.constEnd()) { + it = pageNodesByTitle_.constFind(title); + if (it != pageNodesByTitle_.constEnd()) { /* Reporting all these duplicate section titles is probably overkill. We should report the duplicate file and let that suffice. */ - PageNodeMultiMap::const_iterator j = i; + PageNodeMultiMap::const_iterator j = it; ++j; - if (j != pageNodesByTitle_.constEnd() && j.key() == i.key()) { + if (j != pageNodesByTitle_.constEnd() && j.key() == it.key()) { while (j != pageNodesByTitle_.constEnd()) { - if (j.key() == i.key() && j.value()->url().isEmpty()) { + if (j.key() == it.key() && j.value()->url().isEmpty()) { break; // Just report one duplicate for now. } ++j; } if (j != pageNodesByTitle_.cend()) { - i.value()->location().warning("This page title exists in more than one file: " + title); + it.value()->location().warning("This page title exists in more than one file: " + title); j.value()->location().warning("[It also exists here]"); } } - return i.value(); + return it.value(); } return nullptr; } @@ -1020,11 +994,11 @@ CNMap *Tree::getCollectionMap(Node::NodeType type) */ CollectionNode *Tree::getCollection(const QString &name, Node::NodeType type) { - CNMap *m = getCollectionMap(type); - if (m) { - CNMap::const_iterator i = m->constFind(name); - if (i != m->cend()) - return i.value(); + CNMap *map = getCollectionMap(type); + if (map) { + auto it = map->constFind(name); + if (it != map->cend()) + return it.value(); } return nullptr; } @@ -1049,9 +1023,9 @@ CollectionNode *Tree::findCollection(const QString &name, Node::NodeType type) CNMap *m = getCollectionMap(type); if (!m) // error return nullptr; - CNMap::const_iterator i = m->constFind(name); - if (i != m->cend()) - return i.value(); + auto it = m->constFind(name); + if (it != m->cend()) + return it.value(); CollectionNode *cn = new CollectionNode(type, root(), name); cn->markNotSeen(); m->insert(name, cn); @@ -1352,13 +1326,13 @@ QString Tree::getNewLinkTarget(const Node *locNode, QString target = QString("qa-target-%1").arg(-(linkCount())); TargetLoc *tloc = new TargetLoc(locNode, target, fileName, text, broken); TargetList *tList = nullptr; - TargetListMap::iterator i = targetListMap_->find(physicalModuleName); - if (i == targetListMap_->end()) { + auto it = targetListMap_->find(physicalModuleName); + if (it == targetListMap_->end()) { tList = new TargetList; - i = targetListMap_->insert(physicalModuleName, tList); + it = targetListMap_->insert(physicalModuleName, tList); } else - tList = i.value(); + tList = it.value(); tList->append(tloc); return target; } @@ -1452,12 +1426,10 @@ void Tree::addToDontDocumentMap(QString &arg) */ void Tree::markDontDocumentNodes() { - NodeMap::iterator i = dontDocumentMap_.begin(); - while (i != dontDocumentMap_.end()) { - Aggregate *node = findAggregate(i.key()); + for (auto it = dontDocumentMap_.begin(); it != dontDocumentMap_.end(); ++it) { + Aggregate *node = findAggregate(it.key()); if (node != nullptr) node->setStatus(Node::DontDocument); - ++i; } } diff --git a/src/qdoc/webxmlgenerator.cpp b/src/qdoc/webxmlgenerator.cpp index 4b649820f..54373815a 100644 --- a/src/qdoc/webxmlgenerator.cpp +++ b/src/qdoc/webxmlgenerator.cpp @@ -817,8 +817,7 @@ void WebXMLGenerator::generateRelations(QXmlStreamWriter &writer, const Node *no QPair<QString, QString> anchorPair; const Node *linkNode; - for (QMap<Node::LinkType, QPair<QString, QString> >::const_iterator it = - node->links().cbegin(), end = node->links().cend(); it != end; ++it) { + for (auto it = node->links().cbegin(); it != node->links().cend(); ++it) { linkNode = qdb_->findNodeForTarget(it.value().first, node); |