diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-01-13 20:46:07 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2021-01-22 20:45:19 (GMT) |
commit | 65d36226cfb37b8fc9113e69d54ed4cbd9cedd2b (patch) | |
tree | dfa6d95d1d4fc04f69a2d04cd3caf0f84558640e /src | |
parent | 8c0bb948329448cb88b208480e2048af3638aa45 (diff) | |
download | Doxygen-65d36226cfb37b8fc9113e69d54ed4cbd9cedd2b.zip Doxygen-65d36226cfb37b8fc9113e69d54ed4cbd9cedd2b.tar.gz Doxygen-65d36226cfb37b8fc9113e69d54ed4cbd9cedd2b.tar.bz2 |
Refactoring: replace StringDict by StringMap
Diffstat (limited to 'src')
-rw-r--r-- | src/classdef.h | 1 | ||||
-rw-r--r-- | src/containers.h | 1 | ||||
-rw-r--r-- | src/definition.cpp | 6 | ||||
-rw-r--r-- | src/doxygen.cpp | 69 | ||||
-rw-r--r-- | src/doxygen.h | 11 | ||||
-rw-r--r-- | src/util.cpp | 29 | ||||
-rw-r--r-- | src/util.h | 2 |
7 files changed, 53 insertions, 66 deletions
diff --git a/src/classdef.h b/src/classdef.h index 8e5d628..95b1b31 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -41,7 +41,6 @@ class ExampleList; class MemberNameInfoLinkedMap; class PackageDef; class GroupDef; -class StringDict; struct IncludeInfo; class ClassDefImpl; class FTextStream; diff --git a/src/containers.h b/src/containers.h index 770f92d..f8027fd 100644 --- a/src/containers.h +++ b/src/containers.h @@ -26,6 +26,7 @@ using StringUnorderedMap = std::unordered_map<std::string,std::string>; using StringUnorderedSet = std::unordered_set<std::string>; +using StringMap = std::map<std::string,std::string>; using StringSet = std::set<std::string>; using StringVector = std::vector<std::string>; using BoolStack = std::stack<bool>; diff --git a/src/definition.cpp b/src/definition.cpp index 2a03ef9..88b5960 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -2097,10 +2097,10 @@ QCString DefinitionImpl::externalReference(const QCString &relPath) const QCString ref = getReference(); if (!ref.isEmpty()) { - QCString *dest = Doxygen::tagDestinationDict[ref]; - if (dest) + auto it = Doxygen::tagDestinationMap.find(ref.str()); + if (it!=Doxygen::tagDestinationMap.end()) { - QCString result = *dest; + QCString result = it->second; uint l = result.length(); if (!relPath.isEmpty() && l>0 && result.at(0)=='.') { // relative path -> prepend relPath. diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 74887ec..39135b5 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -126,7 +126,7 @@ FileNameLinkedMap *Doxygen::inputNameLinkedMap = 0; GroupLinkedMap *Doxygen::groupLinkedMap = 0; PageLinkedMap *Doxygen::pageLinkedMap = 0; PageLinkedMap *Doxygen::exampleLinkedMap = 0; -StringDict Doxygen::aliasDict(257); // aliases +StringMap Doxygen::aliasMap; // aliases StringSet Doxygen::inputPaths; FileNameLinkedMap *Doxygen::includeNameLinkedMap = 0; // include names FileNameLinkedMap *Doxygen::exampleNameLinkedMap = 0; // examples @@ -135,7 +135,7 @@ FileNameLinkedMap *Doxygen::dotFileNameLinkedMap = 0; // dot files FileNameLinkedMap *Doxygen::mscFileNameLinkedMap = 0; // msc files FileNameLinkedMap *Doxygen::diaFileNameLinkedMap = 0; // dia files StringUnorderedMap Doxygen::namespaceAliasMap; // all namespace aliases -StringDict Doxygen::tagDestinationDict(257); // all tag locations +StringMap Doxygen::tagDestinationMap; // all tag locations StringUnorderedSet Doxygen::expandAsDefinedSet; // all macros that should be expanded MemberGroupInfoMap Doxygen::memberGroupInfoMap; // dictionary of the member groups heading std::unique_ptr<PageDef> Doxygen::mainPage; @@ -189,7 +189,7 @@ void clearAll() Doxygen::dotFileNameLinkedMap->clear(); Doxygen::mscFileNameLinkedMap->clear(); Doxygen::diaFileNameLinkedMap->clear(); - Doxygen::tagDestinationDict.clear(); + Doxygen::tagDestinationMap.clear(); SectionManager::instance().clear(); CitationManager::instance().clear(); Doxygen::mainPage.reset(); @@ -263,10 +263,10 @@ void statistics() #endif //fprintf(stderr,"--- g_excludeNameDict stats ----\n"); //g_excludeNameDict.statistics(); - fprintf(stderr,"--- aliasDict stats ----\n"); - Doxygen::aliasDict.statistics(); - fprintf(stderr,"--- tagDestinationDict stats ----\n"); - Doxygen::tagDestinationDict.statistics(); + //fprintf(stderr,"--- aliasDict stats ----\n"); + //Doxygen::aliasDict.statistics(); + //fprintf(stderr,"--- tagDestinationDict stats ----\n"); + //Doxygen::tagDestinationDict.statistics(); fprintf(stderr,"--- g_compoundKeywordDict stats ----\n"); g_compoundKeywordDict.statistics(); } @@ -9100,7 +9100,8 @@ static void readTagFile(const std::shared_ptr<Entry> &root,const char *tl) destName = tagLine.right(tagLine.length()-eqPos-1).stripWhiteSpace(); if (fileName.isEmpty() || destName.isEmpty()) return; QFileInfo fi(fileName); - Doxygen::tagDestinationDict.insert(fi.absFilePath().utf8(),new QCString(destName)); + Doxygen::tagDestinationMap.insert( + std::make_pair(fi.absFilePath().utf8().str(), destName.str())); //printf("insert tagDestination %s->%s\n",fi.fileName().data(),destName.data()); } else @@ -9874,11 +9875,9 @@ int readFileOrDirectory(const char *s, static void expandAliases() { - QDictIterator<QCString> adi(Doxygen::aliasDict); - QCString *s; - for (adi.toFirst();(s=adi.current());++adi) + for (auto &kv : Doxygen::aliasMap) { - *s = expandAlias(adi.currentKey(),*s); + kv.second = expandAlias(kv.first,kv.second); } } @@ -9886,11 +9885,10 @@ static void expandAliases() static void escapeAliases() { - QDictIterator<QCString> adi(Doxygen::aliasDict); - QCString *s; - for (adi.toFirst();(s=adi.current());++adi) + for (auto &kv : Doxygen::aliasMap) { - QCString value=*s,newValue; + QCString value=kv.second; + QCString newValue; int in,p=0; // for each \n in the alias command value while ((in=value.find("\\n",p))!=-1) @@ -9913,7 +9911,6 @@ static void escapeAliases() p=in+2; } newValue+=value.mid(p,value.length()-p); - *s=newValue; p = 0; newValue = ""; while ((in=value.find("^^",p))!=-1) @@ -9923,7 +9920,7 @@ static void escapeAliases() p=in+2; } newValue+=value.mid(p,value.length()-p); - *s=newValue; + kv.second=newValue.str(); //printf("Alias %s has value %s\n",adi.currentKey().data(),s->data()); } } @@ -9933,30 +9930,26 @@ static void escapeAliases() void readAliases() { // add aliases to a dictionary - Doxygen::aliasDict.setAutoDelete(TRUE); const StringVector &aliasList = Config_getList(ALIASES); - for (const auto &s : aliasList) + for (const auto &al : aliasList) { - QCString alias=s.c_str(); - if (Doxygen::aliasDict[alias]==0) + QCString alias = al; + int i=alias.find('='); + if (i>0) { - int i=alias.find('='); - if (i>0) + QCString name=alias.left(i).stripWhiteSpace(); + QCString value=alias.right(alias.length()-i-1); + //printf("Alias: found name='%s' value='%s'\n",name.data(),value.data()); + if (!name.isEmpty()) { - QCString name=alias.left(i).stripWhiteSpace(); - QCString value=alias.right(alias.length()-i-1); - //printf("Alias: found name='%s' value='%s'\n",name.data(),value.data()); - if (!name.isEmpty()) + auto it = Doxygen::aliasMap.find(name.str()); + if (it==Doxygen::aliasMap.end()) // insert new alias { - QCString *dn=Doxygen::aliasDict[name]; - if (dn==0) // insert new alias - { - Doxygen::aliasDict.insert(name,new QCString(value)); - } - else // overwrite previous alias - { - *dn=value; - } + Doxygen::aliasMap.insert(std::make_pair(name.str(),value.str())); + } + else // overwrite previous alias + { + it->second=value.str(); } } } @@ -10134,7 +10127,7 @@ void initDoxygen() Doxygen::dirLinkedMap = new DirLinkedMap; Doxygen::pageLinkedMap = new PageLinkedMap; // all doc pages Doxygen::exampleLinkedMap = new PageLinkedMap; // all examples - Doxygen::tagDestinationDict.setAutoDelete(TRUE); + //Doxygen::tagDestinationDict.setAutoDelete(TRUE); Doxygen::indexList = new IndexList; // initialisation of these globals depends on diff --git a/src/doxygen.h b/src/doxygen.h index fdfa7da..02eb790 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -64,13 +64,6 @@ class NamespaceDefMutable; typedef QList<QCString> StringList; typedef QListIterator<QCString> StringListIterator; -class StringDict : public QDict<QCString> -{ - public: - StringDict(uint size=17) : QDict<QCString>(size) {} - virtual ~StringDict() {} -}; - struct LookupInfo { LookupInfo() = default; @@ -110,8 +103,8 @@ class Doxygen static StringUnorderedMap namespaceAliasMap; static GroupLinkedMap *groupLinkedMap; static NamespaceLinkedMap *namespaceLinkedMap; - static StringDict tagDestinationDict; - static StringDict aliasDict; + static StringMap tagDestinationMap; + static StringMap aliasMap; static MemberGroupInfoMap memberGroupInfoMap; static StringUnorderedSet expandAsDefinedSet; static NamespaceDefMutable *globalScope; diff --git a/src/util.cpp b/src/util.cpp index 50f3aec..87698d7 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -5976,25 +5976,26 @@ static QCString expandAliasRec(StringUnorderedSet &aliasesProcessed,const QCStri numArgs = countAliasArguments(args); cmd += QCString().sprintf("{%d}",numArgs); // alias name + {n} } - QCString *aliasText=Doxygen::aliasDict.find(cmd); - if (numArgs>1 && aliasText==0) + auto it = Doxygen::aliasMap.find(cmd.str()); + + if (numArgs>1 && it==Doxygen::aliasMap.end()) { // in case there is no command with numArgs parameters, but there is a command with 1 parameter, // we also accept all text as the argument of that command (so you don't have to escape commas) - aliasText=Doxygen::aliasDict.find(cmdNoArgs+"{1}"); - if (aliasText) + it = Doxygen::aliasMap.find((cmdNoArgs+"{1}").str()); + if (it!=Doxygen::aliasMap.end()) { cmd = cmdNoArgs+"{1}"; args = escapeCommas(args); // escape , so that everything is seen as one argument } } //printf("Found command s='%s' cmd='%s' numArgs=%d args='%s' aliasText=%s\n", - // s.data(),cmd.data(),numArgs,args.data(),aliasText?aliasText->data():"<none>"); + // s.data(),cmd.data(),numArgs,args.data(),it!=Doxygen::aliasMap.end()?it->second.c_str():"<none>"); if ((allowRecursion || aliasesProcessed.find(cmd.str())==aliasesProcessed.end()) && - aliasText) // expand the alias + it!=Doxygen::aliasMap.end()) // expand the alias { //printf("is an alias!\n"); if (!allowRecursion) aliasesProcessed.insert(cmd.str()); - QCString val = *aliasText; + QCString val = it->second; if (hasArgs) { val = replaceAliasArguments(aliasesProcessed,val,args); @@ -6079,17 +6080,17 @@ QCString resolveAliasCmd(const QCString aliasCmd) return result; } -QCString expandAlias(const QCString &aliasName,const QCString &aliasValue) +std::string expandAlias(const std::string &aliasName,const std::string &aliasValue) { QCString result; StringUnorderedSet aliasesProcessed; // avoid expanding this command recursively - aliasesProcessed.insert(aliasName.str()); + aliasesProcessed.insert(aliasName); // expand embedded commands //printf("Expanding: '%s'->'%s'\n",aliasName.data(),aliasValue.data()); - result = expandAliasRec(aliasesProcessed,aliasValue); + result = expandAliasRec(aliasesProcessed,aliasValue.c_str()); //printf("Expanding result: '%s'->'%s'\n",aliasName.data(),result.data()); - return result; + return result.str(); } void writeTypeConstraints(OutputList &ol,const Definition *d,const ArgumentList &al) @@ -6378,10 +6379,10 @@ QCString externalRef(const QCString &relPath,const QCString &ref,bool href) QCString result; if (!ref.isEmpty()) { - QCString *dest = Doxygen::tagDestinationDict[ref]; - if (dest) + auto it = Doxygen::tagDestinationMap.find(ref.str()); + if (it!=Doxygen::tagDestinationMap.end()) { - result = *dest; + result = it->second; int l = result.length(); if (!relPath.isEmpty() && l>0 && result.at(0)=='.') { // relative path -> prepend relPath. @@ -377,7 +377,7 @@ QCString extractAliasArgs(const QCString &args,int pos); int countAliasArguments(const QCString argList); QCString resolveAliasCmd(const QCString aliasCmd); -QCString expandAlias(const QCString &aliasName,const QCString &aliasValue); +std::string expandAlias(const std::string &aliasName,const std::string &aliasValue); void writeTypeConstraints(OutputList &ol,const Definition *d,const ArgumentList &al); |