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

📄 doxygen.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{  if (       (root->section==Entry::NAMESPACE_SEC) ||       (root->section==Entry::NAMESPACEDOC_SEC) &&        !root->name.isEmpty()     )  {    QCString fullName=stripAnonymousNamespaceScope(root->name.copy());    if (!fullName.isEmpty())    {      //printf("Found namespace %s in %s at line %d\n",root->name.data(),      //        root->fileName.data(), root->startLine);      NamespaceDef *nd;      if ((nd=Doxygen::namespaceSDict[fullName])) // existing namespace      {        if (!root->doc.isEmpty() || !root->brief.isEmpty()) // block contains docs        {           if (nd->documentation().isEmpty() && !root->doc.isEmpty())          {            nd->setDocumentation(root->doc);            nd->setName(fullName); // change name to match docs            nd->addSectionsToDefinition(root->anchors);          }          else if (!nd->documentation().isEmpty() && !root->doc.isEmpty())          {            warn(                 root->fileName,root->startLine,                 "Warning: namespace %s already has a detailed description. "                 "Skipping the documentation found here.",                 fullName.data());          }          if (nd->briefDescription().isEmpty() && !root->brief.isEmpty())          {            nd->setBriefDescription(root->brief);            nd->setName(fullName); // change name to match docs          }          else if (!nd->briefDescription().isEmpty() && !root->brief.isEmpty())          {            warn(root->fileName,root->startLine,                 "Warning: namespace %s already has a brief description. "                 "Skipping the documentation found here.",                 fullName.data()                );          }        }        bool ambig;        // file definition containing the namespace nd        FileDef *fd=findFileDef(Doxygen::inputNameDict,root->fileName,ambig);        // insert the namespace in the file definition        if (fd) fd->insertNamespace(nd);        addNamespaceToGroups(root,nd);        nd->setRefItems(root->todoId,root->testId,root->bugId);      }      else // fresh namespace      {        QCString tagName;        if (root->tagInfo)        {          tagName=root->tagInfo->tagName;        }        NamespaceDef *nd=new NamespaceDef(root->fileName,root->startLine,fullName,tagName);        nd->setDocumentation(root->doc); // copy docs to definition        nd->setBriefDescription(root->brief);        nd->addSectionsToDefinition(root->anchors);        //printf("Adding namespace to group\n");        addNamespaceToGroups(root,nd);        nd->setRefItems(root->todoId,root->testId,root->bugId);        bool ambig;        // file definition containing the namespace nd        FileDef *fd=findFileDef(Doxygen::inputNameDict,root->fileName,ambig);        // insert the namespace in the file definition        if (fd) fd->insertNamespace(nd);        // the empty string test is needed for extract all case        nd->setBriefDescription(root->brief);        nd->insertUsedFile(root->fileName);        nd->setBodySegment(root->bodyLine,root->endBodyLine);        nd->setBodyDef(fd);        // add class to the list        Doxygen::namespaceSDict.inSort(fullName,nd);        // also add namespace to the correct structural context         Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,fullName);        if (d==0)        {          // TODO: Due to the order in which the tag file is written          // a nested class can be found before its parent!          //          //warn(root->fileName,root->startLine,          //     "Warning: Internal inconsistency: scope for namespace %s not "          //     "found!\n",fullName.data()          //    );        }        else        {          d->addInnerCompound(nd);          nd->setOuterScope(d);        }      }    }  }  EntryListIterator eli(*root->sublist);  Entry *e;  for (;(e=eli.current());++eli)  {    buildNamespaceList(e);  }}//----------------------------------------------------------------------static void findUsingDirectives(Entry *root){  if (root->section==Entry::USINGDIR_SEC)  {    //printf("Found using directive %s at line %d of %s\n",    //    root->name.data(),root->startLine,root->fileName.data());    bool ambig;    if (!root->name.isEmpty())    {      NamespaceDef *usingNd = 0;      NamespaceDef *nd = 0;      FileDef      *fd = findFileDef(Doxygen::inputNameDict,root->fileName,ambig);      QCString nsName;      // see if the using statement was found inside a namespace or inside      // the global file scope.      if (root->parent->section == Entry::NAMESPACE_SEC)      {        nsName=root->parent->name.copy();        if (!nsName.isEmpty())        {          nd = getResolvedNamespace(nsName);        }      }      // find the scope in which the `using' namespace is defined by prepending      // the possible scopes in which the using statement was found, starting      // with the most inner scope and going to the most outer scope (i.e.       // file scope).      int scopeOffset = nsName.length();      do      {        QCString scope=scopeOffset>0 ?                       nsName.left(scopeOffset)+"::" : QCString();        //printf("Trying with scope=`%s'\n",scope.data());        usingNd = getResolvedNamespace(scope+root->name);        if (scopeOffset==0)        {          scopeOffset=-1;        }        else if ((scopeOffset=nsName.findRev("::",scopeOffset-1))==-1)        {          scopeOffset=0;        }      } while (scopeOffset>=0 && usingNd==0);      //printf("%s -> %p\n",root->name.data(),usingNd);      // add the namespace the correct scope      if (usingNd)      {        if (nd)        {          //printf("Inside namespace %s\n",nd->name().data());          nd->addUsingDirective(usingNd);        }        else if (fd)        {          //printf("Inside file %s\n",fd->name().data());          fd->addUsingDirective(usingNd);        }      }      else // unknown namespace, but add it anyway.      {        NamespaceDef *nd=new NamespaceDef(            root->fileName,root->startLine,root->name);        nd->setDocumentation(root->doc); // copy docs to definition        nd->setBriefDescription(root->brief);        nd->addSectionsToDefinition(root->anchors);        QListIterator<Grouping> gli(*root->groups);        Grouping *g;        for (;(g=gli.current());++gli)        {          GroupDef *gd=0;          if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict[g->groupname]))            gd->addNamespace(nd);        }        bool ambig;        // file definition containing the namespace nd        FileDef *fd=findFileDef(Doxygen::inputNameDict,root->fileName,ambig);        // insert the namespace in the file definition        if (fd)         {          fd->insertNamespace(nd);          fd->addUsingDirective(nd);        }        // the empty string test is needed for extract all case        nd->setBriefDescription(root->brief);        nd->insertUsedFile(root->fileName);        // add class to the list        Doxygen::namespaceSDict.inSort(root->name,nd);        nd->setRefItems(root->todoId,root->testId,root->bugId);      }    }  }  EntryListIterator eli(*root->sublist);  Entry *e;  for (;(e=eli.current());++eli)  {    findUsingDirectives(e);  }}//----------------------------------------------------------------------static void findUsingDeclarations(Entry *root){  if (root->section==Entry::USINGDECL_SEC)  {    //printf("Found using declaration %s at line %d of %s\n",    //    root->name.data(),root->startLine,root->fileName.data());    bool ambig;    if (!root->name.isEmpty())    {      ClassDef *usingCd = 0;      NamespaceDef *nd = 0;      FileDef      *fd = findFileDef(Doxygen::inputNameDict,root->fileName,ambig);      QCString scName;      // see if the using statement was found inside a namespace or inside      // the global file scope.      if (root->parent->section == Entry::NAMESPACE_SEC)      {        scName=root->parent->name.copy();        if (!scName.isEmpty())        {          nd = getResolvedNamespace(scName);        }      }      // Assume the using statement was used to import a class.      // Find the scope in which the `using' namespace is defined by prepending      // the possible scopes in which the using statement was found, starting      // with the most inner scope and going to the most outer scope (i.e.       // file scope).      int scopeOffset = scName.length();      do      {        QCString scope=scopeOffset>0 ?                       scName.left(scopeOffset)+"::" : QCString();        //printf("Trying with scope=`%s'\n",scope.data());        usingCd = getClass(scope+root->name);        if (scopeOffset==0)        {          scopeOffset=-1;        }        else if ((scopeOffset=scName.findRev("::",scopeOffset-1))==-1)        {          scopeOffset=0;        }      } while (scopeOffset>=0 && usingCd==0);      //printf("%s -> %p\n",root->name.data(),usingCd);      // add the namespace the correct scope      if (usingCd)      {        if (nd)        {          //printf("Inside namespace %s\n",nd->name().data());          nd->addUsingDeclaration(usingCd);        }        else if (fd)        {          //printf("Inside file %s\n",nd->name().data());          fd->addUsingDeclaration(usingCd);        }      }    }  }  EntryListIterator eli(*root->sublist);  Entry *e;  for (;(e=eli.current());++eli)  {    findUsingDeclarations(e);  }}//----------------------------------------------------------------------static MemberDef *addVariableToClass(    Entry *root,    ClassDef *cd,    MemberDef::MemberType mtype,    const QCString &scope,    const QCString &name,    bool fromAnnScope,    int indentDepth,    MemberDef *fromAnnMemb,    Protection prot){  Debug::print(Debug::Variables,0,      "  class variable:\n"      "    %s' %s'::`%s' `%s' prot=`%d ann=%d init=%s\n",      root->type.data(),      scope.data(),       name.data(),      root->args.data(),      root->protection,      fromAnnScope,      root->initializer.data()              );  // class friends may be templatized  //QCString name=n;  //int i;  //if (root->type.left(7)=="friend " && (i=name.find('<'))!=-1)  //{  //  name=name.left(i);   //}     // add template names, if the class is a non-specialized template  //if (scope.find('<')==-1 && cd->templateArguments())  //{  //  scope+=cd->getTemplateNameString();  //}  // generate member definition.  QCString def;  if (!root->type.isEmpty())  {    if (mtype==MemberDef::Friend || Config_getBool("HIDE_SCOPE_NAMES"))    {      def=root->type+" "+name+root->args;    }    else    {      def=root->type+" "+scope+"::"+name+root->args;    }  }  else  {    if (Config_getBool("HIDE_SCOPE_NAMES"))    {      def=name+root->args;    }    else    {      def=scope+"::"+name+root->args;    }  }  if (def.left(7)=="static ") def=def.right(def.length()-7);  // see if the member is already found in the same scope  // (this may be the case for a static member that is initialized  //  outside the class)  MemberName *mn=Doxygen::memberNameSDict[name];  if (mn)  {    MemberNameIterator mni(*mn);    MemberDef *md;    for (mni.toFirst();(md=mni.current());++mni)    {      if (md->getClassDef()==cd && root->type==md->typeString())         // member already in the scope      {        addMemberDocs(root,md,def,0,FALSE);        return md;      }    }   }  // new member variable, typedef or enum value  MemberDef *md=new MemberDef(      root->fileName,root->startLine,      root->type,name,root->args,0,      prot,Normal,root->stat,FALSE,      mtype,0,0);  if (root->tagInfo)   {    md->setAnchor(root->tagInfo->anchor);    md->setReference(root->tagInfo->tagName);  }  md->setMemberClass(cd);  //md->setDefFile(root->fileName);  //md->setDefLine(root->startLine);  md->setDocumentation(root->doc);  md->setBriefDescription(root->brief);  md->setDefinition(def);  md->setBitfields(root->bitfields);  md->addSectionsToDefinition(root->anchors);  md->setFromAnonymousScope(fromAnnScope);  md->setFromAnonymousMember(fromAnnMemb);  md->setIndentDepth(indentDepth);

⌨️ 快捷键说明

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