00001 /****************************************************************************** 00002 * 00003 * $Id: namespacedef.cpp,v 1.27 2001/03/19 19:27:41 root Exp $ 00004 * 00005 * Copyright (C) 1997-2008 by Dimitri van Heesch. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and its 00008 * documentation under the terms of the GNU General Public License is hereby 00009 * granted. No representations are made about the suitability of this software 00010 * for any purpose. It is provided "as is" without express or implied warranty. 00011 * See the GNU General Public License for more details. 00012 * 00013 * Documents produced by Doxygen are derivative works derived from the 00014 * input used in their production; they are not affected by this license. 00015 * 00016 */ 00017 00018 #include "qtbc.h" 00019 #include "namespacedef.h" 00020 #include "outputlist.h" 00021 #include "util.h" 00022 #include "language.h" 00023 #include "classdef.h" 00024 #include "classlist.h" 00025 #include "memberlist.h" 00026 #include "doxygen.h" 00027 #include "message.h" 00028 #include "docparser.h" 00029 #include "searchindex.h" 00030 #include "vhdldocgen.h" 00031 00032 NamespaceDef::NamespaceDef(const char *df,int dl, 00033 const char *name,const char *lref, 00034 const char *fName) : 00035 Definition(df,dl,name) 00036 { 00037 if (fName) 00038 { 00039 fileName = stripExtension(fName); 00040 } 00041 else 00042 { 00043 fileName="namespace"; 00044 fileName+=name; 00045 } 00046 classSDict = new ClassSDict(17); 00047 namespaceSDict = new NamespaceSDict(17); 00048 m_innerCompounds = new SDict<Definition>(17); 00049 usingDirList = 0; 00050 usingDeclList = 0; 00051 setReference(lref); 00052 memberGroupSDict = new MemberGroupSDict; 00053 memberGroupSDict->setAutoDelete(TRUE); 00054 visited=FALSE; 00055 m_subGrouping=Config_getBool("SUBGROUPING"); 00056 } 00057 00058 NamespaceDef::~NamespaceDef() 00059 { 00060 delete classSDict; 00061 delete namespaceSDict; 00062 delete m_innerCompounds; 00063 delete usingDirList; 00064 delete usingDeclList; 00065 delete memberGroupSDict; 00066 } 00067 00068 void NamespaceDef::distributeMemberGroupDocumentation() 00069 { 00070 MemberGroupSDict::Iterator mgli(*memberGroupSDict); 00071 MemberGroup *mg; 00072 for (;(mg=mgli.current());++mgli) 00073 { 00074 mg->distributeMemberGroupDocumentation(); 00075 } 00076 } 00077 00078 void NamespaceDef::findSectionsInDocumentation() 00079 { 00080 docFindSections(documentation(),this,0,docFile()); 00081 MemberGroupSDict::Iterator mgli(*memberGroupSDict); 00082 MemberGroup *mg; 00083 for (;(mg=mgli.current());++mgli) 00084 { 00085 mg->findSectionsInDocumentation(); 00086 } 00087 QListIterator<MemberList> mli(m_memberLists); 00088 MemberList *ml; 00089 for (mli.toFirst();(ml=mli.current());++mli) 00090 { 00091 if (ml->listType()&MemberList::declarationLists) 00092 { 00093 ml->findSectionsInDocumentation(); 00094 } 00095 } 00096 } 00097 00098 void NamespaceDef::insertUsedFile(const char *f) 00099 { 00100 if (files.find(f)==-1) 00101 { 00102 if (Config_getBool("SORT_MEMBER_DOCS")) 00103 files.inSort(f); 00104 else 00105 files.append(f); 00106 } 00107 } 00108 00109 void NamespaceDef::addInnerCompound(Definition *d) 00110 { 00111 m_innerCompounds->append(d->localName(),d); 00112 if (d->definitionType()==Definition::TypeNamespace) 00113 { 00114 insertNamespace((NamespaceDef *)d); 00115 } 00116 else if (d->definitionType()==Definition::TypeClass) 00117 { 00118 insertClass((ClassDef *)d); 00119 } 00120 } 00121 00122 void NamespaceDef::insertClass(ClassDef *cd) 00123 { 00124 if (classSDict->find(cd->name())==0) 00125 { 00126 if (Config_getBool("SORT_BRIEF_DOCS")) 00127 classSDict->inSort(cd->name(),cd); 00128 else 00129 classSDict->append(cd->name(),cd); 00130 } 00131 } 00132 00133 void NamespaceDef::insertNamespace(NamespaceDef *nd) 00134 { 00135 if (namespaceSDict->find(nd->name())==0) 00136 { 00137 if (Config_getBool("SORT_MEMBER_DOCS")) 00138 namespaceSDict->inSort(nd->name(),nd); 00139 else 00140 namespaceSDict->append(nd->name(),nd); 00141 } 00142 } 00143 00144 00145 void NamespaceDef::addMembersToMemberGroup() 00146 { 00147 QListIterator<MemberList> mli(m_memberLists); 00148 MemberList *ml; 00149 for (mli.toFirst();(ml=mli.current());++mli) 00150 { 00151 if (ml->listType()&MemberList::declarationLists) 00152 { 00153 ::addMembersToMemberGroup(ml,&memberGroupSDict,this); 00154 } 00155 } 00156 00157 // add members inside sections to their groups 00158 if (memberGroupSDict) 00159 { 00160 MemberGroupSDict::Iterator mgli(*memberGroupSDict); 00161 MemberGroup *mg; 00162 for (;(mg=mgli.current());++mgli) 00163 { 00164 if (mg->allMembersInSameSection() && m_subGrouping) 00165 { 00166 //printf("----> addToDeclarationSection(%s)\n",mg->header().data()); 00167 mg->addToDeclarationSection(); 00168 } 00169 } 00170 } 00171 } 00172 00173 void NamespaceDef::insertMember(MemberDef *md) 00174 { 00175 if (md->isHidden()) return; 00176 MemberList *allMemberList = getMemberList(MemberList::allMembersList); 00177 if (allMemberList==0) 00178 { 00179 allMemberList = new MemberList(MemberList::allMembersList); 00180 m_memberLists.append(allMemberList); 00181 } 00182 allMemberList->append(md); 00183 //::addNamespaceMemberNameToIndex(md); 00184 //static bool sortBriefDocs=Config_getBool("SORT_BRIEF_DOCS"); 00185 switch(md->memberType()) 00186 { 00187 case MemberDef::Variable: 00188 addMemberToList(MemberList::decVarMembers,md); 00189 addMemberToList(MemberList::docVarMembers,md); 00190 break; 00191 case MemberDef::Function: 00192 addMemberToList(MemberList::decFuncMembers,md); 00193 addMemberToList(MemberList::docFuncMembers,md); 00194 break; 00195 case MemberDef::Typedef: 00196 addMemberToList(MemberList::decTypedefMembers,md); 00197 addMemberToList(MemberList::docTypedefMembers,md); 00198 break; 00199 case MemberDef::Enumeration: 00200 addMemberToList(MemberList::decEnumMembers,md); 00201 addMemberToList(MemberList::docEnumMembers,md); 00202 break; 00203 case MemberDef::EnumValue: 00204 break; 00205 case MemberDef::Prototype: 00206 addMemberToList(MemberList::decProtoMembers,md); 00207 addMemberToList(MemberList::docProtoMembers,md); 00208 break; 00209 case MemberDef::Define: 00210 addMemberToList(MemberList::decDefineMembers,md); 00211 addMemberToList(MemberList::docDefineMembers,md); 00212 break; 00213 default: 00214 err("NamespaceDef::insertMembers(): " 00215 "member `%s' with class scope `%s' inserted in namespace scope `%s'!\n", 00216 md->name().data(), 00217 md->getClassDef() ? md->getClassDef()->name().data() : "", 00218 name().data()); 00219 } 00220 } 00221 00222 void NamespaceDef::computeAnchors() 00223 { 00224 MemberList *allMemberList = getMemberList(MemberList::allMembersList); 00225 if (allMemberList) setAnchors(0,'a',allMemberList); 00226 } 00227 00228 void NamespaceDef::writeDetailedDocumentation(OutputList &ol) 00229 { 00230 if ((!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF")) || 00231 !documentation().isEmpty()) 00232 { 00233 ol.writeRuler(); 00234 ol.pushGeneratorState(); 00235 ol.disableAllBut(OutputGenerator::Html); 00236 //bool latexOn = ol.isEnabled(OutputGenerator::Latex); 00237 //if (latexOn) ol.disable(OutputGenerator::Latex); 00238 ol.writeAnchor(0,"_details"); 00239 //if (latexOn) ol.enable(OutputGenerator::Latex); 00240 ol.popGeneratorState(); 00241 ol.startGroupHeader(); 00242 ol.parseText(theTranslator->trDetailedDescription()); 00243 ol.endGroupHeader(); 00244 ol.startTextBlock(); 00245 if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF")) 00246 { 00247 ol.parseDoc(briefFile(),briefLine(),this,0,briefDescription(),FALSE,FALSE); 00248 } 00249 if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF") && 00250 !documentation().isEmpty()) 00251 { 00252 ol.pushGeneratorState(); 00253 ol.disable(OutputGenerator::Man); 00254 ol.newParagraph(); 00255 ol.enableAll(); 00256 ol.disableAllBut(OutputGenerator::Man); 00257 ol.writeString("\n\n"); 00258 ol.popGeneratorState(); 00259 } 00260 if (!documentation().isEmpty()) 00261 { 00262 ol.parseDoc(docFile(),docLine(),this,0,documentation()+"\n",TRUE,FALSE); 00263 //ol.newParagraph(); 00264 } 00265 ol.endTextBlock(); 00266 } 00267 } 00268 00269 void NamespaceDef::writeDocumentation(OutputList &ol) 00270 { 00271 bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN"); 00272 bool vhdlOpt = Config_getBool("OPTIMIZE_OUTPUT_VHDL"); 00273 00274 QCString pageTitle; 00275 if (Config_getBool("OPTIMIZE_OUTPUT_JAVA")) 00276 { 00277 pageTitle = theTranslator->trPackage(displayName()); 00278 } 00279 else if (fortranOpt) 00280 { 00281 pageTitle = theTranslator->trModuleReference(displayName()); 00282 } 00283 else 00284 { 00285 pageTitle = theTranslator->trNamespaceReference(displayName()); 00286 } 00287 startFile(ol,getOutputFileBase(),name(),pageTitle,HLI_NamespaceVisible,TRUE); 00288 if (getOuterScope()!=Doxygen::globalScope) 00289 { 00290 writeNavigationPath(ol); 00291 } 00292 ol.endQuickIndices(); 00293 ol.startContents(); 00294 startTitle(ol,getOutputFileBase()); 00295 ol.parseText(pageTitle); 00296 addGroupListToTitle(ol,this); 00297 endTitle(ol,getOutputFileBase(),displayName()); 00298 00299 if (Config_getBool("SEARCHENGINE")) 00300 { 00301 Doxygen::searchIndex->setCurrentDoc(pageTitle,getOutputFileBase()); 00302 Doxygen::searchIndex->addWord(localName(),TRUE); 00303 } 00304 00305 if (!Config_getString("GENERATE_TAGFILE").isEmpty()) 00306 { 00307 Doxygen::tagFile << " <compound kind=\"namespace\">" << endl; 00308 Doxygen::tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; 00309 Doxygen::tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl; 00310 } 00311 00312 ol.startTextBlock(); 00313 00314 if (Config_getBool("DETAILS_AT_TOP")) 00315 { 00316 writeDetailedDocumentation(ol); 00317 ol.newParagraph(); 00318 } 00319 else if (!briefDescription().isEmpty()) 00320 { 00321 ol.parseDoc(briefFile(),briefLine(),this,0,briefDescription(),TRUE,FALSE); 00322 ol.writeString(" \n"); 00323 ol.pushGeneratorState(); 00324 ol.disableAllBut(OutputGenerator::Html); 00325 ol.startTextLink(0,"_details"); 00326 ol.parseText(theTranslator->trMore()); 00327 ol.endTextLink(); 00328 ol.enableAll(); 00329 ol.disableAllBut(OutputGenerator::Man); 00330 ol.newParagraph(); 00331 ol.popGeneratorState(); 00332 } 00333 ol.disable(OutputGenerator::Man); 00334 ol.disable(OutputGenerator::RTF); 00335 ol.newParagraph(); 00336 ol.enable(OutputGenerator::Man); 00337 ol.enable(OutputGenerator::RTF); 00338 ol.writeSynopsis(); 00339 00340 ol.endTextBlock(); 00341 00342 ol.startMemberSections(); 00343 classSDict->writeDeclaration(ol,0,0,TRUE); 00344 00345 namespaceSDict->writeDeclaration(ol,TRUE); 00346 00347 /* write user defined member groups */ 00348 if (memberGroupSDict) 00349 { 00350 MemberGroupSDict::Iterator mgli(*memberGroupSDict); 00351 MemberGroup *mg; 00352 for (;(mg=mgli.current());++mgli) 00353 { 00354 if ((!mg->allMembersInSameSection() || !m_subGrouping) 00355 && mg->header()!="[NOHEADER]") 00356 { 00357 mg->writeDeclarations(ol,0,this,0,0); 00358 } 00359 } 00360 } 00361 00362 writeMemberDeclarations(ol,MemberList::decDefineMembers,theTranslator->trDefines()); 00363 writeMemberDeclarations(ol,MemberList::decProtoMembers,theTranslator->trFuncProtos()); 00364 writeMemberDeclarations(ol,MemberList::decTypedefMembers,theTranslator->trTypedefs()); 00365 writeMemberDeclarations(ol,MemberList::decEnumMembers,theTranslator->trEnumerations()); 00366 writeMemberDeclarations(ol,MemberList::decFuncMembers, 00367 fortranOpt ? theTranslator->trSubprograms() : 00368 vhdlOpt ? VhdlDocGen::trFunctionAndProc() : 00369 theTranslator->trFunctions()); 00370 writeMemberDeclarations(ol,MemberList::decVarMembers,theTranslator->trVariables()); 00371 ol.endMemberSections(); 00372 00373 if (!Config_getBool("DETAILS_AT_TOP")) 00374 { 00375 writeDetailedDocumentation(ol); 00376 } 00377 00378 writeMemberDocumentation(ol); 00379 00380 // write Author section (Man only) 00381 ol.pushGeneratorState(); 00382 ol.disableAllBut(OutputGenerator::Man); 00383 ol.startGroupHeader(); 00384 ol.parseText(theTranslator->trAuthor(TRUE,TRUE)); 00385 ol.endGroupHeader(); 00386 ol.parseText(theTranslator->trGeneratedAutomatically(Config_getString("PROJECT_NAME"))); 00387 00388 if (!Config_getString("GENERATE_TAGFILE").isEmpty()) 00389 { 00390 writeDocAnchorsToTagFile(); 00391 Doxygen::tagFile << " </compound>" << endl; 00392 } 00393 00394 ol.popGeneratorState(); 00395 endFile(ol); 00396 00397 if (Config_getBool("SEPARATE_MEMBER_PAGES")) 00398 { 00399 MemberList *allMemberList = getMemberList(MemberList::allMembersList); 00400 if (allMemberList) allMemberList->sort(); 00401 writeMemberPages(ol); 00402 } 00403 } 00404 00405 void NamespaceDef::writeMemberDocumentation(OutputList &ol) 00406 { 00407 bool fortranOpt=Config_getBool("OPTIMIZE_FOR_FORTRAN"); 00408 if (Config_getBool("SEPARATE_MEMBER_PAGES")) 00409 { 00410 ol.disable(OutputGenerator::Html); 00411 } 00412 00413 writeMemberDocumentation(ol,MemberList::docDefineMembers,theTranslator->trDefineDocumentation()); 00414 writeMemberDocumentation(ol,MemberList::docProtoMembers,theTranslator->trFunctionPrototypeDocumentation()); 00415 writeMemberDocumentation(ol,MemberList::docTypedefMembers,theTranslator->trTypedefDocumentation()); 00416 writeMemberDocumentation(ol,MemberList::docEnumMembers,theTranslator->trEnumerationTypeDocumentation()); 00417 writeMemberDocumentation(ol,MemberList::docFuncMembers,fortranOpt?theTranslator->trSubprogramDocumentation():theTranslator->trFunctionDocumentation()); 00418 writeMemberDocumentation(ol,MemberList::docVarMembers,theTranslator->trVariableDocumentation()); 00419 00420 if (Config_getBool("SEPARATE_MEMBER_PAGES")) 00421 { 00422 ol.enable(OutputGenerator::Html); 00423 } 00424 } 00425 00426 void NamespaceDef::writeMemberPages(OutputList &ol) 00427 { 00428 ol.pushGeneratorState(); 00429 ol.disableAllBut(OutputGenerator::Html); 00430 00431 QListIterator<MemberList> mli(m_memberLists); 00432 MemberList *ml; 00433 for (mli.toFirst();(ml=mli.current());++mli) 00434 { 00435 if (ml->listType()&MemberList::documentationLists) 00436 { 00437 ml->writeDocumentationPage(ol,name(),this); 00438 } 00439 } 00440 ol.popGeneratorState(); 00441 } 00442 00443 void NamespaceDef::writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const 00444 { 00445 static bool createSubDirs=Config_getBool("CREATE_SUBDIRS"); 00446 00447 ol.writeString(" <div class=\"navtab\">\n"); 00448 ol.writeString(" <table>\n"); 00449 00450 MemberList *allMemberList = getMemberList(MemberList::allMembersList); 00451 if (allMemberList) 00452 { 00453 MemberListIterator mli(*allMemberList); 00454 MemberDef *md; 00455 for (mli.toFirst();(md=mli.current());++mli) 00456 { 00457 if (md->getNamespaceDef()==this && md->isLinkable()) 00458 { 00459 ol.writeString(" <tr><td class=\"navtab\">"); 00460 if (md->isLinkableInProject()) 00461 { 00462 if (md==currentMd) // selected item => highlight 00463 { 00464 ol.writeString("<a class=\"qindexHL\" "); 00465 } 00466 else 00467 { 00468 ol.writeString("<a class=\"qindex\" "); 00469 } 00470 ol.writeString("href=\""); 00471 if (createSubDirs) ol.writeString("../../"); 00472 ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor()); 00473 ol.writeString("\">"); 00474 ol.writeString(md->localName()); 00475 ol.writeString("</a>"); 00476 } 00477 ol.writeString("</td></tr>\n"); 00478 } 00479 } 00480 } 00481 00482 ol.writeString(" </table>\n"); 00483 ol.writeString(" </div>\n"); 00484 } 00485 00486 int NamespaceDef::countMembers() 00487 { 00488 MemberList *allMemberList = getMemberList(MemberList::allMembersList); 00489 if (allMemberList) allMemberList->countDocMembers(); 00490 return (allMemberList ? allMemberList->numDocMembers() : 0)+classSDict->count(); 00491 } 00492 00493 void NamespaceDef::addUsingDirective(NamespaceDef *nd) 00494 { 00495 if (usingDirList==0) 00496 { 00497 usingDirList = new NamespaceSDict; 00498 } 00499 if (usingDirList->find(nd->qualifiedName())==0) 00500 { 00501 usingDirList->append(nd->qualifiedName(),nd); 00502 } 00503 //printf("%p: NamespaceDef::addUsingDirective: %s:%d\n",this,name().data(),usingDirList->count()); 00504 } 00505 00506 NamespaceSDict *NamespaceDef::getUsedNamespaces() const 00507 { 00508 //printf("%p: NamespaceDef::getUsedNamespace: %s:%d\n",this,name().data(),usingDirList?usingDirList->count():0); 00509 return usingDirList; 00510 } 00511 00512 void NamespaceDef::addUsingDeclaration(Definition *d) 00513 { 00514 if (usingDeclList==0) 00515 { 00516 usingDeclList = new SDict<Definition>(17); 00517 } 00518 if (usingDeclList->find(d->qualifiedName())==0) 00519 { 00520 usingDeclList->append(d->qualifiedName(),d); 00521 } 00522 } 00523 00524 QCString NamespaceDef::getOutputFileBase() const 00525 { 00526 if (isReference()) 00527 { 00528 return fileName; 00529 } 00530 else 00531 { 00532 return convertNameToFile(fileName); 00533 } 00534 } 00535 00536 Definition *NamespaceDef::findInnerCompound(const char *n) 00537 { 00538 if (n==0) return 0; 00539 Definition *d = m_innerCompounds->find(n); 00540 if (d==0) 00541 { 00542 if (usingDirList) 00543 { 00544 d = usingDirList->find(n); 00545 } 00546 if (d==0 && usingDeclList) 00547 { 00548 d = usingDeclList->find(n); 00549 } 00550 } 00551 return d; 00552 } 00553 00554 void NamespaceDef::addListReferences() 00555 { 00556 bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN"); 00557 { 00558 LockingPtr< QList<ListItemInfo> > xrefItems = xrefListItems(); 00559 addRefItem(xrefItems.pointer(), 00560 fortranOpt?theTranslator->trModule(TRUE,TRUE):theTranslator->trNamespace(TRUE,TRUE), 00561 getOutputFileBase(),displayName() 00562 ); 00563 } 00564 MemberGroupSDict::Iterator mgli(*memberGroupSDict); 00565 MemberGroup *mg; 00566 for (;(mg=mgli.current());++mgli) 00567 { 00568 mg->addListReferences(this); 00569 } 00570 QListIterator<MemberList> mli(m_memberLists); 00571 MemberList *ml; 00572 for (mli.toFirst();(ml=mli.current());++mli) 00573 { 00574 if (ml->listType()&MemberList::documentationLists) 00575 { 00576 ml->addListReferences(this); 00577 } 00578 } 00579 } 00580 00581 QCString NamespaceDef::displayName() const 00582 { 00583 QCString result=name(); 00584 if (Config_getBool("OPTIMIZE_OUTPUT_JAVA")) 00585 { 00586 result = substitute(result,"::","."); 00587 } 00588 return result; 00589 } 00590 00591 void NamespaceDef::combineUsingRelations() 00592 { 00593 if (visited) return; // already done 00594 visited=TRUE; 00595 if (usingDirList) 00596 { 00597 NamespaceSDict::Iterator nli(*usingDirList); 00598 NamespaceDef *nd; 00599 for (nli.toFirst();(nd=nli.current());++nli) 00600 { 00601 nd->combineUsingRelations(); 00602 } 00603 for (nli.toFirst();(nd=nli.current());++nli) 00604 { 00605 // add used namespaces of namespace nd to this namespace 00606 if (nd->getUsedNamespaces()) 00607 { 00608 NamespaceSDict::Iterator unli(*nd->getUsedNamespaces()); 00609 NamespaceDef *und; 00610 for (unli.toFirst();(und=unli.current());++unli) 00611 { 00612 //printf("Adding namespace %s to the using list of %s\n",und->qualifiedName().data(),qualifiedName().data()); 00613 addUsingDirective(und); 00614 } 00615 } 00616 // add used classes of namespace nd to this namespace 00617 if (nd->getUsedClasses()) 00618 { 00619 SDict<Definition>::Iterator cli(*nd->getUsedClasses()); 00620 Definition *ucd; 00621 for (cli.toFirst();(ucd=cli.current());++cli) 00622 { 00623 //printf("Adding class %s to the using list of %s\n",cd->qualifiedName().data(),qualifiedName().data()); 00624 addUsingDeclaration(ucd); 00625 } 00626 } 00627 } 00628 } 00629 } 00630 00631 void NamespaceSDict::writeDeclaration(OutputList &ol,bool localName) 00632 { 00633 if (count()==0) return; // no namespaces in the list 00634 00635 SDict<NamespaceDef>::Iterator ni(*this); 00636 NamespaceDef *nd; 00637 bool found=FALSE; 00638 for (ni.toFirst();(nd=ni.current()) && !found;++ni) 00639 { 00640 if (nd->isLinkable()) found=TRUE; 00641 } 00642 if (!found) return; // no linkable namespaces in the list 00643 00644 // write list of namespaces 00645 ol.startMemberHeader(); 00646 bool javaOpt = Config_getBool("OPTIMIZE_OUTPUT_JAVA"); 00647 bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN"); 00648 if (javaOpt) 00649 { 00650 ol.parseText(theTranslator->trPackages()); 00651 } 00652 else if (fortranOpt) 00653 { 00654 ol.parseText(theTranslator->trModules()); 00655 } 00656 else 00657 { 00658 ol.parseText(theTranslator->trNamespaces()); 00659 } 00660 ol.endMemberHeader(); 00661 ol.startMemberList(); 00662 for (ni.toFirst();(nd=ni.current());++ni) 00663 { 00664 if (nd->isLinkable()) 00665 { 00666 ol.startMemberItem(0); 00667 if (javaOpt) 00668 { 00669 ol.docify("package "); 00670 } 00671 else if (fortranOpt) 00672 { 00673 ol.docify("module "); 00674 } 00675 else 00676 { 00677 ol.docify("namespace "); 00678 } 00679 ol.insertMemberAlign(); 00680 QCString name; 00681 if (localName) 00682 { 00683 name = nd->localName(); 00684 } 00685 else 00686 { 00687 name = nd->displayName(); 00688 } 00689 ol.writeObjectLink(nd->getReference(),nd->getOutputFileBase(),0,name); 00690 if (!Config_getString("GENERATE_TAGFILE").isEmpty() && !nd->isReference()) 00691 { 00692 Doxygen::tagFile << " <namespace>" << convertToXML(nd->name()) << "</namespace>" << endl; 00693 } 00694 ol.endMemberItem(); 00695 if (!nd->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC")) 00696 { 00697 ol.startMemberDescription(); 00698 ol.parseDoc(nd->briefFile(),nd->briefLine(),nd,0,nd->briefDescription(),FALSE,FALSE); 00699 ol.endMemberDescription(); 00700 ol.newParagraph(); 00701 } 00702 } 00703 } 00704 ol.endMemberList(); 00705 } 00706 00707 MemberList *NamespaceDef::createMemberList(MemberList::ListType lt) 00708 { 00709 m_memberLists.setAutoDelete(TRUE); 00710 QListIterator<MemberList> mli(m_memberLists); 00711 MemberList *ml; 00712 for (mli.toFirst();(ml=mli.current());++mli) 00713 { 00714 if (ml->listType()==lt) 00715 { 00716 return ml; 00717 } 00718 } 00719 // not found, create a new member list 00720 ml = new MemberList(lt); 00721 m_memberLists.append(ml); 00722 return ml; 00723 } 00724 00725 void NamespaceDef::addMemberToList(MemberList::ListType lt,MemberDef *md) 00726 { 00727 static bool sortBriefDocs = Config_getBool("SORT_BRIEF_DOCS"); 00728 static bool sortMemberDocs = Config_getBool("SORT_MEMBER_DOCS"); 00729 MemberList *ml = createMemberList(lt); 00730 if (((ml->listType()&MemberList::declarationLists) && sortBriefDocs) || 00731 ((ml->listType()&MemberList::documentationLists) && sortMemberDocs) 00732 ) 00733 ml->inSort(md); 00734 else 00735 ml->append(md); 00736 if (ml->listType()&MemberList::declarationLists) md->setSectionList(this,ml); 00737 } 00738 00739 MemberList *NamespaceDef::getMemberList(MemberList::ListType lt) const 00740 { 00741 NamespaceDef *that = (NamespaceDef*)this; 00742 MemberList *ml = that->m_memberLists.first(); 00743 while (ml) 00744 { 00745 if (ml->listType()==lt) 00746 { 00747 return ml; 00748 } 00749 ml = that->m_memberLists.next(); 00750 } 00751 return 0; 00752 } 00753 00754 void NamespaceDef::writeMemberDeclarations(OutputList &ol,MemberList::ListType lt,const QCString &title) 00755 { 00756 MemberList * ml = getMemberList(lt); 00757 if (ml) ml->writeDeclarations(ol,0,this,0,0,title,0); 00758 } 00759 00760 void NamespaceDef::writeMemberDocumentation(OutputList &ol,MemberList::ListType lt,const QCString &title) 00761 { 00762 MemberList * ml = getMemberList(lt); 00763 if (ml) ml->writeDocumentation(ol,name(),this,title); 00764 } 00765 00766 00767 bool NamespaceDef::isLinkableInProject() const 00768 { 00769 int i = name().findRev("::"); 00770 if (i==-1) i=0; else i+=2; 00771 static bool extractAnonNs = Config_getBool("EXTRACT_ANON_NSPACES"); 00772 if (extractAnonNs && name().mid(i,20)=="anonymous_namespace{") 00773 { 00774 return TRUE; 00775 } 00776 return !name().isEmpty() && name().at(i)!='@' && 00777 hasDocumentation() && !isReference() && !isHidden() && !isArtificial(); 00778 } 00779 00780 bool NamespaceDef::isLinkable() const 00781 { 00782 return isLinkableInProject() || isReference(); 00783 }