Orb/Doxygen/src/namespacedef.cpp
changeset 0 42188c7ea2d9
child 4 468f4c8d3d5b
equal deleted inserted replaced
-1:000000000000 0:42188c7ea2d9
       
     1 /******************************************************************************
       
     2  *
       
     3  * 
       
     4  *
       
     5  * Copyright (C) 1997-2008 by Dimitri van Heesch.
       
     6  *
       
     7  * Permission to use, copy, modify, and distribute this software and its
       
     8  * documentation under the terms of the GNU General Public License is hereby 
       
     9  * granted. No representations are made about the suitability of this software 
       
    10  * for any purpose. It is provided "as is" without express or implied warranty.
       
    11  * See the GNU General Public License for more details.
       
    12  *
       
    13  * Documents produced by Doxygen are derivative works derived from the
       
    14  * input used in their production; they are not affected by this license.
       
    15  *
       
    16  */
       
    17 
       
    18 #include "qtbc.h"
       
    19 #include "namespacedef.h"
       
    20 #include "outputlist.h"
       
    21 #include "util.h"
       
    22 #include "language.h"
       
    23 #include "classdef.h"
       
    24 #include "classlist.h"
       
    25 #include "memberlist.h"
       
    26 #include "doxygen.h"
       
    27 #include "message.h"
       
    28 #include "docparser.h"
       
    29 #include "searchindex.h"
       
    30 #include "vhdldocgen.h"
       
    31 #include "layout.h"
       
    32 
       
    33 //------------------------------------------------------------------
       
    34 
       
    35 NamespaceDef::NamespaceDef(const char *df,int dl,
       
    36                            const char *name,const char *lref,
       
    37                            const char *fName) : 
       
    38    Definition(df,dl,name)
       
    39 {
       
    40   if (fName)
       
    41   {
       
    42     fileName = stripExtension(fName);
       
    43   }
       
    44   else
       
    45   {
       
    46     fileName="namespace";
       
    47     fileName+=name;
       
    48   }
       
    49   classSDict = new ClassSDict(17);
       
    50   namespaceSDict = new NamespaceSDict(17);
       
    51   m_innerCompounds = new SDict<Definition>(17);
       
    52   usingDirList = 0;
       
    53   usingDeclList = 0;
       
    54   m_allMembersDict = 0;
       
    55   setReference(lref);
       
    56   memberGroupSDict = new MemberGroupSDict;
       
    57   memberGroupSDict->setAutoDelete(TRUE);
       
    58   visited=FALSE;
       
    59   m_subGrouping=Config_getBool("SUBGROUPING");
       
    60 }
       
    61 
       
    62 NamespaceDef::~NamespaceDef()
       
    63 {
       
    64   delete classSDict;
       
    65   delete namespaceSDict;
       
    66   delete m_innerCompounds;
       
    67   delete usingDirList;
       
    68   delete usingDeclList;
       
    69   delete memberGroupSDict;
       
    70 }
       
    71 
       
    72 void NamespaceDef::distributeMemberGroupDocumentation()
       
    73 {
       
    74   MemberGroupSDict::Iterator mgli(*memberGroupSDict);
       
    75   MemberGroup *mg;
       
    76   for (;(mg=mgli.current());++mgli)
       
    77   {
       
    78     mg->distributeMemberGroupDocumentation();
       
    79   }
       
    80 }
       
    81 
       
    82 void NamespaceDef::findSectionsInDocumentation()
       
    83 {
       
    84   docFindSections(documentation(),this,0,docFile());
       
    85   MemberGroupSDict::Iterator mgli(*memberGroupSDict);
       
    86   MemberGroup *mg;
       
    87   for (;(mg=mgli.current());++mgli)
       
    88   {
       
    89     mg->findSectionsInDocumentation();
       
    90   }
       
    91   QListIterator<MemberList> mli(m_memberLists);
       
    92   MemberList *ml;
       
    93   for (mli.toFirst();(ml=mli.current());++mli)
       
    94   {
       
    95     if (ml->listType()&MemberList::declarationLists)
       
    96     {
       
    97       ml->findSectionsInDocumentation();
       
    98     }
       
    99   }
       
   100 }
       
   101 
       
   102 void NamespaceDef::insertUsedFile(const char *f)
       
   103 {
       
   104   if (files.find(f)==-1) 
       
   105   {
       
   106     if (Config_getBool("SORT_MEMBER_DOCS"))
       
   107       files.inSort(f);
       
   108     else
       
   109       files.append(f);
       
   110   }
       
   111 }
       
   112 
       
   113 void NamespaceDef::addInnerCompound(Definition *d)
       
   114 {
       
   115   m_innerCompounds->append(d->localName(),d);
       
   116   if (d->definitionType()==Definition::TypeNamespace)
       
   117   {
       
   118     insertNamespace((NamespaceDef *)d);
       
   119   }
       
   120   else if (d->definitionType()==Definition::TypeClass)
       
   121   {
       
   122     insertClass((ClassDef *)d);
       
   123   }
       
   124 }
       
   125 
       
   126 void NamespaceDef::insertClass(ClassDef *cd)
       
   127 {
       
   128   if (classSDict->find(cd->name())==0)
       
   129   {
       
   130     if (Config_getBool("SORT_BRIEF_DOCS"))
       
   131       classSDict->inSort(cd->name(),cd);
       
   132     else
       
   133       classSDict->append(cd->name(),cd);
       
   134   }
       
   135 }
       
   136 
       
   137 void NamespaceDef::insertNamespace(NamespaceDef *nd)
       
   138 {
       
   139   if (namespaceSDict->find(nd->name())==0)
       
   140   {
       
   141     if (Config_getBool("SORT_MEMBER_DOCS"))
       
   142       namespaceSDict->inSort(nd->name(),nd);
       
   143     else
       
   144       namespaceSDict->append(nd->name(),nd);
       
   145   }
       
   146 }
       
   147 
       
   148 
       
   149 void NamespaceDef::addMembersToMemberGroup()
       
   150 {
       
   151   QListIterator<MemberList> mli(m_memberLists);
       
   152   MemberList *ml;
       
   153   for (mli.toFirst();(ml=mli.current());++mli)
       
   154   {
       
   155     if (ml->listType()&MemberList::declarationLists)
       
   156     {
       
   157       ::addMembersToMemberGroup(ml,&memberGroupSDict,this);
       
   158     }
       
   159   }
       
   160 
       
   161   // add members inside sections to their groups
       
   162   if (memberGroupSDict)
       
   163   {
       
   164     MemberGroupSDict::Iterator mgli(*memberGroupSDict);
       
   165     MemberGroup *mg;
       
   166     for (;(mg=mgli.current());++mgli)
       
   167     {
       
   168       if (mg->allMembersInSameSection() && m_subGrouping)
       
   169       {
       
   170         //printf("----> addToDeclarationSection(%s)\n",mg->header().data());
       
   171         mg->addToDeclarationSection();
       
   172       }
       
   173     }
       
   174   }
       
   175 }
       
   176 
       
   177 void NamespaceDef::insertMember(MemberDef *md)
       
   178 {
       
   179   if (md->isHidden()) return;
       
   180   MemberList *allMemberList = getMemberList(MemberList::allMembersList);
       
   181   if (allMemberList==0)
       
   182   {
       
   183     allMemberList = new MemberList(MemberList::allMembersList);
       
   184     m_memberLists.append(allMemberList);
       
   185   }
       
   186   allMemberList->append(md); 
       
   187   if (m_allMembersDict==0)
       
   188   {
       
   189     m_allMembersDict = new MemberSDict;
       
   190   }
       
   191   //printf("%s::m_allMembersDict->append(%s)\n",name().data(),md->localName().data());
       
   192   m_allMembersDict->append(md->localName(),md); 
       
   193   //::addNamespaceMemberNameToIndex(md);
       
   194   //static bool sortBriefDocs=Config_getBool("SORT_BRIEF_DOCS");
       
   195   switch(md->memberType())
       
   196   {
       
   197     case MemberDef::Variable:     
       
   198       addMemberToList(MemberList::decVarMembers,md);
       
   199       addMemberToList(MemberList::docVarMembers,md);
       
   200       break;
       
   201     case MemberDef::Function: 
       
   202       addMemberToList(MemberList::decFuncMembers,md);
       
   203       addMemberToList(MemberList::docFuncMembers,md);
       
   204       break;
       
   205     case MemberDef::Typedef:      
       
   206       addMemberToList(MemberList::decTypedefMembers,md);
       
   207       addMemberToList(MemberList::docTypedefMembers,md);
       
   208       break;
       
   209     case MemberDef::Enumeration:  
       
   210       addMemberToList(MemberList::decEnumMembers,md);
       
   211       addMemberToList(MemberList::docEnumMembers,md);
       
   212       break;
       
   213     case MemberDef::EnumValue:    
       
   214       break;
       
   215     case MemberDef::Define:       
       
   216       addMemberToList(MemberList::decDefineMembers,md);
       
   217       addMemberToList(MemberList::docDefineMembers,md);
       
   218       break;
       
   219     default:
       
   220       err("NamespaceDef::insertMembers(): "
       
   221            "member `%s' with class scope `%s' inserted in namespace scope `%s'!\n",
       
   222            md->name().data(),
       
   223            md->getClassDef() ? md->getClassDef()->name().data() : "",
       
   224            name().data());
       
   225   }
       
   226 }
       
   227 
       
   228 void NamespaceDef::computeAnchors()
       
   229 {
       
   230   MemberList *allMemberList = getMemberList(MemberList::allMembersList);
       
   231   if (allMemberList) setAnchors(0,'a',allMemberList);
       
   232 }
       
   233 
       
   234 void NamespaceDef::writeDetailedDescription(OutputList &ol,const QCString &title)
       
   235 {
       
   236   if ((!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF")) || 
       
   237       !documentation().isEmpty()
       
   238      )
       
   239   {
       
   240     ol.writeRuler();
       
   241     ol.pushGeneratorState();
       
   242     ol.disableAllBut(OutputGenerator::Html);
       
   243       ol.writeAnchor(0,"_details"); 
       
   244     ol.popGeneratorState();
       
   245     ol.startGroupHeader();
       
   246     ol.parseText(title);
       
   247     ol.endGroupHeader();
       
   248 
       
   249     ol.startTextBlock();
       
   250     if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF"))
       
   251     {
       
   252       ol.parseDoc(briefFile(),briefLine(),this,0,briefDescription(),FALSE,FALSE);
       
   253     }
       
   254     if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF") &&
       
   255         !documentation().isEmpty())
       
   256     {
       
   257       ol.pushGeneratorState();
       
   258         ol.disable(OutputGenerator::Man);
       
   259         ol.disable(OutputGenerator::RTF);
       
   260         //ol.newParagraph(); // FIXME:PARA
       
   261         ol.enableAll();
       
   262         ol.disableAllBut(OutputGenerator::Man);
       
   263         ol.writeString("\n\n");
       
   264       ol.popGeneratorState();
       
   265     }
       
   266     if (!documentation().isEmpty())
       
   267     {
       
   268       ol.parseDoc(docFile(),docLine(),this,0,documentation()+"\n",TRUE,FALSE);
       
   269     }
       
   270     ol.endTextBlock();
       
   271   }
       
   272 }
       
   273 
       
   274 void NamespaceDef::writeBriefDescription(OutputList &ol)
       
   275 {
       
   276   if (!briefDescription().isEmpty()) 
       
   277   {
       
   278     ol.startParagraph();
       
   279     ol.parseDoc(briefFile(),briefLine(),this,0,
       
   280                 briefDescription(),TRUE,FALSE,0,TRUE,FALSE);
       
   281     ol.pushGeneratorState();
       
   282     ol.disable(OutputGenerator::RTF);
       
   283     ol.writeString(" \n");
       
   284     ol.enable(OutputGenerator::RTF);
       
   285 
       
   286     if (Config_getBool("REPEAT_BRIEF") ||
       
   287         !documentation().isEmpty()
       
   288        )
       
   289     {
       
   290       ol.disableAllBut(OutputGenerator::Html);
       
   291       ol.startTextLink(0,"_details");
       
   292       ol.parseText(theTranslator->trMore());
       
   293       ol.endTextLink();
       
   294     }
       
   295     ol.popGeneratorState();
       
   296     ol.endParagraph();
       
   297 
       
   298     // FIXME:PARA
       
   299     //ol.pushGeneratorState();
       
   300     //ol.disable(OutputGenerator::RTF);
       
   301     //ol.newParagraph();
       
   302     //ol.popGeneratorState();
       
   303   }
       
   304   ol.writeSynopsis();
       
   305 }
       
   306 
       
   307 void NamespaceDef::startMemberDeclarations(OutputList &ol)
       
   308 {
       
   309   ol.startMemberSections();
       
   310 }
       
   311 
       
   312 void NamespaceDef::endMemberDeclarations(OutputList &ol)
       
   313 {
       
   314   ol.endMemberSections();
       
   315 }
       
   316 
       
   317 void NamespaceDef::startMemberDocumentation(OutputList &ol)
       
   318 {
       
   319   if (Config_getBool("SEPARATE_MEMBER_PAGES"))
       
   320   {
       
   321     ol.disable(OutputGenerator::Html);
       
   322     Doxygen::suppressDocWarnings = TRUE;
       
   323   }
       
   324 }
       
   325 
       
   326 void NamespaceDef::endMemberDocumentation(OutputList &ol)
       
   327 {
       
   328   if (Config_getBool("SEPARATE_MEMBER_PAGES"))
       
   329   {
       
   330     ol.enable(OutputGenerator::Html);
       
   331     Doxygen::suppressDocWarnings = FALSE;
       
   332   }
       
   333 }
       
   334 
       
   335 void NamespaceDef::writeClassDeclarations(OutputList &ol,const QCString &title)
       
   336 {
       
   337   if (classSDict) classSDict->writeDeclaration(ol,0,title,TRUE);
       
   338 }
       
   339 
       
   340 void NamespaceDef::writeNamespaceDeclarations(OutputList &ol,const QCString &title)
       
   341 {
       
   342   if (namespaceSDict) namespaceSDict->writeDeclaration(ol,title,TRUE);
       
   343 }
       
   344 
       
   345 void NamespaceDef::writeMemberGroups(OutputList &ol)
       
   346 {
       
   347   /* write user defined member groups */
       
   348   if (memberGroupSDict)
       
   349   {
       
   350     MemberGroupSDict::Iterator mgli(*memberGroupSDict);
       
   351     MemberGroup *mg;
       
   352     for (;(mg=mgli.current());++mgli)
       
   353     {
       
   354       if ((!mg->allMembersInSameSection() || !m_subGrouping) 
       
   355           && mg->header()!="[NOHEADER]")
       
   356       {
       
   357         mg->writeDeclarations(ol,0,this,0,0);
       
   358       }
       
   359     }
       
   360   }
       
   361 }
       
   362   
       
   363 void NamespaceDef::writeAuthorSection(OutputList &ol)
       
   364 {
       
   365   // write Author section (Man only)
       
   366   ol.pushGeneratorState();
       
   367   ol.disableAllBut(OutputGenerator::Man);
       
   368   ol.startGroupHeader();
       
   369   ol.parseText(theTranslator->trAuthor(TRUE,TRUE));
       
   370   ol.endGroupHeader();
       
   371   ol.parseText(theTranslator->trGeneratedAutomatically(Config_getString("PROJECT_NAME")));
       
   372   ol.popGeneratorState();
       
   373 }
       
   374 
       
   375 void NamespaceDef::writeDocumentation(OutputList &ol)
       
   376 {
       
   377   bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
       
   378 
       
   379   QCString pageTitle;
       
   380   if (Config_getBool("OPTIMIZE_OUTPUT_JAVA"))
       
   381   {
       
   382     pageTitle = theTranslator->trPackage(displayName());
       
   383   }
       
   384   else if (fortranOpt)
       
   385   {
       
   386     pageTitle = theTranslator->trModuleReference(displayName());
       
   387   }
       
   388   else
       
   389   {
       
   390     pageTitle = theTranslator->trNamespaceReference(displayName());
       
   391   }
       
   392   startFile(ol,getOutputFileBase(),name(),pageTitle,HLI_NamespaceVisible,TRUE);
       
   393   if (getOuterScope()!=Doxygen::globalScope)
       
   394   {
       
   395     writeNavigationPath(ol);
       
   396   }
       
   397   ol.endQuickIndices();
       
   398   ol.startContents();
       
   399   startTitle(ol,getOutputFileBase());
       
   400   ol.parseText(pageTitle);
       
   401   addGroupListToTitle(ol,this);
       
   402   endTitle(ol,getOutputFileBase(),displayName());
       
   403   
       
   404   if (Doxygen::searchIndex)
       
   405   {
       
   406     Doxygen::searchIndex->setCurrentDoc(pageTitle,getOutputFileBase());
       
   407     Doxygen::searchIndex->addWord(localName(),TRUE);
       
   408   }
       
   409 
       
   410   bool generateTagFile = !Config_getString("GENERATE_TAGFILE").isEmpty();
       
   411   if (generateTagFile)
       
   412   {
       
   413     Doxygen::tagFile << "  <compound kind=\"namespace\">" << endl;
       
   414     Doxygen::tagFile << "    <name>" << convertToXML(name()) << "</name>" << endl;
       
   415     Doxygen::tagFile << "    <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl;
       
   416   }
       
   417 
       
   418   Doxygen::indexList.addIndexItem(this,0);
       
   419 
       
   420   //---------------------------------------- start flexible part -------------------------------
       
   421 
       
   422   QListIterator<LayoutDocEntry> eli(
       
   423       LayoutDocManager::instance().docEntries(LayoutDocManager::Namespace));
       
   424   LayoutDocEntry *lde;
       
   425   for (eli.toFirst();(lde=eli.current());++eli)
       
   426   {
       
   427     switch (lde->kind())
       
   428     {
       
   429       case LayoutDocEntry::BriefDesc: 
       
   430         writeBriefDescription(ol);
       
   431         break; 
       
   432       case LayoutDocEntry::MemberDeclStart: 
       
   433         startMemberDeclarations(ol);
       
   434         break; 
       
   435       case LayoutDocEntry::NamespaceClasses: 
       
   436         {
       
   437           LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
       
   438           writeClassDeclarations(ol,ls->title);
       
   439         }
       
   440         break; 
       
   441       case LayoutDocEntry::NamespaceNestedNamespaces: 
       
   442         {
       
   443           LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
       
   444           writeNamespaceDeclarations(ol,ls->title);
       
   445         }
       
   446         break; 
       
   447       case LayoutDocEntry::MemberGroups: 
       
   448         writeMemberGroups(ol);
       
   449         break; 
       
   450       case LayoutDocEntry::MemberDecl: 
       
   451         {
       
   452           LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde;
       
   453           writeMemberDeclarations(ol,lmd->type,lmd->title);
       
   454         }
       
   455         break; 
       
   456       case LayoutDocEntry::MemberDeclEnd: 
       
   457         endMemberDeclarations(ol);
       
   458         break;
       
   459       case LayoutDocEntry::DetailedDesc: 
       
   460         {
       
   461           LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
       
   462           writeDetailedDescription(ol,ls->title);
       
   463         }
       
   464         break;
       
   465       case LayoutDocEntry::MemberDefStart: 
       
   466         startMemberDocumentation(ol);
       
   467         break; 
       
   468       case LayoutDocEntry::MemberDef: 
       
   469         {
       
   470           LayoutDocEntryMemberDef *lmd = (LayoutDocEntryMemberDef*)lde;
       
   471           writeMemberDocumentation(ol,lmd->type,lmd->title);
       
   472         }
       
   473         break;
       
   474       case LayoutDocEntry::MemberDefEnd: 
       
   475         endMemberDocumentation(ol);
       
   476         break;
       
   477       case LayoutDocEntry::AuthorSection: 
       
   478         writeAuthorSection(ol);
       
   479         break;
       
   480       case LayoutDocEntry::ClassIncludes:
       
   481       case LayoutDocEntry::ClassInheritanceGraph:
       
   482       case LayoutDocEntry::ClassNestedClasses:
       
   483       case LayoutDocEntry::ClassCollaborationGraph:
       
   484       case LayoutDocEntry::ClassAllMembersLink:
       
   485       case LayoutDocEntry::ClassUsedFiles:
       
   486       case LayoutDocEntry::FileClasses:
       
   487       case LayoutDocEntry::FileNamespaces:
       
   488       case LayoutDocEntry::FileIncludes:
       
   489       case LayoutDocEntry::FileIncludeGraph:
       
   490       case LayoutDocEntry::FileIncludedByGraph: 
       
   491       case LayoutDocEntry::FileSourceLink:
       
   492       case LayoutDocEntry::GroupClasses: 
       
   493       case LayoutDocEntry::GroupNamespaces:
       
   494       case LayoutDocEntry::GroupDirs: 
       
   495       case LayoutDocEntry::GroupNestedGroups: 
       
   496       case LayoutDocEntry::GroupFiles:
       
   497       case LayoutDocEntry::GroupGraph: 
       
   498       case LayoutDocEntry::GroupPageDocs:
       
   499       case LayoutDocEntry::DirSubDirs:
       
   500       case LayoutDocEntry::DirFiles:
       
   501       case LayoutDocEntry::DirGraph:
       
   502         err("Internal inconsistency: member %d should not be part of "
       
   503             "LayoutDocManager::Namespace entry list\n",lde->kind());
       
   504         break;
       
   505     }
       
   506   }
       
   507 
       
   508   //---------------------------------------- end flexible part -------------------------------
       
   509 
       
   510   endFile(ol);
       
   511 
       
   512   if (generateTagFile)
       
   513   {
       
   514     writeDocAnchorsToTagFile();
       
   515     Doxygen::tagFile << "  </compound>" << endl;
       
   516   }
       
   517 
       
   518   if (Config_getBool("SEPARATE_MEMBER_PAGES"))
       
   519   {
       
   520     MemberList *allMemberList = getMemberList(MemberList::allMembersList);
       
   521     if (allMemberList) allMemberList->sort();
       
   522     writeMemberPages(ol);
       
   523   }
       
   524 }
       
   525 
       
   526 void NamespaceDef::writeMemberPages(OutputList &ol)
       
   527 {
       
   528   ol.pushGeneratorState();
       
   529   ol.disableAllBut(OutputGenerator::Html);
       
   530 
       
   531   QListIterator<MemberList> mli(m_memberLists);
       
   532   MemberList *ml;
       
   533   for (mli.toFirst();(ml=mli.current());++mli)
       
   534   {
       
   535     if (ml->listType()&MemberList::documentationLists)
       
   536     {
       
   537       ml->writeDocumentationPage(ol,name(),this);
       
   538     }
       
   539   }
       
   540   ol.popGeneratorState();
       
   541 }
       
   542 
       
   543 void NamespaceDef::writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const
       
   544 {
       
   545   static bool createSubDirs=Config_getBool("CREATE_SUBDIRS");
       
   546 
       
   547   ol.writeString("      <div class=\"navtab\">\n");
       
   548   ol.writeString("        <table>\n");
       
   549 
       
   550   MemberList *allMemberList = getMemberList(MemberList::allMembersList);
       
   551   if (allMemberList)
       
   552   {
       
   553     MemberListIterator mli(*allMemberList);
       
   554     MemberDef *md;
       
   555     for (mli.toFirst();(md=mli.current());++mli)
       
   556     {
       
   557       if (md->getNamespaceDef()==this && md->isLinkable())
       
   558       {
       
   559         ol.writeString("          <tr><td class=\"navtab\">");
       
   560         if (md->isLinkableInProject())
       
   561         {
       
   562           if (md==currentMd) // selected item => highlight
       
   563           {
       
   564             ol.writeString("<a class=\"qindexHL\" ");
       
   565           }
       
   566           else
       
   567           {
       
   568             ol.writeString("<a class=\"qindex\" ");
       
   569           }
       
   570           ol.writeString("href=\"");
       
   571           if (createSubDirs) ol.writeString("../../");
       
   572           ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor());
       
   573           ol.writeString("\">");
       
   574           ol.writeString(md->localName());
       
   575           ol.writeString("</a>");
       
   576         }
       
   577         ol.writeString("</td></tr>\n");
       
   578       }
       
   579     }
       
   580   }
       
   581 
       
   582   ol.writeString("        </table>\n");
       
   583   ol.writeString("      </div>\n");
       
   584 }
       
   585 
       
   586 int NamespaceDef::countMembers()
       
   587 {
       
   588   MemberList *allMemberList = getMemberList(MemberList::allMembersList);
       
   589   if (allMemberList) allMemberList->countDocMembers();
       
   590   return (allMemberList ? allMemberList->numDocMembers() : 0)+classSDict->count();
       
   591 }
       
   592 
       
   593 void NamespaceDef::addUsingDirective(NamespaceDef *nd)
       
   594 {
       
   595   if (usingDirList==0)
       
   596   {
       
   597     usingDirList = new NamespaceSDict;
       
   598   }
       
   599   if (usingDirList->find(nd->qualifiedName())==0)
       
   600   {
       
   601     usingDirList->append(nd->qualifiedName(),nd);
       
   602   }
       
   603   //printf("%p: NamespaceDef::addUsingDirective: %s:%d\n",this,name().data(),usingDirList->count());
       
   604 }
       
   605 
       
   606 NamespaceSDict *NamespaceDef::getUsedNamespaces() const 
       
   607 { 
       
   608   //printf("%p: NamespaceDef::getUsedNamespace: %s:%d\n",this,name().data(),usingDirList?usingDirList->count():0);
       
   609   return usingDirList; 
       
   610 }
       
   611 
       
   612 void NamespaceDef::addUsingDeclaration(Definition *d)
       
   613 {
       
   614   if (usingDeclList==0)
       
   615   {
       
   616     usingDeclList = new SDict<Definition>(17);
       
   617   }
       
   618   if (usingDeclList->find(d->qualifiedName())==0)
       
   619   {
       
   620     usingDeclList->append(d->qualifiedName(),d);
       
   621   }
       
   622 }
       
   623 
       
   624 QCString NamespaceDef::getOutputFileBase() const 
       
   625 { 
       
   626   if (isReference())
       
   627   {
       
   628     return fileName;
       
   629   }
       
   630   else
       
   631   {
       
   632     return convertNameToFile(fileName); 
       
   633   }
       
   634 }
       
   635 
       
   636 Definition *NamespaceDef::findInnerCompound(const char *n)
       
   637 {
       
   638   if (n==0) return 0;
       
   639   Definition *d = m_innerCompounds->find(n);
       
   640   if (d==0)
       
   641   {
       
   642     if (usingDirList)
       
   643     {
       
   644       d = usingDirList->find(n);
       
   645     }
       
   646     if (d==0 && usingDeclList)
       
   647     {
       
   648       d = usingDeclList->find(n);
       
   649     }
       
   650   }
       
   651   return d;
       
   652 }
       
   653 
       
   654 void NamespaceDef::addListReferences()
       
   655 {
       
   656   bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
       
   657   {
       
   658     LockingPtr< QList<ListItemInfo> > xrefItems = xrefListItems();
       
   659     addRefItem(xrefItems.pointer(),
       
   660         qualifiedName(),
       
   661         fortranOpt?theTranslator->trModule(TRUE,TRUE):theTranslator->trNamespace(TRUE,TRUE),
       
   662         getOutputFileBase(),displayName(),
       
   663         0
       
   664         );
       
   665   }
       
   666   MemberGroupSDict::Iterator mgli(*memberGroupSDict);
       
   667   MemberGroup *mg;
       
   668   for (;(mg=mgli.current());++mgli)
       
   669   {
       
   670     mg->addListReferences(this);
       
   671   }
       
   672   QListIterator<MemberList> mli(m_memberLists);
       
   673   MemberList *ml;
       
   674   for (mli.toFirst();(ml=mli.current());++mli)
       
   675   {
       
   676     if (ml->listType()&MemberList::documentationLists)
       
   677     {
       
   678       ml->addListReferences(this);
       
   679     }
       
   680   }
       
   681 }
       
   682 
       
   683 QCString NamespaceDef::displayName() const
       
   684 {
       
   685   QCString result=name();
       
   686   if (Config_getBool("OPTIMIZE_OUTPUT_JAVA"))
       
   687   {
       
   688     result = substitute(result,"::",".");
       
   689   }
       
   690   return result; 
       
   691 }
       
   692 
       
   693 void NamespaceDef::combineUsingRelations()
       
   694 {
       
   695   if (visited) return; // already done
       
   696   visited=TRUE;
       
   697   if (usingDirList)
       
   698   {
       
   699     NamespaceSDict::Iterator nli(*usingDirList);
       
   700     NamespaceDef *nd;
       
   701     for (nli.toFirst();(nd=nli.current());++nli)
       
   702     {
       
   703       nd->combineUsingRelations();
       
   704     }
       
   705     for (nli.toFirst();(nd=nli.current());++nli)
       
   706     {
       
   707       // add used namespaces of namespace nd to this namespace
       
   708       if (nd->getUsedNamespaces())
       
   709       {
       
   710         NamespaceSDict::Iterator unli(*nd->getUsedNamespaces());
       
   711         NamespaceDef *und;
       
   712         for (unli.toFirst();(und=unli.current());++unli)
       
   713         {
       
   714           //printf("Adding namespace %s to the using list of %s\n",und->qualifiedName().data(),qualifiedName().data());
       
   715           addUsingDirective(und);
       
   716         }
       
   717       }
       
   718       // add used classes of namespace nd to this namespace
       
   719       if (nd->getUsedClasses())
       
   720       {
       
   721         SDict<Definition>::Iterator cli(*nd->getUsedClasses());
       
   722         Definition *ucd;
       
   723         for (cli.toFirst();(ucd=cli.current());++cli)
       
   724         {
       
   725           //printf("Adding class %s to the using list of %s\n",cd->qualifiedName().data(),qualifiedName().data());
       
   726           addUsingDeclaration(ucd);
       
   727         }
       
   728       }
       
   729     }
       
   730   }
       
   731 }
       
   732 
       
   733 void NamespaceSDict::writeDeclaration(OutputList &ol,const char *title,bool localName)
       
   734 {
       
   735   if (count()==0) return; // no namespaces in the list
       
   736 
       
   737   SDict<NamespaceDef>::Iterator ni(*this);
       
   738   NamespaceDef *nd;
       
   739   bool found=FALSE;
       
   740   for (ni.toFirst();(nd=ni.current()) && !found;++ni)
       
   741   {
       
   742     if (nd->isLinkable()) found=TRUE;
       
   743   }
       
   744   if (!found) return; // no linkable namespaces in the list
       
   745 
       
   746   // write list of namespaces
       
   747   ol.startMemberHeader();
       
   748   bool javaOpt    = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
       
   749   bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
       
   750 #if 0
       
   751   if (javaOpt)
       
   752   {
       
   753     ol.parseText(theTranslator->trPackages());
       
   754   }
       
   755   else if (fortranOpt)
       
   756   {
       
   757     ol.parseText(theTranslator->trModules());
       
   758   }
       
   759   else
       
   760   {
       
   761     ol.parseText(theTranslator->trNamespaces());
       
   762   }
       
   763 #endif
       
   764   ol.parseText(title);
       
   765   ol.endMemberHeader();
       
   766   ol.startMemberList();
       
   767   for (ni.toFirst();(nd=ni.current());++ni)
       
   768   {
       
   769     if (nd->isLinkable())
       
   770     {
       
   771       ol.startMemberItem(0);
       
   772       if (javaOpt)
       
   773       {
       
   774         ol.docify("package ");
       
   775       }
       
   776       else if (fortranOpt)
       
   777       {
       
   778         ol.docify("module ");
       
   779       }
       
   780       else
       
   781       {
       
   782         ol.docify("namespace ");
       
   783       }
       
   784       ol.insertMemberAlign();
       
   785       QCString name;
       
   786       if (localName)
       
   787       {
       
   788         name = nd->localName();
       
   789       }
       
   790       else
       
   791       {
       
   792         name = nd->displayName();
       
   793       }
       
   794       ol.writeObjectLink(nd->getReference(),nd->getOutputFileBase(),0,name);
       
   795       if (!Config_getString("GENERATE_TAGFILE").isEmpty() && !nd->isReference()) 
       
   796       {
       
   797         Doxygen::tagFile << "    <namespace>" << convertToXML(nd->name()) << "</namespace>" << endl;
       
   798       }
       
   799       ol.endMemberItem();
       
   800       if (!nd->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC"))
       
   801       {
       
   802         ol.startParagraph();
       
   803         ol.startMemberDescription();
       
   804         ol.parseDoc(nd->briefFile(),nd->briefLine(),nd,0,nd->briefDescription(),FALSE,FALSE);
       
   805         ol.endMemberDescription();
       
   806         ol.endParagraph();
       
   807       }
       
   808     }
       
   809   }
       
   810   ol.endMemberList();
       
   811 }
       
   812 
       
   813 MemberList *NamespaceDef::createMemberList(MemberList::ListType lt)
       
   814 {
       
   815   m_memberLists.setAutoDelete(TRUE);
       
   816   QListIterator<MemberList> mli(m_memberLists);
       
   817   MemberList *ml;
       
   818   for (mli.toFirst();(ml=mli.current());++mli)
       
   819   {
       
   820     if (ml->listType()==lt)
       
   821     {
       
   822       return ml;
       
   823     }
       
   824   }
       
   825   // not found, create a new member list
       
   826   ml = new MemberList(lt);
       
   827   m_memberLists.append(ml);
       
   828   return ml;
       
   829 }
       
   830 
       
   831 void NamespaceDef::addMemberToList(MemberList::ListType lt,MemberDef *md)
       
   832 {
       
   833   static bool sortBriefDocs = Config_getBool("SORT_BRIEF_DOCS");
       
   834   static bool sortMemberDocs = Config_getBool("SORT_MEMBER_DOCS");
       
   835   MemberList *ml = createMemberList(lt);
       
   836   if (((ml->listType()&MemberList::declarationLists) && sortBriefDocs) ||
       
   837       ((ml->listType()&MemberList::documentationLists) && sortMemberDocs)
       
   838      )
       
   839     ml->inSort(md);
       
   840   else
       
   841     ml->append(md);
       
   842   if (ml->listType()&MemberList::declarationLists) md->setSectionList(this,ml);
       
   843 }
       
   844 
       
   845 MemberList *NamespaceDef::getMemberList(MemberList::ListType lt) const
       
   846 {
       
   847   NamespaceDef *that = (NamespaceDef*)this;
       
   848   MemberList *ml = that->m_memberLists.first();
       
   849   while (ml)
       
   850   {
       
   851     if (ml->listType()==lt)
       
   852     {
       
   853       return ml;
       
   854     }
       
   855     ml = that->m_memberLists.next();
       
   856   }
       
   857   return 0;
       
   858 }
       
   859 
       
   860 void NamespaceDef::writeMemberDeclarations(OutputList &ol,MemberList::ListType lt,const QCString &title)
       
   861 {
       
   862   MemberList * ml = getMemberList(lt);
       
   863   if (ml) ml->writeDeclarations(ol,0,this,0,0,title,0);
       
   864 }
       
   865 
       
   866 void NamespaceDef::writeMemberDocumentation(OutputList &ol,MemberList::ListType lt,const QCString &title)
       
   867 {
       
   868   MemberList * ml = getMemberList(lt);
       
   869   if (ml) ml->writeDocumentation(ol,name(),this,title);
       
   870 }
       
   871 
       
   872 
       
   873 bool NamespaceDef::isLinkableInProject() const
       
   874 {
       
   875   int i = name().findRev("::");
       
   876   if (i==-1) i=0; else i+=2;
       
   877   static bool extractAnonNs = Config_getBool("EXTRACT_ANON_NSPACES");
       
   878   static bool showNamespaces = Config_getBool("SHOW_NAMESPACES");
       
   879   if (extractAnonNs &&                             // extract anonymous ns
       
   880       name().mid(i,20)=="anonymous_namespace{" &&  // correct prefix
       
   881       showNamespaces)                              // not disabled by config
       
   882   {
       
   883     return TRUE;
       
   884   }
       
   885   return !name().isEmpty() && name().at(i)!='@' && // not anonymous
       
   886     hasDocumentation() &&  // documented
       
   887     !isReference() &&      // not an external reference
       
   888     !isHidden() &&         // not hidden
       
   889     !isArtificial() &&     // or artificial
       
   890     showNamespaces;        // not disabled by config
       
   891 }
       
   892 
       
   893 bool NamespaceDef::isLinkable() const
       
   894 {
       
   895   return isLinkableInProject() || isReference();
       
   896 }
       
   897 
       
   898 
       
   899 MemberDef * NamespaceDef::getMemberByName(const QCString &n) const
       
   900 {
       
   901   MemberDef *md = 0;
       
   902   if (m_allMembersDict && !n.isEmpty())
       
   903   {
       
   904     md = m_allMembersDict->find(n);
       
   905     //printf("%s::m_allMembersDict->find(%s)=%p\n",name().data(),n.data(),md);
       
   906   }
       
   907   return md;
       
   908 }
       
   909