From ea6e16bf7f3af2ed8779df553b8fadbf396737fa Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 2 Aug 2020 16:45:10 +0200 Subject: Changed container class for class use and constrained relations from QDict to StringSet --- src/classdef.h | 23 ++++++++----------- src/dotclassgraph.cpp | 61 ++++++++++++++++++--------------------------------- 2 files changed, 30 insertions(+), 54 deletions(-) diff --git a/src/classdef.h b/src/classdef.h index 46a13c1..d413794 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -24,6 +24,7 @@ #include #include +#include "containers.h" #include "definition.h" #include "arguments.h" @@ -433,18 +434,15 @@ struct UsesClassDef { UsesClassDef(ClassDef *cd) : classDef(cd) { - accessors = new QDict(17); - containment = TRUE; } ~UsesClassDef() { - delete accessors; } void addAccessor(const char *s) { - if (accessors->find(s)==0) + if (accessors.find(s)==accessors.end()) { - accessors->insert(s,(void *)666); + accessors.insert(s); } } /** Class definition that this relation uses. */ @@ -453,12 +451,12 @@ struct UsesClassDef /** Dictionary of member variable names that form the edge labels of the * usage relation. */ - QDict *accessors; + StringSet accessors; /** Template arguments used for the base class */ QCString templSpecifiers; - bool containment; + bool containment = true; }; /** Dictionary of usage relations. @@ -486,8 +484,7 @@ class UsesClassDictIterator : public QDictIterator */ struct BaseClassDef { - BaseClassDef(ClassDef *cd,const char *n,Protection p, - Specifier v,const char *t) : + BaseClassDef(ClassDef *cd,const char *n,Protection p, Specifier v,const char *t) : classDef(cd), usedName(n), prot(p), virt(v), templSpecifiers(t) {} /** Class definition that this relation inherits from. */ @@ -549,17 +546,15 @@ struct ConstraintClassDef { ConstraintClassDef(ClassDef *cd) : classDef(cd) { - accessors = new QDict(17); } ~ConstraintClassDef() { - delete accessors; } void addAccessor(const char *s) { - if (accessors->find(s)==0) + if (accessors.find(s)==accessors.end()) { - accessors->insert(s,(void *)666); + accessors.insert(s); } } /** Class definition that this relation uses. */ @@ -568,7 +563,7 @@ struct ConstraintClassDef /** Dictionary of member types names that form the edge labels of the * constraint relation. */ - QDict *accessors; + StringSet accessors; }; /** Dictionary of constraint relations. diff --git a/src/dotclassgraph.cpp b/src/dotclassgraph.cpp index 28967f4..84b7962 100644 --- a/src/dotclassgraph.cpp +++ b/src/dotclassgraph.cpp @@ -239,6 +239,25 @@ bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, // left to right order. } +static QCString joinLabels(const StringSet &ss) +{ + QCString label; + int count=1; + int maxLabels=10; + auto it = std::begin(ss), e = std::end(ss); + if (it!=e) // set not empty + { + label += (*it++).c_str(); + for (; it!=e && count < maxLabels ; ++it,++count) + { + label += '\n'; + label += (*it).c_str(); + } + if (count==maxLabels) label+="\n..."; + } + return label; +} + void DotClassGraph::buildGraph(const ClassDef *cd,DotNode *n,bool base,int distance) { //printf("DocClassGraph::buildGraph(%s,distance=%d,base=%d)\n", @@ -275,27 +294,8 @@ void DotClassGraph::buildGraph(const ClassDef *cd,DotNode *n,bool base,int dista UsesClassDef *ucd; for (;(ucd=ucdi.current());++ucdi) { - QCString label; - QDictIterator dvi(*ucd->accessors); - const char *s; - bool first=TRUE; - int count=0; - int maxLabels=10; - for (;(s=dvi.currentKey()) && countclassDef->name().data(),ucd->templSpecifiers.data()); - addClass(ucd->classDef,n,EdgeInfo::Purple,label,0, + addClass(ucd->classDef,n,EdgeInfo::Purple,joinLabels(ucd->accessors),0, ucd->templSpecifiers,base,distance); } } @@ -309,27 +309,8 @@ void DotClassGraph::buildGraph(const ClassDef *cd,DotNode *n,bool base,int dista ConstraintClassDef *ccd; for (;(ccd=ccdi.current());++ccdi) { - QCString label; - QDictIterator dvi(*ccd->accessors); - const char *s; - bool first=TRUE; - int count=0; - int maxLabels=10; - for (;(s=dvi.currentKey()) && countclassDef->name().data(),ucd->templSpecifiers.data()); - addClass(ccd->classDef,n,EdgeInfo::Orange2,label,0, + addClass(ccd->classDef,n,EdgeInfo::Orange2,joinLabels(ccd->accessors),0, 0,TRUE,distance); } } -- cgit v0.12