Imported Upstream version 1.9.4
[platform/upstream/doxygen.git] / src / docbookvisitor.h
1 /******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16 #ifndef DOCBOOKDOCVISITOR_H
17 #define DOCBOOKDOCVISITOR_H
18
19 #include <iostream>
20
21 #include "containers.h"
22 #include "docvisitor.h"
23 #include "docnode.h"
24 #include "qcstring.h"
25
26 class CodeOutputInterface;
27 class QCString;
28 class TextStream;
29
30 /*! @brief Concrete visitor implementation for Docbook output. */
31 class DocbookDocVisitor : public DocVisitor
32 {
33     public:
34     DocbookDocVisitor(TextStream &t,CodeOutputInterface &ci,const QCString &langExt);
35     ~DocbookDocVisitor();
36     //-----------------------------------------
37     template<class T>
38     void visitChildren(const T &t)
39     {
40       for (const auto &child : t.children())
41       {
42         std::visit(*this, child);
43       }
44     }
45     //--------------------------------------
46     // visitor functions for leaf nodes
47     //--------------------------------------
48     void operator()(const DocWord &);
49     void operator()(const DocLinkedWord &);
50     void operator()(const DocWhiteSpace &);
51     void operator()(const DocSymbol &);
52     void operator()(const DocEmoji &);
53     void operator()(const DocURL &);
54     void operator()(const DocLineBreak &);
55     void operator()(const DocHorRuler &);
56     void operator()(const DocStyleChange &);
57     void operator()(const DocVerbatim &);
58     void operator()(const DocAnchor &);
59     void operator()(const DocInclude &);
60     void operator()(const DocIncOperator &);
61     void operator()(const DocFormula &);
62     void operator()(const DocIndexEntry &);
63     void operator()(const DocSimpleSectSep &);
64     void operator()(const DocCite &);
65     void operator()(const DocSeparator &);
66     //--------------------------------------
67     // visitor functions for compound nodes
68     //--------------------------------------
69     void operator()(const DocAutoList &);
70     void operator()(const DocAutoListItem &);
71     void operator()(const DocPara &) ;
72     void operator()(const DocRoot &);
73     void operator()(const DocSimpleSect &);
74     void operator()(const DocTitle &);
75     void operator()(const DocSimpleList &);
76     void operator()(const DocSimpleListItem &);
77     void operator()(const DocSection &);
78     void operator()(const DocHtmlList &);
79     void operator()(const DocHtmlListItem &);
80     void operator()(const DocHtmlDescList &);
81     void operator()(const DocHtmlDescTitle &);
82     void operator()(const DocHtmlDescData &);
83     void operator()(const DocHtmlTable &);
84     void operator()(const DocHtmlRow &);
85     void operator()(const DocHtmlCell &);
86     void operator()(const DocHtmlCaption &);
87     void operator()(const DocInternal &);
88     void operator()(const DocHRef &);
89     void operator()(const DocHtmlHeader &);
90     void operator()(const DocImage &);
91     void operator()(const DocDotFile &);
92     void operator()(const DocMscFile &);
93     void operator()(const DocDiaFile &);
94     void operator()(const DocLink &);
95     void operator()(const DocRef &);
96     void operator()(const DocSecRefItem &);
97     void operator()(const DocSecRefList &);
98     void operator()(const DocParamSect &);
99     void operator()(const DocParamList &);
100     void operator()(const DocXRefItem &);
101     void operator()(const DocInternalRef &);
102     void operator()(const DocText &);
103     void operator()(const DocHtmlBlockQuote &);
104     void operator()(const DocVhdlFlow &);
105     void operator()(const DocParBlock &);
106
107   private:
108     //--------------------------------------
109     // helper functions
110     //--------------------------------------
111     void filter(const QCString &str, const bool retainNewLine = false);
112     void startLink(const QCString &file,
113     const QCString &anchor);
114     void endLink();
115     void startMscFile(const QCString &fileName,const QCString &width,
116                       const QCString &height, bool hasCaption,const DocNodeList &children,
117                       const QCString &srcFile, int srcLine);
118     void endMscFile(bool hasCaption);
119     void writeMscFile(const QCString &fileName, const DocVerbatim &s);
120     void startDiaFile(const QCString &fileName,const QCString &width,
121                       const QCString &height, bool hasCaption,const DocNodeList &children,
122                       const QCString &srcFile, int srcLine);
123     void endDiaFile(bool hasCaption);
124     void writeDiaFile(const QCString &fileName, const DocVerbatim &s);
125     void startDotFile(const QCString &fileName,const QCString &width,
126                       const QCString &height, bool hasCaption,const DocNodeList &children,
127                       const QCString &srcFile, int srcLine);
128     void endDotFile(bool hasCaption);
129     void writeDotFile(const QCString &fileName, const DocVerbatim &s);
130     void writePlantUMLFile(const QCString &fileName, const DocVerbatim &s);
131     void visitPreStart(TextStream &t,
132                    const DocNodeList &children,
133                    bool hasCaption,
134                    const QCString &name,
135                    const QCString &width,
136                    const QCString &height,
137                    bool inlineImage = FALSE);
138     void visitPostEnd(TextStream &t, bool hasCaption, bool inlineImage = FALSE);
139     void visitCaption(const DocNodeList &children);
140     //--------------------------------------
141     // state variables
142     //--------------------------------------
143     TextStream &m_t;
144     CodeOutputInterface &m_ci;
145     bool m_insidePre = false;
146     bool m_hide = false;
147     BoolStack m_enabled;
148     QCString m_langExt;
149     int m_colCnt = 0;
150     BoolStack m_bodySet; // it is possible to have tables without a header, needs to be an array as we can have tables in tables
151 };
152
153 #endif