summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-08-09 18:55:22 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-08-24 14:08:14 (GMT)
commit0815bb7d5c99fccdbdba24fb933f9e7fce29bbc6 (patch)
treef3af0df1bd26f367220386ab4e011a27c9b341fd
parent8b3efba55c297d9af5274bf525e53417b78e8be3 (diff)
downloadDoxygen-0815bb7d5c99fccdbdba24fb933f9e7fce29bbc6.zip
Doxygen-0815bb7d5c99fccdbdba24fb933f9e7fce29bbc6.tar.gz
Doxygen-0815bb7d5c99fccdbdba24fb933f9e7fce29bbc6.tar.bz2
Refactoring: OutputList & OutputGen
- Initialized member variables inside the class - Added copy & assign operators for OutputGenerator and Derived classes. - throw a runtime exception when OutputGenerator is copied while is file is still in progress. - Added clone method to make a copy of OutputList. - Moved the implementation of enable() & disable() and friend into OutputGen instead of having the same implementation in each derived class. - Made m_dir and m_fileName readonly (members dir() and fileName()) - Removed call to new while adding generators to OutputList - Replaced QStack by std::stack for the "enabled" state.
-rw-r--r--src/code.l1
-rw-r--r--src/docbookgen.cpp50
-rw-r--r--src/docbookgen.h53
-rw-r--r--src/doxygen.cpp15
-rw-r--r--src/filedef.cpp10
-rw-r--r--src/htmlgen.cpp136
-rw-r--r--src/htmlgen.h54
-rw-r--r--src/latexgen.cpp100
-rw-r--r--src/latexgen.h49
-rw-r--r--src/mangen.cpp26
-rw-r--r--src/mangen.h53
-rw-r--r--src/outputgen.cpp113
-rw-r--r--src/outputgen.h134
-rw-r--r--src/outputlist.cpp26
-rw-r--r--src/outputlist.h15
-rw-r--r--src/rtfgen.cpp44
-rw-r--r--src/rtfgen.h69
17 files changed, 515 insertions, 433 deletions
diff --git a/src/code.l b/src/code.l
index 6627498..56b0e0f 100644
--- a/src/code.l
+++ b/src/code.l
@@ -36,6 +36,7 @@
#include <ctype.h>
#include <qregexp.h>
#include <qdir.h>
+#include <qstack.h>
#include "code.h"
#include "entry.h"
diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp
index e5c9a6b..da7987b 100644
--- a/src/docbookgen.cpp
+++ b/src/docbookgen.cpp
@@ -89,7 +89,7 @@ inline void writeDocbookCodeString(FTextStream &t,const char *s, int &col)
{
case '\t':
{
- static int tabSize = Config_getInt(TAB_SIZE);
+ int tabSize = Config_getInt(TAB_SIZE);
int spacesToNextTabStop = tabSize - (col%tabSize);
col+=spacesToNextTabStop;
while (spacesToNextTabStop--) t << "&#32;";
@@ -140,7 +140,6 @@ DocbookCodeGenerator::DocbookCodeGenerator(FTextStream &t)
DocbookCodeGenerator::DocbookCodeGenerator()
{
- m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING);
}
DocbookCodeGenerator::~DocbookCodeGenerator() {}
@@ -255,25 +254,24 @@ void DocbookCodeGenerator::endCodeFragment()
m_t << "</computeroutput></literallayout>" << endl;
}
-DocbookGenerator::DocbookGenerator() : OutputGenerator()
+DocbookGenerator::DocbookGenerator() : OutputGenerator(Config_getString(DOCBOOK_OUTPUT))
{
DB_GEN_C
- m_dir=Config_getString(DOCBOOK_OUTPUT);
- //insideTabbing=FALSE;
- //firstDescItem=TRUE;
- //disableLinks=FALSE;
- //m_indent=0;
- //templateMemberItem = FALSE;
- m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING);
- m_denseText = FALSE;
- m_inGroup = FALSE;
- m_inDetail = FALSE;
- m_levelListItem = 0;
- m_descTable = FALSE;
- m_inLevel = -1;
- m_firstMember = FALSE;
- for (size_t i = 0 ; i < sizeof(m_inListItem) / sizeof(*m_inListItem) ; i++) m_inListItem[i] = FALSE;
- for (size_t i = 0 ; i < sizeof(m_inSimpleSect) / sizeof(*m_inSimpleSect) ; i++) m_inSimpleSect[i] = FALSE;
+}
+
+DocbookGenerator::DocbookGenerator(const DocbookGenerator &og) : OutputGenerator(og)
+{
+}
+
+DocbookGenerator &DocbookGenerator::operator=(const DocbookGenerator &og)
+{
+ OutputGenerator::operator=(og);
+ return *this;
+}
+
+std::unique_ptr<OutputGenerator> DocbookGenerator::clone() const
+{
+ return std::make_unique<DocbookGenerator>(*this);
}
DocbookGenerator::~DocbookGenerator()
@@ -428,7 +426,7 @@ DB_GEN_C2("IndexSections " << is)
void DocbookGenerator::endIndexSection(IndexSections is)
{
DB_GEN_C2("IndexSections " << is)
- static bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
+ bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
switch (is)
{
case isTitlePageStart:
@@ -913,7 +911,7 @@ DB_GEN_C
t << " <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\""
<< relPath << fileName << ".png\">" << "</imagedata>" << endl;
t << " </imageobject>" << endl;
- d.writeImage(t,m_dir,relPath,fileName,FALSE);
+ d.writeImage(t,dir(),relPath,fileName,FALSE);
t << " </mediaobject>" << endl;
t << " </informalfigure>" << endl;
t << "</para>" << endl;
@@ -1104,7 +1102,7 @@ DB_GEN_C
void DocbookGenerator::endGroupCollaboration(DotGroupCollaboration &g)
{
DB_GEN_C
- g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),m_fileName,relPath,FALSE);
+ g.writeGraph(t,GOF_BITMAP,EOF_DocBook,dir(),fileName(),relPath,FALSE);
}
void DocbookGenerator::startDotGraph()
{
@@ -1113,7 +1111,7 @@ DB_GEN_C
void DocbookGenerator::endDotGraph(DotClassGraph &g)
{
DB_GEN_C
- g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),m_fileName,relPath,TRUE,FALSE);
+ g.writeGraph(t,GOF_BITMAP,EOF_DocBook,dir(),fileName(),relPath,TRUE,FALSE);
}
void DocbookGenerator::startInclDepGraph()
{
@@ -1122,7 +1120,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), m_fileName,relPath,FALSE);
+ QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,dir(),fileName(),relPath,FALSE);
}
void DocbookGenerator::startCallGraph()
{
@@ -1131,7 +1129,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), m_fileName,relPath,FALSE);
+ QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,dir(),fileName(),relPath,FALSE);
}
void DocbookGenerator::startDirDepGraph()
{
@@ -1140,7 +1138,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), m_fileName,relPath,FALSE);
+ QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,dir(),fileName(),relPath,FALSE);
}
void DocbookGenerator::startMemberDocList()
{
diff --git a/src/docbookgen.h b/src/docbookgen.h
index bed2f5f..0fefe4b 100644
--- a/src/docbookgen.h
+++ b/src/docbookgen.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
-*
+*
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
@@ -15,6 +15,7 @@
#ifndef DOCBOOKGEN_H
#define DOCBOOKGEN_H
+#include "config.h"
#include "outputgen.h"
class DocbookCodeGenerator : public CodeOutputInterface
@@ -57,16 +58,16 @@ class DocbookCodeGenerator : public CodeOutputInterface
private:
FTextStream m_t;
- bool m_streamSet = FALSE;
+ bool m_streamSet = false;
QCString m_refId;
QCString m_external;
int m_lineNumber = -1;
int m_col = 0;
- bool m_insideCodeLine = FALSE;
- bool m_insideSpecialHL = FALSE;
+ bool m_insideCodeLine = false;
+ bool m_insideSpecialHL = false;
QCString m_relPath;
QCString m_sourceFileName;
- bool m_prettyCode = FALSE;
+ bool m_prettyCode = Config_getBool(DOCBOOK_PROGRAMLISTING);
};
@@ -97,20 +98,14 @@ class DocbookGenerator : public OutputGenerator
{
public:
DocbookGenerator();
- ~DocbookGenerator();
+ DocbookGenerator(const DocbookGenerator &o);
+ DocbookGenerator &operator=(const DocbookGenerator &o);
+ virtual ~DocbookGenerator();
+ virtual std::unique_ptr<OutputGenerator> clone() const;
+
static void init();
- ///////////////////////////////////////////////////////////////
- // generic generator methods
- ///////////////////////////////////////////////////////////////
- void enable()
- { 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 && m_active); }
- OutputGenerator *get(OutputType o) { return (o==Docbook) ? this : 0; }
+ OutputType type() const { return Docbook; }
// --- CodeOutputInterface
void codify(const char *text)
@@ -343,21 +338,19 @@ class DocbookGenerator : public OutputGenerator
void addWord(const char *,bool) {DB_GEN_EMPTY}
private:
- DocbookGenerator(const DocbookGenerator &o);
- DocbookGenerator &operator=(const DocbookGenerator &o);
-
+
QCString relPath;
DocbookCodeGenerator m_codeGen;
- bool m_prettyCode;
- bool m_denseText;
- bool m_inGroup;
- bool m_inDetail;
- int m_levelListItem;
- bool m_inListItem[20];
- bool m_inSimpleSect[20];
- bool m_descTable;
- int m_inLevel;
- bool m_firstMember;
+ bool m_prettyCode = Config_getBool(DOCBOOK_PROGRAMLISTING);
+ bool m_denseText = false;
+ bool m_inGroup = false;
+ bool m_inDetail = false;
+ int m_levelListItem = 0;
+ bool m_inListItem[20] = { false, };
+ bool m_inSimpleSect[20] = { false, };
+ bool m_descTable = false;
+ int m_inLevel = -1;
+ bool m_firstMember = false;
};
#endif
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 4b5c267..757e783 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -7586,7 +7586,6 @@ static void generateFileSources()
{
msg("Generating code for file %s...\n",fd->docName().data());
fd->writeSource(*g_outputList,nullptr);
-
}
else if (!fd->isReference() && Doxygen::parseSourcesNeeded)
// we needed to parse the sources even if we do not show them
@@ -11383,10 +11382,10 @@ void generateOutput()
bool generateDocbook = Config_getBool(GENERATE_DOCBOOK);
- g_outputList = new OutputList(TRUE);
+ g_outputList = new OutputList;
if (generateHtml)
{
- g_outputList->add(new HtmlGenerator);
+ g_outputList->add<HtmlGenerator>();
HtmlGenerator::init();
// add HTML indexers that are enabled
@@ -11405,22 +11404,22 @@ void generateOutput()
}
if (generateLatex)
{
- g_outputList->add(new LatexGenerator);
+ g_outputList->add<LatexGenerator>();
LatexGenerator::init();
}
if (generateDocbook)
{
- g_outputList->add(new DocbookGenerator);
+ g_outputList->add<DocbookGenerator>();
DocbookGenerator::init();
}
if (generateMan)
{
- g_outputList->add(new ManGenerator);
+ g_outputList->add<ManGenerator>();
ManGenerator::init();
}
if (generateRtf)
{
- g_outputList->add(new RTFGenerator);
+ g_outputList->add<RTFGenerator>();
RTFGenerator::init();
}
if (Config_getBool(USE_HTAGS))
@@ -11533,7 +11532,7 @@ void generateOutput()
generateDirDocs(*g_outputList);
g_s.end();
- if (g_outputList->count()>0)
+ if (g_outputList->size()>0)
{
writeIndexHierarchy(*g_outputList);
}
diff --git a/src/filedef.cpp b/src/filedef.cpp
index 15fd1e5..f07201d 100644
--- a/src/filedef.cpp
+++ b/src/filedef.cpp
@@ -1151,11 +1151,11 @@ void FileDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *currentM
/*! Write a source listing of this file to the output */
void FileDefImpl::writeSource(OutputList &ol,ClangTUParser *clangParser)
{
- static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
- static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES);
- static bool latexSourceCode = Config_getBool(LATEX_SOURCE_CODE);
- static bool docbookSourceCode = Config_getBool(DOCBOOK_PROGRAMLISTING);
- static bool rtfSourceCode = Config_getBool(RTF_SOURCE_CODE);
+ bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
+ bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES);
+ bool latexSourceCode = Config_getBool(LATEX_SOURCE_CODE);
+ bool docbookSourceCode = Config_getBool(DOCBOOK_PROGRAMLISTING);
+ bool rtfSourceCode = Config_getBool(RTF_SOURCE_CODE);
DevNullCodeDocInterface devNullIntf;
QCString title = m_docname;
if (!m_fileVersion.isEmpty())
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index 7b125af..e4684ef 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -87,7 +87,7 @@ static void writeClientSearchBox(FTextStream &t,const char *relPath)
// part will be rendered inside menu.js
static void writeServerSearchBox(FTextStream &t,const char *relPath,bool highlightSearch)
{
- static bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
+ bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
t << " <div id=\"MSearchBox\" class=\"MSearchBoxInactive\">\n";
t << " <div class=\"left\">\n";
t << " <form id=\"FSearchBox\" action=\"" << relPath;
@@ -422,18 +422,18 @@ static QCString substituteHtmlKeywords(const QCString &str,
QCString mathJaxJs;
QCString extraCssText;
- static QCString projectName = Config_getString(PROJECT_NAME);
- static bool timeStamp = Config_getBool(HTML_TIMESTAMP);
- static bool treeView = Config_getBool(GENERATE_TREEVIEW);
- static bool searchEngine = Config_getBool(SEARCHENGINE);
- static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
- static bool mathJax = Config_getBool(USE_MATHJAX);
- static QCString mathJaxFormat = Config_getEnum(MATHJAX_FORMAT);
- static bool disableIndex = Config_getBool(DISABLE_INDEX);
- static bool hasProjectName = !projectName.isEmpty();
- static bool hasProjectNumber = !Config_getString(PROJECT_NUMBER).isEmpty();
- static bool hasProjectBrief = !Config_getString(PROJECT_BRIEF).isEmpty();
- static bool hasProjectLogo = !Config_getString(PROJECT_LOGO).isEmpty();
+ QCString projectName = Config_getString(PROJECT_NAME);
+ bool timeStamp = Config_getBool(HTML_TIMESTAMP);
+ bool treeView = Config_getBool(GENERATE_TREEVIEW);
+ bool searchEngine = Config_getBool(SEARCHENGINE);
+ bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
+ bool mathJax = Config_getBool(USE_MATHJAX);
+ QCString mathJaxFormat = Config_getEnum(MATHJAX_FORMAT);
+ bool disableIndex = Config_getBool(DISABLE_INDEX);
+ bool hasProjectName = !projectName.isEmpty();
+ bool hasProjectNumber = !Config_getString(PROJECT_NUMBER).isEmpty();
+ bool hasProjectBrief = !Config_getString(PROJECT_BRIEF).isEmpty();
+ bool hasProjectLogo = !Config_getString(PROJECT_LOGO).isEmpty();
static bool titleArea = (hasProjectName || hasProjectBrief || hasProjectLogo || (disableIndex && searchEngine));
cssFile = Config_getString(HTML_STYLESHEET);
@@ -631,7 +631,7 @@ void HtmlCodeGenerator::setRelativePath(const QCString &path)
void HtmlCodeGenerator::codify(const char *str)
{
- static int tabSize = Config_getInt(TAB_SIZE);
+ int tabSize = Config_getInt(TAB_SIZE);
if (str && m_streamSet)
{
const char *p=str;
@@ -910,11 +910,23 @@ void HtmlCodeGenerator::writeCodeAnchor(const char *anchor)
//--------------------------------------------------------------------------
-HtmlGenerator::HtmlGenerator() : OutputGenerator()
+HtmlGenerator::HtmlGenerator() : OutputGenerator(Config_getString(HTML_OUTPUT))
{
- m_dir=Config_getString(HTML_OUTPUT);
- m_emptySection=FALSE;
- m_sectionCount=0;
+}
+
+HtmlGenerator::HtmlGenerator(const HtmlGenerator &og) : OutputGenerator(og)
+{
+}
+
+HtmlGenerator &HtmlGenerator::operator=(const HtmlGenerator &og)
+{
+ OutputGenerator::operator=(og);
+ return *this;
+}
+
+std::unique_ptr<OutputGenerator> HtmlGenerator::clone() const
+{
+ return std::make_unique<HtmlGenerator>(*this);
}
HtmlGenerator::~HtmlGenerator()
@@ -922,9 +934,10 @@ HtmlGenerator::~HtmlGenerator()
//printf("HtmlGenerator::~HtmlGenerator()\n");
}
+
void HtmlGenerator::init()
{
- QCString dname=Config_getString(HTML_OUTPUT);
+ QCString dname = Config_getString(HTML_OUTPUT);
QDir d(dname);
if (!d.exists() && !d.mkdir(dname))
{
@@ -1032,32 +1045,32 @@ void HtmlGenerator::writeTabData()
mgr.copyResource("nav_g.png",dname);
}
-void HtmlGenerator::writeSearchData(const char *dir)
+void HtmlGenerator::writeSearchData(const char *dname)
{
- static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
- //writeImgData(dir,serverBasedSearch ? search_server_data : search_client_data);
+ bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
+ //writeImgData(dname,serverBasedSearch ? search_server_data : search_client_data);
ResourceMgr &mgr = ResourceMgr::instance();
- mgr.copyResource("search_l.png",dir);
+ mgr.copyResource("search_l.png",dname);
Doxygen::indexList->addImageFile("search/search_l.png");
- mgr.copyResource("search_m.png",dir);
+ mgr.copyResource("search_m.png",dname);
Doxygen::indexList->addImageFile("search/search_m.png");
- mgr.copyResource("search_r.png",dir);
+ mgr.copyResource("search_r.png",dname);
Doxygen::indexList->addImageFile("search/search_r.png");
if (serverBasedSearch)
{
- mgr.copyResource("mag.svg",dir);
+ mgr.copyResource("mag.svg",dname);
Doxygen::indexList->addImageFile("search/mag.svg");
}
else
{
- mgr.copyResource("close.svg",dir);
+ mgr.copyResource("close.svg",dname);
Doxygen::indexList->addImageFile("search/close.svg");
- mgr.copyResource("mag_sel.svg",dir);
+ mgr.copyResource("mag_sel.svg",dname);
Doxygen::indexList->addImageFile("search/mag_sel.svg");
}
- QCString searchDirName = Config_getString(HTML_OUTPUT)+"/search";
+ QCString searchDirName = QCString(dname)+"/search";
QFile f(searchDirName+"/search.css");
if (f.open(IO_WriteOnly))
{
@@ -1119,8 +1132,8 @@ void HtmlGenerator::startFile(const char *name,const char *,
t << "<!-- " << theTranslator->trGeneratedBy() << " Doxygen "
<< getDoxygenVersion() << " -->" << endl;
- //static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
- static bool searchEngine = Config_getBool(SEARCHENGINE);
+ //bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
+ bool searchEngine = Config_getBool(SEARCHENGINE);
if (searchEngine /*&& !generateTreeView*/)
{
t << "<script type=\"text/javascript\">\n";
@@ -1136,8 +1149,8 @@ void HtmlGenerator::startFile(const char *name,const char *,
void HtmlGenerator::writeSearchInfo(FTextStream &t,const QCString &)
{
- static bool searchEngine = Config_getBool(SEARCHENGINE);
- static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
+ bool searchEngine = Config_getBool(SEARCHENGINE);
+ bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
if (searchEngine && !serverBasedSearch)
{
t << "<!-- window showing the filter options -->\n";
@@ -1165,7 +1178,7 @@ void HtmlGenerator::writeSearchInfo()
QCString HtmlGenerator::writeLogoAsString(const char *path)
{
- static bool timeStamp = Config_getBool(HTML_TIMESTAMP);
+ bool timeStamp = Config_getBool(HTML_TIMESTAMP);
QCString result;
if (timeStamp)
{
@@ -1409,7 +1422,7 @@ void HtmlGenerator::endTextLink()
void HtmlGenerator::startHtmlLink(const char *url)
{
- static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
+ bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
t << "<a ";
if (generateTreeView) t << "target=\"top\" ";
t << "href=\"";
@@ -1534,7 +1547,7 @@ static void startSectionHeader(FTextStream &t,
const QCString &relPath,int sectionCount)
{
//t << "<!-- startSectionHeader -->";
- static bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
+ bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
if (dynamicSections)
{
t << "<div id=\"dynsection-" << sectionCount << "\" "
@@ -1559,7 +1572,7 @@ static void endSectionHeader(FTextStream &t)
static void startSectionSummary(FTextStream &t,int sectionCount)
{
//t << "<!-- startSectionSummary -->";
- static bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
+ bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
if (dynamicSections)
{
t << "<div id=\"dynsection-" << sectionCount << "-summary\" "
@@ -1571,7 +1584,7 @@ static void startSectionSummary(FTextStream &t,int sectionCount)
static void endSectionSummary(FTextStream &t)
{
//t << "<!-- endSectionSummary -->";
- static bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
+ bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
if (dynamicSections)
{
t << "</div>" << endl;
@@ -1581,7 +1594,7 @@ static void endSectionSummary(FTextStream &t)
static void startSectionContent(FTextStream &t,int sectionCount)
{
//t << "<!-- startSectionContent -->";
- static bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
+ bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
if (dynamicSections)
{
t << "<div id=\"dynsection-" << sectionCount << "-content\" "
@@ -1617,7 +1630,7 @@ void HtmlGenerator::endClassDiagram(const ClassDiagram &d,
startSectionSummary(t,m_sectionCount);
endSectionSummary(t);
startSectionContent(t,m_sectionCount);
- d.writeImage(tt,m_dir,m_relPath,fileName);
+ d.writeImage(tt,dir(),m_relPath,fileName);
if (!result.isEmpty())
{
t << " <div class=\"center\">" << endl;
@@ -2000,7 +2013,7 @@ void HtmlGenerator::endDotGraph(DotClassGraph &g)
endSectionSummary(t);
startSectionContent(t,m_sectionCount);
- g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,TRUE,m_sectionCount);
+ g.writeGraph(t,GOF_BITMAP,EOF_Html,dir(),fileName(),m_relPath,TRUE,TRUE,m_sectionCount);
if (generateLegend && !umlLook)
{
t << "<center><span class=\"legend\">[";
@@ -2026,7 +2039,7 @@ void HtmlGenerator::endInclDepGraph(DotInclDepGraph &g)
endSectionSummary(t);
startSectionContent(t,m_sectionCount);
- g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount);
+ g.writeGraph(t,GOF_BITMAP,EOF_Html,dir(),fileName(),m_relPath,TRUE,m_sectionCount);
endSectionContent(t);
m_sectionCount++;
@@ -2044,7 +2057,7 @@ void HtmlGenerator::endGroupCollaboration(DotGroupCollaboration &g)
endSectionSummary(t);
startSectionContent(t,m_sectionCount);
- g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount);
+ g.writeGraph(t,GOF_BITMAP,EOF_Html,dir(),fileName(),m_relPath,TRUE,m_sectionCount);
endSectionContent(t);
m_sectionCount++;
@@ -2062,7 +2075,7 @@ void HtmlGenerator::endCallGraph(DotCallGraph &g)
endSectionSummary(t);
startSectionContent(t,m_sectionCount);
- g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount);
+ g.writeGraph(t,GOF_BITMAP,EOF_Html,dir(),fileName(),m_relPath,TRUE,m_sectionCount);
endSectionContent(t);
m_sectionCount++;
@@ -2080,7 +2093,7 @@ void HtmlGenerator::endDirDepGraph(DotDirDeps &g)
endSectionSummary(t);
startSectionContent(t,m_sectionCount);
- g.writeGraph(t,GOF_BITMAP,EOF_Html,m_dir,m_fileName,m_relPath,TRUE,m_sectionCount);
+ g.writeGraph(t,GOF_BITMAP,EOF_Html,dir(),fileName(),m_relPath,TRUE,m_sectionCount);
endSectionContent(t);
m_sectionCount++;
@@ -2088,7 +2101,7 @@ void HtmlGenerator::endDirDepGraph(DotDirDeps &g)
void HtmlGenerator::writeGraphicalHierarchy(DotGfxHierarchyTable &g)
{
- g.writeGraph(t,m_dir,m_fileName);
+ g.writeGraph(t,dir(),fileName());
}
void HtmlGenerator::startMemberGroupHeader(bool)
@@ -2275,8 +2288,8 @@ static void endQuickIndexItem(FTextStream &t,const char *l)
static bool quickLinkVisible(LayoutNavEntry::Kind kind)
{
- static bool showFiles = Config_getBool(SHOW_FILES);
- static bool showNamespaces = Config_getBool(SHOW_NAMESPACES);
+ bool showFiles = Config_getBool(SHOW_FILES);
+ bool showNamespaces = Config_getBool(SHOW_NAMESPACES);
switch (kind)
{
case LayoutNavEntry::MainPage: return TRUE;
@@ -2384,8 +2397,8 @@ static void renderQuickLinksAsTabs(FTextStream &t,const QCString &relPath,
}
if (hlEntry->parent()==LayoutDocManager::instance().rootNavEntry()) // first row is special as it contains the search box
{
- static bool searchEngine = Config_getBool(SEARCHENGINE);
- static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
+ bool searchEngine = Config_getBool(SEARCHENGINE);
+ bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
if (searchEngine)
{
t << " <li>\n";
@@ -2422,9 +2435,9 @@ static void writeDefaultQuickLinks(FTextStream &t,bool compact,
const char *file,
const QCString &relPath)
{
- static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
- static bool searchEngine = Config_getBool(SEARCHENGINE);
- static bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
+ bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
+ bool searchEngine = Config_getBool(SEARCHENGINE);
+ bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
LayoutNavEntry *root = LayoutDocManager::instance().rootNavEntry();
LayoutNavEntry::Kind kind = (LayoutNavEntry::Kind)-1;
LayoutNavEntry::Kind altKind = (LayoutNavEntry::Kind)-1; // fall back for the old layout file
@@ -2546,7 +2559,7 @@ void HtmlGenerator::endQuickIndices()
QCString HtmlGenerator::writeSplitBarAsString(const char *name,const char *relpath)
{
- static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
+ bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
QCString result;
// write split bar
if (generateTreeView)
@@ -2613,10 +2626,10 @@ void HtmlGenerator::writeQuickLinks(bool compact,HighlightedItem hli,const char
// PHP based search script
void HtmlGenerator::writeSearchPage()
{
- static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
- static bool disableIndex = Config_getBool(DISABLE_INDEX);
- static QCString projectName = Config_getString(PROJECT_NAME);
- static QCString htmlOutput = Config_getString(HTML_OUTPUT);
+ bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
+ bool disableIndex = Config_getBool(DISABLE_INDEX);
+ QCString projectName = Config_getString(PROJECT_NAME);
+ QCString htmlOutput = Config_getString(HTML_OUTPUT);
// OPENSEARCH_PROVIDER {
QCString configFileName = htmlOutput+"/search_config.php";
@@ -2701,8 +2714,9 @@ void HtmlGenerator::writeSearchPage()
void HtmlGenerator::writeExternalSearchPage()
{
- static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
- QCString fileName = Config_getString(HTML_OUTPUT)+"/search"+Doxygen::htmlFileExtension;
+ bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
+ QCString dname = Config_getString(HTML_OUTPUT);
+ QCString fileName = dname+"/search"+Doxygen::htmlFileExtension;
QFile f(fileName);
if (f.open(IO_WriteOnly))
{
@@ -2752,7 +2766,7 @@ void HtmlGenerator::writeExternalSearchPage()
writePageFooter(t,"Search","","");
}
- QCString scriptName = Config_getString(HTML_OUTPUT)+"/search/search.js";
+ QCString scriptName = dname+"/search/search.js";
QFile sf(scriptName);
if (sf.open(IO_WriteOnly))
{
diff --git a/src/htmlgen.h b/src/htmlgen.h
index a8268da..9487e60 100644
--- a/src/htmlgen.h
+++ b/src/htmlgen.h
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -39,7 +39,7 @@ class HtmlCodeGenerator : public CodeOutputInterface
void writeCodeLink(const char *ref,const char *file,
const char *anchor,const char *name,
const char *tooltip);
- void writeTooltip(const char *id,
+ void writeTooltip(const char *id,
const DocLinkInfo &docInfo,
const char *decl,
const char *desc,
@@ -72,7 +72,12 @@ class HtmlGenerator : public OutputGenerator
{
public:
HtmlGenerator();
+ HtmlGenerator &operator=(const HtmlGenerator &g);
+ HtmlGenerator(const HtmlGenerator &g);
virtual ~HtmlGenerator();
+ virtual std::unique_ptr<OutputGenerator> clone() const;
+
+ virtual OutputType type() const { return Html; }
static void init();
static void writeStyleSheetFile(QFile &f);
static void writeHeaderFile(QFile &f, const char *cssname);
@@ -84,18 +89,9 @@ class HtmlGenerator : public OutputGenerator
static void writeExternalSearchPage();
static QCString writeLogoAsString(const char *path);
static QCString writeSplitBarAsString(const char *name,const char *relpath);
-
- void enable()
- { if (m_genStack->top()) m_active=*m_genStack->top(); else m_active=TRUE; }
- void disable() { m_active=FALSE; }
- void enableIf(OutputType o) { if (o==Html) enable(); }
- void disableIf(OutputType o) { if (o==Html) disable(); }
- void disableIfNot(OutputType o) { if (o!=Html) disable(); }
- bool isEnabled(OutputType o) { return (o==Html && m_active); }
- OutputGenerator *get(OutputType o) { return (o==Html) ? this : 0; }
// ---- CodeOutputInterface
- void codify(const char *text)
+ void codify(const char *text)
{ m_codeGen.codify(text); }
void writeCodeLink(const char *ref,const char *file,
const char *anchor,const char *name,
@@ -111,11 +107,11 @@ class HtmlGenerator : public OutputGenerator
{ m_codeGen.startCodeLine(hasLineNumbers); }
void endCodeLine()
{ m_codeGen.endCodeLine(); }
- void startFontClass(const char *s)
+ void startFontClass(const char *s)
{ m_codeGen.startFontClass(s); }
- void endFontClass()
+ void endFontClass()
{ m_codeGen.endFontClass(); }
- void writeCodeAnchor(const char *anchor)
+ void writeCodeAnchor(const char *anchor)
{ m_codeGen.writeCodeAnchor(anchor); }
// ---------------------------
@@ -139,7 +135,7 @@ class HtmlGenerator : public OutputGenerator
void endTitleHead(const char *,const char *);
void startTitle() { t << "<div class=\"title\">"; }
void endTitle() { t << "</div>"; }
-
+
void startParagraph(const char *classDef);
void endParagraph();
void writeString(const char *text);
@@ -210,7 +206,7 @@ class HtmlGenerator : public OutputGenerator
const char *title,const char *name);
void writeRuler() { t << "<hr/>"; }
- void writeAnchor(const char *,const char *name)
+ void writeAnchor(const char *,const char *name)
{ t << "<a name=\"" << name <<"\" id=\"" << name << "\"></a>"; }
void startCodeFragment();
void endCodeFragment();
@@ -226,10 +222,10 @@ class HtmlGenerator : public OutputGenerator
void endDescForItem() { t << "</dd>\n"; }
void lineBreak(const char *style);
void writeChar(char c);
- void startMemberDoc(const char *clName, const char *memName,
- const char *anchor, const char *title,
+ void startMemberDoc(const char *clName, const char *memName,
+ const char *anchor, const char *title,
int memCount, int memTotal, bool showInline);
- void endMemberDoc(bool);
+ void endMemberDoc(bool);
void startDoxyAnchor(const char *fName,const char *manName,
const char *anchor,const char *name,
const char *args);
@@ -294,9 +290,9 @@ class HtmlGenerator : public OutputGenerator
void endDirDepGraph(DotDirDeps &g);
void writeGraphicalHierarchy(DotGfxHierarchyTable &g);
- void startTextBlock(bool)
+ void startTextBlock(bool)
{ t << "<div class=\"textblock\">"; }
- void endTextBlock(bool)
+ void endTextBlock(bool)
{ t << "</div>"; }
void lastIndexPage() {}
@@ -334,9 +330,6 @@ class HtmlGenerator : public OutputGenerator
void writeLabel(const char *l,bool isLast);
void endLabels();
-
- //static void generateSectionImages();
-
private:
static void writePageFooter(FTextStream &t,const QCString &,const QCString &,const QCString &);
QCString m_lastTitle;
@@ -344,11 +337,8 @@ class HtmlGenerator : public OutputGenerator
QCString m_relPath;
void docify(const char *text,bool inHtmlComment);
- HtmlGenerator &operator=(const HtmlGenerator &g);
- HtmlGenerator(const HtmlGenerator &g);
-
- int m_sectionCount;
- bool m_emptySection;
+ int m_sectionCount = 0;
+ bool m_emptySection = false;
HtmlCodeGenerator m_codeGen;
};
diff --git a/src/latexgen.cpp b/src/latexgen.cpp
index cb42863..5116d3e 100644
--- a/src/latexgen.cpp
+++ b/src/latexgen.cpp
@@ -84,7 +84,7 @@ void LatexCodeGenerator::codify(const char *str)
signed char c;
//char cs[5];
int spacesToNextTabStop;
- static int tabSize = Config_getInt(TAB_SIZE);
+ int tabSize = Config_getInt(TAB_SIZE);
static signed char *result = NULL;
static int lresult = 0;
int i;
@@ -168,8 +168,8 @@ void LatexCodeGenerator::writeCodeLink(const char *ref,const char *f,
const char *anchor,const char *name,
const char *)
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
- static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool usePDFLatex = Config_getBool(USE_PDFLATEX);
int l = qstrlen(name);
if (!ref && usePDFLatex && pdfHyperlinks)
{
@@ -190,8 +190,8 @@ void LatexCodeGenerator::writeCodeLink(const char *ref,const char *f,
void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,const char *anchor,int l)
{
- static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool usePDFLatex = Config_getBool(USE_PDFLATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
if (!DoxyCodeLineOpen)
{
m_t << "\\DoxyCodeLine{";
@@ -265,16 +265,24 @@ void LatexCodeGenerator::setDoxyCodeOpen(bool val)
//-------------------------------
-LatexGenerator::LatexGenerator() : OutputGenerator()
+LatexGenerator::LatexGenerator() : OutputGenerator(Config_getString(LATEX_OUTPUT))
{
- m_dir=Config_getString(LATEX_OUTPUT);
//printf("LatexGenerator::LatexGenerator() m_insideTabbing=FALSE\n");
- m_insideTabbing=FALSE;
- m_firstDescItem=TRUE;
- m_disableLinks=FALSE;
- m_indent=0;
- templateMemberItem = FALSE;
- m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
+}
+
+LatexGenerator::LatexGenerator(const LatexGenerator &og) : OutputGenerator(og)
+{
+}
+
+LatexGenerator &LatexGenerator::operator=(const LatexGenerator &og)
+{
+ OutputGenerator::operator=(og);
+ return *this;
+}
+
+std::unique_ptr<OutputGenerator> LatexGenerator::clone() const
+{
+ return std::make_unique<LatexGenerator>(*this);
}
LatexGenerator::~LatexGenerator()
@@ -284,8 +292,7 @@ LatexGenerator::~LatexGenerator()
static void writeLatexMakefile()
{
bool generateBib = !CitationManager::instance().isEmpty();
- QCString dir=Config_getString(LATEX_OUTPUT);
- QCString fileName=dir+"/Makefile";
+ QCString fileName=Config_getString(LATEX_OUTPUT)+"/Makefile";
QFile file(fileName);
if (!file.open(IO_WriteOnly))
{
@@ -379,8 +386,7 @@ static void writeLatexMakefile()
static void writeMakeBat()
{
#if defined(_MSC_VER)
- QCString dir=Config_getString(LATEX_OUTPUT);
- QCString fileName=dir+"/make.bat";
+ QCString fileName=dir()+"/make.bat";
QCString latex_command = theTranslator->latexCommandName();
QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME);
QFile file(fileName);
@@ -463,12 +469,11 @@ static void writeMakeBat()
void LatexGenerator::init()
{
-
- QCString dir=Config_getString(LATEX_OUTPUT);
- QDir d(dir);
- if (!d.exists() && !d.mkdir(dir))
+ QCString dname = Config_getString(LATEX_OUTPUT);
+ QDir d(dname);
+ if (!d.exists() && !d.mkdir(dname))
{
- term("Could not create output directory %s\n",dir.data());
+ term("Could not create output directory %s\n",dname.data());
}
writeLatexMakefile();
@@ -634,7 +639,7 @@ static void writeDefaultHeaderPart1(FTextStream &t)
// Headers & footers
QGString genString;
QCString generatedBy;
- static bool timeStamp = Config_getBool(LATEX_TIMESTAMP);
+ bool timeStamp = Config_getBool(LATEX_TIMESTAMP);
FTextStream tg(&genString);
if (timeStamp)
{
@@ -698,11 +703,10 @@ static void writeDefaultHeaderPart1(FTextStream &t)
QCString macroFile = Config_getString(FORMULA_MACROFILE);
if (!macroFile.isEmpty())
{
- QCString dir=Config_getString(LATEX_OUTPUT);
QFileInfo fi(macroFile);
macroFile=fi.absFilePath().utf8();
QCString stripMacroFile = fi.fileName().data();
- copyFile(macroFile,dir + "/" + stripMacroFile);
+ copyFile(macroFile,Config_getString(LATEX_OUTPUT) + "/" + stripMacroFile);
t << "\\input{" << stripMacroFile << "}" << endl;
}
@@ -1087,10 +1091,10 @@ void LatexGenerator::startIndexSection(IndexSections is)
void LatexGenerator::endIndexSection(IndexSections is)
{
- //static bool compactLatex = Config_getBool(COMPACT_LATEX);
- static bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
- static QCString latexHeader = Config_getString(LATEX_HEADER);
- static QCString latexFooter = Config_getString(LATEX_FOOTER);
+ //bool compactLatex = Config_getBool(COMPACT_LATEX);
+ bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
+ QCString latexHeader = Config_getString(LATEX_HEADER);
+ QCString latexFooter = Config_getString(LATEX_FOOTER);
switch (is)
{
case isTitlePageStart:
@@ -1476,7 +1480,7 @@ void LatexGenerator::endIndexValue(const char *name,bool /*hasBrief*/)
void LatexGenerator::startTextLink(const char *f,const char *anchor)
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
if (!m_disableLinks && pdfHyperlinks)
{
t << "\\mbox{\\hyperlink{";
@@ -1492,7 +1496,7 @@ void LatexGenerator::startTextLink(const char *f,const char *anchor)
void LatexGenerator::endTextLink()
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
if (!m_disableLinks && pdfHyperlinks)
{
t << "}";
@@ -1503,7 +1507,7 @@ void LatexGenerator::endTextLink()
void LatexGenerator::writeObjectLink(const char *ref, const char *f,
const char *anchor, const char *text)
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
if (!m_disableLinks && !ref && pdfHyperlinks)
{
t << "\\mbox{\\hyperlink{";
@@ -1538,8 +1542,8 @@ void LatexGenerator::endPageRef(const char *clname, const char *anchor)
void LatexGenerator::startTitleHead(const char *fileName)
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
- static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool usePDFLatex = Config_getBool(USE_PDFLATEX);
if (usePDFLatex && pdfHyperlinks && fileName)
{
t << "\\hypertarget{" << stripPath(fileName) << "}{}";
@@ -1669,8 +1673,8 @@ void LatexGenerator::startMemberDoc(const char *clname,
t << "}" << endl;
}
static const char *levelLab[] = { "doxysubsubsection","doxyparagraph","doxysubparagraph", "doxysubparagraph" };
- static bool compactLatex = Config_getBool(COMPACT_LATEX);
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool compactLatex = Config_getBool(COMPACT_LATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
int level=0;
if (showInline) level+=2;
if (compactLatex) level++;
@@ -1706,8 +1710,8 @@ void LatexGenerator::startDoxyAnchor(const char *fName,const char *,
const char *anchor, const char *,
const char *)
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
- static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool usePDFLatex = Config_getBool(USE_PDFLATEX);
t << "\\mbox{";
if (usePDFLatex && pdfHyperlinks)
{
@@ -1730,8 +1734,8 @@ void LatexGenerator::writeAnchor(const char *fName,const char *name)
{
//printf("LatexGenerator::writeAnchor(%s,%s)\n",fName,name);
t << "\\label{" << stripPath(name) << "}" << endl;
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
- static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool usePDFLatex = Config_getBool(USE_PDFLATEX);
if (usePDFLatex && pdfHyperlinks)
{
if (fName)
@@ -1775,8 +1779,8 @@ void LatexGenerator::addIndexItem(const char *s1,const char *s2)
void LatexGenerator::startSection(const char *lab,const char *,SectionType type)
{
- static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
- static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
+ bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
+ bool usePDFLatex = Config_getBool(USE_PDFLATEX);
if (usePDFLatex && pdfHyperlinks)
{
t << "\\hypertarget{" << stripPath(lab) << "}{}";
@@ -1838,7 +1842,7 @@ void LatexGenerator::startClassDiagram()
void LatexGenerator::endClassDiagram(const ClassDiagram &d,
const char *fileName,const char *)
{
- d.writeFigure(t,m_dir,fileName);
+ d.writeFigure(t,dir(),fileName);
}
@@ -2067,7 +2071,7 @@ void LatexGenerator::startDotGraph()
void LatexGenerator::endDotGraph(DotClassGraph &g)
{
- g.writeGraph(t,GOF_EPS,EOF_LaTeX,Config_getString(LATEX_OUTPUT),m_fileName,m_relPath);
+ g.writeGraph(t,GOF_EPS,EOF_LaTeX,dir(),fileName(),m_relPath);
}
void LatexGenerator::startInclDepGraph()
@@ -2076,7 +2080,7 @@ void LatexGenerator::startInclDepGraph()
void LatexGenerator::endInclDepGraph(DotInclDepGraph &g)
{
- g.writeGraph(t,GOF_EPS,EOF_LaTeX,Config_getString(LATEX_OUTPUT),m_fileName,m_relPath);
+ g.writeGraph(t,GOF_EPS,EOF_LaTeX,dir(),fileName(),m_relPath);
}
void LatexGenerator::startGroupCollaboration()
@@ -2085,7 +2089,7 @@ void LatexGenerator::startGroupCollaboration()
void LatexGenerator::endGroupCollaboration(DotGroupCollaboration &g)
{
- g.writeGraph(t,GOF_EPS,EOF_LaTeX,Config_getString(LATEX_OUTPUT),m_fileName,m_relPath);
+ g.writeGraph(t,GOF_EPS,EOF_LaTeX,dir(),fileName(),m_relPath);
}
void LatexGenerator::startCallGraph()
@@ -2094,7 +2098,7 @@ void LatexGenerator::startCallGraph()
void LatexGenerator::endCallGraph(DotCallGraph &g)
{
- g.writeGraph(t,GOF_EPS,EOF_LaTeX,Config_getString(LATEX_OUTPUT),m_fileName,m_relPath);
+ g.writeGraph(t,GOF_EPS,EOF_LaTeX,dir(),fileName(),m_relPath);
}
void LatexGenerator::startDirDepGraph()
@@ -2103,7 +2107,7 @@ void LatexGenerator::startDirDepGraph()
void LatexGenerator::endDirDepGraph(DotDirDeps &g)
{
- g.writeGraph(t,GOF_EPS,EOF_LaTeX,Config_getString(LATEX_OUTPUT),m_fileName,m_relPath);
+ g.writeGraph(t,GOF_EPS,EOF_LaTeX,dir(),fileName(),m_relPath);
}
void LatexGenerator::startDescription()
diff --git a/src/latexgen.h b/src/latexgen.h
index 2c32388..12b34d8 100644
--- a/src/latexgen.h
+++ b/src/latexgen.h
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -18,6 +18,7 @@
#ifndef LATEXGEN_H
#define LATEXGEN_H
+#include "config.h"
#include "outputgen.h"
class QFile;
@@ -72,23 +73,17 @@ class LatexGenerator : public OutputGenerator
{
public:
LatexGenerator();
- ~LatexGenerator();
+ LatexGenerator(const LatexGenerator &);
+ LatexGenerator &operator=(const LatexGenerator &);
+ virtual ~LatexGenerator();
+ virtual std::unique_ptr<OutputGenerator> clone() const;
+
static void init();
static void writeStyleSheetFile(QFile &f);
static void writeHeaderFile(QFile &f);
static void writeFooterFile(QFile &f);
- //OutputGenerator *copy();
- //OutputGenerator *clone() { return new LatexGenerator(*this); }
- //void append(const OutputGenerator *o);
- void enable()
- { if (m_genStack->top()) m_active=*m_genStack->top(); else m_active=TRUE; }
- void disable() { m_active=FALSE; }
- void enableIf(OutputType o) { if (o==Latex) enable(); }
- void disableIf(OutputType o) { if (o==Latex) disable(); }
- void disableIfNot(OutputType o) { if (o!=Latex) disable(); }
- bool isEnabled(OutputType o) { return (o==Latex && m_active); }
- OutputGenerator *get(OutputType o) { return (o==Latex) ? this : 0; }
+ virtual OutputType type() const { return Latex; }
// --- CodeOutputInterface
void codify(const char *text)
@@ -123,7 +118,7 @@ class LatexGenerator : public OutputGenerator
void writeFooter(const char *) {}
void endFile();
void clearBuffer();
-
+
void startIndexSection(IndexSections);
void endIndexSection(IndexSections);
void writePageLink(const char *,bool);
@@ -167,7 +162,7 @@ class LatexGenerator : public OutputGenerator
void endItemListItem() {}
void startMemberSections() {}
- void endMemberSections() {}
+ void endMemberSections() {}
void startHeaderSection() {}
void endHeaderSection() {}
void startMemberHeader(const char *,int);
@@ -193,7 +188,7 @@ class LatexGenerator : public OutputGenerator
void endMemberGroupDocs();
void startMemberGroup();
void endMemberGroup(bool);
-
+
void insertMemberAlign(bool) {}
void insertMemberAlignLeft(int,bool){}
@@ -216,7 +211,7 @@ class LatexGenerator : public OutputGenerator
void endDoxyAnchor(const char *,const char *);
void writeChar(char c);
void writeLatexSpacing() { t << "\\hspace{0.3cm}"; }
- void writeStartAnnoItem(const char *type,const char *file,
+ void writeStartAnnoItem(const char *type,const char *file,
const char *path,const char *name);
void writeEndAnnoItem(const char *name);
void startSubsection() { t << "\\subsection*{"; }
@@ -229,7 +224,7 @@ class LatexGenerator : public OutputGenerator
void endSmall() { t << "\\normalsize "; }
void startMemberDescription(const char *,const char *,bool);
void endMemberDescription();
- void startMemberDeclaration() {}
+ void startMemberDeclaration() {}
void endMemberDeclaration(const char *,const char *) {}
void writeInheritedSectionTitle(const char *,const char *,const char *,
const char *,const char *,const char *) {}
@@ -326,15 +321,13 @@ class LatexGenerator : public OutputGenerator
private:
- LatexGenerator(const LatexGenerator &);
- LatexGenerator &operator=(const LatexGenerator &);
- bool m_insideTabbing;
- bool m_firstDescItem;
- bool m_disableLinks;
+ bool m_insideTabbing = false;
+ bool m_firstDescItem = true;
+ bool m_disableLinks = false;
QCString m_relPath;
- int m_indent;
- bool templateMemberItem;
- bool m_prettyCode;
+ int m_indent = 0;
+ bool templateMemberItem = false;
+ bool m_prettyCode = Config_getBool(LATEX_SOURCE_CODE);
LatexCodeGenerator m_codeGen;
};
diff --git a/src/mangen.cpp b/src/mangen.cpp
index 1faa296..8574018 100644
--- a/src/mangen.cpp
+++ b/src/mangen.cpp
@@ -74,15 +74,23 @@ static QCString getSubdir()
return dir;
}
-ManGenerator::ManGenerator() : OutputGenerator()
+ManGenerator::ManGenerator() : OutputGenerator(Config_getString(MAN_OUTPUT)+"/"+getSubdir())
{
- m_dir=Config_getString(MAN_OUTPUT) + "/" + getSubdir();
- m_firstCol=TRUE;
- m_paragraph=TRUE;
- m_col=0;
- m_upperCase=FALSE;
- m_insideTabbing=FALSE;
- m_inHeader=FALSE;
+}
+
+ManGenerator::ManGenerator(const ManGenerator &og) : OutputGenerator(og)
+{
+}
+
+ManGenerator &ManGenerator::operator=(const ManGenerator &og)
+{
+ OutputGenerator::operator=(og);
+ return *this;
+}
+
+std::unique_ptr<OutputGenerator> ManGenerator::clone() const
+{
+ return std::make_unique<ManGenerator>(*this);
}
ManGenerator::~ManGenerator()
@@ -428,7 +436,7 @@ void ManGenerator::startDoxyAnchor(const char *,const char *manName,
// name,baseName.data(),buildFileName(baseName).data());
// - remove dangerous characters and append suffix, then add dir prefix
- QCString fileName=m_dir+"/"+buildFileName( baseName );
+ QCString fileName=dir()+"/"+buildFileName( baseName );
QFile linkfile( fileName );
// - only create file if it doesn't exist already
if ( !linkfile.open( IO_ReadOnly ) )
diff --git a/src/mangen.h b/src/mangen.h
index a3a2a33..9bcdb18 100644
--- a/src/mangen.h
+++ b/src/mangen.h
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -27,19 +27,12 @@ class ManGenerator : public OutputGenerator
{
public:
ManGenerator();
- ~ManGenerator();
-
- //OutputGenerator *copy() { return new ManGenerator; }
- //OutputGenerator *clone() { return new ManGenerator(*this); }
- //void append(const OutputGenerator *o);
- void enable()
- { if (m_genStack->top()) m_active=*m_genStack->top(); else m_active=TRUE; }
- void disable() { m_active=FALSE; }
- void enableIf(OutputType o) { if (o==Man) enable(); }
- void disableIf(OutputType o) { if (o==Man) disable(); }
- void disableIfNot(OutputType o) { if (o!=Man) disable(); }
- bool isEnabled(OutputType o) { return (o==Man && m_active); }
- OutputGenerator *get(OutputType o) { return (o==Man) ? this : 0; }
+ ManGenerator(const ManGenerator &g);
+ ManGenerator &operator=(const ManGenerator &g);
+ virtual ~ManGenerator();
+ virtual std::unique_ptr<OutputGenerator> clone() const;
+
+ OutputType type() const { return Man; }
void writeDoc(DocNode *,const Definition *,const MemberDef *);
@@ -60,7 +53,7 @@ class ManGenerator : public OutputGenerator
void endTitleHead(const char *,const char *);
void startTitle();
void endTitle();
-
+
void newParagraph();
void startParagraph(const char *classDef);
void endParagraph();
@@ -68,11 +61,11 @@ class ManGenerator : public OutputGenerator
void startIndexListItem() {}
void endIndexListItem() {}
void startIndexList() {}
- void endIndexList() { newParagraph(); }
+ void endIndexList() { newParagraph(); }
void startIndexKey() {}
- void endIndexKey() {}
+ void endIndexKey() {}
void startIndexValue(bool) {}
- void endIndexValue(const char *,bool) {}
+ void endIndexValue(const char *,bool) {}
void startItemList() {}
void endItemList() { newParagraph(); }
void startIndexItem(const char *ref,const char *file);
@@ -163,7 +156,7 @@ class ManGenerator : public OutputGenerator
void endSmall() {}
void startMemberDescription(const char *,const char *,bool) { t << "\n.RI \""; m_firstCol=FALSE; }
void endMemberDescription() { t << "\""; m_firstCol=FALSE; }
- void startMemberDeclaration() {}
+ void startMemberDeclaration() {}
void endMemberDeclaration(const char *,const char *) {}
void writeInheritedSectionTitle(const char *,const char *,const char *,
const char *,const char *,const char *) {}
@@ -196,7 +189,7 @@ class ManGenerator : public OutputGenerator
void startContents() {}
void endContents() {}
void writeNonBreakableSpace(int n) { int i; for (i=0;i<n;i++) t << " "; }
-
+
void startDescTable(const char *t);
void endDescTable();
void startDescTableRow() {}
@@ -214,7 +207,7 @@ class ManGenerator : public OutputGenerator
void endGroupCollaboration(DotGroupCollaboration &) {}
void startCallGraph() {}
void endCallGraph(DotCallGraph &) {}
- void startDirDepGraph() {}
+ void startDirDepGraph() {}
void endDirDepGraph(DotDirDeps &) {}
void writeGraphicalHierarchy(DotGfxHierarchyTable &) {}
@@ -264,15 +257,13 @@ class ManGenerator : public OutputGenerator
void addWord(const char *,bool) {}
private:
- bool m_firstCol;
- bool m_paragraph;
- int m_col;
- bool m_upperCase;
- bool m_insideTabbing;
- bool m_inHeader;
+ bool m_firstCol = true;
+ bool m_paragraph = true;
+ int m_col = 0;
+ bool m_upperCase = false;
+ bool m_insideTabbing = false;
+ bool m_inHeader = false;
- ManGenerator(const ManGenerator &g);
- ManGenerator &operator=(const ManGenerator &g);
};
#endif
diff --git a/src/outputgen.cpp b/src/outputgen.cpp
index b9f24fa..2c3bf46 100644
--- a/src/outputgen.cpp
+++ b/src/outputgen.cpp
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -15,6 +15,8 @@
*
*/
+#include <stdexcept>
+
#include <stdlib.h>
#include <qfile.h>
@@ -23,55 +25,124 @@
#include "message.h"
#include "portable.h"
-OutputGenerator::OutputGenerator()
+OutputGenerator::OutputGenerator(const char *dir) : m_dir(dir)
{
//printf("OutputGenerator::OutputGenerator()\n");
- m_file=0;
- m_active=TRUE;
- m_genStack = new QStack<bool>;
- m_genStack->setAutoDelete(TRUE);
}
OutputGenerator::~OutputGenerator()
{
//printf("OutputGenerator::~OutputGenerator()\n");
- delete m_file;
- delete m_genStack;
+}
+
+OutputGenerator::OutputGenerator(const OutputGenerator &og)
+{
+ m_dir = og.m_dir;
+ // we don't copy the other fields.
+ // after copying startPlainFile() should be called
+ if (og.t.device()!=nullptr)
+ {
+ throw std::runtime_error("OutputGenerator copy constructor called while a file is processing");
+ }
+}
+
+OutputGenerator &OutputGenerator::operator=(const OutputGenerator &og)
+{
+ m_dir = og.m_dir;
+ // we don't copy the other fields.
+ // after assignment startPlainFile() should be called
+ if (og.t.device()!=nullptr)
+ {
+ throw std::runtime_error("OutputGenerator assignment operator called while a file is processing");
+ }
+ return *this;
}
void OutputGenerator::startPlainFile(const char *name)
{
//printf("startPlainFile(%s)\n",name);
m_fileName=m_dir+"/"+name;
- m_file = new QFile(m_fileName);
- if (!m_file->open(IO_WriteOnly))
+ m_file.setName(m_fileName);
+ if (!m_file.open(IO_WriteOnly))
{
term("Could not open file %s for writing\n",m_fileName.data());
}
- t.setDevice(m_file);
+ t.setDevice(&m_file);
}
void OutputGenerator::endPlainFile()
{
t.unsetDevice();
- delete m_file;
- m_file=0;
+ m_file.close();
m_fileName.resize(0);
}
+QCString OutputGenerator::dir() const
+{
+ return m_dir;
+}
+
+QCString OutputGenerator::fileName() const
+{
+ return m_fileName;
+}
+
void OutputGenerator::pushGeneratorState()
{
- m_genStack->push(new bool(isEnabled()));
+ m_genStack.push(isEnabled());
//printf("%p:pushGeneratorState(%d) enabled=%d\n",this,genStack->count(),isEnabled());
}
void OutputGenerator::popGeneratorState()
{
//printf("%p:popGeneratorState(%d) enabled=%d\n",this,genStack->count(),isEnabled());
- bool *lb = m_genStack->pop();
- ASSERT(lb!=0);
- if (lb==0) return; // for some robustness against superfluous \endhtmlonly commands.
- if (*lb) enable(); else disable();
- delete lb;
+ if (!m_genStack.empty())
+ {
+ bool lb = m_genStack.top();
+ m_genStack.pop();
+ if (lb) enable(); else disable();
+ }
+}
+
+void OutputGenerator::enable()
+{
+ if (!m_genStack.empty())
+ {
+ m_active=m_genStack.top();
+ }
+ else
+ {
+ m_active=true;
+ }
+}
+
+void OutputGenerator::disable()
+{
+ m_active=false;
+}
+
+void OutputGenerator::enableIf(OutputGenerator::OutputType o)
+{
+ if (o==type()) enable();
+}
+
+void OutputGenerator::disableIf(OutputGenerator::OutputType o)
+{
+ if (o==type()) disable();
+}
+
+void OutputGenerator::disableIfNot(OutputGenerator::OutputType o)
+{
+ if (o!=type()) disable();
+}
+
+bool OutputGenerator::isEnabled(OutputGenerator::OutputType o)
+{
+ return (o==type() && m_active);
+}
+
+OutputGenerator *OutputGenerator::get(OutputGenerator::OutputType o)
+{
+ return (o==type()) ? this : 0;
}
diff --git a/src/outputgen.h b/src/outputgen.h
index 009225f..4bfed25 100644
--- a/src/outputgen.h
+++ b/src/outputgen.h
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -18,7 +18,10 @@
#ifndef OUTPUTGEN_H
#define OUTPUTGEN_H
-#include <qstack.h>
+#include <memory>
+#include <stack>
+
+#include <qfile.h>
#include "index.h"
#include "section.h"
@@ -33,9 +36,7 @@ class DotGfxHierarchyTable;
class DotGroupCollaboration;
class DocNode;
class MemberDef;
-class GroupDef;
class Definition;
-class QFile;
struct DocLinkInfo
{
@@ -54,15 +55,15 @@ struct SourceLinkInfo
QCString anchor;
};
-/** Output interface for code parser.
+/** Output interface for code parser.
*/
class CodeOutputInterface
{
public:
virtual ~CodeOutputInterface() {}
- /*! Writes an code fragment to the output. This function should keep
- * spaces visible, should break lines at a newline and should convert
+ /*! Writes an code fragment to the output. This function should keep
+ * spaces visible, should break lines at a newline and should convert
* tabs to the right number of spaces.
*/
virtual void codify(const char *s) = 0;
@@ -71,8 +72,8 @@ class CodeOutputInterface
* \param ref If this is non-zero, the object is to be found in
* an external documentation file.
* \param file The file in which the object is located.
- * \param anchor The anchor uniquely identifying the object within
- * the file.
+ * \param anchor The anchor uniquely identifying the object within
+ * the file.
* \param name The text to display as a placeholder for the link.
* \param tooltip The tooltip to display when the mouse is on the link.
*/
@@ -89,7 +90,7 @@ class CodeOutputInterface
virtual void writeLineNumber(const char *ref,const char *file,
const char *anchor,int lineNumber) = 0;
- /*! Writes a tool tip definition
+ /*! Writes a tool tip definition
* \param id unique identifier for the tooltip
* \param docInfo Info about the symbol's documentation.
* \param decl full declaration of the symbol (for functions)
@@ -97,14 +98,14 @@ class CodeOutputInterface
* \param defInfo Info about the symbol's definition in the source code
* \param declInfo Info about the symbol's declaration in the source code
*/
- virtual void writeTooltip(const char *id,
+ virtual void writeTooltip(const char *id,
const DocLinkInfo &docInfo,
const char *decl,
const char *desc,
const SourceLinkInfo &defInfo,
const SourceLinkInfo &declInfo
) = 0;
-
+
virtual void startCodeLine(bool hasLineNumbers) = 0;
/*! Ends a line of code started with startCodeLine() */
@@ -141,29 +142,29 @@ class BaseOutputDocInterface : public CodeOutputInterface
public:
virtual ~BaseOutputDocInterface() {}
enum ParamListTypes { Param, RetVal, Exception };
- enum SectionTypes { /*See, Return, Author, Version,
+ enum SectionTypes { /*See, Return, Author, Version,
Since, Date, Bug, Note,
- Warning, Par, Deprecated, Pre,
- Post, Invar, Remark, Attention,
+ Warning, Par, Deprecated, Pre,
+ Post, Invar, Remark, Attention,
Todo, Test, RCS, */
- EnumValues,
- Examples
+ EnumValues,
+ Examples
};
virtual void parseText(const QCString &) {}
-
+
/*! Start of a bullet list: e.g. \c \<ul\> in html. startItemListItem() is
* Used for the bullet items.
*/
virtual void startItemList() = 0;
- /*! Writes a list item for a bullet or enumerated
- * list: e.g. \c \<li\> in html
+ /*! Writes a list item for a bullet or enumerated
+ * list: e.g. \c \<li\> in html
*/
virtual void startItemListItem() = 0;
- /*! Writes a list item for a bullet or enumerated
- * list: e.g. \c \</li\> in html
+ /*! Writes a list item for a bullet or enumerated
+ * list: e.g. \c \</li\> in html
*/
virtual void endItemListItem() = 0;
@@ -171,7 +172,7 @@ class BaseOutputDocInterface : public CodeOutputInterface
virtual void endItemList() = 0;
/*! Writes an ASCII string to the output. Converts characters that have
- * A special meaning, like \c & in html.
+ * A special meaning, like \c & in html.
*/
virtual void docify(const char *s) = 0;
@@ -180,8 +181,8 @@ class BaseOutputDocInterface : public CodeOutputInterface
*/
virtual void writeChar(char c) = 0;
- /*! Writes an ASCII string to the output, \e without converting
- * special characters.
+ /*! Writes an ASCII string to the output, \e without converting
+ * special characters.
*/
virtual void writeString(const char *text) = 0;
@@ -197,8 +198,8 @@ class BaseOutputDocInterface : public CodeOutputInterface
* \param ref If this is non-zero, the object is to be found in
* an external documentation file.
* \param file The file in which the object is located.
- * \param anchor The anchor uniquely identifying the object within
- * the file.
+ * \param anchor The anchor uniquely identifying the object within
+ * the file.
* \param name The text to display as a placeholder for the link.
*/
virtual void writeObjectLink(const char *ref,const char *file,
@@ -214,7 +215,7 @@ class BaseOutputDocInterface : public CodeOutputInterface
*/
virtual void endHtmlLink() = 0;
-
+
/*! Changes the text font to bold face. The bold section ends with
* endBold()
*/
@@ -250,13 +251,13 @@ class BaseOutputDocInterface : public CodeOutputInterface
*/
virtual void endCodeFragment() = 0;
-
-
+
+
/*! Writes a horizontal ruler to the output */
virtual void writeRuler() = 0;
-
- /*! Starts a description list: e.g. \c \<dl\> in HTML
+
+ /*! Starts a description list: e.g. \c \<dl\> in HTML
* Items are surrounded by startDescItem() and endDescItem()
*/
virtual void startDescription() = 0;
@@ -270,8 +271,8 @@ class BaseOutputDocInterface : public CodeOutputInterface
virtual void startDescForItem() = 0;
virtual void endDescForItem() = 0;
- /*! Ends an item of a description list and starts the
- * description itself: e.g. \c \</dt\> in HTML.
+ /*! Ends an item of a description list and starts the
+ * description itself: e.g. \c \</dt\> in HTML.
*/
virtual void endDescItem() = 0;
@@ -324,19 +325,27 @@ class OutputGenerator : public BaseOutputDocInterface
public:
enum OutputType { Html, Latex, Man, RTF, XML, DEF, Perl , Docbook};
- OutputGenerator();
+ OutputGenerator(const char *dir);
+ OutputGenerator(const OutputGenerator &o);
+ OutputGenerator &operator=(const OutputGenerator &o);
virtual ~OutputGenerator();
+ virtual OutputType type() const = 0;
+ virtual std::unique_ptr<OutputGenerator> clone() const = 0;
+
///////////////////////////////////////////////////////////////
// generic generator methods
///////////////////////////////////////////////////////////////
- virtual void enable() = 0;
- virtual void disable() = 0;
- virtual void enableIf(OutputType o) = 0;
- virtual void disableIf(OutputType o) = 0;
- virtual void disableIfNot(OutputType o) = 0;
- virtual bool isEnabled(OutputType o) = 0;
- virtual OutputGenerator *get(OutputType o) = 0;
+ void enable();
+ void disable();
+ void enableIf(OutputType o);
+ void disableIf(OutputType o);
+ void disableIfNot(OutputType o);
+ bool isEnabled(OutputType o);
+ OutputGenerator *get(OutputType o);
+ QCString dir() const;
+ QCString fileName() const;
+
void startPlainFile(const char *name);
void endPlainFile();
//QCString getContents() const;
@@ -489,21 +498,18 @@ class OutputGenerator : public BaseOutputDocInterface
protected:
FTextStream t;
- QFile *m_file;
- QCString m_fileName;
- QCString m_dir;
- bool m_active;
- QStack<bool> *m_genStack;
-
private:
- OutputGenerator(const OutputGenerator &o);
- OutputGenerator &operator=(const OutputGenerator &o);
+ QCString m_dir;
+ QCString m_fileName;
+ QFile m_file;
+ bool m_active = true;
+ std::stack<bool> m_genStack;
};
/** Interface used for generating documentation.
*
* This abstract class is used by several functions
- * to generate the output for a specific format.
+ * to generate the output for a specific format.
* This interface contains some state saving and changing
* functions for dealing with format specific output.
*/
@@ -512,18 +518,13 @@ class OutputDocInterface : public BaseOutputDocInterface
public:
virtual ~OutputDocInterface() {}
- /*! Create a new output generator. This can later by appended
- * to the current one using append().
- */
- //virtual OutputDocInterface *clone() = 0;
-
- /*! Disables all output formats except format \a o
- * (useful for OutputList only)
+ /*! Disables all output formats except format \a o
+ * (useful for OutputList only)
*/
virtual void disableAllBut(OutputGenerator::OutputType o) = 0;
/*! Enables all output formats as far as they have been enabled in
- * the config file. (useful for OutputList only)
+ * the config file. (useful for OutputList only)
*/
virtual void enableAll() = 0;
@@ -536,27 +537,26 @@ class OutputDocInterface : public BaseOutputDocInterface
/*! Enables a specific output format (useful for OutputList only) */
virtual void enable(OutputGenerator::OutputType o) = 0;
- /*! Check whether a specific output format is currently enabled
- * (useful for OutputList only)
+ /*! Check whether a specific output format is currently enabled
+ * (useful for OutputList only)
*/
virtual bool isEnabled(OutputGenerator::OutputType o) = 0;
/*! Appends the output generated by generator \a g to this
* generator.
- */
+ */
//virtual void append(const OutputDocInterface *g) = 0;
- /*! Pushes the state of the current generator (or list of
+ /*! Pushes the state of the current generator (or list of
* generators) on a stack.
*/
virtual void pushGeneratorState() = 0;
- /*! Pops the state of the current generator (or list of
+ /*! Pops the state of the current generator (or list of
* generators) on a stack. Should be preceded by a call
* the pushGeneratorState().
*/
virtual void popGeneratorState() = 0;
};
-
#endif
diff --git a/src/outputlist.cpp b/src/outputlist.cpp
index e942465..3e05dac 100644
--- a/src/outputlist.cpp
+++ b/src/outputlist.cpp
@@ -30,19 +30,35 @@
#include "docparser.h"
#include "vhdldocgen.h"
-OutputList::OutputList(bool)
+
+OutputList::OutputList()
{
//printf("OutputList::OutputList()\n");
}
-OutputList::~OutputList()
+OutputList::OutputList(const OutputList &ol)
{
- //printf("OutputList::~OutputList()\n");
+ for (const auto &og : ol.m_outputs)
+ {
+ m_outputs.emplace_back(og->clone());
+ }
+}
+
+OutputList &OutputList::operator=(const OutputList &ol)
+{
+ if (this!=&ol)
+ {
+ for (const auto &og : ol.m_outputs)
+ {
+ m_outputs.emplace_back(og->clone());
+ }
+ }
+ return *this;
}
-void OutputList::add(OutputGenerator *og)
+OutputList::~OutputList()
{
- if (og) m_outputs.emplace_back(og);
+ //printf("OutputList::~OutputList()\n");
}
void OutputList::disableAllBut(OutputGenerator::OutputType o)
diff --git a/src/outputlist.h b/src/outputlist.h
index 9393a59..003e508 100644
--- a/src/outputlist.h
+++ b/src/outputlist.h
@@ -37,11 +37,18 @@ class DocRoot;
class OutputList : public OutputDocInterface
{
public:
- OutputList(bool);
+ OutputList();
+ OutputList(const OutputList &ol);
+ OutputList &operator=(const OutputList &ol);
virtual ~OutputList();
- void add(OutputGenerator *);
- uint count() const { return static_cast<uint>(m_outputs.size()); }
+ template<class Generator>
+ void add()
+ {
+ m_outputs.emplace_back(std::make_unique<Generator>());
+ }
+
+ size_t size() const { return m_outputs.size(); }
void disableAllBut(OutputGenerator::OutputType o);
void enableAll();
@@ -493,8 +500,8 @@ class OutputList : public OutputDocInterface
}
}
- OutputList(const OutputList &ol);
std::vector< std::unique_ptr<OutputGenerator> > m_outputs;
+
};
#endif
diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp
index 9d0a957..dff4cdd 100644
--- a/src/rtfgen.cpp
+++ b/src/rtfgen.cpp
@@ -63,16 +63,23 @@ static QCString dateToRTFDateString()
return result;
}
-RTFGenerator::RTFGenerator() : OutputGenerator()
+RTFGenerator::RTFGenerator() : OutputGenerator(Config_getString(RTF_OUTPUT))
{
- m_dir=Config_getString(RTF_OUTPUT);
- m_col=0;
- //insideTabbing=FALSE;
- m_listLevel = 0;
- m_bstartedBody = FALSE;
- m_omitParagraph = FALSE;
- m_numCols = 0;
- m_prettyCode=Config_getBool(RTF_SOURCE_CODE);
+}
+
+RTFGenerator::RTFGenerator(const RTFGenerator &og) : OutputGenerator(og)
+{
+}
+
+RTFGenerator &RTFGenerator::operator=(const RTFGenerator &og)
+{
+ OutputGenerator::operator=(og);
+ return *this;
+}
+
+std::unique_ptr<OutputGenerator> RTFGenerator::clone() const
+{
+ return std::make_unique<RTFGenerator>(*this);
}
RTFGenerator::~RTFGenerator()
@@ -577,8 +584,8 @@ void RTFGenerator::endIndexSection(IndexSections is)
{
bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN);
bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
- static bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
- static QCString projectName = Config_getString(PROJECT_NAME);
+ bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
+ QCString projectName = Config_getString(PROJECT_NAME);
switch (is)
{
@@ -1872,7 +1879,7 @@ void RTFGenerator::endClassDiagram(const ClassDiagram &d,
newParagraph();
// create a png file
- d.writeImage(t,m_dir,m_relPath,fileName,FALSE);
+ d.writeImage(t,dir(),m_relPath,fileName,FALSE);
// display the file
t << "{" << endl;
@@ -2500,7 +2507,7 @@ void RTFGenerator::endDotGraph(DotClassGraph &g)
newParagraph();
QCString fn =
- g.writeGraph(t,GOF_BITMAP,EOF_Rtf,Config_getString(RTF_OUTPUT),m_fileName,m_relPath,TRUE,FALSE);
+ g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,TRUE,FALSE);
// display the file
t << "{" << endl;
@@ -2523,8 +2530,7 @@ void RTFGenerator::endInclDepGraph(DotInclDepGraph &g)
{
newParagraph();
- QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,Config_getString(RTF_OUTPUT),
- m_fileName,m_relPath,FALSE);
+ QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,FALSE);
// display the file
t << "{" << endl;
@@ -2554,8 +2560,7 @@ void RTFGenerator::endCallGraph(DotCallGraph &g)
{
newParagraph();
- QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,Config_getString(RTF_OUTPUT),
- m_fileName,m_relPath,FALSE);
+ QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,FALSE);
// display the file
t << "{" << endl;
@@ -2577,8 +2582,7 @@ void RTFGenerator::endDirDepGraph(DotDirDeps &g)
{
newParagraph();
- QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,Config_getString(RTF_OUTPUT),
- m_fileName,m_relPath,FALSE);
+ QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,FALSE);
// display the file
t << "{" << endl;
@@ -3037,7 +3041,7 @@ void RTFGenerator::endInlineMemberDoc()
void RTFGenerator::writeLineNumber(const char *ref,const char *fileName,const char *anchor,int l)
{
- static bool rtfHyperlinks = Config_getBool(RTF_HYPERLINKS);
+ bool rtfHyperlinks = Config_getBool(RTF_HYPERLINKS);
DoxyCodeLineOpen = TRUE;
QCString lineNumber;
diff --git a/src/rtfgen.h b/src/rtfgen.h
index 9330b13..ac6f580 100644
--- a/src/rtfgen.h
+++ b/src/rtfgen.h
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Parker Waechter & Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -18,6 +18,7 @@
#ifndef RTFGEN_H
#define RTFGEN_H
+#include "config.h"
#include "outputgen.h"
class QFile;
@@ -27,21 +28,18 @@ class RTFGenerator : public OutputGenerator
{
public:
RTFGenerator();
- ~RTFGenerator();
+ RTFGenerator(const RTFGenerator &);
+ RTFGenerator &operator=(const RTFGenerator &);
+ virtual ~RTFGenerator();
+ virtual std::unique_ptr<OutputGenerator> clone() const;
+
static void init();
static void writeStyleSheetFile(QFile &f);
static void writeExtensionsFile(QFile &file);
+ OutputType type() const { return RTF; }
void setRelativePath(const QCString &path);
void setSourceFileName(const QCString &sourceFileName);
- void enable()
- { if (m_genStack->top()) m_active=*m_genStack->top(); else m_active=TRUE; }
- void disable() { m_active=FALSE; }
- void enableIf(OutputType o) { if (o==RTF) enable(); }
- void disableIf(OutputType o) { if (o==RTF) disable(); }
- void disableIfNot(OutputType o) { if (o!=RTF) disable(); }
- bool isEnabled(OutputType o) { return (o==RTF && m_active); }
- OutputGenerator *get(OutputType o) { return (o==RTF) ? this : 0; }
void writeDoc(DocNode *,const Definition *,const MemberDef *);
@@ -51,7 +49,7 @@ class RTFGenerator : public OutputGenerator
void endFile();
void clearBuffer();
//void postProcess(QByteArray &);
-
+
void startIndexSection(IndexSections);
void endIndexSection(IndexSections);
void writePageLink(const char *,bool);
@@ -61,7 +59,7 @@ class RTFGenerator : public OutputGenerator
void startTitleHead(const char *);
void startTitle();
void endTitleHead(const char *,const char *name);
- void endTitle() {}
+ void endTitle() {}
void newParagraph();
void startParagraph(const char *classDef);
@@ -102,13 +100,13 @@ class RTFGenerator : public OutputGenerator
void endItemListItem();
void startMemberSections() {}
- void endMemberSections() {}
+ void endMemberSections() {}
void startHeaderSection() {}
void endHeaderSection() {}
void startMemberHeader(const char *,int) { startGroupHeader(FALSE); }
void endMemberHeader() { endGroupHeader(FALSE); }
- void startMemberSubtitle();
- void endMemberSubtitle();
+ void startMemberSubtitle();
+ void endMemberSubtitle();
void startMemberDocList() {}
void endMemberDocList() {}
void startMemberList();
@@ -125,7 +123,7 @@ class RTFGenerator : public OutputGenerator
void insertMemberAlignLeft(int,bool){}
void writeRuler() { rtfwriteRuler_thin(); }
-
+
void writeAnchor(const char *fileName,const char *name);
void startCodeFragment();
void endCodeFragment();
@@ -147,7 +145,7 @@ class RTFGenerator : public OutputGenerator
void endDoxyAnchor(const char *,const char *);
void writeChar(char c);
void writeLatexSpacing() {};//{ t << "\\hspace{0.3cm}"; }
- void writeStartAnnoItem(const char *type,const char *file,
+ void writeStartAnnoItem(const char *type,const char *file,
const char *path,const char *name);
void writeEndAnnoItem(const char *name);
void startSubsection();
@@ -161,7 +159,7 @@ class RTFGenerator : public OutputGenerator
void startMemberDescription(const char *,const char *,bool);
void endMemberDescription();
- void startMemberDeclaration() {}
+ void startMemberDeclaration() {}
void endMemberDeclaration(const char *,const char *) {}
void writeInheritedSectionTitle(const char *,const char *,const char *,
const char *,const char *,const char *) {}
@@ -193,7 +191,7 @@ class RTFGenerator : public OutputGenerator
void startContents() {}
void endContents() {}
void writeNonBreakableSpace(int);
-
+
void startDescTable(const char *title);
void endDescTable();
void startDescTableRow();
@@ -202,7 +200,7 @@ class RTFGenerator : public OutputGenerator
void endDescTableTitle();
void startDescTableData();
void endDescTableData();
-
+
void startDotGraph();
void endDotGraph(DotClassGraph &);
void startInclDepGraph();
@@ -221,7 +219,7 @@ class RTFGenerator : public OutputGenerator
void endMemberGroupDocs();
void startMemberGroup();
void endMemberGroup(bool);
-
+
void startTextBlock(bool dense);
void endTextBlock(bool);
void lastIndexPage();
@@ -268,11 +266,8 @@ class RTFGenerator : public OutputGenerator
void addWord(const char *,bool) {}
static bool preProcessFileInplace(const char *path,const char *name);
-
- private:
- RTFGenerator(const RTFGenerator &);
- RTFGenerator &operator=(const RTFGenerator &);
+ private:
const char *rtf_BList_DepthStyle();
const char *rtf_CList_DepthStyle();
const char *rtf_EList_DepthStyle();
@@ -281,16 +276,6 @@ class RTFGenerator : public OutputGenerator
const char *rtf_Code_DepthStyle();
void incrementIndentLevel();
void decrementIndentLevel();
- QCString m_sourceFileName;
- int m_col;
- bool m_prettyCode;
-
- bool m_bstartedBody; // has startbody been called yet?
- int m_listLevel; // // RTF does not really have a additive indent...manually set list level.
- bool m_omitParagraph; // should a the next paragraph command be ignored?
- int m_numCols; // number of columns in a table
- QCString m_relPath;
-
void beginRTFDocument();
void beginRTFChapter();
void beginRTFSection();
@@ -299,7 +284,15 @@ class RTFGenerator : public OutputGenerator
void rtfwriteRuler_thick();
void rtfwriteRuler_thin();
void writeRTFReference(const char *label);
- //char *getMultiByte(int c);
+
+ QCString m_sourceFileName;
+ int m_col = 0;
+ bool m_prettyCode = Config_getBool(RTF_SOURCE_CODE);
+ bool m_bstartedBody = false; // has startbody been called yet?
+ int m_listLevel = 0; // // RTF does not really have a additive indent...manually set list level.
+ bool m_omitParagraph = false; // should a the next paragraph command be ignored?
+ int m_numCols = 0; // number of columns in a table
+ QCString m_relPath;
};
#endif