summaryrefslogtreecommitdiffstats
path: root/src/classdef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/classdef.h')
-rw-r--r--src/classdef.h256
1 files changed, 121 insertions, 135 deletions
diff --git a/src/classdef.h b/src/classdef.h
index 3158c50..46e1f7d 100644
--- a/src/classdef.h
+++ b/src/classdef.h
@@ -1,12 +1,12 @@
/******************************************************************************
*
- *
+ *
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -19,50 +19,84 @@
#define CLASSDEF_H
#include <vector>
+#include <set>
#include <qlist.h>
#include <qdict.h>
#include <qptrdict.h>
+#include "containers.h"
#include "definition.h"
+#include "arguments.h"
+#include "membergroup.h"
struct Argument;
class MemberDef;
+class MemberDefMutable;
class MemberList;
-class MemberDict;
-class ClassList;
-class ClassSDict;
+class MemberLists;
+class ClassLinkedRefMap;
class OutputList;
class FileDef;
class FileList;
-class BaseClassList;
class NamespaceDef;
class MemberDef;
-class ExampleSDict;
-class MemberNameInfoSDict;
+class ExampleList;
+class MemberNameInfoLinkedMap;
class UsesClassDict;
class ConstraintClassDict;
-class MemberGroupSDict;
class QTextStream;
class PackageDef;
class GroupDef;
class StringDict;
struct IncludeInfo;
class ClassDefImpl;
-class ArgumentList;
class FTextStream;
+class ClassDef;
+class ClassDefMutable;
+
+/** Class that contains information about an inheritance relation.
+ */
+struct BaseClassDef
+{
+ 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. */
+ ClassDef *classDef;
+
+ /** name used in the inheritance list
+ * (may be a typedef name instead of the class name)
+ */
+ QCString usedName;
+
+ /** Protection level of the inheritance relation:
+ * Public, Protected, or Private
+ */
+ Protection prot;
+
+ /** Virtualness of the inheritance relation:
+ * Normal, or Virtual
+ */
+ Specifier virt;
+
+ /** Template arguments used for the base class */
+ QCString templSpecifiers;
+};
+
+using BaseClassList = std::vector<BaseClassDef>;
/** A abstract class representing of a compound symbol.
*
* A compound can be a class, struct, union, interface, service, singleton,
* or exception.
*/
-class ClassDef : virtual public Definition
+class ClassDef : public Definition
{
public:
/** The various compound types */
- enum CompoundType { Class, //=Entry::CLASS_SEC,
- Struct, //=Entry::STRUCT_SEC,
+ enum CompoundType { Class, //=Entry::CLASS_SEC,
+ Struct, //=Entry::STRUCT_SEC,
Union, //=Entry::UNION_SEC,
Interface, //=Entry::INTERFACE_SEC,
Protocol, //=Entry::PROTOCOL_SEC,
@@ -74,9 +108,8 @@ class ClassDef : virtual public Definition
virtual ~ClassDef() {}
-
//-----------------------------------------------------------------------------------
- // --- getters
+ // --- getters
//-----------------------------------------------------------------------------------
/** Used for RTTI, this is a class */
@@ -99,7 +132,7 @@ class ClassDef : virtual public Definition
virtual bool isLocal() const = 0;
/** returns the classes nested into this class */
- virtual ClassSDict *getClassSDict() const = 0;
+ virtual ClassLinkedRefMap getClasses() const = 0;
/** returns TRUE if this class has documentation */
virtual bool hasDocumentation() const = 0;
@@ -125,16 +158,22 @@ class ClassDef : virtual public Definition
/** Returns the list of base classes from which this class directly
* inherits.
*/
- virtual BaseClassList *baseClasses() const = 0;
+ virtual BaseClassList baseClasses() const = 0;
+
+ /** Update the list of base classes to the one passed */
+ virtual void updateBaseClasses(const BaseClassList &bcd) = 0;
/** Returns the list of sub classes that directly derive from this class
*/
- virtual BaseClassList *subClasses() const = 0;
+ virtual BaseClassList subClasses() const = 0;
+
+ /** Update the list of sub classes to the one passed */
+ virtual void updateSubClasses(const BaseClassList &bcd) = 0;
/** Returns a dictionary of all members. This includes any inherited
* members. Members are sorted alphabetically.
*/
- virtual MemberNameInfoSDict *memberNameInfoSDict() const = 0;
+ virtual const MemberNameInfoLinkedMap &memberNameInfoLinkedMap() const = 0;
/** Return the protection level (Public,Protected,Private) in which
* this compound was found.
@@ -220,7 +259,7 @@ class ClassDef : virtual public Definition
* available, or 0 otherwise.
* @param name The name of the nested compound
*/
- virtual Definition *findInnerCompound(const char *name) const = 0;
+ virtual const Definition *findInnerCompound(const char *name) const = 0;
/** Returns the template parameter lists that form the template
* declaration of this class.
@@ -229,10 +268,10 @@ class ClassDef : virtual public Definition
* will return a list with one ArgumentList containing one argument
* with type="class" and name="T".
*/
- virtual std::vector<ArgumentList> getTemplateParameterLists() const = 0;
+ virtual ArgumentLists getTemplateParameterLists() const = 0;
virtual QCString qualifiedNameWithTemplateParameters(
- const std::vector<ArgumentList> *actualParams=0,int *actualParamIndex=0) const = 0;
+ const ArgumentLists *actualParams=0,uint *actualParamIndex=0) const = 0;
/** Returns TRUE if there is at least one pure virtual member in this
* class.
@@ -278,10 +317,10 @@ class ClassDef : virtual public Definition
virtual MemberList *getMemberList(MemberListType lt) const = 0;
/** Returns the list containing the list of members sorted per type */
- virtual const QList<MemberList> &getMemberLists() const = 0;
+ virtual const MemberLists &getMemberLists() const = 0;
/** Returns the member groups defined for this class */
- virtual MemberGroupSDict *getMemberGroupSDict() const = 0;
+ virtual const MemberGroupList &getMemberGroups() const = 0;
virtual QDict<int> *getTemplateBaseClassNames() const = 0;
@@ -294,22 +333,19 @@ class ClassDef : virtual public Definition
virtual bool isSimple() const = 0;
- virtual const ClassList *taggedInnerClasses() const = 0;
- virtual ClassDef *tagLessReference() const = 0;
+ virtual const ClassDef *tagLessReference() const = 0;
virtual MemberDef *isSmartPointer() const = 0;
virtual bool isJavaEnum() const = 0;
- virtual bool isGeneric() const = 0;
- virtual const ClassSDict *innerClasses() const = 0;
virtual QCString title() const = 0;
virtual QCString generatedFromFiles() const = 0;
virtual const FileList &usedFiles() const = 0;
virtual const ArgumentList &typeConstraints() const = 0;
- virtual const ExampleSDict *exampleList() const = 0;
+ virtual const ExampleList &getExamples() const = 0;
virtual bool hasExamples() const = 0;
virtual QCString getMemberListFileName() const = 0;
virtual bool subGrouping() const = 0;
@@ -318,6 +354,30 @@ class ClassDef : virtual public Definition
virtual bool hasNonReferenceSuperClass() const = 0;
//-----------------------------------------------------------------------------------
+ // --- count members ----
+ //-----------------------------------------------------------------------------------
+
+ virtual int countMembersIncludingGrouped(MemberListType lt,
+ const ClassDef *inheritedFrom,bool additional) const = 0;
+ virtual int countInheritanceNodes() const = 0;
+ virtual int countMemberDeclarations(MemberListType lt,const ClassDef *inheritedFrom,
+ int lt2,bool invert,bool showAlways,QPtrDict<void> *visitedClasses) const = 0;
+
+ //-----------------------------------------------------------------------------------
+ // --- helpers ----
+ //-----------------------------------------------------------------------------------
+
+ virtual ClassDef *insertTemplateInstance(const QCString &fileName,int startLine,int startColumn,
+ const QCString &templSpec,bool &freshInstance) const = 0;
+ virtual void writeDeclarationLink(OutputList &ol,bool &found,
+ const char *header,bool localNames) const = 0;
+
+};
+
+class ClassDefMutable : public DefinitionMutable, public ClassDef
+{
+ public:
+ //-----------------------------------------------------------------------------------
// --- setters ----
//-----------------------------------------------------------------------------------
@@ -337,7 +397,7 @@ class ClassDef : virtual public Definition
virtual void setTypeConstraints(const ArgumentList &al) = 0;
virtual void setCategoryOf(ClassDef *cd) = 0;
virtual void setUsedOnly(bool b) = 0;
- virtual void setTagLessReference(ClassDef *cd) = 0;
+ virtual void setTagLessReference(const ClassDef *cd) = 0;
virtual void setName(const char *name) = 0;
virtual void setMetaData(const char *md) = 0;
@@ -349,12 +409,9 @@ class ClassDef : virtual public Definition
virtual void insertSubClass(ClassDef *,Protection p,Specifier s,const char *t=0) = 0;
virtual void insertMember(MemberDef *) = 0;
virtual void insertUsedFile(FileDef *) = 0;
- virtual void addMembersToTemplateInstance(const ClassDef *cd,const char *templSpec) = 0;
- virtual void addTaggedInnerClass(ClassDef *cd) = 0;
+ virtual void addMembersToTemplateInstance(const ClassDef *cd,const ArgumentList &templateArguments,const char *templSpec) = 0;
virtual void addInnerCompound(const Definition *d) = 0;
virtual bool addExample(const char *anchor,const char *name, const char *file) = 0;
- virtual ClassDef *insertTemplateInstance(const QCString &fileName,int startLine,int startColumn,
- const QCString &templSpec,bool &freshInstance) const = 0;
virtual void addUsedClass(ClassDef *cd,const char *accessName,Protection prot) = 0;
virtual void addUsedByClass(ClassDef *cd,const char *accessName,Protection prot) = 0;
virtual void makeTemplateArgument(bool b=TRUE) = 0;
@@ -367,10 +424,11 @@ class ClassDef : virtual public Definition
virtual void mergeMembers() = 0;
virtual void sortMemberLists() = 0;
virtual void distributeMemberGroupDocumentation() = 0;
- virtual void reclassifyMember(MemberDef *md,MemberType t) = 0;
+ virtual void reclassifyMember(MemberDefMutable *md,MemberType t) = 0;
virtual void removeMemberFromLists(MemberDef *md) = 0;
virtual void setAnonymousEnumType() = 0;
virtual void countMembers() = 0;
+ virtual void sortAllMembersList() = 0;
//-----------------------------------------------------------------------------------
// --- write output ----
@@ -385,8 +443,6 @@ class ClassDef : virtual public Definition
virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *md) const = 0;
virtual void writeSummaryLinks(OutputList &ol) const = 0;
virtual void writeInlineDocumentation(OutputList &ol) const = 0;
- virtual void writeDeclarationLink(OutputList &ol,bool &found,
- const char *header,bool localNames) const = 0;
virtual void writeTagFile(FTextStream &) = 0;
virtual void writeMemberDeclarations(OutputList &ol,MemberListType lt,const QCString &title,
const char *subTitle=0,bool showInline=FALSE,const ClassDef *inheritedFrom=0,
@@ -395,27 +451,11 @@ class ClassDef : virtual public Definition
virtual void addGroupedInheritedMembers(OutputList &ol,MemberListType lt,
const ClassDef *inheritedFrom,const QCString &inheritId) const = 0;
- //-----------------------------------------------------------------------------------
- // --- count members ----
- //-----------------------------------------------------------------------------------
-
- virtual int countMembersIncludingGrouped(MemberListType lt,
- const ClassDef *inheritedFrom,bool additional) const = 0;
- virtual int countInheritanceNodes() const = 0;
- virtual int countMemberDeclarations(MemberListType lt,const ClassDef *inheritedFrom,
- int lt2,bool invert,bool showAlways,QPtrDict<void> *visitedClasses) const = 0;
-
-
- //-----------------------------------------------------------------------------------
- // --- visiting administration ----
- //-----------------------------------------------------------------------------------
- virtual void setVisited(bool visited) const = 0;
- virtual bool isVisited() const = 0;
};
/** Factory method to create a new ClassDef object */
-ClassDef *createClassDef(
+ClassDefMutable *createClassDef(
const char *fileName,int startLine,int startColumn,
const char *name,ClassDef::CompoundType ct,
const char *ref=0,const char *fName=0,
@@ -423,27 +463,35 @@ ClassDef *createClassDef(
ClassDef *createClassDefAlias(const Definition *newScope,const ClassDef *cd);
+// --- Set of classes
+
+using ClassDefSet = std::set<const ClassDef*>;
+
+// --- Cast functions
+
+ClassDef *toClassDef(Definition *d);
+ClassDef *toClassDef(DefinitionMutable *d);
+const ClassDef *toClassDef(const Definition *d);
+ClassDefMutable *toClassDefMutable(Definition *d);
+ClassDefMutable *toClassDefMutable(const Definition *d);
//------------------------------------------------------------------------
-/** Class that contains information about a usage relation.
+/** Class that contains information about a usage relation.
*/
struct UsesClassDef
{
- UsesClassDef(ClassDef *cd) : classDef(cd)
- {
- accessors = new QDict<void>(17);
- containment = TRUE;
+ UsesClassDef(ClassDef *cd) : classDef(cd)
+ {
}
~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. */
@@ -452,95 +500,35 @@ struct UsesClassDef
/** Dictionary of member variable names that form the edge labels of the
* usage relation.
*/
- QDict<void> *accessors;
+ StringSet accessors;
/** Template arguments used for the base class */
QCString templSpecifiers;
- bool containment;
+ bool containment = true;
};
-/** Dictionary of usage relations.
+/** Dictionary of usage relations.
*/
class UsesClassDict : public QDict<UsesClassDef>
{
public:
- UsesClassDict(int size) : QDict<UsesClassDef>(size) {}
+ UsesClassDict(uint size) : QDict<UsesClassDef>(size) {}
~UsesClassDict() {}
};
-/** Iterator class to iterate over a dictionary of usage relations.
+/** Iterator class to iterate over a dictionary of usage relations.
*/
class UsesClassDictIterator : public QDictIterator<UsesClassDef>
{
public:
- UsesClassDictIterator(const QDict<UsesClassDef> &d)
+ UsesClassDictIterator(const QDict<UsesClassDef> &d)
: QDictIterator<UsesClassDef>(d) {}
~UsesClassDictIterator() {}
};
//------------------------------------------------------------------------
-/** Class that contains information about an inheritance relation.
- */
-struct BaseClassDef
-{
- 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. */
- ClassDef *classDef;
-
- /** name used in the inheritance list
- * (may be a typedef name instead of the class name)
- */
- QCString usedName;
-
- /** Protection level of the inheritance relation:
- * Public, Protected, or Private
- */
- Protection prot;
-
- /** Virtualness of the inheritance relation:
- * Normal, or Virtual
- */
- Specifier virt;
-
- /** Template arguments used for the base class */
- QCString templSpecifiers;
-};
-
-/** List of base classes.
- *
- * The classes are alphabetically sorted on name if inSort() is used.
- */
-class BaseClassList : public QList<BaseClassDef>
-{
- public:
- ~BaseClassList() {}
- int compareValues(const BaseClassDef *item1,const BaseClassDef *item2) const
- {
- const ClassDef *c1=item1->classDef;
- const ClassDef *c2=item2->classDef;
- if (c1==0 || c2==0)
- return FALSE;
- else
- return qstricmp(c1->name(),c2->name());
- }
-};
-
-/** Iterator for a list of base classes.
- */
-class BaseClassListIterator : public QListIterator<BaseClassDef>
-{
- public:
- BaseClassListIterator(const BaseClassList &bcl) :
- QListIterator<BaseClassDef>(bcl) {}
-};
-
-//------------------------------------------------------------------------
-
/** Class that contains information about a type constraint relations.
*/
@@ -548,17 +536,15 @@ struct ConstraintClassDef
{
ConstraintClassDef(ClassDef *cd) : classDef(cd)
{
- accessors = new QDict<void>(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. */
@@ -567,7 +553,7 @@ struct ConstraintClassDef
/** Dictionary of member types names that form the edge labels of the
* constraint relation.
*/
- QDict<void> *accessors;
+ StringSet accessors;
};
/** Dictionary of constraint relations.
@@ -575,7 +561,7 @@ struct ConstraintClassDef
class ConstraintClassDict : public QDict<ConstraintClassDef>
{
public:
- ConstraintClassDict(int size) : QDict<ConstraintClassDef>(size) {}
+ ConstraintClassDict(uint size) : QDict<ConstraintClassDef>(size) {}
~ConstraintClassDict() {}
};