Skip to content

Commit 0df1623

Browse files
committed
Refactor: modernize configuration values
1 parent fd11115 commit 0df1623

29 files changed

+1041
-1088
lines changed

addon/doxyapp/doxyapp.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -264,31 +264,32 @@ int main(int argc,char **argv)
264264
checkConfiguration();
265265
adjustConfiguration();
266266
// we need a place to put intermediate files
267-
Config_getString(OUTPUT_DIRECTORY)="/tmp/doxygen";
267+
Config_updateString(OUTPUT_DIRECTORY,"/tmp/doxygen");
268268
// disable html output
269-
Config_getBool(GENERATE_HTML)=FALSE;
269+
Config_updateBool(GENERATE_HTML,FALSE);
270270
// disable latex output
271-
Config_getBool(GENERATE_LATEX)=FALSE;
271+
Config_updateBool(GENERATE_LATEX,FALSE);
272272
// be quiet
273-
Config_getBool(QUIET)=TRUE;
273+
Config_updateBool(QUIET,TRUE);
274274
// turn off warnings
275-
Config_getBool(WARNINGS)=FALSE;
276-
Config_getBool(WARN_IF_UNDOCUMENTED)=FALSE;
277-
Config_getBool(WARN_IF_DOC_ERROR)=FALSE;
275+
Config_updateBool(WARNINGS,FALSE);
276+
Config_updateBool(WARN_IF_UNDOCUMENTED,FALSE);
277+
Config_updateBool(WARN_IF_DOC_ERROR,FALSE);
278278
// Extract as much as possible
279-
Config_getBool(EXTRACT_ALL)=TRUE;
280-
Config_getBool(EXTRACT_STATIC)=TRUE;
281-
Config_getBool(EXTRACT_PRIVATE)=TRUE;
282-
Config_getBool(EXTRACT_LOCAL_METHODS)=TRUE;
279+
Config_updateBool(EXTRACT_ALL,TRUE);
280+
Config_updateBool(EXTRACT_STATIC,TRUE);
281+
Config_updateBool(EXTRACT_PRIVATE,TRUE);
282+
Config_updateBool(EXTRACT_LOCAL_METHODS,TRUE);
283283
// Extract source browse information, needed
284284
// to make doxygen gather the cross reference info
285-
Config_getBool(SOURCE_BROWSER)=TRUE;
285+
Config_updateBool(SOURCE_BROWSER,TRUE);
286286
// In case of a directory take all files on directory and its subdirectories
287-
Config_getBool(RECURSIVE)=TRUE;
287+
Config_updateBool(RECURSIVE,TRUE);
288288

289289
// set the input
290-
Config_getList(INPUT).clear();
291-
Config_getList(INPUT).append(argv[1]);
290+
StringVector inputList;
291+
inputList.push_back(argv[1]);
292+
Config_updateList(INPUT,inputList);
292293

293294
// parse the files
294295
parseInput();

addon/doxyparse/doxyparse.cpp

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -462,44 +462,35 @@ int main(int argc,char **argv) {
462462
else
463463
tmpdir << "doxyparse-" << pid;
464464

465-
Config_getString(OUTPUT_DIRECTORY)= tmpdir.str().c_str();
465+
Config_updateString(OUTPUT_DIRECTORY,tmpdir.str().c_str());
466466
// enable HTML (fake) output to omit warning about missing output format
467-
Config_getBool(GENERATE_HTML)=TRUE;
467+
Config_updateBool(GENERATE_HTML,TRUE);
468468
// disable latex output
469-
Config_getBool(GENERATE_LATEX)=FALSE;
469+
Config_updateBool(GENERATE_LATEX,FALSE);
470470
// be quiet
471-
Config_getBool(QUIET)=TRUE;
471+
Config_updateBool(QUIET,TRUE);
472472
// turn off warnings
473-
Config_getBool(WARNINGS)=FALSE;
474-
Config_getBool(WARN_IF_UNDOCUMENTED)=FALSE;
475-
Config_getBool(WARN_IF_DOC_ERROR)=FALSE;
473+
Config_updateBool(WARNINGS,FALSE);
474+
Config_updateBool(WARN_IF_UNDOCUMENTED,FALSE);
475+
Config_updateBool(WARN_IF_DOC_ERROR,FALSE);
476476
// Extract as much as possible
477-
Config_getBool(EXTRACT_ALL)=TRUE;
478-
Config_getBool(EXTRACT_STATIC)=TRUE;
479-
Config_getBool(EXTRACT_PRIVATE)=TRUE;
480-
Config_getBool(EXTRACT_LOCAL_METHODS)=TRUE;
481-
Config_getBool(EXTRACT_PACKAGE)=TRUE;
477+
Config_updateBool(EXTRACT_ALL,TRUE);
478+
Config_updateBool(EXTRACT_STATIC,TRUE);
479+
Config_updateBool(EXTRACT_PRIVATE,TRUE);
480+
Config_updateBool(EXTRACT_LOCAL_METHODS,TRUE);
481+
Config_updateBool(EXTRACT_PACKAGE,TRUE);
482482
// Extract source browse information, needed
483483
// to make doxygen gather the cross reference info
484-
Config_getBool(SOURCE_BROWSER)=TRUE;
484+
Config_updateBool(SOURCE_BROWSER,TRUE);
485485
// find functions call between modules
486-
Config_getBool(CALL_GRAPH)=TRUE;
486+
Config_updateBool(CALL_GRAPH,TRUE);
487487
// loop recursive over input files
488-
Config_getBool(RECURSIVE)=TRUE;
488+
Config_updateBool(RECURSIVE,TRUE);
489489
// add file extensions
490-
Config_getList(FILE_PATTERNS).append("*.cc");
491-
Config_getList(FILE_PATTERNS).append("*.cxx");
492-
Config_getList(FILE_PATTERNS).append("*.cpp");
493-
Config_getList(FILE_PATTERNS).append("*.java");
494-
Config_getList(FILE_PATTERNS).append("*.py");
495-
Config_getList(FILE_PATTERNS).append("*.pyw");
496-
Config_getList(FILE_PATTERNS).append("*.cs");
497-
Config_getList(FILE_PATTERNS).append("*.c");
498-
Config_getList(FILE_PATTERNS).append("*.h");
499-
Config_getList(FILE_PATTERNS).append("*.hh");
500-
Config_getList(FILE_PATTERNS).append("*.hpp");
490+
Config_updateList(FILE_PATTERNS, { "*.cc", "*.cxx", "*.cpp", "*.java",
491+
"*.py", "*.pyw", "*.cs", "*.c", "*.h", "*.hh", "*.hpp"});
501492
// set the input
502-
Config_getList(INPUT).clear();
493+
StringVector inputList;
503494
for (int i = 1; i < argc; i++) {
504495
if (strcmp(argv[i], "-") == 0) {
505496
char filename[1024];
@@ -508,13 +499,14 @@ int main(int argc,char **argv) {
508499
if (feof(stdin)) {
509500
break;
510501
}
511-
Config_getList(INPUT).append(filename);
502+
inputList.push_back(filename);
512503
}
513504
} else {
514-
Config_getList(INPUT).append(argv[i]);
505+
inputList.push_back(argv[i]);
515506
}
516507
}
517-
if (Config_getList(INPUT).isEmpty()) {
508+
Config_updateList(INPUT,inputList);
509+
if (inputList.empty()) {
518510
exit(0);
519511
}
520512

src/cite.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Based on a patch by David Munger
55
*
66
* Permission to use, copy, modify, and distribute this software and its
7-
* documentation under the terms of the GNU General Public License is hereby
8-
* granted. No representations are made about the suitability of this software
7+
* documentation under the terms of the GNU General Public License is hereby
8+
* granted. No representations are made about the suitability of this software
99
* for any purpose. It is provided "as is" without express or implied warranty.
1010
* See the GNU General Public License for more details.
1111
*
@@ -94,7 +94,7 @@ void CitationManager::clear()
9494

9595
bool CitationManager::isEmpty() const
9696
{
97-
uint numFiles = Config_getList(CITE_BIB_FILES).count();
97+
size_t numFiles = Config_getList(CITE_BIB_FILES).size();
9898
return (numFiles==0 || p->entries.empty());
9999
}
100100

@@ -117,20 +117,18 @@ void CitationManager::generatePage()
117117

118118
// 0. add cross references from the bib files to the cite dictionary
119119
QFile f;
120-
const QStrList &citeDataList = Config_getList(CITE_BIB_FILES);
121-
QStrListIterator li(citeDataList);
122-
const char *bibdata = 0;
123-
for (li.toFirst() ; (bibdata = li.current()) ; ++li)
120+
const StringVector &citeDataList = Config_getList(CITE_BIB_FILES);
121+
for (const auto &bibdata : citeDataList)
124122
{
125-
QCString bibFile = bibdata;
123+
QCString bibFile = bibdata.c_str();
126124
if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib";
127125
QFileInfo fi(bibFile);
128126
if (fi.exists())
129127
{
130128
if (!bibFile.isEmpty())
131129
{
132130
f.setName(bibFile);
133-
if (!f.open(IO_ReadOnly))
131+
if (!f.open(IO_ReadOnly))
134132
{
135133
err("could not open file %s for reading\n",bibFile.data());
136134
}
@@ -173,7 +171,7 @@ void CitationManager::generatePage()
173171
QCString outputDir = Config_getString(OUTPUT_DIRECTORY);
174172
QCString citeListFile = outputDir+"/citelist.doc";
175173
f.setName(citeListFile);
176-
if (!f.open(IO_WriteOnly))
174+
if (!f.open(IO_WriteOnly))
177175
{
178176
err("could not open file %s for writing\n",citeListFile.data());
179177
}
@@ -207,9 +205,9 @@ void CitationManager::generatePage()
207205
QDir thisDir;
208206
thisDir.mkdir(bibOutputDir);
209207
int i = 0;
210-
for (li.toFirst() ; (bibdata = li.current()) ; ++li)
208+
for (const auto &bibdata : citeDataList)
211209
{
212-
QCString bibFile = bibdata;
210+
QCString bibFile = bibdata.c_str();
213211
if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib";
214212
QFileInfo fi(bibFile);
215213
if (fi.exists())
@@ -242,7 +240,7 @@ void CitationManager::generatePage()
242240

243241
// 6. read back the file
244242
f.setName(citeListFile);
245-
if (!f.open(IO_ReadOnly))
243+
if (!f.open(IO_ReadOnly))
246244
{
247245
err("could not open file %s for reading\n",citeListFile.data());
248246
}
@@ -294,16 +292,16 @@ void CitationManager::generatePage()
294292
// 7. add it as a page
295293
addRelatedPage(fileName(),theTranslator->trCiteReferences(),doc,fileName(),1);
296294

297-
// 8. for latex we just copy the bib files to the output and let
295+
// 8. for latex we just copy the bib files to the output and let
298296
// latex do this work.
299297
if (Config_getBool(GENERATE_LATEX))
300298
{
301299
// copy bib files to the latex output dir
302300
QCString latexOutputDir = Config_getString(LATEX_OUTPUT)+"/";
303301
i = 0;
304-
for (li.toFirst() ; (bibdata = li.current()) ; ++li)
302+
for (const auto &bibdata : citeDataList)
305303
{
306-
QCString bibFile = bibdata;
304+
QCString bibFile = bibdata.c_str();
307305
// Note: file can now have multiple dots
308306
if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib";
309307
fi.setFile(bibFile);
@@ -333,7 +331,7 @@ void CitationManager::generatePage()
333331
// we might try to remove too many files as empty files didn't get a corresponding new file
334332
// but the remove function does not emit an error for it and we don't catch the error return
335333
// so no problem.
336-
for (unsigned int j = 1; j <= citeDataList.count(); j++)
334+
for (size_t j = 1; j <= citeDataList.size(); j++)
337335
{
338336
thisDir.remove(bibOutputDir + bibTmpFile + QCString().setNum(j) + ".bib");
339337
}
@@ -370,13 +368,11 @@ void CitationManager::writeLatexBibliography(FTextStream &t) const
370368
}
371369
t << "\\bibliographystyle{" << style << "}\n"
372370
"\\bibliography{";
373-
QStrList &citeDataList = Config_getList(CITE_BIB_FILES);
371+
const StringVector &citeDataList = Config_getList(CITE_BIB_FILES);
374372
int i = 0;
375-
QStrListIterator li(citeDataList);
376-
const char *bibdata = 0;
377-
for (li.toFirst() ; (bibdata = li.current()) ; ++li)
373+
for (const auto &bibdata : citeDataList)
378374
{
379-
QCString bibFile = bibdata;
375+
QCString bibFile = bibdata.c_str();
380376
// Note: file can now have multiple dots
381377
if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib";
382378
QFileInfo fi(bibFile);

src/clangparser.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ void ClangParser::determineInputFilesInSameTu(QStrList &files)
159159

160160
void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
161161
{
162-
static bool clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING);
163-
static QStrList &includePath = Config_getList(INCLUDE_PATH);
164-
static QStrList clangOptions = Config_getList(CLANG_OPTIONS);
165-
static QCString clangCompileDatabase = Config_getString(CLANG_DATABASE_PATH);
162+
bool clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING);
163+
const StringVector &includePath = Config_getList(INCLUDE_PATH);
164+
const StringVector &clangOptions = Config_getList(CLANG_OPTIONS);
165+
QCString clangCompileDatabase = Config_getString(CLANG_DATABASE_PATH);
166166
if (!clangAssistedParsing) return;
167167
//printf("ClangParser::start(%s)\n",fileName);
168168
p->fileName = fileName;
@@ -198,8 +198,8 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
198198
}
199199
char **argv = (char**)malloc(sizeof(char*)*
200200
(4+Doxygen::inputPaths.size()+
201-
includePath.count()+
202-
clangOptions.count()+
201+
includePath.size()+
202+
clangOptions.size()+
203203
clang_option_len));
204204
if (!command.empty() )
205205
{
@@ -222,15 +222,15 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
222222
//printf("argv[%d]=%s\n",argc,argv[argc]);
223223
}
224224
// add external include paths
225-
for (uint i=0;i<includePath.count();i++)
225+
for (size_t i=0;i<includePath.size();i++)
226226
{
227-
QCString inc = QCString("-I")+includePath.at(i);
227+
QCString inc = QCString("-I")+includePath[i].c_str();
228228
argv[argc++]=qstrdup(inc.data());
229229
}
230230
// user specified options
231-
for (uint i=0;i<clangOptions.count();i++)
231+
for (size_t i=0;i<clangOptions.size();i++)
232232
{
233-
argv[argc++]=qstrdup(clangOptions.at(i));
233+
argv[argc++]=qstrdup(clangOptions[i].c_str());
234234
}
235235
// extra options
236236
argv[argc++]=qstrdup("-ferror-limit=0");

src/classdef.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,16 +1848,15 @@ void ClassDefImpl::writeIncludeFilesForSlice(OutputList &ol) const
18481848
if (m_impl->incInfo)
18491849
{
18501850
QCString nm;
1851-
QStrList paths = Config_getList(STRIP_FROM_PATH);
1852-
if (!paths.isEmpty() && m_impl->incInfo->fileDef)
1851+
const StringVector &paths = Config_getList(STRIP_FROM_PATH);
1852+
if (!paths.empty() && m_impl->incInfo->fileDef)
18531853
{
18541854
QCString abs = m_impl->incInfo->fileDef->absFilePath();
1855-
const char *s = paths.first();
18561855
QCString potential;
18571856
unsigned int length = 0;
1858-
while (s)
1857+
for (const auto &s : paths)
18591858
{
1860-
QFileInfo info(s);
1859+
QFileInfo info(s.c_str());
18611860
if (info.exists())
18621861
{
18631862
QCString prefix = info.absFilePath().utf8();
@@ -1872,7 +1871,6 @@ void ClassDefImpl::writeIncludeFilesForSlice(OutputList &ol) const
18721871
length = prefix.length();
18731872
potential = abs.right(abs.length() - prefix.length());
18741873
}
1875-
s = paths.next();
18761874
}
18771875
}
18781876

src/condparser.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Copyright (C) 1997-2015 by Dimitri van Heesch.
33
*
44
* Permission to use, copy, modify, and distribute this software and its
5-
* documentation under the terms of the GNU General Public License is hereby
6-
* granted. No representations are made about the suitability of this software
5+
* documentation under the terms of the GNU General Public License is hereby
6+
* granted. No representations are made about the suitability of this software
77
* for any purpose. It is provided "as is" without express or implied warranty.
88
* See the GNU General Public License for more details.
99
*
@@ -19,6 +19,8 @@
1919
* ! NOT operator
2020
*/
2121

22+
#include <algorithm>
23+
2224
#include "condparser.h"
2325
#include "config.h"
2426
#include "message.h"
@@ -27,7 +29,7 @@
2729

2830
/**
2931
* parses and evaluates the given expression.
30-
* @returns
32+
* @returns
3133
* - On error, an error message is returned.
3234
* - On success, the result of the expression is either "1" or "0".
3335
*/
@@ -123,13 +125,13 @@ int CondParser::getOperatorId(const QCString &opName)
123125

124126
/**
125127
* Get next token in the current string expr.
126-
* Uses the data in m_expr pointed to by m_e to
128+
* Uses the data in m_expr pointed to by m_e to
127129
* produce m_tokenType and m_token, set m_err in case of an error
128130
*/
129131
void CondParser::getToken()
130132
{
131133
m_tokenType = NOTHING;
132-
m_token.resize(0);
134+
m_token.resize(0);
133135

134136
//printf("\tgetToken e:{%c}, ascii=%i, col=%i\n", *e, *e, e-expr);
135137

@@ -303,7 +305,7 @@ bool CondParser::evalOperator(int opId, bool lhs, bool rhs)
303305
*/
304306
bool CondParser::evalVariable(const char *varName)
305307
{
306-
if (Config_getList(ENABLED_SECTIONS).find(varName)==-1) return FALSE;
307-
return TRUE;
308+
const StringVector &list = Config_getList(ENABLED_SECTIONS);
309+
return std::find(list.begin(),list.end(),varName)!=list.end();
308310
}
309311

0 commit comments

Comments
 (0)