Skip to content

Commit 6675be2

Browse files
committed
Refactoring: replaced PageSDict by PageLinked*Map
1 parent da8c801 commit 6675be2

20 files changed

+225
-332
lines changed

src/context.cpp

Lines changed: 49 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5388,14 +5388,9 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private>
53885388
if (!cache.examples)
53895389
{
53905390
TemplateList *exampleList = TemplateList::alloc();
5391-
if (m_groupDef->getExamples())
5391+
for (const auto &ex : m_groupDef->getExamples())
53925392
{
5393-
PageSDict::Iterator eli(*m_groupDef->getExamples());
5394-
const PageDef *ex;
5395-
for (eli.toFirst();(ex=eli.current());++eli)
5396-
{
5397-
exampleList->append(PageContext::alloc(ex,FALSE,TRUE));
5398-
}
5393+
exampleList->append(PageContext::alloc(ex,FALSE,TRUE));
53995394
}
54005395
cache.examples.reset(exampleList);
54015396
}
@@ -5407,14 +5402,9 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private>
54075402
if (!cache.pages)
54085403
{
54095404
TemplateList *pageList = TemplateList::alloc();
5410-
if (m_groupDef->getExamples())
5405+
for (const auto &ex : m_groupDef->getPages())
54115406
{
5412-
PageSDict::Iterator eli(*m_groupDef->getPages());
5413-
const PageDef *ex;
5414-
for (eli.toFirst();(ex=eli.current());++eli)
5415-
{
5416-
pageList->append(PageContext::alloc(ex,FALSE,TRUE));
5417-
}
5407+
pageList->append(PageContext::alloc(ex,FALSE,TRUE));
54185408
}
54195409
cache.pages.reset(pageList);
54205410
}
@@ -6397,9 +6387,9 @@ class NestingNodeContext::Private
63976387
void addPages(ClassDefSet &visitedClasses)
63986388
{
63996389
const PageDef *pd = toPageDef(m_def);
6400-
if (pd && pd->getSubPages())
6390+
if (pd && !pd->getSubPages().empty())
64016391
{
6402-
m_children->addPages(*pd->getSubPages(),FALSE,visitedClasses);
6392+
m_children->addPages(pd->getSubPages(),FALSE,visitedClasses);
64036393
}
64046394
}
64056395
void addModules(ClassDefSet &visitedClasses)
@@ -6577,19 +6567,28 @@ class NestingContext::Private : public GenericNodeListContext
65776567
m_index++;
65786568
}
65796569
}
6580-
void addPages(const PageSDict &pages,bool rootOnly,ClassDefSet &visitedClasses)
6570+
void addPage(const PageDef *pd,bool rootOnly,ClassDefSet &visitedClasses)
65816571
{
6582-
SDict<PageDef>::Iterator pli(pages);
6583-
const PageDef *pd;
6584-
for (pli.toFirst();(pd=pli.current());++pli)
6572+
if (!rootOnly ||
6573+
pd->getOuterScope()==0 ||
6574+
pd->getOuterScope()->definitionType()!=Definition::TypePage)
65856575
{
6586-
if (!rootOnly ||
6587-
pd->getOuterScope()==0 ||
6588-
pd->getOuterScope()->definitionType()!=Definition::TypePage)
6589-
{
6590-
append(NestingNodeContext::alloc(m_parent,pd,m_index,m_level,FALSE,FALSE,FALSE,visitedClasses));
6591-
m_index++;
6592-
}
6576+
append(NestingNodeContext::alloc(m_parent,pd,m_index,m_level,FALSE,FALSE,FALSE,visitedClasses));
6577+
m_index++;
6578+
}
6579+
}
6580+
void addPages(const PageLinkedMap &pages,bool rootOnly,ClassDefSet &visitedClasses)
6581+
{
6582+
for (const auto &pd : pages)
6583+
{
6584+
addPage(pd.get(),rootOnly,visitedClasses);
6585+
}
6586+
}
6587+
void addPages(const PageLinkedRefMap &pages,bool rootOnly,ClassDefSet &visitedClasses)
6588+
{
6589+
for (const auto &pd : pages)
6590+
{
6591+
addPage(pd,rootOnly,visitedClasses);
65936592
}
65946593
}
65956594
void addModules(const GroupSDict &groups,ClassDefSet &visitedClasses)
@@ -6751,7 +6750,12 @@ void NestingContext::addFiles(const FileList &files,ClassDefSet &visitedClasses)
67516750
p->addFiles(files,visitedClasses);
67526751
}
67536752

6754-
void NestingContext::addPages(const PageSDict &pages,bool rootOnly,ClassDefSet &visitedClasses)
6753+
void NestingContext::addPages(const PageLinkedMap &pages,bool rootOnly,ClassDefSet &visitedClasses)
6754+
{
6755+
p->addPages(pages,rootOnly,visitedClasses);
6756+
}
6757+
6758+
void NestingContext::addPages(const PageLinkedRefMap &pages,bool rootOnly,ClassDefSet &visitedClasses)
67556759
{
67566760
p->addPages(pages,rootOnly,visitedClasses);
67576761
}
@@ -7331,15 +7335,12 @@ TemplateVariant FileTreeContext::get(const char *name) const
73317335
class PageTreeContext::Private
73327336
{
73337337
public:
7334-
Private(const PageSDict *pages)
7338+
Private(const PageLinkedMap &pages)
73357339
{
73367340
m_pageTree.reset(NestingContext::alloc(0,0));
73377341
ClassDefSet visitedClasses;
73387342
// Add pages
7339-
if (pages)
7340-
{
7341-
m_pageTree->addPages(*pages,TRUE,visitedClasses);
7342-
}
7343+
m_pageTree->addPages(pages,TRUE,visitedClasses);
73437344

73447345
//%% PageNodeList tree:
73457346
static bool init=FALSE;
@@ -7420,7 +7421,7 @@ class PageTreeContext::Private
74207421

74217422
PropertyMapper<PageTreeContext::Private> PageTreeContext::Private::s_inst;
74227423

7423-
PageTreeContext::PageTreeContext(const PageSDict *pages) : RefCountedContext("PageTreeContext")
7424+
PageTreeContext::PageTreeContext(const PageLinkedMap &pages) : RefCountedContext("PageTreeContext")
74247425
{
74257426
p = new Private(pages);
74267427
}
@@ -7441,24 +7442,22 @@ TemplateVariant PageTreeContext::get(const char *name) const
74417442
class PageListContext::Private : public GenericNodeListContext
74427443
{
74437444
public:
7444-
void addPages(const PageSDict &pages)
7445+
void addPages(const PageLinkedMap &pages)
74457446
{
7446-
PageSDict::Iterator pdi(pages);
7447-
const PageDef *pd=0;
7448-
for (pdi.toFirst();(pd=pdi.current());++pdi)
7447+
for (const auto &pd : pages)
74497448
{
74507449
if (!pd->getGroupDef() && !pd->isReference())
74517450
{
7452-
append(PageContext::alloc(pd,FALSE,FALSE));
7451+
append(PageContext::alloc(pd.get(),FALSE,FALSE));
74537452
}
74547453
}
74557454
}
74567455
};
74577456

7458-
PageListContext::PageListContext(const PageSDict *pages) : RefCountedContext("PageListContext")
7457+
PageListContext::PageListContext(const PageLinkedMap &pages) : RefCountedContext("PageListContext")
74597458
{
74607459
p = new Private;
7461-
if (pages) p->addPages(*pages);
7460+
p->addPages(pages);
74627461
}
74637462

74647463
PageListContext::~PageListContext()
@@ -7490,16 +7489,11 @@ class ExampleListContext::Private : public GenericNodeListContext
74907489
public:
74917490
Private()
74927491
{
7493-
if (Doxygen::exampleSDict)
7492+
for (const auto &pd : *Doxygen::exampleLinkedMap)
74947493
{
7495-
PageSDict::Iterator pdi(*Doxygen::exampleSDict);
7496-
const PageDef *pd=0;
7497-
for (pdi.toFirst();(pd=pdi.current());++pdi)
7494+
if (!pd->getGroupDef() && !pd->isReference())
74987495
{
7499-
if (!pd->getGroupDef() && !pd->isReference())
7500-
{
7501-
append(PageContext::alloc(pd,FALSE,TRUE));
7502-
}
7496+
append(PageContext::alloc(pd.get(),FALSE,TRUE));
75037497
}
75047498
}
75057499
}
@@ -7796,10 +7790,7 @@ class ExampleTreeContext::Private
77967790
m_exampleTree.reset(NestingContext::alloc(0,0));
77977791
ClassDefSet visitedClasses;
77987792
// Add pages
7799-
if (Doxygen::exampleSDict)
7800-
{
7801-
m_exampleTree->addPages(*Doxygen::exampleSDict,TRUE,visitedClasses);
7802-
}
7793+
m_exampleTree->addPages(*Doxygen::exampleLinkedMap,TRUE,visitedClasses);
78037794

78047795
static bool init=FALSE;
78057796
if (!init)
@@ -10141,8 +10132,8 @@ void generateOutputViaTemplate()
1014110132
SharedPtr<DirListContext> dirList (DirListContext::alloc());
1014210133
SharedPtr<FileListContext> fileList (FileListContext::alloc());
1014310134
SharedPtr<FileTreeContext> fileTree (FileTreeContext::alloc());
10144-
SharedPtr<PageTreeContext> pageTree (PageTreeContext::alloc(Doxygen::pageSDict));
10145-
SharedPtr<PageListContext> pageList (PageListContext::alloc(Doxygen::pageSDict));
10135+
SharedPtr<PageTreeContext> pageTree (PageTreeContext::alloc(*Doxygen::pageLinkedMap));
10136+
SharedPtr<PageListContext> pageList (PageListContext::alloc(*Doxygen::pageLinkedMap));
1014610137
SharedPtr<ExampleTreeContext> exampleTree (ExampleTreeContext::alloc());
1014710138
SharedPtr<ExampleListContext> exampleList (ExampleListContext::alloc());
1014810139
SharedPtr<ModuleTreeContext> moduleTree (ModuleTreeContext::alloc());
@@ -10191,15 +10182,15 @@ void generateOutputViaTemplate()
1019110182
//%% Page mainPage
1019210183
if (Doxygen::mainPage)
1019310184
{
10194-
SharedPtr<PageContext> mainPage(PageContext::alloc(Doxygen::mainPage,TRUE,FALSE));
10185+
SharedPtr<PageContext> mainPage(PageContext::alloc(Doxygen::mainPage.get(),TRUE,FALSE));
1019510186
ctx->set("mainPage",mainPage.get());
1019610187
}
1019710188
else
1019810189
{
1019910190
// TODO: for LaTeX output index should be main... => solve in template
10200-
Doxygen::mainPage = createPageDef("[generated]",1,"index","",theTranslator->trMainPage());
10191+
Doxygen::mainPage.reset(createPageDef("[generated]",1,"index","",theTranslator->trMainPage()));
1020110192
Doxygen::mainPage->setFileName("index");
10202-
SharedPtr<PageContext> mainPage(PageContext::alloc(Doxygen::mainPage,TRUE,FALSE));
10193+
SharedPtr<PageContext> mainPage(PageContext::alloc(Doxygen::mainPage.get(),TRUE,FALSE));
1020310194
ctx->set("mainPage",mainPage.get());
1020410195
}
1020510196
//%% GlobalsIndex globalsIndex:

src/context.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
class Definition;
2929
class PageDef;
30+
class PageLinkedMap;
31+
class PageLinkedRefMap;
3032
class GroupDef;
3133
class NamespaceDef;
3234
class NamespaceLinkedMap;
@@ -37,7 +39,6 @@ class FileNameLinkedMap;
3739
class ClassLinkedMap;
3840
class DirSDict;
3941
class DirDef;
40-
class PageSDict;
4142
class GroupSDict;
4243
class GroupDef;
4344
class GroupList;
@@ -543,13 +544,14 @@ class NestingContext : public RefCountedContext, public TemplateListIntf
543544

544545
void addNamespaces(const NamespaceLinkedMap &nsLinkedMap,bool rootOnly,bool addClasses,ClassDefSet &visitedClasses);
545546
void addNamespaces(const NamespaceLinkedRefMap &nsLinkedMap,bool rootOnly,bool addClasses,ClassDefSet &visitedClasses);
546-
void addClasses(const ClassLinkedRefMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses);
547547
void addClasses(const ClassLinkedMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses);
548+
void addClasses(const ClassLinkedRefMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses);
548549
void addDirs(const DirSDict &,ClassDefSet &visitedClasses);
549550
void addDirs(const DirList &,ClassDefSet &visitedClasses);
550551
void addFiles(const FileNameLinkedMap &,ClassDefSet &visitedClasses);
551552
void addFiles(const FileList &,ClassDefSet &visitedClasses);
552-
void addPages(const PageSDict &pages,bool rootOnly,ClassDefSet &visitedClasses);
553+
void addPages(const PageLinkedMap &pages,bool rootOnly,ClassDefSet &visitedClasses);
554+
void addPages(const PageLinkedRefMap &pages,bool rootOnly,ClassDefSet &visitedClasses);
553555
void addModules(const GroupSDict &modules,ClassDefSet &visitedClasses);
554556
void addModules(const GroupList &modules,ClassDefSet &visitedClasses);
555557
void addClassHierarchy(const ClassLinkedMap &clLinkedMap,ClassDefSet &visitedClasses);
@@ -687,7 +689,7 @@ class FileTreeContext : public RefCountedContext, public TemplateStructIntf
687689
class PageListContext : public RefCountedContext, public TemplateListIntf
688690
{
689691
public:
690-
static PageListContext *alloc(const PageSDict *pages) { return new PageListContext(pages); }
692+
static PageListContext *alloc(const PageLinkedMap &pages) { return new PageListContext(pages); }
691693

692694
// TemplateListIntf methods
693695
virtual uint count() const;
@@ -696,10 +698,10 @@ class PageListContext : public RefCountedContext, public TemplateListIntf
696698
virtual int addRef() { return RefCountedContext::addRef(); }
697699
virtual int release() { return RefCountedContext::release(); }
698700

699-
void addPages(const PageSDict &pages);
701+
void addPages(const PageLinkedMap &pages);
700702

701703
private:
702-
PageListContext(const PageSDict *pages);
704+
PageListContext(const PageLinkedMap &pages);
703705
~PageListContext();
704706
class Private;
705707
Private *p;
@@ -710,15 +712,15 @@ class PageListContext : public RefCountedContext, public TemplateListIntf
710712
class PageTreeContext : public RefCountedContext, public TemplateStructIntf
711713
{
712714
public:
713-
static PageTreeContext *alloc(const PageSDict *pages) { return new PageTreeContext(pages); }
715+
static PageTreeContext *alloc(const PageLinkedMap &pages) { return new PageTreeContext(pages); }
714716

715717
// TemplateStructIntf methods
716718
virtual TemplateVariant get(const char *name) const;
717719
virtual int addRef() { return RefCountedContext::addRef(); }
718720
virtual int release() { return RefCountedContext::release(); }
719721

720722
private:
721-
PageTreeContext(const PageSDict *pages);
723+
PageTreeContext(const PageLinkedMap &pages);
722724
~PageTreeContext();
723725
class Private;
724726
Private *p;

src/docbookgen.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,7 @@ DB_GEN_C2("IndexSections " << is)
595595
case isExampleDocumentation:
596596
{
597597
t << "</title>" << endl;
598-
PageSDict::Iterator pdi(*Doxygen::exampleSDict);
599-
PageDef *pd=pdi.toFirst();
600-
if (pd)
601-
{
602-
t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
603-
}
604-
for (++pdi;(pd=pdi.current());++pdi)
598+
for (const auto &pd : *Doxygen::exampleLinkedMap)
605599
{
606600
t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
607601
}
@@ -620,9 +614,7 @@ DB_GEN_C2("IndexSections " << is)
620614
void DocbookGenerator::writePageLink(const char *name, bool /*first*/)
621615
{
622616
DB_GEN_C
623-
PageSDict::Iterator pdi(*Doxygen::pageSDict);
624-
PageDef *pd = pdi.toFirst();
625-
for (pd = pdi.toFirst();(pd=pdi.current());++pdi)
617+
for (const auto &pd : *Doxygen::pageLinkedMap)
626618
{
627619
if (!pd->getGroupDef() && !pd->isReference() && pd->name() == stripPath(name))
628620
{

src/docparser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static bool findDocsForMemberOrCompound(const char *commandName,
693693
*pDef=gd;
694694
return TRUE;
695695
}
696-
pd = Doxygen::pageSDict->find(cmdArg);
696+
pd = Doxygen::pageLinkedMap->find(cmdArg);
697697
if (pd) // page
698698
{
699699
*pDoc=pd->documentation();
@@ -2427,7 +2427,7 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) :
24272427
PageDef *pd = 0;
24282428
if (sec->type()==SectionType::Page)
24292429
{
2430-
pd = Doxygen::pageSDict->find(target);
2430+
pd = Doxygen::pageLinkedMap->find(target);
24312431
}
24322432
m_text = sec->title();
24332433
if (m_text.isEmpty()) m_text = sec->label();

src/dotgroupcollaboration.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,10 @@ void DotGroupCollaboration::buildGraph(const GroupDef* gd)
139139
}
140140

141141
// Add pages
142-
if ( gd->getPages() && gd->getPages()->count() )
142+
for (const auto &def : gd->getPages())
143143
{
144-
PageSDict::Iterator defli(*gd->getPages());
145-
PageDef *def;
146-
for (;(def=defli.current());++defli)
147-
{
148-
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
149-
addCollaborationMember( def, tmp_url, DotGroupCollaboration::tpages );
150-
}
144+
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
145+
addCollaborationMember( def, tmp_url, DotGroupCollaboration::tpages );
151146
}
152147

153148
// Add directories

0 commit comments

Comments
 (0)