diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-12-30 20:12:09 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-12-30 20:12:09 (GMT) |
commit | 2bb3a8790770f0aa05cf0b7c2d13e2b5e7e27afe (patch) | |
tree | ba0841c49e36701c4349f0d19632a57ad0118b9b | |
parent | 34ac30b4e46023e0c86247dac4d47fce0ae1d4f8 (diff) | |
download | Doxygen-2bb3a8790770f0aa05cf0b7c2d13e2b5e7e27afe.zip Doxygen-2bb3a8790770f0aa05cf0b7c2d13e2b5e7e27afe.tar.gz Doxygen-2bb3a8790770f0aa05cf0b7c2d13e2b5e7e27afe.tar.bz2 |
Refactoring: change MemberGroupSDict to MemberGroupList
-rw-r--r-- | src/classdef.cpp | 159 | ||||
-rw-r--r-- | src/classdef.h | 4 | ||||
-rw-r--r-- | src/context.cpp | 56 | ||||
-rw-r--r-- | src/context.h | 12 | ||||
-rw-r--r-- | src/dotnode.cpp | 7 | ||||
-rw-r--r-- | src/filedef.cpp | 93 | ||||
-rw-r--r-- | src/filedef.h | 3 | ||||
-rw-r--r-- | src/groupdef.cpp | 57 | ||||
-rw-r--r-- | src/groupdef.h | 4 | ||||
-rw-r--r-- | src/index.cpp | 2 | ||||
-rw-r--r-- | src/membergroup.h | 19 | ||||
-rw-r--r-- | src/memberlist.cpp | 22 | ||||
-rw-r--r-- | src/memberlist.h | 4 | ||||
-rw-r--r-- | src/namespacedef.cpp | 72 | ||||
-rw-r--r-- | src/namespacedef.h | 4 | ||||
-rw-r--r-- | src/perlmodgen.cpp | 69 | ||||
-rw-r--r-- | src/sqlite3gen.cpp | 42 | ||||
-rw-r--r-- | src/util.cpp | 76 | ||||
-rw-r--r-- | src/util.h | 3 | ||||
-rw-r--r-- | src/xmlgen.cpp | 42 |
20 files changed, 262 insertions, 488 deletions
diff --git a/src/classdef.cpp b/src/classdef.cpp index b3eb353..0653203 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -223,7 +223,7 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable> virtual QCString className() const; virtual MemberList *getMemberList(MemberListType lt) const; virtual const QList<MemberList> &getMemberLists() const; - virtual MemberGroupSDict *getMemberGroupSDict() const; + virtual const MemberGroupList &getMemberGroups() const; virtual QDict<int> *getTemplateBaseClassNames() const; virtual ClassDef *getVariableInstance(const char *templSpec) const; virtual bool isUsedOnly() const; @@ -495,8 +495,8 @@ class ClassDefAliasImpl : public DefinitionAliasMixin<ClassDef> { return getCdAlias()->getMemberList(lt); } virtual const QList<MemberList> &getMemberLists() const { return getCdAlias()->getMemberLists(); } - virtual MemberGroupSDict *getMemberGroupSDict() const - { return getCdAlias()->getMemberGroupSDict(); } + virtual const MemberGroupList &getMemberGroups() const + { return getCdAlias()->getMemberGroups(); } virtual QDict<int> *getTemplateBaseClassNames() const { return getCdAlias()->getTemplateBaseClassNames(); } virtual ClassDef *getVariableInstance(const char *templSpec) const @@ -677,7 +677,7 @@ class ClassDefImpl::IMPL QList<MemberList> memberLists; /* user defined member groups */ - MemberGroupSDict *memberGroupSDict = 0; + MemberGroupList memberGroups; /*! Is this an abstract class? */ bool isAbstract = false; @@ -741,7 +741,6 @@ void ClassDefImpl::IMPL::init(const char *defFileName, const char *name, usedByImplClassDict=0; usesIntfClassDict=0; constraintClassDict=0; - memberGroupSDict = 0; subGrouping=Config_getBool(SUBGROUPING); templateInstances = 0; variableInstances = 0; @@ -787,7 +786,6 @@ ClassDefImpl::IMPL::~IMPL() delete usesIntfClassDict; delete constraintClassDict; delete incInfo; - delete memberGroupSDict; delete templateInstances; delete variableInstances; delete templBaseClassNames; @@ -861,22 +859,17 @@ void ClassDefImpl::addMembersToMemberGroup() { if ((ml->listType()&MemberListType_detailedLists)==0) { - ::addMembersToMemberGroup(ml,&m_impl->memberGroupSDict,this); + ::addMembersToMemberGroup(ml,&m_impl->memberGroups,this); } } // add members inside sections to their groups - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if (mg->allMembersInSameSection() && m_impl->subGrouping) { - if (mg->allMembersInSameSection() && m_impl->subGrouping) - { - //printf("addToDeclarationSection(%s)\n",mg->header().data()); - mg->addToDeclarationSection(); - } + //printf("addToDeclarationSection(%s)\n",mg->header().data()); + mg->addToDeclarationSection(); } } } @@ -1194,27 +1187,17 @@ void ClassDefImpl::computeAnchors() } } - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->setAnchors(); - } + mg->setAnchors(); } } void ClassDefImpl::distributeMemberGroupDocumentation() { - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->distributeMemberGroupDocumentation(); - } + mg->distributeMemberGroupDocumentation(); } } @@ -1222,14 +1205,9 @@ void ClassDefImpl::findSectionsInDocumentation() { docFindSections(briefDescription(),this,docFile()); docFindSections(documentation(),this,docFile()); - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->findSectionsInDocumentation(this); - } + mg->findSectionsInDocumentation(this); } QListIterator<MemberList> mli(m_impl->memberLists); MemberList *ml; @@ -2004,22 +1982,16 @@ void ClassDefImpl::writeIncludeFiles(OutputList &ol) const void ClassDefImpl::writeMemberGroups(OutputList &ol,bool showInline) const { // write user defined member groups - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - m_impl->memberGroupSDict->sort(); - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if (!mg->allMembersInSameSection() || !m_impl->subGrouping) // group is in its own section { - if (!mg->allMembersInSameSection() || !m_impl->subGrouping) // group is in its own section - { - mg->writeDeclarations(ol,this,0,0,0,showInline); - } - else // add this group to the corresponding member section - { - //printf("addToDeclarationSection(%s)\n",mg->header().data()); - //mg->addToDeclarationSection(); - } + mg->writeDeclarations(ol,this,0,0,0,showInline); + } + else // add this group to the corresponding member section + { + //printf("addToDeclarationSection(%s)\n",mg->header().data()); + //mg->addToDeclarationSection(); } } } @@ -2230,14 +2202,9 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) break; case LayoutDocEntry::MemberGroups: { - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->writeTagFile(tagFile); - } + mg->writeTagFile(tagFile); } } break; @@ -3340,15 +3307,10 @@ void ClassDefImpl::writeDeclaration(OutputList &ol,const MemberDef *md,bool inGr ol.endMemberItem(); // write user defined member groups - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->setInGroup(inGroup); - mg->writePlainDeclarations(ol,this,0,0,0,inheritedFrom,inheritId); - } + mg->setInGroup(inGroup); + mg->writePlainDeclarations(ol,this,0,0,0,inheritedFrom,inheritId); } QListIterator<LayoutDocEntry> eli( @@ -4232,14 +4194,9 @@ void ClassDefImpl::addListReferences() this ); } - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->addListReferences(this); - } + mg->addListReferences(this); } QListIterator<MemberList> mli(m_impl->memberLists); MemberList *ml; @@ -4371,11 +4328,9 @@ int ClassDefImpl::countMemberDeclarations(MemberListType lt,const ClassDef *inhe //printf("-> ml2=%d\n",ml2->numDecMembers()); } // also include grouped members that have their own section in the class (see bug 722759) - if (inheritedFrom && m_impl->memberGroupSDict) + if (inheritedFrom) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_impl->memberGroups) { count+=mg->countGroupedInheritedMembers(lt); if (lt2!=1) count+=mg->countGroupedInheritedMembers((MemberListType)lt2); @@ -4409,14 +4364,9 @@ void ClassDefImpl::setAnonymousEnumType() } else if (lde->kind()==LayoutDocEntry::MemberGroups) { - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->setAnonymousEnumType(); - } + mg->setAnonymousEnumType(); } } } @@ -4431,15 +4381,10 @@ void ClassDefImpl::countMembers() ml->countDecMembers(); ml->countDocMembers(); } - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->countDecMembers(); - mg->countDocMembers(); - } + mg->countDecMembers(); + mg->countDocMembers(); } } @@ -4557,18 +4502,13 @@ int ClassDefImpl::countMembersIncludingGrouped(MemberListType lt, count=ml->countInheritableMembers(inheritedFrom); } //printf("%s:countMembersIncludingGrouped: count=%d\n",name().data(),count); - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + bool hasOwnSection = !mg->allMembersInSameSection() || + !m_impl->subGrouping; // group is in its own section + if ((additional && hasOwnSection) || (!additional && !hasOwnSection)) { - bool hasOwnSection = !mg->allMembersInSameSection() || - !m_impl->subGrouping; // group is in its own section - if ((additional && hasOwnSection) || (!additional && !hasOwnSection)) - { - count+=mg->countGroupedInheritedMembers(lt); - } + count+=mg->countGroupedInheritedMembers(lt); } } //printf("%s:countMembersIncludingGrouped(lt=%d,%s)=%d\n", @@ -4673,16 +4613,11 @@ void ClassDefImpl::addGroupedInheritedMembers(OutputList &ol,MemberListType lt, const ClassDef *inheritedFrom,const QCString &inheritId) const { //printf("** %s::addGroupedInheritedMembers(%p) inheritId=%s\n",name().data(),m_impl->memberGroupSDict,inheritId.data()); - if (m_impl->memberGroupSDict) + for (const auto &mg : m_impl->memberGroups) { - MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if (!mg->allMembersInSameSection() || !m_impl->subGrouping) // group is in its own section { - if (!mg->allMembersInSameSection() || !m_impl->subGrouping) // group is in its own section - { - mg->addGroupedInheritedMembers(ol,this,lt,inheritedFrom,inheritId); - } + mg->addGroupedInheritedMembers(ol,this,lt,inheritedFrom,inheritId); } } } @@ -4884,9 +4819,9 @@ const QList<MemberList> &ClassDefImpl::getMemberLists() const return m_impl->memberLists; } -MemberGroupSDict *ClassDefImpl::getMemberGroupSDict() const +const MemberGroupList &ClassDefImpl::getMemberGroups() const { - return m_impl->memberGroupSDict; + return m_impl->memberGroups; } void ClassDefImpl::setNamespace(NamespaceDef *nd) diff --git a/src/classdef.h b/src/classdef.h index 217002d..408c8d2 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -28,6 +28,7 @@ #include "containers.h" #include "definition.h" #include "arguments.h" +#include "membergroup.h" struct Argument; class MemberDef; @@ -45,7 +46,6 @@ class ExampleSDict; class MemberNameInfoLinkedMap; class UsesClassDict; class ConstraintClassDict; -class MemberGroupSDict; class QTextStream; class PackageDef; class GroupDef; @@ -321,7 +321,7 @@ class ClassDef : public Definition virtual const QList<MemberList> &getMemberLists() const = 0; /** Returns the member groups defined for this class */ - virtual MemberGroupSDict *getMemberGroupSDict() const = 0; + virtual const MemberGroupList &getMemberGroups() const = 0; virtual QDict<int> *getTemplateBaseClassNames() const = 0; diff --git a/src/context.cpp b/src/context.cpp index 0e531b0..58a297a 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -2500,9 +2500,9 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> Cachable &cache = getCache(); if (!cache.memberGroups) { - if (m_classDef->getMemberGroupSDict()) + if (!m_classDef->getMemberGroups().empty()) { - cache.memberGroups.reset(MemberGroupListContext::alloc(m_classDef,relPathAsString(),m_classDef->getMemberGroupSDict(),m_classDef->subGrouping())); + cache.memberGroups.reset(MemberGroupListContext::alloc(m_classDef,relPathAsString(),m_classDef->getMemberGroups(),m_classDef->subGrouping())); } else { @@ -2848,9 +2848,9 @@ class NamespaceContext::Private : public DefinitionContext<NamespaceContext::Pri Cachable &cache = getCache(); if (!cache.memberGroups) { - if (m_namespaceDef->getMemberGroupSDict()) + if (!m_namespaceDef->getMemberGroups().empty()) { - cache.memberGroups.reset(MemberGroupListContext::alloc(m_namespaceDef,relPathAsString(),m_namespaceDef->getMemberGroupSDict(),m_namespaceDef->subGrouping())); + cache.memberGroups.reset(MemberGroupListContext::alloc(m_namespaceDef,relPathAsString(),m_namespaceDef->getMemberGroups(),m_namespaceDef->subGrouping())); } else { @@ -3291,9 +3291,9 @@ class FileContext::Private : public DefinitionContext<FileContext::Private> Cachable &cache = getCache(); if (!cache.memberGroups) { - if (m_fileDef->getMemberGroupSDict()) + if (!m_fileDef->getMemberGroups().empty()) { - cache.memberGroups.reset(MemberGroupListContext::alloc(m_fileDef,relPathAsString(),m_fileDef->getMemberGroupSDict(),m_fileDef->subGrouping())); + cache.memberGroups.reset(MemberGroupListContext::alloc(m_fileDef,relPathAsString(),m_fileDef->getMemberGroups(),m_fileDef->subGrouping())); } else { @@ -5588,9 +5588,9 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private> Cachable &cache = getCache(); if (!cache.memberGroups) { - if (m_groupDef->getMemberGroupSDict()) + if (!m_groupDef->getMemberGroups().empty()) { - cache.memberGroups.reset(MemberGroupListContext::alloc(m_groupDef,relPathAsString(),m_groupDef->getMemberGroupSDict(),m_groupDef->subGrouping())); + cache.memberGroups.reset(MemberGroupListContext::alloc(m_groupDef,relPathAsString(),m_groupDef->getMemberGroups(),m_groupDef->subGrouping())); } else { @@ -8895,7 +8895,7 @@ MemberGroupListContext::MemberGroupListContext() : RefCountedContext("MemberGrou p = new Private; } -MemberGroupListContext::MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupList &list) : RefCountedContext("MemberGroupListContext") +MemberGroupListContext::MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupRefList &list) : RefCountedContext("MemberGroupListContext") { p = new Private; for (const auto &mg : list) @@ -8904,19 +8904,14 @@ MemberGroupListContext::MemberGroupListContext(const Definition *def,const QCStr } } -MemberGroupListContext::MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupSDict *dict,bool subGrouping) : RefCountedContext("MemberGroupListContext") +MemberGroupListContext::MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupList &list,bool subGrouping) : RefCountedContext("MemberGroupListContext") { p = new Private; - if (dict) + for (const auto &mg : list) { - MemberGroupSDict::Iterator di(*dict); - const MemberGroup *mg; - for (di.toFirst();(mg=di.current());++di) + if (!mg->allMembersInSameSection() || !subGrouping) { - if (!mg->allMembersInSameSection() || !subGrouping) - { - p->addMemberGroup(def,relPath,mg); - } + p->addMemberGroup(def,relPath,mg.get()); } } } @@ -9184,24 +9179,21 @@ class InheritedMemberInfoListContext::Private : public GenericNodeListContext void addMemberGroupsOfClass(const ClassDef *inheritedFrom, const ClassDef *cd,MemberListType lt,MemberList *combinedList) { - if (cd->getMemberGroupSDict()) + // TODO: why this there no addMemberGroupsOfNamespace, addMembersGroupsOfFile, + // addMemberGroupsOfGroup? + for (const auto &mg: cd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if (mg->members() && (!mg->allMembersInSameSection() || !cd->subGrouping())) // group is in its own section { - if (mg->members() && (!mg->allMembersInSameSection() || !cd->subGrouping())) // group is in its own section + MemberListIterator li(*mg->members()); + MemberDef *md; + for (li.toFirst();(md=li.current());++li) { - MemberListIterator li(*mg->members()); - MemberDef *md; - for (li.toFirst();(md=li.current());++li) + if (lt==md->getSectionList(mg->container())->listType() && + !md->isReimplementedBy(inheritedFrom) && + md->isBriefSectionVisible()) { - if (lt==md->getSectionList(mg->container())->listType() && - !md->isReimplementedBy(inheritedFrom) && - md->isBriefSectionVisible()) - { - combinedList->append(md); - } + combinedList->append(md); } } } diff --git a/src/context.h b/src/context.h index 8e3c0fb..9b4b0fe 100644 --- a/src/context.h +++ b/src/context.h @@ -49,8 +49,6 @@ struct Argument; class ArgumentList; class MemberNameInfoLinkedMap; class MemberInfo; -class MemberGroup; -class MemberGroupSDict; class DotNode; class DotGfxHierarchyTable; @@ -1006,10 +1004,10 @@ class MemberGroupListContext : public RefCountedContext, public TemplateListIntf public: static MemberGroupListContext *alloc() { return new MemberGroupListContext; } - static MemberGroupListContext *alloc(const Definition *def,const QCString &relPath,const MemberGroupList &list) + static MemberGroupListContext *alloc(const Definition *def,const QCString &relPath,const MemberGroupRefList &list) { return new MemberGroupListContext(def,relPath,list); } - static MemberGroupListContext *alloc(const Definition *def,const QCString &relPath,const MemberGroupSDict *dict,bool subGrouping) - { return new MemberGroupListContext(def,relPath,dict,subGrouping); } + static MemberGroupListContext *alloc(const Definition *def,const QCString &relPath,const MemberGroupList &list,bool subGrouping) + { return new MemberGroupListContext(def,relPath,list,subGrouping); } // TemplateListIntf virtual uint count() const; @@ -1020,8 +1018,8 @@ class MemberGroupListContext : public RefCountedContext, public TemplateListIntf private: MemberGroupListContext(); - MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupList &list); - MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupSDict *mgDict,bool subGrouping); + MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupRefList &list); + MemberGroupListContext(const Definition *def,const QCString &relPath,const MemberGroupList &list,bool subGrouping); ~MemberGroupListContext(); class Private; Private *p; diff --git a/src/dotnode.cpp b/src/dotnode.cpp index b56e258..06de5f4 100644 --- a/src/dotnode.cpp +++ b/src/dotnode.cpp @@ -477,12 +477,9 @@ void DotNode::writeBox(FTextStream &t, writeBoxMemberList(t,'-',m_classDef->getMemberList(MemberListType_priStaticMethods),m_classDef,TRUE); writeBoxMemberList(t,'-',m_classDef->getMemberList(MemberListType_priSlots),m_classDef); } - if (m_classDef->getLanguage()!=SrcLangExt_Fortran && - m_classDef->getMemberGroupSDict()) + if (m_classDef->getLanguage()!=SrcLangExt_Fortran) { - MemberGroupSDict::Iterator mgdi(*m_classDef->getMemberGroupSDict()); - MemberGroup *mg; - for (mgdi.toFirst();(mg=mgdi.current());++mgdi) + for (const auto &mg : m_classDef->getMemberGroups()) { if (mg->members()) { diff --git a/src/filedef.cpp b/src/filedef.cpp index e8d6066..49fb4d9 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -85,7 +85,7 @@ class FileDefImpl : public DefinitionMixin<FileDef> virtual void getAllIncludeFilesRecursively(StringVector &incFiles) const; virtual MemberList *getMemberList(MemberListType lt) const; virtual const QList<MemberList> &getMemberLists() const { return m_memberLists; } - virtual MemberGroupSDict *getMemberGroupSDict() const { return m_memberGroupSDict; } + virtual const MemberGroupList &getMemberGroups() const { return m_memberGroups; } virtual NamespaceLinkedRefMap getNamespaces() const { return m_namespaces; } virtual ClassLinkedRefMap getClasses() const { return m_classes; } virtual QCString title() const; @@ -169,7 +169,7 @@ class FileDefImpl : public DefinitionMixin<FileDef> PackageDef *m_package; DirDef *m_dir; QList<MemberList> m_memberLists; - MemberGroupSDict *m_memberGroupSDict; + MemberGroupList m_memberGroups; NamespaceLinkedRefMap m_namespaces; ClassLinkedRefMap m_classes; ClassLinkedRefMap m_interfaces; @@ -241,7 +241,6 @@ FileDefImpl::FileDefImpl(const char *p,const char *nm, m_docname.prepend(stripFromPath(m_path.copy())); } setLanguage(getLanguageFromFileName(name())); - m_memberGroupSDict = 0; acquireFileVersion(); m_subGrouping=Config_getBool(SUBGROUPING); } @@ -255,7 +254,6 @@ FileDefImpl::~FileDefImpl() delete m_includedByList; delete m_srcDefDict; delete m_srcMemberDict; - delete m_memberGroupSDict; } void FileDefImpl::setDiskName(const QCString &name) @@ -284,14 +282,9 @@ void FileDefImpl::computeAnchors() void FileDefImpl::distributeMemberGroupDocumentation() { //printf("FileDefImpl::distributeMemberGroupDocumentation()\n"); - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->distributeMemberGroupDocumentation(); - } + mg->distributeMemberGroupDocumentation(); } } @@ -299,14 +292,9 @@ void FileDefImpl::findSectionsInDocumentation() { docFindSections(briefDescription(),this,docFile()); docFindSections(documentation(),this,docFile()); - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->findSectionsInDocumentation(this); - } + mg->findSectionsInDocumentation(this); } QListIterator<MemberList> mli(m_memberLists); @@ -411,14 +399,9 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile) break; case LayoutDocEntry::MemberGroups: { - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->writeTagFile(tagFile); - } + mg->writeTagFile(tagFile); } } break; @@ -751,18 +734,12 @@ void FileDefImpl::endMemberDocumentation(OutputList &ol) void FileDefImpl::writeMemberGroups(OutputList &ol) { /* write user defined member groups */ - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - m_memberGroupSDict->sort(); - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if ((!mg->allMembersInSameSection() || !m_subGrouping) + && mg->header()!="[NOHEADER]") { - if ((!mg->allMembersInSameSection() || !m_subGrouping) - && mg->header()!="[NOHEADER]") - { - mg->writeDeclarations(ol,0,0,this,0); - } + mg->writeDeclarations(ol,0,0,this,0); } } } @@ -1273,22 +1250,17 @@ void FileDefImpl::addMembersToMemberGroup() { if (ml->listType()&MemberListType_declarationLists) { - ::addMembersToMemberGroup(ml,&m_memberGroupSDict,this); + ::addMembersToMemberGroup(ml,&m_memberGroups,this); } } // add members inside sections to their groups - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if (mg->allMembersInSameSection() && m_subGrouping) { - if (mg->allMembersInSameSection() && m_subGrouping) - { - //printf("----> addToDeclarationSection(%s)\n",mg->header().data()); - mg->addToDeclarationSection(); - } + //printf("----> addToDeclarationSection(%s)\n",mg->header().data()); + mg->addToDeclarationSection(); } } } @@ -1575,14 +1547,9 @@ void FileDefImpl::addListReferences() 0 ); } - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->addListReferences(this); - } + mg->addListReferences(this); } QListIterator<MemberList> mli(m_memberLists); MemberList *ml; @@ -1982,15 +1949,10 @@ void FileDefImpl::sortMemberLists() if (ml->needsSorting()) { ml->sort(); ml->setNeedsSorting(FALSE); } } - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - MemberList *mlg = mg->members(); - if (mlg->needsSorting()) { mlg->sort(); mlg->setNeedsSorting(FALSE); } - } + MemberList *mlg = mg->members(); + if (mlg->needsSorting()) { mlg->sort(); mlg->setNeedsSorting(FALSE); } } if (Config_getBool(SORT_BRIEF_DOCS)) @@ -2116,15 +2078,10 @@ void FileDefImpl::countMembers() ml->countDecMembers(); ml->countDocMembers(); } - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->countDecMembers(); - mg->countDocMembers(); - } + mg->countDecMembers(); + mg->countDocMembers(); } } diff --git a/src/filedef.h b/src/filedef.h index 26e5de5..2e0de97 100644 --- a/src/filedef.h +++ b/src/filedef.h @@ -39,7 +39,6 @@ class MemberDef; class OutputList; class NamespaceDef; class NamespaceLinkedRefMap; -class MemberGroupSDict; class PackageDef; class DirDef; class FTextStream; @@ -132,7 +131,7 @@ class FileDef : public DefinitionMutable, public Definition virtual const QList<MemberList> &getMemberLists() const = 0; /* user defined member groups */ - virtual MemberGroupSDict *getMemberGroupSDict() const = 0; + virtual const MemberGroupList &getMemberGroups() const = 0; virtual NamespaceLinkedRefMap getNamespaces() const = 0; virtual ClassLinkedRefMap getClasses() const = 0; diff --git a/src/groupdef.cpp b/src/groupdef.cpp index e0d60bd..84f02e9 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -98,7 +98,7 @@ class GroupDefImpl : public DefinitionMixin<GroupDef> virtual const QList<MemberList> &getMemberLists() const { return m_memberLists; } /* user defined member groups */ - virtual MemberGroupSDict *getMemberGroupSDict() const { return m_memberGroupSDict; } + virtual const MemberGroupList &getMemberGroups() const { return m_memberGroups; } virtual FileList * getFiles() const { return m_fileList; } virtual ClassLinkedRefMap getClasses() const { return m_classes; } @@ -150,7 +150,7 @@ class GroupDefImpl : public DefinitionMixin<GroupDef> MemberNameInfoLinkedMap m_allMemberNameInfoLinkedMap; Definition * m_groupScope; QList<MemberList> m_memberLists; - MemberGroupSDict * m_memberGroupSDict; + MemberGroupList m_memberGroups; bool m_subGrouping; }; @@ -180,8 +180,6 @@ GroupDefImpl::GroupDefImpl(const char *df,int dl,const char *na,const char *t, m_fileName = convertNameToFile(QCString("group_")+na); } setGroupTitle( t ); - m_memberGroupSDict = new MemberGroupSDict; - m_memberGroupSDict->setAutoDelete(TRUE); m_allMemberList = new MemberList(MemberListType_allMembersList); @@ -197,7 +195,6 @@ GroupDefImpl::~GroupDefImpl() delete m_pageDict; delete m_exampleDict; delete m_allMemberList; - delete m_memberGroupSDict; } void GroupDefImpl::setGroupTitle( const char *t ) @@ -218,9 +215,7 @@ void GroupDefImpl::setGroupTitle( const char *t ) void GroupDefImpl::distributeMemberGroupDocumentation() { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_memberGroups) { mg->distributeMemberGroupDocumentation(); } @@ -230,9 +225,8 @@ void GroupDefImpl::findSectionsInDocumentation() { docFindSections(briefDescription(),this,docFile()); docFindSections(documentation(),this,docFile()); - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + + for (const auto &mg : m_memberGroups) { mg->findSectionsInDocumentation(this); } @@ -313,14 +307,12 @@ void GroupDefImpl::addMembersToMemberGroup() { if (ml->listType()&MemberListType_declarationLists) { - ::addMembersToMemberGroup(ml,&m_memberGroupSDict,this); + ::addMembersToMemberGroup(ml,&m_memberGroups,this); } } //printf("GroupDefImpl::addMembersToMemberGroup() memberGroupList=%d\n",memberGroupList->count()); - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_memberGroups) { mg->setInGroup(TRUE); } @@ -599,15 +591,10 @@ void GroupDefImpl::countMembers() ml->countDecMembers(); ml->countDocMembers(); } - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->countDecMembers(); - mg->countDocMembers(); - } + mg->countDecMembers(); + mg->countDocMembers(); } } @@ -738,14 +725,9 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) break; case LayoutDocEntry::MemberGroups: { - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->writeTagFile(tagFile); - } + mg->writeTagFile(tagFile); } } break; @@ -1036,16 +1018,9 @@ void GroupDefImpl::writePageDocumentation(OutputList &ol) void GroupDefImpl::writeMemberGroups(OutputList &ol) { /* write user defined member groups */ - if (m_memberGroupSDict) + for (const auto &mg : m_memberGroups) { - m_memberGroupSDict->sort(); - /* write user defined member groups */ - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->writeDeclarations(ol,0,0,0,this); - } + mg->writeDeclarations(ol,0,0,0,this); } } @@ -1601,9 +1576,7 @@ void GroupDefImpl::addListReferences() 0 ); } - MemberGroupSDict::Iterator mgli(*m_memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_memberGroups) { mg->addListReferences(this); } diff --git a/src/groupdef.h b/src/groupdef.h index 0b682c2..f8d17b9 100644 --- a/src/groupdef.h +++ b/src/groupdef.h @@ -24,6 +24,7 @@ #include "definition.h" #include "dirdef.h" #include "layout.h" +#include "membergroup.h" class MemberList; class FileList; @@ -35,7 +36,6 @@ class NamespaceDef; class GroupList; class OutputList; class NamespaceSDict; -class MemberGroupSDict; class PageSDict; class PageDef; class DirDef; @@ -93,7 +93,7 @@ class GroupDef : public DefinitionMutable, public Definition virtual const QList<MemberList> &getMemberLists() const = 0; /* user defined member groups */ - virtual MemberGroupSDict *getMemberGroupSDict() const = 0; + virtual const MemberGroupList &getMemberGroups() const = 0; virtual FileList * getFiles() const = 0; virtual ClassLinkedRefMap getClasses() const = 0; diff --git a/src/index.cpp b/src/index.cpp index 52254f6..dff2515 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -355,7 +355,7 @@ void addMembersToIndex(T *def,LayoutDocManager::LayoutPart part, const QCString &name,const QCString &anchor, bool addToIndex=TRUE,bool preventSeparateIndex=FALSE) { - bool hasMembers = def->getMemberLists().count()>0 || def->getMemberGroupSDict()!=0; + bool hasMembers = def->getMemberLists().count()>0 || !def->getMemberGroups().empty(); Doxygen::indexList->addContentsItem(hasMembers,name, def->getReference(),def->getOutputFileBase(),anchor, hasMembers && !preventSeparateIndex, diff --git a/src/membergroup.h b/src/membergroup.h index 0734344..72e25ed 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -19,6 +19,8 @@ #define MEMBERGROUP_H #include <vector> +#include <map> +#include <memory> #include <qlist.h> #include "sortdict.h" @@ -105,20 +107,9 @@ class MemberGroup RefItemVector m_xrefListItems; }; -using MemberGroupList = std::vector<MemberGroup *>; - -/** A sorted dictionary of MemberGroup objects. */ -class MemberGroupSDict : public SIntDict<MemberGroup> -{ - public: - MemberGroupSDict(int size=17) : SIntDict<MemberGroup>(size) {} - ~MemberGroupSDict() {} - private: - int compareValues(const MemberGroup *item1,const MemberGroup *item2) const - { - return item1->groupId() - item2->groupId(); - } -}; +using MemberGroupRefList = std::vector<MemberGroup *>; +//using MemberGroupMap = std::map< int, std::unique_ptr<MemberGroup> >; +using MemberGroupList = std::vector< std::unique_ptr<MemberGroup> >; /** Data collected for a member group */ struct MemberGroupInfo diff --git a/src/memberlist.cpp b/src/memberlist.cpp index 78c9373..4daedb5 100644 --- a/src/memberlist.cpp +++ b/src/memberlist.cpp @@ -123,7 +123,7 @@ int MemberList::countInheritableMembers(const ClassDef *inheritedFrom) const } } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { count+=mg->countInheritableMembers(inheritedFrom); } @@ -200,7 +200,7 @@ void MemberList::countDecMembers() } } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->countDecMembers(); /* @@ -241,7 +241,7 @@ void MemberList::countDocMembers() m_numDocMembers++; } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->countDocMembers(); m_numDocMembers+=mg->numDocMembers(); @@ -330,7 +330,7 @@ void MemberList::setAnonymousEnumType() } } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->setAnonymousEnumType(); } @@ -695,7 +695,7 @@ void MemberList::writeDeclarations(OutputList &ol, } //printf("memberGroupList=%p\n",memberGroupList); - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { bool hasHeader=!mg->header().isEmpty() && mg->header()!="[NOHEADER]"; if (inheritId.isEmpty()) @@ -806,7 +806,7 @@ void MemberList::writeDocumentation(OutputList &ol, } } //printf("MemberList::writeDocumentation() -- member groups %d\n",memberGroupList->count()); - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->writeDocumentation(ol,scopeName,container,showEnumValues,showInline); } @@ -919,7 +919,7 @@ void MemberList::writeDocumentationPage(OutputList &ol, } } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->writeDocumentationPage(ol,scopeName,container); } @@ -927,7 +927,7 @@ void MemberList::writeDocumentationPage(OutputList &ol, void MemberList::addMemberGroup(MemberGroup *mg) { - m_memberGroupList.push_back(mg); + m_memberGroupRefList.push_back(mg); } void MemberList::addListReferences(Definition *def) @@ -958,7 +958,7 @@ void MemberList::addListReferences(Definition *def) } } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->addListReferences(def); } @@ -976,7 +976,7 @@ void MemberList::findSectionsInDocumentation(const Definition *d) md->findSectionsInDocumentation(); } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->findSectionsInDocumentation(d); } @@ -1077,7 +1077,7 @@ void MemberList::writeTagFile(FTextStream &tagFile) } } } - for (const auto &mg : m_memberGroupList) + for (const auto &mg : m_memberGroupRefList) { mg->writeTagFile(tagFile); } diff --git a/src/memberlist.h b/src/memberlist.h index e9e14dd..2c2d5ee 100644 --- a/src/memberlist.h +++ b/src/memberlist.h @@ -89,7 +89,7 @@ class MemberList : private QList<MemberDef> void addListReferences(Definition *def); void findSectionsInDocumentation(const Definition *d); void setNeedsSorting(bool b); - const MemberGroupList &getMemberGroupList() const { return m_memberGroupList; } + const MemberGroupRefList &getMemberGroupList() const { return m_memberGroupRefList; } void setAnonymousEnumType(); void setAnchors(); @@ -111,7 +111,7 @@ class MemberList : private QList<MemberDef> int m_numDecEnumValues; int m_numDocMembers; // number of members in the detailed part of the memberlist int m_numDocEnumValues; - MemberGroupList m_memberGroupList; + MemberGroupRefList m_memberGroupRefList; bool m_inGroup; // is this list part of a group definition bool m_inFile; // is this list part of a file definition MemberListType m_listType; diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 11597bc..0651fdf 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -97,7 +97,7 @@ class NamespaceDefImpl : public DefinitionMixin<NamespaceDefMutable> virtual MemberList *getMemberList(MemberListType lt) const; virtual const QList<MemberList> &getMemberLists() const { return m_memberLists; } virtual MemberDef *getMemberByName(const QCString &) const; - virtual MemberGroupSDict *getMemberGroupSDict() const { return memberGroupSDict; } + virtual const MemberGroupList &getMemberGroups() const { return m_memberGroups; } virtual ClassLinkedRefMap getClasses() const { return classes; } virtual ClassLinkedRefMap getInterfaces() const { return interfaces; } virtual ClassLinkedRefMap getStructs() const { return structs; } @@ -140,7 +140,7 @@ class NamespaceDefImpl : public DefinitionMixin<NamespaceDefMutable> MemberSDict *m_allMembersDict = 0; QList<MemberList> m_memberLists; - MemberGroupSDict *memberGroupSDict = 0; + MemberGroupList m_memberGroups; ClassLinkedRefMap classes; ClassLinkedRefMap interfaces; ClassLinkedRefMap structs; @@ -212,8 +212,8 @@ class NamespaceDefAliasImpl : public DefinitionAliasMixin<NamespaceDef> { return getNSAlias()->getMemberLists(); } virtual MemberDef *getMemberByName(const QCString &name) const { return getNSAlias()->getMemberByName(name); } - virtual MemberGroupSDict *getMemberGroupSDict() const - { return getNSAlias()->getMemberGroupSDict(); } + virtual const MemberGroupList &getMemberGroups() const + { return getNSAlias()->getMemberGroups(); } virtual ClassLinkedRefMap getClasses() const { return getNSAlias()->getClasses(); } virtual ClassLinkedRefMap getInterfaces() const @@ -266,8 +266,6 @@ NamespaceDefImpl::NamespaceDefImpl(const char *df,int dl,int dc, m_innerCompounds = new SDict<Definition>(17); m_allMembersDict = 0; setReference(lref); - memberGroupSDict = new MemberGroupSDict; - memberGroupSDict->setAutoDelete(TRUE); m_inline=FALSE; m_subGrouping=Config_getBool(SUBGROUPING); if (type && !strcmp("module", type)) @@ -291,7 +289,6 @@ NamespaceDefImpl::NamespaceDefImpl(const char *df,int dl,int dc, NamespaceDefImpl::~NamespaceDefImpl() { delete m_innerCompounds; - delete memberGroupSDict; delete m_allMembersDict; } @@ -309,9 +306,7 @@ void NamespaceDefImpl::setFileName(const QCString &fn) void NamespaceDefImpl::distributeMemberGroupDocumentation() { - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_memberGroups) { mg->distributeMemberGroupDocumentation(); } @@ -321,9 +316,7 @@ void NamespaceDefImpl::findSectionsInDocumentation() { docFindSections(briefDescription(),this,docFile()); docFindSections(documentation(),this,docFile()); - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_memberGroups) { mg->findSectionsInDocumentation(this); } @@ -400,22 +393,17 @@ void NamespaceDefImpl::addMembersToMemberGroup() { if (ml->listType()&MemberListType_declarationLists) { - ::addMembersToMemberGroup(ml,&memberGroupSDict,this); + ::addMembersToMemberGroup(ml,&m_memberGroups,this); } } // add members inside sections to their groups - if (memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if (mg->allMembersInSameSection() && m_subGrouping) { - if (mg->allMembersInSameSection() && m_subGrouping) - { - //printf("----> addToDeclarationSection(%s)\n",mg->header().data()); - mg->addToDeclarationSection(); - } + //printf("----> addToDeclarationSection(%s)\n",mg->header().data()); + mg->addToDeclarationSection(); } } } @@ -620,14 +608,9 @@ void NamespaceDefImpl::writeTagFile(FTextStream &tagFile) break; case LayoutDocEntry::MemberGroups: { - if (memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->writeTagFile(tagFile); - } + mg->writeTagFile(tagFile); } } break; @@ -789,18 +772,12 @@ void NamespaceDefImpl::writeNamespaceDeclarations(OutputList &ol,const QCString void NamespaceDefImpl::writeMemberGroups(OutputList &ol) { /* write user defined member groups */ - if (memberGroupSDict) + for (const auto &mg : m_memberGroups) { - memberGroupSDict->sort(); - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + if ((!mg->allMembersInSameSection() || !m_subGrouping) + && mg->header()!="[NOHEADER]") { - if ((!mg->allMembersInSameSection() || !m_subGrouping) - && mg->header()!="[NOHEADER]") - { - mg->writeDeclarations(ol,0,this,0,0); - } + mg->writeDeclarations(ol,0,this,0,0); } } } @@ -1146,15 +1123,10 @@ void NamespaceDefImpl::countMembers() ml->countDecMembers(); ml->countDocMembers(); } - if (memberGroupSDict) + for (const auto &mg : m_memberGroups) { - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - mg->countDecMembers(); - mg->countDocMembers(); - } + mg->countDecMembers(); + mg->countDocMembers(); } } @@ -1213,9 +1185,7 @@ void NamespaceDefImpl::addListReferences() this ); } - MemberGroupSDict::Iterator mgli(*memberGroupSDict); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) + for (const auto &mg : m_memberGroups) { mg->addListReferences(this); } diff --git a/src/namespacedef.h b/src/namespacedef.h index e9bf86f..fb6a0d5 100644 --- a/src/namespacedef.h +++ b/src/namespacedef.h @@ -22,13 +22,13 @@ #include "definition.h" #include "filedef.h" #include "linkedmap.h" +#include "membergroup.h" class MemberList; class ClassDef; class OutputList; class ClassLinkedRefMap; class MemberDef; -class MemberGroupSDict; class NamespaceDef; class FTextStream; class NamespaceDef; @@ -79,7 +79,7 @@ class NamespaceDef : public Definition virtual MemberDef *getMemberByName(const QCString &) const = 0; /*! Returns the user defined member groups */ - virtual MemberGroupSDict *getMemberGroupSDict() const = 0; + virtual const MemberGroupList &getMemberGroups() const = 0; /*! Returns the classes contained in this namespace */ virtual ClassLinkedRefMap getClasses() const = 0; diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index d84d5e4..e7a41c6 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -1529,7 +1529,7 @@ public: inline PerlModGenerator(bool pretty) : m_output(pretty) { } void generatePerlModForMember(const MemberDef *md, const Definition *); - void generatePerlUserDefinedSection(const Definition *d, const MemberGroupSDict *gsd); + void generatePerlUserDefinedSection(const Definition *d, const MemberGroupList &mgl); void generatePerlModSection(const Definition *d, MemberList *ml, const char *name, const char *header=0); void addListOfAllMembers(const ClassDef *cd); @@ -1776,37 +1776,33 @@ void PerlModGenerator::addListOfAllMembers(const ClassDef *cd) m_output.closeList(); } -/* DGA: fix #7490 Perlmod generation issue with multiple grouped functions (member groups) */ -void PerlModGenerator::generatePerlUserDefinedSection(const Definition *d, const MemberGroupSDict *gsd) -{ - if (gsd) - { - MemberGroupSDict::Iterator mgli(*gsd); - MemberGroup *mg; - m_output.openList("user_defined"); - for (; (mg = mgli.current()); ++mgli) - { - m_output.openHash(); - if (mg->header()) - m_output.addFieldQuotedString("header", mg->header()); - - if (mg->members()) - { - m_output.openList("members"); - MemberListIterator mli(*mg->members()); - const MemberDef *md; - for (mli.toFirst(); (md = mli.current()); ++mli) - { - generatePerlModForMember(md, d); - } - m_output.closeList(); - } - m_output.closeHash(); - } - m_output.closeList(); - } -} -/* DGA: end of fix #7490 */ +void PerlModGenerator::generatePerlUserDefinedSection(const Definition *d, const MemberGroupList &mgl) +{ + if (!mgl.empty()) + { + m_output.openList("user_defined"); + for (const auto &mg : mgl) + { + m_output.openHash(); + if (mg->header()) + m_output.addFieldQuotedString("header", mg->header()); + + if (mg->members()) + { + m_output.openList("members"); + MemberListIterator mli(*mg->members()); + const MemberDef *md; + for (mli.toFirst(); (md = mli.current()); ++mli) + { + generatePerlModForMember(md, d); + } + m_output.closeList(); + } + m_output.closeHash(); + } + m_output.closeList(); + } +} void PerlModGenerator::generatePerlModForClass(const ClassDef *cd) { @@ -1892,7 +1888,7 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd) addTemplateList(cd,m_output); addListOfAllMembers(cd); - generatePerlUserDefinedSection(cd, cd->getMemberGroupSDict()); + generatePerlUserDefinedSection(cd, cd->getMemberGroups()); generatePerlModSection(cd,cd->getMemberList(MemberListType_pubTypes),"public_typedefs"); generatePerlModSection(cd,cd->getMemberList(MemberListType_pubMethods),"public_methods"); @@ -1986,7 +1982,7 @@ void PerlModGenerator::generatePerlModForNamespace(const NamespaceDef *nd) m_output.closeList(); } - generatePerlUserDefinedSection(nd, nd->getMemberGroupSDict()); + generatePerlUserDefinedSection(nd, nd->getMemberGroups()); generatePerlModSection(nd,nd->getMemberList(MemberListType_decDefineMembers),"defines"); generatePerlModSection(nd,nd->getMemberList(MemberListType_decProtoMembers),"prototypes"); @@ -2057,8 +2053,7 @@ void PerlModGenerator::generatePerlModForFile(const FileDef *fd) } m_output.closeList(); - /* DGA: fix #7494 Perlmod does not generate grouped members from files */ - generatePerlUserDefinedSection(fd, fd->getMemberGroupSDict()); + generatePerlUserDefinedSection(fd, fd->getMemberGroups()); generatePerlModSection(fd,fd->getMemberList(MemberListType_decDefineMembers),"defines"); generatePerlModSection(fd,fd->getMemberList(MemberListType_decProtoMembers),"prototypes"); @@ -2152,7 +2147,7 @@ void PerlModGenerator::generatePerlModForGroup(const GroupDef *gd) m_output.closeList(); } - generatePerlUserDefinedSection(gd, gd->getMemberGroupSDict()); + generatePerlUserDefinedSection(gd, gd->getMemberGroups()); generatePerlModSection(gd,gd->getMemberList(MemberListType_decDefineMembers),"defines"); generatePerlModSection(gd,gd->getMemberList(MemberListType_decProtoMembers),"prototypes"); diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 97c7337..821f24a 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -2015,15 +2015,10 @@ static void generateSqlite3ForClass(const ClassDef *cd) writeTemplateList(cd); // + member groups - if (cd->getMemberGroupSDict()) + for (const auto &mg : cd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateSqlite3Section(cd,mg->members(),refid,"user-defined",mg->header(), - mg->documentation()); - } + generateSqlite3Section(cd,mg->members(),refid,"user-defined",mg->header(), + mg->documentation()); } // this is just a list of *local* members @@ -2079,15 +2074,10 @@ static void generateSqlite3ForNamespace(const NamespaceDef *nd) writeInnerNamespaces(nd->getNamespaces(),refid); // + member groups - if (nd->getMemberGroupSDict()) + for (const auto &mg : nd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateSqlite3Section(nd,mg->members(),refid,"user-defined",mg->header(), - mg->documentation()); - } + generateSqlite3Section(nd,mg->members(),refid,"user-defined",mg->header(), + mg->documentation()); } // + normal members @@ -2241,15 +2231,10 @@ static void generateSqlite3ForFile(const FileDef *fd) writeInnerNamespaces(fd->getNamespaces(),refid); // + member groups - if (fd->getMemberGroupSDict()) + for (const auto &mg : fd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateSqlite3Section(fd,mg->members(),refid,"user-defined",mg->header(), + generateSqlite3Section(fd,mg->members(),refid,"user-defined",mg->header(), mg->documentation()); - } } // + normal members @@ -2315,15 +2300,10 @@ static void generateSqlite3ForGroup(const GroupDef *gd) writeInnerGroups(gd->getSubGroups(),refid); // + member groups - if (gd->getMemberGroupSDict()) + for (const auto &mg : gd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateSqlite3Section(gd,mg->members(),refid,"user-defined",mg->header(), - mg->documentation()); - } + generateSqlite3Section(gd,mg->members(),refid,"user-defined",mg->header(), + mg->documentation()); } // + members diff --git a/src/util.cpp b/src/util.cpp index ac476b2..ec5d21f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -4412,7 +4412,7 @@ QCString getOverloadDocs() } void addMembersToMemberGroup(MemberList *ml, - MemberGroupSDict **ppMemberGroupSDict, + MemberGroupList *pMemberGroups, const Definition *context) { ASSERT(context!=0); @@ -4439,26 +4439,30 @@ void addMembersToMemberGroup(MemberList *ml, if (it!=Doxygen::memberGroupInfoMap.end()) { auto &info = it->second; - if (*ppMemberGroupSDict==0) + auto mg_it = std::find_if(pMemberGroups->begin(), + pMemberGroups->end(), + [&groupId](const auto &g) + { return g->groupId()==groupId; } + ); + MemberGroup *mg_ptr = 0; + if (mg_it==pMemberGroups->end()) { - *ppMemberGroupSDict = new MemberGroupSDict; - (*ppMemberGroupSDict)->setAutoDelete(TRUE); + auto mg = std::make_unique<MemberGroup>( + context, + groupId, + info->header, + info->doc, + info->docFile, + info->docLine); + mg_ptr = mg.get(); + pMemberGroups->push_back(std::move(mg)); } - MemberGroup *mg = (*ppMemberGroupSDict)->find(groupId); - if (mg==0) + else { - mg = new MemberGroup( - context, - groupId, - info->header, - info->doc, - info->docFile, - info->docLine - ); - (*ppMemberGroupSDict)->append(groupId,mg); + mg_ptr = (*mg_it).get(); } - mg->insertMember(fmd); // insert in member group - fmd->setMemberGroup(mg); + mg_ptr->insertMember(fmd); // insert in member group + fmd->setMemberGroup(mg_ptr); } } } @@ -4471,28 +4475,32 @@ void addMembersToMemberGroup(MemberList *ml, if (it!=Doxygen::memberGroupInfoMap.end()) { auto &info = it->second; - if (*ppMemberGroupSDict==0) + auto mg_it = std::find_if(pMemberGroups->begin(), + pMemberGroups->end(), + [&groupId](const auto &g) + { return g->groupId()==groupId; } + ); + MemberGroup *mg_ptr = 0; + if (mg_it==pMemberGroups->end()) { - *ppMemberGroupSDict = new MemberGroupSDict; - (*ppMemberGroupSDict)->setAutoDelete(TRUE); + auto mg = std::make_unique<MemberGroup>( + context, + groupId, + info->header, + info->doc, + info->docFile, + info->docLine); + mg_ptr = mg.get(); + pMemberGroups->push_back(std::move(mg)); } - MemberGroup *mg = (*ppMemberGroupSDict)->find(groupId); - if (mg==0) + else { - mg = new MemberGroup( - context, - groupId, - info->header, - info->doc, - info->docFile, - info->docLine - ); - (*ppMemberGroupSDict)->append(groupId,mg); + mg_ptr = (*mg_it).get(); } md = ml->take(index); // remove from member list - mg->insertMember(md->resolveAlias()); // insert in member group - mg->setRefItems(info->m_sli); - md->setMemberGroup(mg); + mg_ptr->insertMember(md->resolveAlias()); // insert in member group + mg_ptr->setRefItems(info->m_sli); + md->setMemberGroup(mg_ptr); continue; } } @@ -51,7 +51,6 @@ class ExampleSDict; class GroupDef; class NamespaceSDict; class ClassList; -class MemberGroupSDict; struct TagInfo; class PageDef; class SectionInfo; @@ -265,7 +264,7 @@ QCString convertToPSString(const char *s); QCString getOverloadDocs(); void addMembersToMemberGroup(/* in,out */ MemberList *ml, - /* in,out */ MemberGroupSDict **ppMemberGroupSDict, + /* in,out */ MemberGroupList *pMemberGroups, /* in */ const Definition *context); int extractClassNameFromType(const QCString &type,int &pos, diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 8ffaca2..7eb09f1 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -1365,15 +1365,10 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) writeInnerClasses(cd->getClasses(),t); writeTemplateList(cd,t); - if (cd->getMemberGroupSDict()) + for (const auto &mg : cd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateXMLSection(cd,ti,t,mg->members(),"user-defined",mg->header(), - mg->documentation()); - } + generateXMLSection(cd,ti,t,mg->members(),"user-defined",mg->header(), + mg->documentation()); } QListIterator<MemberList> mli(cd->getMemberLists()); @@ -1469,15 +1464,10 @@ static void generateXMLForNamespace(const NamespaceDef *nd,FTextStream &ti) writeInnerClasses(nd->getClasses(),t); writeInnerNamespaces(nd->getNamespaces(),t); - if (nd->getMemberGroupSDict()) + for (const auto &mg : nd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateXMLSection(nd,ti,t,mg->members(),"user-defined",mg->header(), + generateXMLSection(nd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); - } } QListIterator<MemberList> mli(nd->getMemberLists()); @@ -1600,15 +1590,10 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) writeInnerClasses(fd->getClasses(),t); writeInnerNamespaces(fd->getNamespaces(),t); - if (fd->getMemberGroupSDict()) + for (const auto &mg : fd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateXMLSection(fd,ti,t,mg->members(),"user-defined",mg->header(), - mg->documentation()); - } + generateXMLSection(fd,ti,t,mg->members(),"user-defined",mg->header(), + mg->documentation()); } QListIterator<MemberList> mli(fd->getMemberLists()); @@ -1680,15 +1665,10 @@ static void generateXMLForGroup(const GroupDef *gd,FTextStream &ti) writeInnerPages(gd->getPages(),t); writeInnerGroups(gd->getSubGroups(),t); - if (gd->getMemberGroupSDict()) + for (const auto &mg : gd->getMemberGroups()) { - MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict()); - MemberGroup *mg; - for (;(mg=mgli.current());++mgli) - { - generateXMLSection(gd,ti,t,mg->members(),"user-defined",mg->header(), - mg->documentation()); - } + generateXMLSection(gd,ti,t,mg->members(),"user-defined",mg->header(), + mg->documentation()); } QListIterator<MemberList> mli(gd->getMemberLists()); |