summaryrefslogtreecommitdiff
path: root/src/filedef.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/filedef.cpp')
-rw-r--r--src/filedef.cpp213
1 files changed, 62 insertions, 151 deletions
diff --git a/src/filedef.cpp b/src/filedef.cpp
index e8d6066..2fb2af7 100644
--- a/src/filedef.cpp
+++ b/src/filedef.cpp
@@ -48,6 +48,9 @@
//---------------------------------------------------------------------------
+using DefinitionLineMap = std::unordered_map<int,const Definition *>;
+using MemberDefLineMap = std::unordered_map<int,const MemberDef *>;
+
class FileDefImpl : public DefinitionMixin<FileDef>
{
public:
@@ -69,8 +72,8 @@ class FileDefImpl : public DefinitionMixin<FileDef>
virtual const QCString &docName() const { return m_docname; }
virtual bool isSource() const { return m_isSource; }
virtual bool isDocumentationFile() const;
- virtual Definition *getSourceDefinition(int lineNr) const;
- virtual MemberDef *getSourceMember(int lineNr) const;
+ virtual const Definition *getSourceDefinition(int lineNr) const;
+ virtual const MemberDef *getSourceMember(int lineNr) const;
virtual QCString getPath() const { return m_path; }
virtual QCString getVersion() const { return m_fileVersion; }
virtual bool isLinkableInProject() const;
@@ -84,8 +87,8 @@ class FileDefImpl : public DefinitionMixin<FileDef>
virtual QList<IncludeInfo> *includedByFileList() const { return m_includedByList; }
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 MemberLists &getMemberLists() const { return m_memberLists; }
+ 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;
@@ -95,7 +98,7 @@ class FileDefImpl : public DefinitionMixin<FileDef>
virtual void countMembers();
virtual int numDocMembers() const;
virtual int numDecMembers() const;
- virtual void addSourceRef(int line,Definition *d,MemberDef *md);
+ virtual void addSourceRef(int line,const Definition *d,const MemberDef *md);
virtual void writeDocumentation(OutputList &ol);
virtual void writeMemberPages(OutputList &ol);
virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const;
@@ -127,7 +130,6 @@ class FileDefImpl : public DefinitionMixin<FileDef>
private:
void acquireFileVersion();
- MemberList *createMemberList(MemberListType lt);
void addMemberToList(MemberListType lt,MemberDef *md);
void writeMemberDeclarations(OutputList &ol,MemberListType lt,const QCString &title);
void writeMemberDocumentation(OutputList &ol,MemberListType lt,const QCString &title);
@@ -162,14 +164,14 @@ class FileDefImpl : public DefinitionMixin<FileDef>
QCString m_outputDiskName;
QCString m_fileName;
QCString m_docname;
- QIntDict<Definition> *m_srcDefDict;
- QIntDict<MemberDef> *m_srcMemberDict;
+ DefinitionLineMap m_srcDefMap;
+ MemberDefLineMap m_srcMemberMap;
bool m_isSource;
QCString m_fileVersion;
PackageDef *m_package;
DirDef *m_dir;
- QList<MemberList> m_memberLists;
- MemberGroupSDict *m_memberGroupSDict;
+ MemberLists m_memberLists;
+ MemberGroupList m_memberGroups;
NamespaceLinkedRefMap m_namespaces;
ClassLinkedRefMap m_classes;
ClassLinkedRefMap m_interfaces;
@@ -230,8 +232,6 @@ FileDefImpl::FileDefImpl(const char *p,const char *nm,
m_includeDict = 0;
m_includedByList = 0;
m_includedByDict = 0;
- m_srcDefDict = 0;
- m_srcMemberDict = 0;
m_package = 0;
m_isSource = guessSection(nm)==Entry::SOURCE_SEC;
m_docname = nm;
@@ -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);
}
@@ -253,9 +252,6 @@ FileDefImpl::~FileDefImpl()
delete m_includeList;
delete m_includedByDict;
delete m_includedByList;
- delete m_srcDefDict;
- delete m_srcMemberDict;
- delete m_memberGroupSDict;
}
void FileDefImpl::setDiskName(const QCString &name)
@@ -284,14 +280,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,19 +290,12 @@ 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);
- MemberList *ml;
- for (mli.toFirst();(ml=mli.current());++mli)
+ for (auto &ml : m_memberLists)
{
if (ml->listType()&MemberListType_declarationLists)
{
@@ -411,14 +395,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 +730,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);
}
}
}
@@ -1068,9 +1041,7 @@ void FileDefImpl::writeMemberPages(OutputList &ol)
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
- QListIterator<MemberList> mli(m_memberLists);
- MemberList *ml;
- for (mli.toFirst();(ml=mli.current());++mli)
+ for (const auto &ml : m_memberLists)
{
if (ml->listType()&MemberListType_documentationLists)
{
@@ -1267,28 +1238,21 @@ void FileDefImpl::parseSource(ClangTUParser *clangParser)
void FileDefImpl::addMembersToMemberGroup()
{
- QListIterator<MemberList> mli(m_memberLists);
- MemberList *ml;
- for (mli.toFirst();(ml=mli.current());++mli)
+ for (auto &ml : m_memberLists)
{
if (ml->listType()&MemberListType_declarationLists)
{
- ::addMembersToMemberGroup(ml,&m_memberGroupSDict,this);
+ ::addMembersToMemberGroup(ml.get(),&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();
}
}
}
@@ -1307,8 +1271,8 @@ void FileDefImpl::insertMember(MemberDef *md)
if (allMemberList==0)
{
- allMemberList = new MemberList(MemberListType_allMembersList);
- m_memberLists.append(allMemberList);
+ m_memberLists.emplace_back(std::make_unique<MemberList>(MemberListType_allMembersList));
+ allMemberList = m_memberLists.back().get();
}
allMemberList->append(md);
//::addFileMemberNameToIndex(md);
@@ -1396,40 +1360,30 @@ QCString FileDefImpl::name() const
return DefinitionMixin::name();
}
-void FileDefImpl::addSourceRef(int line,Definition *d,MemberDef *md)
+void FileDefImpl::addSourceRef(int line,const Definition *d,const MemberDef *md)
{
//printf("FileDefImpl::addSourceDef(%d,%p,%p)\n",line,d,md);
if (d)
{
- if (m_srcDefDict==0) m_srcDefDict = new QIntDict<Definition>(257);
- if (m_srcMemberDict==0) m_srcMemberDict = new QIntDict<MemberDef>(257);
- m_srcDefDict->insert(line,d);
- if (md) m_srcMemberDict->insert(line,md);
+ m_srcDefMap.insert(std::make_pair(line,d));
+ if (md) m_srcMemberMap.insert(std::make_pair(line,md));
//printf("Adding member %s with anchor %s at line %d to file %s\n",
// md?md->name().data():"<none>",md?md->anchor().data():"<none>",line,name().data());
}
}
-Definition *FileDefImpl::getSourceDefinition(int lineNr) const
+const Definition *FileDefImpl::getSourceDefinition(int lineNr) const
{
- Definition *result=0;
- if (m_srcDefDict)
- {
- result = m_srcDefDict->find(lineNr);
- }
- //printf("%s::getSourceDefinition(%d)=%s\n",name().data(),lineNr,result?result->name().data():"none");
- return result;
+ auto it = m_srcDefMap.find(lineNr);
+ //printf("%s::getSourceDefinition(%d)=%s\n",name().data(),lineNr,it!=m_srcDefMap.end()?it->second->name().data():"none");
+ return it!=m_srcDefMap.end() ? it->second : 0;
}
-MemberDef *FileDefImpl::getSourceMember(int lineNr) const
+const MemberDef *FileDefImpl::getSourceMember(int lineNr) const
{
- MemberDef *result=0;
- if (m_srcMemberDict)
- {
- result = m_srcMemberDict->find(lineNr);
- }
- //printf("%s::getSourceMember(%d)=%s\n",name().data(),lineNr,result?result->name().data():"none");
- return result;
+ auto it = m_srcMemberMap.find(lineNr);
+ //printf("%s::getSourceMember(%d)=%s\n",name().data(),lineNr,it!=m_srcMemberMap.end()?it->second->name().data():"none");
+ return it!=m_srcMemberMap.end() ? it->second : 0;
}
@@ -1575,18 +1529,11 @@ 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;
- for (mli.toFirst();(ml=mli.current());++mli)
+ for (auto &ml : m_memberLists)
{
if (ml->listType()&MemberListType_documentationLists)
{
@@ -1791,20 +1738,18 @@ static void addDirsAsGroups(Directory *root,GroupDef *parent,int level)
GroupDef *gd=0;
if (root->kind()==DirEntry::Dir)
{
- gd = createGroupDef("[generated]",
+ gd = Doxygen::groupLinkedMap->add(root->path(),
+ std::unique_ptr<GroupDef>(
+ createGroupDef("[generated]",
1,
root->path(), // name
root->name() // title
- );
+ )));
if (parent)
{
parent->addGroup(gd);
gd->makePartOfGroup(parent);
}
- else
- {
- Doxygen::groupSDict->append(root->path(),gd);
- }
}
QListIterator<DirEntry> dli(root->children());
DirEntry *de;
@@ -1932,29 +1877,11 @@ QCString FileDefImpl::includeName() const
return getSourceFileBase();
}
-MemberList *FileDefImpl::createMemberList(MemberListType lt)
-{
- m_memberLists.setAutoDelete(TRUE);
- QListIterator<MemberList> mli(m_memberLists);
- MemberList *ml;
- for (mli.toFirst();(ml=mli.current());++mli)
- {
- if (ml->listType()==lt)
- {
- return ml;
- }
- }
- // not found, create a new member list
- ml = new MemberList(lt);
- m_memberLists.append(ml);
- return ml;
-}
-
void FileDefImpl::addMemberToList(MemberListType lt,MemberDef *md)
{
static bool sortBriefDocs = Config_getBool(SORT_BRIEF_DOCS);
static bool sortMemberDocs = Config_getBool(SORT_MEMBER_DOCS);
- MemberList *ml = createMemberList(lt);
+ const auto &ml = m_memberLists.get(lt);
ml->setNeedsSorting(
((ml->listType()&MemberListType_declarationLists) && sortBriefDocs) ||
((ml->listType()&MemberListType_documentationLists) && sortMemberDocs));
@@ -1968,29 +1895,22 @@ void FileDefImpl::addMemberToList(MemberListType lt,MemberDef *md)
MemberDefMutable *mdm = toMemberDefMutable(md);
if (mdm)
{
- mdm->setSectionList(this,ml);
+ mdm->setSectionList(this,ml.get());
}
}
}
void FileDefImpl::sortMemberLists()
{
- QListIterator<MemberList> mli(m_memberLists);
- MemberList *ml;
- for (;(ml=mli.current());++mli)
+ for (auto &ml : m_memberLists)
{
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))
@@ -2018,13 +1938,11 @@ void FileDefImpl::sortMemberLists()
MemberList *FileDefImpl::getMemberList(MemberListType lt) const
{
- QListIterator<MemberList> mli(m_memberLists);
- MemberList *ml;
- for (;(ml=mli.current());++mli)
+ for (auto &ml : m_memberLists)
{
if (ml->listType()==lt)
{
- return ml;
+ return ml.get();
}
}
return 0;
@@ -2109,22 +2027,15 @@ QCString FileDefImpl::includedByDependencyGraphFileName() const
void FileDefImpl::countMembers()
{
- QListIterator<MemberList> mli(m_memberLists);
- MemberList *ml;
- for (mli.toFirst();(ml=mli.current());++mli)
+ for (auto &ml : m_memberLists)
{
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();
}
}