diff options
Diffstat (limited to 'src/index.cpp')
-rw-r--r-- | src/index.cpp | 534 |
1 files changed, 200 insertions, 334 deletions
diff --git a/src/index.cpp b/src/index.cpp index e68f7eb..e2e5ea1 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -21,6 +21,8 @@ #include <stdlib.h> +#include <array> + #include <assert.h> #include <qtextstream.h> #include <qdatetime.h> @@ -145,29 +147,25 @@ static void endIndexHierarchy(OutputList &ol,int level) //---------------------------------------------------------------------------- -class MemberIndexList : public QList<MemberDef> -{ - public: - typedef const MemberDef ElementType; - MemberIndexList(uint letter) : QList<MemberDef>(), m_letter(letter) {} - ~MemberIndexList() {} - int compareValues(const MemberDef *md1, const MemberDef *md2) const - { - int result = qstricmp(md1->name(),md2->name()); - if (result==0) - { - result = qstricmp(md1->qualifiedName(),md2->qualifiedName()); - } - return result; - } - uint letter() const { return m_letter; } - private: - uint m_letter; -}; +using MemberIndexList = std::vector<const MemberDef *>; +using MemberIndexMap = std::map<std::string,MemberIndexList>; + +static std::array<MemberIndexMap,CMHL_Total> g_classIndexLetterUsed; +static std::array<MemberIndexMap,FMHL_Total> g_fileIndexLetterUsed; +static std::array<MemberIndexMap,NMHL_Total> g_namespaceIndexLetterUsed; -static LetterToIndexMap<MemberIndexList> g_memberIndexLetterUsed[CMHL_Total]; -static LetterToIndexMap<MemberIndexList> g_fileIndexLetterUsed[FMHL_Total]; -static LetterToIndexMap<MemberIndexList> g_namespaceIndexLetterUsed[NMHL_Total]; +void MemberIndexMap_add(MemberIndexMap &map,const std::string &letter,const MemberDef *md) +{ + auto it = map.find(letter); + if (it!=map.end()) + { + it->second.push_back(md); + } + else + { + map.insert(std::make_pair(letter,std::vector<const MemberDef*>({md}))); + } +} const int maxItemsBeforeQuickIndex = MAX_ITEMS_BEFORE_QUICK_INDEX; @@ -357,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().empty() || !def->getMemberGroups().empty(); Doxygen::indexList->addContentsItem(hasMembers,name, def->getReference(),def->getOutputFileBase(),anchor, hasMembers && !preventSeparateIndex, @@ -400,7 +398,7 @@ void addMembersToIndex(T *def,LayoutDocManager::LayoutPart part, { for (const auto &cd : def->getClasses()) { - if (cd->isLinkable() && (cd->partOfGroups()==0 || def->definitionType()==Definition::TypeGroup)) + if (cd->isLinkable() && (cd->partOfGroups().empty() || def->definitionType()==Definition::TypeGroup)) { static bool inlineSimpleStructs = Config_getBool(INLINE_SIMPLE_STRUCTS); bool isNestedClass = def->definitionType()==Definition::TypeClass; @@ -536,7 +534,7 @@ static void writeClassTreeToOutput(OutputList &ol,const BaseClassList &bcl,int l //---------------------------------------------------------------------------- -static bool dirHasVisibleChildren(DirDef *dd) +static bool dirHasVisibleChildren(const DirDef *dd) { if (dd->hasDocumentation()) return TRUE; @@ -555,7 +553,7 @@ static bool dirHasVisibleChildren(DirDef *dd) } } - for(const auto subdd : dd->subDirs()) + for(const auto &subdd : dd->subDirs()) { if (dirHasVisibleChildren(subdd)) { @@ -566,7 +564,7 @@ static bool dirHasVisibleChildren(DirDef *dd) } //---------------------------------------------------------------------------- -static void writeDirTreeNode(OutputList &ol, DirDef *dd, int level, FTVHelp* ftv,bool addToIndex) +static void writeDirTreeNode(OutputList &ol, const DirDef *dd, int level, FTVHelp* ftv,bool addToIndex) { if (level>20) { @@ -615,7 +613,7 @@ static void writeDirTreeNode(OutputList &ol, DirDef *dd, int level, FTVHelp* ftv if (dd->subDirs().size()>0) { startIndexHierarchy(ol,level+1); - for(const auto subdd : dd->subDirs()) + for(const auto &subdd : dd->subDirs()) { writeDirTreeNode(ol,subdd,level+1,ftv,addToIndex); } @@ -728,13 +726,11 @@ static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex) startIndexHierarchy(ol,0); if (fullPathNames) { - SDict<DirDef>::Iterator dli(*Doxygen::directories); - DirDef *dd; - for (dli.toFirst();(dd=dli.current());++dli) + for (const auto &dd : *Doxygen::dirLinkedMap) { if (dd->getOuterScope()==Doxygen::globalScope) { - writeDirTreeNode(ol,dd,0,ftv,addToIndex); + writeDirTreeNode(ol,dd.get(),0,ftv,addToIndex); } } } @@ -1571,7 +1567,7 @@ static void writeClassTree(const ListType &cl,FTVHelp *ftv,bool addToIndex,bool addMembersToIndex(cd,LayoutDocManager::Class, cd->displayName(FALSE), cd->anchor(), - addToIndex && cd->partOfGroups()==0 && !cd->isSimple()); + addToIndex && cd->partOfGroups().empty() && !cd->isSimple()); } if (count>0) { @@ -2024,11 +2020,6 @@ inline bool isId1(int c) return (c<127 && c>31); // printable ASCII character } -static QCString letterToString(uint letter) -{ - return QString(QChar(letter)).utf8(); -} - static QCString letterToLabel(const char *startLetter) { const char *p = startLetter; @@ -2052,44 +2043,6 @@ static QCString letterToLabel(const char *startLetter) return result; } -static QCString letterToLabel(uint startLetter) -{ - char s[11]; // max 0x12345678 + '\0' - if (isId1(startLetter)) // printable ASCII character - { - s[0]=(char)startLetter; - s[1]=0; - } - else - { - const char hex[]="0123456789abcdef"; - int i=0; - s[i++]='0'; - s[i++]='x'; - if (startLetter>(1<<24)) // 4 byte character - { - s[i++]=hex[(startLetter>>28)&0xf]; - s[i++]=hex[(startLetter>>24)&0xf]; - } - if (startLetter>(1<<16)) // 3 byte character - { - s[i++]=hex[(startLetter>>20)&0xf]; - s[i++]=hex[(startLetter>>16)&0xf]; - } - if (startLetter>(1<<8)) // 2 byte character - { - s[i++]=hex[(startLetter>>12)&0xf]; - s[i++]=hex[(startLetter>>8)&0xf]; - } - // one byte character - s[i++]=hex[(startLetter>>4)&0xf]; - s[i++]=hex[(startLetter>>0)&0xf]; - s[i++]=0; - } - return s; -} - - //---------------------------------------------------------------------------- /** Class representing a cell in the alphabetical class index. */ @@ -2544,7 +2497,7 @@ static void writeAnnotatedExceptionIndex(OutputList &ol) } //---------------------------------------------------------------------------- -static void writeClassLinkForMember(OutputList &ol,MemberDef *md,const char *separator, +static void writeClassLinkForMember(OutputList &ol,const MemberDef *md,const char *separator, QCString &prevClassName) { const ClassDef *cd=md->getClassDef(); @@ -2558,7 +2511,7 @@ static void writeClassLinkForMember(OutputList &ol,MemberDef *md,const char *sep } } -static void writeFileLinkForMember(OutputList &ol,MemberDef *md,const char *separator, +static void writeFileLinkForMember(OutputList &ol,const MemberDef *md,const char *separator, QCString &prevFileName) { const FileDef *fd=md->getFileDef(); @@ -2572,7 +2525,7 @@ static void writeFileLinkForMember(OutputList &ol,MemberDef *md,const char *sepa } } -static void writeNamespaceLinkForMember(OutputList &ol,MemberDef *md,const char *separator, +static void writeNamespaceLinkForMember(OutputList &ol,const MemberDef *md,const char *separator, QCString &prevNamespaceName) { const NamespaceDef *nd=md->getNamespaceDef(); @@ -2586,14 +2539,14 @@ static void writeNamespaceLinkForMember(OutputList &ol,MemberDef *md,const char } } -static void writeMemberList(OutputList &ol,bool useSections,int page, - const LetterToIndexMap<MemberIndexList> &memberLists, +static void writeMemberList(OutputList &ol,bool useSections,const std::string &page, + const MemberIndexMap &memberIndexMap, Definition::DefType type) { int index = (int)type; ASSERT(index<3); - typedef void (*writeLinkForMember_t)(OutputList &ol,MemberDef *md,const char *separator, + typedef void (*writeLinkForMember_t)(OutputList &ol,const MemberDef *md,const char *separator, QCString &prevNamespaceName); // each index tab has its own write function @@ -2608,20 +2561,26 @@ static void writeMemberList(OutputList &ol,bool useSections,int page, bool first=TRUE; bool firstSection=TRUE; bool firstItem=TRUE; - MemberIndexList *ml; - SIntDict<MemberIndexList>::Iterator it(memberLists); - for (it.toFirst();(ml=it.current());++it) + const MemberIndexList *mil = 0; + std::string letter; + for (const auto &kv : memberIndexMap) { - if (page!=-1) + if (!page.empty()) // specific page mode + { + auto it = memberIndexMap.find(page); + if (it != memberIndexMap.end()) + { + mil = &it->second; + letter = page; + } + } + else // do all pages { - ml = memberLists[page]; - it.toLast(); + mil = &kv.second; + letter = kv.first; } - if (ml==0 || ml->count()==0) continue; - ml->sort(); - QListIterator<MemberDef> mli(*ml); - MemberDef *md; - for (mli.toFirst();(md=mli.current());++mli) + if (mil==0 || mil->empty()) continue; + for (const auto &md : *mil) { const char *sep; bool isFunc=!md->isObjCMethod() && @@ -2636,10 +2595,9 @@ static void writeMemberList(OutputList &ol,bool useSections,int page, { if (!firstItem) ol.endItemListItem(); if (!firstSection) ol.endItemList(); - QCString cs = letterToLabel(ml->letter()); - QCString cl = letterToString(ml->letter()); + QCString cs = letterToLabel(letter.c_str()); QCString anchor=(QCString)"index_"+convertToId(cs); - QCString title=(QCString)"- "+cl+" -"; + QCString title=(QCString)"- "+letter.c_str()+" -"; ol.startSection(anchor,title,SectionType::Subsection); ol.docify(title); ol.endSection(anchor,SectionType::Subsection); @@ -2677,6 +2635,10 @@ static void writeMemberList(OutputList &ol,bool useSections,int page, writeLinkForMemberMap[index](ol,md,sep,prevDefName); } } + if (!page.empty()) + { + break; + } } if (!firstItem) ol.endItemListItem(); ol.endItemList(); @@ -2690,11 +2652,11 @@ void initClassMemberIndices() for (j=0;j<CMHL_Total;j++) { documentedClassMembers[j]=0; - g_memberIndexLetterUsed[j].clear(); + g_classIndexLetterUsed[j].clear(); } } -void addClassMemberNameToIndex(MemberDef *md) +void addClassMemberNameToIndex(const MemberDef *md) { static bool hideFriendCompounds = Config_getBool(HIDE_FRIEND_COMPOUNDS); const ClassDef *cd=0; @@ -2706,8 +2668,8 @@ void addClassMemberNameToIndex(MemberDef *md) { QCString n = md->name(); int index = getPrefixIndex(n); - uint letter = getUtf8CodeToLower(n,index); - if (!n.isEmpty()) + char letter[MAX_UTF8_CHAR_SIZE]; + if (getUtf8Char(n.data()+index,letter,CaseModifier::ToLower)>0) { bool isFriendToHide = hideFriendCompounds && (QCString(md->typeString())=="friend class" || @@ -2717,48 +2679,48 @@ void addClassMemberNameToIndex(MemberDef *md) (!md->isEnumValue() || (md->getEnumScope() && !md->getEnumScope()->isStrong())) ) { - g_memberIndexLetterUsed[CMHL_All].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_All],letter,md); documentedClassMembers[CMHL_All]++; } if (md->isFunction() || md->isSlot() || md->isSignal()) { - g_memberIndexLetterUsed[CMHL_Functions].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Functions],letter,md); documentedClassMembers[CMHL_Functions]++; } else if (md->isVariable()) { - g_memberIndexLetterUsed[CMHL_Variables].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Variables],letter,md); documentedClassMembers[CMHL_Variables]++; } else if (md->isTypedef()) { - g_memberIndexLetterUsed[CMHL_Typedefs].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Typedefs],letter,md); documentedClassMembers[CMHL_Typedefs]++; } else if (md->isEnumerate()) { - g_memberIndexLetterUsed[CMHL_Enums].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Enums],letter,md); documentedClassMembers[CMHL_Enums]++; } else if (md->isEnumValue() && md->getEnumScope() && !md->getEnumScope()->isStrong()) { - g_memberIndexLetterUsed[CMHL_EnumValues].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_EnumValues],letter,md); documentedClassMembers[CMHL_EnumValues]++; } else if (md->isProperty()) { - g_memberIndexLetterUsed[CMHL_Properties].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Properties],letter,md); documentedClassMembers[CMHL_Properties]++; } else if (md->isEvent()) { - g_memberIndexLetterUsed[CMHL_Events].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Events],letter,md); documentedClassMembers[CMHL_Events]++; } else if (md->isRelated() || md->isForeign() || (md->isFriend() && !isFriendToHide)) { - g_memberIndexLetterUsed[CMHL_Related].append(letter,md); + MemberIndexMap_add(g_classIndexLetterUsed[CMHL_Related],letter,md); documentedClassMembers[CMHL_Related]++; } } @@ -2777,55 +2739,55 @@ void initNamespaceMemberIndices() } } -void addNamespaceMemberNameToIndex(MemberDef *md) +void addNamespaceMemberNameToIndex(const MemberDef *md) { const NamespaceDef *nd=md->getNamespaceDef(); if (nd && nd->isLinkableInProject() && md->isLinkableInProject()) { QCString n = md->name(); int index = getPrefixIndex(n); - uint letter = getUtf8CodeToLower(n,index); - if (!n.isEmpty()) + char letter[MAX_UTF8_CHAR_SIZE]; + if (getUtf8Char(n.data()+index,letter,CaseModifier::ToLower)>0) { if (!md->isEnumValue() || (md->getEnumScope() && !md->getEnumScope()->isStrong())) { - g_namespaceIndexLetterUsed[NMHL_All].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_All],letter,md); documentedNamespaceMembers[NMHL_All]++; } if (md->isFunction()) { - g_namespaceIndexLetterUsed[NMHL_Functions].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_Functions],letter,md); documentedNamespaceMembers[NMHL_Functions]++; } else if (md->isVariable()) { - g_namespaceIndexLetterUsed[NMHL_Variables].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_Variables],letter,md); documentedNamespaceMembers[NMHL_Variables]++; } else if (md->isTypedef()) { - g_namespaceIndexLetterUsed[NMHL_Typedefs].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_Typedefs],letter,md); documentedNamespaceMembers[NMHL_Typedefs]++; } else if (md->isSequence()) { - g_namespaceIndexLetterUsed[NMHL_Sequences].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_Sequences],letter,md); documentedNamespaceMembers[NMHL_Sequences]++; } else if (md->isDictionary()) { - g_namespaceIndexLetterUsed[NMHL_Dictionaries].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_Dictionaries],letter,md); documentedNamespaceMembers[NMHL_Dictionaries]++; } else if (md->isEnumerate()) { - g_namespaceIndexLetterUsed[NMHL_Enums].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_Enums],letter,md); documentedNamespaceMembers[NMHL_Enums]++; } else if (md->isEnumValue() && md->getEnumScope() && !md->getEnumScope()->isStrong()) { - g_namespaceIndexLetterUsed[NMHL_EnumValues].append(letter,md); + MemberIndexMap_add(g_namespaceIndexLetterUsed[NMHL_EnumValues],letter,md); documentedNamespaceMembers[NMHL_EnumValues]++; } } @@ -2844,60 +2806,60 @@ void initFileMemberIndices() } } -void addFileMemberNameToIndex(MemberDef *md) +void addFileMemberNameToIndex(const MemberDef *md) { const FileDef *fd=md->getFileDef(); if (fd && fd->isLinkableInProject() && md->isLinkableInProject()) { QCString n = md->name(); int index = getPrefixIndex(n); - uint letter = getUtf8CodeToLower(n,index); - if (!n.isEmpty()) + char letter[MAX_UTF8_CHAR_SIZE]; + if (getUtf8Char(n.data()+index,letter,CaseModifier::ToLower)>0) { if (!md->isEnumValue() || (md->getEnumScope() && !md->getEnumScope()->isStrong())) { - g_fileIndexLetterUsed[FMHL_All].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_All],letter,md); documentedFileMembers[FMHL_All]++; } if (md->isFunction()) { - g_fileIndexLetterUsed[FMHL_Functions].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Functions],letter,md); documentedFileMembers[FMHL_Functions]++; } else if (md->isVariable()) { - g_fileIndexLetterUsed[FMHL_Variables].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Variables],letter,md); documentedFileMembers[FMHL_Variables]++; } else if (md->isTypedef()) { - g_fileIndexLetterUsed[FMHL_Typedefs].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Typedefs],letter,md); documentedFileMembers[FMHL_Typedefs]++; } else if (md->isSequence()) { - g_fileIndexLetterUsed[FMHL_Sequences].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Sequences],letter,md); documentedFileMembers[FMHL_Sequences]++; } else if (md->isDictionary()) { - g_fileIndexLetterUsed[FMHL_Dictionaries].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Dictionaries],letter,md); documentedFileMembers[FMHL_Dictionaries]++; } else if (md->isEnumerate()) { - g_fileIndexLetterUsed[FMHL_Enums].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Enums],letter,md); documentedFileMembers[FMHL_Enums]++; } else if (md->isEnumValue() && md->getEnumScope() && !md->getEnumScope()->isStrong()) { - g_fileIndexLetterUsed[FMHL_EnumValues].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_EnumValues],letter,md); documentedFileMembers[FMHL_EnumValues]++; } else if (md->isDefine()) { - g_fileIndexLetterUsed[FMHL_Defines].append(letter,md); + MemberIndexMap_add(g_fileIndexLetterUsed[FMHL_Defines],letter,md); documentedFileMembers[FMHL_Defines]++; } } @@ -2906,19 +2868,47 @@ void addFileMemberNameToIndex(MemberDef *md) //---------------------------------------------------------------------------- +static void sortMemberIndexList(MemberIndexMap &map) +{ + for (auto &kv : map) + { + std::sort(kv.second.begin(),kv.second.end(), + [](const MemberDef *md1,const MemberDef *md2) + { + int result = qstricmp(md1->name(),md2->name()); + return result==0 ? qstricmp(md1->qualifiedName(),md2->qualifiedName())<0 : result<0; + }); + } +} + +void sortMemberIndexLists() +{ + for (auto &idx : g_classIndexLetterUsed) + { + sortMemberIndexList(idx); + } + for (auto &idx : g_fileIndexLetterUsed) + { + sortMemberIndexList(idx); + } + for (auto &idx : g_namespaceIndexLetterUsed) + { + sortMemberIndexList(idx); + } +} + +//---------------------------------------------------------------------------- + static void writeQuickMemberIndex(OutputList &ol, - const LetterToIndexMap<MemberIndexList> &charUsed,uint page, + const MemberIndexMap &map,const std::string &page, QCString fullName,bool multiPage) { bool first=TRUE; startQuickIndexList(ol,TRUE); - SIntDict<MemberIndexList>::Iterator it(charUsed); - MemberIndexList *ml; - for (it.toFirst();(ml=it.current());++it) + for (const auto &kv : map) { - uint i = ml->letter(); - QCString is = letterToLabel(i); - QCString ci = letterToString(i); + QCString ci = kv.first.c_str(); + QCString is = letterToLabel(ci); QCString anchor; QCString extension=Doxygen::htmlFileExtension; if (!multiPage) @@ -2926,8 +2916,8 @@ static void writeQuickMemberIndex(OutputList &ol, else if (first) anchor=fullName+extension+"#index_"; else - anchor=fullName+"_"+letterToLabel(i)+extension+"#index_"; - startQuickIndexItem(ol,anchor+convertToId(is),i==page,TRUE,first); + anchor=fullName+"_"+is+extension+"#index_"; + startQuickIndexItem(ol,anchor+convertToId(is),kv.first==page,TRUE,first); ol.writeString(ci); endQuickIndexItem(ol); first=FALSE; @@ -2945,7 +2935,7 @@ struct CmhlInfo QCString title; }; -static const CmhlInfo *getCmhlInfo(int hl) +static const CmhlInfo *getCmhlInfo(size_t hl) { static bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); static bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL); @@ -2996,19 +2986,17 @@ static void writeClassMemberIndexFiltered(OutputList &ol, ClassMemberHighlight h } bool first=TRUE; - SIntDict<MemberIndexList>::Iterator it(g_memberIndexLetterUsed[hl]); - MemberIndexList *ml; - for (it.toFirst();(ml=it.current());++it) + for (const auto &kv : g_classIndexLetterUsed[hl]) { - uint page = ml->letter(); + std::string page = kv.first; QCString fileName = getCmhlInfo(hl)->fname; if (multiPageIndex) { + QCString cs = page; if (!first) { - fileName+="_"+letterToLabel(page); + fileName+="_"+letterToLabel(cs); } - QCString cs = letterToString(page); if (addToIndex) { Doxygen::indexList->addContentsItem(FALSE,cs,0,fileName,0,FALSE,TRUE); @@ -3051,7 +3039,7 @@ static void writeClassMemberIndexFiltered(OutputList &ol, ClassMemberHighlight h // quick alphabetical index if (quickIndex) { - writeQuickMemberIndex(ol,g_memberIndexLetterUsed[hl],page, + writeQuickMemberIndex(ol,g_classIndexLetterUsed[hl],page, getCmhlInfo(hl)->fname,multiPageIndex); } } @@ -3076,8 +3064,8 @@ static void writeClassMemberIndexFiltered(OutputList &ol, ClassMemberHighlight h } writeMemberList(ol,quickIndex, - multiPageIndex?page:-1, - g_memberIndexLetterUsed[hl], + multiPageIndex ? page : std::string(), + g_classIndexLetterUsed[hl], Definition::TypeClass); endFile(ol); first=FALSE; @@ -3124,7 +3112,7 @@ struct FmhlInfo QCString title; }; -static const FmhlInfo *getFmhlInfo(int hl) +static const FmhlInfo *getFmhlInfo(size_t hl) { static bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); static bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL); @@ -3175,19 +3163,17 @@ static void writeFileMemberIndexFiltered(OutputList &ol, FileMemberHighlight hl) } bool first=TRUE; - SIntDict<MemberIndexList>::Iterator it(g_fileIndexLetterUsed[hl]); - MemberIndexList *ml; - for (it.toFirst();(ml=it.current());++it) + for (const auto &kv : g_fileIndexLetterUsed[hl]) { - uint page = ml->letter(); + std::string page = kv.first; QCString fileName = getFmhlInfo(hl)->fname; if (multiPageIndex) { + QCString cs = page; if (!first) { - fileName+="_"+letterToLabel(page); + fileName+="_"+letterToLabel(cs); } - QCString cs = letterToString(page); if (addToIndex) { Doxygen::indexList->addContentsItem(FALSE,cs,0,fileName,0,FALSE,TRUE); @@ -3252,7 +3238,7 @@ static void writeFileMemberIndexFiltered(OutputList &ol, FileMemberHighlight hl) } writeMemberList(ol,quickIndex, - multiPageIndex?page:-1, + multiPageIndex ? page : std::string(), g_fileIndexLetterUsed[hl], Definition::TypeFile); endFile(ol); @@ -3297,7 +3283,7 @@ struct NmhlInfo QCString title; }; -static const NmhlInfo *getNmhlInfo(int hl) +static const NmhlInfo *getNmhlInfo(size_t hl) { static bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); static bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL); @@ -3351,19 +3337,17 @@ static void writeNamespaceMemberIndexFiltered(OutputList &ol, } bool first=TRUE; - SIntDict<MemberIndexList>::Iterator it(g_namespaceIndexLetterUsed[hl]); - MemberIndexList *ml; - for (it.toFirst();(ml=it.current());++it) + for (const auto &kv : g_namespaceIndexLetterUsed[hl]) { - uint page = ml->letter(); + std::string page = kv.first; QCString fileName = getNmhlInfo(hl)->fname; if (multiPageIndex) { + QCString cs = page; if (!first) { - fileName+="_"+letterToLabel(page); + fileName+="_"+letterToLabel(cs); } - QCString cs = letterToString(page); if (addToIndex) { Doxygen::indexList->addContentsItem(FALSE,cs,0,fileName,0,FALSE,TRUE); @@ -3428,7 +3412,7 @@ static void writeNamespaceMemberIndexFiltered(OutputList &ol, } writeMemberList(ol,quickIndex, - multiPageIndex?page:-1, + multiPageIndex ? page : std::string(), g_namespaceIndexLetterUsed[hl], Definition::TypeNamespace); endFile(ol); @@ -3469,7 +3453,7 @@ static void writeNamespaceMemberIndex(OutputList &ol) static void writeExampleIndex(OutputList &ol) { - if (Doxygen::exampleSDict->count()==0) return; + if (Doxygen::exampleLinkedMap->empty()) return; ol.pushGeneratorState(); ol.disable(OutputGenerator::Man); ol.disable(OutputGenerator::Docbook); @@ -3496,9 +3480,7 @@ static void writeExampleIndex(OutputList &ol) ol.endTextBlock(); ol.startItemList(); - PageSDict::Iterator pdi(*Doxygen::exampleSDict); - PageDef *pd=0; - for (pdi.toFirst();(pd=pdi.current());++pdi) + for (const auto &pd : *Doxygen::exampleLinkedMap) { ol.startItemListItem(); QCString n=pd->getOutputFileBase(); @@ -3537,15 +3519,13 @@ static void writeExampleIndex(OutputList &ol) static void countRelatedPages(int &docPages,int &indexPages) { docPages=indexPages=0; - PageSDict::Iterator pdi(*Doxygen::pageSDict); - PageDef *pd=0; - for (pdi.toFirst();(pd=pdi.current());++pdi) + for (const auto &pd : *Doxygen::pageLinkedMap) { - if ( pd->visibleInIndex()) + if (pd->visibleInIndex()) { indexPages++; } - if ( pd->documentedPage()) + if (pd->documentedPage()) { docPages++; } @@ -3565,7 +3545,7 @@ static bool mainPageHasOwnTitle() return !projectName.isEmpty() && mainPageHasTitle() && qstricmp(title,projectName)!=0; } -static void writePages(PageDef *pd,FTVHelp *ftv) +static void writePages(const PageDef *pd,FTVHelp *ftv) { //printf("writePages()=%s pd=%p mainpage=%p\n",pd->name().data(),pd,Doxygen::mainPage); LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Pages); @@ -3592,7 +3572,7 @@ static void writePages(PageDef *pd,FTVHelp *ftv) pd->getReference(),pd->getOutputFileBase(), 0,hasSubPages,TRUE,pd); } - if (addToIndex && pd!=Doxygen::mainPage) + if (addToIndex && pd!=Doxygen::mainPage.get()) { Doxygen::indexList->addContentsItem( hasSubPages || hasSections,pageTitle, @@ -3602,24 +3582,18 @@ static void writePages(PageDef *pd,FTVHelp *ftv) } if (hasSubPages && ftv) ftv->incContentsDepth(); bool doIndent = (hasSections || hasSubPages) && - (pd!=Doxygen::mainPage || mainPageHasOwnTitle()); + (pd!=Doxygen::mainPage.get() || mainPageHasOwnTitle()); if (doIndent) { Doxygen::indexList->incContentsDepth(); } if (hasSections) { - pd->addSectionsToIndex(); + const_cast<PageDef*>(pd)->addSectionsToIndex(); } - PageSDict *subPages = pd->getSubPages(); - if (subPages) + for (const auto &subPage : pd->getSubPages()) { - PageSDict::Iterator pi(*subPages); - PageDef *subPage; - for (pi.toFirst();(subPage=pi.current());++pi) - { - writePages(subPage,ftv); - } + writePages(subPage,ftv); } if (hasSubPages && ftv) ftv->decContentsDepth(); if (doIndent) @@ -3649,16 +3623,14 @@ static void writePageIndex(OutputList &ol) { FTVHelp* ftv = new FTVHelp(FALSE); - PageSDict::Iterator pdi(*Doxygen::pageSDict); - PageDef *pd=0; - for (pdi.toFirst();(pd=pdi.current());++pdi) + for (const auto &pd : *Doxygen::pageLinkedMap) { if ((pd->getOuterScope()==0 || pd->getOuterScope()->definitionType()!=Definition::TypePage) && // not a sub page !pd->isReference() // not an external page ) { - writePages(pd,ftv); + writePages(pd.get(),ftv); } } QGString outStr; @@ -3680,9 +3652,7 @@ static void writePageIndex(OutputList &ol) static int countGroups() { int count=0; - GroupSDict::Iterator gli(*Doxygen::groupSDict); - GroupDef *gd; - for (gli.toFirst();(gd=gli.current());++gli) + for (const auto &gd : *Doxygen::groupLinkedMap) { if (!gd->isReference()) { @@ -3698,9 +3668,7 @@ static int countGroups() static int countDirs() { int count=0; - SDict<DirDef>::Iterator dli(*Doxygen::directories); - DirDef *dd; - for (dli.toFirst();(dd=dli.current());++dli) + for (const auto &dd : *Doxygen::dirLinkedMap) { if (dd->isLinkableInProject()) { @@ -3764,7 +3732,7 @@ void writeGraphInfo(OutputList &ol) /*! * write groups as hierarchical trees */ -static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* ftv, bool addToIndex) +static void writeGroupTreeNode(OutputList &ol, const GroupDef *gd, int level, FTVHelp* ftv, bool addToIndex) { //bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); //bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL); @@ -3786,14 +3754,12 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* { //printf("gd->name()=%s #members=%d\n",gd->name().data(),gd->countMembers()); // write group info - bool hasSubGroups = gd->getSubGroups()->count()>0; - bool hasSubPages = gd->getPages()->count()>0; + bool hasSubGroups = !gd->getSubGroups().empty(); + bool hasSubPages = !gd->getPages().empty(); size_t numSubItems = 0; if (1 /*Config_getBool(TOC_EXPAND)*/) { - QListIterator<MemberList> mli(gd->getMemberLists()); - MemberList *ml; - for (mli.toFirst();(ml=mli.current());++mli) + for (const auto &ml : gd->getMemberLists()) { if (ml->listType()&MemberListType_documentationLists) { @@ -3804,7 +3770,7 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* numSubItems += gd->getClasses().size(); numSubItems += gd->getFiles()->count(); numSubItems += gd->getDirs().size(); - numSubItems += gd->getPages()->count(); + numSubItems += gd->getPages().size(); } bool isDir = hasSubGroups || hasSubPages || numSubItems>0; @@ -3885,7 +3851,7 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* { //bool nestedClassInSameGroup = // cd->getOuterScope() && cd->getOuterScope()->definitionType()==Definition::TypeClass && - // cd->getOuterScope()->partOfGroups()!=0 && cd->getOuterScope()->partOfGroups()->contains(gd); + // cd->getOuterScope()->partOfGroups().empty() && cd->getOuterScope()->partOfGroups()->contains(gd); //printf("===== GroupClasses: %s visible=%d nestedClassInSameGroup=%d\n",cd->name().data(),cd->isVisible(),nestedClassInSameGroup); if (cd->isVisible() /*&& !nestedClassInSameGroup*/) { @@ -3944,9 +3910,7 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* } else if (lde->kind()==LayoutDocEntry::GroupPageDocs && addToIndex) { - SDict<PageDef>::Iterator it(*gd->getPages()); - PageDef *pd; - for (;(pd=it.current());++it) + for (const auto &pd : gd->getPages()) { const SectionInfo *si=0; if (!pd->name().isEmpty()) si=SectionManager::instance().find(pd->name()); @@ -3966,7 +3930,7 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* } if (hasSections) { - pd->addSectionsToIndex(); + const_cast<PageDef*>(pd)->addSectionsToIndex(); } writePages(pd,0); if (hasSections || hasSubPages) @@ -3977,12 +3941,10 @@ static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* } else if (lde->kind()==LayoutDocEntry::GroupNestedGroups) { - if (gd->getSubGroups()->count()>0) + if (!gd->getSubGroups().empty()) { startIndexHierarchy(ol,level+1); - QListIterator<GroupDef> gli(*gd->getSubGroups()); - GroupDef *subgd = 0; - for (gli.toFirst();(subgd=gli.current());++gli) + for (const auto &subgd : gd->getSubGroups()) { writeGroupTreeNode(ol,subgd,level+1,ftv,addToIndex); } @@ -4013,11 +3975,9 @@ static void writeGroupHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex) ol.disable(OutputGenerator::Html); } startIndexHierarchy(ol,0); - GroupSDict::Iterator gli(*Doxygen::groupSDict); - GroupDef *gd; - for (gli.toFirst();(gd=gli.current());++gli) + for (const auto &gd : *Doxygen::groupLinkedMap) { - writeGroupTreeNode(ol,gd,0,ftv,addToIndex); + writeGroupTreeNode(ol,gd.get(),0,ftv,addToIndex); } endIndexHierarchy(ol,0); if (ftv) @@ -4026,41 +3986,6 @@ static void writeGroupHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex) } } -#if 0 -static void writeGroupTree(GroupDef *gd,FTVHelp *ftv,int level,bool addToIndex) -{ - static bool externalGroups = Config_getBool(EXTERNAL_GROUPS); - /* Some groups should appear twice under different parent-groups. - * That is why we should not check if it was visited - */ - if ((!gd->isASubGroup() || level>0) && - gd->isVisible() && - (!gd->isReference() || externalGroups) // hide external groups by default - ) - { - if (ftv) - { - ftv->addContentsItem(hasSubGroups,gd->groupTitle(),gd->getReference(),gd->getOutputFileBase(),0); - ftv->incContentsDepth(); - } - if (ftv) - { - ftv->decContentsDepth(); - } - } -} - -static void writeGroupTree(FTVHelp *ftv,bool addToIndex) -{ - GroupSDict::Iterator gli(*Doxygen::groupSDict); - GroupDef *gd; - for (gli.toFirst();(gd=gli.current());++gli) - { - writeGroupTree(gd,ftv,0,addToIndex); - } -} -#endif - //---------------------------------------------------------------------------- static void writeGroupIndex(OutputList &ol) @@ -4133,62 +4058,6 @@ static void writeGroupIndex(OutputList &ol) //---------------------------------------------------------------------------- -#if 0 -static void writeDirIndex(OutputList &ol) -{ - if (documentedDirs==0) return; - ol.pushGeneratorState(); - ol.disable(OutputGenerator::Man); - LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Dirs); - QCString title = lne ? lne->title() : theTranslator->trDirectories(); - bool addToIndex=FALSE; //lne==0 || lne->visible(); - - startFile(ol,"dirs",0,title,HLI_Directories); - startTitle(ol,0); - ol.parseText(title); - endTitle(ol,0,0); - ol.startContents(); - ol.startTextBlock(); - - if (addToIndex) - { - Doxygen::indexList->addContentsItem(TRUE,title,0,"dirs",0,TRUE,TRUE); - Doxygen::indexList->incContentsDepth(); - } - ol.parseText(lne ? lne->intro() : theTranslator->trDirDescription()); - ol.endTextBlock(); - - FTVHelp* ftv = 0; - bool treeView=Config_getBool(USE_INLINE_TREES); - if (treeView) - { - ftv = new FTVHelp(FALSE); - } - - writeDirHierarchy(ol,ftv,addToIndex); - - if (ftv) - { - QGString outStr; - FTextStream t(&outStr); - ftv->generateTreeViewInline(t); - ol.pushGeneratorState(); - ol.disableAllBut(OutputGenerator::Html); - ol.writeString(outStr); - ol.popGeneratorState(); - delete ftv; - } - if (addToIndex) - { - Doxygen::indexList->decContentsDepth(); - } - endFile(ol); - ol.popGeneratorState(); -} -#endif - -//---------------------------------------------------------------------------- - static void writeUserGroupStubPage(OutputList &ol,LayoutNavEntry *lne) { if (lne->baseFile().left(9)=="usergroup") @@ -4275,7 +4144,7 @@ static void writeIndex(OutputList &ol) } if (Doxygen::mainPage->hasSubPages() || Doxygen::mainPage->hasSections()) { - writePages(Doxygen::mainPage,0); + writePages(Doxygen::mainPage.get(),0); } } @@ -4307,7 +4176,7 @@ static void writeIndex(OutputList &ol) ol.startHeaderSection(); ol.startTitleHead(0); ol.generateDoc(Doxygen::mainPage->docFile(),Doxygen::mainPage->getStartBodyLine(), - Doxygen::mainPage,0,Doxygen::mainPage->title(),TRUE,FALSE, + Doxygen::mainPage.get(),0,Doxygen::mainPage->title(),TRUE,FALSE, 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); headerWritten = TRUE; } @@ -4343,7 +4212,7 @@ static void writeIndex(OutputList &ol) } ol.startTextBlock(); - ol.generateDoc(defFileName,defLine,Doxygen::mainPage,0, + ol.generateDoc(defFileName,defLine,Doxygen::mainPage.get(),0, Doxygen::mainPage->documentation(),TRUE,FALSE, 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); ol.endTextBlock(); @@ -4382,7 +4251,7 @@ static void writeIndex(OutputList &ol) if (!Config_getString(PROJECT_NUMBER).isEmpty()) { ol.startProjectNumber(); - ol.generateDoc(defFileName,defLine,Doxygen::mainPage,0,Config_getString(PROJECT_NUMBER),FALSE,FALSE, + ol.generateDoc(defFileName,defLine,Doxygen::mainPage.get(),0,Config_getString(PROJECT_NUMBER),FALSE,FALSE, 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); ol.endProjectNumber(); } @@ -4411,14 +4280,12 @@ static void writeIndex(OutputList &ol) { //ol.parseText(projPrefix+theTranslator->trPageDocumentation()); //ol.endIndexSection(isPageDocumentation); - PageSDict::Iterator pdi(*Doxygen::pageSDict); - PageDef *pd=pdi.toFirst(); bool first=Doxygen::mainPage==0; - for (pdi.toFirst();(pd=pdi.current());++pdi) + for (const auto &pd : *Doxygen::pageLinkedMap) { if (!pd->getGroupDef() && !pd->isReference() && (!pd->hasParentPage() || // not inside other page - (Doxygen::mainPage==pd->getOuterScope())) // or inside main page + (Doxygen::mainPage.get()==pd->getOuterScope())) // or inside main page ) { bool isCitationPage = pd->name()=="citelist"; @@ -4579,7 +4446,7 @@ static void writeIndex(OutputList &ol) ol.parseText(/*projPrefix+*/theTranslator->trFileDocumentation()); ol.endIndexSection(isFileDocumentation); } - if (Doxygen::exampleSDict->count()>0) + if (!Doxygen::exampleLinkedMap->empty()) { ol.startIndexSection(isExampleDocumentation); ol.parseText(/*projPrefix+*/theTranslator->trExampleDocumentation()); @@ -4595,7 +4462,7 @@ static void writeIndex(OutputList &ol) startFile(ol,Doxygen::mainPage->name(),0,Doxygen::mainPage->title()); ol.startContents(); ol.startTextBlock(); - ol.generateDoc(defFileName,defLine,Doxygen::mainPage,0, + ol.generateDoc(defFileName,defLine,Doxygen::mainPage.get(),0, Doxygen::mainPage->documentation(),FALSE,FALSE, 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT) ); @@ -4948,7 +4815,7 @@ static bool quickLinkVisible(LayoutNavEntry::Kind kind) case LayoutNavEntry::Files: return documentedHtmlFiles>0 && showFiles; case LayoutNavEntry::FileList: return documentedHtmlFiles>0 && showFiles; case LayoutNavEntry::FileGlobals: return documentedFileMembers[FMHL_All]>0; - case LayoutNavEntry::Examples: return Doxygen::exampleSDict->count()>0; + case LayoutNavEntry::Examples: return !Doxygen::exampleLinkedMap->empty(); case LayoutNavEntry::None: // should never happen, means not properly initialized assert(kind != LayoutNavEntry::None); return FALSE; @@ -4956,14 +4823,15 @@ static bool quickLinkVisible(LayoutNavEntry::Kind kind) return FALSE; } -template<class T> +template<class T,std::size_t total> void renderMemberIndicesAsJs(FTextStream &t, - int total,const int *numDocumented,const LetterToIndexMap<MemberIndexList> *memberLists, - const T *(*getInfo)(int hl)) + const int *numDocumented, + const std::array<MemberIndexMap,total> &memberLists, + const T *(*getInfo)(size_t hl)) { // index items per category member lists bool firstMember=TRUE; - for (int i=0;i<total;i++) + for (std::size_t i=0;i<total;i++) { if (numDocumented[i]>0) { @@ -4988,14 +4856,12 @@ void renderMemberIndicesAsJs(FTextStream &t, } t << ",children:[" << endl; bool firstLetter=TRUE; - SIntDict<MemberIndexList>::Iterator it(memberLists[i]); - MemberIndexList *ml; - for (it.toFirst();(ml=it.current());++it) + for (const auto &kv : memberLists[i]) { if (!firstLetter) t << "," << endl; - uint letter = ml->letter(); - QCString is = letterToLabel(letter); - QCString ci = letterToString(letter); + std::string letter = kv.first; + QCString ci = letter; + QCString is = letterToLabel(ci); QCString anchor; QCString extension=Doxygen::htmlFileExtension; QCString fullName = getInfo(i)->fname; @@ -5044,17 +4910,17 @@ static bool renderQuickLinksAsJs(FTextStream &t,LayoutNavEntry *root,bool first) bool hasChildren=FALSE; if (entry->kind()==LayoutNavEntry::NamespaceMembers) { - renderMemberIndicesAsJs(t,NMHL_Total,documentedNamespaceMembers, + renderMemberIndicesAsJs(t,documentedNamespaceMembers, g_namespaceIndexLetterUsed,getNmhlInfo); } else if (entry->kind()==LayoutNavEntry::ClassMembers) { - renderMemberIndicesAsJs(t,CMHL_Total,documentedClassMembers, - g_memberIndexLetterUsed,getCmhlInfo); + renderMemberIndicesAsJs(t,documentedClassMembers, + g_classIndexLetterUsed,getCmhlInfo); } else if (entry->kind()==LayoutNavEntry::FileGlobals) { - renderMemberIndicesAsJs(t,FMHL_Total,documentedFileMembers, + renderMemberIndicesAsJs(t,documentedFileMembers, g_fileIndexLetterUsed,getFmhlInfo); } else // recursive into child list |