From 963caeef1c24d66a51376f77d8692f1a3c5d4a62 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 19 Dec 2020 20:15:16 +0100 Subject: Refactoring: replace ClassSDict by ClassLinkedMap/ClassLinkedRefMap --- addon/doxyapp/doxyapp.cpp | 4 +- addon/doxyparse/doxyparse.cpp | 15 +- src/classdef.cpp | 130 ++++++-------- src/classdef.h | 9 +- src/classlist.cpp | 130 ++++++-------- src/classlist.h | 45 ++--- src/context.cpp | 234 +++++++++++-------------- src/context.h | 6 +- src/defgen.cpp | 8 +- src/dirdef.h | 1 - src/docbookgen.cpp | 17 +- src/docparser.cpp | 2 +- src/dotgfxhierarchytable.cpp | 16 +- src/dotgfxhierarchytable.h | 4 +- src/dotgroupcollaboration.cpp | 15 +- src/doxygen.cpp | 392 ++++++++++++++++++++---------------------- src/doxygen.h | 6 +- src/filedef.cpp | 101 +++++------ src/filedef.h | 5 +- src/fortrancode.l | 6 +- src/groupdef.cpp | 143 +++++++++------ src/groupdef.h | 4 +- src/index.cpp | 209 ++++++++++------------ src/latexgen.cpp | 54 ++---- src/linkedmap.h | 61 ++++--- src/namespacedef.cpp | 133 ++++++-------- src/namespacedef.h | 10 +- src/perlmodgen.cpp | 24 +-- src/rtfgen.cpp | 64 ++----- src/searchindex.cpp | 16 +- src/sqlite3gen.cpp | 23 +-- src/util.cpp | 23 +-- src/util.h | 1 - src/vhdldocgen.cpp | 57 +++--- src/vhdldocgen.h | 4 +- src/xmlgen.cpp | 53 ++---- 36 files changed, 882 insertions(+), 1143 deletions(-) diff --git a/addon/doxyapp/doxyapp.cpp b/addon/doxyapp/doxyapp.cpp index 3ec8fb2..2a788b2 100644 --- a/addon/doxyapp/doxyapp.cpp +++ b/addon/doxyapp/doxyapp.cpp @@ -185,8 +185,8 @@ static void lookupSymbol(Definition *d) case Definition::TypeNamespace: { NamespaceDef *nd = dynamic_cast(d); - printf("Kind: Namespace: contains %d classes and %d namespaces\n", - nd->getClassSDict() ? nd->getClassSDict()->count() : 0, + printf("Kind: Namespace: contains %zu classes and %d namespaces\n", + nd->getClasses().size(), nd->getNamespaceSDict() ? nd->getNamespaceSDict()->count() : 0); } break; diff --git a/addon/doxyparse/doxyparse.cpp b/addon/doxyparse/doxyparse.cpp index 4235bf3..b5fbcb3 100644 --- a/addon/doxyparse/doxyparse.cpp +++ b/addon/doxyparse/doxyparse.cpp @@ -413,16 +413,11 @@ static void listSymbols() { listMembers(ml); } - ClassSDict *classes = fd->getClassSDict(); - if (classes) { - ClassDefSet visitedClasses; - ClassSDict::Iterator cli(*classes); - const ClassDef *cd; - for (cli.toFirst(); (cd = cli.current()); ++cli) { - if (visitedClasses.find(cd)==visitedClasses.end()) { - classInformation(cd); - visitedClasses.insert(cd); - } + ClassDefSet visitedClasses; + for (const auto &cd : fd->getClasses()) { + if (visitedClasses.find(cd)==visitedClasses.end()) { + classInformation(cd); + visitedClasses.insert(cd); } } } diff --git a/src/classdef.cpp b/src/classdef.cpp index 9586731..f0d84ee 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -177,7 +177,7 @@ class ClassDefImpl : public DefinitionMixin virtual QCString getReference() const; virtual bool isReference() const; virtual bool isLocal() const; - virtual ClassSDict *getClassSDict() const; + virtual ClassLinkedRefMap getClasses() const; virtual bool hasDocumentation() const; virtual bool hasDetailedDescription() const; virtual QCString collaborationGraphFileName() const; @@ -237,11 +237,10 @@ class ClassDefImpl : public DefinitionMixin virtual bool isEmbeddedInOuterScope() const; virtual bool isSimple() const; virtual const ClassList *taggedInnerClasses() const; - virtual ClassDef *tagLessReference() const; + virtual const ClassDef *tagLessReference() const; virtual MemberDef *isSmartPointer() const; virtual bool isJavaEnum() const; virtual bool isGeneric() const; - virtual const ClassSDict *innerClasses() const; virtual QCString title() const; virtual QCString generatedFromFiles() const; virtual const FileList &usedFiles() const; @@ -283,7 +282,7 @@ class ClassDefImpl : public DefinitionMixin virtual void setCategoryOf(ClassDef *cd); virtual void setUsedOnly(bool b); virtual void addTaggedInnerClass(ClassDef *cd); - virtual void setTagLessReference(ClassDef *cd); + virtual void setTagLessReference(const ClassDef *cd); virtual void setName(const char *name); virtual void setMetaData(const char *md); virtual void findSectionsInDocumentation(); @@ -406,8 +405,8 @@ class ClassDefAliasImpl : public DefinitionAliasMixin { return getCdAlias()->isReference(); } virtual bool isLocal() const { return getCdAlias()->isLocal(); } - virtual ClassSDict *getClassSDict() const - { return getCdAlias()->getClassSDict(); } + virtual ClassLinkedRefMap getClasses() const + { return getCdAlias()->getClasses(); } virtual bool hasDocumentation() const { return getCdAlias()->hasDocumentation(); } virtual bool hasDetailedDescription() const @@ -521,7 +520,7 @@ class ClassDefAliasImpl : public DefinitionAliasMixin { return getCdAlias()->isSimple(); } virtual const ClassList *taggedInnerClasses() const { return getCdAlias()->taggedInnerClasses(); } - virtual ClassDef *tagLessReference() const + virtual const ClassDef *tagLessReference() const { return getCdAlias()->tagLessReference(); } virtual MemberDef *isSmartPointer() const { return getCdAlias()->isSmartPointer(); } @@ -529,8 +528,6 @@ class ClassDefAliasImpl : public DefinitionAliasMixin { return getCdAlias()->isJavaEnum(); } virtual bool isGeneric() const { return getCdAlias()->isGeneric(); } - virtual const ClassSDict *innerClasses() const - { return getCdAlias()->innerClasses(); } virtual QCString title() const { return getCdAlias()->title(); } virtual QCString generatedFromFiles() const @@ -657,7 +654,7 @@ class ClassDefImpl::IMPL /*! The inner classes contained in this class. Will be 0 if there are * no inner classes. */ - ClassSDict *innerClasses = 0; + ClassLinkedRefMap innerClasses; /* classes for the collaboration diagram */ UsesClassDict *usesImplClassDict = 0; @@ -728,7 +725,7 @@ class ClassDefImpl::IMPL MemberDef *arrowOperator = 0; ClassList *taggedInnerClasses = 0; - ClassDef *tagLessRef = 0; + const ClassDef *tagLessRef = 0; /** Does this class represent a Java style enum? */ bool isJavaEnum = false; @@ -761,7 +758,6 @@ void ClassDefImpl::IMPL::init(const char *defFileName, const char *name, usesIntfClassDict=0; constraintClassDict=0; memberGroupSDict = 0; - innerClasses = 0; subGrouping=Config_getBool(SUBGROUPING); templateInstances = 0; variableInstances = 0; @@ -810,7 +806,6 @@ ClassDefImpl::IMPL::~IMPL() delete constraintClassDict; delete incInfo; delete memberGroupSDict; - delete innerClasses; delete templateInstances; delete variableInstances; delete templBaseClassNames; @@ -2051,18 +2046,12 @@ void ClassDefImpl::writeMemberGroups(OutputList &ol,bool showInline) const void ClassDefImpl::writeNestedClasses(OutputList &ol,const QCString &title) const { // nested classes - if (m_impl->innerClasses) - { - m_impl->innerClasses->writeDeclaration(ol,0,title,TRUE); - } + m_impl->innerClasses.writeDeclaration(ol,0,title,TRUE); } void ClassDefImpl::writeInlineClasses(OutputList &ol) const { - if (m_impl->innerClasses) - { - m_impl->innerClasses->writeDocumentation(ol,this); - } + m_impl->innerClasses.writeDocumentation(ol,this); } void ClassDefImpl::startMemberDocumentation(OutputList &ol) const @@ -2133,8 +2122,7 @@ void ClassDefImpl::writeSummaryLinks(OutputList &ol) const for (eli.toFirst();(lde=eli.current());++eli) { if (lde->kind()==LayoutDocEntry::ClassNestedClasses && - m_impl->innerClasses && - m_impl->innerClasses->declVisible() + m_impl->innerClasses.declVisible() ) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; @@ -2236,20 +2224,15 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) { case LayoutDocEntry::ClassNestedClasses: { - if (m_impl->innerClasses) + for (const auto &innerCd : m_impl->innerClasses) { - ClassSDict::Iterator cli(*m_impl->innerClasses); - ClassDef *innerCd; - for (cli.toFirst();(innerCd=cli.current());++cli) + if (innerCd->isLinkableInProject() && innerCd->templateMaster()==0 && + protectionLevelVisible(innerCd->protection()) && + !innerCd->isEmbeddedInOuterScope() + ) { - if (innerCd->isLinkableInProject() && innerCd->templateMaster()==0 && - protectionLevelVisible(innerCd->protection()) && - !innerCd->isEmbeddedInOuterScope() - ) - { - tagFile << " compoundTypeString() << - "\">" << convertToXML(innerCd->name()) << "" << endl; - } + tagFile << " compoundTypeString() << + "\">" << convertToXML(innerCd->name()) << "" << endl; } } } @@ -2906,27 +2889,22 @@ void ClassDefImpl::writeDocumentationForInnerClasses(OutputList &ol) const { // write inner classes after the parent, so the tag files contain // the definition in proper order! - if (m_impl->innerClasses) + for (const auto &innerCd : m_impl->innerClasses) { - ClassSDict::Iterator cli(*m_impl->innerClasses); - ClassDef *innerCd; - for (cli.toFirst();(innerCd=cli.current());++cli) + ClassDefMutable *innerCdm = toClassDefMutable(innerCd); + if (innerCdm) { - ClassDefMutable *innerCdm = toClassDefMutable(innerCd); - if (innerCdm) + if ( + innerCd->isLinkableInProject() && innerCd->templateMaster()==0 && + protectionLevelVisible(innerCd->protection()) && + !innerCd->isEmbeddedInOuterScope() + ) { - if ( - innerCd->isLinkableInProject() && innerCd->templateMaster()==0 && - protectionLevelVisible(innerCd->protection()) && - !innerCd->isEmbeddedInOuterScope() - ) - { - msg("Generating docs for nested compound %s...\n",qPrint(innerCd->name())); - innerCdm->writeDocumentation(ol); - innerCdm->writeMemberList(ol); - } - innerCdm->writeDocumentationForInnerClasses(ol); + msg("Generating docs for nested compound %s...\n",qPrint(innerCd->name())); + innerCdm->writeDocumentation(ol); + innerCdm->writeMemberList(ol); } + innerCdm->writeDocumentationForInnerClasses(ol); } } } @@ -3251,10 +3229,17 @@ void ClassDefImpl::addTypeConstraint(const QCString &typeConstraint,const QCStri ClassDefMutable *cd = resolver.resolveClassMutable(this,typeConstraint); if (cd==0 && !hideUndocRelation) { - cd = new ClassDefImpl(getDefFileName(),getDefLine(),getDefColumn(),typeConstraint,ClassDef::Class); + cd = toClassDefMutable( + Doxygen::hiddenClassLinkedMap->add(typeConstraint, + std::unique_ptr( + new ClassDefImpl( + getDefFileName(),getDefLine(), + getDefColumn(), + typeConstraint, + ClassDef::Class)))); + cd->setUsedOnly(TRUE); cd->setLanguage(getLanguage()); - Doxygen::hiddenClasses->append(typeConstraint,cd); //printf("Adding undocumented constraint '%s' to class %s on type %s\n", // typeConstraint.data(),name().data(),type.data()); } @@ -4046,23 +4031,13 @@ void ClassDefImpl::addInnerCompound(const Definition *d) if (d->definitionType()==Definition::TypeClass) // only classes can be // nested in classes. { - if (m_impl->innerClasses==0) - { - m_impl->innerClasses = new ClassSDict(17); - } - m_impl->innerClasses->inSort(d->localName(),toClassDef(d)); + m_impl->innerClasses.add(d->localName(),toClassDef(d)); } } const Definition *ClassDefImpl::findInnerCompound(const char *name) const { - const Definition *result=0; - if (name==0) return 0; - if (m_impl->innerClasses) - { - result = m_impl->innerClasses->find(name); - } - return result; + return m_impl->innerClasses.find(name); } ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName, @@ -4354,10 +4329,14 @@ void ClassDefImpl::sortMemberLists() { if (ml->needsSorting()) { ml->sort(); ml->setNeedsSorting(FALSE); } } - if (m_impl->innerClasses) - { - m_impl->innerClasses->sort(); - } + std::sort(m_impl->innerClasses.begin(), + m_impl->innerClasses.end(), + [](const auto &c1,const auto &c2) + { + return Config_getBool(SORT_BY_SCOPE_NAME) ? + qstricmp(c1->name(), c2->name() )<0 : + qstricmp(c1->className(), c2->className())<0 ; + }); } int ClassDefImpl::countMemberDeclarations(MemberListType lt,const ClassDef *inheritedFrom, @@ -4728,7 +4707,7 @@ bool ClassDefImpl::isLocal() const return m_impl->isLocal; } -ClassSDict *ClassDefImpl::getClassSDict() const +ClassLinkedRefMap ClassDefImpl::getClasses() const { return m_impl->innerClasses; } @@ -5037,12 +5016,12 @@ void ClassDefImpl::addTaggedInnerClass(ClassDef *cd) m_impl->taggedInnerClasses->append(cd); } -ClassDef *ClassDefImpl::tagLessReference() const +const ClassDef *ClassDefImpl::tagLessReference() const { return m_impl->tagLessRef; } -void ClassDefImpl::setTagLessReference(ClassDef *cd) +void ClassDefImpl::setTagLessReference(const ClassDef *cd) { m_impl->tagLessRef = cd; } @@ -5081,11 +5060,6 @@ bool ClassDefImpl::isExtension() const return b; } -const ClassSDict *ClassDefImpl::innerClasses() const -{ - return m_impl->innerClasses; -} - const FileList &ClassDefImpl::usedFiles() const { return m_impl->files; diff --git a/src/classdef.h b/src/classdef.h index 54664e5..9cd0426 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -35,7 +35,7 @@ class MemberDefMutable; class MemberList; class MemberDict; class ClassList; -class ClassSDict; +class ClassLinkedRefMap; class OutputList; class FileDef; class FileList; @@ -133,7 +133,7 @@ class ClassDef : public Definition virtual bool isLocal() const = 0; /** returns the classes nested into this class */ - virtual ClassSDict *getClassSDict() const = 0; + virtual ClassLinkedRefMap getClasses() const = 0; /** returns TRUE if this class has documentation */ virtual bool hasDocumentation() const = 0; @@ -335,14 +335,13 @@ class ClassDef : public Definition virtual bool isSimple() const = 0; virtual const ClassList *taggedInnerClasses() const = 0; - virtual ClassDef *tagLessReference() const = 0; + virtual const ClassDef *tagLessReference() const = 0; virtual MemberDef *isSmartPointer() const = 0; virtual bool isJavaEnum() const = 0; virtual bool isGeneric() const = 0; - virtual const ClassSDict *innerClasses() const = 0; virtual QCString title() const = 0; virtual QCString generatedFromFiles() const = 0; @@ -401,7 +400,7 @@ class ClassDefMutable : public DefinitionMutable, public ClassDef virtual void setTypeConstraints(const ArgumentList &al) = 0; virtual void setCategoryOf(ClassDef *cd) = 0; virtual void setUsedOnly(bool b) = 0; - virtual void setTagLessReference(ClassDef *cd) = 0; + virtual void setTagLessReference(const ClassDef *cd) = 0; virtual void setName(const char *name) = 0; virtual void setMetaData(const char *md) = 0; diff --git a/src/classlist.cpp b/src/classlist.cpp index d0f37ce..2998ac4 100644 --- a/src/classlist.cpp +++ b/src/classlist.cpp @@ -52,72 +52,59 @@ int ClassList::compareValues(const ClassDef *item1, const ClassDef *item2) const return compItems(item1,item2); } -int ClassSDict::compareValues(const ClassDef *item1, const ClassDef *item2) const -{ - return compItems(item1,item2); -} - ClassListIterator::ClassListIterator(const ClassList &cllist) : QListIterator(cllist) { } -bool ClassSDict::declVisible(const ClassDef::CompoundType *filter) const +//------------------------------------------- + +bool ClassLinkedRefMap::declVisible(const ClassDef::CompoundType *filter) const { - static bool hideUndocClasses = Config_getBool(HIDE_UNDOC_CLASSES); - static bool extractLocalClasses = Config_getBool(EXTRACT_LOCAL_CLASSES); - if (count()>0) + bool hideUndocClasses = Config_getBool(HIDE_UNDOC_CLASSES); + bool extractLocalClasses = Config_getBool(EXTRACT_LOCAL_CLASSES); + for (const auto &cd : *this) { - ClassSDict::Iterator sdi(*this); - ClassDef *cd=0; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (!cd->isAnonymous() && + (filter==0 || *filter==cd->compoundType()) + ) { - if (!cd->isAnonymous() && - (filter==0 || *filter==cd->compoundType()) + bool isLink = cd->isLinkable(); + if (isLink || + (!hideUndocClasses && + (!cd->isLocal() || extractLocalClasses) + ) ) { - bool isLink = cd->isLinkable(); - if (isLink || - (!hideUndocClasses && - (!cd->isLocal() || extractLocalClasses) - ) - ) - { - return TRUE; - } + return true; } } } - return FALSE; + return false; } -void ClassSDict::writeDeclaration(OutputList &ol,const ClassDef::CompoundType *filter, - const char *header,bool localNames) const +void ClassLinkedRefMap::writeDeclaration(OutputList &ol,const ClassDef::CompoundType *filter, + const char *header,bool localNames) const { static bool extractPrivate = Config_getBool(EXTRACT_PRIVATE); - if (count()>0) + bool found=FALSE; + for (const auto &cd : *this) { - ClassSDict::Iterator sdi(*this); - ClassDef *cd=0; - bool found=FALSE; - for (sdi.toFirst();(cd=sdi.current());++sdi) + //printf(" ClassLinkedRefMap::writeDeclaration for %s\n",cd->name().data()); + if (!cd->isAnonymous() && + !cd->isExtension() && + (cd->protection()!=Private || extractPrivate) && + (filter==0 || *filter==cd->compoundType()) + ) { - //printf(" ClassSDict::writeDeclaration for %s\n",cd->name().data()); - if (!cd->isAnonymous() && - !cd->isExtension() && - (cd->protection()!=Private || extractPrivate) && - (filter==0 || *filter==cd->compoundType()) - ) - { - //printf("writeDeclarationLink()\n"); - cd->writeDeclarationLink(ol,found,header,localNames); - } + //printf("writeDeclarationLink()\n"); + cd->writeDeclarationLink(ol,found,header,localNames); } - if (found) ol.endMemberList(); } + if (found) ol.endMemberList(); } -void ClassSDict::writeDocumentation(OutputList &ol,const Definition * container) const +void ClassLinkedRefMap::writeDocumentation(OutputList &ol,const Definition * container) const { static bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); @@ -125,40 +112,35 @@ void ClassSDict::writeDocumentation(OutputList &ol,const Definition * container) static bool inlineSimpleClasses = Config_getBool(INLINE_SIMPLE_STRUCTS); if (!inlineGroupedClasses && !inlineSimpleClasses) return; - if (count()>0) - { - bool found=FALSE; + bool found=FALSE; - ClassSDict::Iterator sdi(*this); - ClassDef *cd=0; - for (sdi.toFirst();(cd=sdi.current());++sdi) + for (const auto &cd : *this) + { + //printf("%s:writeDocumentation() %p linkable=%d embedded=%d container=%p partOfGroups=%d\n", + // cd->name().data(),cd->getOuterScope(),cd->isLinkableInProject(),cd->isEmbeddedInOuterScope(), + // container,cd->partOfGroups() ? cd->partOfGroups()->count() : 0); + + if (!cd->isAnonymous() && + cd->isLinkableInProject() && + cd->isEmbeddedInOuterScope() && + !cd->isAlias() && + (container==0 || cd->partOfGroups()==0) // if container==0 -> show as part of the group docs, otherwise only show if not part of a group + ) { - //printf("%s:writeDocumentation() %p linkable=%d embedded=%d container=%p partOfGroups=%d\n", - // cd->name().data(),cd->getOuterScope(),cd->isLinkableInProject(),cd->isEmbeddedInOuterScope(), - // container,cd->partOfGroups() ? cd->partOfGroups()->count() : 0); - - if (!cd->isAnonymous() && - cd->isLinkableInProject() && - cd->isEmbeddedInOuterScope() && - !cd->isAlias() && - (container==0 || cd->partOfGroups()==0) // if container==0 -> show as part of the group docs, otherwise only show if not part of a group - ) + //printf(" showing class %s\n",cd->name().data()); + if (!found) + { + ol.writeRuler(); + ol.startGroupHeader(); + ol.parseText(fortranOpt?theTranslator->trTypeDocumentation(): + theTranslator->trClassDocumentation()); + ol.endGroupHeader(); + found=TRUE; + } + ClassDefMutable *cdm = toClassDefMutable(cd); + if (cdm) { - //printf(" showing class %s\n",cd->name().data()); - if (!found) - { - ol.writeRuler(); - ol.startGroupHeader(); - ol.parseText(fortranOpt?theTranslator->trTypeDocumentation(): - theTranslator->trClassDocumentation()); - ol.endGroupHeader(); - found=TRUE; - } - ClassDefMutable *cdm = toClassDefMutable(cd); - if (cdm) - { - cdm->writeInlineDocumentation(ol); - } + cdm->writeInlineDocumentation(ol); } } } diff --git a/src/classlist.h b/src/classlist.h index 6e4281f..9ff53db 100644 --- a/src/classlist.h +++ b/src/classlist.h @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -21,6 +21,7 @@ #include #include +#include "linkedmap.h" #include "classdef.h" #include "sortdict.h" @@ -44,28 +45,6 @@ class ClassListIterator : public QListIterator ClassListIterator(const ClassList &list); }; -/** An unsorted dictionary of ClassDef objects. */ -class ClassDict : public QDict -{ - public: - ClassDict(uint size) : QDict(size) {} - ~ClassDict() {} -}; - -/** A sorted dictionary of ClassDef objects. */ -class ClassSDict : public SDict -{ - public: - ClassSDict(uint size=17) : SDict(size) {} - ~ClassSDict() {} - void writeDeclaration(OutputList &ol,const ClassDef::CompoundType *filter=0, - const char *header=0,bool localNames=FALSE) const; - void writeDocumentation(OutputList &ol,const Definition *container=0) const; - bool declVisible(const ClassDef::CompoundType *filter=0) const; - private: - int compareValues(const ClassDef *item1,const ClassDef *item2) const; -}; - class GenericsCollection : public QIntDict { public: @@ -73,7 +52,7 @@ class GenericsCollection : public QIntDict ~GenericsCollection() {} }; -class GenericsSDict +class GenericsSDict { public: GenericsSDict() : m_dict(17) { m_dict.setAutoDelete(TRUE); } @@ -84,4 +63,18 @@ class GenericsSDict SDict m_dict; }; +class ClassLinkedMap : public LinkedMap +{ +}; + +class ClassLinkedRefMap : public LinkedRefMap +{ + public: + bool declVisible(const ClassDef::CompoundType *filter=0) const; + void writeDeclaration(OutputList &ol,const ClassDef::CompoundType *filter,const char *header,bool localNames) const; + void writeDocumentation(OutputList &ol,const Definition * container=0) const; +}; + + + #endif diff --git a/src/context.cpp b/src/context.cpp index 074e6ec..213e068 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -2317,16 +2317,11 @@ class ClassContext::Private : public DefinitionContext if (!cache.classes) { TemplateList *classList = TemplateList::alloc(); - if (m_classDef->getClassSDict()) + for (const auto &cd : m_classDef->getClasses()) { - ClassSDict::Iterator sdi(*m_classDef->getClassSDict()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (cd->visibleInParentsDeclList()) { - if (cd->visibleInParentsDeclList()) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.classes.reset(classList); @@ -2339,20 +2334,15 @@ class ClassContext::Private : public DefinitionContext if (!cache.innerClasses) { TemplateList *classList = TemplateList::alloc(); - if (m_classDef->getClassSDict()) + for (const auto &cd : m_classDef->getClasses()) { - ClassSDict::Iterator sdi(*m_classDef->getClassSDict()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (!cd->isAnonymous() && + cd->isLinkableInProject() && + cd->isEmbeddedInOuterScope() && + cd->partOfGroups()==0 + ) { - if (!cd->isAnonymous() && - cd->isLinkableInProject() && - cd->isEmbeddedInOuterScope() && - cd->partOfGroups()==0 - ) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.innerClasses.reset(classList); @@ -2752,22 +2742,17 @@ class NamespaceContext::Private : public DefinitionContextgetClassSDict()) + for (const auto &cd : m_namespaceDef->getClasses()) { - ClassSDict::Iterator sdi(*m_namespaceDef->getClassSDict()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (sliceOpt && (cd->compoundType()==ClassDef::Struct || + cd->compoundType()==ClassDef::Interface || + cd->compoundType()==ClassDef::Exception)) { - if (sliceOpt && (cd->compoundType()==ClassDef::Struct || - cd->compoundType()==ClassDef::Interface || - cd->compoundType()==ClassDef::Exception)) - { - continue; // These types appear in their own sections. - } - if (cd->visibleInParentsDeclList()) - { - classList->append(ClassContext::alloc(cd)); - } + continue; // These types appear in their own sections. + } + if (cd->visibleInParentsDeclList()) + { + classList->append(ClassContext::alloc(cd)); } } cache.classes.reset(classList); @@ -2920,19 +2905,14 @@ class NamespaceContext::Private : public DefinitionContextgetClassSDict()) + for (const auto &cd : m_namespaceDef->getClasses()) { - ClassSDict::Iterator sdi(*m_namespaceDef->getClassSDict()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (!cd->isAnonymous() && + cd->isLinkableInProject() && + cd->isEmbeddedInOuterScope() && + cd->partOfGroups()==0) { - if (!cd->isAnonymous() && - cd->isLinkableInProject() && - cd->isEmbeddedInOuterScope() && - cd->partOfGroups()==0) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.inlineClasses.reset(classList); @@ -3217,16 +3197,11 @@ class FileContext::Private : public DefinitionContext if (!cache.classes) { TemplateList *classList = TemplateList::alloc(); - if (m_fileDef->getClassSDict()) + for (const auto &cd : m_fileDef->getClasses()) { - ClassSDict::Iterator sdi(*m_fileDef->getClassSDict()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (cd->visibleInParentsDeclList()) { - if (cd->visibleInParentsDeclList()) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.classes.reset(classList); @@ -3384,19 +3359,14 @@ class FileContext::Private : public DefinitionContext if (!cache.inlineClasses) { TemplateList *classList = TemplateList::alloc(); - if (m_fileDef->getClassSDict()) + for (const auto &cd : m_fileDef->getClasses()) { - ClassSDict::Iterator sdi(*m_fileDef->getClassSDict()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (!cd->isAnonymous() && + cd->isLinkableInProject() && + cd->isEmbeddedInOuterScope() && + cd->partOfGroups()==0) { - if (!cd->isAnonymous() && - cd->isLinkableInProject() && - cd->isEmbeddedInOuterScope() && - cd->partOfGroups()==0) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.inlineClasses.reset(classList); @@ -5509,16 +5479,11 @@ class ModuleContext::Private : public DefinitionContext if (!cache.classes) { TemplateList *classList = TemplateList::alloc(); - if (m_groupDef->getClasses()) + for (const auto &cd : m_groupDef->getClasses()) { - ClassSDict::Iterator sdi(*m_groupDef->getClasses()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (cd->visibleInParentsDeclList()) { - if (cd->visibleInParentsDeclList()) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.classes.reset(classList); @@ -5725,19 +5690,14 @@ class ModuleContext::Private : public DefinitionContext if (!cache.inlineClasses) { TemplateList *classList = TemplateList::alloc(); - if (m_groupDef->getClasses()) + for (const auto &cd : m_groupDef->getClasses()) { - ClassSDict::Iterator sdi(*m_groupDef->getClasses()); - const ClassDef *cd; - for (sdi.toFirst();(cd=sdi.current());++sdi) + if (!cd->isAnonymous() && + cd->isLinkableInProject() && + cd->isEmbeddedInOuterScope() && + cd->partOfGroups()==0) { - if (!cd->isAnonymous() && - cd->isLinkableInProject() && - cd->isEmbeddedInOuterScope() && - cd->partOfGroups()==0) - { - classList->append(ClassContext::alloc(cd)); - } + classList->append(ClassContext::alloc(cd)); } } cache.inlineClasses.reset(classList); @@ -5824,11 +5784,9 @@ TemplateVariant ModuleContext::get(const char *n) const class ClassListContext::Private : public GenericNodeListContext { public: - void addClasses(const ClassSDict &classSDict) + void addClasses(const ClassLinkedMap &classLinkedMap) { - ClassSDict::Iterator cli(classSDict); - const ClassDef *cd; - for (cli.toFirst() ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : classLinkedMap) { if (cd->getLanguage()==SrcLangExt_VHDL && ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || @@ -5840,7 +5798,7 @@ class ClassListContext::Private : public GenericNodeListContext if (cd->isLinkableInProject() && cd->templateMaster()==0 && !cd->isHidden() && !cd->isEmbeddedInOuterScope()) { - append(ClassContext::alloc(cd)); + append(ClassContext::alloc(cd.get())); } } } @@ -5849,8 +5807,8 @@ class ClassListContext::Private : public GenericNodeListContext ClassListContext::ClassListContext() : RefCountedContext("ClassListContext") { p = new Private; - p->addClasses(*Doxygen::classSDict); - p->addClasses(*Doxygen::hiddenClasses); + p->addClasses(*Doxygen::classLinkedMap); + p->addClasses(*Doxygen::hiddenClassLinkedMap); } ClassListContext::~ClassListContext() @@ -5903,11 +5861,9 @@ class ClassIndexContext::Private if (!m_cache.classes) { TemplateList *classList = TemplateList::alloc(); - if (Doxygen::classSDict) + if (Doxygen::classLinkedMap) { - ClassSDict::Iterator cli(*Doxygen::classSDict); - const ClassDef *cd; - for (cli.toFirst() ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->getLanguage()==SrcLangExt_VHDL && ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || @@ -5918,7 +5874,7 @@ class ClassIndexContext::Private } if (cd->isLinkableInProject() && cd->templateMaster()==0) { - classList->append(ClassContext::alloc(cd)); + classList->append(ClassContext::alloc(cd.get())); } } } @@ -6070,8 +6026,8 @@ class ClassHierarchyContext::Private { m_classTree.reset(NestingContext::alloc(0,0)); ClassDefSet visitedClasses; - m_classTree->addClassHierarchy(*Doxygen::classSDict,visitedClasses); - m_classTree->addClassHierarchy(*Doxygen::hiddenClasses,visitedClasses); + m_classTree->addClassHierarchy(*Doxygen::classLinkedMap,visitedClasses); + m_classTree->addClassHierarchy(*Doxygen::hiddenClassLinkedMap,visitedClasses); //%% ClassInheritance tree static bool init=FALSE; if (!init) @@ -6438,9 +6394,9 @@ class NestingNodeContext::Private } else { - if (cd && cd->getClassSDict()) + if (cd) { - m_children->addClasses(*cd->getClassSDict(),FALSE,visitedClasses); + m_children->addClasses(cd->getClasses(),FALSE,visitedClasses); } } } @@ -6451,9 +6407,9 @@ class NestingNodeContext::Private { m_children->addNamespaces(*nd->getNamespaceSDict(),FALSE,addClasses,visitedClasses); } - if (addClasses && nd && nd->getClassSDict()) + if (addClasses && nd) { - m_children->addClasses(*nd->getClassSDict(),FALSE,visitedClasses); + m_children->addClasses(nd->getClasses(),FALSE,visitedClasses); } } void addDirFiles(ClassDefSet &visitedClasses) @@ -6559,35 +6515,44 @@ class NestingContext::Private : public GenericNodeListContext } } } - void addClasses(const ClassSDict &clDict,bool rootOnly,ClassDefSet &visitedClasses) + void addClass(const ClassDef *cd,bool rootOnly,ClassDefSet &visitedClasses) { - ClassSDict::Iterator cli(clDict); - const ClassDef *cd; - for (;(cd=cli.current());++cli) + if (cd->getLanguage()==SrcLangExt_VHDL) { - if (cd->getLanguage()==SrcLangExt_VHDL) + if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || + (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS + )// no architecture { - if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || - (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS - )// no architecture - { - continue; - } + return; } - if (!rootOnly || - cd->getOuterScope()==0 || - cd->getOuterScope()==Doxygen::globalScope - ) + } + if (!rootOnly || + cd->getOuterScope()==0 || + cd->getOuterScope()==Doxygen::globalScope + ) + { + if (classVisibleInIndex(cd) && cd->templateMaster()==0) { - if (classVisibleInIndex(cd) && cd->templateMaster()==0) - { - NestingNodeContext *nnc = NestingNodeContext::alloc(m_parent,cd,m_index,m_level,TRUE,FALSE,FALSE,visitedClasses); - append(nnc); - m_index++; - } + NestingNodeContext *nnc = NestingNodeContext::alloc(m_parent,cd,m_index,m_level,TRUE,FALSE,FALSE,visitedClasses); + append(nnc); + m_index++; } } } + void addClasses(const ClassLinkedRefMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses) + { + for (const auto &cd : clLinkedMap) + { + addClass(cd,rootOnly,visitedClasses); + } + } + void addClasses(const ClassLinkedMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses) + { + for (const auto &cd : clLinkedMap) + { + addClass(cd.get(),rootOnly,visitedClasses); + } + } void addDirs(const DirSDict &dirDict,ClassDefSet &visitedClasses) { SDict::Iterator dli(dirDict); @@ -6705,11 +6670,9 @@ class NestingContext::Private : public GenericNodeListContext } } } - void addClassHierarchy(const ClassSDict &classSDict,ClassDefSet &visitedClasses) + void addClassHierarchy(const ClassLinkedMap &classLinkedMap,ClassDefSet &visitedClasses) { - ClassSDict::Iterator cli(classSDict); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : classLinkedMap) { bool b; if (cd->getLanguage()==SrcLangExt_VHDL) @@ -6729,7 +6692,7 @@ class NestingContext::Private : public GenericNodeListContext if (cd->isVisibleInHierarchy()) // should it be visible { // new root level class - NestingNodeContext *nnc = NestingNodeContext::alloc(m_parent,cd,m_index,m_level,TRUE,TRUE,FALSE,visitedClasses); + NestingNodeContext *nnc = NestingNodeContext::alloc(m_parent,cd.get(),m_index,m_level,TRUE,TRUE,FALSE,visitedClasses); append(nnc); m_index++; } @@ -6769,9 +6732,14 @@ TemplateListIntf::ConstIterator *NestingContext::createIterator() const return p->createIterator(); } -void NestingContext::addClasses(const ClassSDict &clDict,bool rootOnly,ClassDefSet &visitedClasses) +void NestingContext::addClasses(const ClassLinkedRefMap &clLinkedRefMap,bool rootOnly,ClassDefSet &visitedClasses) +{ + p->addClasses(clLinkedRefMap,rootOnly,visitedClasses); +} + +void NestingContext::addClasses(const ClassLinkedMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses) { - p->addClasses(clDict,rootOnly,visitedClasses); + p->addClasses(clLinkedMap,rootOnly,visitedClasses); } void NestingContext::addNamespaces(const NamespaceSDict &nsDict,bool rootOnly,bool addClasses,ClassDefSet &visitedClasses) @@ -6814,9 +6782,9 @@ void NestingContext::addModules(const GroupList &modules,ClassDefSet &visitedCla p->addModules(modules,visitedClasses); } -void NestingContext::addClassHierarchy(const ClassSDict &classSDict,ClassDefSet &visitedClasses) +void NestingContext::addClassHierarchy(const ClassLinkedMap &classLinkedMap,ClassDefSet &visitedClasses) { - p->addClassHierarchy(classSDict,visitedClasses); + p->addClassHierarchy(classLinkedMap,visitedClasses); } void NestingContext::addDerivedClasses(const BaseClassList &bcl,bool hideSuper,ClassDefSet &visitedClasses) @@ -6839,9 +6807,9 @@ class ClassTreeContext::Private { m_classTree->addNamespaces(*Doxygen::namespaceSDict,TRUE,TRUE,visitedClasses); } - if (Doxygen::classSDict) + if (Doxygen::classLinkedMap) { - m_classTree->addClasses(*Doxygen::classSDict,TRUE,visitedClasses); + m_classTree->addClasses(*Doxygen::classLinkedMap,TRUE,visitedClasses); } //%% Nesting tree static bool init=FALSE; diff --git a/src/context.h b/src/context.h index dca5d91..709fc83 100644 --- a/src/context.h +++ b/src/context.h @@ -31,6 +31,7 @@ class NamespaceSDict; class FileDef; class FileList; class FileNameLinkedMap; +class ClassLinkedMap; class DirSDict; class DirDef; class PageSDict; @@ -544,7 +545,8 @@ class NestingContext : public RefCountedContext, public TemplateListIntf virtual int release() { return RefCountedContext::release(); } void addNamespaces(const NamespaceSDict &nsDict,bool rootOnly,bool addClasses,ClassDefSet &visitedClasses); - void addClasses(const ClassSDict &clDict,bool rootOnly,ClassDefSet &visitedClasses); + void addClasses(const ClassLinkedRefMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses); + void addClasses(const ClassLinkedMap &clLinkedMap,bool rootOnly,ClassDefSet &visitedClasses); void addDirs(const DirSDict &,ClassDefSet &visitedClasses); void addDirs(const DirList &,ClassDefSet &visitedClasses); void addFiles(const FileNameLinkedMap &,ClassDefSet &visitedClasses); @@ -552,7 +554,7 @@ class NestingContext : public RefCountedContext, public TemplateListIntf void addPages(const PageSDict &pages,bool rootOnly,ClassDefSet &visitedClasses); void addModules(const GroupSDict &modules,ClassDefSet &visitedClasses); void addModules(const GroupList &modules,ClassDefSet &visitedClasses); - void addClassHierarchy(const ClassSDict &clDict,ClassDefSet &visitedClasses); + void addClassHierarchy(const ClassLinkedMap &clLinkedMap,ClassDefSet &visitedClasses); void addDerivedClasses(const BaseClassList &bcl,bool hideSuper,ClassDefSet &visitedClasses); private: diff --git a/src/defgen.cpp b/src/defgen.cpp index 82f7c26..a1cd28d 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -588,13 +588,11 @@ void generateDEF() FTextStream t(&f); t << "AutoGen Definitions dummy;" << endl; - if (Doxygen::classSDict->count()+Doxygen::inputNameLinkedMap->size()>0) + if (Doxygen::classLinkedMap->size()+Doxygen::inputNameLinkedMap->size()>0) { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - generateDEFForClass(cd,t); + generateDEFForClass(cd.get(),t); } for (const auto &fn : *Doxygen::inputNameLinkedMap) { diff --git a/src/dirdef.h b/src/dirdef.h index 32fa442..1057049 100644 --- a/src/dirdef.h +++ b/src/dirdef.h @@ -24,7 +24,6 @@ #include class FileList; -class ClassSDict; class QStrList; class FileDef; class OutputList; diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 385c2ef..d378703 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -557,22 +557,7 @@ DB_GEN_C2("IndexSections " << is) case isClassDocumentation: { t << "" << endl; - ClassSDict::Iterator cli(*Doxygen::classSDict); - const ClassDef *cd=0; - bool found=FALSE; - for (cli.toFirst();(cd=cli.current()) && !found;++cli) - { - if (cd->isLinkableInProject() && - cd->templateMaster()==0 && - !cd->isEmbeddedInOuterScope() && - !cd->isAlias() - ) - { - t << " getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; - found=TRUE; - } - } - for (;(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->isLinkableInProject() && cd->templateMaster()==0 && diff --git a/src/docparser.cpp b/src/docparser.cpp index 8621cc7..9a71cf7 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -770,7 +770,7 @@ static bool findDocsForMemberOrCompound(const char *commandName, //printf("Trying fullName='%s'\n",fullName.data()); // try class, namespace, group, page, file reference - cd = Doxygen::classSDict->find(fullName); + cd = Doxygen::classLinkedMap->find(fullName); if (cd) // class { *pDoc=cd->documentation(); diff --git a/src/dotgfxhierarchytable.cpp b/src/dotgfxhierarchytable.cpp index 77620ed..c535acf 100644 --- a/src/dotgfxhierarchytable.cpp +++ b/src/dotgfxhierarchytable.cpp @@ -171,11 +171,9 @@ void DotGfxHierarchyTable::addHierarchy(DotNode *n,const ClassDef *cd,ClassDefSe //printf("end addHierarchy\n"); } -void DotGfxHierarchyTable::addClassList(const ClassSDict *cl,ClassDefSet &visitedClasses) +void DotGfxHierarchyTable::addClassList(const ClassLinkedMap &cl,ClassDefSet &visitedClasses) { - ClassSDict::Iterator cli(*cl); - ClassDef *cd; - for (cli.toLast();(cd=cli.current());--cli) + for (const auto &cd : cl) { //printf("Trying %s subClasses=%d\n",cd->name().data(),cd->subClasses()->count()); if (cd->getLanguage()==SrcLangExt_VHDL && @@ -211,10 +209,10 @@ void DotGfxHierarchyTable::addClassList(const ClassSDict *cl,ClassDefSet &visite m_usedNodes.insert(std::make_pair(cd->name().str(),std::move(n))); m_rootNodes.push_back(root); - if (visitedClasses.find(cd)==visitedClasses.end() && !cd->subClasses().empty()) + if (visitedClasses.find(cd.get())==visitedClasses.end() && !cd->subClasses().empty()) { - addHierarchy(root,cd,visitedClasses); - visitedClasses.insert(cd); + addHierarchy(root,cd.get(),visitedClasses); + visitedClasses.insert(cd.get()); } } } @@ -227,8 +225,8 @@ DotGfxHierarchyTable::DotGfxHierarchyTable(const char *prefix,ClassDef::Compound // build a graph with each class as a node and the inheritance relations // as edges ClassDefSet visitedClasses; - addClassList(Doxygen::classSDict,visitedClasses); - addClassList(Doxygen::hiddenClasses,visitedClasses); + addClassList(*Doxygen::classLinkedMap,visitedClasses); + addClassList(*Doxygen::hiddenClassLinkedMap,visitedClasses); // m_usedNodes now contains all nodes in the graph // color the graph into a set of independent subgraphs diff --git a/src/dotgfxhierarchytable.h b/src/dotgfxhierarchytable.h index 0d884bd..089ecd2 100644 --- a/src/dotgfxhierarchytable.h +++ b/src/dotgfxhierarchytable.h @@ -27,6 +27,8 @@ #include "dotgraph.h" #include "dotnode.h" +class ClassLinkedMap; + /** Represents a graphical class hierarchy */ class DotGfxHierarchyTable : public DotGraph { @@ -44,7 +46,7 @@ class DotGfxHierarchyTable : public DotGraph private: void addHierarchy(DotNode *n,const ClassDef *cd,ClassDefSet &visited); - void addClassList(const ClassSDict *cl,ClassDefSet &visited); + void addClassList(const ClassLinkedMap &cl,ClassDefSet &visited); using DotNodeMap = std::unordered_multimap< std::string, std::unique_ptr >; int m_graphId; diff --git a/src/dotgroupcollaboration.cpp b/src/dotgroupcollaboration.cpp index db6bd23..ecc937f 100644 --- a/src/dotgroupcollaboration.cpp +++ b/src/dotgroupcollaboration.cpp @@ -109,19 +109,14 @@ void DotGroupCollaboration::buildGraph(const GroupDef* gd) addMemberList( gd->getMemberList(MemberListType_allMembersList) ); // Add classes - if ( gd->getClasses() && gd->getClasses()->count() ) + for (const auto &def : gd->getClasses()) { - ClassSDict::Iterator defli(*gd->getClasses()); - ClassDef *def; - for (;(def=defli.current());++defli) + tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension; + if (!def->anchor().isEmpty()) { - tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension; - if (!def->anchor().isEmpty()) - { - tmp_url+="#"+def->anchor(); - } - addCollaborationMember( def, tmp_url, DotGroupCollaboration::tclass ); + tmp_url+="#"+def->anchor(); } + addCollaborationMember( def, tmp_url, DotGroupCollaboration::tclass ); } // Add namespaces diff --git a/src/doxygen.cpp b/src/doxygen.cpp index e2ab088..4d2aa80 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -117,17 +117,17 @@ extern void initResources(); #endif // globally accessible variables -ClassSDict *Doxygen::classSDict = 0; -ClassSDict *Doxygen::hiddenClasses = 0; -NamespaceSDict *Doxygen::namespaceSDict = 0; -MemberNameLinkedMap *Doxygen::memberNameLinkedMap = 0; -MemberNameLinkedMap *Doxygen::functionNameLinkedMap = 0; -FileNameLinkedMap *Doxygen::inputNameLinkedMap = 0; -GroupSDict *Doxygen::groupSDict = 0; -PageSDict *Doxygen::pageSDict = 0; -PageSDict *Doxygen::exampleSDict = 0; -StringDict Doxygen::aliasDict(257); // aliases -StringSet Doxygen::inputPaths; +ClassLinkedMap *Doxygen::classLinkedMap = 0; +ClassLinkedMap *Doxygen::hiddenClassLinkedMap = 0; +NamespaceSDict *Doxygen::namespaceSDict = 0; +MemberNameLinkedMap *Doxygen::memberNameLinkedMap = 0; +MemberNameLinkedMap *Doxygen::functionNameLinkedMap = 0; +FileNameLinkedMap *Doxygen::inputNameLinkedMap = 0; +GroupSDict *Doxygen::groupSDict = 0; +PageSDict *Doxygen::pageSDict = 0; +PageSDict *Doxygen::exampleSDict = 0; +StringDict Doxygen::aliasDict(257); // aliases +StringSet Doxygen::inputPaths; FileNameLinkedMap *Doxygen::includeNameLinkedMap = 0; // include names FileNameLinkedMap *Doxygen::exampleNameLinkedMap = 0; // examples FileNameLinkedMap *Doxygen::imageNameLinkedMap = 0; // images @@ -135,35 +135,35 @@ FileNameLinkedMap *Doxygen::dotFileNameLinkedMap = 0; // dot files FileNameLinkedMap *Doxygen::mscFileNameLinkedMap = 0; // msc files FileNameLinkedMap *Doxygen::diaFileNameLinkedMap = 0; // dia files StringUnorderedMap Doxygen::namespaceAliasMap; // all namespace aliases -StringDict Doxygen::tagDestinationDict(257); // all tag locations -StringUnorderedSet Doxygen::expandAsDefinedSet; // all macros that should be expanded +StringDict Doxygen::tagDestinationDict(257); // all tag locations +StringUnorderedSet Doxygen::expandAsDefinedSet; // all macros that should be expanded QIntDict Doxygen::memGrpInfoDict(1009); // dictionary of the member groups heading -PageDef *Doxygen::mainPage = 0; -bool Doxygen::insideMainPage = FALSE; // are we generating docs for the main page? -NamespaceDefMutable *Doxygen::globalScope = 0; -bool Doxygen::parseSourcesNeeded = FALSE; -SearchIndexIntf *Doxygen::searchIndex=0; +PageDef *Doxygen::mainPage = 0; +bool Doxygen::insideMainPage = FALSE; // are we generating docs for the main page? +NamespaceDefMutable *Doxygen::globalScope = 0; +bool Doxygen::parseSourcesNeeded = FALSE; +SearchIndexIntf *Doxygen::searchIndex=0; SymbolMap Doxygen::symbolMap; -QDict *Doxygen::clangUsrMap = 0; -bool Doxygen::outputToWizard=FALSE; -QDict * Doxygen::htmlDirMap = 0; +QDict *Doxygen::clangUsrMap = 0; +bool Doxygen::outputToWizard=FALSE; +QDict * Doxygen::htmlDirMap = 0; Cache *Doxygen::lookupCache; -DirSDict *Doxygen::directories; -SDict Doxygen::dirRelations(257); -ParserManager *Doxygen::parserManager = 0; -QCString Doxygen::htmlFileExtension; -bool Doxygen::suppressDocWarnings = FALSE; -QCString Doxygen::objDBFileName; -QCString Doxygen::entryDBFileName; -QCString Doxygen::filterDBFileName; -IndexList *Doxygen::indexList; -int Doxygen::subpageNestingLevel = 0; -bool Doxygen::userComments = FALSE; -QCString Doxygen::spaces; -bool Doxygen::generatingXmlOutput = FALSE; -GenericsSDict *Doxygen::genericsDict; -DefinesPerFileList Doxygen::macroDefinitions; -bool Doxygen::clangAssistedParsing = FALSE; +DirSDict *Doxygen::directories; +SDict Doxygen::dirRelations(257); +ParserManager *Doxygen::parserManager = 0; +QCString Doxygen::htmlFileExtension; +bool Doxygen::suppressDocWarnings = FALSE; +QCString Doxygen::objDBFileName; +QCString Doxygen::entryDBFileName; +QCString Doxygen::filterDBFileName; +IndexList *Doxygen::indexList; +int Doxygen::subpageNestingLevel = 0; +bool Doxygen::userComments = FALSE; +QCString Doxygen::spaces; +bool Doxygen::generatingXmlOutput = FALSE; +GenericsSDict *Doxygen::genericsDict; +DefinesPerFileList Doxygen::macroDefinitions; +bool Doxygen::clangAssistedParsing = FALSE; // locally accessible globals static std::multimap< std::string, const Entry* > g_classEntries; @@ -181,7 +181,8 @@ void clearAll() //g_excludeNameDict.clear(); //delete g_outputList; g_outputList=0; - Doxygen::classSDict->clear(); + Doxygen::classLinkedMap->clear(); + Doxygen::hiddenClassLinkedMap->clear(); Doxygen::namespaceSDict->clear(); Doxygen::pageSDict->clear(); Doxygen::exampleSDict->clear(); @@ -1056,8 +1057,13 @@ static void addClassToContext(const Entry *root) { tArgList = getTemplateArgumentsFromName(fullName,root->tArgLists); } - cd=createClassDef(tagInfo?tagName:root->fileName,root->startLine,root->startColumn, - fullName,sec,tagName,refFileName,TRUE,root->spec&Entry::Enum); + // add class to the list + //printf("ClassDict.insert(%s)\n",fullName.data()); + cd = toClassDefMutable( + Doxygen::classLinkedMap->add(fullName, + std::unique_ptr( + createClassDef(tagInfo?tagName:root->fileName,root->startLine,root->startColumn, + fullName,sec,tagName,refFileName,TRUE,root->spec&Entry::Enum) ))); Debug::print(Debug::Classes,0," New class '%s' (sec=0x%08x)! #tArgLists=%d tagInfo=%p\n", qPrint(fullName),sec,root->tArgLists.size(), tagInfo); cd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition @@ -1090,9 +1096,6 @@ static void addClassToContext(const Entry *root) cd->insertUsedFile(fd); - // add class to the list - //printf("ClassDict.insert(%s)\n",fullName.data()); - Doxygen::classSDict->append(fullName,cd); if (cd->isGeneric()) // generics are also stored in a separate dictionary for fast lookup of instances { @@ -1152,7 +1155,6 @@ static void buildClassDocList(const Entry *root) static void resolveClassNestingRelations() { - ClassSDict::Iterator cli(*Doxygen::classSDict); ClassDefSet visitedClasses; bool done=FALSE; @@ -1161,11 +1163,18 @@ static void resolveClassNestingRelations() { done=TRUE; ++iteration; - ClassDef *icd=0; - for (cli.toFirst();(icd=cli.current());++cli) + struct ClassAlias { - ClassDefMutable *cd = toClassDefMutable(icd); - if (cd && visitedClasses.find(icd)==visitedClasses.end()) + ClassAlias(const QCString &name,std::unique_ptr cd) : + aliasFullName(name),aliasCd(std::move(cd)) {} + const QCString aliasFullName; + std::unique_ptr aliasCd; + }; + std::vector aliases; + for (const auto &icd : *Doxygen::classLinkedMap) + { + ClassDefMutable *cd = toClassDefMutable(icd.get()); + if (cd && visitedClasses.find(icd.get())==visitedClasses.end()) { QCString name = stripAnonymousNamespaceScope(icd->name()); //printf("processing=%s, iteration=%d\n",cd->name().data(),iteration); @@ -1195,10 +1204,10 @@ static void resolveClassNestingRelations() dm = toDefinitionMutable(d); if (dm) { - ClassDef *aliasCd = createClassDefAlias(d,cd); - dm->addInnerCompound(aliasCd); + std::unique_ptr aliasCd { createClassDefAlias(d,cd) }; + dm->addInnerCompound(aliasCd.get()); QCString aliasFullName = d->qualifiedName()+"::"+aliasCd->localName(); - Doxygen::classSDict->append(aliasFullName,aliasCd); + aliases.push_back(ClassAlias(aliasFullName,std::move(aliasCd))); //printf("adding %s to %s as %s\n",qPrint(aliasCd->name()),qPrint(d->name()),qPrint(aliasFullName)); } } @@ -1209,7 +1218,7 @@ static void resolveClassNestingRelations() } } - visitedClasses.insert(icd); + visitedClasses.insert(icd.get()); done=FALSE; } //else @@ -1218,14 +1227,18 @@ static void resolveClassNestingRelations() //} } } + // add aliases + for (auto &alias : aliases) + { + Doxygen::classLinkedMap->add(alias.aliasFullName,std::move(alias.aliasCd)); + } } //give warnings for unresolved compounds - ClassDef *icd=0; - for (cli.toFirst();(icd=cli.current());++cli) + for (const auto &icd : *Doxygen::classLinkedMap) { - ClassDefMutable *cd = toClassDefMutable(icd); - if (cd && visitedClasses.find(icd)==visitedClasses.end()) + ClassDefMutable *cd = toClassDefMutable(icd.get()); + if (cd && visitedClasses.find(icd.get())==visitedClasses.end()) { QCString name = stripAnonymousNamespaceScope(cd->name()); //printf("processing unresolved=%s, iteration=%d\n",cd->name().data(),iteration); @@ -1259,20 +1272,15 @@ void distributeClassGroupRelations() //printf("** distributeClassGroupRelations()\n"); ClassDefSet visitedClasses; - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { //printf("Checking %s\n",cd->name().data()); // distribute the group to nested classes as well - if (cd && visitedClasses.find(cd)==visitedClasses.end() && - cd->partOfGroups()!=0 && cd->getClassSDict()) + if (visitedClasses.find(cd.get())==visitedClasses.end() && cd->partOfGroups()!=0) { //printf(" Candidate for merging\n"); - ClassSDict::Iterator ncli(*cd->getClassSDict()); - ClassDef *ncd; GroupDef *gd = cd->partOfGroups()->at(0); - for (ncli.toFirst();(ncd=ncli.current());++ncli) + for (const auto &ncd : cd->getClasses()) { ClassDefMutable *ncdm = toClassDefMutable(ncd); if (ncdm && ncdm->partOfGroups()==0) @@ -1283,23 +1291,28 @@ void distributeClassGroupRelations() gd->addClass(ncdm); } } - visitedClasses.insert(cd); // only visit every class once + visitedClasses.insert(cd.get()); // only visit every class once } } } //---------------------------- -static ClassDefMutable *createTagLessInstance(ClassDef *rootCd,ClassDef *templ,const QCString &fieldName) +static ClassDefMutable *createTagLessInstance(const ClassDef *rootCd,const ClassDef *templ,const QCString &fieldName) { QCString fullName = removeAnonymousScopes(templ->name()); if (fullName.right(2)=="::") fullName=fullName.left(fullName.length()-2); fullName+="."+fieldName; - ClassDefMutable *cd = createClassDef(templ->getDefFileName(), + + //printf("** adding class %s based on %s\n",fullName.data(),templ->name().data()); + ClassDefMutable *cd = toClassDefMutable( + Doxygen::classLinkedMap->add(fullName, + std::unique_ptr( + createClassDef(templ->getDefFileName(), templ->getDefLine(), templ->getDefColumn(), fullName, - templ->compoundType()); + templ->compoundType())))); cd->setDocumentation(templ->documentation(),templ->docFile(),templ->docLine()); // copy docs to definition cd->setBriefDescription(templ->briefDescription(),templ->briefFile(),templ->briefLine()); cd->setLanguage(templ->getLanguage()); @@ -1333,8 +1346,6 @@ static ClassDefMutable *createTagLessInstance(ClassDef *rootCd,ClassDef *templ,c gd->addClass(cd); } } - //printf("** adding class %s based on %s\n",fullName.data(),templ->name().data()); - Doxygen::classSDict->append(fullName,cd); MemberList *ml = templ->getMemberList(MemberListType_pubAttribs); if (ml) @@ -1374,14 +1385,14 @@ static ClassDefMutable *createTagLessInstance(ClassDef *rootCd,ClassDef *templ,c * recursively. Later on we need to patch the member types so we keep * track of the hierarchy of classes we create. */ -static void processTagLessClasses(ClassDef *rootCd, - ClassDef *cd, +static void processTagLessClasses(const ClassDef *rootCd, + const ClassDef *cd, ClassDefMutable *tagParentCd, const QCString &prefix,int count) { //printf("%d: processTagLessClasses %s\n",count,cd->name().data()); //printf("checking members for %s\n",cd->name().data()); - if (tagParentCd && cd->getClassSDict()) + if (tagParentCd && !cd->getClasses().empty()) { MemberList *ml = cd->getMemberList(MemberListType_pubAttribs); if (ml) @@ -1393,9 +1404,7 @@ static void processTagLessClasses(ClassDef *rootCd, QCString type = md->typeString(); if (type.find("::@")!=-1) // member of tag less struct/union { - ClassSDict::Iterator it(*cd->getClassSDict()); - ClassDef *icd; - for (it.toFirst();(icd=it.current());++it) + for (const auto &icd : cd->getClasses()) { //printf(" member %s: type='%s'\n",md->name().data(),type.data()); //printf(" comparing '%s'<->'%s'\n",type.data(),icd->name().data()); @@ -1441,18 +1450,13 @@ static void processTagLessClasses(ClassDef *rootCd, } } -static void findTagLessClasses(ClassDef *cd) +static void findTagLessClasses(const ClassDef *cd) { - if (cd->getClassSDict()) + for (const auto &icd : cd->getClasses()) { - ClassSDict::Iterator it(*cd->getClassSDict()); - ClassDef *icd; - for (it.toFirst();(icd=it.current());++it) + if (icd->name().find("@")==-1) // process all non-anonymous inner classes { - if (icd->name().find("@")==-1) // process all non-anonymous inner classes - { - findTagLessClasses(icd); - } + findTagLessClasses(icd); } } @@ -1461,14 +1465,12 @@ static void findTagLessClasses(ClassDef *cd) static void findTagLessClasses() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) // for each class + for (const auto &cd : *Doxygen::classLinkedMap) { Definition *scope = cd->getOuterScope(); if (scope && scope->definitionType()!=Definition::TypeClass) // that is not nested { - findTagLessClasses(cd); + findTagLessClasses(cd.get()); } } } @@ -1845,7 +1847,7 @@ static void findUsingDeclarations(const Entry *root) } if (usingCd==0) { - usingCd = toClassDefMutable(Doxygen::hiddenClasses->find(name)); // check if it is already hidden + usingCd = toClassDefMutable(Doxygen::hiddenClassLinkedMap->find(name)); // check if it is already hidden } //printf("%s -> %p\n",root->name.data(),usingCd); @@ -1853,11 +1855,10 @@ static void findUsingDeclarations(const Entry *root) { Debug::print(Debug::Classes,0," New using class '%s' (sec=0x%08x)! #tArgLists=%d\n", qPrint(name),root->section,root->tArgLists.size()); - usingCd = createClassDef( - "",1,1, - name, - ClassDef::Class); - Doxygen::hiddenClasses->append(root->name,usingCd); + usingCd = toClassDefMutable( + Doxygen::hiddenClassLinkedMap->add(root->name, + std::unique_ptr( + createClassDef( "",1,1, name, ClassDef::Class)))); usingCd->setArtificial(TRUE); usingCd->setLanguage(root->lang); } @@ -3938,19 +3939,21 @@ static void findUsedClassesForClass(const Entry *root, found=TRUE; Debug::print(Debug::Classes,0," New used class '%s'\n", qPrint(usedName)); - ClassDefMutable *usedCd = toClassDefMutable(Doxygen::hiddenClasses->find(usedName)); + ClassDefMutable *usedCd = toClassDefMutable(Doxygen::hiddenClassLinkedMap->find(usedName)); if (usedCd==0) { - usedCd = createClassDef( - masterCd->getDefFileName(),masterCd->getDefLine(), - masterCd->getDefColumn(), - usedName, - ClassDef::Class); + usedCd = toClassDefMutable( + Doxygen::hiddenClassLinkedMap->add(usedName, + std::unique_ptr( + createClassDef( + masterCd->getDefFileName(),masterCd->getDefLine(), + masterCd->getDefColumn(), + usedName, + ClassDef::Class)))); //printf("making %s a template argument!!!\n",usedCd->name().data()); usedCd->makeTemplateArgument(); usedCd->setUsedOnly(TRUE); usedCd->setLanguage(masterCd->getLanguage()); - Doxygen::hiddenClasses->append(usedName,usedCd); } if (isArtificial) usedCd->setArtificial(TRUE); Debug::print(Debug::Classes,0," Adding used class '%s' (1)\n", qPrint(usedCd->name())); @@ -3981,7 +3984,7 @@ static void findUsedClassesForClass(const Entry *root, } if (!found && !type.isEmpty()) // used class is not documented in any scope { - ClassDefMutable *usedCd = toClassDefMutable(Doxygen::hiddenClasses->find(type)); + ClassDefMutable *usedCd = toClassDefMutable(Doxygen::hiddenClassLinkedMap->find(type)); if (usedCd==0 && !Config_getBool(HIDE_UNDOC_RELATIONS)) { if (type.right(2)=="(*" || type.right(2)=="(^") // type is a function pointer @@ -3989,13 +3992,15 @@ static void findUsedClassesForClass(const Entry *root, type+=md->argsString(); } Debug::print(Debug::Classes,0," New undocumented used class '%s'\n", qPrint(type)); - usedCd = createClassDef( - masterCd->getDefFileName(),masterCd->getDefLine(), - masterCd->getDefColumn(), - type,ClassDef::Class); + usedCd = toClassDefMutable( + Doxygen::hiddenClassLinkedMap->add(type, + std::unique_ptr( + createClassDef( + masterCd->getDefFileName(),masterCd->getDefLine(), + masterCd->getDefColumn(), + type,ClassDef::Class)))); usedCd->setUsedOnly(TRUE); usedCd->setLanguage(masterCd->getLanguage()); - Doxygen::hiddenClasses->append(type,usedCd); } if (usedCd) { @@ -4102,7 +4107,7 @@ static bool findTemplateInstanceRelation(const Entry *root, if (freshInstance) { Debug::print(Debug::Classes,0," found fresh instance '%s'!\n",qPrint(instanceClass->name())); - Doxygen::classSDict->append(instanceClass->name(),instanceClass); + Doxygen::classLinkedMap->add(instanceClass->name(),std::unique_ptr(instanceClass)); instanceClass->setTemplateBaseClassNames(templateNames); // search for new template instances caused by base classes of @@ -4473,28 +4478,32 @@ static bool findClassRelation( baseClass=0; if (isATemplateArgument) { - baseClass=toClassDefMutable(Doxygen::hiddenClasses->find(baseClassName)); + baseClass=toClassDefMutable(Doxygen::hiddenClassLinkedMap->find(baseClassName)); if (baseClass==0) { - baseClass=createClassDef(root->fileName,root->startLine,root->startColumn, + baseClass= toClassDefMutable( + Doxygen::hiddenClassLinkedMap->add(baseClassName, + std::unique_ptr( + createClassDef(root->fileName,root->startLine,root->startColumn, baseClassName, - ClassDef::Class); - Doxygen::hiddenClasses->append(baseClassName,baseClass); + ClassDef::Class)))); if (isArtificial) baseClass->setArtificial(TRUE); baseClass->setLanguage(root->lang); } } else { - baseClass=toClassDefMutable(Doxygen::classSDict->find(baseClassName)); + baseClass=toClassDefMutable(Doxygen::classLinkedMap->find(baseClassName)); //printf("*** classDDict->find(%s)=%p biName=%s templSpec=%s\n", // baseClassName.data(),baseClass,biName.data(),templSpec.data()); if (baseClass==0) { - baseClass=createClassDef(root->fileName,root->startLine,root->startColumn, - baseClassName, - ClassDef::Class); - Doxygen::classSDict->append(baseClassName,baseClass); + baseClass = toClassDefMutable( + Doxygen::classLinkedMap->add(baseClassName, + std::unique_ptr( + createClassDef(root->fileName,root->startLine,root->startColumn, + baseClassName, + ClassDef::Class)))); if (isArtificial) baseClass->setArtificial(TRUE); baseClass->setLanguage(root->lang); si = baseClassName.findRev("::"); @@ -4625,7 +4634,6 @@ static QCString extractClassName(const Entry *root) */ static void findInheritedTemplateInstances() { - ClassSDict::Iterator cli(*Doxygen::classSDict); ClassDefSet visitedClasses; for (const auto &kv : g_classEntries) { @@ -4647,7 +4655,6 @@ static void findInheritedTemplateInstances() static void findUsedTemplateInstances() { - ClassSDict::Iterator cli(*Doxygen::classSDict); for (const auto &kv : g_classEntries) { const Entry *root = kv.second; @@ -4668,7 +4675,6 @@ static void findUsedTemplateInstances() static void computeClassRelations() { - ClassSDict::Iterator cli(*Doxygen::classSDict); for (const auto &kv : g_classEntries) { const Entry *root = kv.second; @@ -4778,11 +4784,9 @@ static void computeTemplateClassRelations() static void computeMemberReferences() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->computeAnchors(); @@ -4817,11 +4821,9 @@ static void computeMemberReferences() static void addListReferences() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->addListReferences(); @@ -7436,26 +7438,12 @@ static void computeMemberRelations() } } - -//---------------------------------------------------------------------------- -//static void computeClassImplUsageRelations() -//{ -// ClassDef *cd; -// ClassSDict::Iterator cli(*Doxygen::classSDict); -// for (;(cd=cli.current());++cli) -// { -// cd->determineImplUsageRelation(); -// } -//} - //---------------------------------------------------------------------------- static void createTemplateInstanceMembers() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; // for each class - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { // that is a template QDict *templInstances = cd->getTemplateInstances(); @@ -7469,7 +7457,7 @@ static void createTemplateInstanceMembers() ClassDefMutable *tcdm = toClassDefMutable(tcd); if (tcdm) { - tcdm->addMembersToTemplateInstance(cd,qdi.currentKey()); + tcdm->addMembersToTemplateInstance(cd.get(),qdi.currentKey()); } } } @@ -7480,21 +7468,19 @@ static void createTemplateInstanceMembers() static void mergeCategories() { - ClassDef *cd; - ClassSDict::Iterator cli(*Doxygen::classSDict); // merge members of categories into the class they extend - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { int i=cd->name().find('('); if (i!=-1) // it is an Objective-C category { QCString baseName=cd->name().left(i); - ClassDefMutable *baseClass=toClassDefMutable(Doxygen::classSDict->find(baseName)); + ClassDefMutable *baseClass=toClassDefMutable(Doxygen::classLinkedMap->find(baseName)); if (baseClass) { //printf("*** merging members of category %s into %s\n", // cd->name().data(),baseClass->name().data()); - baseClass->mergeCategory(cd); + baseClass->mergeCategory(cd.get()); } } } @@ -7504,16 +7490,14 @@ static void mergeCategories() static void buildCompleteMemberLists() { - ClassDef *cd; - ClassSDict::Iterator cli(*Doxygen::classSDict); // merge the member list of base classes into the inherited classes. - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (// !cd->isReference() && // not an external class cd->subClasses().empty() && // is a root of the hierarchy !cd->baseClasses().empty()) // and has at least one base class { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { //printf("*** merging members for %s\n",cd->name().data()); @@ -7522,9 +7506,9 @@ static void buildCompleteMemberLists() } } // now sort the member list of all members for all classes. - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->sortAllMembersList(); @@ -7759,14 +7743,12 @@ static void generateFileDocs() static void addSourceReferences() { // add source references for class definitions - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { FileDef *fd=cd->getBodyDef(); if (fd && cd->isLinkableInProject() && cd->getStartDefLine()!=-1) { - fd->addSourceRef(cd->getStartDefLine(),cd,0); + fd->addSourceRef(cd->getStartDefLine(),cd.get(),0); } } // add source references for namespace definitions @@ -7869,11 +7851,9 @@ static void buildDefineList() static void sortMemberLists() { // sort class member lists - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->sortMemberLists(); @@ -7935,11 +7915,9 @@ static void computeTooltipTexts() static void setAnonymousEnumType() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->setAnonymousEnumType(); @@ -7951,11 +7929,9 @@ static void setAnonymousEnumType() static void countMembers() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->countMembers(); @@ -7993,12 +7969,11 @@ static void countMembers() //---------------------------------------------------------------------------- // generate the documentation of all classes -static void generateClassList(ClassSDict &classSDict) +static void generateClassList(const ClassLinkedMap &classList) { - ClassSDict::Iterator cli(classSDict); - for ( ; cli.current() ; ++cli ) + for (const auto &cdi : classList) { - ClassDefMutable *cd=toClassDefMutable(cli.current()); + ClassDefMutable *cd=toClassDefMutable(cdi.get()); //printf("cd=%s getOuterScope=%p global=%p\n",cd->name().data(),cd->getOuterScope(),Doxygen::globalScope); if (cd && @@ -8024,8 +7999,8 @@ static void generateClassList(ClassSDict &classSDict) static void generateClassDocs() { - generateClassList(*Doxygen::classSDict); - generateClassList(*Doxygen::hiddenClasses); + generateClassList(*Doxygen::classLinkedMap); + generateClassList(*Doxygen::hiddenClassLinkedMap); } //---------------------------------------------------------------------------- @@ -8095,11 +8070,9 @@ static void combineUsingRelations() static void addMembersToMemberGroup() { // for each class - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for ( ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->addMembersToMemberGroup(); @@ -8138,11 +8111,9 @@ static void addMembersToMemberGroup() static void distributeMemberGroupDocumentation() { // for each class - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for ( ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->distributeMemberGroupDocumentation(); @@ -8181,11 +8152,9 @@ static void distributeMemberGroupDocumentation() static void findSectionsInDocumentation() { // for each class - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for ( ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm) { cdm->findSectionsInDocumentation(); @@ -8889,12 +8858,10 @@ static void generateGroupDocs() //---------------------------------------------------------------------------- // generate module pages -static void generateNamespaceClassDocs(ClassSDict *d) +static void generateNamespaceClassDocs(const ClassLinkedRefMap &classList) { // for each class in the namespace... - ClassSDict::Iterator cli(*d); - ClassDef *cd; - for ( ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : classList) { ClassDefMutable *cdm = toClassDefMutable(cd); if (cdm) @@ -8938,12 +8905,12 @@ static void generateNamespaceDocs() } } - generateNamespaceClassDocs(nd->getClassSDict()); + generateNamespaceClassDocs(nd->getClasses()); if (sliceOpt) { - generateNamespaceClassDocs(nd->getInterfaceSDict()); - generateNamespaceClassDocs(nd->getStructSDict()); - generateNamespaceClassDocs(nd->getExceptionSDict()); + generateNamespaceClassDocs(nd->getInterfaces()); + generateNamespaceClassDocs(nd->getStructs()); + generateNamespaceClassDocs(nd->getExceptions()); } } } @@ -10071,10 +10038,8 @@ void initDoxygen() Doxygen::groupSDict->setAutoDelete(TRUE); Doxygen::namespaceSDict = new NamespaceSDict(20); Doxygen::namespaceSDict->setAutoDelete(TRUE); - Doxygen::classSDict = new ClassSDict(1009); - Doxygen::classSDict->setAutoDelete(TRUE); - Doxygen::hiddenClasses = new ClassSDict(257); - Doxygen::hiddenClasses->setAutoDelete(TRUE); + Doxygen::classLinkedMap = new ClassLinkedMap; + Doxygen::hiddenClassLinkedMap = new ClassLinkedMap; Doxygen::directories = new DirSDict(17); Doxygen::directories->setAutoDelete(TRUE); Doxygen::pageSDict = new PageSDict(1009); // all doc pages @@ -10137,8 +10102,6 @@ void cleanUpDoxygen() delete Doxygen::memberNameLinkedMap; delete Doxygen::functionNameLinkedMap; delete Doxygen::groupSDict; - delete Doxygen::classSDict; - delete Doxygen::hiddenClasses; delete Doxygen::namespaceSDict; delete Doxygen::directories; @@ -10682,11 +10645,9 @@ static void writeTagFile() } } // for each class - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for ( ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassDefMutable *cdm = toClassDefMutable(cd); + ClassDefMutable *cdm = toClassDefMutable(cd.get()); if (cdm && cdm->isLinkableInProject()) { cdm->writeTagFile(tagFile); @@ -11409,6 +11370,13 @@ void parseInput() )<0; }; + auto classComp = [](const ClassLinkedMap::Ptr &c1,const ClassLinkedMap::Ptr &c2) + { + return Config_getBool(SORT_BY_SCOPE_NAME) ? + qstricmp(c1->name(), c2->name())<0 : + qstricmp(c1->className(), c2->className())<0; + }; + g_s.begin("Sorting lists...\n"); std::sort(Doxygen::memberNameLinkedMap->begin(), Doxygen::memberNameLinkedMap->end(), @@ -11416,8 +11384,12 @@ void parseInput() std::sort(Doxygen::functionNameLinkedMap->begin(), Doxygen::functionNameLinkedMap->end(), memberNameComp); - Doxygen::hiddenClasses->sort(); - Doxygen::classSDict->sort(); + std::sort(Doxygen::hiddenClassLinkedMap->begin(), + Doxygen::hiddenClassLinkedMap->end(), + classComp); + std::sort(Doxygen::classLinkedMap->begin(), + Doxygen::classLinkedMap->end(), + classComp); g_s.end(); QDir thisDir; diff --git a/src/doxygen.h b/src/doxygen.h index 8ab8679..a9a708d 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -49,7 +49,7 @@ class GroupDef; class GroupSDict; class FileDef; class ClassDef; -class ClassSDict; +class ClassLinkedMap; class GenericsSDict; class MemberNameLinkedMap; class FileNameLinkedMap; @@ -95,8 +95,8 @@ extern QCString g_spaces; class Doxygen { public: - static ClassSDict *classSDict; - static ClassSDict *hiddenClasses; + static ClassLinkedMap *classLinkedMap; + static ClassLinkedMap *hiddenClassLinkedMap; static PageSDict *exampleSDict; static PageSDict *pageSDict; static PageDef *mainPage; diff --git a/src/filedef.cpp b/src/filedef.cpp index 68c2218..3ac4e67 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -87,7 +87,7 @@ class FileDefImpl : public DefinitionMixin virtual const QList &getMemberLists() const { return m_memberLists; } virtual MemberGroupSDict *getMemberGroupSDict() const { return m_memberGroupSDict; } virtual NamespaceSDict *getNamespaceSDict() const { return m_namespaceSDict; } - virtual ClassSDict *getClassSDict() const { return m_classSDict; } + virtual ClassLinkedRefMap getClasses() const { return m_classes; } virtual QCString title() const; virtual bool hasDetailedDescription() const; virtual QCString fileVersion() const; @@ -107,7 +107,7 @@ class FileDefImpl : public DefinitionMixin virtual void parseSource(ClangTUParser *clangParser); virtual void setDiskName(const QCString &name); virtual void insertMember(MemberDef *md); - virtual void insertClass(ClassDef *cd); + virtual void insertClass(const ClassDef *cd); virtual void insertNamespace(NamespaceDef *nd); virtual void computeAnchors(); virtual void setPackageDef(PackageDef *pd) { m_package=pd; } @@ -139,7 +139,7 @@ class FileDefImpl : public DefinitionMixin void writeSourceLink(OutputList &ol); void writeNamespaceDeclarations(OutputList &ol,const QCString &title, bool isConstantGroup); - void writeClassDeclarations(OutputList &ol,const QCString &title,ClassSDict *d); + void writeClassDeclarations(OutputList &ol,const QCString &title,const ClassLinkedRefMap &list); void writeInlineClasses(OutputList &ol); void startMemberDeclarations(OutputList &ol); void endMemberDeclarations(OutputList &ol); @@ -147,7 +147,7 @@ class FileDefImpl : public DefinitionMixin void endMemberDocumentation(OutputList &ol); void writeDetailedDescription(OutputList &ol,const QCString &title); void writeBriefDescription(OutputList &ol); - void writeClassesToTagFile(FTextStream &t,ClassSDict *d); + void writeClassesToTagFile(FTextStream &t,const ClassLinkedRefMap &list); QDict *m_includeDict; QList *m_includeList; @@ -171,10 +171,10 @@ class FileDefImpl : public DefinitionMixin QList m_memberLists; MemberGroupSDict *m_memberGroupSDict; NamespaceSDict *m_namespaceSDict; - ClassSDict *m_classSDict; - ClassSDict *m_interfaceSDict; - ClassSDict *m_structSDict; - ClassSDict *m_exceptionSDict; + ClassLinkedRefMap m_classes; + ClassLinkedRefMap m_interfaces; + ClassLinkedRefMap m_structs; + ClassLinkedRefMap m_exceptions; bool m_subGrouping; }; @@ -226,10 +226,6 @@ FileDefImpl::FileDefImpl(const char *p,const char *nm, m_fileName=nm; setReference(lref); setDiskName(dn?dn:nm); - m_classSDict = 0; - m_interfaceSDict = 0; - m_structSDict = 0; - m_exceptionSDict = 0; m_includeList = 0; m_includeDict = 0; m_includedByList = 0; @@ -254,10 +250,6 @@ FileDefImpl::FileDefImpl(const char *p,const char *nm, /*! destroy the file definition */ FileDefImpl::~FileDefImpl() { - delete m_classSDict; - delete m_interfaceSDict; - delete m_structSDict; - delete m_exceptionSDict; delete m_includeDict; delete m_includeList; delete m_includedByDict; @@ -380,26 +372,22 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile) { case LayoutDocEntry::FileClasses: { - if (m_classSDict) - writeClassesToTagFile(tagFile, m_classSDict); + writeClassesToTagFile(tagFile, m_classes); } break; case LayoutDocEntry::FileInterfaces: { - if (m_interfaceSDict) - writeClassesToTagFile(tagFile, m_interfaceSDict); + writeClassesToTagFile(tagFile, m_interfaces); } break; case LayoutDocEntry::FileStructs: { - if (m_structSDict) - writeClassesToTagFile(tagFile, m_structSDict); + writeClassesToTagFile(tagFile, m_structs); } break; case LayoutDocEntry::FileExceptions: { - if (m_exceptionSDict) - writeClassesToTagFile(tagFile, m_exceptionSDict); + writeClassesToTagFile(tagFile, m_exceptions); } break; case LayoutDocEntry::FileNamespaces: @@ -569,11 +557,9 @@ void FileDefImpl::writeBriefDescription(OutputList &ol) ol.writeSynopsis(); } -void FileDefImpl::writeClassesToTagFile(FTextStream &tagFile, ClassSDict *d) +void FileDefImpl::writeClassesToTagFile(FTextStream &tagFile, const ClassLinkedRefMap &list) { - SDict::Iterator ci(*d); - ClassDef *cd; - for (ci.toFirst();(cd=ci.current());++ci) + for (const auto &cd : list) { if (cd->isLinkableInProject()) { @@ -722,10 +708,10 @@ void FileDefImpl::writeNamespaceDeclarations(OutputList &ol,const QCString &titl if (m_namespaceSDict) m_namespaceSDict->writeDeclaration(ol,title,isConstantGroup); } -void FileDefImpl::writeClassDeclarations(OutputList &ol,const QCString &title,ClassSDict *d) +void FileDefImpl::writeClassDeclarations(OutputList &ol,const QCString &title,const ClassLinkedRefMap &list) { // write list of classes - if (d) d->writeDeclaration(ol,0,title,FALSE); + list.writeDeclaration(ol,0,title,FALSE); } void FileDefImpl::writeInlineClasses(OutputList &ol) @@ -735,7 +721,7 @@ void FileDefImpl::writeInlineClasses(OutputList &ol) bool isEnabled = ol.isEnabled(OutputGenerator::Html); ol.enable(OutputGenerator::Html); - if (m_classSDict) m_classSDict->writeDocumentation(ol,this); + m_classes.writeDocumentation(ol,this); // restore the initial state if needed if (!isEnabled) ol.disable(OutputGenerator::Html); @@ -811,28 +797,28 @@ void FileDefImpl::writeSummaryLinks(OutputList &ol) const SrcLangExt lang=getLanguage(); for (eli.toFirst();(lde=eli.current());++eli) { - if (lde->kind()==LayoutDocEntry::FileClasses && m_classSDict && m_classSDict->declVisible()) + if (lde->kind()==LayoutDocEntry::FileClasses && m_classes.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "nested-classes"; ol.writeSummaryLink(0,label,ls->title(lang),first); first=FALSE; } - else if (lde->kind()==LayoutDocEntry::FileInterfaces && m_interfaceSDict && m_interfaceSDict->declVisible()) + else if (lde->kind()==LayoutDocEntry::FileInterfaces && m_interfaces.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "interfaces"; ol.writeSummaryLink(0,label,ls->title(lang),first); first=FALSE; } - else if (lde->kind()==LayoutDocEntry::FileStructs && m_structSDict && m_structSDict->declVisible()) + else if (lde->kind()==LayoutDocEntry::FileStructs && m_structs.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "structs"; ol.writeSummaryLink(0,label,ls->title(lang),first); first=FALSE; } - else if (lde->kind()==LayoutDocEntry::FileExceptions && m_exceptionSDict && m_exceptionSDict->declVisible()) + else if (lde->kind()==LayoutDocEntry::FileExceptions && m_exceptions.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "exceptions"; @@ -970,25 +956,25 @@ void FileDefImpl::writeDocumentation(OutputList &ol) case LayoutDocEntry::FileClasses: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),m_classSDict); + writeClassDeclarations(ol,ls->title(lang),m_classes); } break; case LayoutDocEntry::FileInterfaces: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),m_interfaceSDict); + writeClassDeclarations(ol,ls->title(lang),m_interfaces); } break; case LayoutDocEntry::FileStructs: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),m_structSDict); + writeClassDeclarations(ol,ls->title(lang),m_structs); } break; case LayoutDocEntry::FileExceptions: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),m_exceptionSDict); + writeClassDeclarations(ol,ls->title(lang),m_exceptions); } break; case LayoutDocEntry::FileNamespaces: @@ -1377,40 +1363,29 @@ void FileDefImpl::insertMember(MemberDef *md) } /*! Adds compound definition \a cd to the list of all compounds of this file */ -void FileDefImpl::insertClass(ClassDef *cd) +void FileDefImpl::insertClass(const ClassDef *cd) { if (cd->isHidden()) return; - ClassSDict *d=0; - ClassSDict **dd=&m_classSDict; + ClassLinkedRefMap &list = m_classes; if (Config_getBool(OPTIMIZE_OUTPUT_SLICE)) { if (cd->compoundType()==ClassDef::Interface) { - dd = &m_interfaceSDict; + list = m_interfaces; } else if (cd->compoundType()==ClassDef::Struct) { - dd = &m_structSDict; + list = m_structs; } else if (cd->compoundType()==ClassDef::Exception) { - dd = &m_exceptionSDict; + list = m_exceptions; } } - if (*dd==0) *dd = new ClassSDict(17); - d = *dd; - - if (Config_getBool(SORT_BRIEF_DOCS)) - { - d->inSort(cd->name(),cd); - } - else - { - d->append(cd->name(),cd); - } + list.add(cd->name(),cd); } /*! Adds namespace definition \a nd to the list of all compounds of this file */ @@ -2040,6 +2015,20 @@ void FileDefImpl::sortMemberLists() } } + if (Config_getBool(SORT_BRIEF_DOCS)) + { + auto classComp = [](const ClassLinkedRefMap::Ptr &c1,const ClassLinkedRefMap::Ptr &c2) + { + return Config_getBool(SORT_BY_SCOPE_NAME) ? + qstricmp(c1->name(), c2->name())<0 : + qstricmp(c1->className(), c2->className())<0; + }; + + std::sort(m_classes.begin(), m_classes.end(), classComp); + std::sort(m_interfaces.begin(),m_interfaces.end(),classComp); + std::sort(m_structs.begin(), m_structs.end(), classComp); + std::sort(m_exceptions.begin(),m_exceptions.end(),classComp); + } } MemberList *FileDefImpl::getMemberList(MemberListType lt) const diff --git a/src/filedef.h b/src/filedef.h index 055078f..e9816b4 100644 --- a/src/filedef.h +++ b/src/filedef.h @@ -33,7 +33,6 @@ class MemberList; class FileDef; class FileList; -class ClassSDict; class ClassDef; class ClassList; class MemberDef; @@ -135,7 +134,7 @@ class FileDef : public DefinitionMutable, public Definition /* user defined member groups */ virtual MemberGroupSDict *getMemberGroupSDict() const = 0; virtual NamespaceSDict *getNamespaceSDict() const = 0; - virtual ClassSDict *getClassSDict() const = 0; + virtual ClassLinkedRefMap getClasses() const = 0; virtual QCString title() const = 0; virtual bool hasDetailedDescription() const = 0; @@ -164,7 +163,7 @@ class FileDef : public DefinitionMutable, public Definition virtual void setDiskName(const QCString &name) = 0; virtual void insertMember(MemberDef *md) = 0; - virtual void insertClass(ClassDef *cd) = 0; + virtual void insertClass(const ClassDef *cd) = 0; virtual void insertNamespace(NamespaceDef *nd) = 0; virtual void computeAnchors() = 0; diff --git a/src/fortrancode.l b/src/fortrancode.l index 1c1287d..c4b865b 100644 --- a/src/fortrancode.l +++ b/src/fortrancode.l @@ -1088,12 +1088,12 @@ static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName //cout << "=== search for type: " << tname << endl; // search for type - if ((cd=Doxygen::classSDict->find(tname))) + if ((cd=Doxygen::classLinkedMap->find(tname))) { //cout << "=== type found in global module" << endl; return TRUE; } - else if (moduleName && (cd= Doxygen::classSDict->find(moduleName+"::"+tname))) + else if (moduleName && (cd= Doxygen::classLinkedMap->find(moduleName+"::"+tname))) { //cout << "=== type found in local module" << endl; return TRUE; @@ -1103,7 +1103,7 @@ static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName UseEntry *use; for (UseSDict::Iterator di(*usedict); (use=di.current()); ++di) { - if ((cd= Doxygen::classSDict->find(use->module+"::"+tname))) + if ((cd= Doxygen::classLinkedMap->find(use->module+"::"+tname))) { //cout << "=== type found in used module" << endl; return TRUE; diff --git a/src/groupdef.cpp b/src/groupdef.cpp index 57e2226..5dfc0ae 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -15,8 +15,12 @@ * */ +#include +#include + #include #include + #include "groupdef.h" #include "classdef.h" #include "filedef.h" @@ -97,7 +101,7 @@ class GroupDefImpl : public DefinitionMixin virtual MemberGroupSDict *getMemberGroupSDict() const { return m_memberGroupSDict; } virtual FileList * getFiles() const { return m_fileList; } - virtual ClassSDict * getClasses() const { return m_classSDict; } + virtual ClassLinkedRefMap getClasses() const { return m_classes; } virtual NamespaceSDict * getNamespaces() const { return m_namespaceSDict; } virtual GroupList * getSubGroups() const { return m_groupList; } virtual PageSDict * getPages() const { return m_pageDict; } @@ -136,7 +140,7 @@ class GroupDefImpl : public DefinitionMixin bool m_titleSet; // true if title is not the same as the name QCString m_fileName; // base name of the generated file FileList * m_fileList; // list of files in the group - ClassSDict * m_classSDict; // list of classes in the group + ClassLinkedRefMap m_classes; // list of classes in the group NamespaceSDict * m_namespaceSDict; // list of namespaces in the group GroupList * m_groupList; // list of sub groups. PageSDict * m_pageDict; // list of pages in the group @@ -164,7 +168,6 @@ GroupDefImpl::GroupDefImpl(const char *df,int dl,const char *na,const char *t, const char *refFileName) : DefinitionMixin(df,dl,1,na) { m_fileList = new FileList; - m_classSDict = new ClassSDict(17); m_groupList = new GroupList; m_namespaceSDict = new NamespaceSDict(17); m_pageDict = new PageSDict(17); @@ -191,7 +194,6 @@ GroupDefImpl::GroupDefImpl(const char *df,int dl,const char *na,const char *t, GroupDefImpl::~GroupDefImpl() { delete m_fileList; - delete m_classSDict; delete m_groupList; delete m_namespaceSDict; delete m_pageDict; @@ -261,47 +263,12 @@ void GroupDefImpl::addFile(const FileDef *def) bool GroupDefImpl::addClass(const ClassDef *cd) { - static bool sortBriefDocs = Config_getBool(SORT_BRIEF_DOCS); if (cd->isHidden()) return FALSE; updateLanguage(cd); QCString qn = cd->name(); - if (m_classSDict->find(qn)==0) + if (m_classes.find(qn)==0) { - //printf("--- addClass %s sort=%d\n",qn.data(),sortBriefDocs); - if (sortBriefDocs) - { - m_classSDict->inSort(qn,cd); - } - else - { - int i=qn.findRev("::"); - if (i==-1) i=qn.find('.'); - bool found=FALSE; - //printf("i=%d\n",i); - if (i>0) - { - // add nested classes (e.g. A::B, A::C) after their parent (A) in - // order of insertion - QCString scope = qn.left(i); - int j=m_classSDict->findAt(scope); - if (j!=-1) - { - while (j<(int)m_classSDict->count() && - m_classSDict->at(j)->qualifiedName().left(i)==scope) - { - //printf("skipping over %s\n",classSDict->at(j)->qualifiedName().data()); - j++; - } - //printf("Found scope at index %d\n",j); - m_classSDict->insertAt(j,qn,cd); - found=TRUE; - } - } - if (!found) // no insertion point found -> just append - { - m_classSDict->append(qn,cd); - } - } + m_classes.add(qn,cd); return TRUE; } return FALSE; @@ -653,7 +620,7 @@ void GroupDefImpl::countMembers() int GroupDefImpl::numDocMembers() const { return m_fileList->count()+ - m_classSDict->count()+ + m_classes.size()+ m_namespaceSDict->count()+ m_groupList->count()+ m_allMemberList->count()+ @@ -683,17 +650,12 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) { case LayoutDocEntry::GroupClasses: { - if (m_classSDict) + for (const auto &cd : m_classes) { - SDict::Iterator ci(*m_classSDict); - ClassDef *cd; - for (ci.toFirst();(cd=ci.current());++ci) + if (cd->isLinkableInProject()) { - if (cd->isLinkableInProject()) - { - tagFile << " compoundTypeString() - << "\">" << convertToXML(cd->name()) << "" << endl; - } + tagFile << " compoundTypeString() + << "\">" << convertToXML(cd->name()) << "" << endl; } } } @@ -1050,12 +1012,12 @@ void GroupDefImpl::writeDirs(OutputList &ol,const QCString &title) void GroupDefImpl::writeClasses(OutputList &ol,const QCString &title) { // write list of classes - m_classSDict->writeDeclaration(ol,0,title,FALSE); + m_classes.writeDeclaration(ol,0,title,FALSE); } void GroupDefImpl::writeInlineClasses(OutputList &ol) { - m_classSDict->writeDocumentation(ol); + m_classes.writeDocumentation(ol); } void GroupDefImpl::writePageDocumentation(OutputList &ol) @@ -1152,7 +1114,7 @@ void GroupDefImpl::writeSummaryLinks(OutputList &ol) const SrcLangExt lang = getLanguage(); for (eli.toFirst();(lde=eli.current());++eli) { - if ((lde->kind()==LayoutDocEntry::GroupClasses && m_classSDict->declVisible()) || + if ((lde->kind()==LayoutDocEntry::GroupClasses && m_classes.declVisible()) || (lde->kind()==LayoutDocEntry::GroupNamespaces && m_namespaceSDict->declVisible()) || (lde->kind()==LayoutDocEntry::GroupFiles && m_fileList->count()>0) || (lde->kind()==LayoutDocEntry::GroupNestedGroups && m_groupList->count()>0) || @@ -1697,6 +1659,67 @@ void GroupDefImpl::addMemberToList(MemberListType lt,MemberDef *md) ml->append(md); } +// performs a partial reordering to group elements together with the same scope +template +static void groupClassesWithSameScope(Vec &vec) +{ + bool done=false; + while (!done) // for each iteration + { + done=true; + for (size_t i=0; iname().str(); + size_t posi = qni.rfind("::"); + if (posi!=std::string::npos) + { + std::string scope = qni.substr(0,posi); + auto it = std::find_if( vec.begin(), vec.end(), + [&](typename Vec::Ptr &cd) + { return cd->name().str()==scope; }); + if (it!=vec.end()) + { + size_t idx = std::distance(vec.begin(),it); + if (iname().str().substr(0,posi)==scope) + { + idx = k; + k++; + } + idx = std::distance(vec.begin(),it); + // swap the items such that i is inserted after idx + for (size_t j=i; jname().str().substr(0,posi)!=scope) + { + // parent scope is found before the item, and the item + // has some other item with a different scope in front of it + // move idx to the end of range with the same scope + while (idxname().str().substr(0,posi)==scope) + { + idx++; + } + // swap the items such that i is just after idx + for (size_t j=idx; j mli(m_memberLists); @@ -1708,6 +1731,18 @@ void GroupDefImpl::sortMemberLists() if (Config_getBool(SORT_BRIEF_DOCS)) { std::sort(m_dirList.begin(), m_dirList.end(), compareDirDefs); + + auto classComp = [](const ClassLinkedRefMap::Ptr &c1,const ClassLinkedRefMap::Ptr &c2) + { + return Config_getBool(SORT_BY_SCOPE_NAME) ? + qstricmp(c1->name(), c2->name())<0 : + qstricmp(c1->className(), c2->className())<0; + }; + std::sort(m_classes.begin(), m_classes.end(), classComp); + } + else + { + groupClassesWithSameScope(m_classes); } } diff --git a/src/groupdef.h b/src/groupdef.h index 0a1ec9d..35797e3 100644 --- a/src/groupdef.h +++ b/src/groupdef.h @@ -27,7 +27,7 @@ class MemberList; class FileList; -class ClassSDict; +class ClassLinkedRefMap; class FileDef; class ClassDef; class NamespaceDef; @@ -95,7 +95,7 @@ class GroupDef : public DefinitionMutable, public Definition virtual MemberGroupSDict *getMemberGroupSDict() const = 0; virtual FileList * getFiles() const = 0; - virtual ClassSDict * getClasses() const = 0; + virtual ClassLinkedRefMap getClasses() const = 0; virtual NamespaceSDict * getNamespaces() const = 0; virtual GroupList * getSubGroups() const = 0; virtual PageSDict * getPages() const = 0; diff --git a/src/index.cpp b/src/index.cpp index c58cacb..82430ef 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -397,15 +397,9 @@ void addMembersToIndex(T *def,LayoutDocManager::LayoutPart part, addToIndex, def); int numClasses=0; - ClassSDict *classes = def->getClassSDict(); - if (classes) + for (const auto &cd : def->getClasses()) { - ClassDef *cd; - ClassSDict::Iterator it(*classes); - for (;(cd=it.current());++it) - { - if (cd->isLinkable()) numClasses++; - } + if (cd->isLinkable()) numClasses++; } //printf("addMembersToIndex(def=%s hasMembers=%d numClasses=%d)\n",def->name().data(),hasMembers,numClasses); if (hasMembers || numClasses>0) @@ -437,20 +431,15 @@ void addMembersToIndex(T *def,LayoutDocManager::LayoutPart part, lde->kind()==LayoutDocEntry::ClassNestedClasses ) { - if (classes) + for (const auto &cd : def->getClasses()) { - ClassDef *cd; - ClassSDict::Iterator it(*classes); - for (;(cd=it.current());++it) + if (cd->isLinkable() && (cd->partOfGroups()==0 || def->definitionType()==Definition::TypeGroup)) { - if (cd->isLinkable() && (cd->partOfGroups()==0 || def->definitionType()==Definition::TypeGroup)) - { - static bool inlineSimpleStructs = Config_getBool(INLINE_SIMPLE_STRUCTS); - bool isNestedClass = def->definitionType()==Definition::TypeClass; - addMembersToIndex(cd,LayoutDocManager::Class,cd->displayName(FALSE),cd->anchor(), - addToIndex && (isNestedClass || (cd->isSimple() && inlineSimpleStructs)), - preventSeparateIndex || cd->isEmbeddedInOuterScope()); - } + static bool inlineSimpleStructs = Config_getBool(INLINE_SIMPLE_STRUCTS); + bool isNestedClass = def->definitionType()==Definition::TypeClass; + addMembersToIndex(cd,LayoutDocManager::Class,cd->displayName(FALSE),cd->anchor(), + addToIndex && (isNestedClass || (cd->isSimple() && inlineSimpleStructs)), + preventSeparateIndex || cd->isEmbeddedInOuterScope()); } } } @@ -831,13 +820,11 @@ static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex) //---------------------------------------------------------------------------- -static void writeClassTreeForList(OutputList &ol,ClassSDict *cl,bool &started,FTVHelp* ftv,bool addToIndex, +static void writeClassTreeForList(OutputList &ol,const ClassLinkedMap &cl,bool &started,FTVHelp* ftv,bool addToIndex, ClassDef::CompoundType ct,ClassDefSet &visitedClasses) { static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); - ClassSDict::Iterator cli(*cl); - ClassDef *cd; - for (;(cd=cli.current());++cli) + for (const auto &cd : cl) { //printf("class %s hasVisibleRoot=%d isVisibleInHierarchy=%d\n", // cd->name().data(), @@ -876,8 +863,8 @@ static void writeClassTreeForList(OutputList &ol,ClassSDict *cl,bool &started,FT started=TRUE; } ol.startIndexListItem(); - bool hasChildren = visitedClasses.find(cd)==visitedClasses.end() && - classHasVisibleChildren(cd); + bool hasChildren = visitedClasses.find(cd.get())==visitedClasses.end() && + classHasVisibleChildren(cd.get()); //printf("list: Has children %s: %d\n",cd->name().data(),hasChildren); if (cd->isLinkable()) { @@ -899,7 +886,7 @@ static void writeClassTreeForList(OutputList &ol,ClassSDict *cl,bool &started,FT } if (ftv) { - ftv->addContentsItem(hasChildren,cd->displayName(),cd->getReference(),cd->getOutputFileBase(),cd->anchor(),FALSE,FALSE,cd); + ftv->addContentsItem(hasChildren,cd->displayName(),cd->getReference(),cd->getOutputFileBase(),cd->anchor(),FALSE,FALSE,cd.get()); } } else @@ -913,18 +900,18 @@ static void writeClassTreeForList(OutputList &ol,ClassSDict *cl,bool &started,FT } if (ftv) { - ftv->addContentsItem(hasChildren,cd->displayName(),0,0,0,FALSE,FALSE,cd); + ftv->addContentsItem(hasChildren,cd->displayName(),0,0,0,FALSE,FALSE,cd.get()); } } if (cd->getLanguage()==SrcLangExt_VHDL && hasChildren) { writeClassTreeToOutput(ol,cd->baseClasses(),1,ftv,addToIndex,visitedClasses); - visitedClasses.insert(cd); + visitedClasses.insert(cd.get()); } else if (hasChildren) { writeClassTreeToOutput(ol,cd->subClasses(),1,ftv,addToIndex,visitedClasses); - visitedClasses.insert(cd); + visitedClasses.insert(cd.get()); } ol.endIndexListItem(); } @@ -941,8 +928,8 @@ static void writeClassHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex,Cla ol.disable(OutputGenerator::Html); } bool started=FALSE; - writeClassTreeForList(ol,Doxygen::classSDict,started,ftv,addToIndex,ct,visitedClasses); - writeClassTreeForList(ol,Doxygen::hiddenClasses,started,ftv,addToIndex,ct,visitedClasses); + writeClassTreeForList(ol,*Doxygen::classLinkedMap,started,ftv,addToIndex,ct,visitedClasses); + writeClassTreeForList(ol,*Doxygen::hiddenClassLinkedMap,started,ftv,addToIndex,ct,visitedClasses); if (started) { endIndexHierarchy(ol,0); @@ -959,13 +946,11 @@ static void writeClassHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex,Cla //---------------------------------------------------------------------------- -static int countClassesInTreeList(const ClassSDict &cl, ClassDef::CompoundType ct) +static int countClassesInTreeList(const ClassLinkedMap &cl, ClassDef::CompoundType ct) { static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); int count=0; - ClassSDict::Iterator cli(cl); - ClassDef *cd; - for (;(cd=cli.current());++cli) + for (const auto &cd : cl) { if (sliceOpt && cd->compoundType() != ct) { @@ -988,8 +973,8 @@ static int countClassesInTreeList(const ClassSDict &cl, ClassDef::CompoundType c static int countClassHierarchy(ClassDef::CompoundType ct) { int count=0; - count+=countClassesInTreeList(*Doxygen::classSDict, ct); - count+=countClassesInTreeList(*Doxygen::hiddenClasses, ct); + count+=countClassesInTreeList(*Doxygen::classLinkedMap, ct); + count+=countClassesInTreeList(*Doxygen::hiddenClassLinkedMap, ct); return count; } @@ -1564,75 +1549,70 @@ static int countNamespaces() } //---------------------------------------------------------------------------- +template const ClassDef *get_pointer(const Ptr &p); +template<> const ClassDef *get_pointer(const ClassLinkedMap::Ptr &p) { return p.get(); } +template<> const ClassDef *get_pointer(const ClassLinkedRefMap::Ptr &p) { return p; } -static void writeClassTree(ClassSDict *clDict,FTVHelp *ftv,bool addToIndex,bool globalOnly,ClassDef::CompoundType ct) +template +static void writeClassTree(const ListType &cl,FTVHelp *ftv,bool addToIndex,bool globalOnly,ClassDef::CompoundType ct) { static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); - if (clDict) + for (const auto &cdi : cl) { - ClassSDict::Iterator cli(*clDict); - ClassDef *cd; - for (;(cd=cli.current());++cli) + const ClassDef *cd = get_pointer(cdi); + ClassDefMutable *cdm = toClassDefMutable(cd); + if (cdm && cd->getLanguage()==SrcLangExt_VHDL) { - ClassDefMutable *cdm = toClassDefMutable(cd); - if (cdm && cd->getLanguage()==SrcLangExt_VHDL) + if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || + (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS + )// no architecture { - if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || - (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS - )// no architecture - { - continue; - } - if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS) - { - QCString n=cd->name(); - cdm->setClassName(n.data()); - } + continue; } - - if (sliceOpt && cd->compoundType() != ct) + if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS) { - continue; + QCString n=cd->name(); + cdm->setClassName(n.data()); } + } - if (!globalOnly || - cd->getOuterScope()==0 || - cd->getOuterScope()==Doxygen::globalScope - ) + if (sliceOpt && cd->compoundType() != ct) + { + continue; + } + + if (!globalOnly || + cd->getOuterScope()==0 || + cd->getOuterScope()==Doxygen::globalScope + ) + { + int count=0; + for (const auto &ccd : cd->getClasses()) { - int count=0; - if (cd->getClassSDict()) + if (ccd->isLinkableInProject() && ccd->templateMaster()==0) { - ClassSDict::Iterator ccit(*cd->getClassSDict()); - ClassDef *ccd; - for (;(ccd=ccit.current());++ccit) - { - if (ccd->isLinkableInProject() && ccd->templateMaster()==0) - { - count++; - } - } + count++; } - if (classVisibleInIndex(cd) && cd->templateMaster()==0) + } + if (classVisibleInIndex(cd) && cd->templateMaster()==0) + { + ftv->addContentsItem(count>0,cd->displayName(FALSE),cd->getReference(), + cd->getOutputFileBase(),cd->anchor(),FALSE,TRUE,cd); + if ((cd->getOuterScope()==0 || + cd->getOuterScope()->definitionType()!=Definition::TypeClass + ) + ) { - ftv->addContentsItem(count>0,cd->displayName(FALSE),cd->getReference(), - cd->getOutputFileBase(),cd->anchor(),FALSE,TRUE,cd); - if ((cd->getOuterScope()==0 || - cd->getOuterScope()->definitionType()!=Definition::TypeClass - ) - ) - { - addMembersToIndex(cd,LayoutDocManager::Class, - cd->displayName(FALSE), - cd->anchor(), - addToIndex && cd->partOfGroups()==0 && !cd->isSimple()); - } - if (count>0) - { - ftv->incContentsDepth(); - writeClassTree(cd->getClassSDict(),ftv,addToIndex,FALSE,ct); - ftv->decContentsDepth(); - } + addMembersToIndex(cd,LayoutDocManager::Class, + cd->displayName(FALSE), + cd->anchor(), + addToIndex && cd->partOfGroups()==0 && !cd->isSimple()); + } + if (count>0) + { + ftv->incContentsDepth(); + writeClassTree(cd->getClasses(),ftv,addToIndex,FALSE,ct); + ftv->decContentsDepth(); } } } @@ -1747,7 +1727,7 @@ static void writeNamespaceTree(const NamespaceSDict *nsDict,FTVHelp *ftv, { ftv->incContentsDepth(); writeNamespaceTree(nd->getNamespaceSDict(),ftv,FALSE,addToIndex); - writeClassTree(nd->getClassSDict(),ftv,FALSE,FALSE,ClassDef::Class); + writeClassTree(nd->getClasses(),ftv,FALSE,FALSE,ClassDef::Class); writeNamespaceMembers(nd,addToIndex); ftv->decContentsDepth(); } @@ -1812,20 +1792,20 @@ static void writeClassTreeInsideNamespace(const NamespaceSDict *nsDict,FTVHelp * ftv->incContentsDepth(); writeClassTreeInsideNamespace(nd->getNamespaceSDict(),ftv,FALSE,addToIndex,ct); - ClassSDict *d = nd->getClassSDict(); + ClassLinkedRefMap d = nd->getClasses(); if (sliceOpt) { if (ct == ClassDef::Interface) { - d = nd->getInterfaceSDict(); + d = nd->getInterfaces(); } else if (ct == ClassDef::Struct) { - d = nd->getStructSDict(); + d = nd->getStructs(); } else if (ct == ClassDef::Exception) { - d = nd->getExceptionSDict(); + d = nd->getExceptions(); } } writeClassTree(d,ftv,addToIndex,FALSE,ct); @@ -1957,9 +1937,7 @@ static int countAnnotatedClasses(int *cp, ClassDef::CompoundType ct) static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); int count=0; int countPrinted=0; - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for (;(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (sliceOpt && cd->compoundType() != ct) { @@ -1987,10 +1965,7 @@ static void writeAnnotatedClassList(OutputList &ol,ClassDef::CompoundType ct) static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->getLanguage()==SrcLangExt_VHDL && ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || @@ -2034,7 +2009,7 @@ static void writeAnnotatedClassList(OutputList &ol,ClassDef::CompoundType ct) { ol.generateDoc( cd->briefFile(),cd->briefLine(), - cd,0, + cd.get(),0, cd->briefDescription(TRUE), FALSE, // indexWords FALSE, // isExample @@ -2194,11 +2169,9 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct UsedIndexLetters indexLettersUsed; // first count the number of headers - ClassSDict::Iterator cli(*Doxygen::classSDict); - const ClassDef *cd; uint startLetter=0; int headerItems=0; - for (;(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (sliceOpt && cd->compoundType() != ct) continue; @@ -2252,7 +2225,7 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct // item less. //int icount=0; startLetter=0; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (sliceOpt && cd->compoundType() != ct) continue; @@ -2269,12 +2242,12 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct { if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS )// no architecture { - classesByLetter.append(startLetter,cd); + classesByLetter.append(startLetter,cd.get()); } } else { - classesByLetter.append(startLetter,cd); + classesByLetter.append(startLetter,cd.get()); } } } @@ -2308,7 +2281,7 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct row++; ClassListIterator cit(*cl); cit.toFirst(); - cd = cit.current(); + ClassDef *cd = cit.current(); ++cit; tableRows->append(new AlphaIndexTableCell(row,col,0,cd)); row++; @@ -2376,7 +2349,7 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct else if (cell->classDef()!=(ClassDef*)0x8) { cellCont = true; - cd = cell->classDef(); + const ClassDef *cd = cell->classDef(); ol.writeString(""); QCString namesp,cname; //if (cd->getNamespaceDef()) namesp=cd->getNamespaceDef()->displayName(); @@ -2642,7 +2615,7 @@ static void writeAnnotatedIndexGeneric(OutputList &ol,const AnnotatedIndexContex } FTVHelp ftv(false); writeClassTreeInsideNamespace(Doxygen::namespaceSDict,&ftv,TRUE,addToIndex,ctx.compoundType); - writeClassTree(Doxygen::classSDict,&ftv,addToIndex,TRUE,ctx.compoundType); + writeClassTree(*Doxygen::classLinkedMap,&ftv,addToIndex,TRUE,ctx.compoundType); QGString outStr; FTextStream t(&outStr); ftv.generateTreeViewInline(t); @@ -3974,7 +3947,7 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* } } numSubItems += gd->getNamespaces()->count(); - numSubItems += gd->getClasses()->count(); + numSubItems += gd->getClasses().size(); numSubItems += gd->getFiles()->count(); numSubItems += static_cast(gd->getDirs().size()); numSubItems += gd->getPages()->count(); @@ -4054,9 +4027,7 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* } else if (lde->kind()==LayoutDocEntry::GroupClasses && addToIndex) { - ClassSDict::Iterator it(*gd->getClasses()); - ClassDef *cd; - for (;(cd=it.current());++it) + for (const auto &cd : gd->getClasses()) { //bool nestedClassInSameGroup = // cd->getOuterScope() && cd->getOuterScope()->definitionType()==Definition::TypeClass && diff --git a/src/latexgen.cpp b/src/latexgen.cpp index b98b35b..156be8e 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -1046,10 +1046,7 @@ void LatexGenerator::startIndexSection(IndexSections is) break; case isClassDocumentation: { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - bool found=FALSE; - for (cli.toFirst();(cd=cli.current()) && !found;++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->isLinkableInProject() && cd->templateMaster()==0 && @@ -1059,7 +1056,7 @@ void LatexGenerator::startIndexSection(IndexSections is) { if (compactLatex) t << "\\doxysection"; else t << "\\chapter"; t << "{"; //Compound Documentation}\n"; - found=TRUE; + break; } } } @@ -1225,10 +1222,8 @@ void LatexGenerator::endIndexSection(IndexSections is) break; case isClassDocumentation: { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; bool found=FALSE; - for (cli.toFirst();(cd=cli.current()) && !found;++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->isLinkableInProject() && cd->templateMaster()==0 && @@ -1236,21 +1231,12 @@ void LatexGenerator::endIndexSection(IndexSections is) !cd->isAlias() ) { - t << "}\n\\input{" << cd->getOutputFileBase() << "}\n"; - found=TRUE; - } - } - for (;(cd=cli.current());++cli) - { - if (cd->isLinkableInProject() && - cd->templateMaster()==0 && - !cd->isEmbeddedInOuterScope() && - !cd->isAlias() - ) - { - //if (compactLatex) t << "\\input"; else t << "\\include"; - t << "\\input"; - t << "{" << cd->getOutputFileBase() << "}\n"; + if (!found) + { + t << "}\n"; // end doxysection or chapter title + found=TRUE; + } + t << "\\input{" << cd->getOutputFileBase() << "}\n"; } } } @@ -1266,24 +1252,14 @@ void LatexGenerator::endIndexSection(IndexSections is) { if (isFirst) { - t << "}\n\\input{" << fd->getOutputFileBase() << "}\n"; - if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) - { - //t << "\\include{" << fd->getSourceFileBase() << "}\n"; - t << "\\input{" << fd->getSourceFileBase() << "}\n"; - } - isFirst=FALSE; + t << "}\n"; // end doxysection or chapter title } - else + isFirst=FALSE; + t << "\\input{" << fd->getOutputFileBase() << "}\n"; + if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) { - //if (compactLatex) t << "\\input" ; else t << "\\include"; - t << "\\input" ; - t << "{" << fd->getOutputFileBase() << "}\n"; - if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) - { - //t << "\\include{" << fd->getSourceFileBase() << "}\n"; - t << "\\input{" << fd->getSourceFileBase() << "}\n"; - } + //t << "\\include{" << fd->getSourceFileBase() << "}\n"; + t << "\\input{" << fd->getSourceFileBase() << "}\n"; } } } diff --git a/src/linkedmap.h b/src/linkedmap.h index 9ca0fa2..f09b6d8 100644 --- a/src/linkedmap.h +++ b/src/linkedmap.h @@ -73,6 +73,23 @@ class LinkedMap return result; } + //! Adds an existing object to the ordered vector (unless another object was already + //! added under the same key). Ownership is transferred. + //! Return a non-owning pointer to the newly added object, or to the existing object if + //! it was already inserted before under the given key. + T *add(const char *k, Ptr &&ptr) + { + T *result = find(k); + if (result==nullptr) + { + std::string key(k ? k : ""); + result = ptr.get(); + m_lookup.insert({key,result}); + m_entries.push_back(std::move(ptr)); + } + return result; + } + //! Prepends a new object to the ordered vector if it was not added already. //! Return a non-owning pointer to the newly added object, or to the existing object if //! it was already inserted before under the given key. @@ -110,16 +127,18 @@ class LinkedMap return false; } - iterator begin() { return m_entries.begin(); } - iterator end() { return m_entries.end(); } - const_iterator begin() const { return m_entries.cbegin(); } - const_iterator end() const { return m_entries.cend(); } - reverse_iterator rbegin() { return m_entries.rbegin(); } - reverse_iterator rend() { return m_entries.rend(); } - const_reverse_iterator rbegin() const { return m_entries.crbegin(); } - const_reverse_iterator rend() const { return m_entries.crend(); } - bool empty() const { return m_entries.empty(); } - size_t size() const { return m_entries.size(); } + Ptr &operator[](size_t pos) { return m_entries[pos]; } + const Ptr &operator[](size_t pos) const { return m_entries[pos]; } + iterator begin() { return m_entries.begin(); } + iterator end() { return m_entries.end(); } + const_iterator begin() const { return m_entries.cbegin(); } + const_iterator end() const { return m_entries.cend(); } + reverse_iterator rbegin() { return m_entries.rbegin(); } + reverse_iterator rend() { return m_entries.rend(); } + const_reverse_iterator rbegin() const { return m_entries.crbegin(); } + const_reverse_iterator rend() const { return m_entries.crend(); } + bool empty() const { return m_entries.empty(); } + size_t size() const { return m_entries.size(); } void clear() { @@ -220,16 +239,18 @@ class LinkedRefMap return false; } - iterator begin() { return m_entries.begin(); } - iterator end() { return m_entries.end(); } - const_iterator begin() const { return m_entries.cbegin(); } - const_iterator end() const { return m_entries.cend(); } - reverse_iterator rbegin() { return m_entries.rbegin(); } - reverse_iterator rend() { return m_entries.rend(); } - const_reverse_iterator rbegin() const { return m_entries.crbegin(); } - const_reverse_iterator rend() const { return m_entries.crend(); } - bool empty() const { return m_entries.empty(); } - size_t size() const { return m_entries.size(); } + Ptr &operator[](size_t pos) { return m_entries[pos]; } + const Ptr &operator[](size_t pos) const { return m_entries[pos]; } + iterator begin() { return m_entries.begin(); } + iterator end() { return m_entries.end(); } + const_iterator begin() const { return m_entries.cbegin(); } + const_iterator end() const { return m_entries.cend(); } + reverse_iterator rbegin() { return m_entries.rbegin(); } + reverse_iterator rend() { return m_entries.rend(); } + const_reverse_iterator rbegin() const { return m_entries.crbegin(); } + const_reverse_iterator rend() const { return m_entries.crend(); } + bool empty() const { return m_entries.empty(); } + size_t size() const { return m_entries.size(); } void clear() { diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 4b8b4d8..95374f3 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -98,10 +98,10 @@ class NamespaceDefImpl : public DefinitionMixin virtual const QList &getMemberLists() const { return m_memberLists; } virtual MemberDef *getMemberByName(const QCString &) const; virtual MemberGroupSDict *getMemberGroupSDict() const { return memberGroupSDict; } - virtual ClassSDict *getClassSDict() const { return classSDict; } - virtual ClassSDict *getInterfaceSDict() const { return interfaceSDict; } - virtual ClassSDict *getStructSDict() const { return structSDict; } - virtual ClassSDict *getExceptionSDict() const { return exceptionSDict; } + virtual ClassLinkedRefMap getClasses() const { return classes; } + virtual ClassLinkedRefMap getInterfaces() const { return interfaces; } + virtual ClassLinkedRefMap getStructs() const { return structs; } + virtual ClassLinkedRefMap getExceptions() const { return exceptions; } virtual const NamespaceSDict *getNamespaceSDict() const { return namespaceSDict; } virtual QCString title() const; @@ -118,7 +118,7 @@ class NamespaceDefImpl : public DefinitionMixin void writeBriefDescription(OutputList &ol); void startMemberDeclarations(OutputList &ol); void endMemberDeclarations(OutputList &ol); - void writeClassDeclarations(OutputList &ol,const QCString &title,ClassSDict *d); + void writeClassDeclarations(OutputList &ol,const QCString &title,const ClassLinkedRefMap &d); void writeInlineClasses(OutputList &ol); void writeMemberGroups(OutputList &ol); void writeAuthorSection(OutputList &ol); @@ -126,7 +126,7 @@ class NamespaceDefImpl : public DefinitionMixin void endMemberDocumentation(OutputList &ol); void writeSummaryLinks(OutputList &ol) const; void addNamespaceAttributes(OutputList &ol); - void writeClassesToTagFile(FTextStream &,ClassSDict *d); + void writeClassesToTagFile(FTextStream &,const ClassLinkedRefMap &d); void writeNamespaceDeclarations(OutputList &ol,const QCString &title, bool isConstantGroup=false); @@ -141,10 +141,10 @@ class NamespaceDefImpl : public DefinitionMixin MemberSDict *m_allMembersDict = 0; QList m_memberLists; MemberGroupSDict *memberGroupSDict = 0; - ClassSDict *classSDict = 0; - ClassSDict *interfaceSDict = 0; - ClassSDict *structSDict = 0; - ClassSDict *exceptionSDict = 0; + ClassLinkedRefMap classes; + ClassLinkedRefMap interfaces; + ClassLinkedRefMap structs; + ClassLinkedRefMap exceptions; NamespaceSDict *namespaceSDict = 0; bool m_subGrouping = false; enum { NAMESPACE, MODULE, CONSTANT_GROUP, LIBRARY } m_type; @@ -214,14 +214,14 @@ class NamespaceDefAliasImpl : public DefinitionAliasMixin { return getNSAlias()->getMemberByName(name); } virtual MemberGroupSDict *getMemberGroupSDict() const { return getNSAlias()->getMemberGroupSDict(); } - virtual ClassSDict *getClassSDict() const - { return getNSAlias()->getClassSDict(); } - virtual ClassSDict *getInterfaceSDict() const - { return getNSAlias()->getInterfaceSDict(); } - virtual ClassSDict *getStructSDict() const - { return getNSAlias()->getStructSDict(); } - virtual ClassSDict *getExceptionSDict() const - { return getNSAlias()->getExceptionSDict(); } + virtual ClassLinkedRefMap getClasses() const + { return getNSAlias()->getClasses(); } + virtual ClassLinkedRefMap getInterfaces() const + { return getNSAlias()->getInterfaces(); } + virtual ClassLinkedRefMap getStructs() const + { return getNSAlias()->getStructs(); } + virtual ClassLinkedRefMap getExceptions() const + { return getNSAlias()->getExceptions(); } virtual const NamespaceSDict *getNamespaceSDict() const { return getNSAlias()->getNamespaceSDict(); } virtual QCString title() const @@ -263,10 +263,6 @@ NamespaceDefImpl::NamespaceDefImpl(const char *df,int dl,int dc, { setFileName(name); } - classSDict = new ClassSDict(17); - interfaceSDict = new ClassSDict(17); - structSDict = new ClassSDict(17); - exceptionSDict = new ClassSDict(17); namespaceSDict = new NamespaceSDict(17); m_innerCompounds = new SDict(17); m_allMembersDict = 0; @@ -295,10 +291,6 @@ NamespaceDefImpl::NamespaceDefImpl(const char *df,int dl,int dc, NamespaceDefImpl::~NamespaceDefImpl() { - delete classSDict; - delete interfaceSDict; - delete structSDict; - delete exceptionSDict; delete namespaceSDict; delete m_innerCompounds; delete memberGroupSDict; @@ -375,35 +367,25 @@ void NamespaceDefImpl::addInnerCompound(const Definition *d) void NamespaceDefImpl::insertClass(const ClassDef *cd) { - ClassSDict *d = classSDict; + ClassLinkedRefMap &d = classes; if (Config_getBool(OPTIMIZE_OUTPUT_SLICE)) { if (cd->compoundType()==ClassDef::Interface) { - d = interfaceSDict; + d = interfaces; } else if (cd->compoundType()==ClassDef::Struct) { - d = structSDict; + d = structs; } else if (cd->compoundType()==ClassDef::Exception) { - d = exceptionSDict; + d = exceptions; } } - if (d->find(cd->name())==0) - { - if (Config_getBool(SORT_BRIEF_DOCS)) - { - d->inSort(cd->name(),cd); - } - else - { - d->append(cd->name(),cd); - } - } + d.add(cd->name(),cd); } void NamespaceDefImpl::insertNamespace(const NamespaceDef *nd) @@ -621,26 +603,22 @@ void NamespaceDefImpl::writeTagFile(FTextStream &tagFile) break; case LayoutDocEntry::NamespaceClasses: { - if (classSDict) - writeClassesToTagFile(tagFile, classSDict); + writeClassesToTagFile(tagFile, classes); } break; case LayoutDocEntry::NamespaceInterfaces: { - if (interfaceSDict) - writeClassesToTagFile(tagFile, interfaceSDict); + writeClassesToTagFile(tagFile, interfaces); } break; case LayoutDocEntry::NamespaceStructs: { - if (structSDict) - writeClassesToTagFile(tagFile, structSDict); + writeClassesToTagFile(tagFile, structs); } break; case LayoutDocEntry::NamespaceExceptions: { - if (exceptionSDict) - writeClassesToTagFile(tagFile, exceptionSDict); + writeClassesToTagFile(tagFile, exceptions); } break; case LayoutDocEntry::MemberDecl: @@ -805,14 +783,14 @@ void NamespaceDefImpl::endMemberDocumentation(OutputList &ol) } } -void NamespaceDefImpl::writeClassDeclarations(OutputList &ol,const QCString &title,ClassSDict *d) +void NamespaceDefImpl::writeClassDeclarations(OutputList &ol,const QCString &title,const ClassLinkedRefMap &d) { - if (d) d->writeDeclaration(ol,0,title,TRUE); + d.writeDeclaration(ol,0,title,TRUE); } void NamespaceDefImpl::writeInlineClasses(OutputList &ol) { - if (classSDict) classSDict->writeDocumentation(ol,this); + classes.writeDocumentation(ol,this); } void NamespaceDefImpl::writeNamespaceDeclarations(OutputList &ol,const QCString &title, @@ -863,28 +841,28 @@ void NamespaceDefImpl::writeSummaryLinks(OutputList &ol) const SrcLangExt lang = getLanguage(); for (eli.toFirst();(lde=eli.current());++eli) { - if (lde->kind()==LayoutDocEntry::NamespaceClasses && classSDict && classSDict->declVisible()) + if (lde->kind()==LayoutDocEntry::NamespaceClasses && classes.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "nested-classes"; ol.writeSummaryLink(0,label,ls->title(lang),first); first=FALSE; } - else if (lde->kind()==LayoutDocEntry::NamespaceInterfaces && interfaceSDict && interfaceSDict->declVisible()) + else if (lde->kind()==LayoutDocEntry::NamespaceInterfaces && interfaces.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "interfaces"; ol.writeSummaryLink(0,label,ls->title(lang),first); first=FALSE; } - else if (lde->kind()==LayoutDocEntry::NamespaceStructs && structSDict && structSDict->declVisible()) + else if (lde->kind()==LayoutDocEntry::NamespaceStructs && structs.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "structs"; ol.writeSummaryLink(0,label,ls->title(lang),first); first=FALSE; } - else if (lde->kind()==LayoutDocEntry::NamespaceExceptions && exceptionSDict && exceptionSDict->declVisible()) + else if (lde->kind()==LayoutDocEntry::NamespaceExceptions && exceptions.declVisible()) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; QCString label = "exceptions"; @@ -930,11 +908,9 @@ void NamespaceDefImpl::addNamespaceAttributes(OutputList &ol) } } -void NamespaceDefImpl::writeClassesToTagFile(FTextStream &tagFile,ClassSDict *d) +void NamespaceDefImpl::writeClassesToTagFile(FTextStream &tagFile,const ClassLinkedRefMap &list) { - SDict::Iterator ci(*d); - ClassDef *cd; - for (ci.toFirst();(cd=ci.current());++ci) + for (const auto &cd : list) { if (cd->isLinkableInProject()) { @@ -996,25 +972,25 @@ void NamespaceDefImpl::writeDocumentation(OutputList &ol) case LayoutDocEntry::NamespaceClasses: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),classSDict); + writeClassDeclarations(ol,ls->title(lang),classes); } break; case LayoutDocEntry::NamespaceInterfaces: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),interfaceSDict); + writeClassDeclarations(ol,ls->title(lang),interfaces); } break; case LayoutDocEntry::NamespaceStructs: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),structSDict); + writeClassDeclarations(ol,ls->title(lang),structs); } break; case LayoutDocEntry::NamespaceExceptions: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - writeClassDeclarations(ol,ls->title(lang),exceptionSDict); + writeClassDeclarations(ol,ls->title(lang),exceptions); } break; case LayoutDocEntry::NamespaceNestedNamespaces: @@ -1456,22 +1432,23 @@ void NamespaceDefImpl::sortMemberLists() { if (ml->needsSorting()) { ml->sort(); ml->setNeedsSorting(FALSE); } } - if (classSDict) - { - classSDict->sort(); - } - if (interfaceSDict) - { - interfaceSDict->sort(); - } - if (structSDict) - { - structSDict->sort(); - } - if (exceptionSDict) + + + if (Config_getBool(SORT_BRIEF_DOCS)) { - exceptionSDict->sort(); + auto classComp = [](const ClassLinkedRefMap::Ptr &c1,const ClassLinkedRefMap::Ptr &c2) + { + return Config_getBool(SORT_BY_SCOPE_NAME) ? + qstricmp(c1->name(), c2->name())<0 : + qstricmp(c1->className(), c2->className())<0; + }; + + std::sort(classes.begin(), classes.end(), classComp); + std::sort(interfaces.begin(),interfaces.end(),classComp); + std::sort(structs.begin(), structs.end(), classComp); + std::sort(exceptions.begin(),exceptions.end(),classComp); } + if (namespaceSDict) { namespaceSDict->sort(); diff --git a/src/namespacedef.h b/src/namespacedef.h index 18171f7..e22f069 100644 --- a/src/namespacedef.h +++ b/src/namespacedef.h @@ -28,7 +28,7 @@ class MemberList; class ClassDef; class OutputList; -class ClassSDict; +class ClassLinkedRefMap; class MemberDef; class MemberGroupSDict; class NamespaceSDict; @@ -73,16 +73,16 @@ class NamespaceDef : public Definition virtual MemberGroupSDict *getMemberGroupSDict() const = 0; /*! Returns the classes contained in this namespace */ - virtual ClassSDict *getClassSDict() const = 0; + virtual ClassLinkedRefMap getClasses() const = 0; /*! Returns the Slice interfaces contained in this namespace */ - virtual ClassSDict *getInterfaceSDict() const = 0; + virtual ClassLinkedRefMap getInterfaces() const = 0; /*! Returns the Slice structs contained in this namespace */ - virtual ClassSDict *getStructSDict() const = 0; + virtual ClassLinkedRefMap getStructs() const = 0; /*! Returns the Slice exceptions contained in this namespace */ - virtual ClassSDict *getExceptionSDict() const = 0; + virtual ClassLinkedRefMap getExceptions() const = 0; /*! Returns the namespaces contained in this namespace */ virtual const NamespaceSDict *getNamespaceSDict() const = 0; diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index c2d120f..24f7482 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -1863,13 +1863,9 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd) m_output.closeList(); } - ClassSDict *cl = cd->getClassSDict(); - if (cl) { m_output.openList("inner"); - ClassSDict::Iterator cli(*cl); - const ClassDef *icd; - for (cli.toFirst();(icd=cli.current());++cli) + for (const auto &icd : cd->getClasses()) m_output.openHash() .addFieldQuotedString("name", icd->name()) .closeHash(); @@ -1970,13 +1966,9 @@ void PerlModGenerator::generatePerlModForNamespace(const NamespaceDef *nd) m_output.openHash() .addFieldQuotedString("name", nd->name()); - ClassSDict *cl = nd->getClassSDict(); - if (cl) { m_output.openList("classes"); - ClassSDict::Iterator cli(*cl); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : nd->getClasses()) m_output.openHash() .addFieldQuotedString("name", cd->name()) .closeHash(); @@ -2116,13 +2108,9 @@ void PerlModGenerator::generatePerlModForGroup(const GroupDef *gd) m_output.closeList(); } - ClassSDict *cl = gd->getClasses(); - if (cl) { m_output.openList("classes"); - ClassSDict::Iterator cli(*cl); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : gd->getClasses()) m_output.openHash() .addFieldQuotedString("name", cd->name()) .closeHash(); @@ -2214,10 +2202,8 @@ bool PerlModGenerator::generatePerlModOutput() m_output.add("$doxydocs=").openHash(); m_output.openList("classes"); - ClassSDict::Iterator cli(*Doxygen::classSDict); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) - generatePerlModForClass(cd); + for (const auto &cd : *Doxygen::classLinkedMap) + generatePerlModForClass(cd.get()); m_output.closeList(); m_output.openList("namespaces"); diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 17ed794..b96e4b5 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -519,10 +519,7 @@ void RTFGenerator::startIndexSection(IndexSections is) case isClassDocumentation: { //Compound Documentation - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - bool found=FALSE; - for (cli.toFirst();(cd=cli.current()) && !found;++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->isLinkableInProject() && cd->templateMaster()==0 && @@ -531,7 +528,7 @@ void RTFGenerator::startIndexSection(IndexSections is) ) { beginRTFChapter(); - found=TRUE; + break; } } } @@ -809,9 +806,7 @@ void RTFGenerator::endIndexSection(IndexSections is) break; case isClassDocumentation: { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd=0; - bool found=FALSE; + bool first=true; if (fortranOpt) { t << "{\\tc \\v " << theTranslator->trTypeDocumentation() << "}"<< endl; @@ -820,7 +815,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { t << "{\\tc \\v " << theTranslator->trClassDocumentation() << "}"<< endl; } - for (cli.toFirst();(cd=cli.current()) && !found;++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->isLinkableInProject() && cd->templateMaster()==0 && @@ -829,22 +824,11 @@ void RTFGenerator::endIndexSection(IndexSections is) ) { t << "\\par " << rtf_Style_Reset << endl; - t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; - t << cd->getOutputFileBase(); - t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; - found=TRUE; - } - } - for (;(cd=cli.current());++cli) - { - if (cd->isLinkableInProject() && - cd->templateMaster()==0 && - !cd->isEmbeddedInOuterScope() && - !cd->isAlias() - ) - { - t << "\\par " << rtf_Style_Reset << endl; - beginRTFSection(); + if (!first) + { + beginRTFSection(); + } + first=false; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << cd->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -863,31 +847,19 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (fd->isLinkableInProject()) { - if (isFirst) + t << "\\par " << rtf_Style_Reset << endl; + if (!isFirst) { - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; - t << fd->getOutputFileBase(); - t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; - if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) - { - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"" << fd->getSourceFileBase() << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; - } - isFirst=FALSE; + beginRTFSection(); } - else + isFirst=FALSE; + t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; + t << fd->getOutputFileBase(); + t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; + if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) { t << "\\par " << rtf_Style_Reset << endl; - beginRTFSection(); - t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; - t << fd->getOutputFileBase(); - t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; - if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) - { - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"" << fd->getSourceFileBase() << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; - } + t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"" << fd->getSourceFileBase() << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; } } } diff --git a/src/searchindex.cpp b/src/searchindex.cpp index 0464cb4..209cdea 100644 --- a/src/searchindex.cpp +++ b/src/searchindex.cpp @@ -738,36 +738,34 @@ void createJavaScriptSearchIndex() // add symbols to letter -> symbol list map // index classes - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for (;(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { uint letter = getUtf8CodeToLower(cd->localName(),0); if (cd->isLinkable() && isId(letter)) { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,cd); + g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,cd.get()); if (sliceOpt) { if (cd->compoundType()==ClassDef::Interface) { - g_searchIndexInfo[SEARCH_INDEX_INTERFACES].symbolList.append(letter,cd); + g_searchIndexInfo[SEARCH_INDEX_INTERFACES].symbolList.append(letter,cd.get()); } else if (cd->compoundType()==ClassDef::Struct) { - g_searchIndexInfo[SEARCH_INDEX_STRUCTS].symbolList.append(letter,cd); + g_searchIndexInfo[SEARCH_INDEX_STRUCTS].symbolList.append(letter,cd.get()); } else if (cd->compoundType()==ClassDef::Exception) { - g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].symbolList.append(letter,cd); + g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].symbolList.append(letter,cd.get()); } else // cd->compoundType()==ClassDef::Class { - g_searchIndexInfo[SEARCH_INDEX_CLASSES].symbolList.append(letter,cd); + g_searchIndexInfo[SEARCH_INDEX_CLASSES].symbolList.append(letter,cd.get()); } } else // non slice optimisation: group all types under classes { - g_searchIndexInfo[SEARCH_INDEX_CLASSES].symbolList.append(letter,cd); + g_searchIndexInfo[SEARCH_INDEX_CLASSES].symbolList.append(letter,cd.get()); } } } diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index bfbe25e..f06d6ee 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -1264,13 +1264,9 @@ I think the hurdles are: inner_refid (unless I'm missing a method that would uniformly return the correct refid for all types). */ -static void writeInnerClasses(const ClassSDict *cl, struct Refid outer_refid) +static void writeInnerClasses(const ClassLinkedRefMap &cl, struct Refid outer_refid) { - if (!cl) return; - - ClassSDict::Iterator cli(*cl); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : cl) { if (!cd->isHidden() && !cd->isAnonymous()) { @@ -2018,7 +2014,7 @@ static void generateSqlite3ForClass(const ClassDef *cd) } // + list of inner classes - writeInnerClasses(cd->getClassSDict(),refid); + writeInnerClasses(cd->getClasses(),refid); // + template argument list(s) writeTemplateList(cd); @@ -2082,7 +2078,7 @@ static void generateSqlite3ForNamespace(const NamespaceDef *nd) step(compounddef_insert); // + contained class definitions - writeInnerClasses(nd->getClassSDict(),refid); + writeInnerClasses(nd->getClasses(),refid); // + contained namespace definitions writeInnerNamespaces(nd->getNamespaceSDict(),refid); @@ -2244,10 +2240,7 @@ static void generateSqlite3ForFile(const FileDef *fd) } // + contained class definitions - if (fd->getClassSDict()) - { - writeInnerClasses(fd->getClassSDict(),refid); - } + writeInnerClasses(fd->getClasses(),refid); // + contained namespace definitions if (fd->getNamespaceSDict()) @@ -2555,12 +2548,10 @@ void generateSqlite3() recordMetadata(); // + classes - ClassSDict::Iterator cli(*Doxygen::classSDict); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + for (const auto &cd : *Doxygen::classLinkedMap) { msg("Generating Sqlite3 output for class %s\n",cd->name().data()); - generateSqlite3ForClass(cd); + generateSqlite3ForClass(cd.get()); } // + namespaces diff --git a/src/util.cpp b/src/util.cpp index ef1e709..2ec2ff0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -480,7 +480,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName, ClassDef *getClass(const char *n) { if (n==0 || n[0]=='\0') return 0; - return Doxygen::classSDict->find(n); + return Doxygen::classLinkedMap->find(n); } NamespaceDef *getResolvedNamespace(const char *name) @@ -6980,34 +6980,29 @@ bool namespaceHasNestedClass(const NamespaceDef *nd,bool filterClasses,ClassDef: } } - const ClassSDict *d = nd->getClassSDict(); + ClassLinkedRefMap list = nd->getClasses(); if (filterClasses) { if (ct == ClassDef::Interface) { - d = nd->getInterfaceSDict(); + list = nd->getInterfaces(); } else if (ct == ClassDef::Struct) { - d = nd->getStructSDict(); + list = nd->getStructs(); } else if (ct == ClassDef::Exception) { - d = nd->getExceptionSDict(); + list = nd->getExceptions(); } } - if (d) + for (const auto &cd : list) { - ClassSDict::Iterator cli(*d); - const ClassDef *cd; - for (;(cd=cli.current());++cli) + if (cd->isLinkableInProject() && cd->templateMaster()==0) { - if (cd->isLinkableInProject() && cd->templateMaster()==0) - { - //printf("name().data(),includeClasses); - return TRUE; - } + //printf("name().data(),includeClasses); + return TRUE; } } return FALSE; diff --git a/src/util.h b/src/util.h index 2c088c4..4afc603 100644 --- a/src/util.h +++ b/src/util.h @@ -48,7 +48,6 @@ class OutputList; class OutputDocInterface; class MemberDef; class ExampleSDict; -class ClassSDict; class GroupDef; class NamespaceSDict; class ClassList; diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp index 93afb4b..dd208aa 100644 --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -174,10 +174,8 @@ static void createSVG() // Brief descriptions for entities are shown too. void VhdlDocGen::writeOverview() { - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; bool found=FALSE; - for ( ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS ) { @@ -201,14 +199,14 @@ void VhdlDocGen::writeOverview() startDot(t); - for (cli.toFirst() ; (cd=cli.current()) ; ++cli ) + for (const auto &cd : *Doxygen::classLinkedMap) { if ((VhdlDocGen::VhdlClasses)cd->protection()!=VhdlDocGen::ENTITYCLASS ) { continue; } - QList* port= getPorts(cd); + QList* port= getPorts(cd.get()); if (port==0) { continue; @@ -221,12 +219,11 @@ void VhdlDocGen::writeOverview() } startTable(t,cd->name()); - writeClassToDot(t,cd); + writeClassToDot(t,cd.get()); writeTable(port,t); endTable(t); - // writeVhdlPortToolTip(t,port,cd); - writeVhdlEntityToolTip(t,cd); + writeVhdlEntityToolTip(t,cd.get()); delete port; for (const auto &bcd : cd->baseClasses()) @@ -637,7 +634,7 @@ const char* VhdlDocGen::findKeyWord(const QCString& kw) ClassDef *VhdlDocGen::getClass(const char *name) { if (name==0 || name[0]=='\0') return 0; - return Doxygen::classSDict->find(QCString(name).stripWhiteSpace()); + return Doxygen::classLinkedMap->find(QCString(name).stripWhiteSpace()); } ClassDef* VhdlDocGen::getPackageName(const QCString & name) @@ -974,12 +971,10 @@ void VhdlDocGen::writeInlineClassLink(const ClassDef* cd ,OutputList& ol) */ void VhdlDocGen::findAllArchitectures(QList& qll,const ClassDef *cd) { - ClassDef *citer; - ClassSDict::Iterator cli(*Doxygen::classSDict); - for ( ; (citer=cli.current()) ; ++cli ) + for (const auto &citer : *Doxygen::classLinkedMap) { QCString jj=citer->className(); - if (cd != citer && jj.contains('-')!=-1) + if (cd != citer.get() && jj.contains('-')!=-1) { QCStringList ql=QCStringList::split("-",jj); QCString temp=ql[1]; @@ -992,13 +987,10 @@ void VhdlDocGen::findAllArchitectures(QList& qll,const ClassDef *cd) }// for }//findAllArchitectures -ClassDef* VhdlDocGen::findArchitecture(const ClassDef *cd) +const ClassDef* VhdlDocGen::findArchitecture(const ClassDef *cd) { - ClassDef *citer; QCString nn=cd->name(); - ClassSDict::Iterator cli(*Doxygen::classSDict); - - for ( ; (citer=cli.current()) ; ++cli ) + for (const auto &citer : *Doxygen::classLinkedMap) { QCString jj=citer->name(); QCStringList ql=QCStringList::split(":",jj); @@ -1006,7 +998,7 @@ ClassDef* VhdlDocGen::findArchitecture(const ClassDef *cd) { if (ql[0]==nn ) { - return citer; + return citer.get(); } } } @@ -2570,21 +2562,18 @@ QCString VhdlDocGen::parseForBinding(QCString & entity,QCString & arch) - // find class with upper/lower letters - ClassDef* VhdlDocGen::findVhdlClass(const char *className ) +// find class with upper/lower letters +ClassDef* VhdlDocGen::findVhdlClass(const char *className ) +{ + for (const auto &cd : *Doxygen::classLinkedMap) { - - ClassSDict::Iterator cli(*Doxygen::classSDict); - ClassDef *cd; - for (;(cd=cli.current());++cli) - { - if (qstricmp(className,cd->name().data())==0) - { - return cd; - } - } - return 0; + if (qstricmp(className,cd->name().data())==0) + { + return cd.get(); + } } + return 0; +} /* @@ -2624,8 +2613,8 @@ void VhdlDocGen::computeVhdlComponentRelations() ClassDefMutable *classEntity= toClassDefMutable(VhdlDocGen::findVhdlClass(entity.data())); inst=VhdlDocGen::getIndexWord(cur->args.data(),0); - ClassDefMutable *cd=toClassDefMutable(Doxygen::classSDict->find(inst)); - ClassDefMutable *ar=toClassDefMutable(Doxygen::classSDict->find(cur->args)); + ClassDefMutable *cd=toClassDefMutable(Doxygen::classLinkedMap->find(inst)); + ClassDefMutable *ar=toClassDefMutable(Doxygen::classLinkedMap->find(cur->args)); if (cd==0) { diff --git a/src/vhdldocgen.h b/src/vhdldocgen.h index b98ea44..22751c5 100644 --- a/src/vhdldocgen.h +++ b/src/vhdldocgen.h @@ -215,8 +215,8 @@ class VhdlDocGen static void parseUCF(const char* input,Entry* entity,QCString f,bool vendor); - static ClassDef* findArchitecture(const ClassDef *cd); - static ClassDef* findArchitecture(QCString identifier, QCString entity_name); + static const ClassDef* findArchitecture(const ClassDef *cd); + //static const ClassDef* findArchitecture(QCString identifier, QCString entity_name); static void correctMemberProperties(MemberDefMutable *md); diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 1993c1e..68ecdf0 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -1124,27 +1124,22 @@ static void writeListOfAllMembers(const ClassDef *cd,FTextStream &t) t << " " << endl; } -static void writeInnerClasses(const ClassSDict *cl,FTextStream &t) +static void writeInnerClasses(const ClassLinkedRefMap &cl,FTextStream &t) { - if (cl) + for (const auto &cd : cl) { - ClassSDict::Iterator cli(*cl); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) + if (!cd->isHidden() && !cd->isAnonymous()) { - if (!cd->isHidden() && !cd->isAnonymous()) + t << " protection()) { - t << " protection()) - { - case Public: t << "public"; break; - case Protected: t << "protected"; break; - case Private: t << "private"; break; - case Package: t << "package"; break; - } - t << "\">" << convertToXML(cd->name()) << "" << endl; + case Public: t << "public"; break; + case Protected: t << "protected"; break; + case Private: t << "private"; break; + case Package: t << "package"; break; } + t << "\">" << convertToXML(cd->name()) << "" << endl; } } } @@ -1363,7 +1358,7 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) } } - writeInnerClasses(cd->getClassSDict(),t); + writeInnerClasses(cd->getClasses(),t); writeTemplateList(cd,t); if (cd->getMemberGroupSDict()) @@ -1467,7 +1462,7 @@ static void generateXMLForNamespace(const NamespaceDef *nd,FTextStream &ti) writeXMLString(t,nd->name()); t << "" << endl; - writeInnerClasses(nd->getClassSDict(),t); + writeInnerClasses(nd->getClasses(),t); writeInnerNamespaces(nd->getNamespaceSDict(),t); if (nd->getMemberGroupSDict()) @@ -1598,10 +1593,7 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) t << " " << endl; } - if (fd->getClassSDict()) - { - writeInnerClasses(fd->getClassSDict(),t); - } + writeInnerClasses(fd->getClasses(),t); if (fd->getNamespaceSDict()) { writeInnerNamespaces(fd->getNamespaceSDict(),t); @@ -1965,23 +1957,10 @@ void generateXML() t << "xml:lang=\"" << theTranslator->trISOLang() << "\""; t << ">" << endl; + for (const auto &cd : *Doxygen::classLinkedMap) { - ClassSDict::Iterator cli(*Doxygen::classSDict); - const ClassDef *cd; - for (cli.toFirst();(cd=cli.current());++cli) - { - generateXMLForClass(cd,t); - } + generateXMLForClass(cd.get(),t); } - //{ - // ClassSDict::Iterator cli(Doxygen::hiddenClasses); - // ClassDef *cd; - // for (cli.toFirst();(cd=cli.current());++cli) - // { - // msg("Generating XML output for class %s\n",cd->name().data()); - // generateXMLForClass(cd,t); - // } - //} NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict); const NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) -- cgit v0.12