Fix for UBSan build
[platform/upstream/doxygen.git] / src / groupdef.h
1 /******************************************************************************
2  *
3  * $Id: groupdef.h,v 1.18 2001/03/19 19:27:40 root Exp $
4  *
5  * Copyright (C) 1997-2012 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby 
9  * granted. No representations are made about the suitability of this software 
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17
18 #ifndef GROUPDEF_H
19 #define GROUPDEF_H
20
21 #include "qtbc.h"
22 #include "sortdict.h"
23 #include "definition.h"
24 #include "memberlist.h"
25 #include "memberdef.h"
26 #include "htmlhelp.h"
27
28 class FileList;
29 class ClassSDict;
30 class FileDef;
31 class ClassDef;
32 class NamespaceDef;
33 class GroupList;
34 class OutputList;
35 class NamespaceSDict;
36 class MemberGroupSDict;
37 class MemberNameInfoSDict;
38 class PageSDict;
39 class PageDef;
40 class DirDef;
41 class DirList;
42 class FTVHelp;
43 class Entry;
44
45 /** A model of a group of symbols. */
46 class GroupDef : public Definition
47 {
48   public:
49     GroupDef(const char *fileName,int line,const char *name,const char *title,const char *refFileName=0);
50    ~GroupDef();
51     DefType definitionType() const { return TypeGroup; }
52     QCString getOutputFileBase() const;
53     QCString anchor() const { return QCString(); }
54     QCString displayName(bool=TRUE) const { return hasGroupTitle() ? title : Definition::name(); }
55     const char *groupTitle() const { return title; }
56     void setGroupTitle( const char *newtitle );
57     bool hasGroupTitle( ) const { return titleSet; }
58     void addFile(const FileDef *def); 
59     bool addClass(const ClassDef *def);
60     bool addNamespace(const NamespaceDef *def);
61     void addGroup(const GroupDef *def);
62     void addParentGroup(const GroupDef *def);
63     void addPage(PageDef *def);
64     void addExample(const PageDef *def);
65     void addDir(const DirDef *dd);
66     bool insertMember(MemberDef *def,bool docOnly=FALSE);
67     void removeMember(MemberDef *md);
68     bool containsGroup(const GroupDef *def);    // true if def is already a subgroup
69     void writeDocumentation(OutputList &ol);
70     void writeMemberPages(OutputList &ol);
71     void writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const;
72     int  countMembers() const;
73     bool isLinkableInProject() const;
74     bool isLinkable() const;
75     bool isASubGroup() const;
76     void computeAnchors();
77
78     void addMembersToMemberGroup();
79     void distributeMemberGroupDocumentation();
80     void findSectionsInDocumentation();
81
82     void addListReferences();
83     void sortMemberLists();
84
85     bool visited;    // number of times accessed for output - KPW
86
87     //friend void writeGroupTreeNode(OutputList&, GroupDef*, int, FTVHelp*);      
88                     // make accessible for writing tree view of group in index.cpp - KPW
89
90     void setGroupScope(Definition *d) { groupScope = d; }
91     Definition *getGroupScope() const { return groupScope; }
92
93     MemberList *getMemberList(MemberList::ListType lt) const;
94     const QList<MemberList> &getMemberLists() const { return m_memberLists; }
95
96     /* user defined member groups */
97     MemberGroupSDict *getMemberGroupSDict() const { return memberGroupSDict; }
98
99     FileList *      getFiles() const        { return fileList; }
100     ClassSDict *    getClasses() const      { return classSDict; }
101     NamespaceSDict * getNamespaces() const   { return namespaceSDict; }
102     GroupList *     getSubGroups() const    { return groupList; }
103     PageSDict *     getPages() const        { return pageDict; }
104     DirList *       getDirs() const         { return dirList; }
105     PageSDict *     getExamples() const     { return exampleDict; }
106     //MemberList*     getMembers() const      { return allMemberList; }
107     void sortSubGroups();
108     
109   protected:
110     void addMemberListToGroup(MemberList *,bool (MemberDef::*)() const);
111
112   private: 
113     MemberList *createMemberList(MemberList::ListType lt);
114     void addMemberToList(MemberList::ListType lt,MemberDef *md);
115     void writeMemberDeclarations(OutputList &ol,MemberList::ListType lt,const QCString &title);
116     void writeMemberDocumentation(OutputList &ol,MemberList::ListType lt,const QCString &title);
117     void removeMemberFromList(MemberList::ListType lt,MemberDef *md);
118     void writeGroupGraph(OutputList &ol);
119     void writeFiles(OutputList &ol,const QCString &title);
120     void writeNamespaces(OutputList &ol,const QCString &title);
121     void writeNestedGroups(OutputList &ol,const QCString &title);
122     void writeDirs(OutputList &ol,const QCString &title);
123     void writeClasses(OutputList &ol,const QCString &title);
124     void writeInlineClasses(OutputList &ol);
125     void writePageDocumentation(OutputList &ol);
126     void writeDetailedDescription(OutputList &ol,const QCString &title);
127     void writeBriefDescription(OutputList &ol);
128     void writeMemberGroups(OutputList &ol);
129     void startMemberDeclarations(OutputList &ol);
130     void endMemberDeclarations(OutputList &ol);
131     void startMemberDocumentation(OutputList &ol);
132     void endMemberDocumentation(OutputList &ol);
133     void writeAuthorSection(OutputList &ol);
134     void writeSummaryLinks(OutputList &ol);
135     void updateLanguage(const Definition *);
136
137     QCString title;                      // title of the group
138     bool titleSet;                       // true if title is not the same as the name
139     QCString fileName;                   // base name of the generated file
140     FileList *fileList;                  // list of files in the group
141     ClassSDict *classSDict;              // list of classes in the group
142     NamespaceSDict *namespaceSDict;      // list of namespaces in the group
143     GroupList *groupList;                // list of sub groups.
144     PageSDict *pageDict;                 // list of pages in the group
145     PageSDict *exampleDict;              // list of examples in the group
146     DirList *dirList;                    // list of directories in the group
147
148     MemberList *allMemberList;
149     MemberNameInfoSDict *allMemberNameInfoSDict;
150     
151     Definition *groupScope;
152
153     QList<MemberList> m_memberLists;
154     MemberGroupSDict *memberGroupSDict;
155
156 };
157
158 /** A sorted dictionary of GroupDef objects. */
159 class GroupSDict : public SDict<GroupDef>
160 {
161   public:
162     GroupSDict(uint size) : SDict<GroupDef>(size) {}
163     virtual ~GroupSDict() {}
164     int compareItems(GCI item1,GCI item2)
165     {
166       return strcmp(((GroupDef*)item1)->groupTitle(),((GroupDef*)item2)->groupTitle());
167     }
168 };
169
170 /** A list of GroupDef objects. */
171 class GroupList : public QList<GroupDef>
172 {
173   public:
174     int compareItems(GCI item1,GCI item2)
175     {
176       return strcmp(((GroupDef*)item1)->groupTitle(),((GroupDef*)item2)->groupTitle());
177     }
178 };
179
180 /** An iterator for GroupDef objects in a GroupList. */
181 class GroupListIterator : public QListIterator<GroupDef>
182 {
183   public:
184     GroupListIterator(const GroupList &l) : QListIterator<GroupDef>(l) {}
185     virtual ~GroupListIterator() {}
186 };
187
188 void addClassToGroups(Entry *root,ClassDef *cd);
189 void addNamespaceToGroups(Entry *root,NamespaceDef *nd);
190 void addGroupToGroups(Entry *root,GroupDef *subGroup);
191 void addMemberToGroups(Entry *root,MemberDef *md);
192 void addPageToGroups(Entry *root,PageDef *pd);
193 void addExampleToGroups(Entry *root,PageDef *eg);
194 void addDirToGroups(Entry *root,DirDef *dd);
195
196 #endif
197