/****************************************************************************** * * * * * Copyright (C) 1997-2002 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. * */ #include #include "qtbc.h" #include "xmlgen.h" #include "doxygen.h" #include "message.h" #include "config.h" #include "classlist.h" #include "util.h" #include "defargs.h" #include "outputgen.h" #include "doc.h" #include "dot.h" #include "code.h" #include "page.h" #include "filename.h" #include "version.h" #include #include #include // no debug info #define XML_DB(x) do {} while(0) // debug to stdout //#define XML_DB(x) printf x // debug inside output //#define XML_DB(x) QCString __t;__t.sprintf x;m_t << __t QCString sectionTypeToString(BaseOutputDocInterface::SectionTypes t) { switch (t) { case BaseOutputDocInterface::See: return "see"; case BaseOutputDocInterface::Return: return "return"; case BaseOutputDocInterface::Author: return "author"; case BaseOutputDocInterface::Version: return "version"; case BaseOutputDocInterface::Since: return "since"; case BaseOutputDocInterface::Date: return "date"; case BaseOutputDocInterface::Bug: return "bug"; case BaseOutputDocInterface::Note: return "note"; case BaseOutputDocInterface::Warning: return "warning"; case BaseOutputDocInterface::Par: return "par"; case BaseOutputDocInterface::Deprecated: return "deprecated"; case BaseOutputDocInterface::Pre: return "pre"; case BaseOutputDocInterface::Post: return "post"; case BaseOutputDocInterface::Invar: return "invariant"; case BaseOutputDocInterface::Remark: return "remark"; case BaseOutputDocInterface::Attention: return "attention"; case BaseOutputDocInterface::Todo: return "todo"; case BaseOutputDocInterface::Test: return "test"; case BaseOutputDocInterface::RCS: return "rcs"; case BaseOutputDocInterface::EnumValues: return "enumvalues"; case BaseOutputDocInterface::Examples: return "examples"; } return "illegal"; } inline void writeXMLString(QTextStream &t,const char *s) { t << convertToXML(s); } void writeXMLLink(QTextStream &t,const char *extRef,const char *compoundId, const char *anchorId,const char *text) { t << ""; writeXMLString(t,text); t << ""; } class TextGeneratorXMLImpl : public TextGeneratorIntf { public: TextGeneratorXMLImpl(QTextStream &t): m_t(t) {} void writeString(const char *s) const { writeXMLString(m_t,s); } void writeBreak() const {} void writeLink(const char *extRef,const char *file, const char *anchor,const char *text ) const { writeXMLLink(m_t,extRef,file,anchor,text); } private: QTextStream &m_t; }; template class ValStack { public: ValStack() : m_values(10), m_sp(0), m_size(10) {} virtual ~ValStack() {} ValStack(const ValStack &s) { m_values=s.m_values.copy(); m_sp=s.m_sp; m_size=s.m_size; } ValStack &operator=(const ValStack &s) { m_values=s.m_values.copy(); m_sp=s.m_sp; m_size=s.m_size; return *this; } void push(T v) { m_sp++; if (m_sp>=m_size) { m_size+=10; m_values.resize(m_size); } m_values[m_sp]=v; } T pop() { ASSERT(m_sp!=0); return m_values[m_sp--]; } T& top() { ASSERT(m_sp!=0); return m_values[m_sp]; } bool isEmpty() { return m_sp==0; } uint count() const { return m_sp; } private: QArray m_values; int m_sp; int m_size; }; /*! This class is used by the documentation parser. * Its methods are called when some XML text or markup * needs to be written. */ class XMLGenerator : public OutputDocInterface { public: // helper functions void startParMode() { if (!m_inParStack.isEmpty() && !m_inParStack.top()) { m_inParStack.top() = TRUE; m_t << ""; XML_DB(("start par at level=%d\n",m_inParStack.count())); } else if (m_inParStack.isEmpty()) { m_inParStack.push(TRUE); m_t << ""; XML_DB(("start par at level=%d\n",m_inParStack.count())); } } void endParMode() { if (!m_inParStack.isEmpty() && m_inParStack.top()) { m_inParStack.top() = FALSE; m_t << "" << endl; XML_DB(("end par at level=%d\n",m_inParStack.count())); } } void startNestedPar() { m_inParStack.push(FALSE); XML_DB(("enter par level=%d\n",m_inParStack.count())); } void endNestedPar() { XML_DB(("leave par level=%d\n",m_inParStack.count())); if (m_inParStack.pop()) { m_t << "" << endl; } else { //XML_DB(("ILLEGAL par level!\n")); } } // Standard generator functions to be implemented by all generators void docify(const char *s) { XML_DB(("(docify \"%s\")\n",s)); startParMode(); writeXMLString(m_t,s); } void writeChar(char c) { char s[2];s[0]=c;s[1]=0; docify(s); } void writeString(const char *text) { //m_t << text; docify(text); } void startItemList() { XML_DB(("(startItemList)\n")); startParMode(); m_t << "" << endl;; m_inListStack.push(TRUE); } void startEnumList() { XML_DB(("(startEnumList)\n")); startParMode(); m_t << ""; m_inListStack.push(TRUE); } void writeListItem() { XML_DB(("(writeListItem)\n")); if (!m_inListStack.isEmpty() && m_inListStack.top()) // first element { m_inListStack.top()=FALSE; } else // not first element, end previous element first { endParMode(); endNestedPar(); m_t << "" << endl; } m_t << ""; startNestedPar(); } void endItemList() { XML_DB(("(endItemList)\n")); if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element { endParMode(); endNestedPar(); m_t << "" << endl; } m_t << "" << endl; } void endEnumList() { XML_DB(("(endEnumList)\n")); if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element { endParMode(); m_t << "" << endl; endNestedPar(); } m_t << "" << endl; } void newParagraph() { XML_DB(("(newParagraph)\n")); endParMode(); startParMode(); } void startBold() { XML_DB(("(startBold)\n")); startParMode(); m_t << ""; // non DocBook } void endBold() { XML_DB(("(endBold)\n")); m_t << ""; // non DocBook } void startTypewriter() { XML_DB(("(startTypewriter)\n")); startParMode(); m_t << ""; } void endTypewriter() { XML_DB(("(endTypewriter)\n")); m_t << ""; } void startEmphasis() { XML_DB(("(startEmphasis)\n")); startParMode(); m_t << ""; } void endEmphasis() { XML_DB(("(endEmphasis)\n")); m_t << ""; } void startCodeFragment() { XML_DB(("(startCodeFragment)\n")); startParMode(); m_t << ""; } void endCodeFragment() { XML_DB(("(endCodeFragment)\n")); m_t << ""; } void startPreFragment() { XML_DB(("(startPreFragment)\n")); startParMode(); m_t << ""; } void endPreFragment() { XML_DB(("(endPreFragment)\n")); m_t << ""; } void writeRuler() { XML_DB(("(startParMode)\n")); startParMode(); m_t << ""; } void startDescription() { XML_DB(("(startDescription)\n")); startParMode(); m_t << ""; m_inListStack.push(TRUE); } void endDescription() { XML_DB(("(endDescription)\n")); if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element { endNestedPar(); m_t << "" << endl; } m_t << ""; if (!m_inListStack.isEmpty()) m_inListStack.pop(); } void startDescItem() { XML_DB(("(startDescItem)\n")); if (!m_inListStack.isEmpty() && m_inListStack.top()) // first element { m_inListStack.top()=FALSE; } else // not first element, end previous element first { endNestedPar(); m_t << ""; } m_t << ""; } void endDescItem() { XML_DB(("(endDescItem)\n")); m_t << ""; startNestedPar(); } void startDescList(SectionTypes st) { XML_DB(("(startDescList)\n")); endParMode(); m_t << ""; startNestedPar(); m_inParStack.top() = TRUE; } void endDescList() { XML_DB(("(endDescList)\n")); endNestedPar(); m_t << "</simplesect>"; } void startParamList(ParamListTypes t) { XML_DB(("(startParamList)\n")); startParMode(); QCString kind; switch(t) { case Param: kind="param"; break; case RetVal: kind="retval"; break; case Exception: kind="exception"; break; } m_t << "<parameterlist kind=\"" << kind << "\"><title>"; // non DocBook startNestedPar(); m_inParStack.top() = TRUE; m_inParamList = TRUE; } void endParamList() { XML_DB(("(endParamList)\n")); m_inParamList = FALSE; m_t << "</parameterlist>"; } void endDescTitle() { m_inParStack.top() = FALSE; endNestedPar(); XML_DB(("(endDescTitle)\n")); m_t << ""; if (!m_inParamList) startNestedPar(); } void writeDescItem() { XML_DB(("(writeDescItem)\n")); } void startDescTable() { XML_DB(("(startDescTable)\n")); } void endDescTable() { XML_DB(("(endDescTable)\n")); } void startDescTableTitle() { XML_DB(("(startDescTableTitle)\n")); m_t << ""; // non docbook } void endDescTableTitle() { XML_DB(("(endDescTableTitle)\n")); m_t << ""; // non docbook } void startDescTableData() { XML_DB(("(startDescTableData)\n")); m_t << ""; // non docbook startNestedPar(); } void endDescTableData() { XML_DB(("(endDescTableData)\n")); endNestedPar(); m_t << ""; // non docbook } void lineBreak() { XML_DB(("(lineBreak)\n")); startParMode(); m_t << ""; // non docbook } void writeNonBreakableSpace(int num) { XML_DB(("(writeNonBreakableSpace)\n")); int i;for (i=0;i"; } void endHtmlLink() { XML_DB(("(endHtmlLink)\n")); m_t << ""; } void writeMailLink(const char *url) { XML_DB(("(writeMailLink)\n")); startParMode(); m_t << ""; docify(url); m_t << ""; } void startSection(const char *id,const char *,bool subsection) { XML_DB(("(startSection)\n")); endParMode(); m_t << ""; startNestedPar(); m_inParStack.top() = TRUE; } void endSection(const char *,bool subsection) { XML_DB(("(endSection)\n")); m_t << ""; m_inParStack.top() = FALSE; endNestedPar(); } void startSubsection() { XML_DB(("(startSubsection)\n")); endParMode(); m_t << ""; startNestedPar(); m_inParStack.top() = TRUE; } void endSubsection() { XML_DB(("(endSubsection)\n")); m_t << ""; m_inParStack.top() = FALSE; endNestedPar(); } void startSubsubsection() { XML_DB(("(startSubsubsection)\n")); endParMode(); m_t << ""; startNestedPar(); m_inParStack.top() = TRUE; } void endSubsubsection() { XML_DB(("(endSubsubsection)\n")); m_t << ""; m_inParStack.top() = FALSE; endNestedPar(); } void startCenter() { XML_DB(("(startCenter)\n")); startParMode(); m_t << "
"; // non docbook } void endCenter() { XML_DB(("(endCenter)\n")); m_t << "
"; // non docbook } void startSmall() { XML_DB(("(startSmall)\n")); startParMode(); m_t << ""; // non docbook } void endSmall() { XML_DB(("(endSmall)\n")); m_t << ""; // non docbook } void startSubscript() { XML_DB(("(startSubscript)\n")); startParMode(); m_t << ""; } void endSubscript() { XML_DB(("(endSubscript)\n")); m_t << ""; } void startSuperscript() { XML_DB(("(startSuperscript)\n")); startParMode(); m_t << ""; } void endSuperscript() { XML_DB(("(endSuperscript)\n")); m_t << ""; } void startTable(bool,int cols) { XML_DB(("startTable\n")); startParMode(); m_t << "\n"; } void endTable(bool) { XML_DB(("endTable\n")); m_t << "\n
"; } void startCaption() { XML_DB(("startCaption")); m_t << ""; } void endCaption() { XML_DB(("encCaption")); m_t << ""; // we need manually add a para here because cells are // parsed before the table is generated, and thus // are already parsed as if they are inside a paragraph. m_t << ""; } void endTableRow() { XML_DB(("(endTableRow)\n")); m_t << "" << endl; } void nextTableColumn() { XML_DB(("(nextTableColumn)\n")); m_t << ""; // we need manually add a para here because cells are // parsed before the table is generated, and thus // are already parsed as if they are inside a paragraph. m_t << ""; } void endTableColumn() { XML_DB(("(endTableColumn)\n")); // we need manually add a para here because cells are // parsed before the table is generated, and thus // are already parsed as if they are inside a paragraph. m_t << ""; m_t << ""; } void writeQuote() { m_t << "\""; } void writeCopyright() { m_t << "©"; } void writeUmlaut(char c) { m_t << "&" << c << "uml;"; } void writeAcute(char c) { m_t << "&" << c << "acute;"; } void writeGrave(char c) { m_t << "&" << c << "grave;"; } void writeCirc(char c) { m_t << "&" << c << "circ;"; } void writeTilde(char c) { m_t << "&" << c << "tilde;"; } void writeRing(char c) { m_t << "&" << c << "ring;"; } void writeSharpS() { m_t << "ß"; } void writeCCedil(char c) { m_t << "&" << c << "cedil;"; } void startTitle() { XML_DB(("(startTitle)\n")); m_t << ""; startNestedPar(); m_inParStack.top() = TRUE; } void endTitle() { m_inParStack.top() = FALSE; endNestedPar(); XML_DB(("(endTitle)\n")); m_t << "" << endl; } void writeAnchor(const char *id,const char *name) { XML_DB(("(writeAnchor)\n")); startParMode(); m_t << ""; } void writeSectionRef(const char *,const char *id, const char *name,const char *text) { XML_DB(("(writeSectionRef)\n")); startParMode(); m_t << ""; docify(text); m_t << ""; } void writeSectionRefItem(const char *,const char *,const char *) { m_t << "(writeSectionRefItem)"; } void addIndexItem(const char *primaryie,const char *secondaryie) { XML_DB(("(addIndexItem)\n")); startParMode(); m_t << ""; docify(primaryie); m_t << ""; docify(secondaryie); m_t << ""; } void writeFormula(const char *id,const char *text) { XML_DB(("(writeFormula)\n")); startParMode(); m_t << ""; // non Docbook docify(text); m_t << ""; } void startImage(const char *name,const char *size,bool /*caption*/) { XML_DB(("(startImage)\n")); startParMode(); m_t << ""; // non docbook } void endImage(bool) { XML_DB(("(endImage)\n")); m_t << ""; } void startDotFile(const char *name,bool /*caption*/) { XML_DB(("(startDotFile)\n")); startParMode(); m_t << ""; // non docbook } void endDotFile(bool) { XML_DB(("(endDotFile)\n")); m_t << ""; } void startTextLink(const char *name,const char *anchor) { XML_DB(("(startTextLink)\n")); startParMode(); m_t << ""; } void endTextLink() { XML_DB(("(endTextLink)\n")); m_t << ""; } void startPageRef() { XML_DB(("(startPageRef)\n")); } void endPageRef(const char *,const char *) { XML_DB(("(endPageRef)\n")); } void writeLineNumber(const char *extRef,const char *compId, const char *anchorId,int l) { XML_DB(("(writeLineNumber)\n")); m_t << ""; } void startCodeLine() { XML_DB(("(startCodeLine)\n")); startParMode(); m_t << ""; // non DocBook } void endCodeLine() { XML_DB(("(endCodeLine)\n")); m_t << "" << endl; // non DocBook } void startCodeAnchor(const char *id) { XML_DB(("(startCodeAnchor)\n")); startParMode(); m_t << ""; } void endCodeAnchor() { XML_DB(("(endCodeAnchor)\n")); m_t << ""; } void startFontClass(const char *colorClass) { XML_DB(("(startFontClass)\n")); m_t << ""; // non DocBook } void endFontClass() { XML_DB(("(endFontClass)\n")); m_t << ""; // non DocBook } void codify(const char *text) { XML_DB(("(codify \"%s\")\n",text)); docify(text); } void startHtmlOnly() { XML_DB(("(startHtmlOnly)\n")); m_t << "" << endl; } void endHtmlOnly() { XML_DB(("(endHtmlOnly)\n")); m_t << "" << endl; } void startLatexOnly() { XML_DB(("(startLatexOnly)\n")); m_t << "" << endl; } void endLatexOnly() { XML_DB(("(endLatexOnly)\n")); m_t << "" << endl; } // Generator specific functions /*! Create a clone of this generator. Uses the copy constructor */ OutputDocInterface *clone() { return new XMLGenerator(this); } /*! Append the output written to generator \a g to this generator */ void append(const OutputDocInterface *g) { const XMLGenerator *xg = (const XMLGenerator *)g; //printf("Appending \n>>>>\n`%s'\n<<<<\n and \n>>>>\n`%s'\n<<<<\n",getContents().data(),xg->getContents().data()); m_t << xg->getContents(); m_inParStack = xg->m_inParStack; m_inListStack = xg->m_inListStack; m_inParamList = xg->m_inParamList; } /*! constructor. */ XMLGenerator() { m_b.setBuffer(m_a); m_b.open( IO_WriteOnly ); m_t.setDevice(&m_b); m_t.setEncoding(QTextStream::Latin1); m_inParamList = FALSE; } /*! copy constructor */ XMLGenerator(const XMLGenerator *xg) { m_b.setBuffer(m_a); m_b.open( IO_WriteOnly ); m_t.setDevice(&m_b); m_t.setEncoding(QTextStream::Latin1); //printf("Cloning >>%s<< m_parStack.count()=%d\n", // xg->getContents().data(),xg->m_inParStack.count()); // copy state variables m_inParStack = xg->m_inParStack; m_inListStack = xg->m_inListStack; m_inParamList = xg->m_inParamList; } /*! destructor */ virtual ~XMLGenerator() { } /*! Returns the output written to this generator as a string */ QCString getContents() const { QCString s; s.resize(m_a.size()+1); memcpy(s.data(),m_a.data(),m_a.size()); s.at(m_a.size())='\0'; return s; } private: // only one destination stream, so these do not have to be implemented void pushGeneratorState() {} void popGeneratorState() {} void disableAllBut(OutputGenerator::OutputType) {} void enableAll() {} void disableAll() {} void disable(OutputGenerator::OutputType) {} void enable(OutputGenerator::OutputType) {} bool isEnabled(OutputGenerator::OutputType) { return TRUE; } QTextStream m_t; QByteArray m_a; QBuffer m_b; ValStack m_inParStack; ValStack m_inListStack; bool m_inParamList; friend void writeXMLCodeBlock(QTextStream &t,FileDef *fd); }; static void writeXMLDocBlock(QTextStream &t, const QCString &fileName, int lineNr, const QCString &scope, MemberDef *md, const QCString &text) { QCString stext = text.stripWhiteSpace(); if (text.isEmpty()) return; XMLGenerator *xmlGen = new XMLGenerator; //xmlGen->startParMode(); parseDoc(*xmlGen, fileName, // input definition file lineNr, // input definition line scope, // scope (which should not be linked to) md, // member (which should not be linked to) stext+"\n" // actual text ); xmlGen->endParMode(); t << xmlGen->getContents(); delete xmlGen; } void writeXMLCodeBlock(QTextStream &t,FileDef *fd) { initParseCodeContext(); XMLGenerator *xmlGen = new XMLGenerator; xmlGen->m_inParStack.push(TRUE); parseCode(*xmlGen, 0, fileToString(fd->absFilePath(),Config_getBool("FILTER_SOURCE_FILES")), FALSE, 0, fd); t << xmlGen->getContents(); delete xmlGen; } static void writeMemberReference(QTextStream &t,Definition *def,MemberDef *rmd,const char *tagName) { QCString scope = rmd->getScopeString(); QCString name = rmd->name(); if (!scope.isEmpty() && scope!=def->name()) { name.prepend(scope+"::"); } Definition *d = rmd->getOuterScope(); if (d==Doxygen::globalScope) d=rmd->getBodyDef(); if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef()) // link to definition in code { t << " <" << tagName << " id=\""; t << rmd->getBodyDef()->getOutputFileBase() << "_1" // encoded `:' character (see util.cpp:convertNameToFile) << rmd->anchor() << "\">" << convertToXML(name) << "" << endl; } else if (rmd->isLinkable() && d && d->isLinkable()) // link to declaration in documentation (in absense of a definition) { t << " <" << tagName << " id=\""; t << d->getOutputFileBase() << "_1" // encoded `:' character (see util.cpp:convertNameToFile) << rmd->anchor() << "\">" << convertToXML(name) << "" << endl; } } static void generateXMLForMember(MemberDef *md,QTextStream &ti,QTextStream &t,Definition *def) { // + declaration/definition arg lists // + reimplements // + reimplementedBy // + exceptions // + const/volatile specifiers // - examples // + source definition // + source references // + source referenced by // - body code // - template arguments // (templateArguments(), definitionTemplateParameterLists()) if (md->memberType()==MemberDef::EnumValue) return; ti << " getOutputFileBase() << "_1" << md->anchor() << "\">" << convertToXML(md->name()) << "" << endl; QCString scopeName; if (md->getClassDef()) scopeName=md->getClassDef()->name(); else if (md->getNamespaceDef()) scopeName=md->getNamespaceDef()->name(); t << " memberType()) { case MemberDef::Define: memType="define"; break; case MemberDef::EnumValue: ASSERT(0); break; case MemberDef::Property: memType="property"; break; case MemberDef::Variable: memType="variable"; break; case MemberDef::Typedef: memType="typedef"; break; case MemberDef::Enumeration: memType="enum"; break; case MemberDef::Function: memType="function"; isFunc=TRUE; break; case MemberDef::Signal: memType="signal"; isFunc=TRUE; break; case MemberDef::Prototype: memType="prototype"; isFunc=TRUE; break; case MemberDef::Friend: memType="friend"; isFunc=TRUE; break; case MemberDef::DCOP: memType="dcop"; isFunc=TRUE; break; case MemberDef::Slot: memType="slot"; isFunc=TRUE; break; } t << memType << "\" id=\""; t << md->getOutputFileBase() << "_1" // encoded `:' character (see util.cpp:convertNameToFile) << md->anchor(); t << "\""; t << " virt=\""; switch (md->virtualness()) { case Normal: t << "normal"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; default: ASSERT(0); } t << "\" prot=\""; switch(md->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; } t << "\""; if (isFunc) { ArgumentList *al = md->argumentList(); t << " const=\""; if (al && al->constSpecifier) t << "yes"; else t << "no"; t << "\" volatile=\""; if (al && al->volatileSpecifier) t << "yes"; else t << "no"; t << "\""; } t << ">" << endl; if (md->memberType()!=MemberDef::Define && md->memberType()!=MemberDef::Enumeration ) { QCString typeStr = md->typeString(); //replaceAnonymousScopes(md->typeString()); t << " "; linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),typeStr); t << "" << endl; } t << " " << convertToXML(md->name()) << "" << endl; MemberDef *rmd = md->reimplements(); if (rmd) { t << " getOutputFileBase() << "_1" << rmd->anchor() << "\">" << convertToXML(rmd->name()) << ""; } MemberList *rbml = md->reimplementedBy(); if (rbml) { MemberListIterator mli(*rbml); for (mli.toFirst();(rmd=mli.current());++mli) { t << " getOutputFileBase() << "_1" << rmd->anchor() << "\">" << convertToXML(rmd->name()) << ""; } } if (isFunc) //function { ArgumentList *declAl = md->declArgumentList(); ArgumentList *defAl = md->argumentList(); if (declAl && declAl->count()>0) { ArgumentListIterator declAli(*declAl); ArgumentListIterator defAli(*defAl); Argument *a; for (declAli.toFirst();(a=declAli.current());++declAli) { Argument *defArg = defAli.current(); t << " " << endl; if (!a->attrib.isEmpty()) { t << " "; writeXMLString(t,a->attrib); t << "" << endl; } if (!a->type.isEmpty()) { t << " "; linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),a->type); t << "" << endl; } if (!a->name.isEmpty()) { t << " "; writeXMLString(t,a->name); t << "" << endl; } if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) { t << " "; writeXMLString(t,defArg->name); t << "" << endl; } if (!a->array.isEmpty()) { t << " "; writeXMLString(t,a->array); t << "" << endl; } if (!a->defval.isEmpty()) { t << " "; linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),a->defval); t << "" << endl; } t << " " << endl; if (defArg) ++defAli; } } } else if (md->memberType()==MemberDef::Define && md->argsString()!=0) // define { ArgumentListIterator ali(*md->argumentList()); Argument *a; for (ali.toFirst();(a=ali.current());++ali) { t << " " << a->type << "" << endl; } } if (!md->initializer().isEmpty()) { t << " "; linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),md->initializer()); t << "" << endl; } if (md->excpString()) { t << " "; linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),md->excpString()); t << "" << endl; } if (md->memberType()==MemberDef::Enumeration) // enum { if (md->enumFieldList()) { MemberListIterator emli(*md->enumFieldList()); MemberDef *emd; for (emli.toFirst();(emd=emli.current());++emli) { t << " " << endl; t << " "; writeXMLString(t,emd->name()); t << "" << endl; if (!emd->initializer().isEmpty()) { t << " "; writeXMLString(t,emd->initializer()); t << "" << endl; } t << " " << endl; } } } t << " " << endl; writeXMLDocBlock(t,md->getDefFileName(),md->getDefLine(),scopeName,md,md->briefDescription()); t << " " << endl; t << " " << endl; writeXMLDocBlock(t,md->getDefFileName(),md->getDefLine(),scopeName,md,md->documentation()); t << " " << endl; if (md->getDefLine()!=-1) { t << " getDefFileName() << "\" line=\"" << md->getDefLine() << "\""; if (md->getStartBodyLine()!=-1) { t << " bodystart=\"" << md->getStartBodyLine() << "\" bodyend=\"" << md->getEndBodyLine() << "\""; } t << "/>" << endl; } //printf("md->getReferencesMembers()=%p\n",md->getReferencesMembers()); if (md->getReferencesMembers()) { MemberSDict::Iterator mdi(*md->getReferencesMembers()); MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { writeMemberReference(t,def,rmd,"references"); } } if (md->getReferencedByMembers()) { MemberSDict::Iterator mdi(*md->getReferencedByMembers()); MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { writeMemberReference(t,def,rmd,"referencedby"); } } t << " " << endl; } static void generateXMLSection(Definition *d,QTextStream &ti,QTextStream &t, MemberList *ml,const char *kind,const char *header=0) { if (ml->count()==0) return; // empty list t << " " << endl; if (header) { t << "
" << convertToXML(header) << "
" << endl; } MemberListIterator mli(*ml); MemberDef *md; for (mli.toFirst();(md=mli.current());++mli) { generateXMLForMember(md,ti,t,d); } t << "
" << endl; } static void writeTemplateLists(Definition *d,QTextStream &t) { if (d->definitionType()==Definition::TypeClass) { if (d->getOuterScope()) writeTemplateLists(d->getOuterScope(),t); ClassDef *cd = (ClassDef *)d; ArgumentList *al = cd->templateArguments(); if (al) { t << " " << endl; ArgumentListIterator ali(*al); Argument *a; for (ali.toFirst();(a=ali.current());++ali) { t << " " << endl; if (!a->type.isEmpty()) { t << " "; linkifyText(TextGeneratorXMLImpl(t),d->name(),0,a->type); t << "" << endl; } if (!a->name.isEmpty()) { t << " " << a->name << "" << endl; } if (!a->defval.isEmpty()) { t << " "; linkifyText(TextGeneratorXMLImpl(t),d->name(),0,a->defval); t << "" << endl; } t << " " << endl; } t << " " << endl; } } } static void writeListOfAllMembers(ClassDef *cd,QTextStream &t) { t << " " << endl; MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict()); MemberNameInfo *mni; for (mnii.toFirst();(mni=mnii.current());++mnii) { MemberNameInfoIterator mii(*mni); MemberInfo *mi; for (mii.toFirst();(mi=mii.current());++mii) { MemberDef *md=mi->memberDef; ClassDef *cd=md->getClassDef(); Definition *d=md->getGroupDef(); if (d==0) d = cd; Protection prot = mi->prot; Specifier virt=md->virtualness(); t << " getOutputFileBase() << "_" << md->anchor() << "\" prot=\""; switch (prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; } t << "\" virt=\""; switch(virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; } t << "\""; if (!mi->ambiguityResolutionScope.isEmpty()) { t << " ambiguityscope=\"" << mi->ambiguityResolutionScope << "\""; } t << ">" << convertToXML(cd->name()) << "" << convertToXML(md->name()) << "" << endl; } } t << " " << endl; } static void generateXMLForClass(ClassDef *cd,QTextStream &ti) { // + brief description // + detailed description // + template argument list(s) // - include file // + member groups // + inheritance diagram // + list of direct super classes // + list of direct sub classes // + list of inner classes // + collaboration diagram // + list of all members // + user defined member sections // + standard member sections // + detailed member documentation // - examples using the class if (cd->isReference()) return; // skip external references. if (cd->name().find('@')!=-1) return; // skip anonymous compounds. if (cd->templateMaster()!=0) return; // skip generated template instances. ti << " getOutputFileBase() << "\">" << convertToXML(cd->name()) << "" << endl; QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); QCString fileName=outputDirectory+"/xml/"+cd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } QTextStream t(&f); t << "" << endl; t << "" << endl; t << " getOutputFileBase() << "\" kind=\"" << cd->compoundTypeString() << "\">" << endl; t << " "; writeXMLString(t,cd->name()); t << "" << endl; if (cd->baseClasses()->count()>0) { BaseClassListIterator bcli(*cd->baseClasses()); BaseClassDef *bcd; for (bcli.toFirst();(bcd=bcli.current());++bcli) { t << " classDef->getOutputFileBase() << "\" prot=\""; switch (bcd->prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; } t << "\" virt=\""; switch(bcd->virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t <<"pure-virtual"; break; } t << "\"/>" << endl; } } if (cd->subClasses()->count()>0) { BaseClassListIterator bcli(*cd->subClasses()); BaseClassDef *bcd; for (bcli.toFirst();(bcd=bcli.current());++bcli) { t << " classDef->getOutputFileBase() << "\" prot=\""; switch (bcd->prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; } t << "\" virt=\""; switch(bcd->virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; } t << "\"/>" << endl; } } ClassSDict *cl = cd->getInnerClasses(); if (cl) { ClassSDict::Iterator cli(*cl); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { t << " getOutputFileBase() << "\">" << convertToXML(cd->name()) << "" << endl; } } writeTemplateLists(cd,t); writeListOfAllMembers(cd,t); MemberGroupSDict::Iterator mgli(*cd->memberGroupSDict); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(cd,ti,t,mg->members(),"user-defined",mg->header()); } generateXMLSection(cd,ti,t,&cd->pubTypes,"public-type"); generateXMLSection(cd,ti,t,&cd->pubMembers,"public-func"); generateXMLSection(cd,ti,t,&cd->pubAttribs,"public-attrib"); generateXMLSection(cd,ti,t,&cd->pubSlots,"public-slot"); generateXMLSection(cd,ti,t,&cd->signals,"signal"); generateXMLSection(cd,ti,t,&cd->dcopMethods,"dcop-func"); generateXMLSection(cd,ti,t,&cd->properties,"property"); generateXMLSection(cd,ti,t,&cd->pubStaticMembers,"public-static-func"); generateXMLSection(cd,ti,t,&cd->pubStaticAttribs,"public-static-attrib"); generateXMLSection(cd,ti,t,&cd->proTypes,"protected-type"); generateXMLSection(cd,ti,t,&cd->proMembers,"protected-func"); generateXMLSection(cd,ti,t,&cd->proAttribs,"protected-attrib"); generateXMLSection(cd,ti,t,&cd->proSlots,"protected-slot"); generateXMLSection(cd,ti,t,&cd->proStaticMembers,"protected-static-func"); generateXMLSection(cd,ti,t,&cd->proStaticAttribs,"protected-static-attrib"); generateXMLSection(cd,ti,t,&cd->priTypes,"private-type"); generateXMLSection(cd,ti,t,&cd->priMembers,"private-func"); generateXMLSection(cd,ti,t,&cd->priAttribs,"private-attrib"); generateXMLSection(cd,ti,t,&cd->priSlots,"private-slot"); generateXMLSection(cd,ti,t,&cd->priStaticMembers,"private-static-func"); generateXMLSection(cd,ti,t,&cd->priStaticAttribs,"private-static-attrib"); generateXMLSection(cd,ti,t,&cd->friends,"friend"); generateXMLSection(cd,ti,t,&cd->related,"related"); t << " " << endl; writeXMLDocBlock(t,cd->getDefFileName(),cd->getDefLine(),cd->name(),0,cd->briefDescription()); t << " " << endl; t << " " << endl; writeXMLDocBlock(t,cd->getDefFileName(),cd->getDefLine(),cd->name(),0,cd->documentation()); t << " " << endl; DotClassGraph inheritanceGraph(cd,DotClassGraph::Inheritance); if (!inheritanceGraph.isTrivial()) { t << " " << endl; inheritanceGraph.writeXML(t); t << " " << endl; } DotClassGraph collaborationGraph(cd,DotClassGraph::Implementation); if (!collaborationGraph.isTrivial()) { t << " " << endl; collaborationGraph.writeXML(t); t << " " << endl; } t << " getDefFileName() << "\" line=\"" << cd->getDefLine() << "\""; if (cd->getStartBodyLine()!=-1) { t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\"" << cd->getEndBodyLine() << "\""; } t << "/>" << endl; t << " " << endl; t << "" << endl; ti << " " << endl; } static void generateXMLForNamespace(NamespaceDef *nd,QTextStream &ti) { // + contained class definitions // + contained namespace definitions // + member groups // + normal members // + brief desc // + detailed desc // + location // - files containing (parts of) the namespace definition if (nd->isReference()) return; // skip external references ti << " getOutputFileBase() << "\">" << convertToXML(nd->name()) << "" << endl; QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); QCString fileName=outputDirectory+"/xml/"+nd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } QTextStream t(&f); t << "" << endl; t << "" << endl; t << " getOutputFileBase() << "\" kind=\"namespace\">" << endl; t << " "; writeXMLString(t,nd->name()); t << "" << endl; ClassSDict *cl = nd->classSDict; if (cl) { ClassSDict::Iterator cli(*cl); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { t << " getOutputFileBase() << "\">" << convertToXML(cd->name()) << "" << endl; } } NamespaceSDict *nl = nd->namespaceSDict; if (nl) { NamespaceSDict::Iterator nli(*nl); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { t << " getOutputFileBase() << "\">" << convertToXML(nd->name()) << "" << endl; } } MemberGroupSDict::Iterator mgli(*nd->memberGroupSDict); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(nd,ti,t,mg->members(),"user-defined",mg->header()); } generateXMLSection(nd,ti,t,&nd->decDefineMembers,"define"); generateXMLSection(nd,ti,t,&nd->decProtoMembers,"prototype"); generateXMLSection(nd,ti,t,&nd->decTypedefMembers,"typedef"); generateXMLSection(nd,ti,t,&nd->decEnumMembers,"enum"); generateXMLSection(nd,ti,t,&nd->decFuncMembers,"func"); generateXMLSection(nd,ti,t,&nd->decVarMembers,"var"); t << " " << endl; writeXMLDocBlock(t,nd->getDefFileName(),nd->getDefLine(),0,0,nd->briefDescription()); t << " " << endl; t << " " << endl; writeXMLDocBlock(t,nd->getDefFileName(),nd->getDefLine(),0,0,nd->documentation()); t << " " << endl; t << " getDefFileName() << "\" line=\"" << nd->getDefLine() << "\"/>" << endl; t << " " << endl; t << "" << endl; ti << " " << endl; } static void generateXMLForFile(FileDef *fd,QTextStream &ti) { // + includes files // + includedby files // + include graph // + included by graph // + contained class definitions // + contained namespace definitions // + member groups // + normal members // + brief desc // + detailed desc // + source code // + location // - number of lines if (fd->isReference()) return; // skip external references ti << " getOutputFileBase() << "\">" << convertToXML(fd->name()) << "" << endl; QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); QCString fileName=outputDirectory+"/xml/"+fd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } QTextStream t(&f); t << "" << endl; t << "" << endl; t << " getOutputFileBase() << "\" kind=\"file\">" << endl; t << " "; writeXMLString(t,fd->name()); t << "" << endl; QListIterator ili1(*fd->includeFileList()); IncludeInfo *inc; for (ili1.toFirst();(inc=ili1.current());++ili1) { t << " fileDef && !inc->fileDef->isReference()) // TODO: support external references { t << " id=\"" << inc->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (inc->local ? "yes" : "no") << "\">"; t << inc->includeName; t << "" << endl; } QListIterator ili2(*fd->includedByFileList()); for (ili2.toFirst();(inc=ili2.current());++ili2) { t << " fileDef && !inc->fileDef->isReference()) // TODO: support external references { t << " id=\"" << inc->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (inc->local ? "yes" : "no") << "\">"; t << inc->includeName; t << "" << endl; } DotInclDepGraph incDepGraph(fd,FALSE); if (!incDepGraph.isTrivial()) { t << " " << endl; incDepGraph.writeXML(t); t << " " << endl; } DotInclDepGraph invIncDepGraph(fd,TRUE); if (!invIncDepGraph.isTrivial()) { t << " " << endl; invIncDepGraph.writeXML(t); t << " " << endl; } ClassSDict *cl = fd->classSDict; if (cl) { ClassSDict::Iterator cli(*cl); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { t << " getOutputFileBase() << "\">" << convertToXML(cd->name()) << "" << endl; } } NamespaceSDict *nl = fd->namespaceSDict; if (nl) { NamespaceSDict::Iterator nli(*nl); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { t << " getOutputFileBase() << "\">" << convertToXML(nd->name()) << "" << endl; } } MemberGroupSDict::Iterator mgli(*fd->memberGroupSDict); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(fd,ti,t,mg->members(),"user-defined",mg->header()); } generateXMLSection(fd,ti,t,&fd->decDefineMembers,"define"); generateXMLSection(fd,ti,t,&fd->decProtoMembers,"prototype"); generateXMLSection(fd,ti,t,&fd->decTypedefMembers,"typedef"); generateXMLSection(fd,ti,t,&fd->decEnumMembers,"enum"); generateXMLSection(fd,ti,t,&fd->decFuncMembers,"func"); generateXMLSection(fd,ti,t,&fd->decVarMembers,"var"); t << " " << endl; writeXMLDocBlock(t,fd->getDefFileName(),fd->getDefLine(),0,0,fd->briefDescription()); t << " " << endl; t << " " << endl; writeXMLDocBlock(t,fd->getDefFileName(),fd->getDefLine(),0,0,fd->documentation()); t << " " << endl; t << " " << endl; writeXMLCodeBlock(t,fd); t << " " << endl; t << " getDefFileName() << "\"/>" << endl; t << " " << endl; t << "" << endl; ti << " " << endl; } static void generateXMLForGroup(GroupDef *gd,QTextStream &ti) { // + members // + member groups // + files // + classes // + namespaces // - packages // + pages // + child groups // - examples // + brief description // + detailed description if (gd->isReference()) return; // skip external references ti << " getOutputFileBase() << "\">" << convertToXML(gd->name()) << "" << endl; QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); QCString fileName=outputDirectory+"/xml/"+gd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } QTextStream t(&f); t << "" << endl; t << "" << endl; t << " getOutputFileBase() << "\" kind=\"group\">" << endl; t << " " << convertToXML(gd->name()) << "" << endl; t << " " << convertToXML(gd->groupTitle()) << "" << endl; FileList *fl = gd->getFiles(); if (fl) { QListIterator fli(*fl); FileDef *fd = fl->first(); for (fli.toFirst();(fd=fli.current());++fli) { t << " getOutputFileBase() << "\">" << convertToXML(fd->name()) << "" << endl; } } ClassSDict *cl = gd->getClasses(); if (cl) { ClassSDict::Iterator cli(*cl); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { t << " getOutputFileBase() << "\">" << convertToXML(cd->name()) << "" << endl; } } NamespaceList *nl = gd->getNamespaces(); if (nl) { NamespaceListIterator nli(*nl); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { t << " getOutputFileBase() << "\">" << convertToXML(nd->name()) << "" << endl; } } PageSDict *pl = gd->getPages(); if (pl) { PageSDict::Iterator pli(*pl); PageInfo *pi; for (pli.toFirst();(pi=pli.current());++pli) { t << " getOutputFileBase() << "\"/>" << convertToXML(pi->title) << "" << endl; } } MemberGroupSDict::Iterator mgli(*gd->memberGroupSDict); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(gd,ti,t,mg->members(),"user-defined",mg->header()); } generateXMLSection(gd,ti,t,&gd->decDefineMembers,"define"); generateXMLSection(gd,ti,t,&gd->decProtoMembers,"prototype"); generateXMLSection(gd,ti,t,&gd->decTypedefMembers,"typedef"); generateXMLSection(gd,ti,t,&gd->decEnumMembers,"enum"); generateXMLSection(gd,ti,t,&gd->decFuncMembers,"func"); generateXMLSection(gd,ti,t,&gd->decVarMembers,"var"); t << " " << endl; writeXMLDocBlock(t,gd->getDefFileName(),gd->getDefLine(),0,0,gd->briefDescription()); t << " " << endl; t << " " << endl; writeXMLDocBlock(t,gd->getDefFileName(),gd->getDefLine(),0,0,gd->documentation()); t << " " << endl; t << " " << endl; t << "" << endl; ti << " " << endl; } static void generateXMLForPage(PageInfo *pi,QTextStream &ti) { // + name // + title // + documentation if (pi->isReference()) return; ti << " getOutputFileBase() << "\">" << convertToXML(pi->name) << "" << endl; QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); QCString fileName=outputDirectory+"/xml/"+pi->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } QTextStream t(&f); t << "" << endl; t << "" << endl; t << " name; else t << pi->name.lower(); t << "\" kind=\"page\">" << endl; t << " " << convertToXML(pi->name) << "" << endl; SectionInfo *si = Doxygen::sectionDict.find(pi->name); if (si) { t << " " << si->title << "" << endl; } t << " " << endl; writeXMLDocBlock(t,pi->defFileName,pi->defLine,0,0,pi->doc); t << " " << endl; t << " " << endl; t << "" << endl; ti << " " << endl; } void generateXML() { // + classes // + namespaces // + files // - packages // + groups // + related pages // - examples QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); if (outputDirectory.isEmpty()) { outputDirectory=QDir::currentDirPath(); } else { QDir dir(outputDirectory); if (!dir.exists()) { dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { err("Error: tag OUTPUT_DIRECTORY: Output directory `%s' does not " "exist and cannot be created\n",outputDirectory.data()); exit(1); } else if (!Config_getBool("QUIET")) { err("Notice: Output directory `%s' does not exist. " "I have created it for you.\n", outputDirectory.data()); } dir.cd(outputDirectory); } outputDirectory=dir.absPath(); } QDir dir(outputDirectory); if (!dir.exists()) { dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { err("Cannot create directory %s\n",outputDirectory.data()); return; } } QDir xmlDir(outputDirectory+"/xml"); if (!xmlDir.exists() && !xmlDir.mkdir(outputDirectory+"/xml")) { err("Could not create xml directory in %s\n",outputDirectory.data()); return; } QCString fileName=outputDirectory+"/xml/index.xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } QTextStream t(&f); t << "" << endl; //t << "" << endl; t << "" << endl; //t << " " << endl; ClassSDict::Iterator cli(Doxygen::classSDict); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { generateXMLForClass(cd,t); } NamespaceSDict::Iterator nli(Doxygen::namespaceSDict); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { generateXMLForNamespace(nd,t); } FileNameListIterator fnli(Doxygen::inputNameList); FileName *fn; for (;(fn=fnli.current());++fnli) { FileNameIterator fni(*fn); FileDef *fd; for (;(fd=fni.current());++fni) { generateXMLForFile(fd,t); } } GroupSDict::Iterator gli(Doxygen::groupSDict); GroupDef *gd; for (;(gd=gli.current());++gli) { generateXMLForGroup(gd,t); } PageSDict::Iterator pdi(*Doxygen::pageSDict); PageInfo *pi=0; for (pdi.toFirst();(pi=pdi.current());++pdi) { generateXMLForPage(pi,t); } //t << " " << endl; t << "" << endl; }