Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/namespacedef.cpp

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

Archive Download this file

Revision: 1322