diff options
-rw-r--r-- | src/dotcallgraph.cpp | 37 | ||||
-rw-r--r-- | src/dotcallgraph.h | 7 | ||||
-rw-r--r-- | src/dotclassgraph.cpp | 70 | ||||
-rw-r--r-- | src/dotclassgraph.h | 6 | ||||
-rw-r--r-- | src/dotdirdeps.cpp | 17 | ||||
-rw-r--r-- | src/dotfilepatcher.cpp | 87 | ||||
-rw-r--r-- | src/dotfilepatcher.h | 9 | ||||
-rw-r--r-- | src/dotgroupcollaboration.cpp | 96 | ||||
-rw-r--r-- | src/dotgroupcollaboration.h | 11 | ||||
-rw-r--r-- | src/dotincldepgraph.cpp | 49 | ||||
-rw-r--r-- | src/dotincldepgraph.h | 7 | ||||
-rw-r--r-- | src/dotnode.h | 10 | ||||
-rw-r--r-- | testing/011/interface_integer.xml | 10 | ||||
-rw-r--r-- | testing/027/struct_car.xml | 36 | ||||
-rw-r--r-- | testing/027/struct_object.xml | 20 | ||||
-rw-r--r-- | testing/027/struct_truck.xml | 12 | ||||
-rw-r--r-- | testing/027/struct_vehicle.xml | 24 |
17 files changed, 241 insertions, 267 deletions
diff --git a/src/dotcallgraph.cpp b/src/dotcallgraph.cpp index 9525d52..78e9b9b 100644 --- a/src/dotcallgraph.cpp +++ b/src/dotcallgraph.cpp @@ -36,9 +36,10 @@ void DotCallGraph::buildGraph(DotNode *n,const MemberDef *md,int distance) if (rmd->showInCallGraph()) { QCString uniqueId = getUniqueId(rmd); - DotNode *bn = m_usedNodes->find(uniqueId); - if (bn) // file is already a node in the graph + auto it = m_usedNodes.find(uniqueId.str()); + if (it!=m_usedNodes.end()) // file is already a node in the graph { + DotNode *bn = it->second; n->addChild(bn,0,0,0); bn->addParent(n); bn->setDistance(distance); @@ -56,7 +57,7 @@ void DotCallGraph::buildGraph(DotNode *n,const MemberDef *md,int distance) name = rmd->qualifiedName(); } QCString tooltip = rmd->briefDescriptionAsTooltip(); - bn = new DotNode( + DotNode *bn = new DotNode( getNextNodeNumber(), linkToText(rmd->getLanguage(),name,FALSE), tooltip, @@ -66,7 +67,7 @@ void DotCallGraph::buildGraph(DotNode *n,const MemberDef *md,int distance) n->addChild(bn,0,0,0); bn->addParent(n); bn->setDistance(distance); - m_usedNodes->insert(uniqueId,bn); + m_usedNodes.insert(std::make_pair(uniqueId.str(),bn)); buildGraph(bn,rmd,distance+1); } @@ -74,11 +75,12 @@ void DotCallGraph::buildGraph(DotNode *n,const MemberDef *md,int distance) } } -void DotCallGraph::determineVisibleNodes(QList<DotNode> &queue, int &maxNodes) +void DotCallGraph::determineVisibleNodes(DotNodeDeque &queue, int &maxNodes) { - while (queue.count()>0 && maxNodes>0) + while (!queue.empty() && maxNodes>0) { - DotNode *n = queue.take(0); + DotNode *n = queue.front(); + queue.pop_front(); if (!n->isVisible() && n->distance()<=Config_getInt(MAX_DOT_GRAPH_DEPTH)) // not yet processed { n->markAsVisible(); @@ -86,17 +88,18 @@ void DotCallGraph::determineVisibleNodes(QList<DotNode> &queue, int &maxNodes) // add direct children for (const auto &dn : n->children()) { - queue.append(dn); + queue.push_back(dn); } } } } -void DotCallGraph::determineTruncatedNodes(QList<DotNode> &queue) +void DotCallGraph::determineTruncatedNodes(DotNodeDeque &queue) { - while (queue.count()>0) + while (!queue.empty()) { - DotNode *n = queue.take(0); + DotNode *n = queue.front(); + queue.pop_front(); if (n->isVisible() && n->isTruncated()==DotNode::Unknown) { bool truncated = FALSE; @@ -105,7 +108,7 @@ void DotCallGraph::determineTruncatedNodes(QList<DotNode> &queue) if (!dn->isVisible()) truncated = TRUE; else - queue.append(dn); + queue.push_back(dn); } n->markAsTruncated(truncated); } @@ -135,23 +138,21 @@ DotCallGraph::DotCallGraph(const MemberDef *md,bool inverse) TRUE // root node ); m_startNode->setDistance(0); - m_usedNodes = new QDict<DotNode>(1009); - m_usedNodes->insert(uniqueId,m_startNode); + m_usedNodes.insert(std::make_pair(uniqueId.str(),m_startNode)); buildGraph(m_startNode,md,1); int maxNodes = Config_getInt(DOT_GRAPH_MAX_NODES); - QList<DotNode> openNodeQueue; - openNodeQueue.append(m_startNode); + DotNodeDeque openNodeQueue; + openNodeQueue.push_back(m_startNode); determineVisibleNodes(openNodeQueue,maxNodes); openNodeQueue.clear(); - openNodeQueue.append(m_startNode); + openNodeQueue.push_back(m_startNode); determineTruncatedNodes(openNodeQueue); } DotCallGraph::~DotCallGraph() { DotNode::deleteNodes(m_startNode); - delete m_usedNodes; } QCString DotCallGraph::getBaseName() const diff --git a/src/dotcallgraph.h b/src/dotcallgraph.h index bba976c..1bc8882 100644 --- a/src/dotcallgraph.h +++ b/src/dotcallgraph.h @@ -16,6 +16,7 @@ #ifndef DOTCALLGRAPH_H #define DOTCALLGRAPH_H +#include "dotnode.h" #include "dotgraph.h" #include "ftextstream.h" #include "memberdef.h" @@ -41,10 +42,10 @@ class DotCallGraph : public DotGraph private: void buildGraph(DotNode *n,const MemberDef *md,int distance); - void determineVisibleNodes(QList<DotNode> &queue, int &maxNodes); - void determineTruncatedNodes(QList<DotNode> &queue); + void determineVisibleNodes(DotNodeDeque &queue, int &maxNodes); + void determineTruncatedNodes(DotNodeDeque &queue); DotNode *m_startNode; - QDict<DotNode> *m_usedNodes; + DotNodeMap m_usedNodes; bool m_inverse; QCString m_diskName; const Definition * m_scope; diff --git a/src/dotclassgraph.cpp b/src/dotclassgraph.cpp index cdb30e2..9146a25 100644 --- a/src/dotclassgraph.cpp +++ b/src/dotclassgraph.cpp @@ -51,9 +51,10 @@ void DotClassGraph::addClass(const ClassDef *cd,DotNode *n,int prot, } //printf("DotClassGraph::addClass(class='%s',parent=%s,prot=%d,label=%s,dist=%d,usedName=%s,templSpec=%s,base=%d)\n", // className.data(),n->label().data(),prot,label,distance,usedName,templSpec,base); - DotNode *bn = m_usedNodes->find(fullName); - if (bn) // class already inserted + auto it = m_usedNodes.find(fullName.str()); + if (it!=m_usedNodes.end()) // class already inserted { + DotNode *bn = it->second; if (base) { n->addChild(bn,prot,edgeStyle,label); @@ -81,7 +82,7 @@ void DotClassGraph::addClass(const ClassDef *cd,DotNode *n,int prot, } } QCString tooltip = cd->briefDescriptionAsTooltip(); - bn = new DotNode(getNextNodeNumber(), + DotNode *bn = new DotNode(getNextNodeNumber(), displayName, tooltip, tmp_url.data(), @@ -99,7 +100,7 @@ void DotClassGraph::addClass(const ClassDef *cd,DotNode *n,int prot, n->addParent(bn); } bn->setDistance(distance); - m_usedNodes->insert(fullName,bn); + m_usedNodes.insert(std::make_pair(fullName.str(),bn)); //printf(" add new child node '%s' to %s hidden=%d url=%s\n", // className.data(),n->label().data(),cd->isHidden(),tmp_url.data()); @@ -107,11 +108,12 @@ void DotClassGraph::addClass(const ClassDef *cd,DotNode *n,int prot, } } -void DotClassGraph::determineTruncatedNodes(QList<DotNode> &queue,bool includeParents) +void DotClassGraph::determineTruncatedNodes(DotNodeDeque &queue,bool includeParents) { - while (queue.count()>0) + while (!queue.empty()) { - DotNode *n = queue.take(0); + DotNode *n = queue.front(); + queue.pop_front(); if (n->isVisible() && n->isTruncated()==DotNode::Unknown) { bool truncated = FALSE; @@ -120,7 +122,7 @@ void DotClassGraph::determineTruncatedNodes(QList<DotNode> &queue,bool includePa if (!dn->isVisible()) truncated = TRUE; else - queue.append(dn); + queue.push_back(dn); } if (includeParents) { @@ -129,7 +131,7 @@ void DotClassGraph::determineTruncatedNodes(QList<DotNode> &queue,bool includePa if (!dn->isVisible()) truncated = TRUE; else - queue.append(dn); + queue.push_back(dn); } } n->markAsTruncated(truncated); @@ -140,19 +142,20 @@ void DotClassGraph::determineTruncatedNodes(QList<DotNode> &queue,bool includePa bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, int maxNodes,bool includeParents) { - QList<DotNode> childQueue; - QList<DotNode> parentQueue; + DotNodeDeque childQueue; + DotNodeDeque parentQueue; IntVector childTreeWidth; IntVector parentTreeWidth; - childQueue.append(rootNode); - if (includeParents) parentQueue.append(rootNode); + childQueue.push_back(rootNode); + if (includeParents) parentQueue.push_back(rootNode); bool firstNode=TRUE; // flag to force reprocessing rootNode in the parent loop // despite being marked visible in the child loop - while ((childQueue.count()>0 || parentQueue.count()>0) && maxNodes>0) + while ((!childQueue.empty() || !parentQueue.empty()) && maxNodes>0) { - if (childQueue.count()>0) + if (!childQueue.empty()) { - DotNode *n = childQueue.take(0); + DotNode *n = childQueue.front(); + childQueue.pop_front(); int distance = n->distance(); if (!n->isVisible() && distance<=Config_getInt(MAX_DOT_GRAPH_DEPTH)) // not yet processed { @@ -171,13 +174,14 @@ bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, // add direct children for (const auto &dn : n->children()) { - childQueue.append(dn); + childQueue.push_back(dn); } } } - if (includeParents && parentQueue.count()>0) + if (includeParents && !parentQueue.empty()) { - DotNode *n = parentQueue.take(0); + DotNode *n = parentQueue.front(); + parentQueue.pop_front(); if ((!n->isVisible() || firstNode) && n->distance()<=Config_getInt(MAX_DOT_GRAPH_DEPTH)) // not yet processed { firstNode=FALSE; @@ -197,7 +201,7 @@ bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, // add direct parents for (const auto &dn : n->parents()) { - parentQueue.append(dn); + parentQueue.push_back(dn); } } } @@ -327,15 +331,14 @@ DotClassGraph::DotClassGraph(const ClassDef *cd,GraphType t) cd ); m_startNode->setDistance(0); - m_usedNodes = new QDict<DotNode>(1009); - m_usedNodes->insert(className,m_startNode); + m_usedNodes.insert(std::make_pair(className.str(),m_startNode)); buildGraph(cd,m_startNode,TRUE,1); if (t==Inheritance) buildGraph(cd,m_startNode,FALSE,1); m_lrRank = determineVisibleNodes(m_startNode,Config_getInt(DOT_GRAPH_MAX_NODES),t==Inheritance); - QList<DotNode> openNodeQueue; - openNodeQueue.append(m_startNode); + DotNodeDeque openNodeQueue; + openNodeQueue.push_back(m_startNode); determineTruncatedNodes(openNodeQueue,t==Inheritance); m_collabFileName = cd->collaborationGraphFileName(); @@ -369,7 +372,6 @@ int DotClassGraph::numNodes() const DotClassGraph::~DotClassGraph() { DotNode::deleteNodes(m_startNode); - delete m_usedNodes; } QCString DotClassGraph::getBaseName() const @@ -456,30 +458,24 @@ QCString DotClassGraph::writeGraph(FTextStream &out, void DotClassGraph::writeXML(FTextStream &t) { - QDictIterator<DotNode> dni(*m_usedNodes); - DotNode *node; - for (;(node=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - node->writeXML(t,TRUE); + kv.second->writeXML(t,TRUE); } } void DotClassGraph::writeDocbook(FTextStream &t) { - QDictIterator<DotNode> dni(*m_usedNodes); - DotNode *node; - for (;(node=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - node->writeDocbook(t,TRUE); + kv.second->writeDocbook(t,TRUE); } } void DotClassGraph::writeDEF(FTextStream &t) { - QDictIterator<DotNode> dni(*m_usedNodes); - DotNode *node; - for (;(node=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - node->writeDEF(t); + kv.second->writeDEF(t); } } diff --git a/src/dotclassgraph.h b/src/dotclassgraph.h index 1874f54..168d315 100644 --- a/src/dotclassgraph.h +++ b/src/dotclassgraph.h @@ -17,7 +17,7 @@ #define DOTCLASSGRAPH_H #include "classdef.h" - +#include "dotnode.h" #include "dotgraph.h" /** Representation of a class inheritance or dependency graph */ @@ -46,13 +46,13 @@ protected: private: void buildGraph(const ClassDef *cd,DotNode *n,bool base,int distance); bool determineVisibleNodes(DotNode *rootNode,int maxNodes,bool includeParents); - void determineTruncatedNodes(QList<DotNode> &queue,bool includeParents); + void determineTruncatedNodes(DotNodeDeque &queue,bool includeParents); void addClass(const ClassDef *cd,DotNode *n,int prot,const char *label, const char *usedName,const char *templSpec, bool base,int distance); DotNode * m_startNode; - QDict<DotNode> * m_usedNodes; + DotNodeMap m_usedNodes; GraphType m_graphType; QCString m_collabFileName; QCString m_inheritFileName; diff --git a/src/dotdirdeps.cpp b/src/dotdirdeps.cpp index 8ec3a6e..4b8f1c3 100644 --- a/src/dotdirdeps.cpp +++ b/src/dotdirdeps.cpp @@ -20,6 +20,8 @@ #include "doxygen.h" #include "config.h" +using DirDefMap = std::map<std::string,const DirDef *>; + /** * Puts DOT code for drawing directory to stream and adds it to the list. * @param[in,out] outStream stream to which the DOT code is written to @@ -28,7 +30,7 @@ * @param[in,out] directoriesInGraph lists the directories which have been written to the output stream */ static void drawDirectory(FTextStream &outStream, const DirDef *const directory, const bool fillBackground, - QDict<DirDef> &directoriesInGraph) + DirDefMap &directoriesInGraph) { outStream << " " << directory->getOutputFileBase() << " [shape=box " "label=\"" << directory->shortName() << "\" "; @@ -41,7 +43,7 @@ static void drawDirectory(FTextStream &outStream, const DirDef *const directory, outStream << "color=\"red\" "; } outStream << "URL=\"" << directory->getOutputFileBase() << Doxygen::htmlFileExtension << "\"];\n"; - directoriesInGraph.insert(directory->getOutputFileBase(), directory); + directoriesInGraph.insert(std::make_pair(directory->getOutputFileBase().str(), directory)); } void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations) @@ -57,9 +59,9 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations) t << " node [ fontsize=\"" << fontSize << "\", fontname=\"" << fontName << "\"];\n"; t << " edge [ labelfontsize=\"" << fontSize << "\", labelfontname=\"" << fontName << "\"];\n"; - QDict<DirDef> dirsInGraph(257); + DirDefMap dirsInGraph; - dirsInGraph.insert(dd->getOutputFileBase(),dd); + dirsInGraph.insert(std::make_pair(dd->getOutputFileBase().str(),dd)); std::vector<const DirDef *> usedDirsNotDrawn; for(const auto& usedDir : dd->usedDirs()) @@ -148,17 +150,16 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations) } // add relations between all selected directories - const DirDef *dir; - QDictIterator<DirDef> di(dirsInGraph); - for (;(dir=di.current());++di) // foreach dir in the graph + for (const auto &kv : dirsInGraph) // foreach dir in the graph { + const DirDef *dir = kv.second; for (const auto &udir : dir->usedDirs()) { const DirDef *usedDir=udir->dir(); if ((dir!=dd || !udir->inherited()) && // only show direct dependencies for this dir (usedDir!=dd || !udir->inherited()) && // only show direct dependencies for this dir !usedDir->isParentOf(dir) && // don't point to own parent - dirsInGraph.find(usedDir->getOutputFileBase())) // only point to nodes that are in the graph + dirsInGraph.find(usedDir->getOutputFileBase().str())!=dirsInGraph.end()) // only point to nodes that are in the graph { QCString relationName; relationName.sprintf("dir_%06d_%06d",dir->dirCount(),usedDir->dirCount()); diff --git a/src/dotfilepatcher.cpp b/src/dotfilepatcher.cpp index 285c0bb..aafca34 100644 --- a/src/dotfilepatcher.cpp +++ b/src/dotfilepatcher.cpp @@ -255,7 +255,6 @@ bool DotFilePatcher::convertMapFile(FTextStream &t,const char *mapName, DotFilePatcher::DotFilePatcher(const char *patchFile) : m_patchFile(patchFile) { - m_maps.setAutoDelete(TRUE); } bool DotFilePatcher::isSVGFile() const @@ -266,30 +265,16 @@ bool DotFilePatcher::isSVGFile() const int DotFilePatcher::addMap(const QCString &mapFile,const QCString &relPath, bool urlOnly,const QCString &context,const QCString &label) { - int id = m_maps.count(); - Map *map = new Map; - map->mapFile = mapFile; - map->relPath = relPath; - map->urlOnly = urlOnly; - map->context = context; - map->label = label; - map->zoomable = FALSE; - map->graphId = -1; - m_maps.append(map); + int id = (int)m_maps.size(); + m_maps.emplace_back(mapFile,relPath,urlOnly,context,label); return id; } int DotFilePatcher::addFigure(const QCString &baseName, const QCString &figureName,bool heightCheck) { - int id = m_maps.count(); - Map *map = new Map; - map->mapFile = figureName; - map->urlOnly = heightCheck; - map->label = baseName; - map->zoomable = FALSE; - map->graphId = -1; - m_maps.append(map); + int id = (int)m_maps.size(); + m_maps.emplace_back(figureName,"",heightCheck,"",baseName); return id; } @@ -297,14 +282,8 @@ int DotFilePatcher::addSVGConversion(const QCString &relPath,bool urlOnly, const QCString &context,bool zoomable, int graphId) { - int id = m_maps.count(); - Map *map = new Map; - map->relPath = relPath; - map->urlOnly = urlOnly; - map->context = context; - map->zoomable = zoomable; - map->graphId = graphId; - m_maps.append(map); + int id = (int)m_maps.size(); + m_maps.emplace_back("",relPath,urlOnly,context,"",zoomable,graphId); return id; } @@ -312,14 +291,8 @@ int DotFilePatcher::addSVGObject(const QCString &baseName, const QCString &absImgName, const QCString &relPath) { - int id = m_maps.count(); - Map *map = new Map; - map->mapFile = absImgName; - map->relPath = relPath; - map->label = baseName; - map->zoomable = FALSE; - map->graphId = -1; - m_maps.append(map); + int id = (int)m_maps.size(); + m_maps.emplace_back(absImgName,relPath,false,"",baseName); return id; } @@ -332,10 +305,10 @@ bool DotFilePatcher::run() const QCString relPath; if (isSVGFile) { - Map *map = m_maps.at(0); // there is only one 'map' for a SVG file - interactiveSVG_local = interactiveSVG_local && map->zoomable; - graphId = map->graphId; - relPath = map->relPath; + const Map &map = m_maps.front(); // there is only one 'map' for a SVG file + interactiveSVG_local = interactiveSVG_local && map.zoomable; + graphId = map.graphId; + relPath = map.relPath; //printf("DotFilePatcher::addSVGConversion: file=%s zoomable=%d\n", // m_patchFile.data(),map->zoomable); } @@ -418,8 +391,8 @@ bool DotFilePatcher::run() const // unless we are inside the header of the SVG. // Then we replace it with another header. { - Map *map = m_maps.at(0); // there is only one 'map' for a SVG file - t << replaceRef(line,map->relPath,map->urlOnly,map->context,"_top"); + const Map &map = m_maps.front(); // there is only one 'map' for a SVG file + t << replaceRef(line,map.relPath,map.urlOnly,map.context,"_top"); } } else if ((i=line.find("<!-- SVG"))!=-1 || (i=line.find("[!-- SVG"))!=-1) @@ -428,15 +401,15 @@ bool DotFilePatcher::run() const int mapId=-1; t << line.left(i); int n = sscanf(line.data()+i+1,"!-- SVG %d",&mapId); - if (n==1 && mapId>=0 && mapId<(int)m_maps.count()) + if (n==1 && mapId>=0 && mapId<(int)m_maps.size()) { int e = QMAX(line.find("--]"),line.find("-->")); - Map *map = m_maps.at(mapId); + const Map &map = m_maps.at(mapId); //printf("DotFilePatcher::writeSVGFigure: file=%s zoomable=%d\n", - // m_patchFile.data(),map->zoomable); - if (!writeSVGFigureLink(t,map->relPath,map->label,map->mapFile)) + // m_patchFile.data(),map.zoomable); + if (!writeSVGFigureLink(t,map.relPath,map.label,map.mapFile)) { - err("Problem extracting size from SVG file %s\n",map->mapFile.data()); + err("Problem extracting size from SVG file %s\n",map.mapFile.data()); } if (e!=-1) t << line.mid(e+3); } @@ -451,17 +424,17 @@ bool DotFilePatcher::run() const int mapId=-1; t << line.left(i); int n = sscanf(line.data()+i,"<!-- MAP %d",&mapId); - if (n==1 && mapId>=0 && mapId<(int)m_maps.count()) + if (n==1 && mapId>=0 && mapId<(int)m_maps.size()) { QGString result; FTextStream tt(&result); - Map *map = m_maps.at(mapId); + const Map &map = m_maps.at(mapId); //printf("patching MAP %d in file %s with contents of %s\n", - // mapId,m_patchFile.data(),map->mapFile.data()); - convertMapFile(tt,map->mapFile,map->relPath,map->urlOnly,map->context); + // mapId,m_patchFile.data(),map.mapFile.data()); + convertMapFile(tt,map.mapFile,map.relPath,map.urlOnly,map.context); if (!result.isEmpty()) { - t << "<map name=\"" << correctId(map->label) << "\" id=\"" << correctId(map->label) << "\">" << endl; + t << "<map name=\"" << correctId(map.label) << "\" id=\"" << correctId(map.label) << "\">" << endl; t << result; t << "</map>" << endl; } @@ -477,12 +450,12 @@ bool DotFilePatcher::run() const int mapId=-1; int n = sscanf(line.data()+i+2,"FIG %d",&mapId); //printf("line='%s' n=%d\n",line.data()+i,n); - if (n==1 && mapId>=0 && mapId<(int)m_maps.count()) + if (n==1 && mapId>=0 && mapId<(int)m_maps.size()) { - Map *map = m_maps.at(mapId); + const Map &map = m_maps.at(mapId); //printf("patching FIG %d in file %s with contents of %s\n", - // mapId,m_patchFile.data(),map->mapFile.data()); - if (!writeVecGfxFigure(t,map->label,map->mapFile)) + // mapId,m_patchFile.data(),map.mapFile.data()); + if (!writeVecGfxFigure(t,map.label,map.mapFile)) { err("problem writing FIG %d figure!\n",mapId); return FALSE; @@ -530,8 +503,8 @@ bool DotFilePatcher::run() const break; } line.resize(numBytes+1); - Map *map = m_maps.at(0); // there is only one 'map' for a SVG file - to << replaceRef(line,map->relPath,map->urlOnly,map->context,"_top"); + const Map &map = m_maps.front(); // there is only one 'map' for a SVG file + to << replaceRef(line,map.relPath,map.urlOnly,map.context,"_top"); } fi.close(); fo.close(); diff --git a/src/dotfilepatcher.h b/src/dotfilepatcher.h index b68208d..1886e47 100644 --- a/src/dotfilepatcher.h +++ b/src/dotfilepatcher.h @@ -16,8 +16,9 @@ #ifndef DOTFILEPATCHER_H #define DOTFILEPATCHER_H +#include <vector> + #include "qcstring.h" -#include "qlist.h" class FTextStream; @@ -54,6 +55,10 @@ class DotFilePatcher private: struct Map { + Map(const QCString &mf,const QCString &rp,bool uo,const QCString &ctx, + const QCString &lab,bool zoom=false,int gId=-1) : + mapFile(mf), relPath(rp), urlOnly(uo), context(ctx), + label(lab), zoomable(zoom), graphId(gId) {} QCString mapFile; QCString relPath; bool urlOnly; @@ -62,7 +67,7 @@ class DotFilePatcher bool zoomable; int graphId; }; - QList<Map> m_maps; + std::vector<Map> m_maps; QCString m_patchFile; }; diff --git a/src/dotgroupcollaboration.cpp b/src/dotgroupcollaboration.cpp index a2db7d0..4ce57a2 100644 --- a/src/dotgroupcollaboration.cpp +++ b/src/dotgroupcollaboration.cpp @@ -14,8 +14,6 @@ */ #include "dotgroupcollaboration.h" - -#include "dotnode.h" #include "classlist.h" #include "doxygen.h" #include "namespacedef.h" @@ -26,12 +24,10 @@ DotGroupCollaboration::DotGroupCollaboration(const GroupDef* gd) { QCString tmp_url = gd->getReference()+"$"+gd->getOutputFileBase(); - m_usedNodes = new QDict<DotNode>(1009); QCString tooltip = gd->briefDescriptionAsTooltip(); m_rootNode = new DotNode(getNextNodeNumber(), gd->groupTitle(), tooltip, tmp_url, TRUE ); m_rootNode->markAsVisible(); - m_usedNodes->insert(gd->name(), m_rootNode ); - m_edges.setAutoDelete(TRUE); + m_usedNodes.insert(std::make_pair(gd->name().str(), m_rootNode)); m_diskName = gd->getOutputFileBase(); @@ -40,17 +36,11 @@ DotGroupCollaboration::DotGroupCollaboration(const GroupDef* gd) DotGroupCollaboration::~DotGroupCollaboration() { - // delete all created Nodes saved in m_usedNodes:QDict - if(m_usedNodes != NULL) + // delete all created Nodes saved in m_usedNodes map + for (const auto &kv : m_usedNodes) { - QDictIterator<DotNode> it(*m_usedNodes); - for(;it.current(); ++it) - { - delete it.current(); - } + delete kv.second; } - - delete m_usedNodes; } void DotGroupCollaboration::buildGraph(const GroupDef* gd) @@ -62,14 +52,19 @@ void DotGroupCollaboration::buildGraph(const GroupDef* gd) // Write parents for (const auto &d : gd->partOfGroups()) { - DotNode* nnode = m_usedNodes->find(d->name()); - if ( !nnode ) + DotNode *nnode = 0; + auto it = m_usedNodes.find(d->name().str()); + if ( it==m_usedNodes.end()) { // add node tmp_url = d->getReference()+"$"+d->getOutputFileBase(); QCString tooltip = d->briefDescriptionAsTooltip(); nnode = new DotNode(getNextNodeNumber(), d->groupTitle(), tooltip, tmp_url ); nnode->markAsVisible(); - m_usedNodes->insert(d->name(), nnode ); + m_usedNodes.insert(std::make_pair(d->name().str(), nnode)); + } + else + { + nnode = it->second; } tmp_url = ""; addEdge( nnode, m_rootNode, DotGroupCollaboration::thierarchy, tmp_url, tmp_url ); @@ -78,14 +73,19 @@ void DotGroupCollaboration::buildGraph(const GroupDef* gd) // Add subgroups for (const auto &def : gd->getSubGroups()) { - DotNode* nnode = m_usedNodes->find(def->name()); - if ( !nnode ) + DotNode *nnode = 0; + auto it = m_usedNodes.find(def->name().str()); + if ( it==m_usedNodes.end()) { // add node tmp_url = def->getReference()+"$"+def->getOutputFileBase(); QCString tooltip = def->briefDescriptionAsTooltip(); nnode = new DotNode(getNextNodeNumber(), def->groupTitle(), tooltip, tmp_url ); nnode->markAsVisible(); - m_usedNodes->insert(def->name(), nnode ); + m_usedNodes.insert(std::make_pair(def->name().str(), nnode)); + } + else + { + nnode = it->second; } tmp_url = ""; addEdge( m_rootNode, nnode, DotGroupCollaboration::thierarchy, tmp_url, tmp_url ); @@ -156,27 +156,24 @@ DotGroupCollaboration::Edge* DotGroupCollaboration::addEdge( const QCString& _label, const QCString& _url ) { // search a existing link. - QListIterator<Edge> lli(m_edges); - Edge* newEdge = 0; - for ( lli.toFirst(); (newEdge=lli.current()); ++lli) + Edge *newEdge; + for (const auto &edge : m_edges) { - if ( newEdge->pNStart==_pNStart && - newEdge->pNEnd==_pNEnd && - newEdge->eType==_eType - ) + if ( edge->pNStart==_pNStart && edge->pNEnd==_pNEnd && edge->eType==_eType) { // edge already found + newEdge = edge.get(); break; } } if ( newEdge==0 ) // new link { - newEdge = new Edge(_pNStart,_pNEnd,_eType); - m_edges.append( newEdge ); + m_edges.emplace_back(std::make_unique<Edge>(_pNStart,_pNEnd,_eType)); + newEdge = m_edges.back().get(); } if (!_label.isEmpty()) { - newEdge->links.append(new Link(_label,_url)); + newEdge->links.emplace_back(_label,_url); } return newEdge; @@ -189,7 +186,8 @@ void DotGroupCollaboration::addCollaborationMember( QCString tmp_str; for (const auto &d : def->partOfGroups()) { - DotNode* nnode = m_usedNodes->find(d->name()); + auto it = m_usedNodes.find(d->name().str()); + DotNode* nnode = it!=m_usedNodes.end() ? it->second : 0; if ( nnode != m_rootNode ) { if ( nnode==0 ) @@ -198,7 +196,7 @@ void DotGroupCollaboration::addCollaborationMember( QCString tooltip = d->briefDescriptionAsTooltip(); nnode = new DotNode(getNextNodeNumber(), d->groupTitle(), tooltip, tmp_str ); nnode->markAsVisible(); - m_usedNodes->insert(d->name(), nnode ); + m_usedNodes.insert(std::make_pair(d->name().str(), nnode)); } tmp_str = def->qualifiedName(); addEdge( m_rootNode, nnode, eType, tmp_str, url ); @@ -217,23 +215,19 @@ void DotGroupCollaboration::computeTheGraph() writeGraphHeader(md5stream,m_rootNode->label()); // clean write flags - QDictIterator<DotNode> dni(*m_usedNodes); - DotNode *pn; - for (dni.toFirst();(pn=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - pn->clearWriteFlag(); + kv.second->clearWriteFlag(); } // write other nodes. - for (dni.toFirst();(pn=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - pn->write(md5stream,Inheritance,m_graphFormat,TRUE,FALSE,FALSE); + kv.second->write(md5stream,Inheritance,m_graphFormat,TRUE,FALSE,FALSE); } // write edges - QListIterator<Edge> eli(m_edges); - Edge* edge; - for (eli.toFirst();(edge=eli.current());++eli) + for (const auto &edge : m_edges) { edge->write( md5stream ); } @@ -274,34 +268,30 @@ void DotGroupCollaboration::Edge::write( FTextStream &t ) const t << "Node" << pNEnd->number(); t << " [shape=plaintext"; - if (links.count()>0) // there are links + if (!links.empty()) // there are links { t << ", "; // HTML-like edge labels crash on my Mac with Graphviz 2.0! and // are not supported by older version of dot. // //t << label=<<TABLE BORDER=\"0\" CELLBORDER=\"0\">"; - //QListIterator<Link> lli(links); - //Link *link; - //for( lli.toFirst(); (link=lli.current()); ++lli) + //for (const auto &link : links) //{ // t << "<TR><TD"; - // if ( !link->url.isEmpty() ) - // t << " HREF=\"" << link->url << "\""; - // t << ">" << link->label << "</TD></TR>"; + // if ( !link.url.isEmpty() ) + // t << " HREF=\"" << link.url << "\""; + // t << ">" << DotNode::convertLabel(link->label) << "</TD></TR>"; //} //t << "</TABLE>>"; t << "label=\""; - QListIterator<Link> lli(links); - Link *link; bool first=TRUE; int count=0; const int maxLabels = 10; - for( lli.toFirst(); (link=lli.current()) && count<maxLabels; ++lli,++count) + for (const auto &link : links) { if (first) first=FALSE; else t << "\\n"; - t << DotNode::convertLabel(link->label); + t << DotNode::convertLabel(link.label); } if (count==maxLabels) t << "\\n..."; t << "\""; @@ -322,7 +312,7 @@ void DotGroupCollaboration::Edge::write( FTextStream &t ) const bool DotGroupCollaboration::isTrivial() const { - return m_usedNodes->count() <= 1; + return m_usedNodes.size() <= 1; } void DotGroupCollaboration::writeGraphHeader(FTextStream &t,const QCString &title) const diff --git a/src/dotgroupcollaboration.h b/src/dotgroupcollaboration.h index 539637f..ebfe6e7 100644 --- a/src/dotgroupcollaboration.h +++ b/src/dotgroupcollaboration.h @@ -16,8 +16,8 @@ #ifndef DOTGROUPCOLLABORATION_H #define DOTGROUPCOLLABORATION_H +#include "dotnode.h" #include "dotgraph.h" -#include "qlist.h" #include "groupdef.h" /** Representation of a group collaboration graph */ @@ -58,14 +58,13 @@ class DotGroupCollaboration : public DotGraph struct Edge { Edge(DotNode *start,DotNode *end,EdgeType type) - : pNStart(start), pNEnd(end), eType(type) - { links.setAutoDelete(TRUE); } + : pNStart(start), pNEnd(end), eType(type) {} DotNode* pNStart; DotNode* pNEnd; EdgeType eType; - QList<Link> links; + std::vector<Link> links; void write( FTextStream &t ) const; }; @@ -77,9 +76,9 @@ class DotGroupCollaboration : public DotGraph const QCString& _label, const QCString& _url ); DotNode *m_rootNode; - QDict<DotNode> *m_usedNodes; + DotNodeMap m_usedNodes; QCString m_diskName; - QList<Edge> m_edges; + std::vector< std::unique_ptr<Edge> > m_edges; }; #endif diff --git a/src/dotincldepgraph.cpp b/src/dotincldepgraph.cpp index 9dceecb..07b2139 100644 --- a/src/dotincldepgraph.cpp +++ b/src/dotincldepgraph.cpp @@ -41,9 +41,10 @@ void DotInclDepGraph::buildGraph(DotNode *n,const FileDef *fd,int distance) { url=bfd->getSourceFileBase(); } - DotNode *bn = m_usedNodes->find(in); - if (bn) // file is already a node in the graph + auto it = m_usedNodes.find(in.str()); + if (it!=m_usedNodes.end()) // file is already a node in the graph { + DotNode *bn = it->second; n->addChild(bn,0,0,0); bn->addParent(n); bn->setDistance(distance); @@ -57,7 +58,7 @@ void DotInclDepGraph::buildGraph(DotNode *n,const FileDef *fd,int distance) tmp_url=doc || src ? bfd->getReference()+"$"+url : QCString(); tooltip = bfd->briefDescriptionAsTooltip(); } - bn = new DotNode(getNextNodeNumber(),// n + DotNode *bn = new DotNode(getNextNodeNumber(),// n ii.includeName, // label tooltip, // tip tmp_url, // url @@ -65,7 +66,7 @@ void DotInclDepGraph::buildGraph(DotNode *n,const FileDef *fd,int distance) 0); // cd n->addChild(bn,0,0,0); bn->addParent(n); - m_usedNodes->insert(in,bn); + m_usedNodes.insert(std::make_pair(in.str(),bn)); bn->setDistance(distance); if (bfd) buildGraph(bn,bfd,distance+1); @@ -74,11 +75,12 @@ void DotInclDepGraph::buildGraph(DotNode *n,const FileDef *fd,int distance) } } -void DotInclDepGraph::determineVisibleNodes(QList<DotNode> &queue, int &maxNodes) +void DotInclDepGraph::determineVisibleNodes(DotNodeDeque &queue, int &maxNodes) { - while (queue.count()>0 && maxNodes>0) + while (!queue.empty() && maxNodes>0) { - DotNode *n = queue.take(0); + DotNode *n = queue.front(); + queue.pop_front(); if (!n->isVisible() && n->distance()<=Config_getInt(MAX_DOT_GRAPH_DEPTH)) // not yet processed { n->markAsVisible(); @@ -86,17 +88,18 @@ void DotInclDepGraph::determineVisibleNodes(QList<DotNode> &queue, int &maxNodes // add direct children for (const auto &dn : n->children()) { - queue.append(dn); + queue.push_back(dn); } } } } -void DotInclDepGraph::determineTruncatedNodes(QList<DotNode> &queue) +void DotInclDepGraph::determineTruncatedNodes(DotNodeDeque &queue) { - while (queue.count()>0) + while (!queue.empty()) { - DotNode *n = queue.take(0); + DotNode *n = queue.front(); + queue.pop_front(); if (n->isVisible() && n->isTruncated()==DotNode::Unknown) { bool truncated = FALSE; @@ -108,7 +111,7 @@ void DotInclDepGraph::determineTruncatedNodes(QList<DotNode> &queue) } else { - queue.append(dn); + queue.push_back(dn); } } n->markAsTruncated(truncated); @@ -130,23 +133,21 @@ DotInclDepGraph::DotInclDepGraph(const FileDef *fd,bool inverse) tmp_url.data(), TRUE); // root node m_startNode->setDistance(0); - m_usedNodes = new QDict<DotNode>(1009); - m_usedNodes->insert(fd->absFilePath(),m_startNode); + m_usedNodes.insert(std::make_pair(fd->absFilePath().str(),m_startNode)); buildGraph(m_startNode,fd,1); int maxNodes = Config_getInt(DOT_GRAPH_MAX_NODES); - QList<DotNode> openNodeQueue; - openNodeQueue.append(m_startNode); + DotNodeDeque openNodeQueue; + openNodeQueue.push_back(m_startNode); determineVisibleNodes(openNodeQueue,maxNodes); openNodeQueue.clear(); - openNodeQueue.append(m_startNode); + openNodeQueue.push_back(m_startNode); determineTruncatedNodes(openNodeQueue); } DotInclDepGraph::~DotInclDepGraph() { DotNode::deleteNodes(m_startNode); - delete m_usedNodes; } QCString DotInclDepGraph::getBaseName() const @@ -208,20 +209,16 @@ int DotInclDepGraph::numNodes() const void DotInclDepGraph::writeXML(FTextStream &t) { - QDictIterator<DotNode> dni(*m_usedNodes); - DotNode *node; - for (;(node=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - node->writeXML(t,FALSE); + kv.second->writeXML(t,FALSE); } } void DotInclDepGraph::writeDocbook(FTextStream &t) { - QDictIterator<DotNode> dni(*m_usedNodes); - DotNode *node; - for (;(node=dni.current());++dni) + for (const auto &kv : m_usedNodes) { - node->writeDocbook(t,FALSE); + kv.second->writeDocbook(t,FALSE); } } diff --git a/src/dotincldepgraph.h b/src/dotincldepgraph.h index 5807ce8..0105489 100644 --- a/src/dotincldepgraph.h +++ b/src/dotincldepgraph.h @@ -19,6 +19,7 @@ #include "qcstring.h" #include "filedef.h" +#include "dotnode.h" #include "dotgraph.h" /** Representation of an include dependency graph */ @@ -44,11 +45,11 @@ class DotInclDepGraph : public DotGraph private: QCString diskName() const; void buildGraph(DotNode *n,const FileDef *fd,int distance); - void determineVisibleNodes(QList<DotNode> &queue,int &maxNodes); - void determineTruncatedNodes(QList<DotNode> &queue); + void determineVisibleNodes(DotNodeDeque &queue,int &maxNodes); + void determineTruncatedNodes(DotNodeDeque &queue); DotNode *m_startNode; - QDict<DotNode> *m_usedNodes; + DotNodeMap m_usedNodes; QCString m_inclDepFileName; QCString m_inclByDepFileName; bool m_inverse; diff --git a/src/dotnode.h b/src/dotnode.h index dd42637..2eb3f7d 100644 --- a/src/dotnode.h +++ b/src/dotnode.h @@ -17,6 +17,8 @@ #define DOTNODE_H #include <vector> +#include <map> +#include <deque> #include "dotgraph.h" @@ -128,4 +130,12 @@ class DotNode int m_subgraphId = -1; }; +class DotNodeMap : public std::map<std::string,DotNode*> +{ +}; + +class DotNodeDeque : public std::deque<DotNode*> +{ +}; + #endif diff --git a/testing/011/interface_integer.xml b/testing/011/interface_integer.xml index 45833d8..786bc2a 100644 --- a/testing/011/interface_integer.xml +++ b/testing/011/interface_integer.xml @@ -59,26 +59,26 @@ <para>An interface </para> </detaileddescription> <inheritancegraph> - <node id="2"> - <label>Object</label> - </node> <node id="1"> <label>Integer</label> <link refid="interface_integer"/> <childnode refid="2" relation="public-inheritance"> </childnode> </node> - </inheritancegraph> - <collaborationgraph> <node id="2"> <label>Object</label> </node> + </inheritancegraph> + <collaborationgraph> <node id="1"> <label>Integer</label> <link refid="interface_integer"/> <childnode refid="2" relation="public-inheritance"> </childnode> </node> + <node id="2"> + <label>Object</label> + </node> </collaborationgraph> <location file="011_category.m" line="6" column="12" bodyfile="011_category.m" bodystart="6" bodyend="-1"/> <listofallmembers> diff --git a/testing/027/struct_car.xml b/testing/027/struct_car.xml index 8b203e5..a2d384d 100644 --- a/testing/027/struct_car.xml +++ b/testing/027/struct_car.xml @@ -27,30 +27,30 @@ <para><ref refid="struct_car" kindref="compound">Car</ref> class. </para> </detaileddescription> <inheritancegraph> - <node id="2"> - <label>Vehicle</label> - <link refid="struct_vehicle"/> - <childnode refid="3" relation="public-inheritance"> - </childnode> - </node> - <node id="3"> - <label>Object</label> - <link refid="struct_object"/> - </node> <node id="1"> <label>Car</label> <link refid="struct_car"/> <childnode refid="2" relation="public-inheritance"> </childnode> </node> - </inheritancegraph> - <collaborationgraph> + <node id="3"> + <label>Object</label> + <link refid="struct_object"/> + </node> <node id="2"> <label>Vehicle</label> <link refid="struct_vehicle"/> <childnode refid="3" relation="public-inheritance"> </childnode> - <childnode refid="3" relation="usage"> + </node> + </inheritancegraph> + <collaborationgraph> + <node id="1"> + <label>Car</label> + <link refid="struct_car"/> + <childnode refid="2" relation="public-inheritance"> + </childnode> + <childnode refid="2" relation="usage"> <edgelabel>base</edgelabel> </childnode> </node> @@ -58,12 +58,12 @@ <label>Object</label> <link refid="struct_object"/> </node> - <node id="1"> - <label>Car</label> - <link refid="struct_car"/> - <childnode refid="2" relation="public-inheritance"> + <node id="2"> + <label>Vehicle</label> + <link refid="struct_vehicle"/> + <childnode refid="3" relation="public-inheritance"> </childnode> - <childnode refid="2" relation="usage"> + <childnode refid="3" relation="usage"> <edgelabel>base</edgelabel> </childnode> </node> diff --git a/testing/027/struct_object.xml b/testing/027/struct_object.xml index 7ab7e7a..36866ac 100644 --- a/testing/027/struct_object.xml +++ b/testing/027/struct_object.xml @@ -63,6 +63,16 @@ <para>Base object class. </para> </detaileddescription> <inheritancegraph> + <node id="3"> + <label>Car</label> + <link refid="struct_car"/> + <childnode refid="2" relation="public-inheritance"> + </childnode> + </node> + <node id="1"> + <label>Object</label> + <link refid="struct_object"/> + </node> <node id="4"> <label>Truck</label> <link refid="struct_truck"/> @@ -75,16 +85,6 @@ <childnode refid="1" relation="public-inheritance"> </childnode> </node> - <node id="1"> - <label>Object</label> - <link refid="struct_object"/> - </node> - <node id="3"> - <label>Car</label> - <link refid="struct_car"/> - <childnode refid="2" relation="public-inheritance"> - </childnode> - </node> </inheritancegraph> <location file="027_extends.c" line="19" column="1" bodyfile="027_extends.c" bodystart="20" bodyend="22"/> <listofallmembers> diff --git a/testing/027/struct_truck.xml b/testing/027/struct_truck.xml index 588f425..2e10c7a 100644 --- a/testing/027/struct_truck.xml +++ b/testing/027/struct_truck.xml @@ -27,6 +27,10 @@ <para><ref refid="struct_truck" kindref="compound">Truck</ref> class. </para> </detaileddescription> <inheritancegraph> + <node id="3"> + <label>Object</label> + <link refid="struct_object"/> + </node> <node id="1"> <label>Truck</label> <link refid="struct_truck"/> @@ -39,12 +43,12 @@ <childnode refid="3" relation="public-inheritance"> </childnode> </node> + </inheritancegraph> + <collaborationgraph> <node id="3"> <label>Object</label> <link refid="struct_object"/> </node> - </inheritancegraph> - <collaborationgraph> <node id="1"> <label>Truck</label> <link refid="struct_truck"/> @@ -63,10 +67,6 @@ <edgelabel>base</edgelabel> </childnode> </node> - <node id="3"> - <label>Object</label> - <link refid="struct_object"/> - </node> </collaborationgraph> <location file="027_extends.c" line="77" column="1" bodyfile="027_extends.c" bodystart="78" bodyend="80"/> <listofallmembers> diff --git a/testing/027/struct_vehicle.xml b/testing/027/struct_vehicle.xml index 380f3e7..9f9e27b 100644 --- a/testing/027/struct_vehicle.xml +++ b/testing/027/struct_vehicle.xml @@ -67,6 +67,16 @@ <para><ref refid="struct_vehicle" kindref="compound">Vehicle</ref> class. </para> </detaileddescription> <inheritancegraph> + <node id="3"> + <label>Car</label> + <link refid="struct_car"/> + <childnode refid="1" relation="public-inheritance"> + </childnode> + </node> + <node id="2"> + <label>Object</label> + <link refid="struct_object"/> + </node> <node id="4"> <label>Truck</label> <link refid="struct_truck"/> @@ -79,18 +89,12 @@ <childnode refid="2" relation="public-inheritance"> </childnode> </node> + </inheritancegraph> + <collaborationgraph> <node id="2"> <label>Object</label> <link refid="struct_object"/> </node> - <node id="3"> - <label>Car</label> - <link refid="struct_car"/> - <childnode refid="1" relation="public-inheritance"> - </childnode> - </node> - </inheritancegraph> - <collaborationgraph> <node id="1"> <label>Vehicle</label> <link refid="struct_vehicle"/> @@ -100,10 +104,6 @@ <edgelabel>base</edgelabel> </childnode> </node> - <node id="2"> - <label>Object</label> - <link refid="struct_object"/> - </node> </collaborationgraph> <location file="027_extends.c" line="43" column="1" bodyfile="027_extends.c" bodystart="44" bodyend="46"/> <listofallmembers> |