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

📄 index.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * * $Id: index.cpp,v 1.63 2001/03/19 19:27:40 root Exp $ * * Copyright (C) 1997-2001 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 <stdlib.h>#include <qtextstream.h>#include <qdatetime.h>#include <qdir.h>#include "message.h"#include "index.h"#include "doxygen.h"#include "doc.h"#include "code.h"#include "config.h"#include "filedef.h"#include "outputlist.h"#include "util.h"#include "groupdef.h"#include "language.h"#include "htmlhelp.h"#include "ftvhelp.h"#include "dot.h"#include "page.h"#include "packagedef.h"int annotatedClasses;int hierarchyClasses;int documentedFunctions;int documentedMembers;int documentedHtmlFiles;int documentedFiles;int documentedGroups;int documentedNamespaces;int documentedNamespaceMembers;int documentedIncludeFiles;int documentedPages;int indexedPages;int documentedPackages;int countClassHierarchy();int countClassMembers();int countFileMembers();void countFiles(int &htmlFiles,int &files);int countGroups();int countNamespaces();int countAnnotatedClasses();int countNamespaceMembers();int countIncludeFiles();void countRelatedPages(int &docPages,int &indexPages);int countPackages();void countDataStructures(){  annotatedClasses           = countAnnotatedClasses();  hierarchyClasses           = countClassHierarchy();  documentedMembers          = countClassMembers();  documentedFunctions        = countFileMembers();  countFiles(documentedHtmlFiles,documentedFiles);  countRelatedPages(documentedPages,indexedPages);  documentedGroups           = countGroups();  documentedNamespaces       = countNamespaces();  documentedNamespaceMembers = countNamespaceMembers();  documentedPackages         = countPackages();}//----------------------------------------------------------------------------static bool g_memberIndexLetterUsed[256];static bool g_fileIndexLetterUsed[256];static bool g_namespaceIndexLetterUsed[256];const int maxItemsBeforeQuickIndex = 50;//----------------------------------------------------------------------------// strips w from s iff s starts with wbool stripWord(QCString &s,QCString w){  bool success=FALSE;  if (s.left(w.length())==w)   {    success=TRUE;    s=s.right(s.length()-w.length());  }  return success;}//----------------------------------------------------------------------------// some quasi intelligent brief description abbreviator :^)QCString abbreviate(const char *s,const char *name){  QCString result=s;  QCString start1=(QCString)"The "+name+" class ";  QCString start2=(QCString)"The "+name+" widget ";  QCString start3=(QCString)"The "+name+" file ";  result=result.stripWhiteSpace();  // strip trailing .  if (!result.isEmpty() && result.at(result.length()-1)=='.')     result=result.left(result.length()-1);  bool found=FALSE;  found = found || stripWord(result,start1);  found = found || stripWord(result,start2);  found = found || stripWord(result,start3);  if (found)  {    bool found=FALSE;    found = found || stripWord(result,"is ");    found = found || stripWord(result,"provides ");    found = found || stripWord(result,"specifies ");    found = found || stripWord(result,"contains ");    found = found || stripWord(result,"represents ");    if (found)    {      stripWord(result,"a ");      stripWord(result,"an ");      stripWord(result,"the ");    }  }  if (!result.isEmpty())  {    int c=result[0];    if (c>='a' && c<='z') c+='A'-'a';    result[0]=c;  }  return result;}//----------------------------------------------------------------------------void writeQuickLinks(OutputList &ol,bool compact ,bool ext=FALSE){  ol.pushGeneratorState();  ol.disableAllBut(OutputGenerator::Html);  QCString extLink;  if (ext) { extLink="_doc"; }  if (compact) ol.startCenter(); else ol.startItemList();  if (!compact) ol.writeListItem();  if (Config_getBool("GENERATE_TREEVIEW"))  {    ol.startQuickIndexItem(extLink,"main.html");  }  else  {    ol.startQuickIndexItem(extLink,"index.html");  }  parseText(ol,theTranslator->trMainPage());  ol.endQuickIndexItem();  if (documentedPackages>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"packages.html");    parseText(ol,theTranslator->trPackages());    ol.endQuickIndexItem();  }  if (documentedGroups>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"modules.html");    parseText(ol,theTranslator->trModules());    ol.endQuickIndexItem();  }   if (documentedNamespaces>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"namespaces.html");    parseText(ol,theTranslator->trNamespaceList());    ol.endQuickIndexItem();  }  if (hierarchyClasses>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"hierarchy.html");    parseText(ol,theTranslator->trClassHierarchy());    ol.endQuickIndexItem();  }   if (annotatedClasses>0)  {    if (Config_getBool("ALPHABETICAL_INDEX"))    {      if (!compact) ol.writeListItem();      ol.startQuickIndexItem(extLink,"classes.html");      parseText(ol,theTranslator->trAlphabeticalList());      ol.endQuickIndexItem();    }    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"annotated.html");    parseText(ol,theTranslator->trCompoundList());    ol.endQuickIndexItem();  }   if (documentedHtmlFiles>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"files.html");    parseText(ol,theTranslator->trFileList());    ol.endQuickIndexItem();  }   //if (documentedIncludeFiles>0 && Config_getBool("VERBATIM_HEADERS"))  //{  //  if (!compact) ol.writeListItem();  //  ol.startQuickIndexItem(extLink,"headers.html");  //  parseText(ol,theTranslator->trHeaderFiles());  //  ol.endQuickIndexItem();  //}  //if (Config_getBool("SOURCE_BROWSER"))   //{  //  if (!compact) ol.writeListItem();  //  ol.startQuickIndexItem(extLink,"sources.html");  //  parseText(ol,theTranslator->trSources());  //  ol.endQuickIndexItem();  //}  if (documentedNamespaceMembers>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"namespacemembers.html");    parseText(ol,theTranslator->trNamespaceMembers());    ol.endQuickIndexItem();  }  if (documentedMembers>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"functions.html");    parseText(ol,theTranslator->trCompoundMembers());    ol.endQuickIndexItem();  }   if (documentedFunctions>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"globals.html");    parseText(ol,theTranslator->trFileMembers());    ol.endQuickIndexItem();  }   if (indexedPages>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"pages.html");    parseText(ol,theTranslator->trRelatedPages());    ol.endQuickIndexItem();  }   if (Doxygen::exampleSDict->count()>0)  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem(extLink,"examples.html");    parseText(ol,theTranslator->trExamples());    ol.endQuickIndexItem();  }   if (Config_getBool("SEARCHENGINE"))  {    if (!compact) ol.writeListItem();    ol.startQuickIndexItem("_cgi","");    parseText(ol,theTranslator->trSearch());    ol.endQuickIndexItem();  }   if (compact)   {    ol.endCenter();     ol.writeRuler();  }  else   {    ol.endItemList();  }  ol.popGeneratorState();}void startTitle(OutputList &ol,const char *fileName){  ol.startTitleHead(fileName);  ol.pushGeneratorState();  ol.disable(OutputGenerator::Man);}void endTitle(OutputList &ol,const char *fileName,const char *name){  ol.popGeneratorState();  ol.endTitleHead(fileName,name);}void startFile(OutputList &ol,const char *name,const char *manName,               const char *title,bool external){  ol.startFile(name,manName,title,external);  if (!Config_getBool("DISABLE_INDEX")) writeQuickLinks(ol,TRUE,external);}void endFile(OutputList &ol,bool external){  ol.pushGeneratorState();  ol.disableAllBut(OutputGenerator::Html);  ol.writeFooter(0,external); // write the footer  if (Config_getString("HTML_FOOTER").isEmpty())  {    parseText(ol,theTranslator->trGeneratedAt(              dateToString(TRUE),              Config_getString("PROJECT_NAME")             ));  }  ol.writeFooter(1,external); // write the link to the picture  if (Config_getString("HTML_FOOTER").isEmpty())  {    parseText(ol,theTranslator->trWrittenBy());  }  ol.writeFooter(2,external); // end the footer  ol.popGeneratorState();  ol.endFile();}//----------------------------------------------------------------------------void writeClassTree(OutputList &ol,BaseClassList *bcl,bool hideSuper,int level){  HtmlHelp *htmlHelp=0;  FTVHelp  *ftvHelp=0;  bool &generateHtml = Config_getBool("GENERATE_HTML") ;  bool hasHtmlHelp = generateHtml && Config_getBool("GENERATE_HTMLHELP");  bool hasFtvHelp  = generateHtml && Config_getBool("GENERATE_TREEVIEW");  if (hasHtmlHelp)  {    htmlHelp = HtmlHelp::getInstance();  }  if (hasFtvHelp)  {    ftvHelp = FTVHelp::getInstance();  }  BaseClassListIterator bcli(*bcl);  bool started=FALSE;  for ( ; bcli.current() ; ++bcli)  {    ClassDef *cd=bcli.current()->classDef;    if (cd->isVisibleInHierarchy() && hasVisibleRoot(cd->baseClasses()))    {      if (!started)      {        {          // UGLY HACK!          ol.pushGeneratorState();          ol.disable(OutputGenerator::Man);          ol.disable(OutputGenerator::Html);          if (level<6) ol.startIndexList();          ol.enableAll();          ol.disable(OutputGenerator::Latex);          ol.disable(OutputGenerator::RTF);          ol.startItemList();          ol.popGeneratorState();        }        if (hasHtmlHelp) htmlHelp->incContentsDepth();        if (hasFtvHelp)  ftvHelp->incContentsDepth();        started=TRUE;      }      //printf("Passed...\n");      bool hasChildren = !cd->visited && !hideSuper && cd->subClasses()->count()>0;      if (cd->isLinkable())      {        //printf("Writing class %s\n",cd->displayName().data());        ol.writeIndexItem(cd->getReference(),cd->getOutputFileBase(),cd->displayName());        if (cd->isReference())         {           ol.startTypewriter();           ol.docify(" [external]");          ol.endTypewriter();        }        if (hasHtmlHelp)        {          htmlHelp->addContentsItem(hasChildren,cd->name(),cd->getOutputFileBase());        }        if (hasFtvHelp)        {          ftvHelp->addContentsItem(hasChildren,cd->getReference(),cd->getOutputFileBase(),0,cd->name());        }      }      else      {        ol.writeIndexItem(0,0,cd->name());        if (hasHtmlHelp)        {          htmlHelp->addContentsItem(hasChildren,cd->name(),0);        }        if (hasFtvHelp)        {          ftvHelp->addContentsItem(hasChildren,0,0,0,cd->name());        }      }      if (hasChildren)      {        //printf("Class %s at %p visited=%d\n",cd->name().data(),cd,cd->visited);        bool wasVisited=cd->visited;        cd->visited=TRUE;        writeClassTree(ol,cd->subClasses(),wasVisited,level+1);      }    }  }  if (started)   {    {      // UGLY HACK!      ol.pushGeneratorState();      ol.disable(OutputGenerator::Man);      ol.disable(OutputGenerator::Html);      if (level<6) ol.endIndexList();      ol.enableAll();      ol.disable(OutputGenerator::Latex);      ol.disable(OutputGenerator::RTF);      ol.endItemList();      ol.popGeneratorState();    }    if (hasHtmlHelp) htmlHelp->decContentsDepth();    if (hasFtvHelp)  ftvHelp->decContentsDepth();  }}//----------------------------------------------------------------------------/*! Generates HTML Help tree of classes */void writeClassTree(BaseClassList *cl,int level){  HtmlHelp *htmlHelp=0;  FTVHelp  *ftvHelp=0;  bool &generateHtml = Config_getBool("GENERATE_HTML") ;  bool hasHtmlHelp = generateHtml && Config_getBool("GENERATE_HTMLHELP");  bool hasFtvHelp  = generateHtml && Config_getBool("GENERATE_TREEVIEW");  if (hasHtmlHelp)  {    htmlHelp = HtmlHelp::getInstance();  }  if (hasFtvHelp)  {    ftvHelp = FTVHelp::getInstance();  }  BaseClassListIterator cli(*cl);  bool started=FALSE;  for ( ; cli.current() ; ++cli)  {    ClassDef *cd=cli.current()->classDef;    if (cd->isVisibleInHierarchy() && !cd->visited)    {

⌨️ 快捷键说明

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