1 /******************************************************************************
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
22 #include <sys/types.h>
25 #include "definition.h"
42 /** A model of a class/file/namespace member symbol. */
43 class MemberDef : public Definition
47 MemberDef(const char *defFileName,int defLine,int defColumn,
48 const char *type,const char *name,const char *args,
49 const char *excp,Protection prot,Specifier virt,bool stat,
50 Relationship related,MemberType t,const ArgumentList *tal,
51 const ArgumentList *al,const char *metaData);
53 DefType definitionType() const { return TypeMember; }
54 // move this member into a different scope
55 MemberDef *deepCopy() const;
56 void moveTo(Definition *);
58 //-----------------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------------
63 QCString getOutputFileBase() const;
64 QCString getReference() const;
65 QCString anchor() const;
67 const char *declaration() const;
68 const char *definition() const;
69 const char *typeString() const;
70 const char *argsString() const;
71 const char *excpString() const;
72 const char *bitfieldString() const;
73 const char *extraTypeChars() const;
74 const QCString &initializer() const;
75 int initializerLines() const;
76 uint64 getMemberSpecifiers() const;
77 MemberList *getSectionList(Definition *d) const;
78 QCString displayDefinition() const;
80 // scope query members
81 ClassDef *getClassDef() const;
82 FileDef *getFileDef() const;
83 NamespaceDef* getNamespaceDef() const;
84 ClassDef *accessorClass() const;
86 // grabbing the property read/write accessor names
87 const char *getReadAccessor() const;
88 const char *getWriteAccessor() const;
90 // querying the grouping definition
91 GroupDef *getGroupDef() const;
92 Grouping::GroupPri_t getGroupPri() const;
93 const char *getGroupFileName() const;
94 int getGroupStartLine() const;
95 bool getGroupHasDocs() const;
96 QCString qualifiedName() const;
97 QCString objCMethodName(bool localLink,bool showStatic) const;
100 Protection protection() const;
101 Specifier virtualness(int count=0) const;
102 MemberType memberType() const;
103 QCString memberTypeName() const;
106 bool isSignal() const;
108 bool isVariable() const;
109 bool isEnumerate() const;
110 bool isEnumValue() const;
111 bool isTypedef() const;
112 bool isSequence() const;
113 bool isDictionary() const;
114 bool isFunction() const;
115 bool isFunctionPtr() const;
116 bool isDefine() const;
117 bool isFriend() const;
119 bool isProperty() const;
120 bool isEvent() const;
121 bool isRelated() const;
122 bool isForeign() const;
123 bool isStatic() const;
124 bool isInline() const;
125 bool isExplicit() const;
126 bool isMutable() const;
127 bool isGettable() const;
128 bool isPrivateGettable() const;
129 bool isProtectedGettable() const;
130 bool isSettable() const;
131 bool isPrivateSettable() const;
132 bool isProtectedSettable() const;
133 bool isReadable() const;
134 bool isWritable() const;
135 bool isAddable() const;
136 bool isRemovable() const;
137 bool isRaisable() const;
138 bool isFinal() const;
139 bool isAbstract() const;
140 bool isOverride() const;
141 bool isInitonly() const;
142 bool isOptional() const;
143 bool isRequired() const;
144 bool isNonAtomic() const;
146 bool isAssign() const;
147 bool isRetain() const;
149 bool isStrong() const;
150 bool isUnretained() const;
152 bool isSealed() const;
153 bool isImplementation() const;
154 bool isExternal() const;
155 bool isAlias() const;
156 bool isDefault() const;
157 bool isDelete() const;
158 bool isNoExcept() const;
159 bool isAttribute() const; // UNO IDL attribute
160 bool isUNOProperty() const; // UNO IDL property
161 bool isReadonly() const;
162 bool isBound() const;
163 bool isConstrained() const;
164 bool isTransient() const;
165 bool isMaybeVoid() const;
166 bool isMaybeDefault() const;
167 bool isMaybeAmbiguous() const;
168 bool isPublished() const; // UNO IDL published
169 bool isTemplateSpecialization() const;
170 bool hasDocumentedParams() const;
171 bool hasDocumentedReturnType() const;
172 bool isObjCMethod() const;
173 bool isObjCProperty() const;
174 bool isConstructor() const;
175 bool isDestructor() const;
176 bool hasOneLineInitializer() const;
177 bool hasMultiLineInitializer() const;
178 bool protectionVisible() const;
179 bool showInCallGraph() const;
180 bool isStrongEnumValue() const;
181 bool livesInsideEnum() const;
182 bool isSliceLocal() const;
184 int numberOfFlowKeyWords();
186 bool isFriendToHide() const;
187 bool isNotFriend() const;
188 bool isFunctionOrSignalSlot() const;
189 bool isRelatedOrFriend() const;
192 bool isLinkableInProject() const;
193 bool isLinkable() const;
194 bool hasDocumentation() const; // overrides hasDocumentation in definition.h
195 //bool hasUserDocumentation() const; // overrides hasUserDocumentation
196 bool isDeleted() const;
197 bool isBriefSectionVisible() const;
198 bool isDetailedSectionVisible(bool inGroup,bool inFile) const;
199 bool isDetailedSectionLinkable() const;
200 bool isFriendClass() const;
201 bool isDocumentedFriendClass() const;
203 MemberDef *reimplements() const;
204 MemberList *reimplementedBy() const;
205 bool isReimplementedBy(ClassDef *cd) const;
207 //int inbodyLine() const;
208 //QCString inbodyFile() const;
209 //const QCString &inbodyDocumentation() const;
211 ClassDef *relatedAlso() const;
213 bool hasDocumentedEnumValues() const;
214 MemberDef *getAnonymousEnumType() const;
215 bool isDocsForDefinition() const;
216 MemberDef *getEnumScope() const;
217 MemberList *enumFieldList() const;
218 void setEnumBaseType(const QCString &type);
219 QCString enumBaseType() const;
222 ExampleSDict *getExamples() const;
223 bool isPrototype() const;
225 // argument related members
226 ArgumentList *argumentList() const;
227 ArgumentList *declArgumentList() const;
228 ArgumentList *templateArguments() const;
229 QList<ArgumentList> *definitionTemplateParameterLists() const;
231 // member group related members
232 int getMemberGroupId() const;
233 MemberGroup *getMemberGroup() const;
235 bool fromAnonymousScope() const;
236 bool anonymousDeclShown() const;
237 MemberDef *fromAnonymousMember() const;
239 // callgraph related members
240 bool hasCallGraph() const;
241 bool hasCallerGraph() const;
242 bool visibleMemberGroup(bool hideNoHeader);
243 // refrenced related members
244 bool hasReferencesRelation() const;
245 bool hasReferencedByRelation() const;
247 MemberDef *templateMaster() const;
248 QCString getScopeString() const;
249 ClassDef *getClassDefOfAnonymousType();
251 // cached typedef functions
252 bool isTypedefValCached() const;
253 ClassDef *getCachedTypedefVal() const;
254 QCString getCachedTypedefTemplSpec() const;
255 QCString getCachedResolvedTypedef() const;
257 MemberDef *memberDefinition() const;
258 MemberDef *memberDeclaration() const;
259 MemberDef *inheritsDocsFrom() const;
260 MemberDef *getGroupAlias() const;
262 ClassDef *category() const;
263 MemberDef *categoryRelation() const;
265 QCString displayName(bool=TRUE) const;
266 QCString getDeclType() const;
267 void getLabels(QStrList &sl,Definition *container) const;
269 const ArgumentList *typeConstraints() const;
272 QCString documentation() const;
273 QCString briefDescription(bool abbr=FALSE) const;
274 QCString fieldType() const;
275 bool isReference() const;
278 //-----------------------------------------------------------------------------------
279 // ---- setters -----
280 //-----------------------------------------------------------------------------------
282 void addFlowKeyWord();
285 void setMemberType(MemberType t);
286 void setDefinition(const char *d);
287 void setFileDef(FileDef *fd);
289 void setProtection(Protection p);
290 void setMemberSpecifiers(uint64 s);
291 void mergeMemberSpecifiers(uint64 s);
292 void setInitializer(const char *i);
293 void setBitfields(const char *s);
294 void setMaxInitLines(int lines);
295 void setMemberClass(ClassDef *cd);
296 void setSectionList(Definition *d,MemberList *sl);
297 void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
298 const QCString &fileName,int startLine,bool hasDocs,
299 MemberDef *member=0);
300 void setExplicitExternal(bool b);
301 void setReadAccessor(const char *r);
302 void setWriteAccessor(const char *w);
303 void setTemplateSpecialization(bool b);
307 void setHasDocumentedParams(bool b);
308 void setHasDocumentedReturnType(bool b);
309 void setInheritsDocsFrom(MemberDef *md);
310 void setTagInfo(TagInfo *i);
311 void setArgsString(const char *as);
313 // relation to other members
314 void setReimplements(MemberDef *md);
315 void insertReimplementedBy(MemberDef *md);
317 // in-body documentation
318 //void setInbodyDocumentation(const char *docs,const char *file,int line);
320 void setRelatedAlso(ClassDef *cd);
322 // enumeration specific members
323 void insertEnumField(MemberDef *md);
324 void setEnumScope(MemberDef *md,bool livesInsideEnum=FALSE);
325 void setEnumClassScope(ClassDef *cd);
326 void setDocumentedEnumValues(bool value);
327 void setAnonymousEnumType(MemberDef *md);
329 // example related members
330 bool addExample(const char *anchor,const char *name,const char *file);
332 // prototype related members
333 void setPrototype(bool p);
335 // argument related members
336 void setArgumentList(ArgumentList *al);
337 void setDeclArgumentList(ArgumentList *al);
338 void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists);
339 void setTypeConstraints(ArgumentList *al);
340 void setType(const char *t);
341 void setAccessorType(ClassDef *cd,const char *t);
343 // namespace related members
344 void setNamespace(NamespaceDef *nd);
346 // member group related members
347 void setMemberGroup(MemberGroup *grp);
348 void setMemberGroupId(int id);
349 void makeImplementationDetail();
351 // anonymous scope members
352 void setFromAnonymousScope(bool b);
353 void setFromAnonymousMember(MemberDef *m);
355 void enableCallGraph(bool e);
356 void enableCallerGraph(bool e);
358 void enableReferencedByRelation(bool e);
359 void enableReferencesRelation(bool e);
361 void setTemplateMaster(MemberDef *mt);
362 void addListReference(Definition *d);
363 void setDocsForDefinition(bool b);
364 void setGroupAlias(MemberDef *md);
366 void cacheTypedefVal(ClassDef *val,const QCString &templSpec,const QCString &resolvedType);
367 void invalidateTypedefValCache();
369 void invalidateCachedArgumentTypes();
371 // declaration <-> definition relation
372 void setMemberDefinition(MemberDef *md);
373 void setMemberDeclaration(MemberDef *md);
375 void setAnonymousUsed();
376 void copyArgumentNames(MemberDef *bmd);
378 void setCategory(ClassDef *);
379 void setCategoryRelation(MemberDef *);
381 void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
382 void setBriefDescription(const char *b,const char *briefFile,int briefLine);
383 void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine);
385 void setHidden(bool b);
387 //-----------------------------------------------------------------------------------
389 //-----------------------------------------------------------------------------------
392 void writeDeclaration(OutputList &ol,
393 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
394 bool inGroup, ClassDef *inheritFrom=0,const char *inheritId=0);
395 void writeDocumentation(MemberList *ml,int memCount,int memTotal,OutputList &ol,
396 const char *scopeName,Definition *container,
397 bool inGroup,bool showEnumValues=FALSE,bool
399 void writeMemberDocSimple(OutputList &ol,Definition *container);
400 void writeEnumDeclaration(OutputList &typeDecl,
401 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd);
402 void writeTagFile(FTextStream &);
403 void warnIfUndocumented();
404 void warnIfUndocumentedParams();
406 MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs,
407 ArgumentList *actualArgs);
409 void findSectionsInDocumentation();
414 void flushToDisk() const;
415 void loadFromDisk() const;
419 void saveToDisk() const;
420 void makeResident() const;
421 void _computeLinkableInProject();
422 void _computeIsConstructor();
423 void _computeIsDestructor();
424 void _writeGroupInclude(OutputList &ol,bool inGroup);
425 void _writeCallGraph(OutputList &ol);
426 void _writeCallerGraph(OutputList &ol);
427 void _writeReimplements(OutputList &ol);
428 void _writeReimplementedBy(OutputList &ol);
429 void _writeExamples(OutputList &ol);
430 void _writeTypeConstraints(OutputList &ol);
431 void _writeEnumValues(OutputList &ol,Definition *container,
432 const QCString &cfname,const QCString &ciname,
433 const QCString &cname);
434 void _writeCategoryRelation(OutputList &ol);
435 void _writeTagData(const DefType);
436 void _addToSearchIndex();
438 static int s_indentLevel;
440 int number_of_flowkw;
442 // disable copying of member defs
443 MemberDef(const MemberDef &);
444 MemberDef &operator=(const MemberDef &);
446 void writeLink(OutputList &ol,
447 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
448 bool onlyText=FALSE);
450 MemberDefImpl *m_impl;
451 uchar m_isLinkableCached; // 0 = not cached, 1=FALSE, 2=TRUE
452 uchar m_isConstructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
453 uchar m_isDestructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
456 void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef);