Root/
Source at commit 1322 created 12 years 7 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * $Id: $␊ |
4 | *␊ |
5 | *␊ |
6 | * Copyright (C) 1997-2011 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 "xmldocvisitor.h"␊ |
20 | #include "docparser.h"␊ |
21 | #include "language.h"␊ |
22 | #include "doxygen.h"␊ |
23 | #include "outputgen.h"␊ |
24 | #include "xmlgen.h"␊ |
25 | #include "dot.h"␊ |
26 | #include "message.h"␊ |
27 | #include "util.h"␊ |
28 | #include <qfileinfo.h> ␊ |
29 | #include "parserintf.h"␊ |
30 | ␊ |
31 | XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci) ␊ |
32 | : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) ␊ |
33 | {␊ |
34 | }␊ |
35 | ␊ |
36 | //--------------------------------------␊ |
37 | // visitor functions for leaf nodes␊ |
38 | //--------------------------------------␊ |
39 | ␊ |
40 | void XmlDocVisitor::visit(DocWord *w)␊ |
41 | {␊ |
42 | if (m_hide) return;␊ |
43 | filter(w->word());␊ |
44 | }␊ |
45 | ␊ |
46 | void XmlDocVisitor::visit(DocLinkedWord *w)␊ |
47 | {␊ |
48 | if (m_hide) return;␊ |
49 | startLink(w->ref(),w->file(),w->anchor());␊ |
50 | filter(w->word());␊ |
51 | endLink();␊ |
52 | }␊ |
53 | ␊ |
54 | void XmlDocVisitor::visit(DocWhiteSpace *w)␊ |
55 | {␊ |
56 | if (m_hide) return;␊ |
57 | if (m_insidePre)␊ |
58 | {␊ |
59 | m_t << w->chars();␊ |
60 | }␊ |
61 | else␊ |
62 | {␊ |
63 | m_t << " ";␊ |
64 | }␊ |
65 | }␊ |
66 | ␊ |
67 | void XmlDocVisitor::visit(DocSymbol *s)␊ |
68 | {␊ |
69 | if (m_hide) return;␊ |
70 | switch(s->symbol())␊ |
71 | {␊ |
72 | case DocSymbol::BSlash: m_t << "\\"; break;␊ |
73 | case DocSymbol::At: m_t << "@"; break;␊ |
74 | case DocSymbol::Less: m_t << "<"; break;␊ |
75 | case DocSymbol::Greater: m_t << ">"; break;␊ |
76 | case DocSymbol::Amp: m_t << "&"; break;␊ |
77 | case DocSymbol::Dollar: m_t << "$"; break;␊ |
78 | case DocSymbol::Hash: m_t << "#"; break;␊ |
79 | case DocSymbol::DoubleColon: m_t << "::"; break;␊ |
80 | case DocSymbol::Percent: m_t << "%"; break;␊ |
81 | case DocSymbol::Copy: m_t << "<copy/>"; break;␊ |
82 | case DocSymbol::Tm: m_t << "<trademark/>"; break;␊ |
83 | case DocSymbol::Reg: m_t << "<registered/>"; break;␊ |
84 | case DocSymbol::Apos: m_t << "'"; break;␊ |
85 | case DocSymbol::Quot: m_t << "\""; break;␊ |
86 | case DocSymbol::Lsquo: m_t << "<lsquo/>"; break;␊ |
87 | case DocSymbol::Rsquo: m_t << "<rsquo/>"; break;␊ |
88 | case DocSymbol::Ldquo: m_t << "<ldquo/>"; break;␊ |
89 | case DocSymbol::Rdquo: m_t << "<rdquo/>"; break;␊ |
90 | case DocSymbol::Ndash: m_t << "<ndash/>"; break;␊ |
91 | case DocSymbol::Mdash: m_t << "<mdash/>"; break;␊ |
92 | case DocSymbol::Uml: m_t << "<umlaut char=\"" << s->letter() << "\"/>"; break;␊ |
93 | case DocSymbol::Acute: m_t << "<acute char=\"" << s->letter() << "\"/>"; break;␊ |
94 | case DocSymbol::Grave: m_t << "<grave char=\"" << s->letter() << "\"/>"; break;␊ |
95 | case DocSymbol::Circ: m_t << "<circ char=\"" << s->letter() << "\"/>"; break;␊ |
96 | case DocSymbol::Tilde: m_t << "<tilde char=\"" << s->letter() << "\"/>"; break;␊ |
97 | case DocSymbol::Szlig: m_t << "<szlig/>"; break;␊ |
98 | case DocSymbol::Cedil: m_t << "<cedil char=\"" << s->letter() << "\"/>"; break;␊ |
99 | case DocSymbol::Ring: m_t << "<ring char=\"" << s->letter() << "\"/>"; break;␊ |
100 | case DocSymbol::Slash: m_t << "<slash char=\"" << s->letter() << "\"/>"; break;␊ |
101 | case DocSymbol::Nbsp: m_t << "<nonbreakablespace/>"; break;␊ |
102 | case DocSymbol::Aelig: m_t << "<aelig/>"; break;␊ |
103 | case DocSymbol::AElig: m_t << "<AElig/>"; break;␊ |
104 | default:␊ |
105 | err("error: unknown symbol found\n");␊ |
106 | }␊ |
107 | }␊ |
108 | ␊ |
109 | void XmlDocVisitor::visit(DocURL *u)␊ |
110 | {␊ |
111 | if (m_hide) return;␊ |
112 | m_t << "<ulink url=\""; ␊ |
113 | if (u->isEmail()) m_t << "mailto:";␊ |
114 | filter(u->url());␊ |
115 | m_t << "\">";␊ |
116 | filter(u->url());␊ |
117 | m_t << "</ulink>";␊ |
118 | }␊ |
119 | ␊ |
120 | void XmlDocVisitor::visit(DocLineBreak *)␊ |
121 | {␊ |
122 | if (m_hide) return;␊ |
123 | m_t << "<linebreak/>\n";␊ |
124 | }␊ |
125 | ␊ |
126 | void XmlDocVisitor::visit(DocHorRuler *)␊ |
127 | {␊ |
128 | if (m_hide) return;␊ |
129 | m_t << "<hruler/>\n";␊ |
130 | }␊ |
131 | ␊ |
132 | void XmlDocVisitor::visit(DocStyleChange *s)␊ |
133 | {␊ |
134 | if (m_hide) return;␊ |
135 | switch (s->style())␊ |
136 | {␊ |
137 | case DocStyleChange::Bold:␊ |
138 | if (s->enable()) m_t << "<bold>"; else m_t << "</bold>";␊ |
139 | break;␊ |
140 | case DocStyleChange::Italic:␊ |
141 | if (s->enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";␊ |
142 | break;␊ |
143 | case DocStyleChange::Code:␊ |
144 | if (s->enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";␊ |
145 | break;␊ |
146 | case DocStyleChange::Subscript:␊ |
147 | if (s->enable()) m_t << "<subscript>"; else m_t << "</subscript>";␊ |
148 | break;␊ |
149 | case DocStyleChange::Superscript:␊ |
150 | if (s->enable()) m_t << "<superscript>"; else m_t << "</superscript>";␊ |
151 | break;␊ |
152 | case DocStyleChange::Center:␊ |
153 | if (s->enable()) m_t << "<center>"; else m_t << "</center>";␊ |
154 | break;␊ |
155 | case DocStyleChange::Small:␊ |
156 | if (s->enable()) m_t << "<small>"; else m_t << "</small>";␊ |
157 | break;␊ |
158 | case DocStyleChange::Preformatted:␊ |
159 | if (s->enable()) ␊ |
160 | {␊ |
161 | m_t << "<preformatted>"; ␊ |
162 | m_insidePre=TRUE;␊ |
163 | }␊ |
164 | else ␊ |
165 | {␊ |
166 | m_t << "</preformatted>";␊ |
167 | m_insidePre=FALSE;␊ |
168 | }␊ |
169 | break;␊ |
170 | case DocStyleChange::Div: /* HTML only */ break;␊ |
171 | case DocStyleChange::Span: /* HTML only */ break;␊ |
172 | }␊ |
173 | }␊ |
174 | ␊ |
175 | void XmlDocVisitor::visit(DocVerbatim *s)␊ |
176 | {␊ |
177 | if (m_hide) return;␊ |
178 | switch(s->type())␊ |
179 | {␊ |
180 | case DocVerbatim::Code: // fall though␊ |
181 | m_t << "<programlisting>"; ␊ |
182 | Doxygen::parserManager->getParser(m_langExt)␊ |
183 | ->parseCode(m_ci,s->context(),s->text(),␊ |
184 | s->isExample(),s->exampleFile());␊ |
185 | m_t << "</programlisting>"; ␊ |
186 | break;␊ |
187 | case DocVerbatim::Verbatim: ␊ |
188 | m_t << "<verbatim>";␊ |
189 | filter(s->text());␊ |
190 | m_t << "</verbatim>"; ␊ |
191 | break;␊ |
192 | case DocVerbatim::HtmlOnly: ␊ |
193 | m_t << "<htmlonly>";␊ |
194 | filter(s->text());␊ |
195 | m_t << "</htmlonly>";␊ |
196 | break;␊ |
197 | case DocVerbatim::ManOnly: ␊ |
198 | m_t << "<manonly>";␊ |
199 | filter(s->text());␊ |
200 | m_t << "</manonly>";␊ |
201 | break;␊ |
202 | case DocVerbatim::LatexOnly: ␊ |
203 | m_t << "<latexonly>";␊ |
204 | filter(s->text());␊ |
205 | m_t << "</latexonly>";␊ |
206 | break;␊ |
207 | case DocVerbatim::XmlOnly: ␊ |
208 | m_t << s->text();␊ |
209 | break;␊ |
210 | case DocVerbatim::Dot: ␊ |
211 | m_t << "<dot>";␊ |
212 | filter(s->text());␊ |
213 | m_t << "</dot>";␊ |
214 | break;␊ |
215 | case DocVerbatim::Msc: ␊ |
216 | m_t << "<msc>";␊ |
217 | filter(s->text());␊ |
218 | m_t << "</msc>";␊ |
219 | break;␊ |
220 | }␊ |
221 | }␊ |
222 | ␊ |
223 | void XmlDocVisitor::visit(DocAnchor *anc)␊ |
224 | {␊ |
225 | if (m_hide) return;␊ |
226 | m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>";␊ |
227 | }␊ |
228 | ␊ |
229 | void XmlDocVisitor::visit(DocInclude *inc)␊ |
230 | {␊ |
231 | if (m_hide) return;␊ |
232 | switch(inc->type())␊ |
233 | {␊ |
234 | case DocInclude::IncWithLines:␊ |
235 | { ␊ |
236 | m_t << "<programlisting>";␊ |
237 | QFileInfo cfi( inc->file() );␊ |
238 | FileDef fd( cfi.dirPath(), cfi.fileName() );␊ |
239 | Doxygen::parserManager->getParser(inc->extension())␊ |
240 | ->parseCode(m_ci,inc->context(),␊ |
241 | inc->text(),␊ |
242 | inc->isExample(),␊ |
243 | inc->exampleFile(), &fd);␊ |
244 | m_t << "</programlisting>"; ␊ |
245 | }␊ |
246 | break; ␊ |
247 | case DocInclude::Include: ␊ |
248 | m_t << "<programlisting>";␊ |
249 | Doxygen::parserManager->getParser(inc->extension())␊ |
250 | ->parseCode(m_ci,inc->context(),␊ |
251 | inc->text(),␊ |
252 | inc->isExample(),␊ |
253 | inc->exampleFile());␊ |
254 | m_t << "</programlisting>"; ␊ |
255 | break;␊ |
256 | case DocInclude::DontInclude: ␊ |
257 | break;␊ |
258 | case DocInclude::HtmlInclude: ␊ |
259 | m_t << "<htmlonly>";␊ |
260 | filter(inc->text());␊ |
261 | m_t << "</htmlonly>";␊ |
262 | break;␊ |
263 | case DocInclude::VerbInclude: ␊ |
264 | m_t << "<verbatim>";␊ |
265 | filter(inc->text());␊ |
266 | m_t << "</verbatim>"; ␊ |
267 | break;␊ |
268 | }␊ |
269 | }␊ |
270 | ␊ |
271 | void XmlDocVisitor::visit(DocIncOperator *op)␊ |
272 | {␊ |
273 | //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",␊ |
274 | // op->type(),op->isFirst(),op->isLast(),op->text().data());␊ |
275 | if (op->isFirst()) ␊ |
276 | {␊ |
277 | if (!m_hide)␊ |
278 | {␊ |
279 | m_t << "<programlisting>";␊ |
280 | }␊ |
281 | pushEnabled();␊ |
282 | m_hide = TRUE;␊ |
283 | }␊ |
284 | if (op->type()!=DocIncOperator::Skip) ␊ |
285 | {␊ |
286 | popEnabled();␊ |
287 | if (!m_hide) ␊ |
288 | {␊ |
289 | Doxygen::parserManager->getParser(m_langExt)␊ |
290 | ->parseCode(m_ci,op->context(),␊ |
291 | op->text(),op->isExample(),␊ |
292 | op->exampleFile());␊ |
293 | }␊ |
294 | pushEnabled();␊ |
295 | m_hide=TRUE;␊ |
296 | }␊ |
297 | if (op->isLast()) ␊ |
298 | {␊ |
299 | popEnabled();␊ |
300 | if (!m_hide) m_t << "</programlisting>"; ␊ |
301 | }␊ |
302 | else␊ |
303 | {␊ |
304 | if (!m_hide) m_t << endl;␊ |
305 | }␊ |
306 | }␊ |
307 | ␊ |
308 | void XmlDocVisitor::visit(DocFormula *f)␊ |
309 | {␊ |
310 | if (m_hide) return;␊ |
311 | m_t << "<formula id=\"" << f->id() << "\">";␊ |
312 | filter(f->text());␊ |
313 | m_t << "</formula>";␊ |
314 | }␊ |
315 | ␊ |
316 | void XmlDocVisitor::visit(DocIndexEntry *ie)␊ |
317 | {␊ |
318 | if (m_hide) return;␊ |
319 | m_t << "<indexentry>"␊ |
320 | "<primaryie>";␊ |
321 | filter(ie->entry());␊ |
322 | m_t << "</primaryie>"␊ |
323 | "<secondaryie></secondaryie>"␊ |
324 | "</indexentry>";␊ |
325 | }␊ |
326 | ␊ |
327 | void XmlDocVisitor::visit(DocSimpleSectSep *)␊ |
328 | {␊ |
329 | m_t << "<simplesectsep/>";␊ |
330 | }␊ |
331 | ␊ |
332 | //--------------------------------------␊ |
333 | // visitor functions for compound nodes␊ |
334 | //--------------------------------------␊ |
335 | ␊ |
336 | void XmlDocVisitor::visitPre(DocAutoList *l)␊ |
337 | {␊ |
338 | if (m_hide) return;␊ |
339 | if (l->isEnumList())␊ |
340 | {␊ |
341 | m_t << "<orderedlist>\n";␊ |
342 | }␊ |
343 | else␊ |
344 | {␊ |
345 | m_t << "<itemizedlist>\n";␊ |
346 | }␊ |
347 | }␊ |
348 | ␊ |
349 | void XmlDocVisitor::visitPost(DocAutoList *l)␊ |
350 | {␊ |
351 | if (m_hide) return;␊ |
352 | if (l->isEnumList())␊ |
353 | {␊ |
354 | m_t << "</orderedlist>\n";␊ |
355 | }␊ |
356 | else␊ |
357 | {␊ |
358 | m_t << "</itemizedlist>\n";␊ |
359 | }␊ |
360 | }␊ |
361 | ␊ |
362 | void XmlDocVisitor::visitPre(DocAutoListItem *)␊ |
363 | {␊ |
364 | if (m_hide) return;␊ |
365 | m_t << "<listitem>";␊ |
366 | }␊ |
367 | ␊ |
368 | void XmlDocVisitor::visitPost(DocAutoListItem *) ␊ |
369 | {␊ |
370 | if (m_hide) return;␊ |
371 | m_t << "</listitem>";␊ |
372 | }␊ |
373 | ␊ |
374 | void XmlDocVisitor::visitPre(DocPara *) ␊ |
375 | {␊ |
376 | if (m_hide) return;␊ |
377 | m_t << "<para>";␊ |
378 | }␊ |
379 | ␊ |
380 | void XmlDocVisitor::visitPost(DocPara *)␊ |
381 | {␊ |
382 | if (m_hide) return;␊ |
383 | m_t << "</para>";␊ |
384 | }␊ |
385 | ␊ |
386 | void XmlDocVisitor::visitPre(DocRoot *)␊ |
387 | {␊ |
388 | //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";␊ |
389 | }␊ |
390 | ␊ |
391 | void XmlDocVisitor::visitPost(DocRoot *)␊ |
392 | {␊ |
393 | //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";␊ |
394 | }␊ |
395 | ␊ |
396 | void XmlDocVisitor::visitPre(DocSimpleSect *s)␊ |
397 | {␊ |
398 | if (m_hide) return;␊ |
399 | m_t << "<simplesect kind=\"";␊ |
400 | switch(s->type())␊ |
401 | {␊ |
402 | case DocSimpleSect::See: ␊ |
403 | m_t << "see"; break;␊ |
404 | case DocSimpleSect::Return: ␊ |
405 | m_t << "return"; break;␊ |
406 | case DocSimpleSect::Author: ␊ |
407 | m_t << "author"; break;␊ |
408 | case DocSimpleSect::Authors: ␊ |
409 | m_t << "authors"; break;␊ |
410 | case DocSimpleSect::Version: ␊ |
411 | m_t << "version"; break;␊ |
412 | case DocSimpleSect::Since: ␊ |
413 | m_t << "since"; break;␊ |
414 | case DocSimpleSect::Date: ␊ |
415 | m_t << "date"; break;␊ |
416 | case DocSimpleSect::Note: ␊ |
417 | m_t << "note"; break;␊ |
418 | case DocSimpleSect::Warning:␊ |
419 | m_t << "warning"; break;␊ |
420 | case DocSimpleSect::Pre:␊ |
421 | m_t << "pre"; break;␊ |
422 | case DocSimpleSect::Post:␊ |
423 | m_t << "post"; break;␊ |
424 | case DocSimpleSect::Invar:␊ |
425 | m_t << "invariant"; break;␊ |
426 | case DocSimpleSect::Remark:␊ |
427 | m_t << "remark"; break;␊ |
428 | case DocSimpleSect::Attention:␊ |
429 | m_t << "attention"; break;␊ |
430 | case DocSimpleSect::User: ␊ |
431 | m_t << "par"; break;␊ |
432 | case DocSimpleSect::Rcs: ␊ |
433 | m_t << "rcs"; break;␊ |
434 | case DocSimpleSect::Unknown: break;␊ |
435 | }␊ |
436 | m_t << "\">";␊ |
437 | }␊ |
438 | ␊ |
439 | void XmlDocVisitor::visitPost(DocSimpleSect *)␊ |
440 | {␊ |
441 | if (m_hide) return;␊ |
442 | m_t << "</simplesect>\n";␊ |
443 | }␊ |
444 | ␊ |
445 | void XmlDocVisitor::visitPre(DocTitle *)␊ |
446 | {␊ |
447 | if (m_hide) return;␊ |
448 | m_t << "<title>";␊ |
449 | }␊ |
450 | ␊ |
451 | void XmlDocVisitor::visitPost(DocTitle *)␊ |
452 | {␊ |
453 | if (m_hide) return;␊ |
454 | m_t << "</title>";␊ |
455 | }␊ |
456 | ␊ |
457 | void XmlDocVisitor::visitPre(DocSimpleList *)␊ |
458 | {␊ |
459 | if (m_hide) return;␊ |
460 | m_t << "<itemizedlist>\n";␊ |
461 | }␊ |
462 | ␊ |
463 | void XmlDocVisitor::visitPost(DocSimpleList *)␊ |
464 | {␊ |
465 | if (m_hide) return;␊ |
466 | m_t << "</itemizedlist>\n";␊ |
467 | }␊ |
468 | ␊ |
469 | void XmlDocVisitor::visitPre(DocSimpleListItem *)␊ |
470 | {␊ |
471 | if (m_hide) return;␊ |
472 | m_t << "<listitem>";␊ |
473 | }␊ |
474 | ␊ |
475 | void XmlDocVisitor::visitPost(DocSimpleListItem *) ␊ |
476 | {␊ |
477 | if (m_hide) return;␊ |
478 | m_t << "</listitem>\n";␊ |
479 | }␊ |
480 | ␊ |
481 | void XmlDocVisitor::visitPre(DocSection *s)␊ |
482 | {␊ |
483 | if (m_hide) return;␊ |
484 | m_t << "<sect" << s->level() << " id=\"" << s->file();␊ |
485 | if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();␊ |
486 | m_t << "\">" << endl;␊ |
487 | m_t << "<title>";␊ |
488 | filter(s->title());␊ |
489 | m_t << "</title>" << endl;␊ |
490 | }␊ |
491 | ␊ |
492 | void XmlDocVisitor::visitPost(DocSection *s) ␊ |
493 | {␊ |
494 | m_t << "</sect" << s->level() << ">\n";␊ |
495 | }␊ |
496 | ␊ |
497 | void XmlDocVisitor::visitPre(DocHtmlList *s)␊ |
498 | {␊ |
499 | if (m_hide) return;␊ |
500 | if (s->type()==DocHtmlList::Ordered) ␊ |
501 | m_t << "<orderedlist>\n"; ␊ |
502 | else ␊ |
503 | m_t << "<itemizedlist>\n";␊ |
504 | }␊ |
505 | ␊ |
506 | void XmlDocVisitor::visitPost(DocHtmlList *s) ␊ |
507 | {␊ |
508 | if (m_hide) return;␊ |
509 | if (s->type()==DocHtmlList::Ordered) ␊ |
510 | m_t << "</orderedlist>\n"; ␊ |
511 | else ␊ |
512 | m_t << "</itemizedlist>\n";␊ |
513 | }␊ |
514 | ␊ |
515 | void XmlDocVisitor::visitPre(DocHtmlListItem *)␊ |
516 | {␊ |
517 | if (m_hide) return;␊ |
518 | m_t << "<listitem>\n";␊ |
519 | }␊ |
520 | ␊ |
521 | void XmlDocVisitor::visitPost(DocHtmlListItem *) ␊ |
522 | {␊ |
523 | if (m_hide) return;␊ |
524 | m_t << "</listitem>\n";␊ |
525 | }␊ |
526 | ␊ |
527 | void XmlDocVisitor::visitPre(DocHtmlDescList *)␊ |
528 | {␊ |
529 | if (m_hide) return;␊ |
530 | m_t << "<variablelist>\n";␊ |
531 | }␊ |
532 | ␊ |
533 | void XmlDocVisitor::visitPost(DocHtmlDescList *) ␊ |
534 | {␊ |
535 | if (m_hide) return;␊ |
536 | m_t << "</variablelist>\n";␊ |
537 | }␊ |
538 | ␊ |
539 | void XmlDocVisitor::visitPre(DocHtmlDescTitle *)␊ |
540 | {␊ |
541 | if (m_hide) return;␊ |
542 | m_t << "<varlistentry><term>";␊ |
543 | }␊ |
544 | ␊ |
545 | void XmlDocVisitor::visitPost(DocHtmlDescTitle *) ␊ |
546 | {␊ |
547 | if (m_hide) return;␊ |
548 | m_t << "</term></varlistentry>\n";␊ |
549 | }␊ |
550 | ␊ |
551 | void XmlDocVisitor::visitPre(DocHtmlDescData *)␊ |
552 | {␊ |
553 | if (m_hide) return;␊ |
554 | m_t << "<listitem>";␊ |
555 | }␊ |
556 | ␊ |
557 | void XmlDocVisitor::visitPost(DocHtmlDescData *) ␊ |
558 | {␊ |
559 | if (m_hide) return;␊ |
560 | m_t << "</listitem>\n";␊ |
561 | }␊ |
562 | ␊ |
563 | void XmlDocVisitor::visitPre(DocHtmlTable *t)␊ |
564 | {␊ |
565 | if (m_hide) return;␊ |
566 | m_t << "<table rows=\"" << t->numRows() ␊ |
567 | << "\" cols=\"" << t->numCols() << "\">" ;␊ |
568 | }␊ |
569 | ␊ |
570 | void XmlDocVisitor::visitPost(DocHtmlTable *) ␊ |
571 | {␊ |
572 | if (m_hide) return;␊ |
573 | m_t << "</table>\n";␊ |
574 | }␊ |
575 | ␊ |
576 | void XmlDocVisitor::visitPre(DocHtmlRow *)␊ |
577 | {␊ |
578 | if (m_hide) return;␊ |
579 | m_t << "<row>\n";␊ |
580 | }␊ |
581 | ␊ |
582 | void XmlDocVisitor::visitPost(DocHtmlRow *) ␊ |
583 | {␊ |
584 | if (m_hide) return;␊ |
585 | m_t << "</row>\n";␊ |
586 | }␊ |
587 | ␊ |
588 | void XmlDocVisitor::visitPre(DocHtmlCell *c)␊ |
589 | {␊ |
590 | if (m_hide) return;␊ |
591 | if (c->isHeading()) m_t << "<entry thead=\"yes\">"; else m_t << "<entry thead=\"no\">";␊ |
592 | }␊ |
593 | ␊ |
594 | void XmlDocVisitor::visitPost(DocHtmlCell *) ␊ |
595 | {␊ |
596 | if (m_hide) return;␊ |
597 | m_t << "</entry>"; ␊ |
598 | }␊ |
599 | ␊ |
600 | void XmlDocVisitor::visitPre(DocHtmlCaption *)␊ |
601 | {␊ |
602 | if (m_hide) return;␊ |
603 | m_t << "<caption>";␊ |
604 | }␊ |
605 | ␊ |
606 | void XmlDocVisitor::visitPost(DocHtmlCaption *) ␊ |
607 | {␊ |
608 | if (m_hide) return;␊ |
609 | m_t << "</caption>\n";␊ |
610 | }␊ |
611 | ␊ |
612 | void XmlDocVisitor::visitPre(DocInternal *)␊ |
613 | {␊ |
614 | if (m_hide) return;␊ |
615 | m_t << "<internal>";␊ |
616 | }␊ |
617 | ␊ |
618 | void XmlDocVisitor::visitPost(DocInternal *) ␊ |
619 | {␊ |
620 | if (m_hide) return;␊ |
621 | m_t << "</internal>" << endl;␊ |
622 | }␊ |
623 | ␊ |
624 | void XmlDocVisitor::visitPre(DocHRef *href)␊ |
625 | {␊ |
626 | if (m_hide) return;␊ |
627 | m_t << "<ulink url=\"" << href->url() << "\">";␊ |
628 | }␊ |
629 | ␊ |
630 | void XmlDocVisitor::visitPost(DocHRef *) ␊ |
631 | {␊ |
632 | if (m_hide) return;␊ |
633 | m_t << "</ulink>";␊ |
634 | }␊ |
635 | ␊ |
636 | void XmlDocVisitor::visitPre(DocHtmlHeader *header)␊ |
637 | {␊ |
638 | if (m_hide) return;␊ |
639 | m_t << "<heading level=\"" << header->level() << "\">";␊ |
640 | }␊ |
641 | ␊ |
642 | void XmlDocVisitor::visitPost(DocHtmlHeader *) ␊ |
643 | {␊ |
644 | if (m_hide) return;␊ |
645 | m_t << "</heading>\n";␊ |
646 | }␊ |
647 | ␊ |
648 | void XmlDocVisitor::visitPre(DocImage *img)␊ |
649 | {␊ |
650 | if (m_hide) return;␊ |
651 | m_t << "<image type=\"";␊ |
652 | switch(img->type())␊ |
653 | {␊ |
654 | case DocImage::Html: m_t << "html"; break;␊ |
655 | case DocImage::Latex: m_t << "latex"; break;␊ |
656 | case DocImage::Rtf: m_t << "rtf"; break;␊ |
657 | }␊ |
658 | m_t << "\"";␊ |
659 | ␊ |
660 | QCString baseName=img->name();␊ |
661 | int i;␊ |
662 | if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)␊ |
663 | {␊ |
664 | baseName=baseName.right(baseName.length()-i-1);␊ |
665 | }␊ |
666 | m_t << " name=\"" << baseName << "\"";␊ |
667 | if (!img->width().isEmpty())␊ |
668 | {␊ |
669 | m_t << " width=\"";␊ |
670 | filter(img->width());␊ |
671 | m_t << "\"";␊ |
672 | }␊ |
673 | else if (!img->height().isEmpty())␊ |
674 | {␊ |
675 | m_t << " height=\"";␊ |
676 | filter(img->height());␊ |
677 | m_t << "\"";␊ |
678 | }␊ |
679 | m_t << ">";␊ |
680 | ␊ |
681 | // copy the image to the output dir␊ |
682 | QFile inImage(img->name());␊ |
683 | QFile outImage(Config_getString("XML_OUTPUT")+"/"+baseName.data());␊ |
684 | if (inImage.open(IO_ReadOnly))␊ |
685 | {␊ |
686 | if (outImage.open(IO_WriteOnly))␊ |
687 | {␊ |
688 | char *buffer = new char[inImage.size()];␊ |
689 | inImage.readBlock(buffer,inImage.size());␊ |
690 | outImage.writeBlock(buffer,inImage.size());␊ |
691 | outImage.flush();␊ |
692 | delete[] buffer;␊ |
693 | }␊ |
694 | }␊ |
695 | }␊ |
696 | ␊ |
697 | void XmlDocVisitor::visitPost(DocImage *) ␊ |
698 | {␊ |
699 | if (m_hide) return;␊ |
700 | m_t << "</image>" << endl;␊ |
701 | }␊ |
702 | ␊ |
703 | void XmlDocVisitor::visitPre(DocDotFile *df)␊ |
704 | {␊ |
705 | if (m_hide) return;␊ |
706 | m_t << "<dotfile name=\"" << df->file() << "\">";␊ |
707 | }␊ |
708 | ␊ |
709 | void XmlDocVisitor::visitPost(DocDotFile *) ␊ |
710 | {␊ |
711 | if (m_hide) return;␊ |
712 | m_t << "</dotfile>" << endl;␊ |
713 | }␊ |
714 | ␊ |
715 | void XmlDocVisitor::visitPre(DocMscFile *df)␊ |
716 | {␊ |
717 | if (m_hide) return;␊ |
718 | m_t << "<mscfile name=\"" << df->file() << "\">";␊ |
719 | }␊ |
720 | ␊ |
721 | void XmlDocVisitor::visitPost(DocMscFile *) ␊ |
722 | {␊ |
723 | if (m_hide) return;␊ |
724 | m_t << "</mscfile>" << endl;␊ |
725 | }␊ |
726 | void XmlDocVisitor::visitPre(DocLink *lnk)␊ |
727 | {␊ |
728 | if (m_hide) return;␊ |
729 | startLink(lnk->ref(),lnk->file(),lnk->anchor());␊ |
730 | }␊ |
731 | ␊ |
732 | void XmlDocVisitor::visitPost(DocLink *) ␊ |
733 | {␊ |
734 | if (m_hide) return;␊ |
735 | endLink();␊ |
736 | }␊ |
737 | ␊ |
738 | void XmlDocVisitor::visitPre(DocRef *ref)␊ |
739 | {␊ |
740 | if (m_hide) return;␊ |
741 | if (!ref->file().isEmpty()) startLink(ref->ref(),ref->file(),ref->anchor());␊ |
742 | if (!ref->hasLinkText()) filter(ref->targetTitle());␊ |
743 | }␊ |
744 | ␊ |
745 | void XmlDocVisitor::visitPost(DocRef *ref) ␊ |
746 | {␊ |
747 | if (m_hide) return;␊ |
748 | if (!ref->file().isEmpty()) endLink();␊ |
749 | //m_t << " ";␊ |
750 | }␊ |
751 | ␊ |
752 | void XmlDocVisitor::visitPre(DocSecRefItem *ref)␊ |
753 | {␊ |
754 | if (m_hide) return;␊ |
755 | m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">";␊ |
756 | }␊ |
757 | ␊ |
758 | void XmlDocVisitor::visitPost(DocSecRefItem *) ␊ |
759 | {␊ |
760 | if (m_hide) return;␊ |
761 | m_t << "</tocitem>" << endl;␊ |
762 | }␊ |
763 | ␊ |
764 | void XmlDocVisitor::visitPre(DocSecRefList *)␊ |
765 | {␊ |
766 | if (m_hide) return;␊ |
767 | m_t << "<toclist>" << endl;␊ |
768 | }␊ |
769 | ␊ |
770 | void XmlDocVisitor::visitPost(DocSecRefList *) ␊ |
771 | {␊ |
772 | if (m_hide) return;␊ |
773 | m_t << "</toclist>" << endl;␊ |
774 | }␊ |
775 | ␊ |
776 | //void XmlDocVisitor::visitPre(DocLanguage *l)␊ |
777 | //{␊ |
778 | // if (m_hide) return;␊ |
779 | // m_t << "<language langid=\"" << l->id() << "\">";␊ |
780 | //}␊ |
781 | //␊ |
782 | //void XmlDocVisitor::visitPost(DocLanguage *) ␊ |
783 | //{␊ |
784 | // if (m_hide) return;␊ |
785 | // m_t << "</language>" << endl;␊ |
786 | //}␊ |
787 | ␊ |
788 | void XmlDocVisitor::visitPre(DocParamSect *s)␊ |
789 | {␊ |
790 | if (m_hide) return;␊ |
791 | m_t << "<parameterlist kind=\"";␊ |
792 | switch(s->type())␊ |
793 | {␊ |
794 | case DocParamSect::Param: ␊ |
795 | m_t << "param"; break;␊ |
796 | case DocParamSect::RetVal: ␊ |
797 | m_t << "retval"; break;␊ |
798 | case DocParamSect::Exception: ␊ |
799 | m_t << "exception"; break;␊ |
800 | case DocParamSect::TemplateParam: ␊ |
801 | m_t << "templateparam"; break;␊ |
802 | default:␊ |
803 | ASSERT(0);␊ |
804 | }␊ |
805 | m_t << "\">";␊ |
806 | }␊ |
807 | ␊ |
808 | void XmlDocVisitor::visitPost(DocParamSect *)␊ |
809 | {␊ |
810 | if (m_hide) return;␊ |
811 | m_t << "</parameterlist>" << endl;␊ |
812 | }␊ |
813 | ␊ |
814 | void XmlDocVisitor::visitPre(DocParamList *pl)␊ |
815 | {␊ |
816 | if (m_hide) return;␊ |
817 | m_t << "<parameteritem>" << endl;␊ |
818 | m_t << "<parameternamelist>" << endl;␊ |
819 | //QStrListIterator li(pl->parameters());␊ |
820 | //const char *s;␊ |
821 | QListIterator<DocNode> li(pl->parameters());␊ |
822 | DocNode *param;␊ |
823 | for (li.toFirst();(param=li.current());++li)␊ |
824 | {␊ |
825 | if (pl->paramTypes().count()>0)␊ |
826 | {␊ |
827 | QListIterator<DocNode> li(pl->paramTypes());␊ |
828 | DocNode *type;␊ |
829 | for (li.toFirst();(type=li.current());++li)␊ |
830 | {␊ |
831 | m_t << "<parametertype>";␊ |
832 | if (type->kind()==DocNode::Kind_Word)␊ |
833 | {␊ |
834 | visit((DocWord*)type); ␊ |
835 | }␊ |
836 | else if (type->kind()==DocNode::Kind_LinkedWord)␊ |
837 | {␊ |
838 | visit((DocLinkedWord*)type); ␊ |
839 | }␊ |
840 | m_t << "</parametertype>" << endl;␊ |
841 | }␊ |
842 | }␊ |
843 | m_t << "<parametername";␊ |
844 | if (pl->direction()!=DocParamSect::Unspecified)␊ |
845 | {␊ |
846 | m_t << " direction=\"";␊ |
847 | if (pl->direction()==DocParamSect::In)␊ |
848 | {␊ |
849 | m_t << "in";␊ |
850 | }␊ |
851 | else if (pl->direction()==DocParamSect::Out)␊ |
852 | {␊ |
853 | m_t << "out";␊ |
854 | }␊ |
855 | else if (pl->direction()==DocParamSect::InOut)␊ |
856 | {␊ |
857 | m_t << "inout";␊ |
858 | }␊ |
859 | m_t << "\"";␊ |
860 | }␊ |
861 | m_t << ">";␊ |
862 | if (param->kind()==DocNode::Kind_Word)␊ |
863 | {␊ |
864 | visit((DocWord*)param); ␊ |
865 | }␊ |
866 | else if (param->kind()==DocNode::Kind_LinkedWord)␊ |
867 | {␊ |
868 | visit((DocLinkedWord*)param); ␊ |
869 | }␊ |
870 | m_t << "</parametername>" << endl;␊ |
871 | }␊ |
872 | m_t << "</parameternamelist>" << endl;␊ |
873 | m_t << "<parameterdescription>" << endl;␊ |
874 | }␊ |
875 | ␊ |
876 | void XmlDocVisitor::visitPost(DocParamList *)␊ |
877 | {␊ |
878 | if (m_hide) return;␊ |
879 | m_t << "</parameterdescription>" << endl;␊ |
880 | m_t << "</parameteritem>" << endl;␊ |
881 | }␊ |
882 | ␊ |
883 | void XmlDocVisitor::visitPre(DocXRefItem *x)␊ |
884 | {␊ |
885 | if (m_hide) return;␊ |
886 | m_t << "<xrefsect id=\"";␊ |
887 | m_t << x->file() << "_1" << x->anchor();␊ |
888 | m_t << "\">";␊ |
889 | m_t << "<xreftitle>";␊ |
890 | filter(x->title());␊ |
891 | m_t << "</xreftitle>";␊ |
892 | m_t << "<xrefdescription>";␊ |
893 | }␊ |
894 | ␊ |
895 | void XmlDocVisitor::visitPost(DocXRefItem *)␊ |
896 | {␊ |
897 | if (m_hide) return;␊ |
898 | m_t << "</xrefdescription>";␊ |
899 | m_t << "</xrefsect>";␊ |
900 | }␊ |
901 | ␊ |
902 | void XmlDocVisitor::visitPre(DocInternalRef *ref)␊ |
903 | {␊ |
904 | if (m_hide) return;␊ |
905 | startLink(0,ref->file(),ref->anchor());␊ |
906 | }␊ |
907 | ␊ |
908 | void XmlDocVisitor::visitPost(DocInternalRef *) ␊ |
909 | {␊ |
910 | if (m_hide) return;␊ |
911 | endLink();␊ |
912 | m_t << " ";␊ |
913 | }␊ |
914 | ␊ |
915 | void XmlDocVisitor::visitPre(DocCopy *c)␊ |
916 | {␊ |
917 | if (m_hide) return;␊ |
918 | m_t << "<copydoc link=\"" << convertToXML(c->link()) << "\">";␊ |
919 | }␊ |
920 | ␊ |
921 | void XmlDocVisitor::visitPost(DocCopy *)␊ |
922 | {␊ |
923 | if (m_hide) return;␊ |
924 | m_t << "</copydoc>" << endl;␊ |
925 | }␊ |
926 | ␊ |
927 | void XmlDocVisitor::visitPre(DocText *)␊ |
928 | {␊ |
929 | }␊ |
930 | ␊ |
931 | void XmlDocVisitor::visitPost(DocText *)␊ |
932 | {␊ |
933 | }␊ |
934 | ␊ |
935 | void XmlDocVisitor::filter(const char *str)␊ |
936 | { ␊ |
937 | m_t << convertToXML(str);␊ |
938 | }␊ |
939 | ␊ |
940 | void XmlDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)␊ |
941 | {␊ |
942 | m_t << "<ref refid=\"" << file;␊ |
943 | if (!anchor.isEmpty()) m_t << "_1" << anchor;␊ |
944 | m_t << "\" kindref=\"";␊ |
945 | if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";␊ |
946 | m_t << "\"";␊ |
947 | if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";␊ |
948 | m_t << ">";␊ |
949 | }␊ |
950 | ␊ |
951 | void XmlDocVisitor::endLink()␊ |
952 | {␊ |
953 | m_t << "</ref>";␊ |
954 | }␊ |
955 | ␊ |
956 | void XmlDocVisitor::pushEnabled()␊ |
957 | {␊ |
958 | m_enabled.push(new bool(m_hide));␊ |
959 | }␊ |
960 | ␊ |
961 | void XmlDocVisitor::popEnabled()␊ |
962 | {␊ |
963 | bool *v=m_enabled.pop();␊ |
964 | ASSERT(v!=0);␊ |
965 | m_hide = *v;␊ |
966 | delete v;␊ |
967 | }␊ |
968 | ␊ |
969 |