Fix for UBSan build
[platform/upstream/doxygen.git] / src / memberdef.h
1 /******************************************************************************
2  *
3  * 
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 MEMBERDEF_H
19 #define MEMBERDEF_H
20
21 #include "qtbc.h"
22 #include <qlist.h>
23 #include <qdict.h>
24 #include <qstack.h>
25
26 #include "types.h"
27 #include "definition.h"
28 #include "sortdict.h"
29
30 class ClassDef;
31 class NamespaceDef;
32 class GroupDef;
33 class FileDef;
34 class MemberList;
35 class MemberGroup;
36 class ExampleSDict;
37 class OutputList;
38 class GroupDef;
39 class QTextStream;
40 class ArgumentList;
41 class MemberDefImpl;
42
43 /** A model of a class/file/namespace member symbol. */
44 class MemberDef : public Definition
45 {
46   public:
47     
48     enum MemberType { 
49       Define,
50       Function, 
51       Variable, 
52       Typedef, 
53       Enumeration, 
54       EnumValue,
55       Signal,
56       Slot,
57       Friend,
58       DCOP,
59       Property,
60       Event
61     };
62
63     MemberDef(const char *defFileName,int defLine,
64               const char *type,const char *name,const char *args,
65               const char *excp,Protection prot,Specifier virt,bool stat,
66               Relationship related,MemberType t,const ArgumentList *tal,
67               const ArgumentList *al);
68    ~MemberDef(); 
69     DefType definitionType() const        { return TypeMember; }
70     // move this member into a different scope
71     MemberDef *deepCopy() const;
72     void moveTo(Definition *);
73     
74     //-----------------------------------------------------------------------------------
75     // ----  getters -----
76     //-----------------------------------------------------------------------------------
77
78     // link id
79     QCString getOutputFileBase() const;
80     QCString getReference() const;
81     QCString anchor() const;
82
83     const char *declaration() const;
84     const char *definition() const;
85     const char *typeString() const;
86     const char *argsString() const;
87     const char *excpString() const;
88     const char *bitfieldString() const;
89     const char *extraTypeChars() const;
90     const QCString &initializer() const;
91     int initializerLines() const;
92     int  getMemberSpecifiers() const;
93     MemberList *getSectionList(Definition *d) const;
94
95     // scope query members
96     ClassDef *getClassDef() const;
97     FileDef  *getFileDef() const;
98     NamespaceDef* getNamespaceDef() const;
99
100     // grabbing the property read/write accessor names
101     const char *getReadAccessor() const;
102     const char *getWriteAccessor() const;
103     
104     // querying the grouping definition
105     GroupDef *getGroupDef() const;
106     Grouping::GroupPri_t getGroupPri() const;
107     const char *getGroupFileName() const;
108     int getGroupStartLine() const;
109     bool getGroupHasDocs() const;
110     QCString qualifiedName() const;
111     QCString objCMethodName(bool localLink,bool showStatic) const; 
112
113     // direct kind info 
114     Protection protection() const;
115     Specifier virtualness(int count=0) const;
116     MemberType memberType() const;
117     QCString   memberTypeName() const;
118
119     // getter methods
120     bool isSignal() const;
121     bool isSlot() const;
122     bool isVariable() const;
123     bool isEnumerate() const;
124     bool isEnumValue() const;
125     bool isTypedef() const;
126     bool isFunction() const;
127     bool isFunctionPtr() const;
128     bool isDefine() const;
129     bool isFriend() const;
130     bool isDCOP() const;
131     bool isProperty() const;
132     bool isEvent() const;
133     bool isRelated() const;
134     bool isForeign() const;
135     bool isStatic() const;
136     bool isInline() const;
137     bool isExplicit() const;
138     bool isMutable() const;
139     bool isGettable() const;
140     bool isSettable() const;
141     bool isReadable() const;
142     bool isWritable() const;
143     bool isAddable() const;
144     bool isRemovable() const;
145     bool isRaisable() const;
146     bool isFinal() const;
147     bool isAbstract() const;
148     bool isOverride() const;
149     bool isInitonly() const;
150     bool isOptional() const;
151     bool isRequired() const;
152     bool isNonAtomic() const;
153     bool isCopy() const;
154     bool isAssign() const;
155     bool isRetain() const;
156     bool isWeak() const;
157     bool isStrong() const;
158     bool isUnretained() const;
159     bool isNew() const;
160     bool isSealed() const;
161     bool isImplementation() const;
162     bool isExternal() const;
163     bool isAlias() const;
164     bool isDefault() const;
165     bool isDelete() const;
166     bool isNoExcept() const;
167     bool isTemplateSpecialization() const;
168     bool hasDocumentedParams() const;
169     bool hasDocumentedReturnType() const;
170     bool isObjCMethod() const;
171     bool isObjCProperty() const;
172     bool isConstructor() const;
173     bool isDestructor() const;
174     bool hasOneLineInitializer() const;
175     bool hasMultiLineInitializer() const;
176     bool protectionVisible() const;
177
178     // output info
179     bool isLinkableInProject() const;
180     bool isLinkable() const;
181     bool hasDocumentation() const;  // overrides hasDocumentation in definition.h
182     //bool hasUserDocumentation() const; // overrides hasUserDocumentation
183     bool isBriefSectionVisible() const;
184     bool isDetailedSectionVisible(bool inGroup,bool inFile) const;
185     bool isDetailedSectionLinkable() const;
186     bool isFriendClass() const;
187     bool isDocumentedFriendClass() const;
188
189     MemberDef *reimplements() const;
190     LockingPtr< MemberList > reimplementedBy() const;
191     bool isReimplementedBy(ClassDef *cd) const;
192
193     //int inbodyLine() const;
194     //QCString inbodyFile() const;
195     //const QCString &inbodyDocumentation() const;
196
197     ClassDef *relatedAlso() const;
198
199     bool hasDocumentedEnumValues() const;
200     MemberDef *getAnonymousEnumType() const;
201     bool isDocsForDefinition() const;
202     MemberDef *getEnumScope() const;
203     LockingPtr< MemberList > enumFieldList() const;
204     void setEnumBaseType(const QCString &type);
205     QCString enumBaseType() const;
206
207     bool hasExamples();
208     LockingPtr<ExampleSDict> getExamples() const;
209     bool isPrototype() const;
210
211     // argument related members
212     LockingPtr<ArgumentList> argumentList() const;
213     LockingPtr<ArgumentList> declArgumentList() const;
214     LockingPtr<ArgumentList> templateArguments() const;
215     LockingPtr< QList<ArgumentList> > definitionTemplateParameterLists() const;
216
217     // member group related members
218     int getMemberGroupId() const;
219     MemberGroup *getMemberGroup() const;
220
221     bool fromAnonymousScope() const;
222     bool anonymousDeclShown() const;
223
224     // callgraph related members
225     bool hasCallGraph() const;
226     bool hasCallerGraph() const;
227     bool visibleMemberGroup(bool hideNoHeader);
228
229     MemberDef *templateMaster() const;
230     QCString getScopeString() const;
231     ClassDef *getClassDefOfAnonymousType();
232
233     // cached typedef functions
234     bool isTypedefValCached() const;
235     ClassDef *getCachedTypedefVal() const;
236     QCString getCachedTypedefTemplSpec() const;
237     QCString getCachedResolvedTypedef() const;
238
239     MemberDef *memberDefinition() const;
240     MemberDef *memberDeclaration() const;
241     MemberDef *inheritsDocsFrom() const;
242     MemberDef *getGroupAlias() const;
243
244     ClassDef *category() const;
245     MemberDef *categoryRelation() const;
246
247     QCString displayName(bool=TRUE) const;
248
249     //-----------------------------------------------------------------------------------
250     // ----  setters -----
251     //-----------------------------------------------------------------------------------
252
253     // set functions
254     void setMemberType(MemberType t);
255     void setDefinition(const char *d);
256     void setFileDef(FileDef *fd);
257     void setAnchor(const char *a);
258     void setProtection(Protection p);
259     void setMemberSpecifiers(int s);
260     void mergeMemberSpecifiers(int s);
261     void setInitializer(const char *i);
262     void setBitfields(const char *s);
263     void setMaxInitLines(int lines);
264     void setMemberClass(ClassDef *cd);
265     void setSectionList(Definition *d,MemberList *sl);
266     void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
267                      const QCString &fileName,int startLine,bool hasDocs,
268                      MemberDef *member=0);
269     void setExplicitExternal(bool b);
270     void setReadAccessor(const char *r);
271     void setWriteAccessor(const char *w);
272     void setTemplateSpecialization(bool b);
273     
274     void makeRelated();
275     void makeForeign();
276     void setHasDocumentedParams(bool b);
277     void setHasDocumentedReturnType(bool b);
278     void setInheritsDocsFrom(MemberDef *md);
279     void setTagInfo(TagInfo *i);
280     void setArgsString(const char *as);
281
282     // relation to other members
283     void setReimplements(MemberDef *md);
284     void insertReimplementedBy(MemberDef *md);
285
286     // in-body documentation
287     //void setInbodyDocumentation(const char *docs,const char *file,int line);
288
289     void setRelatedAlso(ClassDef *cd);
290
291     // enumeration specific members
292     void insertEnumField(MemberDef *md);
293     void setEnumScope(MemberDef *md);
294     void setEnumClassScope(ClassDef *cd);
295     void setDocumentedEnumValues(bool value);
296     void setAnonymousEnumType(MemberDef *md);
297
298     // example related members
299     bool addExample(const char *anchor,const char *name,const char *file);
300     
301     // prototype related members
302     void setPrototype(bool p);
303
304     // argument related members
305     void setArgumentList(ArgumentList *al);
306     void setDeclArgumentList(ArgumentList *al);
307     void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists);
308     void setTypeConstraints(ArgumentList *al);
309     void setType(const char *t);
310     void setAccessorType(ClassDef *cd,const char *t);
311
312     // namespace related members
313     void setNamespace(NamespaceDef *nd);
314
315     // member group related members
316     void setMemberGroup(MemberGroup *grp);
317     void setMemberGroupId(int id);
318     void makeImplementationDetail();
319
320     // anonymous scope members
321     void setFromAnonymousScope(bool b);
322     void setFromAnonymousMember(MemberDef *m);
323
324     void enableCallGraph(bool e);
325     void enableCallerGraph(bool e);
326
327     void setTemplateMaster(MemberDef *mt);
328     void addListReference(Definition *d);
329     void setDocsForDefinition(bool b);
330     void setGroupAlias(MemberDef *md);
331
332     void cacheTypedefVal(ClassDef *val,const QCString &templSpec,const QCString &resolvedType);
333     void invalidateTypedefValCache();
334
335     void invalidateCachedArgumentTypes();
336     
337     // declaration <-> definition relation
338     void setMemberDefinition(MemberDef *md);
339     void setMemberDeclaration(MemberDef *md);
340         
341     void setAnonymousUsed();
342     void copyArgumentNames(MemberDef *bmd);
343
344     void setCategory(ClassDef *);
345     void setCategoryRelation(MemberDef *);
346
347     void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
348     void setBriefDescription(const char *b,const char *briefFile,int briefLine);
349     void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine);
350
351     void setHidden(bool b);
352
353     //-----------------------------------------------------------------------------------
354     // --- actions ----
355     //-----------------------------------------------------------------------------------
356
357     // output generation
358     void writeDeclaration(OutputList &ol,
359                    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
360                    bool inGroup,ClassDef *inheritFrom=0,const char *inheritId=0); 
361     void writeDocumentation(MemberList *ml,OutputList &ol,
362                             const char *scopeName,Definition *container,
363                             bool inGroup,bool showEnumValues=FALSE,bool
364                             showInline=FALSE);
365     void writeMemberDocSimple(OutputList &ol,Definition *container);
366     void warnIfUndocumented();
367     
368     MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs,
369                ArgumentList *actualArgs);
370
371     void writeEnumDeclaration(OutputList &typeDecl,
372             ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd);
373
374     void findSectionsInDocumentation();
375     
376     bool visited;
377    
378   protected:
379     void flushToDisk() const;
380     void loadFromDisk() const;
381   private:
382     void lock() const;
383     void unlock() const;
384     void saveToDisk() const;
385     void makeResident() const;
386     void _computeLinkableInProject();
387     void _computeIsConstructor();
388     void _computeIsDestructor();
389     void _getLabels(QStrList &sl,Definition *container) const;
390     void _writeCallGraph(OutputList &ol);
391     void _writeCallerGraph(OutputList &ol);
392     void _writeReimplements(OutputList &ol);
393     void _writeReimplementedBy(OutputList &ol);
394     void _writeExamples(OutputList &ol);
395     void _writeTypeConstraints(OutputList &ol);
396     void _writeEnumValues(OutputList &ol,Definition *container,
397                           const QCString &cfname,const QCString &ciname,
398                           const QCString &cname);
399     void _writeCategoryRelation(OutputList &ol);
400
401     static int s_indentLevel;
402     // disable copying of member defs
403     MemberDef(const MemberDef &);
404     MemberDef &operator=(const MemberDef &);
405
406     void writeLink(OutputList &ol,
407                    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
408                    bool onlyText=FALSE);
409
410     MemberDefImpl *m_impl;
411     int m_cacheHandle;
412     off_t m_storagePos;     // location where the item is stored in file (if impl==0)
413     bool m_flushPending;
414     uchar m_isLinkableCached;    // 0 = not cached, 1=FALSE, 2=TRUE
415     uchar m_isConstructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
416     uchar m_isDestructorCached;  // 0 = not cached, 1=FALSE, 2=TRUE
417 };
418
419 void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef);
420
421 #endif