⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlgen.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    {      m_t << "<sect1 id=\"" << id << "\">";    }    void endSection(const char *,bool)    {      m_t << "</sect1>";    }    void startSubsection()     {      m_t << "<sect2>";    }    void endSubsection()     {      m_t << "</sect2>";    }    void startSubsubsection()     {      m_t << "<sect3>";    }    void endSubsubsection()     {      m_t << "</sect3>";    }    void startCenter()     {      startParMode();      m_t << "<center>"; // non docbook    }    void endCenter()     {      m_t << "</center>"; // non docbook    }    void startSmall()     {      startParMode();      m_t << "<small>"; // non docbook    }    void endSmall()     {      m_t << "</small>"; // non docbook    }    void startSubscript()     {      startParMode();      m_t << "<subscript>";    }    void endSubscript()     {      m_t << "</subscript>";    }    void startSuperscript()     {      startParMode();      m_t << "<superscript>";    }    void endSuperscript()     {      m_t << "</superscript>";    }    void startTable(int cols)     {      XML_DB(("startTable\n");)      startParMode();      m_t << "<table cols=\"" << cols << "\">\n";    }    void endTable()     {      XML_DB(("endTable\n");)      m_t << "</row>\n</table>";    }    void nextTableRow()     {      XML_DB(("nextTableRow\n");)      m_t << "<row><entry>";      // 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 << "<para>";    }    void endTableRow()     {      XML_DB(("endTableRow\n");)      m_t << "</row>" << endl;    }    void nextTableColumn()     {      XML_DB(("nextTableColumn\n");)      m_t << "<entry>";            // 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 << "<para>";    }    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 << "</para>";      m_t << "</entry>";    }    void writeQuote()         { m_t << "\""; }    void writeCopyright()     { m_t << "&copy;"; }    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 << "&szlig;"; }    void writeCCedil(char c)  { m_t << "&" << c << "cedil;"; }    void startTitle()     {      m_t << "<title>";    }    void endTitle()       {      m_t << "</title>" << endl;    }    void writeAnchor(const char *id,const char *name)     {      startParMode();      m_t << "<anchor id=\"" << id << "_" << name << "\"/>";    }    void writeSectionRef(const char *,const char *id,                         const char *name,const char *text)     {      startParMode();      m_t << "<link linkend=\"" << id << "_" << name << "\">";      docify(text);      m_t << "</link>";    }    void writeSectionRefItem(const char *,const char *,const char *)     {      m_t << "(writeSectionRefItem)";    }    void addIndexItem(const char *primaryie,const char *secondaryie)     {      startParMode();      m_t << "<indexentry><primaryie>";      docify(primaryie);      m_t << "</primaryie><secondaryie>";      docify(secondaryie);      m_t << "</secondaryie></indexentry>";    }    void writeFormula(const char *id,const char *text)     {      startParMode();      m_t << "<formula id=\"" << id << "\">"; // non Docbook      docify(text);      m_t << "</formula>";    }    void startImage(const char *name,const char *size,bool /*caption*/)     {      startParMode();      m_t << "<image name=\"" << name << "\"";      if (size) m_t << " size=\"" << size << "\"";      m_t << ">"; // non docbook     }    void endImage(bool)     {      m_t << "</image>";    }    void startDotFile(const char *name,bool /*caption*/)     {      startParMode();      m_t << "<dotfile name=\"" << name << "\">"; // non docbook     }    void endDotFile(bool)     {      m_t << "</dotfile>";    }    void startTextLink(const char *name,const char *anchor)     {      startParMode();      m_t << "<ulink url=\"" << name << "#" << anchor << "\">";    }    void endTextLink()     {      m_t << "<ulink>";    }    void startPageRef()     {    }    void endPageRef(const char *,const char *)     {    }    void writeLineNumber(const char *,const char *file, // TODO: support external references                         const char *anchor,int l)    {      m_t << "<linenumber";      m_t << " line=\"" << l << "\"";      if (file)      {        m_t << " refid=\"" << file << "_1" << anchor << "\"";      }      m_t << "/>";    }    void startCodeLine()     {      startParMode();      m_t << "<codeline>"; // non DocBook    }    void endCodeLine()     {      m_t << "</codeline>" << endl; // non DocBook    }    void startCodeAnchor(const char *id)     {      startParMode();      m_t << "<anchor id=\"" << id << "\">";    }    void endCodeAnchor()     {      m_t << "</anchor>";    }    void startFontClass(const char *colorClass)     {      m_t << "<highlight class=\"" << colorClass << "\">"; // non DocBook    }    void endFontClass()    {      m_t << "</highlight>"; // non DocBook    }    void codify(const char *text)     {      docify(text);    }        // 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<bool> m_inParStack;      ValStack<bool> m_inListStack;    bool m_inParamList;        friend void writeXMLCodeBlock(QTextStream &t,FileDef *fd);};void writeXMLDocBlock(QTextStream &t,                      const QCString &fileName,                      int lineNr,                      const QCString &scope,                      const QCString &name,                      const QCString &text){  if (text.stripWhiteSpace().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)           name,     // member (which should not be linked to)           text+"\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;}void generateXMLForMember(MemberDef *md,QTextStream &t,Definition *def){  // + declaration  // - reimplements  // - reimplementedBy  // - exceptions  // - const/volatile specifiers  // - examples  // + source definition  // - source references  // - source referenced by  // - include code     if (md->memberType()==MemberDef::EnumValue) return;  QCString scopeName;  if (md->getClassDef())     scopeName=md->getClassDef()->name();  else if (md->getNamespaceDef())     scopeName=md->getNamespaceDef()->name();      t << "      <memberdef kind=\"";  //enum { define_t,variable_t,typedef_t,enum_t,function_t } xmlType = function_t;  QCString memType;  bool isFunc=FALSE;  switch (md->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 << def->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 << "\">" << endl;    if (md->memberType()!=MemberDef::Define &&      md->memberType()!=MemberDef::Enumeration     )  {    QCString typeStr = replaceAnonymousScopes(md->typeString());    t << "        <type>";    linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),typeStr);    t << "</type>" << endl;  }  t << "        <name>";  writeXMLString(t,md->name());  t << "</name>" << endl;  if (isFunc) //function  {    ArgumentList *declAl = new ArgumentList;    ArgumentList *defAl = md->argumentList();    stringToArgumentList(md->argsString(),declAl);    if (declAl->count()>0)    {      ArgumentListIterator declAli(*declAl);      ArgumentListIterator defAli(*defAl);      Argument *a;      for (declAli.toFirst();(a=declAli.current());++declAli)      {        Argument *defArg = defAli.current();        t << "        <param>" << endl;        if (!a->attrib.isEmpty())        {          t << "          <attributes>";          writeXMLString(t,a->attrib);          t << "</attributes>" << endl;        }        if (!a->type.isEmpty())        {          t << "          <type>";          linkifyText(TextGeneratorXMLImpl(t),scopeName,md->name(),a->type);          t << "</type>" << endl;        }        if (!a->name.isEmpty())        {          t << "          <declname>";          writeXMLString(t,a->name); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -