Root/
Source at commit 1322 created 12 years 8 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * $Id: $␊ |
4 | *␊ |
5 | *␊ |
6 | * Copyright (C) 1997-2006 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 | */␊ |
15 | ␊ |
16 | #include <stdio.h>␊ |
17 | #include <stdlib.h>␊ |
18 | #include <doxmlintf.h>␊ |
19 | #include <qstring.h>␊ |
20 | ␊ |
21 | /*! Dumps the contents of a hyperlinked text fragment as plain text to the␊ |
22 | * output.␊ |
23 | */␊ |
24 | QString linkedTextToString(ILinkedTextIterator *ti)␊ |
25 | {␊ |
26 | QString result;␊ |
27 | ILinkedText *lt=0;␊ |
28 | for (ti->toFirst();(lt=ti->current());ti->toNext())␊ |
29 | {␊ |
30 | switch (lt->kind())␊ |
31 | {␊ |
32 | case ILinkedText::Kind_Text: // plain text␊ |
33 | result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1(); break;␊ |
34 | case ILinkedText::Kind_Ref: // a link␊ |
35 | result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1(); break;␊ |
36 | }␊ |
37 | }␊ |
38 | return result;␊ |
39 | }␊ |
40 | ␊ |
41 | /*! Macro for printing an indented message. */␊ |
42 | #define InPrint(x) printf("%s",indent.latin1()), printf x;␊ |
43 | ␊ |
44 | /*! Dumps the contents of a documentation block to stdout.␊ |
45 | * @note This function will call itself recursively.␊ |
46 | * @param doc The root of the documentation tree.␊ |
47 | * @param level The indent level.␊ |
48 | */␊ |
49 | void DumpDoc(IDoc *doc,int level)␊ |
50 | {␊ |
51 | if (doc==0) return;␊ |
52 | QString indent;␊ |
53 | indent.fill(' ',level);␊ |
54 | //printf(" doc node kind=`%d'\n",doc->kind());␊ |
55 | switch (doc->kind())␊ |
56 | {␊ |
57 | case IDoc::Para: ␊ |
58 | {␊ |
59 | InPrint(("<para>\n"));␊ |
60 | IDocPara *par = dynamic_cast<IDocPara*>(doc);␊ |
61 | ASSERT(par!=0);␊ |
62 | IDocIterator *di = par->contents();␊ |
63 | IDoc *pdoc;␊ |
64 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
65 | {␊ |
66 | DumpDoc(pdoc,level+1);␊ |
67 | }␊ |
68 | di->release();␊ |
69 | InPrint(("</para>\n"));␊ |
70 | }␊ |
71 | break;␊ |
72 | case IDoc::Text:␊ |
73 | {␊ |
74 | IDocText *txt = dynamic_cast<IDocText*>(doc);␊ |
75 | ASSERT(txt!=0);␊ |
76 | InPrint(("<text value=`%s' markup=%d headingLevel=%d/>\n",␊ |
77 | txt->text()->latin1(),txt->markup(),txt->headingLevel()));␊ |
78 | }␊ |
79 | break;␊ |
80 | case IDoc::MarkupModifier:␊ |
81 | {␊ |
82 | IDocMarkupModifier *md = dynamic_cast<IDocMarkupModifier*>(doc);␊ |
83 | ASSERT(md!=0);␊ |
84 | InPrint(("<markup modifier enabled=%d markup=%d headingLevel=%d/>\n",␊ |
85 | md->enabled(),md->markup(),md->headingLevel()));␊ |
86 | }␊ |
87 | break;␊ |
88 | case IDoc::ItemizedList:␊ |
89 | {␊ |
90 | InPrint(("<itemized list>\n"));␊ |
91 | IDocItemizedList *list = dynamic_cast<IDocItemizedList*>(doc);␊ |
92 | ASSERT(list!=0);␊ |
93 | IDocIterator *di = list->elements();␊ |
94 | IDoc *pdoc;␊ |
95 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
96 | {␊ |
97 | DumpDoc(pdoc,level+1);␊ |
98 | }␊ |
99 | di->release();␊ |
100 | InPrint(("</itemized list>\n"));␊ |
101 | }␊ |
102 | break;␊ |
103 | case IDoc::OrderedList:␊ |
104 | {␊ |
105 | InPrint(("<ordered list>\n"));␊ |
106 | IDocOrderedList *list = dynamic_cast<IDocOrderedList*>(doc);␊ |
107 | ASSERT(list!=0);␊ |
108 | IDocIterator *di = list->elements();␊ |
109 | IDoc *pdoc;␊ |
110 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
111 | {␊ |
112 | DumpDoc(pdoc,level+1);␊ |
113 | }␊ |
114 | di->release();␊ |
115 | InPrint(("</ordered list>\n"));␊ |
116 | }␊ |
117 | break;␊ |
118 | case IDoc::ListItem:␊ |
119 | {␊ |
120 | InPrint(("<list item>\n"));␊ |
121 | IDocListItem *li = dynamic_cast<IDocListItem*>(doc);␊ |
122 | ASSERT(li!=0);␊ |
123 | IDocIterator *di = li->contents();␊ |
124 | IDoc *pdoc;␊ |
125 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
126 | {␊ |
127 | DumpDoc(pdoc,level+1);␊ |
128 | }␊ |
129 | di->release();␊ |
130 | InPrint(("</list item>\n"));␊ |
131 | }␊ |
132 | break;␊ |
133 | case IDoc::ParameterItem:␊ |
134 | {␊ |
135 | IDocParameterItem *item = dynamic_cast<IDocParameterItem*>(doc);␊ |
136 | InPrint(("<parameter item>\n"));␊ |
137 | IDocIterator *di = item->paramNames();␊ |
138 | IDoc *pdoc;␊ |
139 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
140 | {␊ |
141 | DumpDoc(pdoc,level+1);␊ |
142 | }␊ |
143 | di->release();␊ |
144 | DumpDoc(item->description(),level+1);␊ |
145 | InPrint(("</parameter item>\n"));␊ |
146 | }␊ |
147 | break;␊ |
148 | case IDoc::ParameterList:␊ |
149 | {␊ |
150 | IDocParameterList *list = dynamic_cast<IDocParameterList*>(doc);␊ |
151 | InPrint(("<parameter list type=%d>\n",list->sectType()));␊ |
152 | IDocIterator *di = list->params();␊ |
153 | IDoc *pdoc;␊ |
154 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
155 | {␊ |
156 | DumpDoc(pdoc,level+1);␊ |
157 | }␊ |
158 | di->release();␊ |
159 | InPrint(("</parameter list>\n"));␊ |
160 | ASSERT(list!=0);␊ |
161 | }␊ |
162 | break;␊ |
163 | case IDoc::Parameter:␊ |
164 | {␊ |
165 | IDocParameter *par = dynamic_cast<IDocParameter*>(doc);␊ |
166 | ASSERT(par!=0);␊ |
167 | InPrint(("<parameter name=%s/>\n",par->name()->latin1()));␊ |
168 | }␊ |
169 | break;␊ |
170 | case IDoc::SimpleSect:␊ |
171 | {␊ |
172 | IDocSimpleSect *ss = dynamic_cast<IDocSimpleSect*>(doc);␊ |
173 | ASSERT(ss!=0);␊ |
174 | InPrint(("<simplesect type=%s>\n",ss->typeString()->latin1()));␊ |
175 | DumpDoc(ss->title(),level+1);␊ |
176 | DumpDoc(ss->description(),level+1);␊ |
177 | InPrint(("<simplesect/>\n"));␊ |
178 | }␊ |
179 | break;␊ |
180 | case IDoc::Title:␊ |
181 | {␊ |
182 | InPrint(("<title>\n"));␊ |
183 | IDocTitle *t = dynamic_cast<IDocTitle*>(doc);␊ |
184 | ASSERT(t!=0);␊ |
185 | IDocIterator *di = t->title();␊ |
186 | IDoc *pdoc;␊ |
187 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
188 | {␊ |
189 | DumpDoc(pdoc,level+1);␊ |
190 | }␊ |
191 | InPrint(("<title/>\n"));␊ |
192 | }␊ |
193 | break;␊ |
194 | case IDoc::Ref:␊ |
195 | {␊ |
196 | IDocRef *ref = dynamic_cast<IDocRef*>(doc);␊ |
197 | ASSERT(ref!=0);␊ |
198 | InPrint(("<ref id=%s text=%s/>\n",␊ |
199 | ref->refId()->latin1(),ref->text()->latin1()));␊ |
200 | }␊ |
201 | break;␊ |
202 | case IDoc::VariableList:␊ |
203 | {␊ |
204 | InPrint(("<variablelist>\n"));␊ |
205 | IDocVariableList *vl = dynamic_cast<IDocVariableList*>(doc);␊ |
206 | ASSERT(vl!=0);␊ |
207 | IDocIterator *di = vl->entries();␊ |
208 | IDoc *pdoc;␊ |
209 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
210 | {␊ |
211 | DumpDoc(pdoc,level+1);␊ |
212 | }␊ |
213 | di->release();␊ |
214 | InPrint(("<variablelist/>\n"));␊ |
215 | }␊ |
216 | break;␊ |
217 | case IDoc::VariableListEntry:␊ |
218 | {␊ |
219 | IDocVariableListEntry *vle = dynamic_cast<IDocVariableListEntry*>(doc);␊ |
220 | ASSERT(vle!=0);␊ |
221 | ILinkedTextIterator *lti = vle->term();␊ |
222 | QString term = linkedTextToString(lti);␊ |
223 | lti->release();␊ |
224 | InPrint(("<variablelistentry term=%s>\n",term.latin1()));␊ |
225 | DumpDoc(vle->description(),level+1);␊ |
226 | InPrint(("<variablelistentry/>\n"));␊ |
227 | }␊ |
228 | break;␊ |
229 | case IDoc::HRuler:␊ |
230 | {␊ |
231 | IDocHRuler *hr = dynamic_cast<IDocHRuler*>(doc);␊ |
232 | ASSERT(hr!=0);␊ |
233 | InPrint(("<hruler/>\n"));␊ |
234 | }␊ |
235 | break;␊ |
236 | case IDoc::LineBreak:␊ |
237 | {␊ |
238 | IDocLineBreak *lb = dynamic_cast<IDocLineBreak*>(doc);␊ |
239 | ASSERT(lb!=0);␊ |
240 | InPrint(("<linebreak/>\n"));␊ |
241 | }␊ |
242 | break;␊ |
243 | case IDoc::ULink:␊ |
244 | {␊ |
245 | IDocULink *ul = dynamic_cast<IDocULink*>(doc);␊ |
246 | ASSERT(ul!=0);␊ |
247 | InPrint(("<ulink url=`%s' text=`%s'/>\n",ul->url()->latin1(),ul->text()->latin1()));␊ |
248 | }␊ |
249 | break;␊ |
250 | case IDoc::EMail:␊ |
251 | {␊ |
252 | IDocEMail *em = dynamic_cast<IDocEMail*>(doc);␊ |
253 | ASSERT(em!=0);␊ |
254 | InPrint(("<email address=`%s'/>\n",em->address()->latin1()));␊ |
255 | }␊ |
256 | break;␊ |
257 | case IDoc::Link:␊ |
258 | {␊ |
259 | IDocLink *lk = dynamic_cast<IDocLink*>(doc);␊ |
260 | ASSERT(lk!=0);␊ |
261 | InPrint(("<link refid=`%s' text=`%s'/>\n",lk->refId()->latin1(),lk->text()->latin1()));␊ |
262 | }␊ |
263 | break;␊ |
264 | case IDoc::ProgramListing:␊ |
265 | {␊ |
266 | IDocProgramListing *pl = dynamic_cast<IDocProgramListing*>(doc);␊ |
267 | ASSERT(pl!=0);␊ |
268 | InPrint(("<programlisting>\n"));␊ |
269 | IDocIterator *cli = pl->codeLines();␊ |
270 | IDoc *cl;␊ |
271 | for (cli->toFirst();(cl=cli->current());cli->toNext())␊ |
272 | {␊ |
273 | DumpDoc(cl,level+1);␊ |
274 | }␊ |
275 | cli->release();␊ |
276 | InPrint(("</programlisting>\n"));␊ |
277 | }␊ |
278 | break;␊ |
279 | case IDoc::CodeLine:␊ |
280 | {␊ |
281 | IDocCodeLine *cl = dynamic_cast<IDocCodeLine*>(doc);␊ |
282 | ASSERT(cl!=0);␊ |
283 | InPrint(("<codeline lineNumber=%d refId=`%s'>\n",cl->lineNumber(),cl->refId()->latin1()));␊ |
284 | IDocIterator *cei = cl->codeElements();␊ |
285 | IDoc *ce;␊ |
286 | for (cei->toFirst();(ce=cei->current());cei->toNext())␊ |
287 | {␊ |
288 | DumpDoc(ce,level+1);␊ |
289 | }␊ |
290 | cei->release();␊ |
291 | InPrint(("</codeline>\n"));␊ |
292 | }␊ |
293 | break;␊ |
294 | case IDoc::Highlight:␊ |
295 | {␊ |
296 | IDocHighlight *hl = dynamic_cast<IDocHighlight*>(doc);␊ |
297 | ASSERT(hl!=0);␊ |
298 | InPrint(("<highlight kind=%d>\n",hl->kind()));␊ |
299 | IDocIterator *cei = hl->codeElements();␊ |
300 | IDoc *ce;␊ |
301 | for (cei->toFirst();(ce=cei->current());cei->toNext())␊ |
302 | {␊ |
303 | DumpDoc(ce,level+1);␊ |
304 | }␊ |
305 | cei->release();␊ |
306 | InPrint(("</highlight>\n"));␊ |
307 | }␊ |
308 | break;␊ |
309 | case IDoc::Formula:␊ |
310 | {␊ |
311 | IDocFormula *fm = dynamic_cast<IDocFormula*>(doc);␊ |
312 | ASSERT(fm!=0);␊ |
313 | InPrint(("<formula id=`%s' text=`%s'/>\n",fm->id()->latin1(),fm->text()->latin1()));␊ |
314 | }␊ |
315 | break;␊ |
316 | case IDoc::Image:␊ |
317 | {␊ |
318 | IDocImage *img = dynamic_cast<IDocImage*>(doc);␊ |
319 | ASSERT(img!=0);␊ |
320 | InPrint(("<image name=`%s' caption=`%s'/>\n",img->name()->latin1(),img->caption()->latin1()));␊ |
321 | }␊ |
322 | break;␊ |
323 | case IDoc::DotFile:␊ |
324 | {␊ |
325 | IDocDotFile *df = dynamic_cast<IDocDotFile*>(doc);␊ |
326 | ASSERT(df!=0);␊ |
327 | InPrint(("<dotfile name=`%s' caption=`%s'/>\n",df->name()->latin1(),df->caption()->latin1()));␊ |
328 | }␊ |
329 | break;␊ |
330 | case IDoc::IndexEntry:␊ |
331 | {␊ |
332 | IDocIndexEntry *ie = dynamic_cast<IDocIndexEntry*>(doc);␊ |
333 | ASSERT(ie!=0);␊ |
334 | InPrint(("<indexentry primary=`%s' secondary=`%s'/>\n",ie->primary()->latin1(),ie->secondary()->latin1()));␊ |
335 | }␊ |
336 | break;␊ |
337 | case IDoc::Table:␊ |
338 | {␊ |
339 | IDocTable *tbl = dynamic_cast<IDocTable*>(doc);␊ |
340 | ASSERT(tbl!=0);␊ |
341 | InPrint(("<table numcols=%d caption=`%s'>\n",tbl->numColumns(),tbl->caption()->latin1()));␊ |
342 | IDocIterator *ri = tbl->rows();␊ |
343 | IDoc *row;␊ |
344 | for (ri->toFirst();(row=ri->current());ri->toNext())␊ |
345 | {␊ |
346 | DumpDoc(row,level+1);␊ |
347 | }␊ |
348 | ri->release();␊ |
349 | InPrint(("</table>\n"));␊ |
350 | }␊ |
351 | break;␊ |
352 | case IDoc::Row:␊ |
353 | {␊ |
354 | IDocRow *row = dynamic_cast<IDocRow*>(doc);␊ |
355 | ASSERT(row!=0);␊ |
356 | InPrint(("<row>\n"));␊ |
357 | IDocIterator *ei = row->entries();␊ |
358 | IDoc *e;␊ |
359 | for (ei->toFirst();(e=ei->current());ei->toNext())␊ |
360 | {␊ |
361 | DumpDoc(e,level+1);␊ |
362 | }␊ |
363 | ei->release();␊ |
364 | InPrint(("</row>\n"));␊ |
365 | }␊ |
366 | break;␊ |
367 | case IDoc::Entry:␊ |
368 | {␊ |
369 | IDocEntry *ent = dynamic_cast<IDocEntry*>(doc);␊ |
370 | ASSERT(ent!=0);␊ |
371 | InPrint(("<entry>\n"));␊ |
372 | IDocIterator *di = ent->contents();␊ |
373 | IDoc *pdoc;␊ |
374 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
375 | {␊ |
376 | DumpDoc(pdoc,level+1);␊ |
377 | }␊ |
378 | di->release();␊ |
379 | InPrint(("</entry>\n"));␊ |
380 | }␊ |
381 | break;␊ |
382 | case IDoc::Section:␊ |
383 | {␊ |
384 | IDocSection *sec = dynamic_cast<IDocSection*>(doc);␊ |
385 | ASSERT(sec!=0);␊ |
386 | InPrint(("<section id=`%s' level=%d>\n",␊ |
387 | sec->id()->latin1(),sec->level()));␊ |
388 | DumpDoc(sec->title(),level+1);␊ |
389 | IDocIterator *di = sec->paragraphs();␊ |
390 | IDoc *pdoc;␊ |
391 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
392 | {␊ |
393 | DumpDoc(pdoc,level+1);␊ |
394 | }␊ |
395 | di=sec->subSections();␊ |
396 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
397 | {␊ |
398 | DumpDoc(pdoc,level+1);␊ |
399 | }␊ |
400 | IDocInternal *intern = sec->internal();␊ |
401 | if (intern)␊ |
402 | {␊ |
403 | DumpDoc(intern,level+1);␊ |
404 | }␊ |
405 | InPrint(("</section>\n"));␊ |
406 | }␊ |
407 | break;␊ |
408 | case IDoc::Internal:␊ |
409 | {␊ |
410 | IDocInternal *intern = dynamic_cast<IDocInternal*>(doc);␊ |
411 | ASSERT(intern!=0);␊ |
412 | InPrint(("<internal>\n"));␊ |
413 | IDocIterator *di = intern->paragraphs();␊ |
414 | IDoc *pdoc;␊ |
415 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
416 | {␊ |
417 | DumpDoc(pdoc,level+1);␊ |
418 | }␊ |
419 | di=intern->subSections();␊ |
420 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
421 | {␊ |
422 | DumpDoc(pdoc,level+1);␊ |
423 | }␊ |
424 | InPrint(("</internal>\n"));␊ |
425 | }␊ |
426 | break;␊ |
427 | case IDoc::Copy:␊ |
428 | {␊ |
429 | IDocCopy *cpy = dynamic_cast<IDocCopy*>(doc);␊ |
430 | ASSERT(cpy!=0);␊ |
431 | InPrint(("<copydoc>\n"));␊ |
432 | IDocIterator *di = cpy->contents();␊ |
433 | IDoc *pdoc;␊ |
434 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
435 | {␊ |
436 | DumpDoc(pdoc,level+1);␊ |
437 | }␊ |
438 | di->release();␊ |
439 | InPrint(("<copydoc/>\n"));␊ |
440 | }␊ |
441 | break;␊ |
442 | case IDoc::TocItem:␊ |
443 | {␊ |
444 | IDocTocItem *ti = dynamic_cast<IDocTocItem*>(doc);␊ |
445 | ASSERT(ti!=0);␊ |
446 | InPrint(("<tocitem id=\"%s\" title=\"%s\"/>\n",␊ |
447 | ti->id()->latin1(),ti->title()->latin1()));␊ |
448 | }␊ |
449 | break;␊ |
450 | case IDoc::TocList:␊ |
451 | {␊ |
452 | IDocTocList *tl = dynamic_cast<IDocTocList*>(doc);␊ |
453 | ASSERT(tl!=0);␊ |
454 | InPrint(("<toclist>\n"));␊ |
455 | IDocIterator *di = tl->elements();␊ |
456 | IDoc *pdoc;␊ |
457 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
458 | {␊ |
459 | DumpDoc(pdoc,level+1);␊ |
460 | }␊ |
461 | di->release();␊ |
462 | InPrint(("<toclist/>\n"));␊ |
463 | }␊ |
464 | break;␊ |
465 | case IDoc::Verbatim:␊ |
466 | {␊ |
467 | IDocVerbatim *vt = dynamic_cast<IDocVerbatim*>(doc);␊ |
468 | ASSERT(vt!=0);␊ |
469 | const char *s=0;␊ |
470 | switch (vt->type())␊ |
471 | {␊ |
472 | case IDocVerbatim::Verbatim: s="verbatim"; break;␊ |
473 | case IDocVerbatim::HtmlOnly: s="htmlonly"; break;␊ |
474 | case IDocVerbatim::LatexOnly: s="latexonly"; break;␊ |
475 | default:␊ |
476 | printf("Invalid verbatim type!\n");␊ |
477 | }␊ |
478 | InPrint(("<verbatim %s>\n",s));␊ |
479 | InPrint(("%s",vt->text()->latin1()));␊ |
480 | InPrint(("</verbatim>\n"));␊ |
481 | }␊ |
482 | break;␊ |
483 | case IDoc::Anchor:␊ |
484 | {␊ |
485 | IDocAnchor *anc = dynamic_cast<IDocAnchor*>(doc);␊ |
486 | ASSERT(anc!=0);␊ |
487 | InPrint(("<anchor id='%s'/>\n",anc->id()->latin1()));␊ |
488 | }␊ |
489 | break;␊ |
490 | case IDoc::Symbol:␊ |
491 | {␊ |
492 | IDocSymbol *sym = dynamic_cast<IDocSymbol*>(doc);␊ |
493 | ASSERT(sym!=0);␊ |
494 | InPrint(("<symbol type=%s letter=%c/>\n",␊ |
495 | sym->typeString()->latin1(),sym->letter()));␊ |
496 | }␊ |
497 | break;␊ |
498 | case IDoc::Root:␊ |
499 | {␊ |
500 | InPrint(("<root>\n"));␊ |
501 | IDocRoot *root = dynamic_cast<IDocRoot*>(doc);␊ |
502 | ASSERT(root!=0);␊ |
503 | IDocIterator *di = root->contents();␊ |
504 | IDoc *pdoc;␊ |
505 | for (di->toFirst();(pdoc=di->current());di->toNext())␊ |
506 | {␊ |
507 | DumpDoc(pdoc,level+1);␊ |
508 | }␊ |
509 | di->release();␊ |
510 | InPrint(("</root>\n"));␊ |
511 | }␊ |
512 | break;␊ |
513 | ␊ |
514 | default:␊ |
515 | printf("Found unsupported node type %d!\n",doc->kind());␊ |
516 | break;␊ |
517 | }␊ |
518 | }␊ |
519 | ␊ |
520 | void DumpGraph(IGraph *graph)␊ |
521 | {␊ |
522 | if (graph==0) { printf(" --- no graph ---\n"); return; }␊ |
523 | printf(" --- graph ----\n");␊ |
524 | INodeIterator *ni = graph->nodes();␊ |
525 | INode *node;␊ |
526 | for (ni->toFirst();(node=ni->current());ni->toNext())␊ |
527 | {␊ |
528 | printf(" --- node id=%s label=%s linkId=%s\n",␊ |
529 | node->id()->latin1(),␊ |
530 | node->label()->latin1(),␊ |
531 | node->linkId()->latin1()␊ |
532 | );␊ |
533 | IChildNodeIterator *cni = node->children();␊ |
534 | IChildNode *cn;␊ |
535 | for (cni->toFirst();(cn=cni->current());cni->toNext())␊ |
536 | {␊ |
537 | printf(" + child id=%s label=%s relation=%s\n",␊ |
538 | cn->node()->id()->latin1(),␊ |
539 | cn->node()->label()->latin1(),␊ |
540 | cn->relationString()->latin1()␊ |
541 | );␊ |
542 | IEdgeLabelIterator *eli = cn->edgeLabels();␊ |
543 | IEdgeLabel *el;␊ |
544 | for (eli->toFirst();(el=eli->current());eli->toNext())␊ |
545 | {␊ |
546 | printf(" edgeLabel=%s\n",el->label()->latin1());␊ |
547 | }␊ |
548 | eli->release();␊ |
549 | }␊ |
550 | cni->release();␊ |
551 | }␊ |
552 | ni->release();␊ |
553 | printf(" --- end graph ----\n");␊ |
554 | ␊ |
555 | }␊ |
556 | ␊ |
557 | void DumpParamList(IParamIterator *pli,int indent)␊ |
558 | {␊ |
559 | QString indentStr;␊ |
560 | indentStr.fill(' ',indent);␊ |
561 | IParam *par;␊ |
562 | for (pli->toFirst();(par=pli->current());pli->toNext())␊ |
563 | {␊ |
564 | ILinkedTextIterator *lti = par->type();␊ |
565 | QString parType = linkedTextToString(lti);␊ |
566 | lti->release();␊ |
567 | lti = par->defaultValue();␊ |
568 | QString defVal = linkedTextToString(lti);␊ |
569 | lti->release();␊ |
570 | printf("%sParam type=%s decl_name=%s def_name=%s defvalue=%s\n",␊ |
571 | indentStr.data(), parType.latin1(), ␊ |
572 | par->declarationName()->latin1(),␊ |
573 | par->definitionName()->latin1(),␊ |
574 | defVal.latin1());␊ |
575 | }␊ |
576 | }␊ |
577 | ␊ |
578 | int main(int argc,char **argv)␊ |
579 | {␊ |
580 | if (argc!=2)␊ |
581 | {␊ |
582 | printf("Usage: %s xmldir\n",argv[0]);␊ |
583 | exit(1);␊ |
584 | }␊ |
585 | ␊ |
586 | IDoxygen *dox = createObjectModel();␊ |
587 | ␊ |
588 | dox->setDebugLevel(4);␊ |
589 | ␊ |
590 | if (!dox->readXMLDir(argv[1]))␊ |
591 | {␊ |
592 | printf("Error reading %s/index.xml\n",argv[1]);␊ |
593 | exit(1);␊ |
594 | }␊ |
595 | ␊ |
596 | ICompoundIterator *cli = dox->compounds();␊ |
597 | ICompound *comp;␊ |
598 | printf("--- compound list ---------\n");␊ |
599 | for (cli->toFirst();(comp=cli->current());cli->toNext())␊ |
600 | {␊ |
601 | printf("Compound name=%s id=%s kind=%s\n",␊ |
602 | comp->name()->latin1(),comp->id()->latin1(),comp->kindString()->latin1());␊ |
603 | ␊ |
604 | ISectionIterator *sli = comp->sections();␊ |
605 | ISection *sec;␊ |
606 | for (sli->toFirst();(sec=sli->current());sli->toNext())␊ |
607 | {␊ |
608 | printf(" Section kind=%s\n",sec->kindString()->latin1());␊ |
609 | IMemberIterator *mli = sec->members();␊ |
610 | IMember *mem;␊ |
611 | if( sec->kind() == ISection::UserDefined )␊ |
612 | {␊ |
613 | ␉IUserDefined *group = dynamic_cast<IUserDefined*>(sec);␊ |
614 | ␉printf(" Title=%s\n", group->header()->latin1() );␊ |
615 | }␊ |
616 | for (mli->toFirst();(mem=mli->current());mli->toNext())␊ |
617 | {␊ |
618 | ILinkedTextIterator *lti = mem->type();␊ |
619 | printf(" Member type=%s name=%s\n",␊ |
620 | linkedTextToString(lti).latin1(),mem->name()->latin1());␊ |
621 | lti->release();␊ |
622 | ␊ |
623 | IParamIterator *pli = mem->parameters();␊ |
624 | DumpParamList(pli,6);␊ |
625 | pli->release();␊ |
626 | IMemberReferenceIterator *mri = mem->references();␊ |
627 | IMemberReference *mr;␊ |
628 | for (mri->toFirst();(mr=mri->current());mri->toNext())␊ |
629 | {␊ |
630 | IMember *memr = mr->member();␊ |
631 | printf(" References %s at line %d\n",␊ |
632 | mr->name()->latin1(),memr->bodyStart());␊ |
633 | }␊ |
634 | ␊ |
635 | mri->release();␊ |
636 | mri = mem->referencedBy();␊ |
637 | for (mri->toFirst();(mr=mri->current());mri->toNext())␊ |
638 | {␊ |
639 | IMember *memr = mr->member();␊ |
640 | printf(" ReferencedBy %s at line %d\n",␊ |
641 | mr->name()->latin1(),memr->bodyStart());␊ |
642 | }␊ |
643 | mri->release();␊ |
644 | ␊ |
645 | if (mem->kind()==IMember::Enum) // we have found an enum␊ |
646 | {␊ |
647 | IEnum *e = dynamic_cast<IEnum*>(mem);␊ |
648 | IMemberIterator *evi = e->enumValues(); // get the enum values␊ |
649 | IMember *mev;␊ |
650 | for (evi->toFirst();(mev=evi->current());evi->toNext())␊ |
651 | {␊ |
652 | IEnumValue *ev = dynamic_cast<IEnumValue*>(mev);␊ |
653 | ILinkedTextIterator *lti = ev->initializer();␊ |
654 | QString init = linkedTextToString(lti);␊ |
655 | lti->release();␊ |
656 | printf(" Enum value `%s' init=`%s'\n",␊ |
657 | ev->name()->latin1(),init.latin1());␊ |
658 | }␊ |
659 | evi->release();␊ |
660 | }␊ |
661 | ␊ |
662 | pli = mem->templateParameters();␊ |
663 | if (pli)␊ |
664 | {␊ |
665 | printf(" Template parameters\n");␊ |
666 | DumpParamList(pli,8);␊ |
667 | pli->release();␊ |
668 | }␊ |
669 | ␊ |
670 | IDoc *doc = mem->briefDescription();␊ |
671 | if (doc)␊ |
672 | {␊ |
673 | printf("===== brief description ==== \n");␊ |
674 | DumpDoc(doc,0);␊ |
675 | }␊ |
676 | ␊ |
677 | doc = mem->detailedDescription();␊ |
678 | if (doc)␊ |
679 | {␊ |
680 | printf("===== detailed description ==== \n");␊ |
681 | DumpDoc(doc,0);␊ |
682 | }␊ |
683 | }␊ |
684 | mli->release();␊ |
685 | }␊ |
686 | sli->release();␊ |
687 | ␊ |
688 | IDoc *doc = comp->briefDescription();␊ |
689 | if (doc)␊ |
690 | {␊ |
691 | printf("===== brief description ==== \n");␊ |
692 | DumpDoc(doc,0);␊ |
693 | }␊ |
694 | ␊ |
695 | doc = comp->detailedDescription();␊ |
696 | if (doc)␊ |
697 | {␊ |
698 | printf("===== detailed description ==== \n");␊ |
699 | DumpDoc(doc,0);␊ |
700 | }␊ |
701 | ␊ |
702 | if (comp->kind()==ICompound::Class)␊ |
703 | {␊ |
704 | IClass *cls = dynamic_cast<IClass*>(comp);␊ |
705 | ASSERT(cls!=0);␊ |
706 | ␊ |
707 | printf("==== inheritance graph ==== \n");␊ |
708 | DumpGraph(cls->inheritanceGraph());␊ |
709 | ␊ |
710 | printf("==== collabration graph ==== \n");␊ |
711 | DumpGraph(cls->collaborationGraph());␊ |
712 | ␊ |
713 | printf("==== base classes ==== \n");␊ |
714 | IRelatedCompoundIterator *bcli = cls->baseCompounds();␊ |
715 | IRelatedCompound *bClass;␊ |
716 | for (bcli->toFirst();(bClass=bcli->current());bcli->toNext())␊ |
717 | {␊ |
718 | ICompound *bc = bClass->compound();␊ |
719 | printf(" + class %s\n",bc->name()->latin1());␊ |
720 | bc->release();␊ |
721 | }␊ |
722 | bcli->release();␊ |
723 | ␊ |
724 | printf("==== derived classes ==== \n");␊ |
725 | IRelatedCompoundIterator *dcli = cls->derivedCompounds();␊ |
726 | IRelatedCompound *dClass;␊ |
727 | for (dcli->toFirst();(dClass=dcli->current());dcli->toNext())␊ |
728 | {␊ |
729 | ICompound *dc = dClass->compound();␊ |
730 | printf(" + class %s\n",dc->name()->latin1());␊ |
731 | dc->release();␊ |
732 | }␊ |
733 | dcli->release();␊ |
734 | }␊ |
735 | else if (comp->kind()==ICompound::File)␊ |
736 | {␊ |
737 | IFile *file = dynamic_cast<IFile*>(comp);␊ |
738 | ASSERT(file!=0);␊ |
739 | ␊ |
740 | printf("==== include dependency graph ==== \n");␊ |
741 | DumpGraph(file->includeDependencyGraph());␊ |
742 | ␊ |
743 | printf("==== included by dependency graph ==== \n");␊ |
744 | DumpGraph(file->includedByDependencyGraph());␊ |
745 | ␊ |
746 | printf("==== source ====\n");␊ |
747 | DumpDoc(file->source(),0);␊ |
748 | }␊ |
749 | ␊ |
750 | comp->release();␊ |
751 | }␊ |
752 | cli->release();␊ |
753 | printf("---------------------------\n");␊ |
754 | ␊ |
755 | dox->release();␊ |
756 | ␊ |
757 | return 0;␊ |
758 | }␊ |
759 | ␊ |
760 |