summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qdoc/atom.cpp2
-rw-r--r--src/qdoc/clangcodeparser.cpp23
-rw-r--r--src/qdoc/codemarker.cpp41
-rw-r--r--src/qdoc/codemarker.h2
-rw-r--r--src/qdoc/codeparser.cpp2
-rw-r--r--src/qdoc/codeparser.h2
-rw-r--r--src/qdoc/config.cpp208
-rw-r--r--src/qdoc/config.h2
-rw-r--r--src/qdoc/cppcodemarker.cpp83
-rw-r--r--src/qdoc/cppcodeparser.cpp46
-rw-r--r--src/qdoc/doc.cpp150
-rw-r--r--src/qdoc/doc.h16
-rw-r--r--src/qdoc/editdistance.cpp20
-rw-r--r--src/qdoc/generator.cpp293
-rw-r--r--src/qdoc/generator.h18
-rw-r--r--src/qdoc/helpprojectwriter.cpp5
-rw-r--r--src/qdoc/helpprojectwriter.h6
-rw-r--r--src/qdoc/htmlgenerator.cpp902
-rw-r--r--src/qdoc/htmlgenerator.h26
-rw-r--r--src/qdoc/jscodemarker.cpp4
-rw-r--r--src/qdoc/location.cpp4
-rw-r--r--src/qdoc/main.cpp152
-rw-r--r--src/qdoc/node.cpp238
-rw-r--r--src/qdoc/node.h43
-rw-r--r--src/qdoc/openedlist.cpp2
-rw-r--r--src/qdoc/parameters.cpp17
-rw-r--r--src/qdoc/parameters.h6
-rw-r--r--src/qdoc/qdoc.pro2
-rw-r--r--src/qdoc/qdocdatabase.cpp96
-rw-r--r--src/qdoc/qdocindexfiles.cpp39
-rw-r--r--src/qdoc/qdoctagfiles.cpp2
-rw-r--r--src/qdoc/qmlcodemarker.cpp14
-rw-r--r--src/qdoc/qmlcodemarker.h2
-rw-r--r--src/qdoc/qmlmarkupvisitor.cpp2
-rw-r--r--src/qdoc/qmlmarkupvisitor.h4
-rw-r--r--src/qdoc/qmlvisitor.cpp16
-rw-r--r--src/qdoc/quoter.cpp7
-rw-r--r--src/qdoc/sections.cpp148
-rw-r--r--src/qdoc/sections.h8
-rw-r--r--src/qdoc/tokenizer.cpp2
-rw-r--r--src/qdoc/tree.cpp204
-rw-r--r--src/qdoc/webxmlgenerator.cpp57
-rw-r--r--src/qdoc/webxmlgenerator.h2
-rw-r--r--src/qdoc/xmlgenerator.cpp478
-rw-r--r--src/qdoc/xmlgenerator.h71
-rw-r--r--src/qdoc/yyindent.cpp8
-rw-r--r--src/shared/winutils/utils.cpp15
-rw-r--r--src/shared/winutils/utils.h5
-rw-r--r--src/windeployqt/main.cpp10
49 files changed, 1661 insertions, 1844 deletions
diff --git a/src/qdoc/atom.cpp b/src/qdoc/atom.cpp
index dff90b299..ecbea2013 100644
--- a/src/qdoc/atom.cpp
+++ b/src/qdoc/atom.cpp
@@ -334,7 +334,7 @@ QString Atom::typeString() const
while (atms[i].english != nullptr) {
if (atms[i].no != i)
Location::internalError(QCoreApplication::translate("QDoc::Atom", "atom %1 missing").arg(i));
- i++;
+ ++i;
}
deja = true;
}
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 5d95c9c7e..2e96a092d 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -269,7 +269,7 @@ static Node *findNodeForCursor(QDocDatabase *qdb, CXCursor cur) {
if (isVariadic && parameters.last().type() != QLatin1String("..."))
continue;
bool different = false;
- for (int i = 0; i < actualArg; i++) {
+ for (int i = 0; i < actualArg; ++i) {
if (args.size() <= i)
args.append(fromCXString(clang_getTypeSpelling(clang_getArgType(funcType, i))));
QString t1 = parameters.at(i).type();
@@ -347,7 +347,7 @@ static Node *findFunctionNodeForCursor(QDocDatabase *qdb, CXCursor cur) {
if (isVariadic && parameters.last().type() != QLatin1String("..."))
continue;
bool different = false;
- for (int i = 0; i < numArg; i++) {
+ for (int i = 0; i < numArg; ++i) {
if (args.size() <= i)
args.append(fromCXString(clang_getTypeSpelling(clang_getArgType(funcType, i))));
QString t1 = parameters.at(i).type();
@@ -884,7 +884,7 @@ void ClangVisitor::readParameterNamesAndAttributes(FunctionNode *fn, CXCursor cu
}
return CXChildVisit_Continue;
});
- i++;
+ ++i;
}
return CXChildVisit_Continue;
});
@@ -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";
}
}
@@ -1522,7 +1521,7 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg
QString pName = blankSplit.last();
int j = 0;
while (j < pName.length() && !pName.at(i).isLetter())
- j++;
+ ++j;
if (j > 0)
pName = pName.mid(j);
if (!pName.isEmpty() && pName != parameters[i].name())
diff --git a/src/qdoc/codemarker.cpp b/src/qdoc/codemarker.cpp
index 7c8843c65..f9b1a163e 100644
--- a/src/qdoc/codemarker.cpp
+++ b/src/qdoc/codemarker.cpp
@@ -39,7 +39,7 @@
QT_BEGIN_NAMESPACE
QString CodeMarker::defaultLang;
-QList<CodeMarker *> CodeMarker::markers;
+QVector<CodeMarker *> CodeMarker::markers;
/*!
When a code marker constructs itself, it puts itself into
@@ -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/codemarker.h b/src/qdoc/codemarker.h
index 687d808df..4a6264ea6 100644
--- a/src/qdoc/codemarker.h
+++ b/src/qdoc/codemarker.h
@@ -86,7 +86,7 @@ private:
QString macName(const Node *parent, const QString &name = QString());
static QString defaultLang;
- static QList<CodeMarker *> markers;
+ static QVector<CodeMarker *> markers;
};
QT_END_NAMESPACE
diff --git a/src/qdoc/codeparser.cpp b/src/qdoc/codeparser.cpp
index 99bd5b1c8..b8d884a13 100644
--- a/src/qdoc/codeparser.cpp
+++ b/src/qdoc/codeparser.cpp
@@ -42,7 +42,7 @@
QT_BEGIN_NAMESPACE
-QList<CodeParser *> CodeParser::parsers;
+QVector<CodeParser *> CodeParser::parsers;
bool CodeParser::showInternal_ = false;
bool CodeParser::singleExec_ = false;
diff --git a/src/qdoc/codeparser.h b/src/qdoc/codeparser.h
index 78ef8c931..b9a85fb75 100644
--- a/src/qdoc/codeparser.h
+++ b/src/qdoc/codeparser.h
@@ -85,7 +85,7 @@ protected:
QDocDatabase *qdb_;
private:
- static QList<CodeParser *> parsers;
+ static QVector<CodeParser *> parsers;
static bool showInternal_;
static bool singleExec_;
};
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 1ffcdd39a..079ffd0e5 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;
}
}
@@ -267,7 +259,7 @@ QMap<QString, QStringList> Config::includeFilesMap_;
Config::Config(const QString &programName, const QStringList &args)
: prog(programName)
{
- numInstances++;
+ ++numInstances;
processCommandLineOptions(args);
reset();
}
@@ -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 QVector<QRegExp> subRegExps = getRegExpList(var);
- while (s != subRegExps.constEnd()) {
- if (!(*s).isValid())
- return *s;
+ for (const auto &regExp : 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
@@ -676,16 +662,12 @@ QRegExp Config::getRegExp(const QString &var) const
map, converts the string list to a list of regular expressions,
and returns it.
*/
-QList<QRegExp> Config::getRegExpList(const QString &var) const
+QVector<QRegExp> Config::getRegExpList(const QString &var) const
{
- QStringList strs = getStringList(var);
- QStringList::ConstIterator s = strs.constBegin();
- QList<QRegExp> regExps;
-
- while (s != strs.constEnd()) {
- regExps += QRegExp(*s);
- ++s;
- }
+ const QStringList strs = getStringList(var);
+ QVector<QRegExp> regExps;
+ 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);
}
@@ -962,7 +921,7 @@ QString Config::copyFile(const Location &location,
int Config::numParams(const QString &value)
{
int max = 0;
- for (int i = 0; i != value.length(); i++) {
+ for (int i = 0; i != value.length(); ++i) {
uint c = value[i].unicode();
if (c > 0 && c < 8)
max = qMax(max, static_cast<int>(c));
@@ -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/config.h b/src/qdoc/config.h
index 61ed53d87..7006f002a 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -100,7 +100,7 @@ public:
QStringList getStringList(const QString &var) const;
QStringList getCanonicalPathList(const QString &var, bool validate = false) const;
QRegExp getRegExp(const QString &var) const;
- QList<QRegExp> getRegExpList(const QString &var) const;
+ QVector<QRegExp> getRegExpList(const QString &var) const;
QSet<QString> subVars(const QString &var) const;
void subVarsAndValues(const QString &var, ConfigVarMultimap &t) const;
QStringList getAllFiles(const QString &filesVar,
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index a59654cfa..843e24db6 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -139,8 +139,9 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
!node->parent()->isHeader() &&
!node->isProperty() &&
!node->isQmlNode() &&
- !node->isJsNode())
+ !node->isJsNode()) {
name.prepend(taggedNode(node->parent()) + "::");
+ }
}
switch (node->nodeType()) {
@@ -160,7 +161,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
synopsis += QLatin1Char('(');
if (!func->parameters().isEmpty()) {
const Parameters &parameters = func->parameters();
- for (int i = 0; i < parameters.count(); i++) {
+ for (int i = 0; i < parameters.count(); ++i) {
if (i > 0)
synopsis += ", ";
QString name = parameters.at(i).name();
@@ -197,12 +198,10 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
synopsis.append(" &");
else if (func->isRefRef())
synopsis.append(" &&");
- }
- else if (style == Section::AllMembers) {
+ } else if (style == Section::AllMembers) {
if (!func->returnType().isEmpty() && func->returnType() != "void")
synopsis += " : " + typified(func->returnType());
- }
- else {
+ } else {
if (func->isRef())
synopsis.append(" &");
else if (func->isRefRef())
@@ -220,19 +219,15 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
bracketed += "virtual";
}
- if (func->access() == Node::Protected) {
+ if (func->access() == Node::Protected)
bracketed += "protected";
- }
- else if (func->access() == Node::Private) {
+ else if (func->access() == Node::Private)
bracketed += "private";
- }
- if (func->isSignal()) {
+ if (func->isSignal())
bracketed += "signal";
- }
- else if (func->isSlot()) {
+ else if (func->isSlot())
bracketed += "slot";
- }
if (!bracketed.isEmpty())
extra += QLatin1Char('[') + bracketed.join(' ') + QStringLiteral("] ");
}
@@ -259,15 +254,13 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
synopsis += ", ";
synopsis += documentedItems.at(i);
}
- }
- else {
+ } else {
for (int i = 0; i < documentedItems.size(); ++i) {
if (i < MaxEnumValues-2 || i == documentedItems.size()-1) {
if (i != 0)
synopsis += ", ";
synopsis += documentedItems.at(i);
- }
- else if (i == MaxEnumValues - 1) {
+ } else if (i == MaxEnumValues - 1) {
synopsis += ", ...";
}
}
@@ -281,8 +274,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
typedeff = static_cast<const TypedefNode *>(node);
if (typedeff->associatedEnum()) {
synopsis = "flags " + name;
- }
- else {
+ } else {
synopsis = "typedef " + name;
}
break;
@@ -294,8 +286,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
variable = static_cast<const VariableNode *>(node);
if (style == Section::AllMembers) {
synopsis = name + " : " + typified(variable->dataType());
- }
- else {
+ } else {
synopsis = typified(variable->leftType(), true) +
name + protect(variable->rightType());
}
@@ -325,9 +316,9 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
QString CppCodeMarker::markedUpQmlItem(const Node *node, bool summary)
{
QString name = taggedQmlNode(node);
- if (summary)
- name = linkTag(node,name);
- else if (node->isQmlProperty() || node->isJsProperty()) {
+ if (summary) {
+ name = linkTag(node, name);
+ } else if (node->isQmlProperty() || node->isJsProperty()) {
const QmlPropertyNode *pn = static_cast<const QmlPropertyNode *>(node);
if (pn->isAttached())
name.prepend(pn->element() + QLatin1Char('.'));
@@ -346,7 +337,7 @@ QString CppCodeMarker::markedUpQmlItem(const Node *node, bool summary)
synopsis += QLatin1Char('(');
if (!func->parameters().isEmpty()) {
const Parameters &parameters = func->parameters();
- for (int i = 0; i < parameters.count(); i++) {
+ for (int i = 0; i < parameters.count(); ++i) {
if (i > 0)
synopsis += ", ";
QString name = parameters.at(i).name();
@@ -362,8 +353,9 @@ QString CppCodeMarker::markedUpQmlItem(const Node *node, bool summary)
}
}
synopsis += QLatin1Char(')');
- } else
+ } else {
synopsis = name;
+ }
QString extra;
if (summary) {
@@ -392,20 +384,18 @@ QString CppCodeMarker::markedUpName(const Node *node)
QString CppCodeMarker::markedUpFullName(const Node *node, const Node *relative)
{
- if (node->name().isEmpty()) {
+ if (node->name().isEmpty())
return "global";
+
+ QString fullName;
+ for (;;) {
+ fullName.prepend(markedUpName(node));
+ if (node->parent() == relative || node->parent()->name().isEmpty())
+ break;
+ fullName.prepend("<@op>::</@op>");
+ node = node->parent();
}
- else {
- QString fullName;
- for (;;) {
- fullName.prepend(markedUpName(node));
- if (node->parent() == relative || node->parent()->name().isEmpty())
- break;
- fullName.prepend("<@op>::</@op>");
- node = node->parent();
- }
- return fullName;
- }
+ return fullName;
}
QString CppCodeMarker::markedUpEnumValue(const QString &enumValue, const Node *relative)
@@ -432,18 +422,15 @@ QString CppCodeMarker::markedUpIncludes(const QStringList &includes)
{
QString code;
- QStringList::ConstIterator inc = includes.constBegin();
- while (inc != includes.constEnd()) {
- code += "<@preprocessor>#include &lt;<@headerfile>" + *inc + "</@headerfile>&gt;</@preprocessor>\n";
- ++inc;
- }
+ for (const auto &include : includes)
+ code += "<@preprocessor>#include &lt;<@headerfile>"
+ + include + "</@headerfile>&gt;</@preprocessor>\n";
return code;
}
QString CppCodeMarker::functionBeginRegExp(const QString &funcName)
{
return QLatin1Char('^') + QRegExp::escape(funcName) + QLatin1Char('$');
-
}
QString CppCodeMarker::functionEndRegExp(const QString &/* funcName */)
@@ -508,7 +495,7 @@ QString CppCodeMarker::addMarkUp(const QString &in,
keywords.insert(keywordTable[j]);
}
#define readChar() \
- ch = (i < (int)code.length()) ? code[i++].cell() : EOF
+ ch = (i < code.length()) ? code[i++].cell() : EOF
QString code = in;
QString out;
@@ -620,12 +607,12 @@ QString CppCodeMarker::addMarkUp(const QString &in,
case '(':
finish = i;
readChar();
- parenDepth++;
+ ++parenDepth;
break;
case ')':
finish = i;
readChar();
- parenDepth--;
+ --parenDepth;
break;
case ':':
finish = i;
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index b05e2ab3c..ce92448de 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -710,17 +710,11 @@ void CppCodeParser::processMetaCommand(const Doc &doc,
*/
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;
+ const QStringList metaCommandsUsed = doc.metaCommandsUsed().values();
+ for (const auto &command : metaCommandsUsed) {
+ const ArgList args = doc.metaCommandArgs(command);
+ for (const auto &arg : args)
+ processMetaCommand(doc, command, arg, node);
}
}
@@ -986,18 +980,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 +1008,6 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL
docs.append(doc);
}
}
- ++arg;
}
}
}
@@ -1023,15 +1015,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);
+ QVector<Doc>::Iterator d = docs.begin();
+ 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 +1035,6 @@ void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs)
}
}
++d;
- ++n;
}
}
diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp
index 90799bd8c..83033ca51 100644
--- a/src/qdoc/doc.cpp
+++ b/src/qdoc/doc.cpp
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QSet<QString>, null_Set_QString)
Q_GLOBAL_STATIC(TopicList, nullTopicList)
Q_GLOBAL_STATIC(QStringList, null_QStringList)
-Q_GLOBAL_STATIC(QList<Text>, null_QList_Text)
+Q_GLOBAL_STATIC(QVector<Text>, null_QVector_Text)
Q_GLOBAL_STATIC(QStringMultiMap, null_QStringMultiMap)
struct Macro
@@ -298,10 +298,10 @@ class DocPrivateExtra
public:
Doc::Sections granularity_;
Doc::Sections section_; // ###
- QList<Atom *> tableOfContents_;
+ QVector<Atom *> tableOfContents_;
QVector<int> tableOfContentsLevels_;
- QList<Atom *> keywords_;
- QList<Atom *> targets_;
+ QVector<Atom *> keywords_;
+ QVector<Atom *> targets_;
QStringMultiMap metaMap_;
DocPrivateExtra()
@@ -349,7 +349,7 @@ public:
QString src;
Text text;
QSet<QString> params;
- QList<Text> alsoList;
+ QVector<Text> alsoList;
QStringList enumItemList;
QStringList omitEnumItemList;
QSet<QString> metacommandsUsed;
@@ -586,12 +586,12 @@ void DocParser::parse(const QString &source,
case '\\': {
QString cmdStr;
backslashPos = pos;
- pos++;
+ ++pos;
while (pos < len) {
ch = input_.at(pos);
if (ch.isLetterOrNumber()) {
cmdStr += ch;
- pos++;
+ ++pos;
}
else {
break;
@@ -1350,24 +1350,20 @@ void DocParser::parse(const QString &source,
} else if (macroHash()->contains(cmdStr)) {
const Macro &macro = 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);
- numPendingFi++;
+ ++numPendingFi;
}
}
}
@@ -1456,23 +1452,23 @@ void DocParser::parse(const QString &source,
case '{':
enterPara();
appendChar('{');
- braceDepth++;
- pos++;
+ ++braceDepth;
+ ++pos;
break;
case '}': {
- braceDepth--;
- pos++;
+ --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;
}
@@ -1646,7 +1642,7 @@ QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet,
int i = 0;
while (cmds[i].english != nullptr) {
commandSet.insert(*cmds[i].alias);
- i++;
+ ++i;
}
if (aliasMap()->contains(str))
@@ -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);
@@ -2141,7 +2135,7 @@ bool DocParser::expandMacro()
QString cmdStr;
int backslashPos = pos++;
- while (pos < (int) input_.length() && input_[pos].isLetterOrNumber())
+ while (pos < input_.length() && input_[pos].isLetterOrNumber())
cmdStr += input_[pos++];
endPos = pos;
@@ -2185,7 +2179,7 @@ void DocParser::expandMacro(const QString &name,
QStringList args;
QString rawString;
- for (int i = 0; i < numParams; i++) {
+ for (int i = 0; i < numParams; ++i) {
if (numParams == 1 || isLeftBraceAhead()) {
args << getArgument(true);
}
@@ -2227,7 +2221,7 @@ QString DocParser::expandMacroToString(const QString &name, const QString &def,
rawString = def;
} else {
QStringList args;
- for (int i = 0; i < numParams; i++) {
+ for (int i = 0; i < numParams; ++i) {
if (numParams == 1 || isLeftBraceAhead()) {
args << getArgument(true);
}
@@ -2307,20 +2301,20 @@ QString DocParser::getBracedArgument(bool verbatim)
{
QString arg;
int delimDepth = 0;
- if (pos < (int) input_.length() && input_[pos] == '{') {
- pos++;
- while (pos < (int) input_.length() && delimDepth >= 0) {
+ if (pos < input_.length() && input_[pos] == '{') {
+ ++pos;
+ while (pos < input_.length() && delimDepth >= 0) {
switch (input_[pos].unicode()) {
case '{':
- delimDepth++;
+ ++delimDepth;
arg += QLatin1Char('{');
- pos++;
+ ++pos;
break;
case '}':
- delimDepth--;
+ --delimDepth;
if (delimDepth >= 0)
arg += QLatin1Char('}');
- pos++;
+ ++pos;
break;
case '\\':
if (verbatim || !expandMacro())
@@ -2331,7 +2325,7 @@ QString DocParser::getBracedArgument(bool verbatim)
arg += QChar(' ');
else
arg += input_[pos];
- pos++;
+ ++pos;
}
}
if (delimDepth > 0)
@@ -2368,17 +2362,17 @@ QString DocParser::getArgument(bool verbatim)
case '(':
case '[':
case '{':
- delimDepth++;
+ ++delimDepth;
arg += input_[pos];
- pos++;
+ ++pos;
break;
case ')':
case ']':
case '}':
- delimDepth--;
+ --delimDepth;
if (pos == startPos || delimDepth >= 0) {
arg += input_[pos];
- pos++;
+ ++pos;
}
break;
case '\\':
@@ -2387,7 +2381,7 @@ QString DocParser::getArgument(bool verbatim)
break;
default:
arg += input_[pos];
- pos++;
+ ++pos;
}
}
endPos = pos;
@@ -2395,7 +2389,7 @@ QString DocParser::getArgument(bool verbatim)
(QString(".,:;!?").indexOf(input_[pos - 1]) != -1) &&
!arg.endsWith("...")) {
arg.truncate(arg.length() - 1);
- pos--;
+ --pos;
}
if (arg.length() > 2 && input_.mid(pos - 2, 2) == "'s") {
arg.truncate(arg.length() - 2);
@@ -2417,27 +2411,27 @@ QString DocParser::getBracketedArgument()
int delimDepth = 0;
skipSpacesOrOneEndl();
if (pos < input_.length() && input_[pos] == '[') {
- pos++;
+ ++pos;
while (pos < input_.length() && delimDepth >= 0) {
switch (input_[pos].unicode()) {
case '[':
- delimDepth++;
+ ++delimDepth;
arg += QLatin1Char('[');
- pos++;
+ ++pos;
break;
case ']':
- delimDepth--;
+ --delimDepth;
if (delimDepth >= 0)
arg += QLatin1Char(']');
- pos++;
+ ++pos;
break;
case '\\':
arg += input_[pos];
- pos++;
+ ++pos;
break;
default:
arg += input_[pos];
- pos++;
+ ++pos;
}
}
if (delimDepth > 0)
@@ -2449,7 +2443,7 @@ QString DocParser::getBracketedArgument()
QString DocParser::getOptionalArgument()
{
skipSpacesOrOneEndl();
- if (pos + 1 < (int) input_.length() && input_[pos] == '\\' &&
+ if (pos + 1 < input_.length() && input_[pos] == '\\' &&
input_[pos + 1].isLetterOrNumber()) {
return QString();
}
@@ -2592,7 +2586,7 @@ bool DocParser::isBlankLine()
while (i < len && input_[i].isSpace()) {
if (input_[i] == '\n')
return true;
- i++;
+ ++i;
}
return false;
}
@@ -2606,7 +2600,7 @@ bool DocParser::isLeftBraceAhead()
// ### bug with '\\'
if (input_[i] == '\n')
numEndl++;
- i++;
+ ++i;
}
return numEndl < 2 && i < len && input_[i] == '{';
}
@@ -2620,7 +2614,7 @@ bool DocParser::isLeftBracketAhead()
// ### bug with '\\'
if (input_[i] == '\n')
numEndl++;
- i++;
+ ++i;
}
return numEndl < 2 && i < len && input_[i] == '[';
}
@@ -2642,7 +2636,7 @@ void DocParser::skipSpacesOnLine()
void DocParser::skipSpacesOrOneEndl()
{
int firstEndl = -1;
- while (pos < (int) input_.length() && input_[pos].isSpace()) {
+ while (pos < input_.length() && input_[pos].isSpace()) {
QChar ch = input_[pos];
if (ch == '\n') {
if (firstEndl == -1) {
@@ -2653,14 +2647,14 @@ void DocParser::skipSpacesOrOneEndl()
break;
}
}
- pos++;
+ ++pos;
}
}
void DocParser::skipAllSpaces()
{
while (pos < len && input_[pos].isSpace())
- pos++;
+ ++pos;
}
void DocParser::skipToNextPreprocessorCommand()
@@ -2746,7 +2740,7 @@ QString DocParser::untabifyEtc(const QString &str)
result.reserve(str.length());
int column = 0;
- for (int i = 0; i < str.length(); i++) {
+ for (int i = 0; i < str.length(); ++i) {
const QChar c = str.at(i);
if (c == QLatin1Char('\r'))
continue;
@@ -2763,7 +2757,7 @@ QString DocParser::untabifyEtc(const QString &str)
continue;
}
result += c;
- column++;
+ ++column;
}
while (result.endsWith("\n\n"))
@@ -2779,14 +2773,14 @@ int DocParser::indentLevel(const QString &str)
int minIndent = INT_MAX;
int column = 0;
- for (int i = 0; i < (int) str.length(); i++) {
+ for (int i = 0; i < str.length(); ++i) {
if (str[i] == '\n') {
column = 0;
}
else {
if (str[i] != ' ' && column < minIndent)
minIndent = column;
- column++;
+ ++column;
}
}
return minIndent;
@@ -2800,7 +2794,7 @@ QString DocParser::unindent(int level, const QString &str)
QString t;
int column = 0;
- for (int i = 0; i < (int) str.length(); i++) {
+ for (int i = 0; i < str.length(); ++i) {
if (str[i] == QLatin1Char('\n')) {
t += '\n';
column = 0;
@@ -2808,7 +2802,7 @@ QString DocParser::unindent(int level, const QString &str)
else {
if (column >= level)
t += str[i];
- column++;
+ ++column;
}
}
return t;
@@ -3104,9 +3098,9 @@ ArgList Doc::metaCommandArgs(const QString &metacommand) const
return priv == nullptr ? ArgList() : priv->metaCommandMap.value(metacommand);
}
-const QList<Text> &Doc::alsoList() const
+const QVector<Text> &Doc::alsoList() const
{
- return priv == nullptr ? *null_QList_Text() : priv->alsoList;
+ return priv == nullptr ? *null_QVector_Text() : priv->alsoList;
}
bool Doc::hasTableOfContents() const
@@ -3124,7 +3118,7 @@ bool Doc::hasTargets() const
return priv && priv->extra && !priv->extra->targets_.isEmpty();
}
-const QList<Atom *> &Doc::tableOfContents() const
+const QVector<Atom *> &Doc::tableOfContents() const
{
priv->constructExtra();
return priv->extra->tableOfContents_;
@@ -3136,13 +3130,13 @@ const QVector<int> &Doc::tableOfContentsLevels() const
return priv->extra->tableOfContentsLevels_;
}
-const QList<Atom *> &Doc::keywords() const
+const QVector<Atom *> &Doc::keywords() const
{
priv->constructExtra();
return priv->extra->keywords_;
}
-const QList<Atom *> &Doc::targets() const
+const QVector<Atom *> &Doc::targets() const
{
priv->constructExtra();
return priv->extra->targets_;
@@ -3188,7 +3182,7 @@ void Doc::initialize(const Config &config)
if (cmds[i].no != i)
Location::internalError(tr("command %1 missing").arg(i));
- i++;
+ ++i;
}
for (const auto &macroName : config.subVars(CONFIG_MACRO)) {
@@ -3279,7 +3273,7 @@ void Doc::trimCStyleComment(Location &location, QString &str)
int asterColumn = location.columnNo() + 1;
int i;
- for (i = 0; i < (int) str.length(); i++) {
+ for (i = 0; i < str.length(); ++i) {
if (m.columnNo() == asterColumn) {
if (str[i] != '*')
break;
@@ -3299,7 +3293,7 @@ void Doc::trimCStyleComment(Location &location, QString &str)
if (cleaned.length() == str.length())
str = cleaned;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; ++i)
location.advance(str[i]);
str = str.mid(3, str.length() - 5);
}
diff --git a/src/qdoc/doc.h b/src/qdoc/doc.h
index d67275565..38c469ee3 100644
--- a/src/qdoc/doc.h
+++ b/src/qdoc/doc.h
@@ -50,7 +50,7 @@ class Text;
class DitaRef;
typedef QPair<QString, Location> ArgLocPair;
-typedef QList<ArgLocPair> ArgList;
+typedef QVector<ArgLocPair> ArgList;
typedef QMap<QString, QString> QStringMap;
typedef QMultiMap<QString, QString> QStringMultiMap;
@@ -63,9 +63,9 @@ struct Topic
bool isEmpty() const { return topic.isEmpty(); }
void clear() { topic.clear(); args.clear(); }
};
-typedef QList<Topic> TopicList;
+typedef QVector<Topic> TopicList;
-typedef QList<DitaRef *> DitaRefList;
+typedef QVector<DitaRef *> DitaRefList;
class DitaRef
{
@@ -154,16 +154,16 @@ public:
const QSet<QString> &metaCommandsUsed() const;
const TopicList &topicsUsed() const;
ArgList metaCommandArgs(const QString &metaCommand) const;
- const QList<Text> &alsoList() const;
+ const QVector<Text> &alsoList() const;
bool hasTableOfContents() const;
bool hasKeywords() const;
bool hasTargets() const;
bool isInternal() const;
bool isMarkedReimp() const;
- const QList<Atom *> &tableOfContents() const;
+ const QVector<Atom *> &tableOfContents() const;
const QVector<int> &tableOfContentsLevels() const;
- const QList<Atom *> &keywords() const;
- const QList<Atom *> &targets() const;
+ const QVector<Atom *> &keywords() const;
+ const QVector<Atom *> &targets() const;
const QStringMultiMap &metaTagMap() const;
static void initialize(const Config &config);
@@ -184,7 +184,7 @@ private:
static const Config *config_;
};
Q_DECLARE_TYPEINFO(Doc, Q_MOVABLE_TYPE);
-typedef QList<Doc> DocList;
+typedef QVector<Doc> DocList;
QT_END_NAMESPACE
diff --git a/src/qdoc/editdistance.cpp b/src/qdoc/editdistance.cpp
index c96071bf0..ff4630e15 100644
--- a/src/qdoc/editdistance.cpp
+++ b/src/qdoc/editdistance.cpp
@@ -44,12 +44,12 @@ int editDistance(const QString &s, const QString &t)
int *d = new int[m * n];
int result;
- for ( i = 0; i < m; i++ )
+ for (i = 0; i < m; ++i)
D( i, 0 ) = i;
- for ( j = 0; j < n; j++ )
+ for (j = 0; j < n; ++j)
D( 0, j ) = j;
- for ( i = 1; i < m; i++ ) {
- for ( j = 1; j < n; j++ ) {
+ for (i = 1; i < m; ++i) {
+ for (j = 1; j < n; ++j) {
if ( s[i - 1] == t[j - 1] ) {
D( i, j ) = D( i - 1, j - 1 );
} else {
@@ -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++;
+ ++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 184b1f67a..fe2b56b7a 100644
--- a/src/qdoc/generator.cpp
+++ b/src/qdoc/generator.cpp
@@ -36,6 +36,7 @@
#include "doc.h"
#include "editdistance.h"
#include "loggingcategory.h"
+#include "node.h"
#include "openedlist.h"
#include "qdocdatabase.h"
#include "quoter.h"
@@ -56,7 +57,7 @@ QStringList Generator::exampleDirs;
QStringList Generator::exampleImgExts;
QMap<QString, QMap<QString, QString> > Generator::fmtLeftMaps;
QMap<QString, QMap<QString, QString> > Generator::fmtRightMaps;
-QList<Generator *> Generator::generators;
+QVector<Generator *> Generator::generators;
QStringList Generator::imageDirs;
QStringList Generator::imageFiles;
QMap<QString, QStringList> Generator::imgFileExts;
@@ -144,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;
}
}
@@ -176,35 +175,29 @@ 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);
}
-int Generator::appendSortedNames(Text &text, const ClassNode *cn, const QList<RelatedClass> &rc)
+int Generator::appendSortedNames(Text &text, const ClassNode *cn, const QVector<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];
@@ -216,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];
@@ -251,30 +244,49 @@ void Generator::writeOutFileNames()
}
/*!
- Creates the file named \a fileName in the output directory.
- Attaches a QTextStream to the created file, which is written
- to all over the place using out(). This function does not
- store the \a fileName in the \a node as the output file name.
+ Creates the file named \a fileName in the output directory
+ and returns a QFile pointing to this file. In particular,
+ this method deals with errors when opening the file:
+ the returned QFile is always valid and can be written to.
- \sa beginSubPage()
+ \sa beginFilePage()
*/
-void Generator::beginFilePage(const Node *node, const QString &fileName)
+QFile *Generator::openSubPageFile(const Node *node, const QString &fileName)
{
QString path = outputDir() + QLatin1Char('/');
if (Generator::useOutputSubdirs() && !node->outputSubdirectory().isEmpty() &&
- !outputDir().endsWith(node->outputSubdirectory()))
+ !outputDir().endsWith(node->outputSubdirectory())) {
path += node->outputSubdirectory() + QLatin1Char('/');
+ }
path += fileName;
- QFile* outFile = new QFile(redirectDocumentationToDevNull_ ? QStringLiteral("/dev/null") : path);
- if (!redirectDocumentationToDevNull_ && outFile->exists())
- node->location().error(tr("Output file already exists; overwriting %1").arg(outFile->fileName()));
- if (!outFile->open(QFile::WriteOnly))
- node->location().fatal(tr("Cannot open output file '%1'").arg(outFile->fileName()));
+ auto outPath = redirectDocumentationToDevNull_ ? QStringLiteral("/dev/null") : path;
+ auto outFile = new QFile(outPath);
+ if (!redirectDocumentationToDevNull_ && outFile->exists()) {
+ node->location().error(
+ tr("Output file already exists; overwriting %1").arg(outFile->fileName()));
+ }
+ if (!outFile->open(QFile::WriteOnly)) {
+ node->location().fatal(
+ tr("Cannot open output file '%1'").arg(outFile->fileName()));
+ }
qCDebug(lcQdoc, "Writing: %s", qPrintable(path));
outFileNames_ << fileName;
- QTextStream* out = new QTextStream(outFile);
+ return outFile;
+}
+/*!
+ Creates the file named \a fileName in the output directory.
+ Attaches a QTextStream to the created file, which is written
+ to all over the place using out(). This function does not
+ store the \a fileName in the \a node as the output file name.
+
+ \sa beginSubPage()
+ */
+void Generator::beginFilePage(const Node *node, const QString &fileName)
+{
+ QFile *outFile = openSubPageFile(node, fileName);
+ QTextStream* out = new QTextStream(outFile);
#ifndef QT_NO_TEXTCODEC
if (outputCodec)
out->setCodec(outputCodec);
@@ -704,7 +716,7 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir)
void Generator::generateAlsoList(const Node *node, CodeMarker *marker)
{
- QList<Text> alsoList = node->doc().alsoList();
+ QVector<Text> alsoList = node->doc().alsoList();
supplementAlsoList(node, alsoList);
if (!alsoList.isEmpty()) {
@@ -867,66 +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 QVector<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);
- QSet<QString> declaredNames;
- fn->parameters().getNames(declaredNames);
- QSet<QString> documentedNames = fn->doc().parameterNames();
+ const QSet<QString> declaredNames = fn->parameters().getNames();
+ 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;
}
}
/*
@@ -1014,6 +1016,25 @@ void Generator::generateLinkToExample(const ExampleNode *en,
generateText(text, nullptr, marker);
}
+void Generator::addImageToCopy(const ExampleNode *en, const QString &file)
+{
+ QDir dirInfo;
+ QString userFriendlyFilePath;
+ const QString prefix("/images/used-in-examples/");
+ QString srcPath = Config::findFile(en->location(),
+ QStringList(),
+ exampleDirs,
+ file,
+ exampleImgExts,
+ &userFriendlyFilePath);
+ outFileNames_ << prefix.mid(1) + userFriendlyFilePath;
+ userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/'));
+ QString imgOutDir = outDir_ + prefix + userFriendlyFilePath;
+ if (!dirInfo.mkpath(imgOutDir))
+ en->location().fatal(tr("Cannot create output directory '%1'").arg(imgOutDir));
+ Config::copyFile(en->location(), srcPath, file, imgOutDir);
+}
+
/*!
This function is called when the documentation for an example is
being formatted. It outputs a list of files for the example, which
@@ -1045,26 +1066,9 @@ void Generator::generateFileList(const ExampleNode *en, CodeMarker *marker, bool
QString path;
for (const auto &file : qAsConst(paths)) {
if (images) {
- if (!file.isEmpty()) {
- QDir dirInfo;
- QString userFriendlyFilePath;
- const QString prefix("/images/used-in-examples/");
- QString srcPath = Config::findFile(en->location(),
- QStringList(),
- exampleDirs,
- file,
- exampleImgExts,
- &userFriendlyFilePath);
- outFileNames_ << prefix.mid(1) + userFriendlyFilePath;
- userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/'));
- QString imgOutDir = outDir_ + prefix + userFriendlyFilePath;
- if (!dirInfo.mkpath(imgOutDir))
- en->location().fatal(tr("Cannot create output directory '%1'").arg(imgOutDir));
- Config::copyFile(en->location(), srcPath, file, imgOutDir);
- }
-
- }
- else {
+ if (!file.isEmpty())
+ addImageToCopy(en, file);
+ } else {
generateExampleFilePage(en, file, marker);
}
@@ -1102,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
@@ -1112,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 QVector<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);
@@ -1476,15 +1476,15 @@ bool Generator::generateText(const Text &text,
nonreentrant, and true is returned. If there are no exceptions,
the three node lists remain empty and false is returned.
*/
-static bool hasExceptions(const Node *node,
- NodeList &reentrant,
- NodeList &threadsafe,
- NodeList &nonreentrant)
+bool Generator::hasExceptions(const Node *node,
+ NodeList &reentrant,
+ NodeList &threadsafe,
+ NodeList &nonreentrant)
{
bool result = false;
Node::ThreadSafeness ts = node->threadSafeness();
const NodeList &children = static_cast<const Aggregate *>(node)->childNodes();
- for (auto *child : children) {
+ for (auto child : children) {
if (!child->isObsolete()){
switch (child->threadSafeness()) {
case Node::Reentrant:
@@ -1632,19 +1632,16 @@ void Generator::generateThreadSafeness(const Node *node, CodeMarker *marker)
}
/*!
- If the node is an overloaded signal, and a node with an example on how to connect to it
-
- Someone didn't finish writing this comment, and I don't know what this
- function is supposed to do, so I have not tried to complete the comment
- yet.
+ Returns the string containing an example code of the input node,
+ if it is an overloaded signal. Otherwise, returns an empty string.
*/
-void Generator::generateOverloadedSignal(const Node *node, CodeMarker *marker)
+QString Generator::getOverloadedSignalCode(const Node *node)
{
if (!node->isFunction())
- return;
- const FunctionNode *func = static_cast<const FunctionNode *>(node);
+ return QString();
+ const auto func = static_cast<const FunctionNode *>(node);
if (!func->isSignal() || !func->hasOverloads())
- return;
+ return QString();
// Compute a friendly name for the object of that instance.
// e.g: "QAbstractSocket" -> "abstractSocket"
@@ -1656,16 +1653,31 @@ void Generator::generateOverloadedSignal(const Node *node, CodeMarker *marker)
}
// We have an overloaded signal, show an example. Note, for const
- // overloaded signals one should use Q{Const,NonConst}Overload, but
+ // overloaded signals, one should use Q{Const,NonConst}Overload, but
// it is very unlikely that we will ever have public API overloading
// signals by const.
QString code = "connect(" + objectName + ", QOverload<";
- func->parameters().getTypeList(code);
+ code += func->parameters().generateTypeList();
code += ">::of(&" + func->parent()->name() + "::" + func->name() + "),\n [=](";
- func->parameters().getTypeAndNameList(code);
-
+ code += func->parameters().generateTypeAndNameList();
code += "){ /* ... */ });";
+ return code;
+}
+
+/*!
+ If the node is an overloaded signal, and a node with an example on how to connect to it
+
+ Someone didn't finish writing this comment, and I don't know what this
+ function is supposed to do, so I have not tried to complete the comment
+ yet.
+ */
+void Generator::generateOverloadedSignal(const Node *node, CodeMarker *marker)
+{
+ QString code = getOverloadedSignalCode(node);
+ if (code.isEmpty())
+ return;
+
Text text;
text << Atom::ParaLeft
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
@@ -1679,12 +1691,11 @@ void Generator::generateOverloadedSignal(const Node *node, CodeMarker *marker)
"To connect to this signal by using the function pointer syntax, Qt "
"provides a convenient helper for obtaining the function pointer as "
"shown in this example:"
- << Atom(Atom::Code, marker->markedUpCode(code, node, func->location()));
+ << Atom(Atom::Code, marker->markedUpCode(code, node, node->location()));
generateText(text, node, marker);
}
-
/*!
Traverses the database recursively to generate all the documentation.
*/
@@ -1696,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;
}
@@ -1954,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);
}
/*!
@@ -2158,7 +2163,7 @@ void Generator::initializeTextOutput()
sectionNumber_.clear();
}
-void Generator::supplementAlsoList(const Node *node, QList<Text> &alsoList)
+void Generator::supplementAlsoList(const Node *node, QVector<Text> &alsoList)
{
if (node->isFunction() && !node->isMacro()) {
const auto fn = static_cast<const FunctionNode *>(node);
@@ -2211,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();
@@ -2267,7 +2270,7 @@ QString Generator::typeString(const Node *node)
case Node::Typedef:
return "typedef";
case Node::Function: {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto fn = static_cast<const FunctionNode *>(node);
switch (fn->metaness()) {
case FunctionNode::JsSignal:
case FunctionNode::QmlSignal:
diff --git a/src/qdoc/generator.h b/src/qdoc/generator.h
index f90c82315..2ed902ec6 100644
--- a/src/qdoc/generator.h
+++ b/src/qdoc/generator.h
@@ -29,7 +29,6 @@
#ifndef GENERATOR_H
#define GENERATOR_H
-#include "node.h"
#include "text.h"
#include <QtCore/qlist.h>
@@ -46,6 +45,7 @@ typedef QMap<Node *, NodeMultiMap> ParentMaps;
class Config;
class CodeMarker;
class Location;
+class Node;
class QDocDatabase;
class Generator
@@ -103,6 +103,7 @@ public:
static bool useTimestamps() { return useTimestamps_; }
protected:
+ static QFile *openSubPageFile(const Node *node, const QString &fileName);
void beginFilePage(const Node *node, const QString &fileName);
void endFilePage() { endSubPage(); } // for symmetry
void beginSubPage(const Node *node, const QString &fileName);
@@ -140,7 +141,7 @@ protected:
static QString outputPrefix(const Node *node);
static QString outputSuffix(const Node *node);
static void singularPlural(Text &text, const NodeList &nodes);
- static void supplementAlsoList(const Node *node, QList<Text> &alsoList);
+ static void supplementAlsoList(const Node *node, QVector<Text> &alsoList);
static QString trimmedTrailing(const QString &string,
const QString &prefix,
const QString &suffix);
@@ -164,6 +165,7 @@ protected:
QString getMetadataElement(const Aggregate *inner, const QString &t);
QStringList getMetadataElements(const Aggregate *inner, const QString &t);
void generateOverloadedSignal(const Node *node, CodeMarker *marker);
+ static QString getOverloadedSignalCode(const Node *node);
QString indent(int level, const QString &markedCode);
QTextStream& out();
QString outFileName();
@@ -178,6 +180,11 @@ protected:
void unknownAtom(const Atom *atom);
int appendSortedQmlNames(Text &text, const Node *base, const NodeList &subs);
+ static bool hasExceptions(const Node *node,
+ NodeList &reentrant,
+ NodeList &threadsafe,
+ NodeList &nonreentrant);
+
QMap<QString, QStringList> editionGroupMap;
QMap<QString, QStringList> editionModuleMap;
QString naturalLanguage;
@@ -197,17 +204,20 @@ protected:
const QString &fullName,
const Node *actualNode);
void appendFullNames(Text &text, const NodeList &nodes, const Node *relative);
- int appendSortedNames(Text &text, const ClassNode *classe, const QList<RelatedClass> &classes);
+ int appendSortedNames(Text &text, const ClassNode *classe,
+ const QVector<RelatedClass> &classes);
void appendSignature(Text &text, const Node *node);
void signatureList(const NodeList &nodes, const Node *relative, CodeMarker *marker);
+ void addImageToCopy(const ExampleNode *en, const QString &file);
+
private:
static Generator *currentGenerator_;
static QStringList exampleDirs;
static QStringList exampleImgExts;
static QMap<QString, QMap<QString, QString> > fmtLeftMaps;
static QMap<QString, QMap<QString, QString> > fmtRightMaps;
- static QList<Generator *> generators;
+ static QVector<Generator *> generators;
static QStringList imageDirs;
static QStringList imageFiles;
static QMap<QString, QStringList> imgFileExts;
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/helpprojectwriter.h b/src/qdoc/helpprojectwriter.h
index 64ad3aaec..222a5f097 100644
--- a/src/qdoc/helpprojectwriter.h
+++ b/src/qdoc/helpprojectwriter.h
@@ -67,13 +67,13 @@ struct HelpProject
QString fileName;
QString indexRoot;
QString indexTitle;
- QList<QStringList> keywords;
+ QVector<QStringList> keywords;
QSet<QString> files;
QSet<QString> extraFiles;
QSet<QString> filterAttributes;
QHash<QString, QSet<QString>> customFilters;
QSet<QString> excluded;
- QList<SubProject> subprojects;
+ QVector<SubProject> subprojects;
QHash<const Node *, NodeStatusSet> memberStatus;
bool includeIndexNodes;
};
@@ -112,7 +112,7 @@ private:
Generator *gen_;
QString outputDir;
- QList<HelpProject> projects;
+ QVector<HelpProject> projects;
};
QT_END_NAMESPACE
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 97222ef13..a336467ba 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
@@ -569,25 +565,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
break;
}
out() << "<p>";
- if (relative->isProperty() || relative->isVariable()) {
- atom = atom->next();
- if (atom != nullptr && atom->type() == Atom::String) {
- QString firstWord = atom->string().toLower().section(' ', 0, 0, QString::SectionSkipEmpty);
- if (firstWord == QLatin1String("the")
- || firstWord == QLatin1String("a")
- || firstWord == QLatin1String("an")
- || firstWord == QLatin1String("whether")
- || firstWord == QLatin1String("which")) {
- QString str = "This ";
- if (relative->isProperty())
- str += "property holds ";
- else
- str += "variable holds ";
- str += atom->string().left(1).toLower() + atom->string().mid(1);
- const_cast<Atom *>(atom)->setString(str);
- }
- }
- }
+ rewritePropertyBrief(atom, relative);
break;
case Atom::BriefRight:
if (hasBrief(relative))
@@ -598,12 +576,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
// now widely used to write teletype text. As a result, text marked
// with the \c command is not passed to a code marker.
out() << formattingLeftMap()[ATOM_FORMATTING_TELETYPE];
- if (inLink_) {
- out() << protectEnc(plainCode(atom->string()));
- }
- else {
- out() << protectEnc(plainCode(atom->string()));
- }
+ out() << protectEnc(plainCode(atom->string()));
out() << formattingRightMap()[ATOM_FORMATTING_TELETYPE];
break;
case Atom::CaptionLeft:
@@ -728,13 +701,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
}
else if ((idx = atom->string().indexOf(QStringLiteral("bymodule"))) != -1) {
QString moduleName = atom->string().mid(idx + 8).trimmed();
- Node::NodeType type = Node::Module;
- if (atom->string().startsWith(QLatin1String("qml")))
- type = Node::QmlModule;
- else if (atom->string().startsWith(QLatin1String("js")))
- type = Node::JsModule;
- else if (atom->string().startsWith(QLatin1String("groups")))
- type = Node::Group;
+ Node::NodeType type = typeFromString(atom);
QDocDatabase *qdb = QDocDatabase::qdocDB();
const CollectionNode *cn = qdb->getCollectionNode(moduleName, type);
if (cn) {
@@ -816,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 &section : 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 &section : 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)
@@ -845,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;
@@ -908,13 +869,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
out() << " alt=\"\"";
out() << " />";
helpProjectWriter->addExtraFile(fileName);
- if (relative->isExample()) {
- const ExampleNode *cen = static_cast<const ExampleNode *>(relative);
- if (cen->imageFileName().isEmpty()) {
- ExampleNode *en = const_cast<ExampleNode *>(cen);
- en->setImageFileName(fileName);
- }
- }
+ setImageFileName(relative, fileName);
}
if (atom->type() == Atom::Image)
out() << "</p>";
@@ -969,23 +924,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
QString target = qdb_->getNewLinkTarget(relative, node, outFileName(), text);
out() << "<a id=\"" << Doc::canonicalTitle(target) << "\" class=\"qa-mark\"></a>";
}
- /*
- mws saw this on 17/10/2014.
- Is this correct? Setting node to 0 means the
- following test always fails. Did we decide to
- no longer warn about linking to obsolete things?
- */
node = nullptr;
- if (node && node->isObsolete()) {
- if ((relative->parent() != node) && !relative->isObsolete()) {
- inObsoleteLink = true;
- if (obsoleteLinks) {
- relative->doc().location().warning(tr("Link to obsolete item '%1' in %2")
- .arg(atom->string())
- .arg(relative->plainFullName()));
- }
- }
- }
}
beginLink(link, node, relative);
skipAhead = 1;
@@ -1082,24 +1021,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
out() << "<dt>";
}
else { // (atom->string() == ATOM_LIST_VALUE)
- const Atom *lookAhead = atom->next();
- QString t = lookAhead->string();
- lookAhead = lookAhead->next();
- Q_ASSERT(lookAhead->type() == Atom::ListTagRight);
- lookAhead = lookAhead->next();
- if (lookAhead && lookAhead->type() == Atom::SinceTagLeft) {
- lookAhead = lookAhead->next();
- Q_ASSERT(lookAhead && lookAhead->type() == Atom::String);
- t = t + QLatin1String(" (since ");
- if (lookAhead->string().at(0).isDigit())
- t = t + QLatin1String("Qt ");
- t = t + lookAhead->string() + QLatin1String(")");
- skipAhead = 4;
- }
- else {
- skipAhead = 1;
- }
- t = protectEnc(plainCode(marker->markedUpEnumValue(t, relative)));
+ QPair<QString, int> pair = getAtomListValue(atom);
+ skipAhead = pair.second;
+ QString t = protectEnc(plainCode(marker->markedUpEnumValue(pair.first, relative)));
out() << "<tr><td class=\"topAlign\"><code>" << t << "</code>";
if (relative->isEnumType()) {
@@ -1215,30 +1139,15 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
break;
case Atom::TableLeft:
{
- QString p1, p2;
- QString attr = "generic";
- QString width;
+ QPair<QString, QString> pair = getTableWidthAttr(atom);
+ QString attr = pair.second;
+ QString width = pair.first;
+
if (in_para) {
out() << "</p>\n";
in_para = false;
}
- if (atom->count() > 0) {
- p1 = atom->string(0);
- if (atom->count() > 1)
- p2 = atom->string(1);
- }
- if (!p1.isEmpty()) {
- if (p1 == QLatin1String("borderless"))
- attr = p1;
- else if (p1.contains(QLatin1Char('%')))
- width = p1;
- }
- if (!p2.isEmpty()) {
- if (p2 == QLatin1String("borderless"))
- attr = p2;
- else if (p2.contains(QLatin1Char('%')))
- width = p2;
- }
+
out() << "<div class=\"table\"><table class=\"" << attr << '"';
if (!width.isEmpty())
out() << " width=\"" << width << '"';
@@ -1303,7 +1212,6 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
out() << '>';
else {
out() << '>';
- //out() << "><p>";
}
if (matchAhead(atom, Atom::ParaLeft))
skipAhead = 1;
@@ -1314,7 +1222,6 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
out() << "</th>";
else {
out() << "</td>";
- //out() << "</p></td>";
}
if (matchAhead(atom, Atom::ParaLeft))
skipAhead = 1;
@@ -1446,45 +1353,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 &section : 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 &section : qAsConst(*summarySections)) {
+ if (section.members().isEmpty() && !section.inheritedMembers().isEmpty())
+ generateSectionInheritedList(section, aggregate);
}
out() << "</ul>\n";
}
@@ -1508,42 +1410,38 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m
generateExtractionMark(aggregate, EndMark);
}
- s = detailsSections->constBegin();
- while (s != detailsSections->constEnd()) {
+ for (const auto &section :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();
@@ -1553,8 +1451,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();
@@ -1566,11 +1464,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);
}
@@ -1595,16 +1491,13 @@ 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()) {
- // out() << "<hr />\n";
- QString ref = registerRef(s->title().toLower());
+ for (auto it = summarySections->constBegin(); it != summarySections->constEnd(); ++it) {
+ if (!it->members().isEmpty()) {
+ 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");
@@ -1612,7 +1505,6 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker)
if (!aggregate->doc().isEmpty()) {
generateExtractionMark(aggregate, DetailedDescriptionMark);
- //out() << "<hr />\n"
out() << "<div class=\"descr\">\n" // QTBUG-9504
<< "<h2 id=\"" << detailsRef << "\">" << "Detailed Description" << "</h2>\n";
generateBody(aggregate, marker);
@@ -1622,54 +1514,47 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker)
generateExtractionMark(aggregate, EndMark);
}
- s = detailsSections->constBegin();
- while (s != detailsSections->constEnd()) {
- if (s->isEmpty()) {
- ++s;
+ for (const auto &section : 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);
}
@@ -1712,16 +1597,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 &section : 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);
@@ -1734,20 +1618,17 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker)
generateQmlText(cn->doc().body(), cn, marker, qcn->name());
generateAlsoList(qcn, 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 &section : 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);
@@ -1778,16 +1659,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 &section : 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);
@@ -1798,18 +1678,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 &section : 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);
}
@@ -1942,13 +1820,10 @@ 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);
}
@@ -1969,7 +1844,7 @@ void HtmlGenerator::generateNavigationBar(const QString &title,
const QString &buildversion,
bool tableItems)
{
- if (noNavigationBar)
+ if (noNavigationBar || node == nullptr)
return;
Text navigationbar;
@@ -2335,25 +2210,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)
@@ -2375,19 +2247,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>";
}
}
@@ -2412,14 +2283,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());
@@ -2495,23 +2358,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>";
}
}
@@ -2554,7 +2423,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node,
CodeMarker *marker,
QVector<Section> *sections)
{
- QList<Atom *> toc;
+ QVector<Atom *> toc;
if (node->doc().hasTableOfContents())
toc = node->doc().tableOfContents();
if (tocDepth == 0 || (toc.isEmpty() && !sections && !node->isModule())) {
@@ -2605,26 +2474,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 &section : 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"
@@ -2641,8 +2508,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.
@@ -2803,22 +2669,18 @@ QString HtmlGenerator::generateObsoleteMembersFile(const Sections &sections, 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 &section = *summary_spv.at(i);
- generateSectionList(section, aggregate, marker, Section::Obsolete);
+ for (const auto &section : 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 &section : 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);
}
}
@@ -2863,22 +2725,20 @@ QString HtmlGenerator::generateObsoleteQmlMembersFile(const Sections &sections,
<< "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 &section : 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 &section : 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;
}
}
@@ -2893,12 +2753,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;
@@ -2939,7 +2797,7 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative,
CodeMarker *marker,
const NodeMultiMap &nmm)
{
- if (nmm.isEmpty())
+ if (nmm.isEmpty() || relative == nullptr)
return;
generateAnnotatedList(relative, marker, nmm.values());
}
@@ -3051,8 +2909,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))
@@ -3072,7 +2929,6 @@ void HtmlGenerator::generateCompactList(ListType listType,
paragraphName[paragraphNr] = key[0].toUpper();
usedParagraphNames.insert(key[0].toLower().cell());
paragraph[paragraphNr].insert(last, c.value());
- ++c;
}
/*
@@ -3217,26 +3073,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";
}
@@ -3247,7 +3099,6 @@ void HtmlGenerator::generateLegaleseList(const Node *relative, CodeMarker *marke
QMap<Text, const Node *>::ConstIterator it = legaleseTexts.constBegin();
while (it != legaleseTexts.constEnd()) {
Text text = it.key();
- //out() << "<hr />\n";
generateText(text, relative, marker);
out() << "<ul>\n";
do {
@@ -3331,7 +3182,7 @@ void HtmlGenerator::generateList(const Node *relative, CodeMarker *marker, const
if (type != Node::NoType) {
NodeList nodeList;
qdb_->mergeCollections(type, cnm, relative);
- const CollectionList collectionList = cnm.values();
+ const auto collectionList = cnm.values();
nodeList.reserve(collectionList.size());
for (auto *collectionNode : collectionList)
nodeList.append(collectionNode);
@@ -3375,29 +3226,25 @@ 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\"> ";
}
else {
- if (twoColumn && i == (int) (nv.count() + 1) / 2)
+ if (twoColumn && i == (nv.count() + 1) / 2)
out() << "</ul></td><td class=\"topAlign\"><ul>\n";
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";
@@ -3438,18 +3285,15 @@ 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\"> ";
}
else {
- if (twoColumn && i == (int) (members.count() + 1) / 2)
+ if (twoColumn && i == (members.count() + 1) / 2)
out() << "</ul></td><td class=\"topAlign\"><ul>\n";
out() << "<li class=\"fn\">";
}
@@ -3460,9 +3304,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)
@@ -3479,7 +3323,6 @@ void HtmlGenerator::generateSectionList(const Section& section,
else
out() << "</li>\n";
i++;
- ++m;
}
if (alignNames)
out() << "</table></div>\n";
@@ -3503,25 +3346,23 @@ 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 QVector<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;
}
}
-// generateSynopsis(*m, relative, marker, Section::Summary, alignNames);
void HtmlGenerator::generateSynopsis(const Node *node,
const Node *relative,
CodeMarker *marker,
@@ -3745,23 +3586,6 @@ void HtmlGenerator::generateLink(const Atom *atom, CodeMarker *marker)
}
}
-QString HtmlGenerator::registerRef(const QString &ref)
-{
- QString clean = Generator::cleanRef(ref);
-
- for (;;) {
- QString &prevRef = refMap[clean.toLower()];
- if (prevRef.isEmpty()) {
- prevRef = ref;
- break;
- } else if (prevRef == ref) {
- break;
- }
- clean += QLatin1Char('x');
- }
- return clean;
-}
-
QString HtmlGenerator::protectEnc(const QString &string)
{
#ifndef QT_NO_TEXTCODEC
@@ -3829,199 +3653,6 @@ QString HtmlGenerator::fileName(const Node *node)
return Generator::fileName(node);
}
-QString HtmlGenerator::refForNode(const Node *node)
-{
- QString ref;
- switch (node->nodeType()) {
- case Node::Enum:
- ref = node->name() + "-enum";
- break;
- case Node::Typedef:
- {
- const TypedefNode *tdn = static_cast<const TypedefNode *>(node);
- if (tdn->associatedEnum())
- return refForNode(tdn->associatedEnum());
- else
- ref = node->name() + "-typedef";
- }
- break;
- case Node::Function:
- {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
- switch (fn->metaness()) {
- case FunctionNode::JsSignal:
- case FunctionNode::QmlSignal:
- ref = fn->name() + "-signal";
- break;
- case FunctionNode::JsSignalHandler:
- case FunctionNode::QmlSignalHandler:
- ref = fn->name() + "-signal-handler";
- break;
- case FunctionNode::JsMethod:
- case FunctionNode::QmlMethod:
- ref = fn->name() + "-method";
- if (fn->overloadNumber() != 0)
- ref += QLatin1Char('-') + QString::number(fn->overloadNumber());
- break;
- default:
- if (fn->hasOneAssociatedProperty() && fn->doc().isEmpty()) {
- return refForNode(fn->firstAssociatedProperty());
- } else {
- ref = fn->name();
- if (fn->overloadNumber() != 0)
- ref += QLatin1Char('-') + QString::number(fn->overloadNumber());
- }
- break;
- }
- }
- break;
- case Node::JsProperty:
- case Node::QmlProperty:
- if (node->isAttached())
- ref = node->name() + "-attached-prop";
- else
- ref = node->name() + "-prop";
- break;
- case Node::Property:
- ref = node->name() + "-prop";
- break;
- case Node::Variable:
- ref = node->name() + "-var";
- break;
- case Node::SharedComment:
- if (node->isPropertyGroup())
- ref = node->name() + "-prop";
- break;
- default:
- break;
- }
- return registerRef(ref);
-}
-
-/*!
- This function is called for links, i.e. for words that
- are marked with the qdoc link command. For autolinks
- that are not marked with the qdoc link command, the
- getAutoLink() function is called
-
- It returns the string for a link found by using the data
- in the \a atom to search the database. It also sets \a node
- to point to the target node for that link. \a relative points
- to the node holding the qdoc comment where the link command
- was found.
- */
-QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Node** node)
-{
- const QString &t = atom->string();
- if (t.at(0) == QChar('h')) {
- if (t.startsWith("http:") || t.startsWith("https:"))
- return t;
- }
- else if (t.at(0) == QChar('f')) {
- if (t.startsWith("file:") || t.startsWith("ftp:"))
- return t;
- }
- else if (t.at(0) == QChar('m')) {
- if (t.startsWith("mailto:"))
- return t;
- }
- return getAutoLink(atom, relative, node);
-}
-
-/*!
- This function is called for autolinks, i.e. for words that
- are not marked with the qdoc link command that qdoc has
- reason to believe should be links. For links marked with
- the qdoc link command, the getLink() function is called.
-
- It returns the string for a link found by using the data
- in the \a atom to search the database. It also sets \a node
- to point to the target node for that link. \a relative points
- to the node holding the qdoc comment where the link command
- was found.
- */
-QString HtmlGenerator::getAutoLink(const Atom *atom, const Node *relative, const Node** node)
-{
- QString ref;
-
- *node = qdb_->findNodeForAtom(atom, relative, ref);
- if (!(*node)) {
- return QString();
- }
-
- QString link = (*node)->url();
- if (link.isEmpty())
- link = linkForNode(*node, relative);
- if (!ref.isEmpty()) {
- int hashtag = link.lastIndexOf(QChar('#'));
- if (hashtag != -1)
- link.truncate(hashtag);
- link += QLatin1Char('#') + ref;
- }
- return link;
-}
-
-/*!
- Construct the link string for the \a node and return it.
- The \a relative node is use to decide the link we are
- generating is in the same file as the target. Note the
- relative node can be 0, which pretty much guarantees
- that the link and the target aren't in the same file.
- */
-QString HtmlGenerator::linkForNode(const Node *node, const Node *relative)
-{
- if (node == nullptr)
- return QString();
- if (!node->url().isEmpty())
- return node->url();
- if (fileBase(node).isEmpty())
- return QString();
- if (node->isPrivate())
- return QString();
- QString fn = fileName(node);
- if (node && node->parent() &&
- (node->parent()->isQmlType() || node->parent()->isJsType())
- && node->parent()->isAbstract()) {
- if (Generator::qmlTypeContext()) {
- if (Generator::qmlTypeContext()->inherits(node->parent())) {
- fn = fileName(Generator::qmlTypeContext());
- }
- else if (node->parent()->isInternal()) {
- node->doc().location().warning(tr("Cannot link to property in internal type '%1'").arg(node->parent()->name()));
- return QString();
- }
- }
- }
- QString link = fn;
-
- if (!node->isPageNode() || node->isPropertyGroup()) {
- QString ref = refForNode(node);
- if (relative && fn == fileName(relative) && ref == refForNode(relative))
- return QString();
-
- link += QLatin1Char('#');
- link += ref;
- }
- /*
- If the output is going to subdirectories, then if the
- two nodes will be output to different directories, then
- the link must go up to the parent directory and then
- back down into the other subdirectory.
- */
- if (node && relative && (node != relative)) {
- if (useOutputSubdirs() && !node->isExternalPage() &&
- node->outputSubdirectory() != relative->outputSubdirectory()) {
- if (link.startsWith(QString(node->outputSubdirectory() + QLatin1Char('/')))) {
- link.prepend(QString("../"));
- }
- else {
- link.prepend(QString("../" + node->outputSubdirectory() + QLatin1Char('/')));
- }
- }
- }
- return link;
-}
-
void HtmlGenerator::generateFullName(const Node *apparentNode, const Node *relative, const Node *actualNode)
{
if (actualNode == nullptr)
@@ -4089,7 +3720,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node,
generateSince(node, marker);
if (node->isProperty()) {
- const PropertyNode *property = static_cast<const PropertyNode *>(node);
+ const auto property = static_cast<const PropertyNode *>(node);
Section section(Section::Accessors, Section::Active);
section.appendMembers(property->getters().toVector());
@@ -4106,7 +3737,6 @@ void HtmlGenerator::generateDetailedMember(const Node *node,
if (!notifiers.members().isEmpty()) {
out() << "<p><b>Notifier signal:</b></p>\n";
- //out() << "<p>This signal is emitted when the property value is changed.</p>\n";
generateSectionList(notifiers, node, marker);
}
}
@@ -4134,53 +3764,6 @@ void HtmlGenerator::generateDetailedMember(const Node *node,
generateExtractionMark(node, EndMark);
}
-int HtmlGenerator::hOffset(const Node *node)
-{
- switch (node->nodeType()) {
- case Node::Namespace:
- case Node::Class:
- case Node::Struct:
- case Node::Union:
- case Node::Module:
- return 2;
- case Node::QmlModule:
- case Node::QmlBasicType:
- case Node::QmlType:
- case Node::Page:
- return 1;
- case Node::Enum:
- case Node::Typedef:
- case Node::Function:
- case Node::Property:
- default:
- return 3;
- }
-}
-
-bool HtmlGenerator::isThreeColumnEnumValueTable(const Atom *atom)
-{
- while (atom != nullptr && !(atom->type() == Atom::ListRight && atom->string() == ATOM_LIST_VALUE)) {
- if (atom->type() == Atom::ListItemLeft && !matchAhead(atom, Atom::ListItemRight))
- return true;
- atom = atom->next();
- }
- return false;
-}
-
-
-const QPair<QString,QString> HtmlGenerator::anchorForNode(const Node *node)
-{
- QPair<QString,QString> anchorPair;
-
- anchorPair.first = Generator::fileName(node);
- if (node->isPageNode()) {
- const PageNode *pn = static_cast<const PageNode *>(node);
- anchorPair.second = pn->title();
- }
-
- return anchorPair;
-}
-
#ifdef GENERATE_MAC_REFS
/*
No longer valid.
@@ -4256,28 +3839,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";
}
@@ -4311,7 +3891,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()) {
@@ -4323,9 +3902,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>";
@@ -4338,7 +3918,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node,
generateQmlItem(qpn, relative, marker, false);
out() << "</p></td></tr>";
}
- ++p;
}
out() << "</table></div>";
out() << "</div>";
@@ -4361,19 +3940,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;
@@ -4550,9 +4129,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;
@@ -4563,7 +4141,6 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString
proceed = true;
break;
}
- ++i;
}
if (!proceed || !file.open(QFile::WriteOnly | QFile::Text))
return;
@@ -4576,17 +4153,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
@@ -4761,8 +4333,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"));
@@ -4772,7 +4343,6 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString
}
writer.writeEndElement(); // example
- ++i;
}
writer.writeEndElement(); // examples
diff --git a/src/qdoc/htmlgenerator.h b/src/qdoc/htmlgenerator.h
index c1564c5b0..86801e0af 100644
--- a/src/qdoc/htmlgenerator.h
+++ b/src/qdoc/htmlgenerator.h
@@ -35,7 +35,7 @@
#include "codemarker.h"
#include "config.h"
-#include "generator.h"
+#include "xmlgenerator.h"
#include <QtCore/qhash.h>
#include <QtCore/qregexp.h>
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
class HelpProjectWriter;
-class HtmlGenerator : public Generator
+class HtmlGenerator : public XmlGenerator
{
Q_DECLARE_TR_FUNCTIONS(QDoc::HtmlGenerator)
@@ -80,17 +80,12 @@ protected:
void generateCollectionNode(CollectionNode *cn, CodeMarker *marker) override;
void generateGenericCollectionPage(CollectionNode *cn, CodeMarker *marker) override;
QString fileExtension() const override;
- virtual QString refForNode(const Node *node);
- virtual QString linkForNode(const Node *node, const Node *relative);
void generateManifestFile(const QString &manifest, const QString &element);
void readManifestMetaContent(const Config &config);
void generateKeywordAnchors(const Node *node);
void generateAssociatedPropertyNotes(FunctionNode *fn);
- QString getLink(const Atom *atom, const Node *relative, const Node **node);
- QString getAutoLink(const Atom *atom, const Node *relative, const Node **node);
-
private:
enum SubTitleSize { SmallSubTitle, LargeSubTitle };
enum ExtractionMarkType {
@@ -107,7 +102,6 @@ private:
QSet<QString> tags;
};
- const QPair<QString,QString> anchorForNode(const Node *node);
void generateNavigationBar(const QString &title,
const Node *node,
CodeMarker *marker,
@@ -185,12 +179,8 @@ private:
void generateDetailedMember(const Node *node, const PageNode *relative, CodeMarker *marker);
void generateLink(const Atom *atom, CodeMarker *marker);
- inline bool hasBrief(const Node *node);
- QString registerRef(const QString &ref);
QString fileBase(const Node *node) const override;
QString fileName(const Node *node);
- static int hOffset(const Node *node);
- static bool isThreeColumnEnumValueTable(const Atom *atom);
#ifdef GENERATE_MAC_REFS
void generateMacRef(const Node *node, CodeMarker *marker);
#endif
@@ -202,7 +192,6 @@ private:
QXmlStreamWriter &xmlWriter();
- QHash<QString, QString> refMap;
int codeIndent;
QString codePrefix;
QString codeSuffix;
@@ -232,7 +221,7 @@ private:
bool obsoleteLinks;
QStack<QXmlStreamWriter *> xmlWriterStack;
static int id;
- QList<ManifestMetaFilter> manifestMetaContent;
+ QVector<ManifestMetaFilter> manifestMetaContent;
QString homepage;
QString hometitle;
QString landingpage;
@@ -250,15 +239,6 @@ public:
static QString divNavTop;
};
-// Do not display \brief for QML/JS types, document and collection nodes
-inline bool HtmlGenerator::hasBrief(const Node *node)
-{
- return !(node->isQmlType()
- || node->isPageNode()
- || node->isCollectionNode()
- || node->isJsType());
-}
-
#define HTMLGENERATOR_ADDRESS "address"
#define HTMLGENERATOR_FOOTER "footer"
#define HTMLGENERATOR_GENERATEMACREFS "generatemacrefs" // ### document me
diff --git a/src/qdoc/jscodemarker.cpp b/src/qdoc/jscodemarker.cpp
index 6a26fce2e..cc1a234fb 100644
--- a/src/qdoc/jscodemarker.cpp
+++ b/src/qdoc/jscodemarker.cpp
@@ -67,7 +67,7 @@ bool JsCodeMarker::recognizeCode(const QString &code)
QQmlJS::Parser parser(&engine);
QString newCode = code;
- QList<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ QVector<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
lexer.setCode(newCode, 1);
return parser.parseProgram();
@@ -118,7 +118,7 @@ QString JsCodeMarker::addMarkUp(const QString &code,
QQmlJS::Lexer lexer(&engine);
QString newCode = code;
- QList<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ QVector<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
lexer.setCode(newCode, 1);
QQmlJS::Parser parser(&engine);
diff --git a/src/qdoc/location.cpp b/src/qdoc/location.cpp
index f10f53b65..2c088a5b5 100644
--- a/src/qdoc/location.cpp
+++ b/src/qdoc/location.cpp
@@ -215,8 +215,8 @@ void Location::pop()
*/
QString Location::fileName() const
{
- QString fp = filePath();
- return (fp.isEmpty() ? fp : fp.mid(fp.lastIndexOf('/') + 1));
+ QFileInfo fi(filePath());
+ return fi.fileName();
}
diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp
index a681231b5..1accb6449 100644
--- a/src/qdoc/main.cpp
+++ b/src/qdoc/main.cpp
@@ -73,7 +73,7 @@ bool creationTimeBefore(const QFileInfo &fi1, const QFileInfo &fi2)
#ifndef QT_NO_TRANSLATION
typedef QPair<QString, QTranslator *> Translator;
-static QList<Translator> translators;
+static QVector<Translator> translators;
#endif
static ClangCodeParser* clangParser_ = nullptr;
@@ -108,9 +108,8 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
for (const auto &format : formats) {
if (config.getBool(format + Config::dot + "nosubdirs")) {
useNoSubDirs = true;
- QString singleOutputSubdir = config.getString(format
- + Config::dot
- + "outputsubdir");
+ QString singleOutputSubdir =
+ config.getString(format + Config::dot + "outputsubdir");
if (singleOutputSubdir.isEmpty())
singleOutputSubdir = "html";
subDirs << singleOutputSubdir;
@@ -119,11 +118,11 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
if (config.dependModules().size() > 0) {
if (config.indexDirs().size() > 0) {
- for (int i = 0; i < config.indexDirs().size(); i++) {
- if (config.indexDirs()[i].startsWith("..")) {
+ for (auto &dir : config.indexDirs()){
+ if (dir.startsWith("..")) {
const QString prefix(QDir(config.currentDir()).relativeFilePath(config.previousCurrentDir()));
if (!prefix.isEmpty())
- config.indexDirs()[i].prepend(prefix + QLatin1Char('/'));
+ dir.prepend(prefix + QLatin1Char('/'));
}
}
/*
@@ -149,13 +148,12 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
config.dependModules() << foundModules;
});
} else {
- for (int i = 0; i < config.indexDirs().size(); i++) {
- QDir scanDir = QDir(config.indexDirs()[i]);
+ for (const auto &indexDir : config.indexDirs()) {
+ QDir scanDir = QDir(indexDir);
scanDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfoList dirList = scanDir.entryInfoList();
- for (int j = 0; j < dirList.size(); j++) {
- config.dependModules().append(dirList[j].fileName());
- }
+ for (const auto &dir : dirList)
+ config.dependModules().append(dir.fileName());
}
}
// Remove self-dependencies and possible duplicates
@@ -164,19 +162,16 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
Location::logToStdErrAlways(QString("qdocconf file has depends = *;"
" loading all %1 index files found").arg(config.dependModules().count()));
}
- for (int i = 0; i < config.dependModules().size(); i++) {
- QString indexToAdd;
- QString dependModule = config.dependModules()[i];
- QList<QFileInfo> foundIndices;
+ for (const auto &module : config.dependModules()) {
+ QVector<QFileInfo> foundIndices;
// Always look in module-specific subdir, even with *.nosubdirs config
- bool useModuleSubDir = !subDirs.contains(dependModule);
- subDirs << dependModule;
+ bool useModuleSubDir = !subDirs.contains(module);
+ subDirs << module;
- for (int j = 0; j < config.indexDirs().size(); j++) {
+ for (const auto &dir : config.indexDirs()) {
for (const auto &subDir : subDirs) {
- QString fileToLookFor = config.indexDirs()[j]
- + QLatin1Char('/') + subDir
- + QLatin1Char('/') + dependModule + ".index";
+ QString fileToLookFor = dir + QLatin1Char('/') + subDir
+ + QLatin1Char('/') + module + ".index";
if (QFile::exists(fileToLookFor)) {
QFileInfo tempFileInfo(fileToLookFor);
if (!foundIndices.contains(tempFileInfo))
@@ -186,8 +181,9 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
}
// Clear the temporary module-specific subdir
if (useModuleSubDir)
- subDirs.remove(dependModule);
+ subDirs.remove(module);
std::sort(foundIndices.begin(), foundIndices.end(), creationTimeBefore);
+ QString indexToAdd;
if (foundIndices.size() > 1) {
/*
QDoc should always use the last entry in the multimap when there are
@@ -199,10 +195,10 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
for (const auto &found : qAsConst(foundIndices))
indexPaths << found.absoluteFilePath();
Location::null.warning(QString("Multiple index files found for dependency \"%1\":\n%2").arg(
- dependModule, indexPaths.join('\n')));
+ module, indexPaths.join('\n')));
Location::null.warning(QString("Using %1 as index file for dependency \"%2\"").arg(
foundIndices[foundIndices.size() - 1].absoluteFilePath(),
- dependModule));
+ module));
indexToAdd = foundIndices[foundIndices.size() - 1].absoluteFilePath();
}
else if (foundIndices.size() == 1) {
@@ -214,7 +210,7 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats)
}
else if (!asteriskUsed) {
Location::null.warning(QString("\"%1\" Cannot locate index file for dependency \"%2\"").arg(
- config.getString(CONFIG_PROJECT), config.dependModules()[i]));
+ config.getString(CONFIG_PROJECT), module));
}
}
}
@@ -292,13 +288,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) {
+ for (const auto &translator : translators) {
+ if (translator.first == fileName) {
found = true;
break;
}
@@ -306,15 +301,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
@@ -391,12 +385,11 @@ static void processQdocconfFile(const QString &fileName, Config &config)
qCDebug(lcQdoc, "Adding doc/image dirs found in exampledirs to imagedirs");
QSet<QString> exampleImageDirs;
QStringList exampleImageList = config.getExampleImageFiles(excludedDirs, excludedFiles);
- for (int i = 0; i < exampleImageList.size(); ++i) {
- if (exampleImageList[i].contains("doc/images")) {
- QString t = exampleImageList[i].left(exampleImageList[i].lastIndexOf("doc/images") + 10);
- if (!exampleImageDirs.contains(t)) {
+ for (const auto &image : exampleImageList) {
+ if (image.contains("doc/images")) {
+ QString t = image.left(image.lastIndexOf("doc/images") + 10);
+ if (!exampleImageDirs.contains(t))
exampleImageDirs.insert(t);
- }
}
}
Generator::augmentImageDirs(exampleImageDirs);
@@ -406,31 +399,31 @@ static void processQdocconfFile(const QString &fileName, Config &config)
QStringList sourceList;
qCDebug(lcQdoc, "Reading headerdirs");
- headerList = config.getAllFiles(CONFIG_HEADERS,CONFIG_HEADERDIRS,excludedDirs,excludedFiles);
- QMap<QString,QString> headers;
- QMultiMap<QString,QString> headerFileNames;
- for (int i=0; i<headerList.size(); ++i) {
- if (headerList[i].contains(QString("doc/snippets")))
+ headerList = config.getAllFiles(CONFIG_HEADERS,CONFIG_HEADERDIRS, excludedDirs, excludedFiles);
+ QMap<QString, QString> headers;
+ QMultiMap<QString, QString> headerFileNames;
+ for (const auto &header : headerList) {
+ if (header.contains(QLatin1String("doc/snippets")))
continue;
- if (headers.contains(headerList[i]))
+ if (headers.contains(header))
continue;
- headers.insert(headerList[i],headerList[i]);
- QString t = headerList[i].mid(headerList[i].lastIndexOf('/')+1);
- headerFileNames.insert(t,t);
+ headers.insert(header, header);
+ QString t = header.mid(header.lastIndexOf('/') + 1);
+ headerFileNames.insert(t, t);
}
qCDebug(lcQdoc, "Reading sourcedirs");
- sourceList = config.getAllFiles(CONFIG_SOURCES,CONFIG_SOURCEDIRS,excludedDirs,excludedFiles);
- QMap<QString,QString> sources;
- QMultiMap<QString,QString> sourceFileNames;
- for (int i=0; i<sourceList.size(); ++i) {
- if (sourceList[i].contains(QString("doc/snippets")))
+ sourceList = config.getAllFiles(CONFIG_SOURCES,CONFIG_SOURCEDIRS, excludedDirs, excludedFiles);
+ QMap<QString, QString> sources;
+ QMultiMap<QString, QString> sourceFileNames;
+ for (const auto &source : sourceList) {
+ if (source.contains(QLatin1String("doc/snippets")))
continue;
- if (sources.contains(sourceList[i]))
+ if (sources.contains(source))
continue;
- sources.insert(sourceList[i],sourceList[i]);
- QString t = sourceList[i].mid(sourceList[i].lastIndexOf('/')+1);
- sourceFileNames.insert(t,t);
+ sources.insert(source, source);
+ QString t = source.mid(source.lastIndexOf('/') + 1);
+ sourceFileNames.insert(t, t);
}
/*
Find all the qdoc files in the example dirs, and add
@@ -438,11 +431,11 @@ static void processQdocconfFile(const QString &fileName, Config &config)
*/
qCDebug(lcQdoc, "Reading exampledirs");
QStringList exampleQdocList = config.getExampleQdocFiles(excludedDirs, excludedFiles);
- for (int i=0; i<exampleQdocList.size(); ++i) {
- if (!sources.contains(exampleQdocList[i])) {
- sources.insert(exampleQdocList[i],exampleQdocList[i]);
- QString t = exampleQdocList[i].mid(exampleQdocList[i].lastIndexOf('/')+1);
- sourceFileNames.insert(t,t);
+ for (const auto &example : exampleQdocList) {
+ if (!sources.contains(example)) {
+ sources.insert(example, example);
+ QString t = example.mid(example.lastIndexOf('/') + 1);
+ sourceFileNames.insert(t, t);
}
}
/*
@@ -452,15 +445,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 +462,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 +488,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();
@@ -604,9 +591,8 @@ int main(int argc, char **argv)
// Tidy everything away:
#ifndef QT_NO_TRANSLATION
if (!translators.isEmpty()) {
- for (int i=0; i<translators.size(); ++i) {
- delete translators.at(i).second;
- }
+ for (const auto &translator : translators)
+ delete translator.second;
}
translators.clear();
#endif
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index 839dd1336..a1df93cb8 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -158,49 +158,27 @@ bool Node::changeType(NodeType from, NodeType to)
*/
bool Node::nodeNameLessThan(const Node *n1, const Node *n2)
{
+#define LT_RETURN_IF_NOT_EQUAL(a, b) \
+ if ((a) != (b)) \
+ return (a) < (b);
+
if (n1->isPageNode() && n2->isPageNode()) {
- const PageNode *f1 = static_cast<const PageNode *>(n1);
- const PageNode *f2 = static_cast<const PageNode *>(n2);
- if (f1->fullTitle() < f2->fullTitle())
- return true;
- else if (f1->fullTitle() > f2->fullTitle())
- return false;
+ LT_RETURN_IF_NOT_EQUAL(n1->fullName(), n2->fullName());
+ LT_RETURN_IF_NOT_EQUAL(n1->fullTitle(), n2->fullTitle());
}
if (n1->isFunction() && n2->isFunction()) {
const FunctionNode *f1 = static_cast<const FunctionNode *>(n1);
const FunctionNode *f2 = static_cast<const FunctionNode *>(n2);
- if (f1->isConst() < f2->isConst())
- return true;
- else if (f1->isConst() > f2->isConst())
- return false;
-
- if (f1->signature(false, false) < f2->signature(false, false))
- return true;
- else if (f1->signature(false, false) > f2->signature(false, false))
- return false;
+ LT_RETURN_IF_NOT_EQUAL(f1->isConst(), f2->isConst());
+ LT_RETURN_IF_NOT_EQUAL(f1->signature(false, false), f2->signature(false, false));
}
- if (n1->location().filePath() < n2->location().filePath())
- return true;
- else if (n1->location().filePath() > n2->location().filePath())
- return false;
-
- if (n1->nodeType() < n2->nodeType())
- return true;
- else if (n1->nodeType() > n2->nodeType())
- return false;
-
- if (n1->name() < n2->name())
- return true;
- else if (n1->name() > n2->name())
- return false;
-
- if (n1->access() < n2->access())
- return true;
- else if (n1->access() > n2->access())
- return false;
+ LT_RETURN_IF_NOT_EQUAL(n1->location().filePath(), n2->location().filePath());
+ LT_RETURN_IF_NOT_EQUAL(n1->nodeType(), n2->nodeType());
+ LT_RETURN_IF_NOT_EQUAL(n1->name(), n2->name());
+ LT_RETURN_IF_NOT_EQUAL(n1->access(), n2->access());
return false;
}
@@ -681,7 +659,7 @@ QString Node::fullName(const Node *relative) const
If a match is found, return true. If no match is found,
return false.
*/
-bool Node::match(const QList<int> &types) const
+bool Node::match(const QVector<int> &types) const
{
for (int i=0; i<types.size(); ++i) {
if (nodeType() == types.at(i))
@@ -1381,7 +1359,7 @@ QString Node::cleanId(const QString &str)
clean += QLatin1Char('a');
}
- for (int i = 1; i < (int) name.length(); i++) {
+ for (int i = 1; i < name.length(); i++) {
const QChar c = name[i];
const uint u = c.unicode();
if ((u >= 'a' && u <= 'z') ||
@@ -2057,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();
@@ -2075,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());
}
}
}
@@ -2110,10 +2087,10 @@ Node *Aggregate::findNonfunctionChild(const QString &name, bool (Node::*isMatch)
*/
FunctionNode *Aggregate::findFunctionChild(const QString &name, const Parameters &parameters)
{
- 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;
@@ -2136,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;
}
@@ -2206,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();
@@ -2244,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.
@@ -2384,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_++;
}
@@ -2404,10 +2380,10 @@ 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_++;
+ ++functionCount_;
}
/*!
@@ -2552,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));
}
/*!
@@ -2587,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());
@@ -2642,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();
@@ -2793,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());
@@ -2953,7 +2928,7 @@ QString Aggregate::typeWord(bool cap) const
is called recursively with the list of base classes from
that private or internal class node.
*/
-void ClassNode::promotePublicBases(const QList<RelatedClass> &bases)
+void ClassNode::promotePublicBases(const QVector<RelatedClass> &bases)
{
if (!bases.isEmpty()) {
for (int i = bases.size() - 1; i >= 0; --i) {
@@ -3003,7 +2978,7 @@ void ClassNode::removePrivateAndInternalBases()
ClassNode *dc = derived_.at(i).node_;
if (dc != nullptr && (dc->isPrivate() || dc->isInternal())) {
derived_.removeAt(i);
- const QList<RelatedClass> &dd = dc->derivedClasses();
+ const QVector<RelatedClass> &dd = dc->derivedClasses();
for (int j = dd.size() - 1; j >= 0; --j)
derived_.insert(i, dd.at(j));
}
@@ -3017,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) {
@@ -3030,7 +3004,6 @@ void ClassNode::resolvePropertyOverriddenFromPtrs(PropertyNode *pn)
else
cn->resolvePropertyOverriddenFromPtrs(pn);
}
- ++bc;
}
}
@@ -3404,7 +3377,7 @@ PropertyNode *ClassNode::findPropertyNode(const QString &name)
PropertyNode *pn = nullptr;
- const QList<RelatedClass> &bases = baseClasses();
+ const QVector<RelatedClass> &bases = baseClasses();
if (!bases.isEmpty()) {
for (int i = 0; i < bases.size(); ++i) {
ClassNode *cn = bases[i].node_;
@@ -3415,7 +3388,7 @@ PropertyNode *ClassNode::findPropertyNode(const QString &name)
}
}
}
- const QList<RelatedClass> &ignoredBases = ignoredBaseClasses();
+ const QVector<RelatedClass> &ignoredBases = ignoredBaseClasses();
if (!ignoredBases.isEmpty()) {
for (int i = 0; i < ignoredBases.size(); ++i) {
ClassNode *cn = ignoredBases[i].node_;
@@ -3439,7 +3412,7 @@ PropertyNode *ClassNode::findPropertyNode(const QString &name)
QmlTypeNode *ClassNode::findQmlBaseNode()
{
QmlTypeNode *result = nullptr;
- const QList<RelatedClass> &bases = baseClasses();
+ const QVector<RelatedClass> &bases = baseClasses();
if (!bases.isEmpty()) {
for (int i = 0; i < bases.size(); ++i) {
@@ -3473,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);
@@ -3488,7 +3460,6 @@ FunctionNode *ClassNode::findOverriddenFunction(const FunctionNode *fn)
if (result != nullptr && !result->isNonvirtual())
return result;
}
- ++bc;
}
return nullptr;
}
@@ -3502,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;
}
@@ -3611,17 +3578,7 @@ bool HeaderNode::hasDocumentedChildren() const
*/
/*!
- Returns the node's full title, which is usually whatever
- title() returns, but for some cases the full title migth
- be different from title(), so this might require changing,
- because currently it just returns the title().
-
- mws 13/07/2018. This function used to test the node subtype
- for File or Image and append text to the title(), but there
- are no node subtypes now, so it can't do that. There are no
- node type values for File and Image either. Files and images
- are used in examples, but the ExampleNode's example files
- and example images are stored as lists of path strings.
+ Returns the node's full title.
*/
QString PageNode::fullTitle() const
{
@@ -4263,7 +4220,6 @@ QString FunctionNode::metanessString() const
default:
return "plain";
}
- return QString();
}
/*!
@@ -4521,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 &notifier : notifiers()) {
+ if (notifier->name() == name)
return true;
- ++i;
}
return false;
}
@@ -4866,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;
@@ -4883,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;
@@ -4900,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);
}
}
@@ -4915,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);
}
}
@@ -4931,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/node.h b/src/qdoc/node.h
index baec4d9f2..6594df921 100644
--- a/src/qdoc/node.h
+++ b/src/qdoc/node.h
@@ -58,7 +58,7 @@ class SharedCommentNode;
typedef QMap<QString, FunctionNode *> FunctionMap;
typedef QList<Node *> NodeList;
-typedef QList<ClassNode *> ClassList;
+typedef QVector<ClassNode *> ClassList;
typedef QVector<Node *> NodeVector;
typedef QMap<QString, Node *> NodeMap;
typedef QMap<QString, NodeMap> NodeMapMap;
@@ -66,7 +66,7 @@ typedef QMultiMap<QString, Node *> NodeMultiMap;
typedef QMap<QString, NodeMultiMap> NodeMultiMapMap;
typedef QMap<QString, CollectionNode *> CNMap;
typedef QMultiMap<QString, CollectionNode *> CNMultiMap;
-typedef QList<CollectionNode *> CollectionList;
+typedef QVector<CollectionNode *> CollectionList;
class Node
{
@@ -287,7 +287,7 @@ public:
virtual void markDefault() { }
virtual void markReadOnly(bool ) { }
- bool match(const QList<int> &types) const;
+ bool match(const QVector<int> &types) const;
Aggregate *parent() const { return parent_; }
const QString &name() const { return name_; }
QString physicalModuleName() const;
@@ -441,9 +441,10 @@ protected:
class ExternalPageNode : public PageNode
{
public:
- ExternalPageNode(Aggregate *parent, const QString &name)
- : PageNode(Node::ExternalPage, parent, name) {
+ ExternalPageNode(Aggregate *parent, const QString &url)
+ : PageNode(Node::ExternalPage, parent, url) {
setPageType(Node::ArticlePage);
+ setUrl(url);
}
};
@@ -614,15 +615,15 @@ public:
void removePrivateAndInternalBases();
void resolvePropertyOverriddenFromPtrs(PropertyNode *pn);
- QList<RelatedClass> &baseClasses() { return bases_; }
- QList<RelatedClass> &derivedClasses() { return derived_; }
- QList<RelatedClass> &ignoredBaseClasses() { return ignoredBases_; }
- QList<UsingClause> &usingClauses() { return usingClauses_; }
+ QVector<RelatedClass> &baseClasses() { return bases_; }
+ QVector<RelatedClass> &derivedClasses() { return derived_; }
+ QVector<RelatedClass> &ignoredBaseClasses() { return ignoredBases_; }
+ QVector<UsingClause> &usingClauses() { return usingClauses_; }
- const QList<RelatedClass> &baseClasses() const { return bases_; }
- const QList<RelatedClass> &derivedClasses() const { return derived_; }
- const QList<RelatedClass> &ignoredBaseClasses() const { return ignoredBases_; }
- const QList<UsingClause> &usingClauses() const { return usingClauses_; }
+ const QVector<RelatedClass> &baseClasses() const { return bases_; }
+ const QVector<RelatedClass> &derivedClasses() const { return derived_; }
+ const QVector<RelatedClass> &ignoredBaseClasses() const { return ignoredBases_; }
+ const QVector<UsingClause> &usingClauses() const { return usingClauses_; }
QmlTypeNode *qmlElement() { return qmlelement; }
void setQmlElement(QmlTypeNode *qcn) { qmlelement = qcn; }
@@ -635,13 +636,13 @@ public:
bool docMustBeGenerated() const override;
private:
- void promotePublicBases(const QList<RelatedClass> &bases);
+ void promotePublicBases(const QVector<RelatedClass> &bases);
private:
- QList<RelatedClass> bases_;
- QList<RelatedClass> derived_;
- QList<RelatedClass> ignoredBases_;
- QList<UsingClause> usingClauses_;
+ QVector<RelatedClass> bases_;
+ QVector<RelatedClass> derived_;
+ QVector<RelatedClass> ignoredBases_;
+ QVector<UsingClause> usingClauses_;
bool abstract_;
bool wrapper_;
QString obsoleteLink_;
@@ -706,7 +707,7 @@ struct ImportRec {
bool isEmpty() const { return name_.isEmpty(); }
};
-typedef QList<ImportRec> ImportList;
+typedef QVector<ImportRec> ImportList;
class QmlTypeNode : public Aggregate
{
@@ -846,14 +847,14 @@ public:
void setFlagsType(TypedefNode *typedeff);
bool hasItem(const QString &name) const { return names_.contains(name); }
- const QList<EnumItem> &items() const { return items_; }
+ const QVector<EnumItem> &items() const { return items_; }
Access itemAccess(const QString &name) const;
const TypedefNode *flagsType() const { return flagsType_; }
QString itemValue(const QString &name) const;
Node *clone(Aggregate *parent) override;
private:
- QList<EnumItem> items_;
+ QVector<EnumItem> items_;
QSet<QString> names_;
const TypedefNode *flagsType_;
};
diff --git a/src/qdoc/openedlist.cpp b/src/qdoc/openedlist.cpp
index ce9efb06e..a36e3b545 100644
--- a/src/qdoc/openedlist.cpp
+++ b/src/qdoc/openedlist.cpp
@@ -135,7 +135,7 @@ int OpenedList::fromAlpha(const QString &str)
int n = 0;
int u;
- for (int i = 0; i < (int) str.length(); i++) {
+ for (int i = 0; i < str.length(); i++) {
u = str[i].toLower().unicode();
if (u >= 'a' && u <= 'z') {
n *= 26;
diff --git a/src/qdoc/parameters.cpp b/src/qdoc/parameters.cpp
index 44178c9d9..96a591a2a 100644
--- a/src/qdoc/parameters.cpp
+++ b/src/qdoc/parameters.cpp
@@ -507,21 +507,23 @@ void Parameters::set(const QString &signature)
/*!
Insert all the parameter names into names.
*/
-void Parameters::getNames(QSet<QString> &names) const
+QSet<QString> Parameters::getNames() const
{
+ QSet<QString> names;
const auto params = parameters_;
for (const auto &parameter : params) {
if (!parameter.name().isEmpty())
names.insert(parameter.name());
}
+ return names;
}
/*!
- Construct a list of the parameter types and append it to
- \a out. \a out is not cleared first.
+ Construct a list of the parameter types and return it.
*/
-void Parameters::getTypeList(QString &out) const
+QString Parameters::generateTypeList() const
{
+ QString out;
if (count() > 0) {
for (int i = 0; i < count(); ++i) {
if (i > 0)
@@ -529,14 +531,16 @@ void Parameters::getTypeList(QString &out) const
out += parameters_.at(i).type();
}
}
+ return out;
}
/*!
Construct a list of the parameter type/name pairs and
- append it to \a out. \a out is not cleared first.
+ return it.
*/
-void Parameters::getTypeAndNameList(QString &out) const
+QString Parameters::generateTypeAndNameList() const
{
+ QString out;
if (count() > 0) {
for (int i = 0; i < count(); ++i) {
if (i != 0)
@@ -548,6 +552,7 @@ void Parameters::getTypeAndNameList(QString &out) const
out += p.name();
}
}
+ return out;
}
/*!
diff --git a/src/qdoc/parameters.h b/src/qdoc/parameters.h
index dcd4517eb..7e72d1689 100644
--- a/src/qdoc/parameters.h
+++ b/src/qdoc/parameters.h
@@ -97,9 +97,9 @@ public:
QString signature(bool includeValues = false) const;
QString rawSignature(bool names = false, bool values = false) const;
void set(const QString &signature);
- void getNames(QSet<QString> &names) const;
- void getTypeList(QString &out) const;
- void getTypeAndNameList(QString &out) const;
+ QSet<QString> getNames() const;
+ QString generateTypeList() const;
+ QString generateTypeAndNameList() const;
bool match(const Parameters &parameters) const;
private:
diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro
index df9123b09..c38c50b16 100644
--- a/src/qdoc/qdoc.pro
+++ b/src/qdoc/qdoc.pro
@@ -58,6 +58,7 @@ HEADERS += atom.h \
text.h \
tokenizer.h \
tree.h \
+ xmlgenerator.h \
webxmlgenerator.h \
qdoccommandlineparser.h \
utilities.h
@@ -90,6 +91,7 @@ SOURCES += atom.cpp \
text.cpp \
tokenizer.cpp \
tree.cpp \
+ xmlgenerator.cpp \
yyindent.cpp \
webxmlgenerator.cpp \
qdoccommandlineparser.cpp \
diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp
index 311b19db7..5c4acdbf1 100644
--- a/src/qdoc/qdocdatabase.cpp
+++ b/src/qdoc/qdocdatabase.cpp
@@ -175,9 +175,9 @@ void QDocForest::setSearchOrder(const QStringList &t)
return;
/* Allocate space for the search order. */
- searchOrder_.reserve(forest_.size()+1);
+ searchOrder_.reserve(forest_.size() + 1);
searchOrder_.clear();
- moduleNames_.reserve(forest_.size()+1);
+ moduleNames_.reserve(forest_.size() + 1);
moduleNames_.clear();
/* The primary tree is always first in the search order. */
@@ -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 9ea7d9f86..022d658b1 100644
--- a/src/qdoc/qdocindexfiles.cpp
+++ b/src/qdoc/qdocindexfiles.cpp
@@ -157,6 +157,11 @@ void QDocIndexFiles::readIndexFile(const QString &path)
basesList_.clear();
NamespaceNode *root = qdb_->newIndexTree(project_);
+ if (!root) {
+ qWarning() << "Issue parsing index tree" << path;
+ return;
+ }
+
root->tree()->setIndexTitle(indexTitle);
// Scan all elements in the XML file, constructing a map that contains
@@ -387,7 +392,7 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
} else
goto done;
- if (current && current->isExample()) {
+ if (current->isExample()) {
ExampleNode *en = static_cast<ExampleNode *>(current);
if (subtype == QDocAttrFile) {
en->appendFile(name);
@@ -950,7 +955,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter &writer, Node *node,
{
// Classes contain information about their base classes.
const ClassNode *classNode = static_cast<const ClassNode *>(node);
- const QList<RelatedClass> bases = classNode->baseClasses();
+ const QVector<RelatedClass> bases = classNode->baseClasses();
QSet<QString> baseStrings;
for (const auto &related : bases) {
ClassNode *n = related.node_;
@@ -1445,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++;
}
}
}
@@ -1492,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/qdoctagfiles.cpp b/src/qdoc/qdoctagfiles.cpp
index bdf001469..cd4e9e0e5 100644
--- a/src/qdoc/qdoctagfiles.cpp
+++ b/src/qdoc/qdoctagfiles.cpp
@@ -138,7 +138,7 @@ void QDocTagFiles::generateTagFileCompounds(QXmlStreamWriter &writer, const Aggr
// Classes contain information about their base classes.
const ClassNode *classNode = static_cast<const ClassNode *>(node);
- const QList<RelatedClass> bases = classNode->baseClasses();
+ const QVector<RelatedClass> bases = classNode->baseClasses();
for (const auto &related : bases) {
ClassNode *n = related.node_;
if (n)
diff --git a/src/qdoc/qmlcodemarker.cpp b/src/qdoc/qmlcodemarker.cpp
index fe39e6e54..719fc710b 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);
}
@@ -174,7 +172,7 @@ QString QmlCodeMarker::addMarkUp(const QString &code,
QQmlJS::Lexer lexer(&engine);
QString newCode = code;
- QList<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ QVector<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
lexer.setCode(newCode, 1);
QQmlJS::Parser parser(&engine);
@@ -226,11 +224,11 @@ static void replaceWithSpace(QString &str, int idx, int n)
Searches for ".pragma <value>" or ".import <stuff>" declarations
in \a script. Currently supported pragmas are: library
*/
-QList<QQmlJS::AST::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
+QVector<QQmlJS::AST::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
{
const QString pragma(QLatin1String("pragma"));
const QString library(QLatin1String("library"));
- QList<QQmlJS::AST::SourceLocation> removed;
+ QVector<QQmlJS::AST::SourceLocation> removed;
QQmlJS::Lexer l(nullptr);
l.setCode(script, 0);
diff --git a/src/qdoc/qmlcodemarker.h b/src/qdoc/qmlcodemarker.h
index e28d46309..81194cb36 100644
--- a/src/qdoc/qmlcodemarker.h
+++ b/src/qdoc/qmlcodemarker.h
@@ -65,7 +65,7 @@ public:
/* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */
#ifndef QT_NO_DECLARATIVE
- QList<QQmlJS::AST::SourceLocation> extractPragmas(QString &script);
+ QVector<QQmlJS::AST::SourceLocation> extractPragmas(QString &script);
#endif
private:
diff --git a/src/qdoc/qmlmarkupvisitor.cpp b/src/qdoc/qmlmarkupvisitor.cpp
index e99bf5fc3..dbcdf8aa5 100644
--- a/src/qdoc/qmlmarkupvisitor.cpp
+++ b/src/qdoc/qmlmarkupvisitor.cpp
@@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DECLARATIVE
QmlMarkupVisitor::QmlMarkupVisitor(const QString &source,
- const QList<QQmlJS::AST::SourceLocation> &pragmas,
+ const QVector<QQmlJS::AST::SourceLocation> &pragmas,
QQmlJS::Engine *engine)
{
this->source = source;
diff --git a/src/qdoc/qmlmarkupvisitor.h b/src/qdoc/qmlmarkupvisitor.h
index 1f48722b1..a0e3f870b 100644
--- a/src/qdoc/qmlmarkupvisitor.h
+++ b/src/qdoc/qmlmarkupvisitor.h
@@ -51,7 +51,7 @@ public:
};
QmlMarkupVisitor(const QString &code,
- const QList<QQmlJS::AST::SourceLocation> &pragmas,
+ const QVector<QQmlJS::AST::SourceLocation> &pragmas,
QQmlJS::Engine *engine);
virtual ~QmlMarkupVisitor();
@@ -158,7 +158,7 @@ private:
QQmlJS::Engine *engine;
QVector<ExtraType> extraTypes;
- QList<QQmlJS::AST::SourceLocation> extraLocations;
+ QVector<QQmlJS::AST::SourceLocation> extraLocations;
QString source;
QString output;
quint32 cursor;
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..7fd39bc4f 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 &sections = 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 QVector<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 &section : *sections) {
+ if (!section.obsoleteMembers().isEmpty())
+ summary_spv->append(&section);
}
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/sections.h b/src/qdoc/sections.h
index d9aeeb28f..9c1514c2d 100644
--- a/src/qdoc/sections.h
+++ b/src/qdoc/sections.h
@@ -37,11 +37,11 @@ QT_BEGIN_NAMESPACE
typedef QMultiMap<QString, Node *> MemberMap; // the string is the member signature
typedef QPair<const QmlTypeNode *, MemberMap> ClassMap; // the node is the QML type
-typedef QList<ClassMap *> ClassMapList;
+typedef QVector<ClassMap *> ClassMapList;
typedef QPair<QStringList, NodeVector> KeysAndNodes;
typedef QPair<const QmlTypeNode *, KeysAndNodes> ClassKeysNodes;
-typedef QList<ClassKeysNodes *> ClassKeysNodesList;
+typedef QVector<ClassKeysNodes *> ClassKeysNodesList;
class Section
{
@@ -101,7 +101,7 @@ public:
const QStringList &keys(Status t) const { return (t == Obsolete ? obsoleteKeys_ : keys_); }
const NodeVector &members() const { return members_; }
const NodeVector &reimplementedMembers() const { return reimplementedMembers_; }
- const QList<QPair<Aggregate*, int> > &inheritedMembers() const { return inheritedMembers_; }
+ const QVector<QPair<Aggregate*, int> > &inheritedMembers() const { return inheritedMembers_; }
ClassKeysNodesList &classKeysNodesList() { return classKeysNodesList_; }
const NodeVector &obsoleteMembers() const { return obsoleteMembers_; }
void appendMembers(const NodeVector &nv) { members_.append(nv); }
@@ -125,7 +125,7 @@ private:
NodeVector members_;
NodeVector obsoleteMembers_;
NodeVector reimplementedMembers_;
- QList<QPair<Aggregate *, int> > inheritedMembers_;
+ QVector<QPair<Aggregate *, int> > inheritedMembers_;
ClassKeysNodesList classKeysNodesList_;
QMultiMap<QString, Node *> memberMap_;
diff --git a/src/qdoc/tokenizer.cpp b/src/qdoc/tokenizer.cpp
index 45c33fa7c..af3837c3a 100644
--- a/src/qdoc/tokenizer.cpp
+++ b/src/qdoc/tokenizer.cpp
@@ -735,7 +735,7 @@ bool Tokenizer::isTrue(const QString &condition)
X && Y || Z // the or
(X || Y) && Z // the and
*/
- for (int i = 0; i < (int) condition.length() - 1; i++) {
+ for (int i = 0; i < condition.length() - 1; i++) {
QChar ch = condition[i];
if (ch == QChar('(')) {
parenDepth++;
diff --git a/src/qdoc/tree.cpp b/src/qdoc/tree.cpp
index 1ae07c52b..6ff473bdc 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);
- 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 it = n->constBegin(); it != n->constEnd(); ++it) {
+ if ((*it)->isClassNode()) {
+ ClassNode *cn = static_cast<ClassNode *>(*it);
+ QVector<RelatedClass> &bases = cn->baseClasses();
+ for (auto &base : bases) {
+ if (base.node_ == nullptr) {
+ Node *n = qdb_->findClassNode(base.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(base.path_, parent);
}
if (n != nullptr) {
ClassNode *bcn = static_cast<ClassNode *>(n);
- (*b).node_ = bcn;
- bcn->addDerivedClass((*b).access_, cn);
+ base.node_ = bcn;
+ bcn->addDerivedClass(base.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();
@@ -384,15 +366,13 @@ void Tree::resolveUsingClauses()
for (auto *child : children) {
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);
+ QVector<UsingClause> &usingClauses = cn->usingClauses();
+ 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;
}
@@ -814,7 +792,7 @@ void Tree::resolveTargets(Aggregate *root)
}
if (child->doc().hasTableOfContents()) {
- const QList<Atom *> &toc = child->doc().tableOfContents();
+ const QVector<Atom *> &toc = child->doc().tableOfContents();
for (int i = 0; i < toc.size(); ++i) {
QString ref = refForAtom(toc.at(i));
QString title = Text::sectionHeading(toc.at(i)).toString();
@@ -827,7 +805,7 @@ void Tree::resolveTargets(Aggregate *root)
}
}
if (child->doc().hasKeywords()) {
- const QList<Atom *> &keywords = child->doc().keywords();
+ const QVector<Atom *> &keywords = child->doc().keywords();
for (int i = 0; i < keywords.size(); ++i) {
QString ref = refForAtom(keywords.at(i));
QString title = keywords.at(i)->string();
@@ -839,7 +817,7 @@ void Tree::resolveTargets(Aggregate *root)
}
}
if (child->doc().hasTargets()) {
- const QList<Atom *> &targets = child->doc().targets();
+ const QVector<Atom *> &targets = child->doc().targets();
for (int i = 0; i < targets.size(); ++i) {
QString ref = refForAtom(targets.at(i));
QString title = targets.at(i)->string();
@@ -865,14 +843,13 @@ Tree::findUnambiguousTarget(const QString &target, Node::Genus genus, QString &r
{
int numBestTargets = 0;
TargetRec *bestTarget = nullptr;
- QList<TargetRec *> bestTargetList;
+ QVector<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 be19eb435..330f3d474 100644
--- a/src/qdoc/webxmlgenerator.cpp
+++ b/src/qdoc/webxmlgenerator.cpp
@@ -222,7 +222,7 @@ void WebXMLGenerator::append(QXmlStreamWriter &writer, Node *node)
while (atom)
atom = addAtomElements(writer, atom, node, marker_);
- QList<Text> alsoList = node->doc().alsoList();
+ QVector<Text> alsoList = node->doc().alsoList();
supplementAlsoList(node, alsoList);
if (!alsoList.isEmpty()) {
@@ -289,6 +289,9 @@ const Atom *WebXMLGenerator::addAtomElements(QXmlStreamWriter &writer,
{
bool keepQuoting = false;
+ if (!atom)
+ return nullptr;
+
switch (atom->type()) {
case Atom::AnnotatedList:
{
@@ -750,11 +753,8 @@ const Atom *WebXMLGenerator::addAtomElements(QXmlStreamWriter &writer,
}
hasQuotingInformation = keepQuoting;
+ return atom->next();
- if (atom)
- return atom->next();
-
- return nullptr;
}
void WebXMLGenerator::startLink(QXmlStreamWriter &writer, const Atom *atom,
@@ -811,47 +811,13 @@ void WebXMLGenerator::endLink(QXmlStreamWriter &writer) {
}
}
-QString WebXMLGenerator::targetType(const Node *node)
-{
- if (!node)
- return "external";
-
- switch (node->nodeType()) {
- case Node::Namespace:
- return "namespace";
- case Node::Class:
- case Node::Struct:
- case Node::Union:
- return "class";
- case Node::Page:
- case Node::Example:
- return "page";
- case Node::Enum:
- return "enum";
- case Node::Typedef:
- return "typedef";
- case Node::Property:
- return "property";
- case Node::Function:
- return "function";
- case Node::Variable:
- return "variable";
- case Node::Module:
- return "module";
- default:
- break;
- }
- return QString();
-}
-
void WebXMLGenerator::generateRelations(QXmlStreamWriter &writer, const Node *node)
{
if (node && !node->links().empty()) {
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);
@@ -921,15 +887,4 @@ void WebXMLGenerator::generateAnnotatedList(QXmlStreamWriter &writer,
writer.writeEndElement(); // table
}
-const QPair<QString,QString> WebXMLGenerator::anchorForNode(const Node *node)
-{
- QPair<QString,QString> anchorPair;
-
- anchorPair.first = fullDocumentLocation(node);
- if (node->isTextPageNode())
- anchorPair.second = node->title();
-
- return anchorPair;
-}
-
QT_END_NAMESPACE
diff --git a/src/qdoc/webxmlgenerator.h b/src/qdoc/webxmlgenerator.h
index 320d8169e..565be82c9 100644
--- a/src/qdoc/webxmlgenerator.h
+++ b/src/qdoc/webxmlgenerator.h
@@ -64,14 +64,12 @@ protected:
private:
- const QPair<QString,QString> anchorForNode(const Node *node);
void generateAnnotatedList(QXmlStreamWriter &writer, const Node *relative, const NodeMap &nodeMap);
void generateAnnotatedList(QXmlStreamWriter &writer, const Node *relative, const NodeList &nodeList);
void generateRelations(QXmlStreamWriter &writer, const Node *node);
void startLink(QXmlStreamWriter &writer, const Atom *atom, const Node *node,
const QString &link);
void endLink(QXmlStreamWriter &writer);
- QString targetType(const Node *node);
bool inLink;
bool inContents;
diff --git a/src/qdoc/xmlgenerator.cpp b/src/qdoc/xmlgenerator.cpp
new file mode 100644
index 000000000..05cd1b963
--- /dev/null
+++ b/src/qdoc/xmlgenerator.cpp
@@ -0,0 +1,478 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Thibaut Cuvelier
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ xmlgenerator.cpp
+*/
+
+#include "xmlgenerator.h"
+#include "qdocdatabase.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ Do not display \brief for QML/JS types, document and collection nodes
+ */
+bool XmlGenerator::hasBrief(const Node *node)
+{
+ return !(node->isQmlType()
+ || node->isPageNode()
+ || node->isCollectionNode()
+ || node->isJsType());
+}
+
+/*!
+ Determines whether the list atom should be shown with three columns
+ (constant-value-description).
+ */
+bool XmlGenerator::isThreeColumnEnumValueTable(const Atom *atom)
+{
+ while (atom && !(atom->type() == Atom::ListRight && atom->string() == ATOM_LIST_VALUE)) {
+ if (atom->type() == Atom::ListItemLeft && !matchAhead(atom, Atom::ListItemRight))
+ return true;
+ atom = atom->next();
+ }
+ return false;
+}
+
+/*!
+ Header offset depending on the type of the node
+ */
+int XmlGenerator::hOffset(const Node *node)
+{
+ switch (node->nodeType()) {
+ case Node::Namespace:
+ case Node::Class:
+ case Node::Struct:
+ case Node::Union:
+ case Node::Module:
+ return 2;
+ case Node::QmlModule:
+ case Node::QmlBasicType:
+ case Node::QmlType:
+ case Node::Page:
+ return 1;
+ case Node::Enum:
+ case Node::Typedef:
+ case Node::Function:
+ case Node::Property:
+ default:
+ return 3;
+ }
+}
+
+/*!
+ Rewrites the brief of this node depending on its first word.
+ Only for properties and variables (does nothing otherwise).
+ */
+void XmlGenerator::rewritePropertyBrief(const Atom *atom, const Node *relative)
+{
+ if (relative->nodeType() == Node::Property ||
+ relative->nodeType() == Node::Variable) {
+ atom = atom->next();
+ if (atom && atom->type() == Atom::String) {
+ QString firstWord =
+ atom->string().toLower().section(' ', 0, 0, QString::SectionSkipEmpty);
+ if (firstWord == QLatin1String("the")
+ || firstWord == QLatin1String("a")
+ || firstWord == QLatin1String("an")
+ || firstWord == QLatin1String("whether")
+ || firstWord == QLatin1String("which")) {
+ QString str = QLatin1String("This ")
+ + QLatin1String(relative->nodeType() == Node::Property ?
+ "property" : "variable")
+ + QLatin1String(" holds ")
+ + atom->string().left(1).toLower()
+ + atom->string().mid(1);
+ const_cast<Atom *>(atom)->setString(str);
+ }
+ }
+ }
+}
+
+/*!
+ Returns the type of this atom as an enumeration.
+ */
+Node::NodeType XmlGenerator::typeFromString(const Atom *atom)
+{
+ const auto &name = atom->string();
+ if (name.startsWith(QLatin1String("qml")))
+ return Node::QmlModule;
+ else if (name.startsWith(QLatin1String("js")))
+ return Node::JsModule;
+ else if (name.startsWith(QLatin1String("groups")))
+ return Node::Group;
+ else
+ return Node::Module;
+}
+
+/*!
+ For images shown in examples, set the image file to the one it
+ will have once the documentation is generated.
+ */
+void XmlGenerator::setImageFileName(const Node *relative, const QString &fileName)
+{
+ if (relative->isExample()) {
+ const auto cen = static_cast<const ExampleNode *>(relative);
+ if (cen->imageFileName().isEmpty()) {
+ auto *en = const_cast<ExampleNode*>(cen);
+ en->setImageFileName(fileName);
+ }
+ }
+}
+
+/*!
+ Handles the differences in lists between list tags and since tags, and
+ returns the content of the list entry \a atom (first member of the pair).
+ It also returns the number of items to skip ahead (second member of the pair).
+ */
+QPair<QString, int> XmlGenerator::getAtomListValue(const Atom *atom)
+{
+ const Atom *lookAhead = atom->next();
+ if (!lookAhead)
+ return QPair<QString, int>(QString(), 1);
+
+ QString t = lookAhead->string();
+ lookAhead = lookAhead->next();
+ if (!lookAhead || lookAhead->type() != Atom::ListTagRight)
+ return QPair<QString, int>(QString(), 1);
+
+ lookAhead = lookAhead->next();
+ int skipAhead;
+ if (lookAhead && lookAhead->type() == Atom::SinceTagLeft) {
+ lookAhead = lookAhead->next();
+ Q_ASSERT(lookAhead && lookAhead->type() == Atom::String);
+ t += QLatin1String(" (since ");
+ if (lookAhead->string().at(0).isDigit())
+ t += QLatin1String("Qt ");
+ t += lookAhead->string() + QLatin1String(")");
+ skipAhead = 4;
+ } else {
+ skipAhead = 1;
+ }
+ return QPair<QString, int>(t, skipAhead);
+}
+
+/*!
+ Parses the table attributes from the given \a atom.
+ This method returns a pair containing the width (%) and
+ the attribute for this table (either "generic" or
+ "borderless").
+ */
+QPair<QString, QString> XmlGenerator::getTableWidthAttr(const Atom *atom)
+{
+ QString p0, p1;
+ QString attr = "generic";
+ QString width;
+ if (atom->count() > 0) {
+ p0 = atom->string(0);
+ if (atom->count() > 1)
+ p1 = atom->string(1);
+ }
+ if (!p0.isEmpty()) {
+ if (p0 == QLatin1String("borderless"))
+ attr = p0;
+ else if (p0.contains(QLatin1Char('%')))
+ width = p0;
+ }
+ if (!p1.isEmpty()) {
+ if (p1 == QLatin1String("borderless"))
+ attr = p1;
+ else if (p1.contains(QLatin1Char('%')))
+ width = p1;
+ }
+ return QPair<QString, QString>(width, attr);
+}
+
+/*!
+ Registers an anchor reference and returns a unique
+ and cleaned copy of the reference (the one that should be
+ used in the output).
+ To ensure unicity throughout the document, this method
+ uses the \a refMap cache.
+ */
+QString XmlGenerator::registerRef(const QString &ref)
+{
+ QString clean = Generator::cleanRef(ref);
+
+ for (;;) {
+ QString &prevRef = refMap[clean.toLower()];
+ if (prevRef.isEmpty()) {
+ prevRef = ref;
+ break;
+ } else if (prevRef == ref) {
+ break;
+ }
+ clean += QLatin1Char('x');
+ }
+ return clean;
+}
+
+/*!
+ Generates a clean and unique reference for the given \a node.
+ This reference may depend on the type of the node (typedef,
+ QML signal, etc.)
+ */
+QString XmlGenerator::refForNode(const Node *node)
+{
+ QString ref;
+ switch (node->nodeType()) {
+ case Node::Enum:
+ ref = node->name() + "-enum";
+ break;
+ case Node::Typedef: {
+ const auto tdn = static_cast<const TypedefNode *>(node);
+ if (tdn->associatedEnum())
+ return refForNode(tdn->associatedEnum());
+ ref = node->name() + "-typedef";
+ }
+ break;
+ case Node::Function: {
+ const auto fn = static_cast<const FunctionNode *>(node);
+ switch (fn->metaness()) {
+ case FunctionNode::JsSignal:
+ case FunctionNode::QmlSignal:
+ ref = fn->name() + "-signal";
+ break;
+ case FunctionNode::JsSignalHandler:
+ case FunctionNode::QmlSignalHandler:
+ ref = fn->name() + "-signal-handler";
+ break;
+ case FunctionNode::JsMethod:
+ case FunctionNode::QmlMethod:
+ ref = fn->name() + "-method";
+ if (fn->overloadNumber() != 0)
+ ref += QLatin1Char('-') + QString::number(fn->overloadNumber());
+ break;
+ default:
+ if (fn->hasOneAssociatedProperty() && fn->doc().isEmpty()) {
+ return refForNode(fn->firstAssociatedProperty());
+ } else {
+ ref = fn->name();
+ if (fn->overloadNumber() != 0)
+ ref += QLatin1Char('-') + QString::number(fn->overloadNumber());
+ }
+ break;
+ }
+ }
+ break;
+ case Node::JsProperty:
+ case Node::QmlProperty:
+ if (node->isAttached())
+ ref = node->name() + "-attached-prop";
+ else
+ ref = node->name() + "-prop";
+ break;
+ case Node::Property:
+ ref = node->name() + "-prop";
+ break;
+ case Node::Variable:
+ ref = node->name() + "-var";
+ break;
+ case Node::SharedComment:
+ if (node->isPropertyGroup())
+ ref = node->name() + "-prop";
+ break;
+ default:
+ break;
+ }
+ return registerRef(ref);
+}
+
+/*!
+ Construct the link string for the \a node and return it.
+ The \a relative node is used to decide whether the link
+ we are generating is in the same file as the target.
+ Note the relative node can be 0, which pretty much
+ guarantees that the link and the target aren't in the
+ same file.
+ */
+QString XmlGenerator::linkForNode(const Node *node, const Node *relative)
+{
+ if (node == nullptr)
+ return QString();
+ if (!node->url().isEmpty())
+ return node->url();
+ if (fileBase(node).isEmpty())
+ return QString();
+ if (node->isPrivate())
+ return QString();
+
+ QString fn = fileName(node);
+ if (node && node->parent()
+ && (node->parent()->isQmlType() || node->parent()->isJsType())
+ && node->parent()->isAbstract()) {
+ if (Generator::qmlTypeContext()) {
+ if (Generator::qmlTypeContext()->inherits(node->parent())) {
+ fn = fileName(Generator::qmlTypeContext());
+ } else if (node->parent()->isInternal()) {
+ node->doc().location().warning(
+ tr("Cannot link to property in internal type '%1'").arg(node->parent()->name()));
+ return QString();
+ }
+ }
+ }
+
+ QString link = fn;
+
+ if (!node->isPageNode() || node->isPropertyGroup()) {
+ QString ref = refForNode(node);
+ if (relative && fn == fileName(relative) && ref == refForNode(relative))
+ return QString();
+
+ link += QLatin1Char('#');
+ link += ref;
+ }
+
+ /*
+ If the output is going to subdirectories, then if the
+ two nodes will be output to different directories, then
+ the link must go up to the parent directory and then
+ back down into the other subdirectory.
+ */
+ if (node && relative && (node != relative)) {
+ if (useOutputSubdirs() && !node->isExternalPage() &&
+ node->outputSubdirectory() != relative->outputSubdirectory()) {
+ if (link.startsWith(QString(node->outputSubdirectory() + QLatin1Char('/')))) {
+ link.prepend(QString("../"));
+ } else {
+ link.prepend(QString("../" + node->outputSubdirectory() + QLatin1Char('/')));
+ }
+ }
+ }
+ return link;
+}
+
+/*!
+ This function is called for links, i.e. for words that
+ are marked with the qdoc link command. For autolinks
+ that are not marked with the qdoc link command, the
+ getAutoLink() function is called
+
+ It returns the string for a link found by using the data
+ in the \a atom to search the database. It also sets \a node
+ to point to the target node for that link. \a relative points
+ to the node holding the qdoc comment where the link command
+ was found.
+ */
+QString XmlGenerator::getLink(const Atom *atom, const Node *relative, const Node **node)
+{
+ const QString &t = atom->string();
+ if (t.at(0) == QChar('h')) {
+ if (t.startsWith("http:") || t.startsWith("https:"))
+ return t;
+ } else if (t.at(0) == QChar('f')) {
+ if (t.startsWith("file:") || t.startsWith("ftp:"))
+ return t;
+ } else if (t.at(0) == QChar('m')) {
+ if (t.startsWith("mailto:"))
+ return t;
+ }
+ return getAutoLink(atom, relative, node);
+}
+
+/*!
+ This function is called for autolinks, i.e. for words that
+ are not marked with the qdoc link command that qdoc has
+ reason to believe should be links. For links marked with
+ the qdoc link command, the getLink() function is called.
+
+ It returns the string for a link found by using the data
+ in the \a atom to search the database. It also sets \a node
+ to point to the target node for that link. \a relative points
+ to the node holding the qdoc comment where the link command
+ was found.
+ */
+QString XmlGenerator::getAutoLink(const Atom *atom, const Node *relative, const Node **node)
+{
+ QString ref;
+
+ *node = qdb_->findNodeForAtom(atom, relative, ref);
+ if (!(*node))
+ return QString();
+
+ QString link = (*node)->url();
+ if (link.isEmpty())
+ link = linkForNode(*node, relative);
+ if (!ref.isEmpty()) {
+ int hashtag = link.lastIndexOf(QChar('#'));
+ if (hashtag != -1)
+ link.truncate(hashtag);
+ link += QLatin1Char('#') + ref;
+ }
+ return link;
+}
+
+const QPair<QString, QString> XmlGenerator::anchorForNode(const Node *node)
+{
+ QPair<QString, QString> anchorPair;
+
+ anchorPair.first = Generator::fileName(node);
+ if (node->isTextPageNode())
+ anchorPair.second = node->title();
+
+ return anchorPair;
+}
+
+/*!
+ Returns a string describing the \a node type.
+ */
+QString XmlGenerator::targetType(const Node *node)
+{
+ if (!node)
+ return QStringLiteral("external");
+
+ switch (node->nodeType()) {
+ case Node::Namespace:
+ return QStringLiteral("namespace");
+ case Node::Class:
+ case Node::Struct:
+ case Node::Union:
+ return QStringLiteral("class");
+ case Node::Page:
+ case Node::Example:
+ return QStringLiteral("page");
+ case Node::Enum:
+ return QStringLiteral("enum");
+ case Node::Typedef:
+ return QStringLiteral("typedef");
+ case Node::Property:
+ return QStringLiteral("property");
+ case Node::Function:
+ return QStringLiteral("function");
+ case Node::Variable:
+ return QStringLiteral("variable");
+ case Node::Module:
+ return QStringLiteral("module");
+ default:
+ break;
+ }
+ return QString();
+}
+
+QT_END_NAMESPACE
diff --git a/src/qdoc/xmlgenerator.h b/src/qdoc/xmlgenerator.h
new file mode 100644
index 000000000..4bf1ca938
--- /dev/null
+++ b/src/qdoc/xmlgenerator.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Thibaut Cuvelier
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XMLGENERATOR_H
+#define XMLGENERATOR_H
+
+#include "node.h"
+#include "generator.h"
+
+#include <QtCore/qmap.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+class XmlGenerator : public Generator
+{
+public:
+ explicit XmlGenerator() = default;
+
+protected:
+ QHash<QString, QString> refMap;
+
+ static bool hasBrief(const Node *node);
+ static bool isThreeColumnEnumValueTable(const Atom *atom);
+ static int hOffset(const Node *node);
+
+ static void rewritePropertyBrief(const Atom *atom, const Node *relative);
+ static Node::NodeType typeFromString(const Atom *atom);
+ static void setImageFileName(const Node *relative, const QString &fileName);
+ static QPair<QString, int> getAtomListValue(const Atom *atom);
+ static QPair<QString, QString> getTableWidthAttr(const Atom *atom);
+
+ QString registerRef(const QString &ref);
+ QString refForNode(const Node *node);
+ QString linkForNode(const Node *node, const Node *relative);
+ QString getLink(const Atom *atom, const Node *relative, const Node **node);
+ QString getAutoLink(const Atom *atom, const Node *relative, const Node** node);
+
+ const QPair<QString, QString> anchorForNode(const Node *node);
+
+ static QString targetType(const Node *node);
+};
+
+QT_END_NAMESPACE
+
+#endif //XMLGENERATOR_H
diff --git a/src/qdoc/yyindent.cpp b/src/qdoc/yyindent.cpp
index 6e4b1a6ca..c78e132b6 100644
--- a/src/qdoc/yyindent.cpp
+++ b/src/qdoc/yyindent.cpp
@@ -126,7 +126,7 @@ static QRegExp *iflikeKeyword = nullptr;
static QChar firstNonWhiteSpace(const QString &t)
{
int i = 0;
- while (i < (int) t.length()) {
+ while (i < t.length()) {
if (!t[i].isSpace())
return t[i];
i++;
@@ -151,7 +151,7 @@ static bool isOnlyWhiteSpace(const QString &t)
int columnForIndex(const QString &t, int index)
{
int col = 0;
- if (index > (int) t.length())
+ if (index > t.length())
index = t.length();
for (int i = 0; i < index; i++) {
@@ -230,7 +230,7 @@ static QString trimmedCodeLine(const QString &t)
int pos1 = label->pos(1);
int stop = cap1.length();
- if (pos1 + stop < (int) trimmed.length() && ppIndentSize < stop)
+ if (pos1 + stop < trimmed.length() && ppIndentSize < stop)
stop = ppIndentSize;
int i = 0;
@@ -238,7 +238,7 @@ static QString trimmedCodeLine(const QString &t)
eraseChar(trimmed, pos1 + i, ' ');
i++;
}
- while (i < (int) cap1.length()) {
+ while (i < cap1.length()) {
eraseChar(trimmed, pos1 + i, ';');
i++;
}
diff --git a/src/shared/winutils/utils.cpp b/src/shared/winutils/utils.cpp
index 263efbe18..f32b9b76b 100644
--- a/src/shared/winutils/utils.cpp
+++ b/src/shared/winutils/utils.cpp
@@ -112,7 +112,7 @@ QStringList findSharedLibraries(const QDir &directory, Platform platform,
QString nameFilter = prefix;
if (nameFilter.isEmpty())
nameFilter += QLatin1Char('*');
- if (debugMatchMode == MatchDebug && (platform & WindowsBased))
+ if (debugMatchMode == MatchDebug && platformHasDebugSuffix(platform))
nameFilter += QLatin1Char('d');
nameFilter += sharedLibrarySuffix(platform);
QStringList result;
@@ -794,14 +794,13 @@ static inline MsvcDebugRuntimeResult checkMsvcDebugRuntime(const QStringList &de
for (const QString &lib : dependentLibraries) {
int pos = 0;
if (lib.startsWith(QLatin1String("MSVCR"), Qt::CaseInsensitive)
- || lib.startsWith(QLatin1String("MSVCP"), Qt::CaseInsensitive)) {
- pos = 5;
- } else if (lib.startsWith(QLatin1String("VCRUNTIME"), Qt::CaseInsensitive)) {
- pos = 9;
+ || lib.startsWith(QLatin1String("MSVCP"), Qt::CaseInsensitive)
+ || lib.startsWith(QLatin1String("VCRUNTIME"), Qt::CaseInsensitive)) {
+ int lastDotPos = lib.lastIndexOf(QLatin1Char('.'));
+ pos = -1 == lastDotPos ? 0 : lastDotPos - 1;
}
- if (pos && lib.at(pos).isDigit()) {
- for (++pos; lib.at(pos).isDigit(); ++pos)
- ;
+
+ if (pos) {
return lib.at(pos).toLower() == QLatin1Char('d')
? MsvcDebugRuntime : MsvcReleaseRuntime;
}
diff --git a/src/shared/winutils/utils.h b/src/shared/winutils/utils.h
index 5552a3665..7915f8e4e 100644
--- a/src/shared/winutils/utils.h
+++ b/src/shared/winutils/utils.h
@@ -61,6 +61,11 @@ enum Platform {
UnknownPlatform
};
+inline bool platformHasDebugSuffix(Platform p) // Uses 'd' debug suffix
+{
+ return (p & WindowsBased) != 0 && (p & MinGW) == 0;
+}
+
enum ListOption {
ListNone = 0,
ListSource,
diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp
index 1fefc6d21..99d1e152a 100644
--- a/src/windeployqt/main.cpp
+++ b/src/windeployqt/main.cpp
@@ -1062,7 +1062,7 @@ static QString libraryPath(const QString &libraryLocation, const char *name,
if (platform & WindowsBased) {
result += QLatin1String(name);
result += qtLibInfix;
- if (debug)
+ if (debug && platformHasDebugSuffix(platform))
result += QLatin1Char('d');
} else if (platform & UnixBased) {
result += QStringLiteral("lib");
@@ -1408,11 +1408,11 @@ static DeployResult deploy(const Options &options,
if ((options.platform & WindowsBased) && options.platform != WinCEIntel
&& options.platform != WinCEArm && !qtGuiLibrary.isEmpty()) {
QString libGlesName = QStringLiteral("libGLESV2");
- if (isDebug)
+ if (isDebug && platformHasDebugSuffix(options.platform))
libGlesName += QLatin1Char('d');
libGlesName += QLatin1String(windowsSharedLibrarySuffix);
QString libCombinedQtAngleName = QStringLiteral("QtANGLE");
- if (isDebug)
+ if (isDebug && platformHasDebugSuffix(options.platform))
libCombinedQtAngleName += QLatin1Char('d');
libCombinedQtAngleName += QLatin1String(windowsSharedLibrarySuffix);
const QStringList guiLibraries = findDependentLibraries(qtGuiLibrary, options.platform, errorMessage);
@@ -1428,7 +1428,7 @@ static DeployResult deploy(const Options &options,
const QString libGlesFullPath = qtBinDir + slash + libGlesName;
deployedQtLibraries.append(libGlesFullPath);
QString libEglFullPath = qtBinDir + slash + QStringLiteral("libEGL");
- if (isDebug)
+ if (isDebug && platformHasDebugSuffix(options.platform))
libEglFullPath += QLatin1Char('d');
libEglFullPath += QLatin1String(windowsSharedLibrarySuffix);
deployedQtLibraries.append(libEglFullPath);
@@ -1606,7 +1606,7 @@ static bool deployWebEngineCore(const QMap<QString, QString> &qmakeVariables,
"qtwebengine_resources_100p.pak",
"qtwebengine_resources_200p.pak"};
QByteArray webEngineProcessName(webEngineProcessC);
- if (isDebug)
+ if (isDebug && platformHasDebugSuffix(options.platform))
webEngineProcessName.append('d');
if (optVerboseLevel)
std::wcout << "Deploying: " << webEngineProcessName.constData() << "...\n";