/****************************************************************************** * * * * * 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 * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #ifndef _PRINTDOCVISITOR_H #define _PRINTDOCVISITOR_H #include "docvisitor.h" #include "htmlentity.h" #include "emoji.h" #include "message.h" /*! Concrete visitor implementation for pretty printing */ class PrintDocVisitor : public DocVisitor { public: PrintDocVisitor() : DocVisitor(DocVisitor_Other), m_indent(0), m_needsEnter(FALSE), m_insidePre(FALSE) {} //-------------------------------------- void visit(DocWord *w) { indent_leaf(); printf("%s",qPrint(w->word())); } void visit(DocLinkedWord *w) { indent_leaf(); printf("%s",qPrint(w->word())); } void visit(DocWhiteSpace *w) { indent_leaf(); if (m_insidePre) { printf("%s",qPrint(w->chars())); } else { printf(" "); } } void visit(DocSymbol *s) { indent_leaf(); const char *res = HtmlEntityMapper::instance()->utf8(s->symbol(),TRUE); if (res) { printf("%s",res); } else { printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE)); } } void visit(DocEmoji *s) { indent_leaf(); const char *res = EmojiEntityMapper::instance()->name(s->index()); if (res) { printf("%s",res); } else { printf("print: non supported emoji found: %s\n",qPrint(s->name())); } } void visit(DocURL *u) { indent_leaf(); printf("%s",qPrint(u->url())); } void visit(DocLineBreak *) { indent_leaf(); printf("
"); } void visit(DocHorRuler *) { indent_leaf(); printf("
"); } void visit(DocStyleChange *s) { indent_leaf(); switch (s->style()) { case DocStyleChange::Bold: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::S: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Strike: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Del: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Underline: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Ins: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Italic: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Code: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Subscript: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Superscript: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Center: if (s->enable()) printf("
"); else printf("
"); break; case DocStyleChange::Small: if (s->enable()) printf(""); else printf(""); break; case DocStyleChange::Preformatted: if (s->enable()) printf("
"); else printf("
"); break; case DocStyleChange::Div: if (s->enable()) printf("
"); else printf("
"); break; case DocStyleChange::Span: if (s->enable()) printf(""); else printf(""); break; } } void visit(DocVerbatim *s) { indent_leaf(); switch(s->type()) { case DocVerbatim::Code: printf(""); break; case DocVerbatim::Verbatim: printf(""); break; case DocVerbatim::HtmlOnly: printf(""); break; case DocVerbatim::RtfOnly: printf(""); break; case DocVerbatim::ManOnly: printf(""); break; case DocVerbatim::LatexOnly: printf(""); break; case DocVerbatim::XmlOnly: printf(""); break; case DocVerbatim::DocbookOnly: printf(""); break; case DocVerbatim::Dot: printf(""); break; case DocVerbatim::Msc: printf(""); break; case DocVerbatim::PlantUML: printf(""); break; } printf("%s",qPrint(s->text())); switch(s->type()) { case DocVerbatim::Code: printf(""); break; case DocVerbatim::Verbatim: printf(""); break; case DocVerbatim::HtmlOnly: printf(""); break; case DocVerbatim::RtfOnly: printf(""); break; case DocVerbatim::ManOnly: printf(""); break; case DocVerbatim::LatexOnly: printf(""); break; case DocVerbatim::XmlOnly: printf(""); break; case DocVerbatim::DocbookOnly: printf(""); break; case DocVerbatim::Dot: printf(""); break; case DocVerbatim::Msc: printf(""); break; case DocVerbatim::PlantUML: printf(""); break; } } void visit(DocAnchor *a) { indent_leaf(); printf("",qPrint(a->anchor())); } void visit(DocInclude *inc) { indent_leaf(); printf("file())); switch(inc->type()) { case DocInclude::Include: printf("include"); break; case DocInclude::IncWithLines: printf("incwithlines"); break; case DocInclude::DontInclude: printf("dontinclude"); break; case DocInclude::DontIncWithLines: printf("dontinwithlines"); break; case DocInclude::HtmlInclude: printf("htmlinclude"); if (inc->isBlock()) printf(" block=\"yes\""); break; case DocInclude::LatexInclude: printf("latexinclude"); break; case DocInclude::RtfInclude: printf("rtfinclude"); break; case DocInclude::DocbookInclude: printf("docbookinclude"); break; case DocInclude::ManInclude: printf("maninclude"); break; case DocInclude::XmlInclude: printf("xmlinclude"); break; case DocInclude::VerbInclude: printf("verbinclude"); break; case DocInclude::Snippet: printf("snippet"); break; case DocInclude::SnipWithLines: printf("snipwithlines"); break; case DocInclude::SnippetDoc: case DocInclude::IncludeDoc: err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s" "Please create a bug report\n",__FILE__); break; } printf("\"/>"); } void visit(DocIncOperator *op) { indent_leaf(); printf("pattern())); switch(op->type()) { case DocIncOperator::Line: printf("line"); break; case DocIncOperator::Skip: printf("skip"); break; case DocIncOperator::SkipLine: printf("skipline"); break; case DocIncOperator::Until: printf("until"); break; } printf("\"/>"); } void visit(DocFormula *f) { indent_leaf(); printf("",qPrint(f->name()),qPrint(f->text())); } void visit(DocIndexEntry *i) { indent_leaf(); printf("%sentry())); } void visit(DocSimpleSectSep *) { indent_leaf(); printf(""); } void visit(DocCite *cite) { indent_leaf(); printf("\n", qPrint(cite->ref()),qPrint(cite->file()),qPrint(cite->anchor()), qPrint(cite->text())); } //-------------------------------------- void visitPre(DocAutoList *l) { indent_pre(); if (l->isEnumList()) { printf("
    \n"); } else { printf("
      \n"); } } void visitPost(DocAutoList *l) { indent_post(); if (l->isEnumList()) { printf("
\n"); } else { printf("\n"); } } void visitPre(DocAutoListItem *) { indent_pre(); printf("
  • \n"); } void visitPost(DocAutoListItem *) { indent_post(); printf("
  • \n"); } void visitPre(DocPara *) { indent_pre(); printf("\n"); } void visitPost(DocPara *) { indent_post(); printf("\n"); } void visitPre(DocRoot *) { indent_pre(); printf("\n"); } void visitPost(DocRoot *) { indent_post(); printf("\n"); } void visitPre(DocSimpleSect *s) { indent_pre(); printf("\n"); } void visitPost(DocSimpleSect *) { indent_post(); printf("\n"); } void visitPre(DocTitle *) { indent_pre(); printf("\n"); } void visitPost(DocTitle *) { indent_post(); printf("\n"); } void visitPre(DocSimpleList *) { indent_pre(); printf("
      \n"); } void visitPost(DocSimpleList *) { indent_post(); printf("
    \n"); } void visitPre(DocSimpleListItem *) { indent_pre(); printf("
  • \n"); } void visitPost(DocSimpleListItem *) { indent_post(); printf("
  • \n"); } void visitPre(DocSection *s) { indent_pre(); printf("\n",s->level()); } void visitPost(DocSection *s) { indent_post(); printf("\n",s->level()); } void visitPre(DocHtmlList *s) { indent_pre(); if (s->type()==DocHtmlList::Ordered) { printf("attribs()) { printf(" %s=\"%s\"",qPrint(opt.name),qPrint(opt.value)); } printf(">\n"); } else printf("
      \n"); } void visitPost(DocHtmlList *s) { indent_post(); if (s->type()==DocHtmlList::Ordered) printf("\n"); else printf("
    \n"); } void visitPre(DocHtmlListItem *) { indent_pre(); printf("
  • \n"); } void visitPost(DocHtmlListItem *) { indent_post(); printf("
  • \n"); } //void visitPre(DocHtmlPre *) //{ // indent_pre(); // printf("
    \n");
        //  m_insidePre=TRUE;
        //}
        //void visitPost(DocHtmlPre *)
        //{
        //  m_insidePre=FALSE;
        //  indent_post();
        //  printf("
    \n"); //} void visitPre(DocHtmlDescList *) { indent_pre(); printf("
    \n"); } void visitPost(DocHtmlDescList *) { indent_post(); printf("
    \n"); } void visitPre(DocHtmlDescTitle *) { indent_pre(); printf("
    \n"); } void visitPost(DocHtmlDescTitle *) { indent_post(); printf("
    \n"); } void visitPre(DocHtmlDescData *) { indent_pre(); printf("
    \n"); } void visitPost(DocHtmlDescData *) { indent_post(); printf("
    \n"); } void visitPre(DocHtmlTable *t) { indent_pre(); printf("\n", t->numRows(),t->numColumns()); } void visitPost(DocHtmlTable *) { indent_post(); printf("
    \n"); } void visitPre(DocHtmlRow *) { indent_pre(); printf("\n"); } void visitPost(DocHtmlRow *) { indent_post(); printf("\n"); } void visitPre(DocHtmlCell *c) { indent_pre(); printf("\n",c->isHeading()?'h':'d'); } void visitPost(DocHtmlCell *c) { indent_post(); printf("\n",c->isHeading()?'h':'d'); } void visitPre(DocHtmlCaption *) { indent_pre(); printf("\n"); } void visitPost(DocHtmlCaption *) { indent_post(); printf("\n"); } void visitPre(DocInternal *) { indent_pre(); printf("\n"); } void visitPost(DocInternal *) { indent_post(); printf("\n"); } void visitPre(DocHRef *href) { indent_pre(); printf("\n",qPrint(href->url())); } void visitPost(DocHRef *) { indent_post(); printf("\n"); } void visitPre(DocHtmlHeader *header) { indent_pre(); printf("\n",header->level()); } void visitPost(DocHtmlHeader *header) { indent_post(); printf("\n",header->level()); } void visitPre(DocImage *img) { indent_pre(); printf("name())); switch(img->type()) { case DocImage::Html: printf("html"); break; case DocImage::Latex: printf("latex"); break; case DocImage::Rtf: printf("rtf"); break; case DocImage::DocBook: printf("docbook"); break; } printf("\" %s %s inline=\"%s\">\n",qPrint(img->width()),qPrint(img->height()),img->isInlineImage() ? "yes" : "no"); } void visitPost(DocImage *) { indent_post(); printf("\n"); } void visitPre(DocDotFile *df) { indent_pre(); printf("\n",qPrint(df->name())); } void visitPost(DocDotFile *) { indent_post(); printf("\n"); } void visitPre(DocMscFile *df) { indent_pre(); printf("\n",qPrint(df->name())); } void visitPost(DocMscFile *) { indent_post(); printf("\n"); } void visitPre(DocDiaFile *df) { indent_pre(); printf("\n",qPrint(df->name())); } void visitPost(DocDiaFile *) { indent_post(); printf("\n"); } void visitPre(DocLink *lnk) { indent_pre(); printf("\n", qPrint(lnk->ref()),qPrint(lnk->file()),qPrint(lnk->anchor())); } void visitPost(DocLink *) { indent_post(); printf("\n"); } void visitPre(DocRef *ref) { indent_pre(); printf("\n", qPrint(ref->ref()),qPrint(ref->file()),qPrint(ref->anchor()), qPrint(ref->targetTitle()),ref->hasLinkText()?"yes":"no", ref->refToAnchor()?"yes":"no", ref->refToSection()?"yes":"no", ref->refToTable()?"yes":"no"); } void visitPost(DocRef *) { indent_post(); printf("\n"); } void visitPre(DocSecRefItem *ref) { indent_pre(); printf("\n",qPrint(ref->target())); } void visitPost(DocSecRefItem *) { indent_post(); printf("\n"); } void visitPre(DocSecRefList *) { indent_pre(); printf("\n"); } void visitPost(DocSecRefList *) { indent_post(); printf("\n"); } //void visitPre(DocLanguage *l) //{ // indent_pre(); // printf("\n",qPrint(l->id())); //} //void visitPost(DocLanguage *) //{ // indent_post(); // printf("\n"); //} void visitPre(DocParamList *pl) { indent_pre(); printf(""); if (!pl->parameters().empty()) { printf(""); for (const auto ¶m : pl->parameters()) { if (param->kind()==DocNode::Kind_Word) { visit((DocWord*)param.get()); } else if (param->kind()==DocNode::Kind_LinkedWord) { visit((DocLinkedWord*)param.get()); } else if (param->kind()==DocNode::Kind_Sep) { printf(""); printf(""); } } printf(""); } printf("\n"); } void visitPost(DocParamList *) { indent_post(); printf("\n"); } void visitPre(DocParamSect *ps) { indent_pre(); printf("\n"); } void visitPost(DocParamSect *) { indent_post(); printf("\n"); } void visitPre(DocXRefItem *x) { indent_pre(); printf("\n", qPrint(x->file()),qPrint(x->anchor()),qPrint(x->title())); } void visitPost(DocXRefItem *) { indent_post(); printf("\n"); } void visitPre(DocInternalRef *r) { indent_pre(); printf("\n",qPrint(r->file()),qPrint(r->anchor())); } void visitPost(DocInternalRef *) { indent_post(); printf("\n"); } void visitPre(DocText *) { indent_pre(); printf("\n"); } void visitPost(DocText *) { indent_post(); printf("\n"); } void visitPre(DocHtmlBlockQuote *) { indent_pre(); printf("
    \n"); } void visitPost(DocHtmlBlockQuote *) { indent_post(); printf("
    \n"); } void visitPre(DocVhdlFlow *) { indent_pre(); printf("\n"); } void visitPost(DocVhdlFlow *) { indent_post(); printf("\n"); } void visitPre(DocParBlock *) { indent_pre(); printf("\n"); } void visitPost(DocParBlock *) { indent_post(); printf("\n"); } private: // helper functions void indent() { if (m_needsEnter) printf("\n"); for (int i=0;i