xmldocvisitor.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * $Id: $
00004  *
00005  *
00006  * Copyright (C) 1997-2008 by Dimitri van Heesch.
00007  *
00008  * Permission to use, copy, modify, and distribute this software and its
00009  * documentation under the terms of the GNU General Public License is hereby 
00010  * granted. No representations are made about the suitability of this software 
00011  * for any purpose. It is provided "as is" without express or implied warranty.
00012  * See the GNU General Public License for more details.
00013  *
00014  * Documents produced by Doxygen are derivative works derived from the
00015  * input used in their production; they are not affected by this license.
00016  *
00017  */
00018 
00019 #include "xmldocvisitor.h"
00020 #include "docparser.h"
00021 #include "language.h"
00022 #include "doxygen.h"
00023 #include "outputgen.h"
00024 #include "xmlgen.h"
00025 #include "dot.h"
00026 #include "message.h"
00027 #include "util.h"
00028 #include <qfileinfo.h> 
00029 #include "parserintf.h"
00030 
00031 XmlDocVisitor::XmlDocVisitor(QTextStream &t,CodeOutputInterface &ci) 
00032   : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) 
00033 {
00034 }
00035 
00036   //--------------------------------------
00037   // visitor functions for leaf nodes
00038   //--------------------------------------
00039 
00040 void XmlDocVisitor::visit(DocWord *w)
00041 {
00042   if (m_hide) return;
00043   filter(w->word());
00044 }
00045 
00046 void XmlDocVisitor::visit(DocLinkedWord *w)
00047 {
00048   if (m_hide) return;
00049   startLink(w->ref(),w->file(),w->anchor());
00050   filter(w->word());
00051   endLink();
00052 }
00053 
00054 void XmlDocVisitor::visit(DocWhiteSpace *w)
00055 {
00056   if (m_hide) return;
00057   if (m_insidePre)
00058   {
00059     m_t << w->chars();
00060   }
00061   else
00062   {
00063     m_t << " ";
00064   }
00065 }
00066 
00067 void XmlDocVisitor::visit(DocSymbol *s)
00068 {
00069   if (m_hide) return;
00070   switch(s->symbol())
00071   {
00072     case DocSymbol::BSlash:  m_t << "\\"; break;
00073     case DocSymbol::At:      m_t << "@"; break;
00074     case DocSymbol::Less:    m_t << "&lt;"; break;
00075     case DocSymbol::Greater: m_t << "&gt;"; break;
00076     case DocSymbol::Amp:     m_t << "&amp;"; break;
00077     case DocSymbol::Dollar:  m_t << "$"; break;
00078     case DocSymbol::Hash:    m_t << "#"; break;
00079     case DocSymbol::Percent: m_t << "%"; break;
00080     case DocSymbol::Copy:    m_t << "<copy/>"; break;
00081     case DocSymbol::Tm:      m_t << "<trademark/>"; break;
00082     case DocSymbol::Reg:     m_t << "<registered/>"; break;
00083     case DocSymbol::Apos:    m_t << "'"; break;
00084     case DocSymbol::Quot:    m_t << "\""; break;
00085     case DocSymbol::Lsquo:   m_t << "<lsquo/>"; break;
00086     case DocSymbol::Rsquo:   m_t << "<rsquo/>"; break;
00087     case DocSymbol::Ldquo:   m_t << "<ldquo/>"; break;
00088     case DocSymbol::Rdquo:   m_t << "<rdquo/>"; break;
00089     case DocSymbol::Ndash:   m_t << "<ndash/>"; break;
00090     case DocSymbol::Mdash:   m_t << "<mdash/>"; break;
00091     case DocSymbol::Uml:     m_t << "<umlaut char=\"" << s->letter() << "\"/>"; break;
00092     case DocSymbol::Acute:   m_t << "<acute char=\"" << s->letter() << "\"/>"; break;
00093     case DocSymbol::Grave:   m_t << "<grave char=\"" << s->letter() << "\"/>"; break;
00094     case DocSymbol::Circ:    m_t << "<circ char=\"" << s->letter() << "\"/>"; break;
00095     case DocSymbol::Tilde:   m_t << "<tilde char=\"" << s->letter() << "\"/>"; break;
00096     case DocSymbol::Szlig:   m_t << "<szlig/>"; break;
00097     case DocSymbol::Cedil:   m_t << "<cedil char=\"" << s->letter() << "\"/>"; break;
00098     case DocSymbol::Ring:    m_t << "<ring char=\"" << s->letter() << "\"/>"; break;
00099     case DocSymbol::Slash:   m_t << "<slash char=\"" << s->letter() << "\"/>"; break;
00100     case DocSymbol::Nbsp:    m_t << "<nonbreakablespace/>"; break;
00101     default:
00102                              err("Error: unknown symbol found\n");
00103   }
00104 }
00105 
00106 void XmlDocVisitor::visit(DocURL *u)
00107 {
00108   if (m_hide) return;
00109   m_t << "<ulink url=\""; 
00110   if (u->isEmail()) m_t << "mailto:";
00111   filter(u->url());
00112   m_t << "\">";
00113   filter(u->url());
00114   m_t << "</ulink>";
00115 }
00116 
00117 void XmlDocVisitor::visit(DocLineBreak *)
00118 {
00119   if (m_hide) return;
00120   m_t << "<linebreak/>\n";
00121 }
00122 
00123 void XmlDocVisitor::visit(DocHorRuler *)
00124 {
00125   if (m_hide) return;
00126   m_t << "<hruler/>\n";
00127 }
00128 
00129 void XmlDocVisitor::visit(DocStyleChange *s)
00130 {
00131   if (m_hide) return;
00132   switch (s->style())
00133   {
00134     case DocStyleChange::Bold:
00135       if (s->enable()) m_t << "<bold>";      else m_t << "</bold>";
00136       break;
00137     case DocStyleChange::Italic:
00138       if (s->enable()) m_t << "<emphasis>";     else m_t << "</emphasis>";
00139       break;
00140     case DocStyleChange::Code:
00141       if (s->enable()) m_t << "<computeroutput>";   else m_t << "</computeroutput>";
00142       break;
00143     case DocStyleChange::Subscript:
00144       if (s->enable()) m_t << "<subscript>";    else m_t << "</subscript>";
00145       break;
00146     case DocStyleChange::Superscript:
00147       if (s->enable()) m_t << "<superscript>";    else m_t << "</superscript>";
00148       break;
00149     case DocStyleChange::Center:
00150       if (s->enable()) m_t << "<center>"; else m_t << "</center>";
00151       break;
00152     case DocStyleChange::Small:
00153       if (s->enable()) m_t << "<small>";  else m_t << "</small>";
00154       break;
00155     case DocStyleChange::Preformatted:
00156       if (s->enable()) 
00157       {
00158         m_t << "<preformatted>";  
00159         m_insidePre=TRUE;
00160       }
00161       else 
00162       {
00163         m_t << "</preformatted>";
00164         m_insidePre=FALSE;
00165       }
00166       break;
00167     case DocStyleChange::Div:  /* HTML only */ break;
00168     case DocStyleChange::Span: /* HTML only */ break;
00169   }
00170 }
00171 
00172 void XmlDocVisitor::visit(DocVerbatim *s)
00173 {
00174   if (m_hide) return;
00175   switch(s->type())
00176   {
00177     case DocVerbatim::Code: // fall though
00178       m_t << "<programlisting>"; 
00179       Doxygen::parserManager->getParser(m_langExt)
00180                             ->parseCode(m_ci,s->context(),s->text().latin1(),
00181                                         s->isExample(),s->exampleFile());
00182       m_t << "</programlisting>"; 
00183       break;
00184     case DocVerbatim::Verbatim: 
00185       m_t << "<verbatim>";
00186       filter(s->text());
00187       m_t << "</verbatim>"; 
00188       break;
00189     case DocVerbatim::HtmlOnly: 
00190       m_t << "<htmlonly>";
00191       filter(s->text());
00192       m_t << "</htmlonly>";
00193       break;
00194     case DocVerbatim::ManOnly: 
00195       m_t << "<manonly>";
00196       filter(s->text());
00197       m_t << "</manonly>";
00198       break;
00199     case DocVerbatim::LatexOnly: 
00200       m_t << "<latexonly>";
00201       filter(s->text());
00202       m_t << "</latexonly>";
00203       break;
00204     case DocVerbatim::XmlOnly: 
00205       m_t << s->text();
00206       break;
00207     case DocVerbatim::Dot: 
00208       m_t << "<dot>";
00209       filter(s->text());
00210       m_t << "</dot>";
00211       break;
00212     case DocVerbatim::Msc: 
00213       m_t << "<msc>";
00214       filter(s->text());
00215       m_t << "</msc>";
00216       break;
00217   }
00218 }
00219 
00220 void XmlDocVisitor::visit(DocAnchor *anc)
00221 {
00222   if (m_hide) return;
00223   m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>";
00224 }
00225 
00226 void XmlDocVisitor::visit(DocInclude *inc)
00227 {
00228   if (m_hide) return;
00229   switch(inc->type())
00230   {
00231     case DocInclude::IncWithLines:
00232       { 
00233          m_t << "<programlisting>";
00234          QFileInfo cfi( inc->file() );
00235          FileDef fd( cfi.dirPath(), cfi.fileName() );
00236          Doxygen::parserManager->getParser(inc->extension())
00237                                ->parseCode(m_ci,inc->context(),
00238                                            inc->text().latin1(),
00239                                            inc->isExample(),
00240                                            inc->exampleFile(), &fd);
00241          m_t << "</programlisting>"; 
00242       }
00243       break;    
00244     case DocInclude::Include: 
00245       m_t << "<programlisting>";
00246       Doxygen::parserManager->getParser(inc->extension())
00247                             ->parseCode(m_ci,inc->context(),
00248                                         inc->text().latin1(),
00249                                         inc->isExample(),
00250                                         inc->exampleFile());
00251       m_t << "</programlisting>"; 
00252       break;
00253     case DocInclude::DontInclude: 
00254       break;
00255     case DocInclude::HtmlInclude: 
00256       m_t << "<htmlonly>";
00257       filter(inc->text());
00258       m_t << "</htmlonly>";
00259       break;
00260     case DocInclude::VerbInclude: 
00261       m_t << "<verbatim>";
00262       filter(inc->text());
00263       m_t << "</verbatim>"; 
00264       break;
00265   }
00266 }
00267 
00268 void XmlDocVisitor::visit(DocIncOperator *op)
00269 {
00270   //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
00271   //    op->type(),op->isFirst(),op->isLast(),op->text().data());
00272   if (op->isFirst()) 
00273   {
00274     if (!m_hide)
00275     {
00276       m_t << "<programlisting>";
00277     }
00278     pushEnabled();
00279     m_hide = TRUE;
00280   }
00281   if (op->type()!=DocIncOperator::Skip) 
00282   {
00283     popEnabled();
00284     if (!m_hide) 
00285     {
00286       Doxygen::parserManager->getParser(m_langExt)
00287                             ->parseCode(m_ci,op->context(),
00288                                         op->text().latin1(),op->isExample(),
00289                                         op->exampleFile());
00290     }
00291     pushEnabled();
00292     m_hide=TRUE;
00293   }
00294   if (op->isLast())  
00295   {
00296     popEnabled();
00297     if (!m_hide) m_t << "</programlisting>"; 
00298   }
00299   else
00300   {
00301     if (!m_hide) m_t << endl;
00302   }
00303 }
00304 
00305 void XmlDocVisitor::visit(DocFormula *f)
00306 {
00307   if (m_hide) return;
00308   m_t << "<formula id=\"" << f->id() << "\">";
00309   filter(f->text());
00310   m_t << "</formula>";
00311 }
00312 
00313 void XmlDocVisitor::visit(DocIndexEntry *ie)
00314 {
00315   if (m_hide) return;
00316   m_t << "<indexentry>"
00317            "<primaryie>";
00318   filter(ie->entry());
00319   m_t << "</primaryie>"
00320            "<secondaryie></secondaryie>"
00321          "</indexentry>";
00322 }
00323 
00324 //--------------------------------------
00325 // visitor functions for compound nodes
00326 //--------------------------------------
00327 
00328 void XmlDocVisitor::visitPre(DocAutoList *l)
00329 {
00330   if (m_hide) return;
00331   if (l->isEnumList())
00332   {
00333     m_t << "<orderedlist>\n";
00334   }
00335   else
00336   {
00337     m_t << "<itemizedlist>\n";
00338   }
00339 }
00340 
00341 void XmlDocVisitor::visitPost(DocAutoList *l)
00342 {
00343   if (m_hide) return;
00344   if (l->isEnumList())
00345   {
00346     m_t << "</orderedlist>\n";
00347   }
00348   else
00349   {
00350     m_t << "</itemizedlist>\n";
00351   }
00352 }
00353 
00354 void XmlDocVisitor::visitPre(DocAutoListItem *)
00355 {
00356   if (m_hide) return;
00357   m_t << "<listitem>";
00358 }
00359 
00360 void XmlDocVisitor::visitPost(DocAutoListItem *) 
00361 {
00362   if (m_hide) return;
00363   m_t << "</listitem>";
00364 }
00365 
00366 void XmlDocVisitor::visitPre(DocPara *) 
00367 {
00368   if (m_hide) return;
00369   m_t << "<para>";
00370 }
00371 
00372 void XmlDocVisitor::visitPost(DocPara *)
00373 {
00374   if (m_hide) return;
00375   m_t << "</para>";
00376 }
00377 
00378 void XmlDocVisitor::visitPre(DocRoot *)
00379 {
00380   //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
00381 }
00382 
00383 void XmlDocVisitor::visitPost(DocRoot *)
00384 {
00385   //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
00386 }
00387 
00388 void XmlDocVisitor::visitPre(DocSimpleSect *s)
00389 {
00390   if (m_hide) return;
00391   m_t << "<simplesect kind=\"";
00392   switch(s->type())
00393   {
00394     case DocSimpleSect::See: 
00395       m_t << "see"; break;
00396     case DocSimpleSect::Return: 
00397       m_t << "return"; break;
00398     case DocSimpleSect::Author: 
00399       m_t << "author"; break;
00400     case DocSimpleSect::Authors: 
00401       m_t << "authors"; break;
00402     case DocSimpleSect::Version: 
00403       m_t << "version"; break;
00404     case DocSimpleSect::Since: 
00405       m_t << "since"; break;
00406     case DocSimpleSect::Date: 
00407       m_t << "date"; break;
00408     case DocSimpleSect::Note: 
00409       m_t << "note"; break;
00410     case DocSimpleSect::Warning:
00411       m_t << "warning"; break;
00412     case DocSimpleSect::Pre:
00413       m_t << "pre"; break;
00414     case DocSimpleSect::Post:
00415       m_t << "post"; break;
00416     case DocSimpleSect::Invar:
00417       m_t << "invariant"; break;
00418     case DocSimpleSect::Remark:
00419       m_t << "remark"; break;
00420     case DocSimpleSect::Attention:
00421       m_t << "attention"; break;
00422     case DocSimpleSect::User: 
00423       m_t << "par"; break;
00424     case DocSimpleSect::Rcs: 
00425       m_t << "rcs"; break;
00426     case DocSimpleSect::Unknown:  break;
00427   }
00428   m_t << "\">";
00429 }
00430 
00431 void XmlDocVisitor::visitPost(DocSimpleSect *)
00432 {
00433   if (m_hide) return;
00434   m_t << "</simplesect>\n";
00435 }
00436 
00437 void XmlDocVisitor::visitPre(DocTitle *)
00438 {
00439   if (m_hide) return;
00440   m_t << "<title>";
00441 }
00442 
00443 void XmlDocVisitor::visitPost(DocTitle *)
00444 {
00445   if (m_hide) return;
00446   m_t << "</title>";
00447 }
00448 
00449 void XmlDocVisitor::visitPre(DocSimpleList *)
00450 {
00451   if (m_hide) return;
00452   m_t << "<itemizedlist>\n";
00453 }
00454 
00455 void XmlDocVisitor::visitPost(DocSimpleList *)
00456 {
00457   if (m_hide) return;
00458   m_t << "</itemizedlist>\n";
00459 }
00460 
00461 void XmlDocVisitor::visitPre(DocSimpleListItem *)
00462 {
00463   if (m_hide) return;
00464   m_t << "<listitem>";
00465 }
00466 
00467 void XmlDocVisitor::visitPost(DocSimpleListItem *) 
00468 {
00469   if (m_hide) return;
00470   m_t << "</listitem>\n";
00471 }
00472 
00473 void XmlDocVisitor::visitPre(DocSection *s)
00474 {
00475   if (m_hide) return;
00476   m_t << "<sect" << s->level() << " id=\"" << s->file();
00477   if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();
00478   m_t << "\">" << endl;
00479   m_t << "<title>";
00480   filter(s->title());
00481   m_t << "</title>" << endl;
00482 }
00483 
00484 void XmlDocVisitor::visitPost(DocSection *s) 
00485 {
00486   m_t << "</sect" << s->level() << ">\n";
00487 }
00488 
00489 void XmlDocVisitor::visitPre(DocHtmlList *s)
00490 {
00491   if (m_hide) return;
00492   if (s->type()==DocHtmlList::Ordered) 
00493     m_t << "<orderedlist>\n"; 
00494   else 
00495     m_t << "<itemizedlist>\n";
00496 }
00497 
00498 void XmlDocVisitor::visitPost(DocHtmlList *s) 
00499 {
00500   if (m_hide) return;
00501   if (s->type()==DocHtmlList::Ordered) 
00502     m_t << "</orderedlist>\n"; 
00503   else 
00504     m_t << "</itemizedlist>\n";
00505 }
00506 
00507 void XmlDocVisitor::visitPre(DocHtmlListItem *)
00508 {
00509   if (m_hide) return;
00510   m_t << "<listitem>\n";
00511 }
00512 
00513 void XmlDocVisitor::visitPost(DocHtmlListItem *) 
00514 {
00515   if (m_hide) return;
00516   m_t << "</listitem>\n";
00517 }
00518 
00519 void XmlDocVisitor::visitPre(DocHtmlDescList *)
00520 {
00521   if (m_hide) return;
00522   m_t << "<variablelist>\n";
00523 }
00524 
00525 void XmlDocVisitor::visitPost(DocHtmlDescList *) 
00526 {
00527   if (m_hide) return;
00528   m_t << "</variablelist>\n";
00529 }
00530 
00531 void XmlDocVisitor::visitPre(DocHtmlDescTitle *)
00532 {
00533   if (m_hide) return;
00534   m_t << "<varlistentry><term>";
00535 }
00536 
00537 void XmlDocVisitor::visitPost(DocHtmlDescTitle *) 
00538 {
00539   if (m_hide) return;
00540   m_t << "</term></varlistentry>\n";
00541 }
00542 
00543 void XmlDocVisitor::visitPre(DocHtmlDescData *)
00544 {
00545   if (m_hide) return;
00546   m_t << "<listitem>";
00547 }
00548 
00549 void XmlDocVisitor::visitPost(DocHtmlDescData *) 
00550 {
00551   if (m_hide) return;
00552   m_t << "</listitem>\n";
00553 }
00554 
00555 void XmlDocVisitor::visitPre(DocHtmlTable *t)
00556 {
00557   if (m_hide) return;
00558   m_t << "<table rows=\"" << t->numRows() 
00559       << "\" cols=\"" << t->numCols() << "\">" ;
00560 }
00561 
00562 void XmlDocVisitor::visitPost(DocHtmlTable *) 
00563 {
00564   if (m_hide) return;
00565   m_t << "</table>\n";
00566 }
00567 
00568 void XmlDocVisitor::visitPre(DocHtmlRow *)
00569 {
00570   if (m_hide) return;
00571   m_t << "<row>\n";
00572 }
00573 
00574 void XmlDocVisitor::visitPost(DocHtmlRow *) 
00575 {
00576   if (m_hide) return;
00577   m_t << "</row>\n";
00578 }
00579 
00580 void XmlDocVisitor::visitPre(DocHtmlCell *c)
00581 {
00582   if (m_hide) return;
00583   if (c->isHeading()) m_t << "<entry thead=\"yes\">"; else m_t << "<entry thead=\"no\">";
00584 }
00585 
00586 void XmlDocVisitor::visitPost(DocHtmlCell *) 
00587 {
00588   if (m_hide) return;
00589   m_t << "</entry>"; 
00590 }
00591 
00592 void XmlDocVisitor::visitPre(DocHtmlCaption *)
00593 {
00594   if (m_hide) return;
00595   m_t << "<caption>";
00596 }
00597 
00598 void XmlDocVisitor::visitPost(DocHtmlCaption *) 
00599 {
00600   if (m_hide) return;
00601   m_t << "</caption>\n";
00602 }
00603 
00604 void XmlDocVisitor::visitPre(DocInternal *)
00605 {
00606   if (m_hide) return;
00607   m_t << "<internal>";
00608 }
00609 
00610 void XmlDocVisitor::visitPost(DocInternal *) 
00611 {
00612   if (m_hide) return;
00613   m_t << "</internal>" << endl;
00614 }
00615 
00616 void XmlDocVisitor::visitPre(DocHRef *href)
00617 {
00618   if (m_hide) return;
00619   m_t << "<ulink url=\"" << href->url() << "\">";
00620 }
00621 
00622 void XmlDocVisitor::visitPost(DocHRef *) 
00623 {
00624   if (m_hide) return;
00625   m_t << "</ulink>";
00626 }
00627 
00628 void XmlDocVisitor::visitPre(DocHtmlHeader *header)
00629 {
00630   if (m_hide) return;
00631   m_t << "<heading level=\"" << header->level() << "\">";
00632 }
00633 
00634 void XmlDocVisitor::visitPost(DocHtmlHeader *) 
00635 {
00636   if (m_hide) return;
00637   m_t << "</heading>\n";
00638 }
00639 
00640 void XmlDocVisitor::visitPre(DocImage *img)
00641 {
00642   if (m_hide) return;
00643   m_t << "<image type=\"";
00644   switch(img->type())
00645   {
00646     case DocImage::Html:  m_t << "html"; break;
00647     case DocImage::Latex: m_t << "latex"; break;
00648     case DocImage::Rtf:   m_t << "rtf"; break;
00649   }
00650   m_t << "\"";
00651 
00652   QString baseName=img->name();
00653   int i;
00654   if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
00655   {
00656     baseName=baseName.right(baseName.length()-i-1);
00657   }
00658   m_t << " name=\"" << baseName << "\"";
00659   if (!img->width().isEmpty())
00660   {
00661     m_t << " width=\"";
00662     filter(img->width());
00663     m_t << "\"";
00664   }
00665   else if (!img->height().isEmpty())
00666   {
00667     m_t << " height=\"";
00668     filter(img->height());
00669     m_t << "\"";
00670   }
00671   m_t << ">";
00672 
00673   // copy the image to the output dir
00674   QFile inImage(img->name());
00675   QFile outImage(Config_getString("XML_OUTPUT")+"/"+baseName.ascii());
00676   if (inImage.open(IO_ReadOnly))
00677   {
00678     if (outImage.open(IO_WriteOnly))
00679     {
00680       char *buffer = new char[inImage.size()];
00681       inImage.readBlock(buffer,inImage.size());
00682       outImage.writeBlock(buffer,inImage.size());
00683       outImage.flush();
00684       delete buffer;
00685     }
00686   }
00687 }
00688 
00689 void XmlDocVisitor::visitPost(DocImage *) 
00690 {
00691   if (m_hide) return;
00692   m_t << "</image>" << endl;
00693 }
00694 
00695 void XmlDocVisitor::visitPre(DocDotFile *df)
00696 {
00697   if (m_hide) return;
00698   m_t << "<dotfile name=\"" << df->file() << "\">";
00699 }
00700 
00701 void XmlDocVisitor::visitPost(DocDotFile *) 
00702 {
00703   if (m_hide) return;
00704   m_t << "</dotfile>" << endl;
00705 }
00706 
00707 void XmlDocVisitor::visitPre(DocLink *lnk)
00708 {
00709   if (m_hide) return;
00710   startLink(lnk->ref(),lnk->file(),lnk->anchor());
00711 }
00712 
00713 void XmlDocVisitor::visitPost(DocLink *) 
00714 {
00715   if (m_hide) return;
00716   endLink();
00717 }
00718 
00719 void XmlDocVisitor::visitPre(DocRef *ref)
00720 {
00721   if (m_hide) return;
00722    if (!ref->file().isEmpty()) startLink(ref->ref(),ref->file(),ref->anchor());
00723   if (!ref->hasLinkText()) filter(ref->targetTitle());
00724 }
00725 
00726 void XmlDocVisitor::visitPost(DocRef *ref) 
00727 {
00728   if (m_hide) return;
00729   if (!ref->file().isEmpty()) endLink();
00730   //m_t << " ";
00731 }
00732 
00733 void XmlDocVisitor::visitPre(DocSecRefItem *ref)
00734 {
00735   if (m_hide) return;
00736   m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">";
00737 }
00738 
00739 void XmlDocVisitor::visitPost(DocSecRefItem *) 
00740 {
00741   if (m_hide) return;
00742   m_t << "</tocitem>" << endl;
00743 }
00744 
00745 void XmlDocVisitor::visitPre(DocSecRefList *)
00746 {
00747   if (m_hide) return;
00748   m_t << "<toclist>" << endl;
00749 }
00750 
00751 void XmlDocVisitor::visitPost(DocSecRefList *) 
00752 {
00753   if (m_hide) return;
00754   m_t << "</toclist>" << endl;
00755 }
00756 
00757 //void XmlDocVisitor::visitPre(DocLanguage *l)
00758 //{
00759 //  if (m_hide) return;
00760 //  m_t << "<language langid=\"" << l->id() << "\">";
00761 //}
00762 //
00763 //void XmlDocVisitor::visitPost(DocLanguage *) 
00764 //{
00765 //  if (m_hide) return;
00766 //  m_t << "</language>" << endl;
00767 //}
00768 
00769 void XmlDocVisitor::visitPre(DocParamSect *s)
00770 {
00771   if (m_hide) return;
00772   m_t << "<parameterlist kind=\"";
00773   switch(s->type())
00774   {
00775     case DocParamSect::Param: 
00776       m_t << "param"; break;
00777     case DocParamSect::RetVal: 
00778       m_t << "retval"; break;
00779     case DocParamSect::Exception: 
00780       m_t << "exception"; break;
00781     case DocParamSect::TemplateParam: 
00782       m_t << "templateparam"; break;
00783     default:
00784       ASSERT(0);
00785   }
00786   m_t << "\">";
00787 }
00788 
00789 void XmlDocVisitor::visitPost(DocParamSect *)
00790 {
00791   if (m_hide) return;
00792   m_t << "</parameterlist>" << endl;
00793 }
00794 
00795 void XmlDocVisitor::visitPre(DocParamList *pl)
00796 {
00797   if (m_hide) return;
00798   m_t << "<parameteritem>" << endl;
00799   m_t << "<parameternamelist>" << endl;
00800   //QStrListIterator li(pl->parameters());
00801   //const char *s;
00802   QListIterator<DocNode> li(pl->parameters());
00803   DocNode *param;
00804   for (li.toFirst();(param=li.current());++li)
00805   {
00806     m_t << "<parametername";
00807     if (pl->direction()!=DocParamSect::Unspecified)
00808     {
00809       m_t << " direction=\"";
00810       if (pl->direction()==DocParamSect::In)
00811       {
00812         m_t << "in";
00813       }
00814       else if (pl->direction()==DocParamSect::Out)
00815       {
00816         m_t << "out";
00817       }
00818       else if (pl->direction()==DocParamSect::InOut)
00819       {
00820         m_t << "inout";
00821       }
00822       m_t << "\"";
00823     }
00824     m_t << ">";
00825     if (param->kind()==DocNode::Kind_Word)
00826     {
00827       visit((DocWord*)param); 
00828     }
00829     else if (param->kind()==DocNode::Kind_LinkedWord)
00830     {
00831       visit((DocLinkedWord*)param); 
00832     }
00833     m_t << "</parametername>" << endl;
00834   }
00835   m_t << "</parameternamelist>" << endl;
00836   m_t << "<parameterdescription>" << endl;
00837 }
00838 
00839 void XmlDocVisitor::visitPost(DocParamList *)
00840 {
00841   if (m_hide) return;
00842   m_t << "</parameterdescription>" << endl;
00843   m_t << "</parameteritem>" << endl;
00844 }
00845 
00846 void XmlDocVisitor::visitPre(DocXRefItem *x)
00847 {
00848   if (m_hide) return;
00849   m_t << "<xrefsect id=\"";
00850   m_t << x->file() << "_1" << x->anchor();
00851   m_t << "\">";
00852   m_t << "<xreftitle>";
00853   filter(x->title());
00854   m_t << "</xreftitle>";
00855   m_t << "<xrefdescription>";
00856 }
00857 
00858 void XmlDocVisitor::visitPost(DocXRefItem *)
00859 {
00860   if (m_hide) return;
00861   m_t << "</xrefdescription>";
00862   m_t << "</xrefsect>";
00863 }
00864 
00865 void XmlDocVisitor::visitPre(DocInternalRef *ref)
00866 {
00867   if (m_hide) return;
00868   startLink(0,ref->file(),ref->anchor());
00869 }
00870 
00871 void XmlDocVisitor::visitPost(DocInternalRef *) 
00872 {
00873   if (m_hide) return;
00874   endLink();
00875   m_t << " ";
00876 }
00877 
00878 void XmlDocVisitor::visitPre(DocCopy *c)
00879 {
00880   if (m_hide) return;
00881   m_t << "<copydoc link=\"" << convertToXML(c->link()) << "\">";
00882 }
00883 
00884 void XmlDocVisitor::visitPost(DocCopy *)
00885 {
00886   if (m_hide) return;
00887   m_t << "</copydoc>" << endl;
00888 }
00889 
00890 void XmlDocVisitor::visitPre(DocText *)
00891 {
00892 }
00893 
00894 void XmlDocVisitor::visitPost(DocText *)
00895 {
00896 }
00897 
00898 void XmlDocVisitor::filter(const char *str)
00899 { 
00900   m_t << convertToXML(str);
00901 }
00902 
00903 void XmlDocVisitor::startLink(const QString &ref,const QString &file,const QString &anchor)
00904 {
00905   m_t << "<ref refid=\"" << file;
00906   if (!anchor.isEmpty()) m_t << "_1" << anchor;
00907   m_t << "\" kindref=\"";
00908   if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";
00909   m_t << "\"";
00910   if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";
00911   m_t << ">";
00912 }
00913 
00914 void XmlDocVisitor::endLink()
00915 {
00916   m_t << "</ref>";
00917 }
00918 
00919 void XmlDocVisitor::pushEnabled()
00920 {
00921   m_enabled.push(new bool(m_hide));
00922 }
00923 
00924 void XmlDocVisitor::popEnabled()
00925 {
00926   bool *v=m_enabled.pop();
00927   ASSERT(v!=0);
00928   m_hide = *v;
00929   delete v;
00930 }
00931 



Generated on Mon Mar 31 10:58:50 2008 by  doxygen 1.5.1