/******************************************************************************
*
*
*
*
* 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 "htmlentity.h"
#include "emoji.h"
#include "message.h"
/*! Visitor implementation for pretty printing */
class PrintDocVisitor
{
public:
PrintDocVisitor() : m_indent(0), m_needsEnter(FALSE), m_insidePre(FALSE) {}
//--------------------------------------
void operator()(const DocWord &w)
{
indent_leaf();
printf("%s",qPrint(w.word()));
}
void operator()(const DocLinkedWord &w)
{
indent_leaf();
printf("%s",qPrint(w.word()));
}
void operator()(const DocWhiteSpace &w)
{
indent_leaf();
if (m_insidePre)
{
printf("%s",qPrint(w.chars()));
}
else
{
printf(" ");
}
}
void operator()(const 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 operator()(const 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 operator()(const DocURL &u)
{
indent_leaf();
printf("%s",qPrint(u.url()));
}
void operator()(const DocLineBreak &)
{
indent_leaf();
printf(" ");
}
void operator()(const DocHorRuler &)
{
indent_leaf();
printf("
");
}
void operator()(const 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::Cite:
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;
case DocStyleChange::Summary:
if (s.enable())
{
indent_pre();
printf("\n");
}
else
{
indent_post();
printf("\n");
}
break;
}
}
void operator()(const DocVerbatim &s)
{
indent_leaf();
switch(s.type())
{
case DocVerbatim::Code: printf(""); break;
case DocVerbatim::Verbatim: printf(""); break;
case DocVerbatim::JavaDocLiteral: printf(""); break;
case DocVerbatim::JavaDocCode: 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::JavaDocLiteral: printf(""); break;
case DocVerbatim::JavaDocCode: 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 operator()(const DocAnchor &a)
{
indent_leaf();
printf("",qPrint(a.anchor()));
}
void operator()(const DocInclude &inc)
{
indent_leaf();
printf("");
}
void operator()(const DocIncOperator &op)
{
indent_leaf();
printf("");
}
void operator()(const DocFormula &f)
{
indent_leaf();
printf("",qPrint(f.name()),qPrint(f.text()));
}
void operator()(const DocIndexEntry &i)
{
indent_leaf();
printf("%s");
}
void operator()(const DocCite &cite)
{
indent_leaf();
printf("\n",
qPrint(cite.ref()),qPrint(cite.file()),qPrint(cite.anchor()),
qPrint(cite.text()));
}
void operator()(const DocSeparator &)
{
indent_leaf();
printf("");
}
//--------------------------------------
template
void visitChildren(const T &t)
{
for (const auto &child : t.children())
{
std::visit(*this, child);
}
}
void operator()(const DocAutoList &l)
{
indent_pre();
if (l.isEnumList())
{
printf("\n");
}
else
{
printf("
\n");
}
visitChildren(l);
indent_post();
if (l.isEnumList())
{
printf("