From 3820f6a841115bd66ed409221c73824ec41ae6ab Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 24 Nov 2018 19:57:34 +0100 Subject: Refactored code a bit (use const references and made global functions members) --- src/docbookgen.cpp | 11 ++++++++--- src/docbookvisitor.cpp | 49 +++++++++++++++++++++++++++---------------------- src/docbookvisitor.h | 21 +++++++++++++-------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 6464701..97c602d 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -904,10 +904,15 @@ DB_GEN_C void DocbookGenerator::endClassDiagram(const ClassDiagram &d, const char *fileName,const char *) { DB_GEN_C - QList dummy; - visitPreStart(t, FALSE, NULL, dummy, relPath + fileName + ".png", NULL, NULL); + t << " " << endl; + t << " " << endl; + t << " " << endl; + t << " " << "" << endl; + t << " " << endl; d.writeImage(t,dir,relPath,fileName,FALSE); - visitPostEnd(t, FALSE); + t << " " << endl; + t << " " << endl; t << "" << endl; } void DocbookGenerator::startLabels() diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index debb7d7..51d1755 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -49,21 +49,26 @@ #define DB_VIS_C2a(x,y) #endif -static void visitCaption(DocbookDocVisitor *parent, QList children) +void DocbookDocVisitor::visitCaption(const QList &children) { QListIterator cli(children); DocNode *n; - for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); + for (cli.toFirst();(n=cli.current());++cli) n->accept(this); } -void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, QList children, QCString name, QCString width, QCString height, bool inlineImage) +void DocbookDocVisitor::visitPreStart(FTextStream &t, + const QList &children, + bool hasCaption, + const QCString &name, + const QCString &width, + const QCString &height, + bool inlineImage) { - QCString tmpStr; if (hasCaption) { t << "
" << endl; t << " " << endl; - visitCaption(parent, children); + visitCaption(children); t << " " << endl; } else @@ -83,7 +88,7 @@ void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, Q } if (!height.isEmpty()) { - t << " depth=\"" << convertToDocBook(tmpStr) << "\""; + t << " depth=\"" << convertToDocBook(height) << "\""; } t << " align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << name << "\">"; t << "" << endl; @@ -94,7 +99,7 @@ void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, Q } } -void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) +void DocbookDocVisitor::visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) { t << endl; if (hasCaption) @@ -1168,7 +1173,7 @@ DB_VIS_C { baseName=baseName.right(baseName.length()-i-1); } - visitPreStart(m_t, img -> hasCaption(), this, img->children(), img->relPath() + baseName, img -> width(), img -> height(),img -> isInlineImage()); + visitPreStart(m_t, img->children(), img->hasCaption(), img->relPath() + baseName, img->width(), img->height(), img->isInlineImage()); } else { @@ -1622,8 +1627,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + ".png", s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(), s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1638,8 +1643,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); generatePlantUMLOutput(baseName,outDir,PUML_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + ".png", s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1647,7 +1652,7 @@ void DocbookDocVisitor::startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, - QList childs + const QList &children ) { DB_VIS_C @@ -1665,7 +1670,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption,this, childs, baseName + ".png", width, height); + visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } void DocbookDocVisitor::endMscFile(bool hasCaption) @@ -1687,8 +1692,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), shortName, s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), shortName, s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1696,7 +1701,7 @@ void DocbookDocVisitor::startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, - QList childs + const QList &children ) { DB_VIS_C @@ -1714,7 +1719,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, this, childs, baseName + ".png", width, height); + visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } void DocbookDocVisitor::endDiaFile(bool hasCaption) @@ -1736,8 +1741,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1745,7 +1750,7 @@ void DocbookDocVisitor::startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, - QList childs + const QList &children ) { DB_VIS_C @@ -1764,7 +1769,7 @@ DB_VIS_C QCString imgExt = getDotImageExtension(); writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, this, childs, baseName + "." + imgExt, width, height); + visitPreStart(m_t, children, hasCaption, baseName + "." + imgExt, width, height); } void DocbookDocVisitor::endDotFile(bool hasCaption) diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index 87035f8..24b1fbb 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -28,6 +28,7 @@ class FTextStream; class CodeOutputInterface; class QCString; +/*! @brief Concrete visitor implementation for Docbook output. */ class DocbookDocVisitor : public DocVisitor { public: @@ -148,18 +149,27 @@ class DocbookDocVisitor : public DocVisitor void pushEnabled(); void popEnabled(); void startMscFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption,QList childs); + const QCString &height, bool hasCaption,const QList &children); void endMscFile(bool hasCaption); void writeMscFile(const QCString &fileName, DocVerbatim *s); void startDiaFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption,QList childs); + const QCString &height, bool hasCaption,const QList &children); void endDiaFile(bool hasCaption); void writeDiaFile(const QCString &fileName, DocVerbatim *s); void startDotFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption,QList childs); + const QCString &height, bool hasCaption,const QList &children); void endDotFile(bool hasCaption); void writeDotFile(const QCString &fileName, DocVerbatim *s); void writePlantUMLFile(const QCString &fileName, DocVerbatim *s); + void visitPreStart(FTextStream &t, + const QList &children, + bool hasCaption, + const QCString &name, + const QCString &width, + const QCString &height, + bool inlineImage = FALSE); + void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); + void visitCaption(const QList &children); //-------------------------------------- // state variables //-------------------------------------- @@ -171,9 +181,4 @@ class DocbookDocVisitor : public DocVisitor QCString m_langExt; }; -void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, QList children, QCString name, QCString width, QCString height, bool inlineImage=FALSE); -void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); - -/*! @brief Concrete visitor implementation for Docbook output. */ - #endif -- cgit v0.12