/****************************************************************************** * * * * * Copyright (C) 1997-2013 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 #include "docvisitor.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",w->word().data()); } void visit(DocLinkedWord *w) { indent_leaf(); printf("%s",w->word().data()); } void visit(DocWhiteSpace *w) { indent_leaf(); if (m_insidePre) { printf("%s",w->chars().data()); } else { printf(" "); } } void visit(DocSymbol *s) { indent_leaf(); switch(s->symbol()) { case DocSymbol::BSlash: printf("\\"); break; case DocSymbol::At: printf("@"); break; case DocSymbol::Less: printf("<"); break; case DocSymbol::Greater: printf(">"); break; case DocSymbol::Amp: printf("&"); break; case DocSymbol::Dollar: printf("$"); break; case DocSymbol::Hash: printf("#"); break; case DocSymbol::Percent: printf("%%"); break; case DocSymbol::Pipe: printf("|"); break; case DocSymbol::Copy: printf("©"); break; case DocSymbol::Apos: printf("'"); break; case DocSymbol::Quot: printf("\""); break; case DocSymbol::Lsquo: printf("‘"); break; case DocSymbol::Rsquo: printf("’"); break; case DocSymbol::Ldquo: printf("“"); break; case DocSymbol::Rdquo: printf("”"); break; case DocSymbol::Ndash: printf("–"); break; case DocSymbol::Mdash: printf("—"); break; case DocSymbol::Uml: printf("&%cuml;",s->letter()); break; case DocSymbol::Acute: printf("&%cacute;",s->letter()); break; case DocSymbol::Grave: printf("&%cgrave;",s->letter()); break; case DocSymbol::Circ: printf("&%ccirc;",s->letter()); break; case DocSymbol::Tilde: printf("&%ctilde;",s->letter()); break; case DocSymbol::Szlig: printf("ß"); break; case DocSymbol::Cedil: printf("&%ccedul;",s->letter()); break; case DocSymbol::Ring: printf("&%cring;",s->letter()); break; case DocSymbol::Nbsp: printf(" "); break; case DocSymbol::Aelig: printf("æ"); break; case DocSymbol::AElig: printf("Æ"); break; case DocSymbol::GrkGamma: printf("Γ"); break; case DocSymbol::GrkDelta: printf("Δ"); break; case DocSymbol::GrkTheta: printf("Θ"); break; case DocSymbol::GrkLambda: printf("Λ"); break; case DocSymbol::GrkXi: printf("Ξ"); break; case DocSymbol::GrkPi: printf("Π"); break; case DocSymbol::GrkSigma: printf("Σ"); break; case DocSymbol::GrkUpsilon: printf("Υ"); break; case DocSymbol::GrkPhi: printf("Φ"); break; case DocSymbol::GrkPsi: printf("Ψ"); break; case DocSymbol::GrkOmega: printf("Ω"); break; case DocSymbol::Grkalpha: printf("α"); break; case DocSymbol::Grkbeta: printf("β"); break; case DocSymbol::Grkgamma: printf("γ"); break; case DocSymbol::Grkdelta: printf("δ"); break; case DocSymbol::Grkepsilon: printf("ε"); break; case DocSymbol::Grkzeta: printf("ζ"); break; case DocSymbol::Grketa: printf("η"); break; case DocSymbol::Grktheta: printf("θ"); break; case DocSymbol::Grkiota: printf("ι"); break; case DocSymbol::Grkkappa: printf("κ"); break; case DocSymbol::Grklambda: printf("λ"); break; case DocSymbol::Grkmu: printf("μ"); break; case DocSymbol::Grknu: printf("ν"); break; case DocSymbol::Grkxi: printf("ξ"); break; case DocSymbol::Grkpi: printf("π"); break; case DocSymbol::Grkrho: printf("ρ"); break; case DocSymbol::Grksigma: printf("σ"); break; case DocSymbol::Grktau: printf("τ"); break; case DocSymbol::Grkupsilon: printf("υ"); break; case DocSymbol::Grkphi: printf("φ"); break; case DocSymbol::Grkchi: printf("χ"); break; case DocSymbol::Grkpsi: printf("ψ"); break; case DocSymbol::Grkomega: printf("ω"); break; case DocSymbol::Grkvarsigma: printf("ς"); break; case DocSymbol::Section: printf("§"); break; case DocSymbol::Degree: printf("°"); break; case DocSymbol::Prime: printf("′"); break; case DocSymbol::DoublePrime: printf("″"); break; case DocSymbol::Infinity: printf("∞"); break; case DocSymbol::EmptySet: printf("∅"); break; case DocSymbol::PlusMinus: printf("±"); break; case DocSymbol::Times: printf("×"); break; case DocSymbol::Minus: printf("−"); break; case DocSymbol::CenterDot: printf("⋅"); break; case DocSymbol::Partial: printf("∂"); break; case DocSymbol::Nabla: printf("∇"); break; case DocSymbol::SquareRoot: printf("√"); break; case DocSymbol::Perpendicular: printf("⊥"); break; case DocSymbol::Sum: printf("∑"); break; case DocSymbol::Integral: printf("∫"); break; case DocSymbol::Product: printf("∏"); break; case DocSymbol::Similar: printf("∼"); break; case DocSymbol::Approx: printf("≈"); break; case DocSymbol::NotEqual: printf("≠"); break; case DocSymbol::Equivalent: printf("≡"); break; case DocSymbol::Proportional: printf("∝"); break; case DocSymbol::LessEqual: printf("≤"); break; case DocSymbol::GreaterEqual: printf("≥"); break; case DocSymbol::LeftArrow: printf("←"); break; case DocSymbol::RightArrow: printf("→"); break; case DocSymbol::SetIn: printf("∈"); break; case DocSymbol::SetNotIn: printf("∉"); break; case DocSymbol::LeftCeil: printf("⌈"); break; case DocSymbol::RightCeil: printf("⌉"); break; case DocSymbol::LeftFloor: printf("⌊"); break; case DocSymbol::RightFloor: printf("⌋"); break; default: printf("unknown symbol found\n"); } } void visit(DocURL *u) { indent_leaf(); printf("%s",u->url().data()); } 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::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; } printf("%s",s->text().data()); 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; } } void visit(DocAnchor *a) { indent_leaf(); printf("",a->anchor().data()); } void visit(DocInclude *inc) { indent_leaf(); printf("file().data()); switch(inc->type()) { case DocInclude::Include: printf("include"); break; case DocInclude::IncWithLines: printf("incwithlines"); break; case DocInclude::DontInclude: printf("dontinclude"); break; case DocInclude::HtmlInclude: printf("htmlinclude"); break; case DocInclude::VerbInclude: printf("verbinclude"); break; case DocInclude::Snippet: printf("snippet"); break; } printf("\"/>"); } void visit(DocIncOperator *op) { indent_leaf(); printf("pattern().data()); 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("",f->name().data(),f->text().data()); } void visit(DocIndexEntry *i) { indent_leaf(); printf("%sentry().data()); } void visit(DocSimpleSectSep *) { indent_leaf(); printf(""); } void visit(DocCite *cite) { indent_leaf(); printf("\n", cite->ref().data(),cite->file().data(),cite->anchor().data(), cite->text().data()); } //-------------------------------------- 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("
      \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",href->url().data()); } 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().data()); switch(img->type()) { case DocImage::Html: printf("html"); break; case DocImage::Latex: printf("latex"); break; case DocImage::Rtf: printf("rtf"); break; } printf("\" width=%s height=%s>\n",img->width().data(),img->height().data()); } void visitPost(DocImage *) { indent_post(); printf("\n"); } void visitPre(DocDotFile *df) { indent_pre(); printf("\n",df->name().data()); } void visitPost(DocDotFile *) { indent_post(); printf("\n"); } void visitPre(DocMscFile *df) { indent_pre(); printf("\n",df->name().data()); } void visitPost(DocMscFile *) { indent_post(); printf("\n"); } void visitPre(DocDiaFile *df) { indent_pre(); printf("\n",df->name().data()); } void visitPost(DocDiaFile *) { indent_post(); printf("\n"); } void visitPre(DocLink *lnk) { indent_pre(); printf("\n", lnk->ref().data(),lnk->file().data(),lnk->anchor().data()); } void visitPost(DocLink *) { indent_post(); printf("\n"); } void visitPre(DocRef *ref) { indent_pre(); printf("\n", ref->ref().data(),ref->file().data(),ref->anchor().data(), ref->targetTitle().data(),ref->hasLinkText()?"yes":"no", ref->refToAnchor()?"yes":"no", ref->refToSection()?"yes":"no"); } void visitPost(DocRef *) { indent_post(); printf("\n"); } void visitPre(DocSecRefItem *ref) { indent_pre(); printf("\n",ref->target().data()); } 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",l->id().data()); //} //void visitPost(DocLanguage *) //{ // indent_post(); // printf("\n"); //} void visitPre(DocParamList *pl) { indent_pre(); //QStrListIterator sli(pl->parameters()); QListIterator sli(pl->parameters()); //const char *s; DocNode *param; printf(""); for (sli.toFirst();(param=sli.current());++sli) { printf(""); if (param->kind()==DocNode::Kind_Word) { visit((DocWord*)param); } else if (param->kind()==DocNode::Kind_LinkedWord) { visit((DocLinkedWord*)param); } 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", x->file().data(),x->anchor().data(),x->title().data()); } void visitPost(DocXRefItem *) { indent_post(); printf("\n"); } void visitPre(DocInternalRef *r) { indent_pre(); printf("\n",r->file().data(),r->anchor().data()); } void visitPost(DocInternalRef *) { indent_post(); printf("\n"); } void visitPre(DocCopy *c) { indent_pre(); printf("\n",c->link().data()); } void visitPost(DocCopy *) { 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