printdocvisitor.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation under the terms of the GNU General Public License is hereby
10  * granted. No representations are made about the suitability of this software
11  * for any purpose. It is provided "as is" without express or implied warranty.
12  * See the GNU General Public License for more details.
13  *
14  * Documents produced by Doxygen are derivative works derived from the
15  * input used in their production; they are not affected by this license.
16  *
17  */
18 
19 #ifndef _PRINTDOCVISITOR_H
20 #define _PRINTDOCVISITOR_H
21 
22 #include <qglobal.h>
23 #include "docvisitor.h"
24 #include "htmlentity.h"
25 
26 /*! Concrete visitor implementation for pretty printing */
28 {
29  public:
32 
33  //--------------------------------------
34 
35  void visit(DocWord *w)
36  {
37  indent_leaf();
38  printf("%s",w->word().data());
39  }
41  {
42  indent_leaf();
43  printf("%s",w->word().data());
44  }
46  {
47  indent_leaf();
48  if (m_insidePre)
49  {
50  printf("%s",w->chars().data());
51  }
52  else
53  {
54  printf(" ");
55  }
56  }
57  void visit(DocSymbol *s)
58  {
59  indent_leaf();
60  const char *res = HtmlEntityMapper::instance()->utf8(s->symbol(),TRUE);
61  if (res)
62  {
63  printf("%s",res);
64  }
65  else
66  {
67  printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
68  }
69  }
70  void visit(DocURL *u)
71  {
72  indent_leaf();
73  printf("%s",u->url().data());
74  }
76  {
77  indent_leaf();
78  printf("<br/>");
79  }
81  {
82  indent_leaf();
83  printf("<hr>");
84  }
86  {
87  indent_leaf();
88  switch (s->style())
89  {
91  if (s->enable()) printf("<bold>"); else printf("</bold>");
92  break;
94  if (s->enable()) printf("<italic>"); else printf("</italic>");
95  break;
97  if (s->enable()) printf("<code>"); else printf("</code>");
98  break;
100  if (s->enable()) printf("<sub>"); else printf("</sub>");
101  break;
103  if (s->enable()) printf("<sup>"); else printf("</sup>");
104  break;
106  if (s->enable()) printf("<center>"); else printf("</center>");
107  break;
109  if (s->enable()) printf("<small>"); else printf("</small>");
110  break;
112  if (s->enable()) printf("<pre>"); else printf("</pre>");
113  break;
114  case DocStyleChange::Div:
115  if (s->enable()) printf("<div>"); else printf("</div>");
116  break;
118  if (s->enable()) printf("<span>"); else printf("</span>");
119  break;
120  }
121  }
123  {
124  indent_leaf();
125  switch(s->type())
126  {
127  case DocVerbatim::Code: printf("<code>"); break;
128  case DocVerbatim::Verbatim: printf("<verbatim>"); break;
129  case DocVerbatim::HtmlOnly: printf("<htmlonly>"); break;
130  case DocVerbatim::RtfOnly: printf("<rtfonly>"); break;
131  case DocVerbatim::ManOnly: printf("<manonly>"); break;
132  case DocVerbatim::LatexOnly: printf("<latexonly>"); break;
133  case DocVerbatim::XmlOnly: printf("<xmlonly>"); break;
134  case DocVerbatim::DocbookOnly: printf("<docbookonly>"); break;
135  case DocVerbatim::Dot: printf("<dot>"); break;
136  case DocVerbatim::Msc: printf("<msc>"); break;
137  case DocVerbatim::PlantUML: printf("<plantuml>"); break;
138  }
139  printf("%s",s->text().data());
140  switch(s->type())
141  {
142  case DocVerbatim::Code: printf("</code>"); break;
143  case DocVerbatim::Verbatim: printf("</verbatim>"); break;
144  case DocVerbatim::HtmlOnly: printf("</htmlonly>"); break;
145  case DocVerbatim::RtfOnly: printf("</rtfonly>"); break;
146  case DocVerbatim::ManOnly: printf("</manonly>"); break;
147  case DocVerbatim::LatexOnly: printf("</latexonly>"); break;
148  case DocVerbatim::XmlOnly: printf("</xmlonly>"); break;
149  case DocVerbatim::DocbookOnly: printf("</docbookonly>"); break;
150  case DocVerbatim::Dot: printf("</dot>"); break;
151  case DocVerbatim::Msc: printf("</msc>"); break;
152  case DocVerbatim::PlantUML: printf("</plantuml>"); break;
153  }
154  }
156  {
157  indent_leaf();
158  printf("<anchor name=\"%s\"/>",a->anchor().data());
159  }
160  void visit(DocInclude *inc)
161  {
162  indent_leaf();
163  printf("<include file=\"%s\" type=\"",inc->file().data());
164  switch(inc->type())
165  {
166  case DocInclude::Include: printf("include"); break;
167  case DocInclude::IncWithLines: printf("incwithlines"); break;
168  case DocInclude::DontInclude: printf("dontinclude"); break;
169  case DocInclude::HtmlInclude: printf("htmlinclude"); break;
170  case DocInclude::LatexInclude: printf("latexinclude"); break;
171  case DocInclude::VerbInclude: printf("verbinclude"); break;
172  case DocInclude::Snippet: printf("snippet"); break;
173  }
174  printf("\"/>");
175  }
177  {
178  indent_leaf();
179  printf("<incoperator pattern=\"%s\" type=\"",op->pattern().data());
180  switch(op->type())
181  {
182  case DocIncOperator::Line: printf("line"); break;
183  case DocIncOperator::Skip: printf("skip"); break;
184  case DocIncOperator::SkipLine: printf("skipline"); break;
185  case DocIncOperator::Until: printf("until"); break;
186  }
187  printf("\"/>");
188  }
190  {
191  indent_leaf();
192  printf("<formula name=%s text=%s/>",f->name().data(),f->text().data());
193  }
195  {
196  indent_leaf();
197  printf("<indexentry>%s</indexentry\n",i->entry().data());
198  }
200  {
201  indent_leaf();
202  printf("<simplesectsep/>");
203  }
204  void visit(DocCite *cite)
205  {
206  indent_leaf();
207  printf("<cite ref=\"%s\" file=\"%s\" "
208  "anchor=\"%s\" text=\"%s\""
209  "/>\n",
210  cite->ref().data(),cite->file().data(),cite->anchor().data(),
211  cite->text().data());
212  }
213 
214  //--------------------------------------
215 
217  {
218  indent_pre();
219  if (l->isEnumList())
220  {
221  printf("<ol>\n");
222  }
223  else
224  {
225  printf("<ul>\n");
226  }
227  }
229  {
230  indent_post();
231  if (l->isEnumList())
232  {
233  printf("</ol>\n");
234  }
235  else
236  {
237  printf("</ul>\n");
238  }
239  }
241  {
242  indent_pre();
243  printf("<li>\n");
244  }
246  {
247  indent_post();
248  printf("</li>\n");
249  }
250  void visitPre(DocPara *)
251  {
252  indent_pre();
253  printf("<para>\n");
254  }
256  {
257  indent_post();
258  printf("</para>\n");
259  }
261  {
262  indent_pre();
263  printf("<root>\n");
264  }
266  {
267  indent_post();
268  printf("</root>\n");
269  }
271  {
272  indent_pre();
273  printf("<simplesect type=");
274  switch(s->type())
275  {
276  case DocSimpleSect::See: printf("see"); break;
277  case DocSimpleSect::Return: printf("return"); break;
278  case DocSimpleSect::Author: printf("author"); break;
279  case DocSimpleSect::Authors: printf("authors"); break;
280  case DocSimpleSect::Version: printf("version"); break;
281  case DocSimpleSect::Since: printf("since"); break;
282  case DocSimpleSect::Date: printf("date"); break;
283  case DocSimpleSect::Note: printf("note"); break;
284  case DocSimpleSect::Warning: printf("warning"); break;
285  case DocSimpleSect::Pre: printf("pre"); break;
286  case DocSimpleSect::Post: printf("post"); break;
287  case DocSimpleSect::Copyright: printf("copyright"); break;
288  case DocSimpleSect::Invar: printf("invar"); break;
289  case DocSimpleSect::Remark: printf("remark"); break;
290  case DocSimpleSect::Attention: printf("attention"); break;
291  case DocSimpleSect::User: printf("user"); break;
292  case DocSimpleSect::Rcs: printf("rcs"); break;
293  case DocSimpleSect::Unknown: printf("unknown"); break;
294  }
295  printf(">\n");
296  }
298  {
299  indent_post();
300  printf("</simplesect>\n");
301  }
303  {
304  indent_pre();
305  printf("<title>\n");
306  }
308  {
309  indent_post();
310  printf("</title>\n");
311  }
313  {
314  indent_pre();
315  printf("<ul>\n");
316  }
318  {
319  indent_post();
320  printf("</ul>\n");
321  }
323  {
324  indent_pre();
325  printf("<li>\n");
326  }
328  {
329  indent_post();
330  printf("</li>\n");
331  }
333  {
334  indent_pre();
335  printf("<sect%d>\n",s->level());
336  }
338  {
339  indent_post();
340  printf("</sect%d>\n",s->level());
341  }
343  {
344  indent_pre();
345  if (s->type()==DocHtmlList::Ordered) printf("<ol>\n"); else printf("<ul>\n");
346  }
348  {
349  indent_post();
350  if (s->type()==DocHtmlList::Ordered) printf("</ol>\n"); else printf("</ul>\n");
351  }
353  {
354  indent_pre();
355  printf("<li>\n");
356  }
358  {
359  indent_post();
360  printf("</li>\n");
361  }
362  //void visitPre(DocHtmlPre *)
363  //{
364  // indent_pre();
365  // printf("<pre>\n");
366  // m_insidePre=TRUE;
367  //}
368  //void visitPost(DocHtmlPre *)
369  //{
370  // m_insidePre=FALSE;
371  // indent_post();
372  // printf("</pre>\n");
373  //}
375  {
376  indent_pre();
377  printf("<dl>\n");
378  }
380  {
381  indent_post();
382  printf("</dl>\n");
383  }
385  {
386  indent_pre();
387  printf("<dt>\n");
388  }
390  {
391  indent_post();
392  printf("</dt>\n");
393  }
395  {
396  indent_pre();
397  printf("<dd>\n");
398  }
400  {
401  indent_post();
402  printf("</dd>\n");
403  }
405  {
406  indent_pre();
407  printf("<table rows=\"%d\" cols=\"%d\">\n",
408  t->numRows(),t->numColumns());
409  }
411  {
412  indent_post();
413  printf("</table>\n");
414  }
416  {
417  indent_pre();
418  printf("<tr>\n");
419  }
421  {
422  indent_post();
423  printf("</tr>\n");
424  }
426  {
427  indent_pre();
428  printf("<t%c>\n",c->isHeading()?'h':'d');
429  }
431  {
432  indent_post();
433  printf("</t%c>\n",c->isHeading()?'h':'d');
434  }
436  {
437  indent_pre();
438  printf("<caption>\n");
439  }
441  {
442  indent_post();
443  printf("</caption>\n");
444  }
446  {
447  indent_pre();
448  printf("<internal>\n");
449  }
451  {
452  indent_post();
453  printf("</internal>\n");
454  }
455  void visitPre(DocHRef *href)
456  {
457  indent_pre();
458  printf("<a url=\"%s\">\n",href->url().data());
459  }
461  {
462  indent_post();
463  printf("</a>\n");
464  }
465  void visitPre(DocHtmlHeader *header)
466  {
467  indent_pre();
468  printf("<h%d>\n",header->level());
469  }
470  void visitPost(DocHtmlHeader *header)
471  {
472  indent_post();
473  printf("</h%d>\n",header->level());
474  }
476  {
477  indent_pre();
478  printf("<image src=\"%s\" type=\"",img->name().data());
479  switch(img->type())
480  {
481  case DocImage::Html: printf("html"); break;
482  case DocImage::Latex: printf("latex"); break;
483  case DocImage::Rtf: printf("rtf"); break;
484  case DocImage::DocBook: printf("docbook"); break;
485  }
486  printf("\" %s %s>\n",img->width().data(),img->height().data());
487  }
489  {
490  indent_post();
491  printf("</image>\n");
492  }
494  {
495  indent_pre();
496  printf("<dotfile src=\"%s\">\n",df->name().data());
497  }
499  {
500  indent_post();
501  printf("</dotfile>\n");
502  }
504  {
505  indent_pre();
506  printf("<mscfile src=\"%s\">\n",df->name().data());
507  }
509  {
510  indent_post();
511  printf("</mscfile>\n");
512  }
514  {
515  indent_pre();
516  printf("<diafile src=\"%s\">\n",df->name().data());
517  }
519  {
520  indent_post();
521  printf("</diafile>\n");
522  }
523  void visitPre(DocLink *lnk)
524  {
525  indent_pre();
526  printf("<link ref=\"%s\" file=\"%s\" anchor=\"%s\">\n",
527  lnk->ref().data(),lnk->file().data(),lnk->anchor().data());
528  }
530  {
531  indent_post();
532  printf("</link>\n");
533  }
534  void visitPre(DocRef *ref)
535  {
536  indent_pre();
537  printf("<ref ref=\"%s\" file=\"%s\" "
538  "anchor=\"%s\" targetTitle=\"%s\""
539  " hasLinkText=\"%s\" refToAnchor=\"%s\" refToSection=\"%s\" refToTable=\"%s\">\n",
540  ref->ref().data(),ref->file().data(),ref->anchor().data(),
541  ref->targetTitle().data(),ref->hasLinkText()?"yes":"no",
542  ref->refToAnchor()?"yes":"no", ref->refToSection()?"yes":"no",
543  ref->refToTable()?"yes":"no");
544  }
545  void visitPost(DocRef *)
546  {
547  indent_post();
548  printf("</ref>\n");
549  }
551  {
552  indent_pre();
553  printf("<secrefitem target=\"%s\">\n",ref->target().data());
554  }
556  {
557  indent_post();
558  printf("</secrefitem>\n");
559  }
561  {
562  indent_pre();
563  printf("<secreflist>\n");
564  }
566  {
567  indent_post();
568  printf("</secreflist>\n");
569  }
570  //void visitPre(DocLanguage *l)
571  //{
572  // indent_pre();
573  // printf("<language id=%s>\n",l->id().data());
574  //}
575  //void visitPost(DocLanguage *)
576  //{
577  // indent_post();
578  // printf("</language>\n");
579  //}
581  {
582  indent_pre();
583  //QStrListIterator sli(pl->parameters());
585  //const char *s;
586  DocNode *param;
587  printf("<parameters>");
588  for (sli.toFirst();(param=sli.current());++sli)
589  {
590  printf("<param>");
591  if (param->kind()==DocNode::Kind_Word)
592  {
593  visit((DocWord*)param);
594  }
595  else if (param->kind()==DocNode::Kind_LinkedWord)
596  {
597  visit((DocLinkedWord*)param);
598  }
599  printf("</param>");
600  }
601  printf("\n");
602  }
604  {
605  indent_post();
606  printf("</parameters>\n");
607  }
609  {
610  indent_pre();
611  printf("<paramsect type=");
612  switch (ps->type())
613  {
614  case DocParamSect::Param: printf("param"); break;
615  case DocParamSect::RetVal: printf("retval"); break;
616  case DocParamSect::Exception: printf("exception"); break;
617  case DocParamSect::TemplateParam: printf("templateparam"); break;
618  case DocParamSect::Unknown: printf("unknown"); break;
619  }
620  printf(">\n");
621  }
623  {
624  indent_post();
625  printf("</paramsect>\n");
626  }
628  {
629  indent_pre();
630  printf("<xrefitem file=\"%s\" anchor=\"%s\" title=\"%s\"/>\n",
631  x->file().data(),x->anchor().data(),x->title().data());
632  }
634  {
635  indent_post();
636  printf("<xrefitem/>\n");
637  }
639  {
640  indent_pre();
641  printf("<internalref file=%s anchor=%s>\n",r->file().data(),r->anchor().data());
642  }
644  {
645  indent_post();
646  printf("</internalref>\n");
647  }
649  {
650  indent_pre();
651  printf("<copy link=\"%s\">\n",c->link().data());
652  }
654  {
655  indent_post();
656  printf("</copy>\n");
657  }
659  {
660  indent_pre();
661  printf("<text>\n");
662  }
664  {
665  indent_post();
666  printf("</text>\n");
667  }
669  {
670  indent_pre();
671  printf("<blockquote>\n");
672  }
674  {
675  indent_post();
676  printf("</blockquote>\n");
677  }
679  {
680  indent_pre();
681  printf("<vhdlflow>\n");
682  }
684  {
685  indent_post();
686  printf("</vhdlflow>\n");
687  }
689  {
690  indent_pre();
691  printf("<parblock>\n");
692  }
694  {
695  indent_post();
696  printf("</parblock>\n");
697  }
698 
699  private:
700  // helper functions
701  void indent()
702  {
703  if (m_needsEnter) printf("\n");
704  for (int i=0;i<m_indent;i++) printf(".");
706  }
707  void indent_leaf()
708  {
709  if (!m_needsEnter) indent();
711  }
712  void indent_pre()
713  {
714  indent();
715  m_indent++;
716  }
717  void indent_post()
718  {
719  m_indent--;
720  indent();
721  }
722 
723  // member variables
724  int m_indent;
727 };
728 
729 #endif
bool refToSection() const
Definition: docparser.h:834
void visitPost(DocHtmlHeader *header)
void visitPost(DocHtmlDescList *)
void visitPre(DocHtmlDescData *)
void visitPre(DocHtmlRow *)
Type type() const
Definition: docparser.h:532
Type type() const
Definition: docparser.h:1034
void visitPre(DocParamSect *ps)
void visitPost(DocSection *s)
QCString name() const
Definition: docparser.h:695
QCString anchor() const
Definition: docparser.h:830
void visitPost(DocLink *)
void visitPre(DocHtmlList *s)
QCString anchor() const
Definition: docparser.h:277
QCString pattern() const
Definition: docparser.h:534
QCString name() const
Definition: docparser.h:746
QCString url() const
Definition: docparser.h:239
QCString width() const
Definition: docparser.h:697
void visitPre(DocMscFile *df)
QCString text() const
Definition: docparser.h:296
void visitPre(DocXRefItem *x)
bool refToAnchor() const
Definition: docparser.h:833
void visit(DocWhiteSpace *w)
void visitPre(DocSimpleSect *s)
void visit(DocCite *cite)
void visitPre(DocSimpleListItem *)
void visitPre(DocDiaFile *df)
int level() const
Definition: docparser.h:942
void visitPre(DocSimpleList *)
void visitPre(DocHRef *href)
void visitPost(DocText *)
Type type() const
Definition: docparser.h:1101
void visitPost(DocSimpleSect *)
const bool FALSE
Definition: qglobal.h:370
void visitPre(DocHtmlTable *t)
void visitPost(DocParBlock *)
void visitPost(DocHtmlRow *)
static HtmlEntityMapper * instance()
Definition: htmlentity.cpp:341
void visitPre(DocHtmlDescList *)
QCString file() const
Definition: docparser.h:827
Type type() const
Definition: docparser.h:502
QCString anchor() const
Definition: docparser.h:859
QCString ref() const
Definition: docparser.h:294
void visitPost(DocInternal *)
static QStrList * l
Definition: config.cpp:1044
void visitPost(DocDotFile *)
void visitPost(DocMscFile *)
const int DocVisitor_Other
Definition: docvisitor.h:29
void visit(DocHorRuler *)
QCString name() const
Definition: docparser.h:770
QCString height() const
Definition: docparser.h:698
void visitPre(DocAutoListItem *)
void visitPost(DocParamList *)
int level() const
Definition: docparser.h:894
void visitPost(DocHtmlBlockQuote *)
Abstract visitor that participates in the visitor pattern.
Definition: docvisitor.h:90
void visitPost(DocAutoListItem *)
void visitPost(DocSimpleListItem *)
void visitPost(DocXRefItem *)
QCString targetTitle() const
Definition: docparser.h:831
void visit(DocURL *u)
void visitPre(DocSecRefList *)
QCString file() const
Definition: docparser.h:292
QCString name() const
Definition: docparser.h:722
void visit(DocInclude *inc)
QCString ref() const
Definition: docparser.h:829
QCString file() const
Definition: docparser.h:857
void visitPre(DocCopy *c)
void visitPost(DocHtmlCaption *)
QCString text() const
Definition: docparser.h:450
QCString text() const
Definition: docparser.h:563
QCString anchor() const
Definition: docparser.h:670
QCString word() const
Definition: docparser.h:199
void visitPre(DocParamList *pl)
void visit(DocSimpleSectSep *)
void visitPre(DocText *)
const double a
void visitPost(DocHtmlListItem *)
void visitPre(DocRef *ref)
void visit(DocWord *w)
void visitPost(DocSecRefItem *)
void visit(DocStyleChange *s)
const char * data() const
Definition: qcstring.h:207
void visitPre(DocDotFile *df)
void visitPost(DocRef *)
void visitPre(DocRoot *)
type * current() const
Definition: qlist.h:146
QCString url() const
Definition: docparser.h:876
void visit(DocLineBreak *)
void visitPost(DocImage *)
Type type() const
Definition: docparser.h:1057
static constexpr double ps
Definition: Units.h:99
void visitPost(DocHtmlCell *c)
Style style() const
Definition: docparser.h:329
bool isHeading() const
Definition: docparser.h:1260
void visit(DocSymbol *s)
void visit(DocIncOperator *op)
void visitPre(DocInternalRef *r)
void visitPost(DocHtmlTable *)
QCString entry() const
Definition: docparser.h:586
void visitPost(DocHtmlDescData *)
void visit(DocAnchor *a)
QCString word() const
Definition: docparser.h:215
void visitPre(DocParBlock *)
void visitPre(DocTitle *)
void visit(DocLinkedWord *w)
void visitPost(DocRoot *)
void visitPost(DocParamSect *)
void visitPre(DocSection *s)
void visitPost(DocTitle *)
uint numRows() const
Definition: docparser.h:1352
QCString link() const
Definition: docparser.h:605
QCString file() const
Definition: docparser.h:495
void visitPre(DocImage *img)
void visitPre(DocSecRefItem *ref)
const QList< DocNode > & parameters()
Definition: docparser.h:1169
void visitPost(DocVhdlFlow *)
void visitPost(DocPara *)
bool isEnumList() const
Definition: docparser.h:621
SymType symbol() const
Definition: docparser.h:418
QCString file() const
Definition: docparser.h:669
void visitPre(DocHtmlCell *c)
bool hasLinkText() const
Definition: docparser.h:832
void visit(DocVerbatim *s)
void visit(DocFormula *f)
void visitPre(DocHtmlCaption *)
QCString anchor() const
Definition: docparser.h:295
bool refToTable() const
Definition: docparser.h:835
void visit(DocIndexEntry *i)
list x
Definition: train.py:276
void visitPost(DocHRef *)
void visitPost(DocHtmlDescTitle *)
bool enable() const
Definition: docparser.h:331
QCString chars() const
Definition: docparser.h:434
void visitPre(DocHtmlListItem *)
void visitPre(DocInternal *)
QCString title() const
Definition: docparser.h:671
void visitPost(DocSimpleList *)
void visitPre(DocHtmlDescTitle *)
Type type() const
Definition: docparser.h:449
void visitPre(DocHtmlHeader *header)
void visitPost(DocAutoList *l)
Type type() const
Definition: docparser.h:694
void visitPost(DocInternalRef *)
void visitPost(DocSecRefList *)
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
void visitPost(DocHtmlList *s)
void visitPre(DocPara *)
QCString target() const
Definition: docparser.h:965
void visitPre(DocHtmlBlockQuote *)
uint numColumns() const
Definition: docparser.h:1357
const char * utf8(DocSymbol::SymType symb, bool useInPrintf=FALSE) const
Access routine to the UTF8 code of the HTML entity.
Definition: htmlentity.cpp:366
void visitPre(DocVhdlFlow *)
void visitPre(DocLink *lnk)
QCString name() const
Definition: docparser.h:562
void visitPost(DocDiaFile *)
void visitPre(DocAutoList *l)
void visitPost(DocCopy *)