Doxygen
Loading...
Searching...
No Matches
textdocvisitor.cpp
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#include "textdocvisitor.h"
20#include "message.h"
21#include "util.h"
22#include "htmlentity.h"
23#include "cite.h"
24#include "emoji.h"
25
26//-------------------------------------------------------------------------
27
29{
30 const char *res = HtmlEntityMapper::instance().html(s.symbol());
31 if (res)
32 {
33 m_t << res;
34 }
35 else
36 {
37 err("text: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
38 }
39}
40
42{
43 // the TextDocVisitor is only invoked for the JS part of the HTML output
44 const char *res = EmojiEntityMapper::instance().unicode(s.index());
45 if (res)
46 {
47 const char *p = res;
48 while (*p)
49 {
50 switch(*p)
51 {
52 case '&': case '#':
53 break;
54 case 'x':
55 m_t << "\\u{";
56 break;
57 case ';':
58 m_t << "}";
59 break;
60 default:
61 m_t << *p;
62 break;
63 }
64 p++;
65 }
66 }
67 else
68 {
69 filter(s.name());
70 }
71}
72
74{
75 if (!cite.file().isEmpty())
76 {
77 QCString anchor = cite.anchor();
79 anchor = anchor.mid(anchorPrefix.length()); // strip prefix
80 m_t << anchor;
81 }
82 else
83 {
84 filter(cite.text());
85 }
86}
87
89{
90 if (str.isEmpty()) return;
91 //printf("TextDocVisitor::filter(%s)\n",str);
92 const char *p=str.data();
93 while (*p)
94 {
95 char c = *p++;
96 if (c=='\n') c=' ';
97 else m_t << c;
98 }
99}
100
QCString anchorPrefix() const
Definition cite.cpp:122
static CitationManager & instance()
Definition cite.cpp:80
Node representing a citation of some bibliographic reference.
Definition docnode.h:244
QCString text() const
Definition docnode.h:251
QCString anchor() const
Definition docnode.h:250
QCString file() const
Definition docnode.h:247
Node representing an emoji.
Definition docnode.h:336
int index() const
Definition docnode.h:340
QCString name() const
Definition docnode.h:339
Node representing a special symbol.
Definition docnode.h:323
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:327
const char * unicode(int index) const
Access routine to the unicode sequence for the Emoji entity.
Definition emoji.cpp:2016
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1978
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
const char * html(SymType symb, bool useInPrintf=FALSE) const
Access routine to the html code of the HTML entity.
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
void filter(const QCString &str)
TextStream & m_t
void operator()(const DocWord &w)
#define err(fmt,...)
Definition message.h:84
#define TRUE
Definition qcstring.h:37
A bunch of utility functions.