1 /******************************************************************************
5 * Copyright (C) 1997-2014 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);
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 isFunction() const;
113 bool isFunctionPtr() const;
114 bool isDefine() const;
115 bool isFriend() const;
117 bool isProperty() const;
118 bool isEvent() const;
119 bool isRelated() const;
120 bool isForeign() const;
121 bool isStatic() const;
122 bool isInline() const;
123 bool isExplicit() const;
124 bool isMutable() const;
125 bool isGettable() const;
126 bool isSettable() const;
127 bool isReadable() const;
128 bool isWritable() const;
129 bool isAddable() const;
130 bool isRemovable() const;
131 bool isRaisable() const;
132 bool isFinal() const;
133 bool isAbstract() const;
134 bool isOverride() const;
135 bool isInitonly() const;
136 bool isOptional() const;
137 bool isRequired() const;
138 bool isNonAtomic() const;
140 bool isAssign() const;
141 bool isRetain() const;
143 bool isStrong() const;
144 bool isUnretained() const;
146 bool isSealed() const;
147 bool isImplementation() const;
148 bool isExternal() const;
149 bool isAlias() const;
150 bool isDefault() const;
151 bool isDelete() const;
152 bool isNoExcept() const;
153 bool isAttribute() const; // UNO IDL attribute
154 bool isUNOProperty() const; // UNO IDL property
155 bool isReadonly() const;
156 bool isBound() const;
157 bool isConstrained() const;
158 bool isTransient() const;
159 bool isMaybeVoid() const;
160 bool isMaybeDefault() const;
161 bool isMaybeAmbiguous() const;
162 bool isPublished() const; // UNO IDL published
163 bool isTemplateSpecialization() const;
164 bool hasDocumentedParams() const;
165 bool hasDocumentedReturnType() const;
166 bool isObjCMethod() const;
167 bool isObjCProperty() const;
168 bool isConstructor() const;
169 bool isDestructor() const;
170 bool hasOneLineInitializer() const;
171 bool hasMultiLineInitializer() const;
172 bool protectionVisible() const;
173 bool showInCallGraph() const;
174 bool isStrongEnumValue() const;
177 bool isLinkableInProject() const;
178 bool isLinkable() const;
179 bool hasDocumentation() const; // overrides hasDocumentation in definition.h
180 //bool hasUserDocumentation() const; // overrides hasUserDocumentation
181 bool isBriefSectionVisible() const;
182 bool isDetailedSectionVisible(bool inGroup,bool inFile) const;
183 bool isDetailedSectionLinkable() const;
184 bool isFriendClass() const;
185 bool isDocumentedFriendClass() const;
187 MemberDef *reimplements() const;
188 MemberList *reimplementedBy() const;
189 bool isReimplementedBy(ClassDef *cd) const;
191 //int inbodyLine() const;
192 //QCString inbodyFile() const;
193 //const QCString &inbodyDocumentation() const;
195 ClassDef *relatedAlso() const;
197 bool hasDocumentedEnumValues() const;
198 MemberDef *getAnonymousEnumType() const;
199 bool isDocsForDefinition() const;
200 MemberDef *getEnumScope() const;
201 MemberList *enumFieldList() const;
202 void setEnumBaseType(const QCString &type);
203 QCString enumBaseType() const;
206 ExampleSDict *getExamples() const;
207 bool isPrototype() const;
209 // argument related members
210 ArgumentList *argumentList() const;
211 ArgumentList *declArgumentList() const;
212 ArgumentList *templateArguments() const;
213 QList<ArgumentList> *definitionTemplateParameterLists() const;
215 // member group related members
216 int getMemberGroupId() const;
217 MemberGroup *getMemberGroup() const;
219 bool fromAnonymousScope() const;
220 bool anonymousDeclShown() const;
221 MemberDef *fromAnonymousMember() const;
223 // callgraph related members
224 bool hasCallGraph() const;
225 bool hasCallerGraph() const;
226 bool visibleMemberGroup(bool hideNoHeader);
228 MemberDef *templateMaster() const;
229 QCString getScopeString() const;
230 ClassDef *getClassDefOfAnonymousType();
232 // cached typedef functions
233 bool isTypedefValCached() const;
234 ClassDef *getCachedTypedefVal() const;
235 QCString getCachedTypedefTemplSpec() const;
236 QCString getCachedResolvedTypedef() const;
238 MemberDef *memberDefinition() const;
239 MemberDef *memberDeclaration() const;
240 MemberDef *inheritsDocsFrom() const;
241 MemberDef *getGroupAlias() const;
243 ClassDef *category() const;
244 MemberDef *categoryRelation() const;
246 QCString displayName(bool=TRUE) const;
247 QCString getDeclType() const;
248 void getLabels(QStrList &sl,Definition *container) const;
250 const ArgumentList *typeConstraints() const;
253 QCString documentation() const;
254 QCString briefDescription(bool abbr=FALSE) const;
255 QCString fieldType() const;
258 //-----------------------------------------------------------------------------------
259 // ---- setters -----
260 //-----------------------------------------------------------------------------------
263 void setMemberType(MemberType t);
264 void setDefinition(const char *d);
265 void setFileDef(FileDef *fd);
267 void setProtection(Protection p);
268 void setMemberSpecifiers(uint64 s);
269 void mergeMemberSpecifiers(uint64 s);
270 void setInitializer(const char *i);
271 void setBitfields(const char *s);
272 void setMaxInitLines(int lines);
273 void setMemberClass(ClassDef *cd);
274 void setSectionList(Definition *d,MemberList *sl);
275 void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
276 const QCString &fileName,int startLine,bool hasDocs,
277 MemberDef *member=0);
278 void setExplicitExternal(bool b);
279 void setReadAccessor(const char *r);
280 void setWriteAccessor(const char *w);
281 void setTemplateSpecialization(bool b);
285 void setHasDocumentedParams(bool b);
286 void setHasDocumentedReturnType(bool b);
287 void setInheritsDocsFrom(MemberDef *md);
288 void setTagInfo(TagInfo *i);
289 void setArgsString(const char *as);
291 // relation to other members
292 void setReimplements(MemberDef *md);
293 void insertReimplementedBy(MemberDef *md);
295 // in-body documentation
296 //void setInbodyDocumentation(const char *docs,const char *file,int line);
298 void setRelatedAlso(ClassDef *cd);
300 // enumeration specific members
301 void insertEnumField(MemberDef *md);
302 void setEnumScope(MemberDef *md,bool livesInsideEnum=FALSE);
303 void setEnumClassScope(ClassDef *cd);
304 void setDocumentedEnumValues(bool value);
305 void setAnonymousEnumType(MemberDef *md);
307 // example related members
308 bool addExample(const char *anchor,const char *name,const char *file);
310 // prototype related members
311 void setPrototype(bool p);
313 // argument related members
314 void setArgumentList(ArgumentList *al);
315 void setDeclArgumentList(ArgumentList *al);
316 void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists);
317 void setTypeConstraints(ArgumentList *al);
318 void setType(const char *t);
319 void setAccessorType(ClassDef *cd,const char *t);
321 // namespace related members
322 void setNamespace(NamespaceDef *nd);
324 // member group related members
325 void setMemberGroup(MemberGroup *grp);
326 void setMemberGroupId(int id);
327 void makeImplementationDetail();
329 // anonymous scope members
330 void setFromAnonymousScope(bool b);
331 void setFromAnonymousMember(MemberDef *m);
333 void enableCallGraph(bool e);
334 void enableCallerGraph(bool e);
336 void setTemplateMaster(MemberDef *mt);
337 void addListReference(Definition *d);
338 void setDocsForDefinition(bool b);
339 void setGroupAlias(MemberDef *md);
341 void cacheTypedefVal(ClassDef *val,const QCString &templSpec,const QCString &resolvedType);
342 void invalidateTypedefValCache();
344 void invalidateCachedArgumentTypes();
346 // declaration <-> definition relation
347 void setMemberDefinition(MemberDef *md);
348 void setMemberDeclaration(MemberDef *md);
350 void setAnonymousUsed();
351 void copyArgumentNames(MemberDef *bmd);
353 void setCategory(ClassDef *);
354 void setCategoryRelation(MemberDef *);
356 void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
357 void setBriefDescription(const char *b,const char *briefFile,int briefLine);
358 void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine);
360 void setHidden(bool b);
362 //-----------------------------------------------------------------------------------
364 //-----------------------------------------------------------------------------------
367 void writeDeclaration(OutputList &ol,
368 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
369 bool inGroup, const DefType compoundType,
370 ClassDef *inheritFrom=0,const char *inheritId=0);
371 void writeDocumentation(MemberList *ml,OutputList &ol,
372 const char *scopeName,Definition *container,
373 bool inGroup,bool showEnumValues=FALSE,bool
375 void writeMemberDocSimple(OutputList &ol,Definition *container);
376 void writeEnumDeclaration(OutputList &typeDecl,
377 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
378 const DefType compoundType);
379 void warnIfUndocumented();
381 MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs,
382 ArgumentList *actualArgs);
384 void findSectionsInDocumentation();
389 void flushToDisk() const;
390 void loadFromDisk() const;
394 void saveToDisk() const;
395 void makeResident() const;
396 void _computeLinkableInProject();
397 void _computeIsConstructor();
398 void _computeIsDestructor();
399 void _writeGroupInclude(OutputList &ol,bool inGroup);
400 void _writeCallGraph(OutputList &ol);
401 void _writeCallerGraph(OutputList &ol);
402 void _writeReimplements(OutputList &ol);
403 void _writeReimplementedBy(OutputList &ol);
404 void _writeExamples(OutputList &ol);
405 void _writeTypeConstraints(OutputList &ol);
406 void _writeEnumValues(OutputList &ol,Definition *container,
407 const QCString &cfname,const QCString &ciname,
408 const QCString &cname);
409 void _writeCategoryRelation(OutputList &ol);
410 void _writeTagData(const DefType);
411 void _addToSearchIndex();
413 static int s_indentLevel;
414 // disable copying of member defs
415 MemberDef(const MemberDef &);
416 MemberDef &operator=(const MemberDef &);
418 void writeLink(OutputList &ol,
419 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
420 bool onlyText=FALSE);
422 MemberDefImpl *m_impl;
423 uchar m_isLinkableCached; // 0 = not cached, 1=FALSE, 2=TRUE
424 uchar m_isConstructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
425 uchar m_isDestructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
428 void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef);