summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/docbookgen.cpp12
-rw-r--r--src/docbookgen.h7
-rw-r--r--src/entry.cpp4
-rw-r--r--src/htmlgen.cpp62
-rw-r--r--src/htmlgen.h6
-rw-r--r--src/latexgen.cpp15
-rw-r--r--src/latexgen.h5
-rw-r--r--src/textstream.h3
8 files changed, 40 insertions, 74 deletions
diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp
index 6ff520d..6e6d969 100644
--- a/src/docbookgen.cpp
+++ b/src/docbookgen.cpp
@@ -140,14 +140,9 @@ void writeDocbookLink(TextStream &t,const char * /*extRef*/,const char *compound
t << "</link>";
}
-DocbookCodeGenerator::DocbookCodeGenerator(TextStream &t) : m_t(nullptr)
+DocbookCodeGenerator::DocbookCodeGenerator(TextStream &t) : m_t(t)
{
m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING);
- setTextStream(t);
-}
-
-DocbookCodeGenerator::DocbookCodeGenerator() : m_t(nullptr)
-{
}
DocbookCodeGenerator::~DocbookCodeGenerator() {}
@@ -267,12 +262,12 @@ DB_GEN_C1(m_t)
//-------------------------------------------------------------------------------
-DocbookGenerator::DocbookGenerator() : OutputGenerator(Config_getString(DOCBOOK_OUTPUT))
+DocbookGenerator::DocbookGenerator() : OutputGenerator(Config_getString(DOCBOOK_OUTPUT)), m_codeGen(m_t)
{
DB_GEN_C
}
-DocbookGenerator::DocbookGenerator(const DocbookGenerator &og) : OutputGenerator(og)
+DocbookGenerator::DocbookGenerator(const DocbookGenerator &og) : OutputGenerator(og), m_codeGen(og.m_codeGen)
{
}
@@ -324,7 +319,6 @@ DB_GEN_C
relPath = relativePathToRoot(fileName);
if (fileName.right(4)!=".xml") fileName+=".xml";
startPlainFile(fileName);
- m_codeGen.setTextStream(m_t);
m_codeGen.setRelativePath(relPath);
m_codeGen.setSourceFileName(stripPath(fileName));
diff --git a/src/docbookgen.h b/src/docbookgen.h
index 3d22d5d..2de8a40 100644
--- a/src/docbookgen.h
+++ b/src/docbookgen.h
@@ -24,12 +24,7 @@ class DocbookCodeGenerator : public CodeOutputInterface
{
public:
DocbookCodeGenerator(TextStream &t);
- DocbookCodeGenerator();
virtual ~DocbookCodeGenerator();
- void setTextStream(TextStream &t)
- {
- m_t = t;
- }
void setRelativePath(const QCString &path) { m_relPath = path; }
void setSourceFileName(const QCString &sourceFileName) { m_sourceFileName = sourceFileName; }
QCString sourceFileName() { return m_sourceFileName; }
@@ -58,7 +53,7 @@ class DocbookCodeGenerator : public CodeOutputInterface
void endCodeFragment(const char *style);
private:
- TextStream m_t;
+ TextStream &m_t;
QCString m_refId;
QCString m_external;
int m_lineNumber = -1;
diff --git a/src/entry.cpp b/src/entry.cpp
index e44b2d3..a0f8fa3 100644
--- a/src/entry.cpp
+++ b/src/entry.cpp
@@ -72,8 +72,8 @@ Entry::Entry(const Entry &e)
bitfields = e.bitfields;
argList = e.argList;
tArgLists = e.tArgLists;
- program = e.program;
- initializer = e.initializer;
+ program.str(e.program.str());
+ initializer.str(e.initializer.str());
includeFile = e.includeFile;
includeName = e.includeName;
doc = e.doc;
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index 08a8cde..b239116 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -512,20 +512,13 @@ static QCString substituteHtmlKeywords(const QCString &str,
//--------------------------------------------------------------------------
-HtmlCodeGenerator::HtmlCodeGenerator() : m_t(nullptr)
+HtmlCodeGenerator::HtmlCodeGenerator(TextStream &t) : m_t(t)
{
}
HtmlCodeGenerator::HtmlCodeGenerator(TextStream &t,const QCString &relPath)
- : m_t(nullptr), m_relPath(relPath)
+ : m_t(t), m_relPath(relPath)
{
- setTextStream(t);
-}
-
-void HtmlCodeGenerator::setTextStream(TextStream &t)
-{
- m_t = t;
- m_streamSet=true;
}
void HtmlCodeGenerator::setRelativePath(const QCString &path)
@@ -536,7 +529,7 @@ void HtmlCodeGenerator::setRelativePath(const QCString &path)
void HtmlCodeGenerator::codify(const char *str)
{
int tabSize = Config_getInt(TAB_SIZE);
- if (str && m_streamSet)
+ if (str)
{
const char *p=str;
char c;
@@ -601,7 +594,7 @@ void HtmlCodeGenerator::docify(const char *str)
{
//m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(str));
- if (str && m_streamSet)
+ if (str)
{
const char *p=str;
char c;
@@ -647,7 +640,6 @@ void HtmlCodeGenerator::docify(const char *str)
void HtmlCodeGenerator::writeLineNumber(const char *ref,const char *filename,
const char *anchor,int l)
{
- if (!m_streamSet) return;
const int maxLineNrStr = 10;
char lineNumber[maxLineNrStr];
char lineAnchor[maxLineNrStr];
@@ -678,7 +670,6 @@ void HtmlCodeGenerator::writeCodeLink(const char *ref,const char *f,
const char *anchor, const char *name,
const char *tooltip)
{
- if (!m_streamSet) return;
//printf("writeCodeLink(ref=%s,f=%s,anchor=%s,name=%s,tooltip=%s)\n",ref,f,anchor,name,tooltip);
_writeCodeLink("code",ref,f,anchor,name,tooltip);
}
@@ -793,52 +784,46 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
void HtmlCodeGenerator::startCodeLine(bool)
{
- if (m_streamSet)
+ m_col=0;
+ if (!m_lineOpen)
{
- m_col=0;
- if (!m_lineOpen)
- {
- m_t << "<div class=\"line\">";
- m_lineOpen = TRUE;
- }
+ m_t << "<div class=\"line\">";
+ m_lineOpen = TRUE;
}
}
void HtmlCodeGenerator::endCodeLine()
{
- if (m_streamSet)
+ if (m_col == 0)
{
- if (m_col == 0)
- {
- m_t << " ";
- m_col++;
- }
- if (m_lineOpen)
- {
- m_t << "</div>\n";
- m_lineOpen = FALSE;
- }
+ m_t << " ";
+ m_col++;
+ }
+ if (m_lineOpen)
+ {
+ m_t << "</div>\n";
+ m_lineOpen = FALSE;
}
}
void HtmlCodeGenerator::startFontClass(const char *s)
{
- if (m_streamSet) m_t << "<span class=\"" << s << "\">";
+ m_t << "<span class=\"" << s << "\">";
}
void HtmlCodeGenerator::endFontClass()
{
- if (m_streamSet) m_t << "</span>";
+ m_t << "</span>";
}
void HtmlCodeGenerator::writeCodeAnchor(const char *anchor)
{
- if (m_streamSet) m_t << "<a name=\"" << anchor << "\"></a>";
+ m_t << "<a name=\"" << anchor << "\"></a>";
}
void HtmlCodeGenerator::startCodeFragment(const char *)
{
- if (m_streamSet) m_t << "<div class=\"fragment\">";
+ m_t << "<div class=\"fragment\">";
}
void HtmlCodeGenerator::endCodeFragment(const char *)
@@ -846,17 +831,17 @@ void HtmlCodeGenerator::endCodeFragment(const char *)
//endCodeLine checks is there is still an open code line, if so closes it.
endCodeLine();
- if (m_streamSet) m_t << "</div><!-- fragment -->";
+ m_t << "</div><!-- fragment -->";
}
//--------------------------------------------------------------------------
-HtmlGenerator::HtmlGenerator() : OutputGenerator(Config_getString(HTML_OUTPUT))
+HtmlGenerator::HtmlGenerator() : OutputGenerator(Config_getString(HTML_OUTPUT)), m_codeGen(m_t)
{
}
-HtmlGenerator::HtmlGenerator(const HtmlGenerator &og) : OutputGenerator(og)
+HtmlGenerator::HtmlGenerator(const HtmlGenerator &og) : OutputGenerator(og), m_codeGen(og.m_codeGen)
{
}
@@ -1065,7 +1050,6 @@ void HtmlGenerator::startFile(const char *name,const char *,
startPlainFile(fileName);
m_codeGen.setId(id);
- m_codeGen.setTextStream(m_t);
m_codeGen.setRelativePath(m_relPath);
{
std::lock_guard<std::mutex> lock(g_indexLock);
diff --git a/src/htmlgen.h b/src/htmlgen.h
index 053506d..5c8eff5 100644
--- a/src/htmlgen.h
+++ b/src/htmlgen.h
@@ -22,10 +22,9 @@ class HtmlCodeGenerator : public CodeOutputInterface
{
public:
HtmlCodeGenerator(TextStream &t,const QCString &relPath);
- HtmlCodeGenerator();
+ HtmlCodeGenerator(TextStream &t);
int id() const { return m_id; }
void setId(int id) { m_id = id; }
- void setTextStream(TextStream &t);
void setRelativePath(const QCString &path);
void codify(const char *text);
void writeCodeLink(const char *ref,const char *file,
@@ -55,8 +54,7 @@ class HtmlCodeGenerator : public CodeOutputInterface
const char *anchor,const char *name,
const char *tooltip);
void docify(const char *str);
- bool m_streamSet = false;
- TextStream m_t;
+ TextStream &m_t;
int m_col = 0;
QCString m_relPath;
bool m_lineOpen = false;
diff --git a/src/latexgen.cpp b/src/latexgen.cpp
index a7d01f6..0f6d110 100644
--- a/src/latexgen.cpp
+++ b/src/latexgen.cpp
@@ -50,22 +50,16 @@ static QCString g_header;
static QCString g_footer;
LatexCodeGenerator::LatexCodeGenerator(TextStream &t,const QCString &relPath,const QCString &sourceFileName)
- : m_t(nullptr), m_relPath(relPath), m_sourceFileName(sourceFileName)
+ : m_t(t), m_relPath(relPath), m_sourceFileName(sourceFileName)
{
m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
- setTextStream(t);
}
-LatexCodeGenerator::LatexCodeGenerator() : m_t(nullptr)
+LatexCodeGenerator::LatexCodeGenerator(TextStream &t) : m_t(t)
{
m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
}
-void LatexCodeGenerator::setTextStream(TextStream &t)
-{
- m_t = t;
-}
-
void LatexCodeGenerator::setRelativePath(const QCString &path)
{
m_relPath = path;
@@ -264,12 +258,12 @@ void LatexCodeGenerator::endCodeFragment(const char *style)
//-------------------------------
-LatexGenerator::LatexGenerator() : OutputGenerator(Config_getString(LATEX_OUTPUT))
+LatexGenerator::LatexGenerator() : OutputGenerator(Config_getString(LATEX_OUTPUT)), m_codeGen(m_t)
{
//printf("LatexGenerator::LatexGenerator() m_insideTabbing=FALSE\n");
}
-LatexGenerator::LatexGenerator(const LatexGenerator &og) : OutputGenerator(og)
+LatexGenerator::LatexGenerator(const LatexGenerator &og) : OutputGenerator(og), m_codeGen(og.m_codeGen)
{
}
@@ -532,7 +526,6 @@ void LatexGenerator::startFile(const char *name,const char *,const char *,int)
m_relPath = relativePathToRoot(fileName);
if (fileName.right(4)!=".tex" && fileName.right(4)!=".sty") fileName+=".tex";
startPlainFile(fileName);
- m_codeGen.setTextStream(m_t);
m_codeGen.setRelativePath(m_relPath);
m_codeGen.setSourceFileName(stripPath(fileName));
}
diff --git a/src/latexgen.h b/src/latexgen.h
index ce99789..4e92280 100644
--- a/src/latexgen.h
+++ b/src/latexgen.h
@@ -29,8 +29,7 @@ class LatexCodeGenerator : public CodeOutputInterface
{
public:
LatexCodeGenerator(TextStream &t,const QCString &relPath,const QCString &sourceFile);
- LatexCodeGenerator();
- void setTextStream(TextStream &t);
+ LatexCodeGenerator(TextStream &t);
void setRelativePath(const QCString &path);
void setSourceFileName(const QCString &sourceFileName);
void codify(const char *text);
@@ -67,7 +66,7 @@ class LatexCodeGenerator : public CodeOutputInterface
const char *tooltip);
void docify(const char *str);
bool m_streamSet = false;
- TextStream m_t;
+ TextStream &m_t;
QCString m_relPath;
QCString m_sourceFileName;
int m_col = 0;
diff --git a/src/textstream.h b/src/textstream.h
index 37525ef..cee4cb7 100644
--- a/src/textstream.h
+++ b/src/textstream.h
@@ -57,6 +57,9 @@ class TextStream final
/** Writes any data that is buffered to the attached std::ostream */
~TextStream() { flush(); }
+ TextStream(const TextStream &) = delete;
+ TextStream &operator=(const TextStream &) = delete;
+
/** Sets or changes the std::ostream to write to.
* @note Any data already buffered will be flushed.
*/