From 5970cae1c37dc07acb7fd495520e83f20171a821 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Wed, 25 Dec 2019 20:21:37 +0100 Subject: Minor fixes Avoid code duplication by adding function addHtmlExtensionIfMissing() and avoid member shadowing by using 'm_' prefix for member variables --- src/definition.cpp | 2 +- src/docbookgen.cpp | 14 +-- src/docbookgen.h | 6 +- src/filedef.cpp | 2 +- src/htmldocvisitor.cpp | 7 +- src/htmlgen.cpp | 97 +++++++++--------- src/htmlgen.h | 12 +-- src/latexgen.cpp | 86 ++++++++-------- src/latexgen.h | 14 +-- src/mangen.cpp | 268 +++++++++++++++++++++++-------------------------- src/mangen.h | 42 ++++---- src/outputgen.cpp | 32 +++--- src/outputgen.h | 12 +-- src/rtfgen.cpp | 54 ++++------ src/rtfgen.h | 10 +- src/util.cpp | 16 ++- src/util.h | 4 +- 17 files changed, 316 insertions(+), 362 deletions(-) diff --git a/src/definition.cpp b/src/definition.cpp index 1912c46..7540eff 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -532,7 +532,7 @@ void DefinitionImpl::writeDocAnchorsToTagFile(FTextStream &tagFile) const { //printf("write an entry!\n"); if (definitionType()==TypeMember) tagFile << " "; - tagFile << " fileName << (hasExtension(si->fileName) ? "" : Doxygen::htmlFileExtension) << "\""; + tagFile << " fileName) << "\""; if (!si->title.isEmpty()) { tagFile << " title=\"" << convertToXML(si->title) << "\""; diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 51f37db..fff9728 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -260,7 +260,7 @@ void DocbookCodeGenerator::endCodeFragment() DocbookGenerator::DocbookGenerator() : OutputGenerator() { DB_GEN_C - dir=Config_getString(DOCBOOK_OUTPUT); + m_dir=Config_getString(DOCBOOK_OUTPUT); //insideTabbing=FALSE; //firstDescItem=TRUE; //disableLinks=FALSE; @@ -917,7 +917,7 @@ DB_GEN_C t << " " << "" << endl; t << " " << endl; - d.writeImage(t,dir,relPath,fileName,FALSE); + d.writeImage(t,m_dir,relPath,fileName,FALSE); t << " " << endl; t << " " << endl; t << "" << endl; @@ -1108,7 +1108,7 @@ DB_GEN_C void DocbookGenerator::endGroupCollaboration(DotGroupCollaboration &g) { DB_GEN_C - g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),fileName,relPath,FALSE); + g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),m_fileName,relPath,FALSE); } void DocbookGenerator::startDotGraph() { @@ -1117,7 +1117,7 @@ DB_GEN_C void DocbookGenerator::endDotGraph(DotClassGraph &g) { DB_GEN_C - g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),fileName,relPath,TRUE,FALSE); + g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),m_fileName,relPath,TRUE,FALSE); } void DocbookGenerator::startInclDepGraph() { @@ -1126,7 +1126,7 @@ DB_GEN_C void DocbookGenerator::endInclDepGraph(DotInclDepGraph &g) { DB_GEN_C - QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), fileName,relPath,FALSE); + QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), m_fileName,relPath,FALSE); } void DocbookGenerator::startCallGraph() { @@ -1135,7 +1135,7 @@ DB_GEN_C void DocbookGenerator::endCallGraph(DotCallGraph &g) { DB_GEN_C - QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), fileName,relPath,FALSE); + QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), m_fileName,relPath,FALSE); } void DocbookGenerator::startDirDepGraph() { @@ -1144,7 +1144,7 @@ DB_GEN_C void DocbookGenerator::endDirDepGraph(DotDirDeps &g) { DB_GEN_C - QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), fileName,relPath,FALSE); + QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), m_fileName,relPath,FALSE); } void DocbookGenerator::startMemberDocList() { diff --git a/src/docbookgen.h b/src/docbookgen.h index 8f71722..64e9e67 100644 --- a/src/docbookgen.h +++ b/src/docbookgen.h @@ -104,12 +104,12 @@ class DocbookGenerator : public OutputGenerator // generic generator methods /////////////////////////////////////////////////////////////// void enable() - { if (genStack->top()) active=*genStack->top(); else active=TRUE; } - void disable() { active=FALSE; } + { if (m_genStack->top()) m_active=*m_genStack->top(); else m_active=TRUE; } + void disable() { m_active=FALSE; } void enableIf(OutputType o) { if (o==Docbook) enable(); } void disableIf(OutputType o) { if (o==Docbook) disable(); } void disableIfNot(OutputType o) { if (o!=Docbook) disable(); } - bool isEnabled(OutputType o) { return (o==Docbook && active); } + bool isEnabled(OutputType o) { return (o==Docbook && m_active); } OutputGenerator *get(OutputType o) { return (o==Docbook) ? this : 0; } // --- CodeOutputInterface diff --git a/src/filedef.cpp b/src/filedef.cpp index 6556372..fb0e290 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -349,7 +349,7 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile) tagFile << " " << endl; tagFile << " " << convertToXML(name()) << "" << endl; tagFile << " " << convertToXML(getPath()) << "" << endl; - tagFile << " " << convertToXML(getOutputFileBase()) << (hasExtension(getOutputFileBase()) ? "" : Doxygen::htmlFileExtension) << "" << endl; + tagFile << " " << convertToXML(addHtmlExtensionIfMissing(getOutputFileBase())) << "" << endl; if (m_includeList && m_includeList->count()>0) { QListIterator ili(*m_includeList); diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 543d604..3fbbf12 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -1912,8 +1912,7 @@ void HtmlDocVisitor::visitPost(DocRef *ref) void HtmlDocVisitor::visitPre(DocSecRefItem *ref) { if (m_hide) return; - QCString refName=ref->file(); - refName+=(hasExtension(refName) ? "" : Doxygen::htmlFileExtension); + QCString refName=addHtmlExtensionIfMissing(ref->file()); m_t << "
  • anchor() << "\">"; } @@ -2094,7 +2093,7 @@ void HtmlDocVisitor::visitPre(DocXRefItem *x) { m_t << "key()) << ">
    relPath() << x->file() << (hasExtension(x->file()) ? "" : Doxygen::htmlFileExtension) + << x->relPath() << addHtmlExtensionIfMissing(x->file()) << "#" << x->anchor() << "\">"; } else @@ -2260,7 +2259,7 @@ void HtmlDocVisitor::startLink(const QCString &ref,const QCString &file, m_t << externalRef(relPath,ref,TRUE); if (!file.isEmpty()) { - m_t << file << (hasExtension(file) ? "" : Doxygen::htmlFileExtension); + m_t << addHtmlExtensionIfMissing(file); } if (!anchor.isEmpty()) m_t << "#" << anchor; m_t << "\""; diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index 047eec8..bf52eed 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -752,7 +752,7 @@ void HtmlCodeGenerator::_writeCodeLink(const char *className, } m_t << "href=\""; m_t << externalRef(m_relPath,ref,TRUE); - if (f) m_t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension); + if (f) m_t << addHtmlExtensionIfMissing(f); if (anchor) m_t << "#" << anchor; m_t << "\""; if (tooltip) m_t << " title=\"" << convertToHtml(tooltip) << "\""; @@ -773,7 +773,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo, { m_t << "addIndexFile(fileName); - lastFile = fileName; - t << substituteHtmlKeywords(g_header,convertToHtml(filterTitle(title)),relPath); + m_lastFile = fileName; + t << substituteHtmlKeywords(g_header,convertToHtml(filterTitle(title)),m_relPath); t << "" << endl; @@ -1108,7 +1107,7 @@ void HtmlGenerator::startFile(const char *name,const char *, t << "\n"; } @@ -1116,13 +1115,12 @@ void HtmlGenerator::startFile(const char *name,const char *, m_sectionCount=0; } -void HtmlGenerator::writeSearchInfo(FTextStream &t,const QCString &relPath) +void HtmlGenerator::writeSearchInfo(FTextStream &t,const QCString &) { static bool searchEngine = Config_getBool(SEARCHENGINE); static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH); if (searchEngine && !serverBasedSearch) { - (void)relPath; t << "\n"; t << "
    writeTooltips(m_codeGen); - writePageFooter(t,lastTitle,relPath,navPath); + writePageFooter(t,m_lastTitle,m_relPath,navPath); } void HtmlGenerator::endFile() @@ -1323,8 +1321,8 @@ void HtmlGenerator::startIndexItem(const char *ref,const char *f) t << ""; } else @@ -1351,7 +1349,7 @@ void HtmlGenerator::writeStartAnnoItem(const char *,const char *f, { t << "
  • "; if (path) docify(path); - t << ""; + t << ""; docify(name); t << " "; } @@ -1369,8 +1367,8 @@ void HtmlGenerator::writeObjectLink(const char *ref,const char *f, t << ""; docify(name); @@ -1380,7 +1378,7 @@ void HtmlGenerator::writeObjectLink(const char *ref,const char *f, void HtmlGenerator::startTextLink(const char *f,const char *anchor) { t << ""; } @@ -1583,7 +1581,7 @@ static void endSectionContent(FTextStream &t) void HtmlGenerator::startClassDiagram() { - startSectionHeader(t,relPath,m_sectionCount); + startSectionHeader(t,m_relPath,m_sectionCount); } void HtmlGenerator::endClassDiagram(const ClassDiagram &d, @@ -1596,12 +1594,12 @@ void HtmlGenerator::endClassDiagram(const ClassDiagram &d, startSectionSummary(t,m_sectionCount); endSectionSummary(t); startSectionContent(t,m_sectionCount); - d.writeImage(tt,dir,relPath,fileName); + d.writeImage(tt,m_dir,m_relPath,fileName); if (!result.isEmpty()) { t << "
    " << endl; t << " \"\"/" << endl; t << " " << endl; t << " \"\"/" << endl; + t << m_relPath << fileName << ".png\" alt=\"\"/>" << endl; t << "
    "; } endSectionContent(t); @@ -1967,7 +1965,7 @@ void HtmlGenerator::endMemberDoc(bool hasArgs) void HtmlGenerator::startDotGraph() { - startSectionHeader(t,relPath,m_sectionCount); + startSectionHeader(t,m_relPath,m_sectionCount); } void HtmlGenerator::endDotGraph(DotClassGraph &g) @@ -1979,11 +1977,11 @@ void HtmlGenerator::endDotGraph(DotClassGraph &g) endSectionSummary(t); startSectionContent(t,m_sectionCount); - g.writeGraph(t,GOF_BITMAP,EOF_Html,dir,fileName,relPath,TRUE,TRUE,m_sectionCount); + g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,TRUE,m_sectionCount); if (generateLegend && !umlLook) { t << "
    ["; - startHtmlLink(relPath+"graph_legend"+Doxygen::htmlFileExtension); + startHtmlLink(m_relPath+"graph_legend"+Doxygen::htmlFileExtension); t << theTranslator->trLegend(); endHtmlLink(); t << "]
    "; @@ -1995,7 +1993,7 @@ void HtmlGenerator::endDotGraph(DotClassGraph &g) void HtmlGenerator::startInclDepGraph() { - startSectionHeader(t,relPath,m_sectionCount); + startSectionHeader(t,m_relPath,m_sectionCount); } void HtmlGenerator::endInclDepGraph(DotInclDepGraph &g) @@ -2005,7 +2003,7 @@ void HtmlGenerator::endInclDepGraph(DotInclDepGraph &g) endSectionSummary(t); startSectionContent(t,m_sectionCount); - g.writeGraph(t,GOF_BITMAP,EOF_Html,dir,fileName,relPath,TRUE,m_sectionCount); + g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount); endSectionContent(t); m_sectionCount++; @@ -2013,7 +2011,7 @@ void HtmlGenerator::endInclDepGraph(DotInclDepGraph &g) void HtmlGenerator::startGroupCollaboration() { - startSectionHeader(t,relPath,m_sectionCount); + startSectionHeader(t,m_relPath,m_sectionCount); } void HtmlGenerator::endGroupCollaboration(DotGroupCollaboration &g) @@ -2023,7 +2021,7 @@ void HtmlGenerator::endGroupCollaboration(DotGroupCollaboration &g) endSectionSummary(t); startSectionContent(t,m_sectionCount); - g.writeGraph(t,GOF_BITMAP,EOF_Html,dir,fileName,relPath,TRUE,m_sectionCount); + g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount); endSectionContent(t); m_sectionCount++; @@ -2031,7 +2029,7 @@ void HtmlGenerator::endGroupCollaboration(DotGroupCollaboration &g) void HtmlGenerator::startCallGraph() { - startSectionHeader(t,relPath,m_sectionCount); + startSectionHeader(t,m_relPath,m_sectionCount); } void HtmlGenerator::endCallGraph(DotCallGraph &g) @@ -2041,7 +2039,7 @@ void HtmlGenerator::endCallGraph(DotCallGraph &g) endSectionSummary(t); startSectionContent(t,m_sectionCount); - g.writeGraph(t,GOF_BITMAP,EOF_Html,dir,fileName,relPath,TRUE,m_sectionCount); + g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount); endSectionContent(t); m_sectionCount++; @@ -2049,7 +2047,7 @@ void HtmlGenerator::endCallGraph(DotCallGraph &g) void HtmlGenerator::startDirDepGraph() { - startSectionHeader(t,relPath,m_sectionCount); + startSectionHeader(t,m_relPath,m_sectionCount); } void HtmlGenerator::endDirDepGraph(DotDirDeps &g) @@ -2059,7 +2057,7 @@ void HtmlGenerator::endDirDepGraph(DotDirDeps &g) endSectionSummary(t); startSectionContent(t,m_sectionCount); - g.writeGraph(t,GOF_BITMAP,EOF_Html,dir,fileName,relPath,TRUE,m_sectionCount); + g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount); endSectionContent(t); m_sectionCount++; @@ -2067,7 +2065,7 @@ void HtmlGenerator::endDirDepGraph(DotDirDeps &g) void HtmlGenerator::writeGraphicalHierarchy(DotGfxHierarchyTable &g) { - g.writeGraph(t,dir,fileName); + g.writeGraph(t,m_dir,m_fileName); } void HtmlGenerator::startMemberGroupHeader(bool) @@ -2544,7 +2542,7 @@ QCString HtmlGenerator::writeSplitBarAsString(const char *name,const char *relpa "