summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/classdef.cpp619
-rw-r--r--src/classdef.h51
-rw-r--r--src/context.cpp52
-rw-r--r--src/context.h9
-rw-r--r--src/doxygen.cpp326
-rw-r--r--src/groupdef.cpp97
-rw-r--r--src/groupdef.h7
-rw-r--r--src/linkedmap.h110
-rw-r--r--src/membername.cpp42
-rw-r--r--src/membername.h51
-rw-r--r--src/perlmodgen.cpp35
-rw-r--r--src/sqlite3gen.cpp17
-rw-r--r--src/util.h1
-rw-r--r--src/xmlgen.cpp61
15 files changed, 678 insertions, 801 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b7d4af2..146f67f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -254,7 +254,6 @@ add_library(_doxygen STATIC
memberdef.cpp
membergroup.cpp
memberlist.cpp
- membername.cpp
message.cpp
msc.cpp
namespacedef.cpp
diff --git a/src/classdef.cpp b/src/classdef.cpp
index 0cdd354..e637dab 100644
--- a/src/classdef.cpp
+++ b/src/classdef.cpp
@@ -15,7 +15,9 @@
*
*/
-#include <stdio.h>
+#include <cstdio>
+#include <algorithm>
+
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
@@ -81,7 +83,7 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef
virtual QCString compoundTypeString() const;
virtual BaseClassList *baseClasses() const;
virtual BaseClassList *subClasses() const;
- virtual MemberNameInfoSDict *memberNameInfoSDict() const;
+ virtual const MemberNameInfoLinkedMap &memberNameInfoLinkedMap() const;
virtual Protection protection() const;
virtual bool isLinkableInProject() const;
virtual bool isLinkable() const;
@@ -201,6 +203,7 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef
virtual void removeMemberFromLists(MemberDef *md);
virtual void setAnonymousEnumType();
virtual void countMembers();
+ virtual void sortAllMembersList();
virtual void addGroupedInheritedMembers(OutputList &ol,MemberListType lt,
const ClassDef *inheritedFrom,const QCString &inheritId) const;
@@ -319,8 +322,8 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef
{ return getCdAlias()->baseClasses(); }
virtual BaseClassList *subClasses() const
{ return getCdAlias()->subClasses(); }
- virtual MemberNameInfoSDict *memberNameInfoSDict() const
- { return getCdAlias()->memberNameInfoSDict(); }
+ virtual const MemberNameInfoLinkedMap &memberNameInfoLinkedMap() const
+ { return getCdAlias()->memberNameInfoLinkedMap(); }
virtual Protection protection() const
{ return getCdAlias()->protection(); }
virtual bool isLinkableInProject() const
@@ -503,6 +506,7 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef
virtual void removeMemberFromLists(MemberDef *) {}
virtual void setAnonymousEnumType() {}
virtual void countMembers() {}
+ virtual void sortAllMembersList() {}
virtual void addGroupedInheritedMembers(OutputList &,MemberListType,
const ClassDef *,const QCString &) const {}
virtual void writeTagFile(FTextStream &) {}
@@ -578,7 +582,7 @@ class ClassDefImpl::IMPL
FileDef *fileDef = 0;
/*! List of all members (including inherited members) */
- MemberNameInfoSDict *allMemberNameInfoSDict = 0;
+ MemberNameInfoLinkedMap allMemberNameInfoLinkedMap;
/*! Template arguments of this class */
ArgumentList tempArgs;
@@ -701,7 +705,6 @@ void ClassDefImpl::IMPL::init(const char *defFileName, const char *name,
exampleSDict = 0;
inherits = 0;
inheritedBy = 0;
- allMemberNameInfoSDict = 0;
incInfo=0;
prot=Public;
nspace=0;
@@ -755,7 +758,6 @@ ClassDefImpl::IMPL::~IMPL()
{
delete inherits;
delete inheritedBy;
- delete allMemberNameInfoSDict;
delete exampleSDict;
delete usesImplClassDict;
delete usedByImplClassDict;
@@ -1193,24 +1195,9 @@ void ClassDefImpl::internalInsertMember(MemberDef *md,
QCString(md->typeString())=="friend union")))
{
//printf("=======> adding member %s to class %s\n",md->name().data(),name().data());
- MemberInfo *mi = new MemberInfo((MemberDef *)md,
- prot,md->virtualness(),FALSE);
- MemberNameInfo *mni=0;
- if (m_impl->allMemberNameInfoSDict==0)
- {
- m_impl->allMemberNameInfoSDict = new MemberNameInfoSDict(17);
- m_impl->allMemberNameInfoSDict->setAutoDelete(TRUE);
- }
- if ((mni=m_impl->allMemberNameInfoSDict->find(md->name())))
- {
- mni->append(mi);
- }
- else
- {
- mni = new MemberNameInfo(md->name());
- mni->append(mi);
- m_impl->allMemberNameInfoSDict->append(mni->memberName(),mni);
- }
+
+ MemberNameInfo *mni = m_impl->allMemberNameInfoLinkedMap.add(md->name());
+ mni->push_back(std::make_unique<MemberInfo>(md,prot,md->virtualness(),FALSE));
}
}
@@ -2056,27 +2043,6 @@ void ClassDefImpl::writeIncludeFiles(OutputList &ol) const
}
}
-#if 0
-void ClassDefImpl::writeAllMembersLink(OutputList &ol)
-{
- // write link to list of all members (HTML only)
- if (m_impl->allMemberNameInfoSDict &&
- !Config_getBool(OPTIMIZE_OUTPUT_FOR_C)
- )
- {
- ol.pushGeneratorState();
- ol.disableAllBut(OutputGenerator::Html);
- ol.startParagraph();
- ol.startTextLink(getMemberListFileName(),0);
- ol.parseText(theTranslator->trListOfAllMembers());
- ol.endTextLink();
- ol.endParagraph();
- ol.enableAll();
- ol.popGeneratorState();
- }
-}
-#endif
-
void ClassDefImpl::writeMemberGroups(OutputList &ol,bool showInline) const
{
// write user defined member groups
@@ -2194,7 +2160,7 @@ void ClassDefImpl::writeSummaryLinks(OutputList &ol) const
first=FALSE;
}
else if (lde->kind()==LayoutDocEntry::ClassAllMembersLink &&
- m_impl->allMemberNameInfoSDict &&
+ !m_impl->allMemberNameInfoLinkedMap.empty() &&
!Config_getBool(OPTIMIZE_OUTPUT_FOR_C)
)
{
@@ -2922,39 +2888,32 @@ void ClassDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *current
ol.writeString(" <div class=\"navtab\">\n");
ol.writeString(" <table>\n");
- if (m_impl->allMemberNameInfoSDict)
+ for (auto &mni : m_impl->allMemberNameInfoLinkedMap)
{
- MemberNameInfoSDict::Iterator mnili(*m_impl->allMemberNameInfoSDict);
- MemberNameInfo *mni;
- for (;(mni=mnili.current());++mnili)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mnii(*mni);
- MemberInfo *mi;
- for (mnii.toFirst();(mi=mnii.current());++mnii)
+ const MemberDef *md=mi->memberDef();
+ if (md->getClassDef()==this && md->isLinkable() && !md->isEnumValue())
{
- const MemberDef *md=mi->memberDef();
- if (md->getClassDef()==this && md->isLinkable() && !md->isEnumValue())
+ ol.writeString(" <tr><td class=\"navtab\">");
+ if (md->isLinkableInProject())
{
- ol.writeString(" <tr><td class=\"navtab\">");
- if (md->isLinkableInProject())
+ if (md==currentMd) // selected item => highlight
{
- if (md==currentMd) // selected item => highlight
- {
- ol.writeString("<a class=\"qindexHL\" ");
- }
- else
- {
- ol.writeString("<a class=\"qindex\" ");
- }
- ol.writeString("href=\"");
- if (createSubDirs) ol.writeString("../../");
- ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor());
- ol.writeString("\">");
- ol.writeString(convertToHtml(md->name()));
- ol.writeString("</a>");
+ ol.writeString("<a class=\"qindexHL\" ");
}
- ol.writeString("</td></tr>\n");
+ else
+ {
+ ol.writeString("<a class=\"qindex\" ");
+ }
+ ol.writeString("href=\"");
+ if (createSubDirs) ol.writeString("../../");
+ ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor());
+ ol.writeString("\">");
+ ol.writeString(convertToHtml(md->name()));
+ ol.writeString("</a>");
}
+ ol.writeString("</td></tr>\n");
}
}
}
@@ -2996,7 +2955,7 @@ void ClassDefImpl::writeMemberList(OutputList &ol) const
//static bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE);
static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
- if (m_impl->allMemberNameInfoSDict==0 || cOpt) return;
+ if (m_impl->allMemberNameInfoLinkedMap.empty() || cOpt) return;
// only for HTML
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
@@ -3050,14 +3009,9 @@ void ClassDefImpl::writeMemberList(OutputList &ol) const
bool first = true; // to prevent empty table
int idx=0;
- //MemberNameInfo *mni=m_impl->allMemberNameInfoList->first();
- MemberNameInfoSDict::Iterator mnii(*m_impl->allMemberNameInfoSDict);
- MemberNameInfo *mni;
- for (mnii.toFirst();(mni=mnii.current());++mnii)
+ for (auto &mni : m_impl->allMemberNameInfoLinkedMap)
{
- MemberNameInfoIterator it(*mni);
- MemberInfo *mi;
- for (;(mi=it.current());++it)
+ for (auto &mi : *mni)
{
const MemberDef *md=mi->memberDef();
const ClassDef *cd=md->getClassDef();
@@ -3624,221 +3578,201 @@ void ClassDefImpl::mergeMembers()
// merge the members in the base class of this inheritance branch first
bClass->mergeMembers();
- MemberNameInfoSDict *srcMnd = bClass->memberNameInfoSDict();
- MemberNameInfoSDict *dstMnd = m_impl->allMemberNameInfoSDict;
+ const MemberNameInfoLinkedMap &srcMnd = bClass->memberNameInfoLinkedMap();
+ MemberNameInfoLinkedMap &dstMnd = m_impl->allMemberNameInfoLinkedMap;
- if (srcMnd)
+ for (auto &srcMni : srcMnd)
{
- MemberNameInfoSDict::Iterator srcMnili(*srcMnd);
- MemberNameInfo *srcMni;
- for ( ; (srcMni=srcMnili.current()) ; ++srcMnili)
+ //printf(" Base member name %s\n",srcMni->memberName());
+ MemberNameInfo *dstMni;
+ if ((dstMni=dstMnd.find(srcMni->memberName())))
+ // a member with that name is already in the class.
+ // the member may hide or reimplement the one in the sub class
+ // or there may be another path to the base class that is already
+ // visited via another branch in the class hierarchy.
{
- //printf(" Base member name %s\n",srcMni->memberName());
- MemberNameInfo *dstMni;
- if (dstMnd!=0 && (dstMni=dstMnd->find(srcMni->memberName())))
- // a member with that name is already in the class.
- // the member may hide or reimplement the one in the sub class
- // or there may be another path to the base class that is already
- // visited via another branch in the class hierarchy.
+ for (auto &srcMi : *srcMni)
{
- MemberNameInfoIterator srcMnii(*srcMni);
- MemberInfo *srcMi;
- for ( ; (srcMi=srcMnii.current()) ; ++srcMnii )
+ MemberDef *srcMd = srcMi->memberDef();
+ bool found=FALSE;
+ bool ambiguous=FALSE;
+ bool hidden=FALSE;
+ const ClassDef *srcCd = srcMd->getClassDef();
+ for (auto &dstMi : *dstMni)
{
- MemberDef *srcMd = srcMi->memberDef();
- bool found=FALSE;
- bool ambiguous=FALSE;
- bool hidden=FALSE;
- MemberNameInfoIterator dstMnii(*dstMni);
- MemberInfo *dstMi;
- const ClassDef *srcCd = srcMd->getClassDef();
- for ( ; (dstMi=dstMnii.current()) && !found; ++dstMnii )
+ MemberDef *dstMd = dstMi->memberDef();
+ if (srcMd!=dstMd) // different members
{
- MemberDef *dstMd = dstMi->memberDef();
- if (srcMd!=dstMd) // different members
+ const ClassDef *dstCd = dstMd->getClassDef();
+ //printf(" Is %s a base class of %s?\n",srcCd->name().data(),dstCd->name().data());
+ if (srcCd==dstCd || dstCd->isBaseClass(srcCd,TRUE))
+ // member is in the same or a base class
{
- const ClassDef *dstCd = dstMd->getClassDef();
- //printf(" Is %s a base class of %s?\n",srcCd->name().data(),dstCd->name().data());
- if (srcCd==dstCd || dstCd->isBaseClass(srcCd,TRUE))
- // member is in the same or a base class
- {
- ArgumentList &srcAl = srcMd->argumentList();
- ArgumentList &dstAl = dstMd->argumentList();
- found=matchArguments2(
- srcMd->getOuterScope(),srcMd->getFileDef(),&srcAl,
- dstMd->getOuterScope(),dstMd->getFileDef(),&dstAl,
- TRUE
- );
- //printf(" Yes, matching (%s<->%s): %d\n",
- // argListToString(srcMd->argumentList()).data(),
- // argListToString(dstMd->argumentList()).data(),
- // found);
- hidden = hidden || !found;
- }
- else // member is in a non base class => multiple inheritance
- // using the same base class.
- {
- //printf("$$ Existing member %s %s add scope %s\n",
- // dstMi->ambiguityResolutionScope.data(),
- // dstMd->name().data(),
- // dstMi->scopePath.left(dstMi->scopePath.find("::")+2).data());
-
- QCString scope=dstMi->scopePath().left((uint)dstMi->scopePath().find(sep)+sepLen);
- if (scope!=dstMi->ambiguityResolutionScope().left(scope.length()))
- {
- dstMi->setAmbiguityResolutionScope(scope+dstMi->ambiguityResolutionScope());
- }
- ambiguous=TRUE;
- }
+ ArgumentList &srcAl = srcMd->argumentList();
+ ArgumentList &dstAl = dstMd->argumentList();
+ found=matchArguments2(
+ srcMd->getOuterScope(),srcMd->getFileDef(),&srcAl,
+ dstMd->getOuterScope(),dstMd->getFileDef(),&dstAl,
+ TRUE
+ );
+ //printf(" Yes, matching (%s<->%s): %d\n",
+ // argListToString(srcMd->argumentList()).data(),
+ // argListToString(dstMd->argumentList()).data(),
+ // found);
+ hidden = hidden || !found;
}
- else // same members
+ else // member is in a non base class => multiple inheritance
+ // using the same base class.
{
- // do not add if base class is virtual or
- // if scope paths are equal or
- // if base class is an interface (and thus implicitly virtual).
- //printf("same member found srcMi->virt=%d dstMi->virt=%d\n",srcMi->virt,dstMi->virt);
- if ((srcMi->virt()!=Normal && dstMi->virt()!=Normal) ||
- bClass->name()+sep+srcMi->scopePath() == dstMi->scopePath() ||
- dstMd->getClassDef()->compoundType()==Interface
- )
- {
- found=TRUE;
- }
- else // member can be reached via multiple paths in the
- // inheritance tree
+ //printf("$$ Existing member %s %s add scope %s\n",
+ // dstMi->ambiguityResolutionScope.data(),
+ // dstMd->name().data(),
+ // dstMi->scopePath.left(dstMi->scopePath.find("::")+2).data());
+
+ QCString scope=dstMi->scopePath().left((uint)dstMi->scopePath().find(sep)+sepLen);
+ if (scope!=dstMi->ambiguityResolutionScope().left(scope.length()))
{
- //printf("$$ Existing member %s %s add scope %s\n",
- // dstMi->ambiguityResolutionScope.data(),
- // dstMd->name().data(),
- // dstMi->scopePath.left(dstMi->scopePath.find("::")+2).data());
-
- QCString scope=dstMi->scopePath().left((uint)dstMi->scopePath().find(sep)+sepLen);
- if (scope!=dstMi->ambiguityResolutionScope().left(scope.length()))
- {
- dstMi->setAmbiguityResolutionScope(dstMi->ambiguityResolutionScope()+scope);
- }
- ambiguous=TRUE;
+ dstMi->setAmbiguityResolutionScope(scope+dstMi->ambiguityResolutionScope());
}
+ ambiguous=TRUE;
}
}
- //printf("member %s::%s hidden %d ambiguous %d srcMi->ambigClass=%p\n",
- // srcCd->name().data(),srcMd->name().data(),hidden,ambiguous,srcMi->ambigClass);
-
- // TODO: fix the case where a member is hidden by inheritance
- // of a member with the same name but with another prototype,
- // while there is more than one path to the member in the
- // base class due to multiple inheritance. In this case
- // it seems that the member is not reachable by prefixing a
- // scope name either (according to my compiler). Currently,
- // this case is shown anyway.
- if (!found && srcMd->protection()!=Private && !srcMd->isFriend())
+ else // same members
{
- Protection prot=srcMd->protection();
- if (bcd->prot==Protected && prot==Public) prot=bcd->prot;
- else if (bcd->prot==Private) prot=bcd->prot;
-
- if (inlineInheritedMembers)
+ // do not add if base class is virtual or
+ // if scope paths are equal or
+ // if base class is an interface (and thus implicitly virtual).
+ //printf("same member found srcMi->virt=%d dstMi->virt=%d\n",srcMi->virt,dstMi->virt);
+ if ((srcMi->virt()!=Normal && dstMi->virt()!=Normal) ||
+ bClass->name()+sep+srcMi->scopePath() == dstMi->scopePath() ||
+ dstMd->getClassDef()->compoundType()==Interface
+ )
+ {
+ found=TRUE;
+ }
+ else // member can be reached via multiple paths in the
+ // inheritance tree
{
- if (!isStandardFunc(srcMd))
+ //printf("$$ Existing member %s %s add scope %s\n",
+ // dstMi->ambiguityResolutionScope.data(),
+ // dstMd->name().data(),
+ // dstMi->scopePath.left(dstMi->scopePath.find("::")+2).data());
+
+ QCString scope=dstMi->scopePath().left((uint)dstMi->scopePath().find(sep)+sepLen);
+ if (scope!=dstMi->ambiguityResolutionScope().left(scope.length()))
{
- //printf(" insertMember '%s'\n",srcMd->name().data());
- internalInsertMember(srcMd,prot,FALSE);
+ dstMi->setAmbiguityResolutionScope(dstMi->ambiguityResolutionScope()+scope);
}
+ ambiguous=TRUE;
}
+ }
+ if (found) break;
+ }
+ //printf("member %s::%s hidden %d ambiguous %d srcMi->ambigClass=%p\n",
+ // srcCd->name().data(),srcMd->name().data(),hidden,ambiguous,srcMi->ambigClass);
+
+ // TODO: fix the case where a member is hidden by inheritance
+ // of a member with the same name but with another prototype,
+ // while there is more than one path to the member in the
+ // base class due to multiple inheritance. In this case
+ // it seems that the member is not reachable by prefixing a
+ // scope name either (according to my compiler). Currently,
+ // this case is shown anyway.
+ if (!found && srcMd->protection()!=Private && !srcMd->isFriend())
+ {
+ Protection prot=srcMd->protection();
+ if (bcd->prot==Protected && prot==Public) prot=bcd->prot;
+ else if (bcd->prot==Private) prot=bcd->prot;
- Specifier virt=srcMi->virt();
- if (virt==Normal && bcd->virt!=Normal) virt=bcd->virt;
-
- MemberInfo *newMi = new MemberInfo(srcMd,prot,virt,TRUE);
- newMi->setScopePath(bClass->name()+sep+srcMi->scopePath());
- if (ambiguous)
+ if (inlineInheritedMembers)
+ {
+ if (!isStandardFunc(srcMd))
{
- //printf("$$ New member %s %s add scope %s::\n",
- // srcMi->ambiguityResolutionScope.data(),
- // srcMd->name().data(),
- // bClass->name().data());
+ //printf(" insertMember '%s'\n",srcMd->name().data());
+ internalInsertMember(srcMd,prot,FALSE);
+ }
+ }
- QCString scope=bClass->name()+sep;
- if (scope!=srcMi->ambiguityResolutionScope().left(scope.length()))
- {
- newMi->setAmbiguityResolutionScope(scope+srcMi->ambiguityResolutionScope());
- }
+ Specifier virt=srcMi->virt();
+ if (virt==Normal && bcd->virt!=Normal) virt=bcd->virt;
+
+ std::unique_ptr<MemberInfo> newMi = std::make_unique<MemberInfo>(srcMd,prot,virt,TRUE);
+ newMi->setScopePath(bClass->name()+sep+srcMi->scopePath());
+ if (ambiguous)
+ {
+ //printf("$$ New member %s %s add scope %s::\n",
+ // srcMi->ambiguityResolutionScope.data(),
+ // srcMd->name().data(),
+ // bClass->name().data());
+
+ QCString scope=bClass->name()+sep;
+ if (scope!=srcMi->ambiguityResolutionScope().left(scope.length()))
+ {
+ newMi->setAmbiguityResolutionScope(scope+srcMi->ambiguityResolutionScope());
}
- if (hidden)
+ }
+ if (hidden)
+ {
+ if (srcMi->ambigClass()==0)
{
- if (srcMi->ambigClass()==0)
- {
- newMi->setAmbigClass(bClass);
- newMi->setAmbiguityResolutionScope(bClass->name()+sep);
- }
- else
- {
- newMi->setAmbigClass(srcMi->ambigClass());
- newMi->setAmbiguityResolutionScope(srcMi->ambigClass()->name()+sep);
- }
+ newMi->setAmbigClass(bClass);
+ newMi->setAmbiguityResolutionScope(bClass->name()+sep);
+ }
+ else
+ {
+ newMi->setAmbigClass(srcMi->ambigClass());
+ newMi->setAmbiguityResolutionScope(srcMi->ambigClass()->name()+sep);
}
- dstMni->append(newMi);
}
+ dstMni->push_back(std::move(newMi));
}
}
- else // base class has a member that is not in the sub class => copy
+ }
+ else // base class has a member that is not in the sub class => copy
+ {
+ // create a deep copy of the list (only the MemberInfo's will be
+ // copied, not the actual MemberDef's)
+ MemberNameInfo *newMni = dstMnd.add(srcMni->memberName());
+
+ // copy the member(s) from the base to the sub class
+ for (auto &mi : *srcMni)
{
- // create a deep copy of the list (only the MemberInfo's will be
- // copied, not the actual MemberDef's)
- MemberNameInfo *newMni = 0;
- newMni = new MemberNameInfo(srcMni->memberName());
-
- // copy the member(s) from the base to the sub class
- MemberNameInfoIterator mnii(*srcMni);
- MemberInfo *mi;
- for (;(mi=mnii.current());++mnii)
+ if (!mi->memberDef()->isFriend()) // don't inherit friends
{
- if (!mi->memberDef()->isFriend()) // don't inherit friends
+ Protection prot = mi->prot();
+ if (bcd->prot==Protected)
{
- Protection prot = mi->prot();
- if (bcd->prot==Protected)
- {
- if (prot==Public) prot=Protected;
- }
- else if (bcd->prot==Private)
- {
- prot=Private;
- }
- //printf("%s::%s: prot=%d bcd->prot=%d result=%d\n",
- // name().data(),mi->memberDef->name().data(),mi->prot,
- // bcd->prot,prot);
+ if (prot==Public) prot=Protected;
+ }
+ else if (bcd->prot==Private)
+ {
+ prot=Private;
+ }
+ //printf("%s::%s: prot=%d bcd->prot=%d result=%d\n",
+ // name().data(),mi->memberDef->name().data(),mi->prot,
+ // bcd->prot,prot);
- if (prot!=Private || extractPrivate)
- {
- Specifier virt=mi->virt();
- if (virt==Normal && bcd->virt!=Normal) virt=bcd->virt;
+ if (prot!=Private || extractPrivate)
+ {
+ Specifier virt=mi->virt();
+ if (virt==Normal && bcd->virt!=Normal) virt=bcd->virt;
- if (inlineInheritedMembers)
+ if (inlineInheritedMembers)
+ {
+ if (!isStandardFunc(mi->memberDef()))
{
- if (!isStandardFunc(mi->memberDef()))
- {
- //printf(" insertMember '%s'\n",mi->memberDef->name().data());
- internalInsertMember(mi->memberDef(),prot,FALSE);
- }
+ //printf(" insertMember '%s'\n",mi->memberDef->name().data());
+ internalInsertMember(mi->memberDef(),prot,FALSE);
}
- //printf("Adding!\n");
- MemberInfo *newMi=new MemberInfo(mi->memberDef(),prot,virt,TRUE);
- newMi->setScopePath(bClass->name()+sep+mi->scopePath());
- newMi->setAmbigClass(mi->ambigClass());
- newMi->setAmbiguityResolutionScope(mi->ambiguityResolutionScope());
- newMni->append(newMi);
}
+ //printf("Adding!\n");
+ std::unique_ptr<MemberInfo> newMi = std::make_unique<MemberInfo>(mi->memberDef(),prot,virt,TRUE);
+ newMi->setScopePath(bClass->name()+sep+mi->scopePath());
+ newMi->setAmbigClass(mi->ambigClass());
+ newMi->setAmbiguityResolutionScope(mi->ambiguityResolutionScope());
+ newMni->push_back(std::move(newMi));
}
}
-
- if (dstMnd==0)
- {
- m_impl->allMemberNameInfoSDict = new MemberNameInfoSDict(17);
- m_impl->allMemberNameInfoSDict->setAutoDelete(TRUE);
- dstMnd = m_impl->allMemberNameInfoSDict;
- }
- // add it to the dictionary
- dstMnd->append(newMni->memberName(),newMni);
}
}
}
@@ -3889,80 +3823,68 @@ void ClassDefImpl::mergeCategory(ClassDef *category)
}
}
}
-
}
// make methods private for categories defined in the .m file
//printf("%s::mergeCategory makePrivate=%d\n",name().data(),makePrivate);
- MemberNameInfoSDict *srcMnd = category->memberNameInfoSDict();
- MemberNameInfoSDict *dstMnd = m_impl->allMemberNameInfoSDict;
+ const MemberNameInfoLinkedMap &srcMnd = category->memberNameInfoLinkedMap();
+ MemberNameInfoLinkedMap &dstMnd = m_impl->allMemberNameInfoLinkedMap;
- if (srcMnd && dstMnd)
+ for (auto &srcMni : srcMnd)
{
- MemberNameInfoSDict::Iterator srcMnili(*srcMnd);
- MemberNameInfo *srcMni;
- for ( ; (srcMni=srcMnili.current()) ; ++srcMnili)
+ MemberNameInfo *dstMni=dstMnd.find(srcMni->memberName());
+ if (dstMni) // method is already defined in the class
{
- MemberNameInfo *dstMni=dstMnd->find(srcMni->memberName());
- if (dstMni) // method is already defined in the class
+ //printf("Existing member %s\n",srcMni->memberName());
+ auto &dstMi = dstMni->front();
+ auto &srcMi = srcMni->front();
+ if (srcMi && dstMi)
{
- //printf("Existing member %s\n",srcMni->memberName());
- MemberInfo *dstMi = dstMni->getFirst();
- MemberInfo *srcMi = srcMni->getFirst();
- if (srcMi && dstMi)
- {
- combineDeclarationAndDefinition(srcMi->memberDef(),dstMi->memberDef());
- dstMi->memberDef()->setCategory(category);
- dstMi->memberDef()->setCategoryRelation(srcMi->memberDef());
- srcMi->memberDef()->setCategoryRelation(dstMi->memberDef());
- }
+ combineDeclarationAndDefinition(srcMi->memberDef(),dstMi->memberDef());
+ dstMi->memberDef()->setCategory(category);
+ dstMi->memberDef()->setCategoryRelation(srcMi->memberDef());
+ srcMi->memberDef()->setCategoryRelation(dstMi->memberDef());
}
- else // new method name
+ }
+ else // new method name
+ {
+ //printf("New member %s\n",srcMni->memberName());
+ // create a deep copy of the list
+ MemberNameInfo *newMni = dstMnd.add(srcMni->memberName());
+
+ // copy the member(s) from the category to this class
+ for (auto &mi : *srcMni)
{
- //printf("New member %s\n",srcMni->memberName());
- // create a deep copy of the list
- MemberNameInfo *newMni = 0;
- newMni = new MemberNameInfo(srcMni->memberName());
-
- // copy the member(s) from the category to this class
- MemberNameInfoIterator mnii(*srcMni);
- MemberInfo *mi;
- for (;(mi=mnii.current());++mnii)
+ //printf("Adding '%s'\n",mi->memberDef->name().data());
+ Protection prot = mi->prot();
+ //if (makePrivate) prot = Private;
+ std::unique_ptr<MemberDef> newMd { mi->memberDef()->deepCopy() };
+ if (newMd)
{
- //printf("Adding '%s'\n",mi->memberDef->name().data());
- Protection prot = mi->prot();
- //if (makePrivate) prot = Private;
- std::unique_ptr<MemberDef> newMd { mi->memberDef()->deepCopy() };
- if (newMd)
- {
- //printf("Copying member %s\n",mi->memberDef->name().data());
- newMd->moveTo(this);
+ //printf("Copying member %s\n",mi->memberDef->name().data());
+ newMd->moveTo(this);
- MemberInfo *newMi=new MemberInfo(newMd.get(),prot,mi->virt(),mi->inherited());
- newMi->setScopePath(mi->scopePath());
- newMi->setAmbigClass(mi->ambigClass());
- newMi->setAmbiguityResolutionScope(mi->ambiguityResolutionScope());
- newMni->append(newMi);
+ std::unique_ptr<MemberInfo> newMi=std::make_unique<MemberInfo>(newMd.get(),prot,mi->virt(),mi->inherited());
+ newMi->setScopePath(mi->scopePath());
+ newMi->setAmbigClass(mi->ambigClass());
+ newMi->setAmbiguityResolutionScope(mi->ambiguityResolutionScope());
+ newMni->push_back(std::move(newMi));
- // also add the newly created member to the global members list
+ // also add the newly created member to the global members list
- QCString name = newMd->name();
- MemberName *mn = Doxygen::memberNameLinkedMap->add(name);
+ QCString name = newMd->name();
+ MemberName *mn = Doxygen::memberNameLinkedMap->add(name);
- newMd->setCategory(category);
- newMd->setCategoryRelation(mi->memberDef());
- mi->memberDef()->setCategoryRelation(newMd.get());
- if (makePrivate || isExtension)
- {
- newMd->makeImplementationDetail();
- }
- internalInsertMember(newMd.get(),prot,FALSE);
- mn->push_back(std::move(newMd));
+ newMd->setCategory(category);
+ newMd->setCategoryRelation(mi->memberDef());
+ mi->memberDef()->setCategoryRelation(newMd.get());
+ if (makePrivate || isExtension)
+ {
+ newMd->makeImplementationDetail();
}
+ internalInsertMember(newMd.get(),prot,FALSE);
+ mn->push_back(std::move(newMd));
}
-
- // add it to the dictionary
- dstMnd->append(newMni->memberName(),newMni);
}
}
}
@@ -4131,14 +4053,9 @@ void ClassDefImpl::setGroupDefForAllMembers(GroupDef *gd,Grouping::GroupPri_t pr
{
gd->addClass(this);
//printf("ClassDefImpl::setGroupDefForAllMembers(%s)\n",gd->name().data());
- if (m_impl->allMemberNameInfoSDict==0) return;
- MemberNameInfoSDict::Iterator mnili(*m_impl->allMemberNameInfoSDict);
- MemberNameInfo *mni;
- for (;(mni=mnili.current());++mnili)
+ for (auto &mni : m_impl->allMemberNameInfoLinkedMap)
{
- MemberNameInfoIterator mnii(*mni);
- MemberInfo *mi;
- for (mnii.toFirst();(mi=mnii.current());++mnii)
+ for (auto &mi : *mni)
{
MemberDef *md=mi->memberDef();
md->setGroupDef(gd,pri,fileName,startLine,hasDocs);
@@ -4246,14 +4163,9 @@ QDict<int> *ClassDefImpl::getTemplateBaseClassNames() const
void ClassDefImpl::addMembersToTemplateInstance(const ClassDef *cd,const char *templSpec)
{
//printf("%s::addMembersToTemplateInstance(%s,%s)\n",name().data(),cd->name().data(),templSpec);
- if (cd->memberNameInfoSDict()==0) return;
- MemberNameInfoSDict::Iterator mnili(*cd->memberNameInfoSDict());
- MemberNameInfo *mni;
- for (;(mni=mnili.current());++mnili)
+ for (auto &mni : cd->memberNameInfoLinkedMap())
{
- MemberNameInfoIterator mnii(*mni);
- MemberInfo *mi;
- for (mnii.toFirst();(mi=mnii.current());++mnii)
+ for (auto &mi : *mni)
{
auto actualArguments_p = stringToArgumentList(getLanguage(),templSpec);
MemberDef *md = mi->memberDef();
@@ -4434,26 +4346,21 @@ void ClassDefImpl::addListReferences()
MemberDef *ClassDefImpl::getMemberByName(const QCString &name) const
{
MemberDef *xmd = 0;
- if (m_impl->allMemberNameInfoSDict)
- {
- MemberNameInfo *mni = m_impl->allMemberNameInfoSDict->find(name);
- if (mni)
- {
- const int maxInheritanceDepth = 100000;
- int mdist=maxInheritanceDepth;
- MemberNameInfoIterator mnii(*mni);
- MemberInfo *mi;
- for (mnii.toFirst();(mi=mnii.current());++mnii)
+ MemberNameInfo *mni = m_impl->allMemberNameInfoLinkedMap.find(name);
+ if (mni)
+ {
+ const int maxInheritanceDepth = 100000;
+ int mdist=maxInheritanceDepth;
+ for (auto &mi : *mni)
+ {
+ const ClassDef *mcd=mi->memberDef()->getClassDef();
+ int m=minClassDistance(this,mcd);
+ //printf("found member in %s linkable=%d m=%d\n",
+ // mcd->name().data(),mcd->isLinkable(),m);
+ if (m<mdist && mcd->isLinkable())
{
- const ClassDef *mcd=mi->memberDef()->getClassDef();
- int m=minClassDistance(this,mcd);
- //printf("found member in %s linkable=%d m=%d\n",
- // mcd->name().data(),mcd->isLinkable(),m);
- if (m<mdist && mcd->isLinkable())
- {
- mdist=m;
- xmd=mi->memberDef();
- }
+ mdist=m;
+ xmd=mi->memberDef();
}
}
}
@@ -4922,9 +4829,19 @@ BaseClassList *ClassDefImpl::subClasses() const
return m_impl->inheritedBy;
}
-MemberNameInfoSDict *ClassDefImpl::memberNameInfoSDict() const
+const MemberNameInfoLinkedMap &ClassDefImpl::memberNameInfoLinkedMap() const
+{
+ return m_impl->allMemberNameInfoLinkedMap;
+}
+
+void ClassDefImpl::sortAllMembersList()
{
- return m_impl->allMemberNameInfoSDict;
+ std::sort(m_impl->allMemberNameInfoLinkedMap.begin(),
+ m_impl->allMemberNameInfoLinkedMap.end(),
+ [](const auto &m1,const auto &m2)
+ {
+ return qstricmp(m1->memberName(),m2->memberName())<0;
+ });
}
Protection ClassDefImpl::protection() const
diff --git a/src/classdef.h b/src/classdef.h
index 72ee92d..9c3aaa3 100644
--- a/src/classdef.h
+++ b/src/classdef.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.
*
@@ -39,7 +39,7 @@ class BaseClassList;
class NamespaceDef;
class MemberDef;
class ExampleSDict;
-class MemberNameInfoSDict;
+class MemberNameInfoLinkedMap;
class UsesClassDict;
class ConstraintClassDict;
class MemberGroupSDict;
@@ -61,8 +61,8 @@ class ClassDef : virtual public Definition
{
public:
/** The various compound types */
- enum CompoundType { Class, //=Entry::CLASS_SEC,
- Struct, //=Entry::STRUCT_SEC,
+ enum CompoundType { Class, //=Entry::CLASS_SEC,
+ Struct, //=Entry::STRUCT_SEC,
Union, //=Entry::UNION_SEC,
Interface, //=Entry::INTERFACE_SEC,
Protocol, //=Entry::PROTOCOL_SEC,
@@ -76,7 +76,7 @@ class ClassDef : virtual public Definition
//-----------------------------------------------------------------------------------
- // --- getters
+ // --- getters
//-----------------------------------------------------------------------------------
/** Used for RTTI, this is a class */
@@ -134,7 +134,7 @@ class ClassDef : virtual public Definition
/** Returns a dictionary of all members. This includes any inherited
* members. Members are sorted alphabetically.
*/
- virtual MemberNameInfoSDict *memberNameInfoSDict() const = 0;
+ virtual const MemberNameInfoLinkedMap &memberNameInfoLinkedMap() const = 0;
/** Return the protection level (Public,Protected,Private) in which
* this compound was found.
@@ -371,6 +371,7 @@ class ClassDef : virtual public Definition
virtual void removeMemberFromLists(MemberDef *md) = 0;
virtual void setAnonymousEnumType() = 0;
virtual void countMembers() = 0;
+ virtual void sortAllMembersList() = 0;
//-----------------------------------------------------------------------------------
// --- write output ----
@@ -426,13 +427,13 @@ ClassDef *createClassDefAlias(const Definition *newScope,const ClassDef *cd);
//------------------------------------------------------------------------
-/** Class that contains information about a usage relation.
+/** Class that contains information about a usage relation.
*/
struct UsesClassDef
{
- UsesClassDef(ClassDef *cd) : classDef(cd)
- {
- accessors = new QDict<void>(17);
+ UsesClassDef(ClassDef *cd) : classDef(cd)
+ {
+ accessors = new QDict<void>(17);
containment = TRUE;
}
~UsesClassDef()
@@ -460,7 +461,7 @@ struct UsesClassDef
bool containment;
};
-/** Dictionary of usage relations.
+/** Dictionary of usage relations.
*/
class UsesClassDict : public QDict<UsesClassDef>
{
@@ -469,38 +470,38 @@ class UsesClassDict : public QDict<UsesClassDef>
~UsesClassDict() {}
};
-/** Iterator class to iterate over a dictionary of usage relations.
+/** Iterator class to iterate over a dictionary of usage relations.
*/
class UsesClassDictIterator : public QDictIterator<UsesClassDef>
{
public:
- UsesClassDictIterator(const QDict<UsesClassDef> &d)
+ UsesClassDictIterator(const QDict<UsesClassDef> &d)
: QDictIterator<UsesClassDef>(d) {}
~UsesClassDictIterator() {}
};
//------------------------------------------------------------------------
-/** Class that contains information about an inheritance relation.
+/** Class that contains information about an inheritance relation.
*/
struct BaseClassDef
{
BaseClassDef(ClassDef *cd,const char *n,Protection p,
- Specifier v,const char *t) :
+ Specifier v,const char *t) :
classDef(cd), usedName(n), prot(p), virt(v), templSpecifiers(t) {}
/** Class definition that this relation inherits from. */
ClassDef *classDef;
- /** name used in the inheritance list
+ /** name used in the inheritance list
* (may be a typedef name instead of the class name)
*/
- QCString usedName;
-
- /** Protection level of the inheritance relation:
- * Public, Protected, or Private
+ QCString usedName;
+
+ /** Protection level of the inheritance relation:
+ * Public, Protected, or Private
*/
- Protection prot;
+ Protection prot;
/** Virtualness of the inheritance relation:
* Normal, or Virtual
@@ -512,7 +513,7 @@ struct BaseClassDef
};
/** List of base classes.
- *
+ *
* The classes are alphabetically sorted on name if inSort() is used.
*/
class BaseClassList : public QList<BaseClassDef>
@@ -535,7 +536,7 @@ class BaseClassList : public QList<BaseClassDef>
class BaseClassListIterator : public QListIterator<BaseClassDef>
{
public:
- BaseClassListIterator(const BaseClassList &bcl) :
+ BaseClassListIterator(const BaseClassList &bcl) :
QListIterator<BaseClassDef>(bcl) {}
};
diff --git a/src/context.cpp b/src/context.cpp
index 718bbd8..af9a66c 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -2503,15 +2503,8 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
Cachable &cache = getCache();
if (!cache.allMembersList)
{
- if (m_classDef->memberNameInfoSDict())
- {
- AllMembersListContext *ml = AllMembersListContext::alloc(m_classDef->memberNameInfoSDict());
- cache.allMembersList.reset(ml);
- }
- else
- {
- cache.allMembersList.reset(AllMembersListContext::alloc());
- }
+ AllMembersListContext *ml = AllMembersListContext::alloc(m_classDef->memberNameInfoLinkedMap());
+ cache.allMembersList.reset(ml);
}
return cache.allMembersList.get();
}
@@ -8766,31 +8759,24 @@ TemplateVariant MemberInfoContext::get(const char *name) const
class AllMembersListContext::Private : public GenericNodeListContext
{
public:
- Private(const MemberNameInfoSDict *ml)
+ Private(const MemberNameInfoLinkedMap &ml)
{
- if (ml)
+ static bool hideUndocMembers = Config_getBool(HIDE_UNDOC_MEMBERS);
+ for (auto &mni : ml)
{
- static bool hideUndocMembers = Config_getBool(HIDE_UNDOC_MEMBERS);
- MemberNameInfoSDict::Iterator mnii(*ml);
- MemberNameInfo *mni;
- for (mnii.toFirst();(mni=mnii.current());++mnii)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mnii2(*mni);
- MemberInfo *mi;
- for (mnii2.toFirst();(mi=mnii2.current());++mnii2)
+ const MemberDef *md=mi->memberDef();
+ const ClassDef *cd=md->getClassDef();
+ if (cd && !md->isAnonymous())
{
- const MemberDef *md=mi->memberDef();
- const ClassDef *cd=md->getClassDef();
- if (cd && !md->isAnonymous())
+ if ((cd->isLinkable() && md->isLinkable()) ||
+ (!cd->isArtificial() && !hideUndocMembers &&
+ (protectionLevelVisible(md->protection()) || md->isFriend())
+ )
+ )
{
- if ((cd->isLinkable() && md->isLinkable()) ||
- (!cd->isArtificial() && !hideUndocMembers &&
- (protectionLevelVisible(md->protection()) || md->isFriend())
- )
- )
- {
- append(MemberInfoContext::alloc(mi));
- }
+ append(MemberInfoContext::alloc(mi.get()));
}
}
}
@@ -8798,12 +8784,8 @@ class AllMembersListContext::Private : public GenericNodeListContext
}
};
-AllMembersListContext::AllMembersListContext() : RefCountedContext("AllMembersListContext")
-{
- p = new Private(0);
-}
-
-AllMembersListContext::AllMembersListContext(const MemberNameInfoSDict *ml) : RefCountedContext("AllMembersListContext")
+AllMembersListContext::AllMembersListContext(const MemberNameInfoLinkedMap &ml)
+ : RefCountedContext("AllMembersListContext")
{
p = new Private(ml);
}
diff --git a/src/context.h b/src/context.h
index ae61a08..929f06c 100644
--- a/src/context.h
+++ b/src/context.h
@@ -46,7 +46,7 @@ class MemberSDict;
class MemberDef;
struct Argument;
class ArgumentList;
-class MemberNameInfoSDict;
+class MemberNameInfoLinkedMap;
class MemberInfo;
class MemberGroup;
class MemberGroupSDict;
@@ -1113,9 +1113,7 @@ class InheritedMemberInfoListContext : public RefCountedContext, public Template
class AllMembersListContext : public RefCountedContext, public TemplateListIntf
{
public:
- static AllMembersListContext *alloc()
- { return new AllMembersListContext; }
- static AllMembersListContext *alloc(const MemberNameInfoSDict *ml)
+ static AllMembersListContext *alloc(const MemberNameInfoLinkedMap &ml)
{ return new AllMembersListContext(ml); }
// TemplateListIntf
@@ -1126,8 +1124,7 @@ class AllMembersListContext : public RefCountedContext, public TemplateListIntf
virtual int release() { return RefCountedContext::release(); }
private:
- AllMembersListContext();
- AllMembersListContext(const MemberNameInfoSDict *ml);
+ AllMembersListContext(const MemberNameInfoLinkedMap &ml);
~AllMembersListContext();
class Private;
Private *p;
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 13d1651..948c6c4 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -1886,66 +1886,61 @@ static void findUsingDeclImports(const Entry *root)
if (bcd && bcd!=cd)
{
//printf("found class %s memName=%s\n",bcd->name().data(),memName.data());
- MemberNameInfoSDict *mndict=bcd->memberNameInfoSDict();
- if (mndict)
+ const MemberNameInfoLinkedMap &mnlm=bcd->memberNameInfoLinkedMap();
+ const MemberNameInfo *mni = mnlm.find(memName);
+ if (mni)
{
- MemberNameInfo *mni = mndict->find(memName);
- if (mni)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mnii(*mni);
- MemberInfo *mi;
- for ( ; (mi=mnii.current()) ; ++mnii )
+ MemberDef *md = mi->memberDef();
+ if (md && md->protection()!=Private)
{
- MemberDef *md = mi->memberDef();
- if (md && md->protection()!=Private)
+ //printf("found member %s\n",mni->memberName());
+ QCString fileName = root->fileName;
+ if (fileName.isEmpty() && root->tagInfo())
{
- //printf("found member %s\n",mni->memberName());
- QCString fileName = root->fileName;
- if (fileName.isEmpty() && root->tagInfo())
- {
- fileName = root->tagInfo()->tagName;
- }
- const ArgumentList &templAl = md->templateArguments();
- const ArgumentList &al = md->templateArguments();
- std::unique_ptr<MemberDef> newMd { createMemberDef(
+ fileName = root->tagInfo()->tagName;
+ }
+ const ArgumentList &templAl = md->templateArguments();
+ const ArgumentList &al = md->templateArguments();
+ std::unique_ptr<MemberDef> newMd { createMemberDef(
fileName,root->startLine,root->startColumn,
md->typeString(),memName,md->argsString(),
md->excpString(),root->protection,root->virt,
md->isStatic(),Member,md->memberType(),
templAl,al,root->metaData
) };
- newMd->setMemberClass(cd);
- cd->insertMember(newMd.get());
- if (!root->doc.isEmpty() || !root->brief.isEmpty())
- {
- newMd->setDocumentation(root->doc,root->docFile,root->docLine);
- newMd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
- newMd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
- }
- else
- {
- newMd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
- newMd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
- newMd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
- }
- newMd->setDefinition(md->definition());
- newMd->enableCallGraph(root->callGraph);
- newMd->enableCallerGraph(root->callerGraph);
- newMd->enableReferencedByRelation(root->referencedByRelation);
- newMd->enableReferencesRelation(root->referencesRelation);
- newMd->setBitfields(md->bitfieldString());
- newMd->addSectionsToDefinition(root->anchors);
- newMd->setBodySegment(md->getDefLine(),md->getStartBodyLine(),md->getEndBodyLine());
- newMd->setBodyDef(md->getBodyDef());
- newMd->setInitializer(md->initializer());
- newMd->setMaxInitLines(md->initializerLines());
- newMd->setMemberGroupId(root->mGrpId);
- newMd->setMemberSpecifiers(md->getMemberSpecifiers());
- newMd->setLanguage(root->lang);
- newMd->setId(root->id);
- MemberName *mn = Doxygen::memberNameLinkedMap->add(memName);
- mn->push_back(std::move(newMd));
+ newMd->setMemberClass(cd);
+ cd->insertMember(newMd.get());
+ if (!root->doc.isEmpty() || !root->brief.isEmpty())
+ {
+ newMd->setDocumentation(root->doc,root->docFile,root->docLine);
+ newMd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
+ newMd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
}
+ else
+ {
+ newMd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
+ newMd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
+ newMd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
+ }
+ newMd->setDefinition(md->definition());
+ newMd->enableCallGraph(root->callGraph);
+ newMd->enableCallerGraph(root->callerGraph);
+ newMd->enableReferencedByRelation(root->referencedByRelation);
+ newMd->enableReferencesRelation(root->referencesRelation);
+ newMd->setBitfields(md->bitfieldString());
+ newMd->addSectionsToDefinition(root->anchors);
+ newMd->setBodySegment(md->getDefLine(),md->getStartBodyLine(),md->getEndBodyLine());
+ newMd->setBodyDef(md->getBodyDef());
+ newMd->setInitializer(md->initializer());
+ newMd->setMaxInitLines(md->initializerLines());
+ newMd->setMemberGroupId(root->mGrpId);
+ newMd->setMemberSpecifiers(md->getMemberSpecifiers());
+ newMd->setLanguage(root->lang);
+ newMd->setId(root->id);
+ MemberName *mn = Doxygen::memberNameLinkedMap->add(memName);
+ mn->push_back(std::move(newMd));
}
}
}
@@ -3895,153 +3890,142 @@ static void findUsedClassesForClass(const Entry *root,
{
masterCd->setVisited(TRUE);
const ArgumentList &formalArgs = masterCd->templateArguments();
- if (masterCd->memberNameInfoSDict())
+ for (auto &mni : masterCd->memberNameInfoLinkedMap())
{
- MemberNameInfoSDict::Iterator mnili(*masterCd->memberNameInfoSDict());
- MemberNameInfo *mni;
- for (;(mni=mnili.current());++mnili)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mnii(*mni);
- MemberInfo *mi;
- for (mnii.toFirst();(mi=mnii.current());++mnii)
+ MemberDef *md=mi->memberDef();
+ if (md->isVariable() || md->isObjCProperty()) // for each member variable in this class
{
- MemberDef *md=mi->memberDef();
- if (md->isVariable() || md->isObjCProperty()) // for each member variable in this class
+ //printf(" Found variable %s in class %s\n",md->name().data(),masterCd->name().data());
+ QCString type = normalizeNonTemplateArgumentsInString(md->typeString(),masterCd,formalArgs);
+ QCString typedefValue = resolveTypeDef(masterCd,type);
+ if (!typedefValue.isEmpty())
{
- //printf(" Found variable %s in class %s\n",md->name().data(),masterCd->name().data());
- QCString type = normalizeNonTemplateArgumentsInString(md->typeString(),masterCd,formalArgs);
- QCString typedefValue = resolveTypeDef(masterCd,type);
- if (!typedefValue.isEmpty())
+ type = typedefValue;
+ }
+ int pos=0;
+ QCString usedClassName;
+ QCString templSpec;
+ bool found=FALSE;
+ // the type can contain template variables, replace them if present
+ type = substituteTemplateArgumentsInString(type,formalArgs,actualArgs);
+
+ //printf(" template substitution gives=%s\n",type.data());
+ while (!found && extractClassNameFromType(type,pos,usedClassName,templSpec,root->lang)!=-1)
+ {
+ // find the type (if any) that matches usedClassName
+ const ClassDef *typeCd = getResolvedClass(masterCd,
+ masterCd->getFileDef(),
+ usedClassName,
+ 0,0,
+ FALSE,TRUE
+ );
+ //printf("====> usedClassName=%s -> typeCd=%s\n",
+ // usedClassName.data(),typeCd?typeCd->name().data():"<none>");
+ if (typeCd)
{
- type = typedefValue;
+ usedClassName = typeCd->name();
}
- int pos=0;
- QCString usedClassName;
- QCString templSpec;
- bool found=FALSE;
- // the type can contain template variables, replace them if present
- type = substituteTemplateArgumentsInString(type,formalArgs,actualArgs);
- //printf(" template substitution gives=%s\n",type.data());
- while (!found && extractClassNameFromType(type,pos,usedClassName,templSpec,root->lang)!=-1)
+ int sp=usedClassName.find('<');
+ if (sp==-1) sp=0;
+ int si=usedClassName.findRev("::",sp);
+ if (si!=-1)
{
- // find the type (if any) that matches usedClassName
- const ClassDef *typeCd = getResolvedClass(masterCd,
- masterCd->getFileDef(),
- usedClassName,
- 0,0,
- FALSE,TRUE
- );
- //printf("====> usedClassName=%s -> typeCd=%s\n",
- // usedClassName.data(),typeCd?typeCd->name().data():"<none>");
- if (typeCd)
- {
- usedClassName = typeCd->name();
- }
+ // replace any namespace aliases
+ replaceNamespaceAliases(usedClassName,si);
+ }
+ // add any template arguments to the class
+ QCString usedName = removeRedundantWhiteSpace(usedClassName+templSpec);
+ //printf(" usedName=%s\n",usedName.data());
- int sp=usedClassName.find('<');
- if (sp==-1) sp=0;
- int si=usedClassName.findRev("::",sp);
- if (si!=-1)
- {
- // replace any namespace aliases
- replaceNamespaceAliases(usedClassName,si);
- }
- // add any template arguments to the class
- QCString usedName = removeRedundantWhiteSpace(usedClassName+templSpec);
- //printf(" usedName=%s\n",usedName.data());
+ bool delTempNames=FALSE;
+ if (templateNames==0)
+ {
+ templateNames = getTemplateArgumentsInName(formalArgs,usedName);
+ delTempNames=TRUE;
+ }
+ BaseInfo bi(usedName,Public,Normal);
+ findClassRelation(root,context,instanceCd,&bi,templateNames,TemplateInstances,isArtificial);
- bool delTempNames=FALSE;
- if (templateNames==0)
+ for (const Argument &arg : masterCd->templateArguments())
+ {
+ if (arg.name==usedName) // type is a template argument
{
- templateNames = getTemplateArgumentsInName(formalArgs,usedName);
- delTempNames=TRUE;
- }
- BaseInfo bi(usedName,Public,Normal);
- findClassRelation(root,context,instanceCd,&bi,templateNames,TemplateInstances,isArtificial);
+ found=TRUE;
+ Debug::print(Debug::Classes,0," New used class '%s'\n", qPrint(usedName));
- for (const Argument &arg : masterCd->templateArguments())
- {
- if (arg.name==usedName) // type is a template argument
+ ClassDef *usedCd = Doxygen::hiddenClasses->find(usedName);
+ if (usedCd==0)
{
- found=TRUE;
- Debug::print(Debug::Classes,0," New used class '%s'\n", qPrint(usedName));
-
- ClassDef *usedCd = Doxygen::hiddenClasses->find(usedName);
- if (usedCd==0)
- {
- usedCd = 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()));
- instanceCd->addUsedClass(usedCd,md->name(),md->protection());
- usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
+ usedCd = 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()));
+ instanceCd->addUsedClass(usedCd,md->name(),md->protection());
+ usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
}
+ }
- if (!found)
- {
- ClassDef *usedCd=findClassWithinClassContext(context,masterCd,usedName);
- //printf("Looking for used class %s: result=%s master=%s\n",
- // usedName.data(),usedCd?usedCd->name().data():"<none>",masterCd?masterCd->name().data():"<none>");
+ if (!found)
+ {
+ ClassDef *usedCd=findClassWithinClassContext(context,masterCd,usedName);
+ //printf("Looking for used class %s: result=%s master=%s\n",
+ // usedName.data(),usedCd?usedCd->name().data():"<none>",masterCd?masterCd->name().data():"<none>");
- if (usedCd)
- {
- found=TRUE;
- Debug::print(Debug::Classes,0," Adding used class '%s' (2)\n", qPrint(usedCd->name()));
- instanceCd->addUsedClass(usedCd,md->name(),md->protection()); // class exists
- usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
- }
- }
- if (delTempNames)
+ if (usedCd)
{
- delete templateNames;
- templateNames=0;
+ found=TRUE;
+ Debug::print(Debug::Classes,0," Adding used class '%s' (2)\n", qPrint(usedCd->name()));
+ instanceCd->addUsedClass(usedCd,md->name(),md->protection()); // class exists
+ usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
}
}
- if (!found && !type.isEmpty()) // used class is not documented in any scope
+ if (delTempNames)
{
- ClassDef *usedCd = Doxygen::hiddenClasses->find(type);
- if (usedCd==0 && !Config_getBool(HIDE_UNDOC_RELATIONS))
- {
- if (type.right(2)=="(*" || type.right(2)=="(^") // type is a function pointer
- {
- 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->setUsedOnly(TRUE);
- usedCd->setLanguage(masterCd->getLanguage());
- Doxygen::hiddenClasses->append(type,usedCd);
- }
- if (usedCd)
+ delete templateNames;
+ templateNames=0;
+ }
+ }
+ if (!found && !type.isEmpty()) // used class is not documented in any scope
+ {
+ ClassDef *usedCd = Doxygen::hiddenClasses->find(type);
+ if (usedCd==0 && !Config_getBool(HIDE_UNDOC_RELATIONS))
+ {
+ if (type.right(2)=="(*" || type.right(2)=="(^") // type is a function pointer
{
- if (isArtificial) usedCd->setArtificial(TRUE);
- Debug::print(Debug::Classes,0," Adding used class '%s' (3)\n", qPrint(usedCd->name()));
- instanceCd->addUsedClass(usedCd,md->name(),md->protection());
- usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
+ 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->setUsedOnly(TRUE);
+ usedCd->setLanguage(masterCd->getLanguage());
+ Doxygen::hiddenClasses->append(type,usedCd);
+ }
+ if (usedCd)
+ {
+ if (isArtificial) usedCd->setArtificial(TRUE);
+ Debug::print(Debug::Classes,0," Adding used class '%s' (3)\n", qPrint(usedCd->name()));
+ instanceCd->addUsedClass(usedCd,md->name(),md->protection());
+ usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
}
}
}
}
}
- else
- {
- //printf("no members for class %s (%p)\n",masterCd->name().data(),masterCd);
- }
}
static void findBaseClassesForClass(
@@ -4723,7 +4707,7 @@ static void computeClassRelations()
{
findBaseClassesForClass(root,cd,cd,cd,DocumentedOnly,FALSE);
}
- int numMembers = cd && cd->memberNameInfoSDict() ? cd->memberNameInfoSDict()->count() : 0;
+ int numMembers = cd ? cd->memberNameInfoLinkedMap().size() : 0;
if ((cd==0 || (!cd->hasDocumentation() && !cd->isReference())) && numMembers>0 &&
bName.right(2)!="::")
{
@@ -7482,10 +7466,10 @@ static void buildCompleteMemberLists()
cd->mergeMembers();
}
}
- // now sort the member list of all classes.
+ // now sort the member list of all members for all classes.
for (cli.toFirst();(cd=cli.current());++cli)
{
- if (cd->memberNameInfoSDict()) cd->memberNameInfoSDict()->sort();
+ cd->sortAllMembersList();
}
}
diff --git a/src/groupdef.cpp b/src/groupdef.cpp
index d4f4f5d..0f8ca97 100644
--- a/src/groupdef.cpp
+++ b/src/groupdef.cpp
@@ -143,7 +143,7 @@ class GroupDefImpl : public DefinitionImpl, public GroupDef
PageSDict * m_exampleDict; // list of examples in the group
DirList * m_dirList; // list of directories in the group
MemberList * m_allMemberList;
- MemberNameInfoSDict *m_allMemberNameInfoSDict;
+ MemberNameInfoLinkedMap m_allMemberNameInfoLinkedMap;
Definition * m_groupScope;
QList<MemberList> m_memberLists;
MemberGroupSDict * m_memberGroupSDict;
@@ -170,8 +170,6 @@ GroupDefImpl::GroupDefImpl(const char *df,int dl,const char *na,const char *t,
m_pageDict = new PageSDict(17);
m_exampleDict = new PageSDict(17);
m_dirList = new DirList;
- m_allMemberNameInfoSDict = new MemberNameInfoSDict(17);
- m_allMemberNameInfoSDict->setAutoDelete(TRUE);
if (refFileName)
{
m_fileName=stripExtension(refFileName);
@@ -200,7 +198,6 @@ GroupDefImpl::~GroupDefImpl()
delete m_pageDict;
delete m_exampleDict;
delete m_allMemberList;
- delete m_allMemberNameInfoSDict;
delete m_memberGroupSDict;
delete m_dirList;
}
@@ -378,54 +375,43 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly)
if (md->isHidden()) return FALSE;
updateLanguage(md);
//printf("GroupDef(%s)::insertMember(%s)\n", title.data(), md->name().data());
- MemberNameInfo *mni=0;
- if ((mni=(*m_allMemberNameInfoSDict)[md->name()]))
- { // member with this name already found
- MemberNameInfoIterator srcMnii(*mni);
- const MemberInfo *srcMi;
- for ( ; (srcMi=srcMnii.current()) ; ++srcMnii )
+ MemberNameInfo *mni = m_allMemberNameInfoLinkedMap.add(md->name());
+ for (auto &srcMi : *mni)
+ {
+ const MemberDef *srcMd = srcMi->memberDef();
+ if (srcMd==md) return FALSE; // already added before!
+
+ bool sameScope = srcMd->getOuterScope()==md->getOuterScope() || // same class or namespace
+ // both inside a file => definition and declaration do not have to be in the same file
+ (srcMd->getOuterScope()->definitionType()==Definition::TypeFile &&
+ md->getOuterScope()->definitionType()==Definition::TypeFile);
+
+ const ArgumentList &srcMdAl = srcMd->argumentList();
+ const ArgumentList &mdAl = md->argumentList();
+ const ArgumentList &tSrcMdAl = srcMd->templateArguments();
+ const ArgumentList &tMdAl = md->templateArguments();
+
+ if (srcMd->isFunction() && md->isFunction() && // both are a function
+ (tSrcMdAl.size()==tMdAl.size()) && // same number of template arguments
+ matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),&srcMdAl,
+ md->getOuterScope(),md->getFileDef(),&mdAl,
+ TRUE
+ ) && // matching parameters
+ sameScope // both are found in the same scope
+ )
{
- const MemberDef *srcMd = srcMi->memberDef();
- if (srcMd==md) return FALSE; // already added before!
-
- bool sameScope = srcMd->getOuterScope()==md->getOuterScope() || // same class or namespace
- // both inside a file => definition and declaration do not have to be in the same file
- (srcMd->getOuterScope()->definitionType()==Definition::TypeFile &&
- md->getOuterScope()->definitionType()==Definition::TypeFile);
-
- const ArgumentList &srcMdAl = srcMd->argumentList();
- const ArgumentList &mdAl = md->argumentList();
- const ArgumentList &tSrcMdAl = srcMd->templateArguments();
- const ArgumentList &tMdAl = md->templateArguments();
-
- if (srcMd->isFunction() && md->isFunction() && // both are a function
- (tSrcMdAl.size()==tMdAl.size()) && // same number of template arguments
- matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),&srcMdAl,
- md->getOuterScope(),md->getFileDef(),&mdAl,
- TRUE
- ) && // matching parameters
- sameScope // both are found in the same scope
- )
+ if (srcMd->getGroupAlias()==0)
{
- if (srcMd->getGroupAlias()==0)
- {
- md->setGroupAlias(srcMd);
- }
- else if (md!=srcMd->getGroupAlias())
- {
- md->setGroupAlias(srcMd->getGroupAlias());
- }
- return FALSE; // member is the same as one that is already added
+ md->setGroupAlias(srcMd);
}
+ else if (md!=srcMd->getGroupAlias())
+ {
+ md->setGroupAlias(srcMd->getGroupAlias());
+ }
+ return FALSE; // member is the same as one that is already added
}
- mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE));
- }
- else
- {
- mni = new MemberNameInfo(md->name());
- mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE));
- m_allMemberNameInfoSDict->append(mni->memberName(),mni);
}
+ mni->push_back(std::make_unique<MemberInfo>(md,md->protection(),md->virtualness(),FALSE));
//printf("Added member!\n");
m_allMemberList->append(md);
switch(md->memberType())
@@ -539,23 +525,10 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly)
void GroupDefImpl::removeMember(MemberDef *md)
{
// fprintf(stderr, "GroupDef(%s)::removeMember( %s )\n", title.data(), md->name().data());
- MemberNameInfo *mni = m_allMemberNameInfoSDict->find(md->name());
+ MemberNameInfo *mni = m_allMemberNameInfoLinkedMap.find(md->name());
if (mni)
{
- MemberNameInfoIterator mnii(*mni);
- while( mnii.current() )
- {
- if( mnii.current()->memberDef() == md )
- {
- mni->remove(mnii.current());
- break;
- }
- ++mnii;
- }
- if( mni->isEmpty() )
- {
- m_allMemberNameInfoSDict->remove(md->name());
- }
+ m_allMemberNameInfoLinkedMap.del(md->name());
removeMemberFromList(MemberListType_allMembersList,md);
switch(md->memberType())
diff --git a/src/groupdef.h b/src/groupdef.h
index 8a84a98..c210d9e 100644
--- a/src/groupdef.h
+++ b/src/groupdef.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.
*
@@ -33,7 +33,6 @@ class GroupList;
class OutputList;
class NamespaceSDict;
class MemberGroupSDict;
-class MemberNameInfoSDict;
class PageSDict;
class PageDef;
class DirDef;
diff --git a/src/linkedmap.h b/src/linkedmap.h
index c724a39..84c4a91 100644
--- a/src/linkedmap.h
+++ b/src/linkedmap.h
@@ -20,9 +20,11 @@
#include <vector>
#include <memory>
#include <string>
+#include <algorithm>
//! @brief Container class representing a vector of objects with unique keys.
-//! @details Elements can be quickly looked up given the key.
+//! @details Objects can efficiently be looked up given the key.
+//! Objects are owned by the container.
//! When adding objects the order of addition is kept, and used while iterating.
template<class T>
class LinkedMap
@@ -34,7 +36,7 @@ class LinkedMap
using iterator = typename Vec::iterator;
using const_iterator = typename Vec::const_iterator;
- //! find an element given the key.
+ //! Find an object given the key.
//! Returns a pointer to the element if found or nullptr if it is not found.
const T *find(const char *k) const
{
@@ -43,15 +45,15 @@ class LinkedMap
return it!=m_lookup.end() ? it->second : nullptr;
}
- //! non-const wrapper for find() const
+ //! A non-const wrapper for find() const
T* find(const char *key)
{
return const_cast<T*>(static_cast<const LinkedMap&>(*this).find(key));
}
- //! Adds a new element to the ordered set if it was not added already.
- //! Return a non-owning pointer to the newly added item, or to the existing item if it was
- //! already inserted before.
+ //! Adds a new object to the ordered set 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.
template<class...Args>
T *add(const char *k, Args&&... args)
{
@@ -67,12 +69,97 @@ class LinkedMap
return result;
}
- iterator begin() { return m_entries.begin(); }
- iterator end() { return m_entries.end(); }
- const_iterator begin() const { return m_entries.cbegin(); }
+ //! Removes an object from the container and deletes it.
+ //! Returns true if the object was delete or false it is was not found.
+ bool del(const char *k)
+ {
+ std::string key = k ? std::string(k) : std::string();
+ auto it = m_lookup.find(key);
+ if (it!=m_lookup.end())
+ {
+ auto vecit = std::find_if(m_entries.begin(),m_entries.end(),[obj=it->second](auto &el) { return el.get()==obj; });
+ if (vecit!=m_entries.end()) // should always be true
+ {
+ m_entries.erase(vecit);
+ m_lookup.erase(it);
+ return true;
+ }
+ }
+ 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(); }
+ bool empty() const { return m_entries.empty(); }
+ int size() const { return m_entries.size(); }
+
+ void clear()
+ {
+ m_entries.clear();
+ m_lookup.clear();
+ }
+
+ private:
+ Map m_lookup;
+ Vec m_entries;
+};
+
+#if 0 // not yet used
+//! @brief Container class representing a vector of objects with unique keys.
+//! @details Objects can be efficiently be looked up given the key.
+//! Objects are \e not owned by the container, the container will only hold references.
+//! When adding objects the order of addition is kept, and used while iterating.
+template<class T>
+class LinkedRefMap
+{
+ public:
+ using Ptr = T*;
+ using Vec = std::vector<Ptr>;
+ using Map = std::unordered_map<std::string,T*>;
+ using iterator = typename Vec::iterator;
+ using const_iterator = typename Vec::const_iterator;
+
+ //! find an object given the key.
+ //! Returns a pointer to the object if found or nullptr if it is not found.
+ const T *find(const char *k) const
+ {
+ std::string key = k ? std::string(k) : std::string();
+ auto it = m_lookup.find(key);
+ return it!=m_lookup.end() ? it->second : nullptr;
+ }
+
+ //! non-const wrapper for find() const
+ T* find(const char *key)
+ {
+ return const_cast<T*>(static_cast<const LinkedRefMap&>(*this).find(key));
+ }
+
+ //! Adds a new object to the ordered set if it was not added already.
+ //! Return true if the object was added, and false if an object with the same key
+ //! was already added before
+ bool add(const char *k, T* obj)
+ {
+ if (find(k)==nullptr) // new element
+ {
+ std::string key = k ? std::string(k) : std::string();
+ m_lookup.insert({key,obj});
+ m_entries.push_back(obj);
+ return true;
+ }
+ else // already existing, don't add
+ {
+ 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(); }
- bool empty() const { return m_entries.empty(); }
- int size() const { return m_entries.size(); }
+ bool empty() const { return m_entries.empty(); }
+ int size() const { return m_entries.size(); }
void clear()
{
@@ -84,6 +171,7 @@ class LinkedMap
Map m_lookup;
Vec m_entries;
};
+#endif
#endif
diff --git a/src/membername.cpp b/src/membername.cpp
deleted file mode 100644
index f969df8..0000000
--- a/src/membername.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************
- *
- *
- *
- * 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
- * for any purpose. It is provided "as is" without express or implied warranty.
- * See the GNU General Public License for more details.
- *
- * Documents produced by Doxygen are derivative works derived from the
- * input used in their production; they are not affected by this license.
- *
- */
-
-#include "membername.h"
-#include "classdef.h"
-#include "util.h"
-#include "filedef.h"
-
-MemberNameInfo::MemberNameInfo(const char *n) : QList<MemberInfo>()
-{
- name=n;
- setAutoDelete(TRUE);
-}
-
-int MemberNameInfo::compareValues(const MemberInfo *m1,const MemberInfo *m2) const
-{
- const ClassDef *c1=m1->memberDef()->getClassDef();
- const ClassDef *c2=m2->memberDef()->getClassDef();
- const FileDef *f1=m1->memberDef()->getFileDef();
- const FileDef *f2=m2->memberDef()->getFileDef();
- if (c1 && c2)
- return qstrcmp(c1->name(),c2->name());
- else if (f1 && f2)
- return qstrcmp(f1->name(),f2->name());
- else
- return 0;
-}
-
diff --git a/src/membername.h b/src/membername.h
index aa2ce5f..406d406 100644
--- a/src/membername.h
+++ b/src/membername.h
@@ -38,6 +38,8 @@ class MemberName
iterator begin() { return m_members.begin(); }
iterator end() { return m_members.end(); }
+ const_iterator begin() const { return m_members.begin(); }
+ const_iterator end() const { return m_members.end(); }
const_iterator cbegin() const { return m_members.cbegin(); }
const_iterator cend() const { return m_members.cend(); }
reverse_iterator rbegin() { return m_members.rbegin(); }
@@ -95,37 +97,36 @@ class MemberInfo
const ClassDef *m_ambigClass = 0;
};
-/** Class representing all MemberInfo objects with the same name */
-class MemberNameInfo : public QList<MemberInfo>
+class MemberNameInfo
{
public:
- MemberNameInfo(const char *name);
- ~MemberNameInfo() {}
- const char *memberName() const { return name; }
- private:
- int compareValues(const MemberInfo *item1,const MemberInfo *item2) const;
- QCString name;
-};
+ using Ptr = std::unique_ptr<MemberInfo>;
+ using Vec = std::vector<Ptr>;
+ using iterator = typename Vec::iterator;
+ using const_iterator = typename Vec::const_iterator;
-/** Iterator for MemberInfo objects in a MemberNameInfo list. */
-class MemberNameInfoIterator : public QListIterator<MemberInfo>
-{
- public:
- MemberNameInfoIterator(const MemberNameInfo &mnii)
- : QListIterator<MemberInfo>(mnii) {}
+ MemberNameInfo(const char *name) : m_name(name) {}
+ const char *memberName() const { return m_name; }
+
+ iterator begin() { return m_members.begin(); }
+ iterator end() { return m_members.end(); }
+ const_iterator begin() const { return m_members.begin(); }
+ const_iterator end() const { return m_members.end(); }
+ bool empty() const { return m_members.empty(); }
+ int size() const { return m_members.size(); }
+ Ptr &back() { return m_members.back(); }
+ const Ptr &back() const { return m_members.back(); }
+ Ptr &front() { return m_members.front(); }
+ const Ptr &front() const { return m_members.front(); }
+ void push_back(Ptr &&p) { m_members.push_back(std::move(p)); }
+
+ private:
+ QCString m_name;
+ Vec m_members;
};
-/** Sorted dictionary of MemberNameInfo objects. */
-class MemberNameInfoSDict : public SDict<MemberNameInfo>
+class MemberNameInfoLinkedMap : public LinkedMap<MemberNameInfo>
{
- public:
- MemberNameInfoSDict(uint size) : SDict<MemberNameInfo>(size) {}
- ~MemberNameInfoSDict() {}
- private:
- int compareValues(const MemberNameInfo *item1,const MemberNameInfo *item2) const
- {
- return qstricmp(item1->memberName(), item2->memberName());
- }
};
#endif
diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp
index 04ddfb4..b6f663a 100644
--- a/src/perlmodgen.cpp
+++ b/src/perlmodgen.cpp
@@ -1750,32 +1750,25 @@ void PerlModGenerator::generatePerlModSection(const Definition *d,
void PerlModGenerator::addListOfAllMembers(const ClassDef *cd)
{
m_output.openList("all_members");
- if (cd->memberNameInfoSDict())
+ for (auto &mni : cd->memberNameInfoLinkedMap())
{
- MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict());
- MemberNameInfo *mni;
- for (mnii.toFirst();(mni=mnii.current());++mnii)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mii(*mni);
- MemberInfo *mi;
- for (mii.toFirst();(mi=mii.current());++mii)
- {
- const MemberDef *md=mi->memberDef();
- const ClassDef *mcd=md->getClassDef();
- const Definition *d=md->getGroupDef();
- if (d==0) d = mcd;
+ const MemberDef *md=mi->memberDef();
+ const ClassDef *mcd=md->getClassDef();
+ const Definition *d=md->getGroupDef();
+ if (d==0) d = mcd;
- m_output.openHash()
- .addFieldQuotedString("name", md->name())
- .addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
- .addFieldQuotedString("protection", getProtectionName(mi->prot()));
+ m_output.openHash()
+ .addFieldQuotedString("name", md->name())
+ .addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
+ .addFieldQuotedString("protection", getProtectionName(mi->prot()));
- if (!mi->ambiguityResolutionScope().isEmpty())
- m_output.addFieldQuotedString("ambiguity_scope", mi->ambiguityResolutionScope());
+ if (!mi->ambiguityResolutionScope().isEmpty())
+ m_output.addFieldQuotedString("ambiguity_scope", mi->ambiguityResolutionScope());
- m_output.addFieldQuotedString("scope", mcd->name())
- .closeHash();
- }
+ m_output.addFieldQuotedString("scope", mcd->name())
+ .closeHash();
}
}
m_output.closeList();
diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp
index 895f70c..eb944e6 100644
--- a/src/sqlite3gen.cpp
+++ b/src/sqlite3gen.cpp
@@ -1904,20 +1904,13 @@ static void generateSqlite3Section( const Definition *d,
static void associateAllClassMembers(const ClassDef *cd, struct Refid scope_refid)
{
- if (cd->memberNameInfoSDict())
+ for (auto &mni : cd->memberNameInfoLinkedMap())
{
- MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict());
- MemberNameInfo *mni;
- for (mnii.toFirst();(mni=mnii.current());++mnii)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mii(*mni);
- MemberInfo *mi;
- for (mii.toFirst();(mi=mii.current());++mii)
- {
- MemberDef *md = mi->memberDef();
- QCString qrefid = md->getOutputFileBase() + "_1" + md->anchor();
- associateMember(md, insertRefid(qrefid), scope_refid);
- }
+ MemberDef *md = mi->memberDef();
+ QCString qrefid = md->getOutputFileBase() + "_1" + md->anchor();
+ associateMember(md, insertRefid(qrefid), scope_refid);
}
}
}
diff --git a/src/util.h b/src/util.h
index a34a53c..da17ff2 100644
--- a/src/util.h
+++ b/src/util.h
@@ -51,7 +51,6 @@ class NamespaceSDict;
class ClassList;
class MemberGroupSDict;
struct TagInfo;
-class MemberNameInfoSDict;
class PageDef;
class SectionInfo;
class QDir;
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index e918f24..2424853 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -1076,45 +1076,38 @@ static void generateXMLSection(const Definition *d,FTextStream &ti,FTextStream &
static void writeListOfAllMembers(const ClassDef *cd,FTextStream &t)
{
t << " <listofallmembers>" << endl;
- if (cd->memberNameInfoSDict())
+ for (auto &mni : cd->memberNameInfoLinkedMap())
{
- MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict());
- MemberNameInfo *mni;
- for (mnii.toFirst();(mni=mnii.current());++mnii)
+ for (auto &mi : *mni)
{
- MemberNameInfoIterator mii(*mni);
- MemberInfo *mi;
- for (mii.toFirst();(mi=mii.current());++mii)
+ const MemberDef *md=mi->memberDef();
+ if (!md->isAnonymous())
{
- const MemberDef *md=mi->memberDef();
- if (!md->isAnonymous())
+ Protection prot = mi->prot();
+ Specifier virt=md->virtualness();
+ t << " <member refid=\"" << memberOutputFileBase(md) << "_1" <<
+ md->anchor() << "\" prot=\"";
+ switch (prot)
{
- Protection prot = mi->prot();
- Specifier virt=md->virtualness();
- t << " <member refid=\"" << memberOutputFileBase(md) << "_1" <<
- md->anchor() << "\" prot=\"";
- switch (prot)
- {
- case Public: t << "public"; break;
- case Protected: t << "protected"; break;
- case Private: t << "private"; break;
- case Package: t << "package"; break;
- }
- t << "\" virt=\"";
- switch(virt)
- {
- case Normal: t << "non-virtual"; break;
- case Virtual: t << "virtual"; break;
- case Pure: t << "pure-virtual"; break;
- }
- t << "\"";
- if (!mi->ambiguityResolutionScope().isEmpty())
- {
- t << " ambiguityscope=\"" << convertToXML(mi->ambiguityResolutionScope()) << "\"";
- }
- t << "><scope>" << convertToXML(cd->name()) << "</scope><name>" <<
- convertToXML(md->name()) << "</name></member>" << endl;
+ case Public: t << "public"; break;
+ case Protected: t << "protected"; break;
+ case Private: t << "private"; break;
+ case Package: t << "package"; break;
+ }
+ t << "\" virt=\"";
+ switch(virt)
+ {
+ case Normal: t << "non-virtual"; break;
+ case Virtual: t << "virtual"; break;
+ case Pure: t << "pure-virtual"; break;
+ }
+ t << "\"";
+ if (!mi->ambiguityResolutionScope().isEmpty())
+ {
+ t << " ambiguityscope=\"" << convertToXML(mi->ambiguityResolutionScope()) << "\"";
}
+ t << "><scope>" << convertToXML(cd->name()) << "</scope><name>" <<
+ convertToXML(md->name()) << "</name></member>" << endl;
}
}
}