doxygen
definition.h
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 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 DEFINITION_H
19 #define DEFINITION_H
20 
21 #include <vector>
22 
23 #include "types.h"
24 #include "reflist.h"
25 
26 #ifdef _MSC_VER
27 // To disable 'inherits via dominance' warnings with MSVC.
28 // See also https://stackoverflow.com/a/14487243/784672
29 #pragma warning( disable: 4250 )
30 #endif
31 
32 class FileDef;
33 class OutputList;
34 class SectionRefs;
35 class MemberDef;
36 class MemberVector;
37 class GroupDef;
38 class GroupList;
39 class SectionInfo;
40 class Definition;
41 class DefinitionMutable;
42 class DefinitionImpl;
43 class TextStream;
44 
46 struct DocInfo
47 {
48  QCString doc;
49  int line = -1;
50  QCString file;
51 };
52 
54 struct BriefInfo
55 {
56  QCString doc;
57  QCString tooltip;
58  int line = -1;
59  QCString file;
60 };
61 
63 struct BodyInfo
64 {
65  int defLine = -1;
66  int startLine = -1;
67  int endLine = -1;
68  const FileDef *fileDef = 0;
69 };
70 
77 {
78  public:
79  struct Cookie
80  {
81  virtual ~Cookie() {}
82  };
83 
85  enum DefType
86  {
87  TypeClass = 0,
88  TypeFile = 1,
89  TypeNamespace = 2,
90  TypeMember = 3,
91  TypeGroup = 4,
92  TypePackage = 5,
93  TypePage = 6,
94  TypeDir = 7,
95  TypeConcept = 8
96  };
97 
98 
99  //-----------------------------------------------------------------------------------
100  // ---- getters -----
101  //-----------------------------------------------------------------------------------
102 
104  virtual DefType definitionType() const = 0;
105 
107  virtual CodeSymbolType codeSymbolType() const = 0;
108 
110  virtual bool isAlias() const = 0;
111 
113  virtual QCString name() const = 0;
114 
118  virtual bool isAnonymous() const = 0;
119 
121  virtual QCString displayName(bool includeScope=TRUE) const = 0;
122 
124  virtual QCString localName() const = 0;
125 
128  virtual QCString qualifiedName() const = 0;
129 
132  virtual QCString symbolName() const = 0;
133 
137  virtual QCString getOutputFileBase() const = 0;
138 
140  virtual QCString anchor() const = 0;
141 
143  virtual QCString getSourceFileBase() const = 0;
144 
146  virtual QCString getSourceAnchor() const = 0;
147 
149  virtual QCString documentation() const = 0;
150 
152  virtual int docLine() const = 0;
153 
157  virtual QCString docFile() const = 0;
158 
160  virtual QCString briefDescription(bool abbreviate=FALSE) const = 0;
161 
165  virtual QCString briefDescriptionAsTooltip() const = 0;
166 
168  virtual int briefLine() const = 0;
169 
171  virtual QCString inbodyDocumentation() const = 0;
172 
174  virtual QCString inbodyFile() const = 0;
175 
178  virtual int inbodyLine() const = 0;
179 
183  virtual QCString briefFile() const = 0;
184 
186  virtual QCString getDefFileName() const = 0;
187 
189  virtual QCString getDefFileExtension() const = 0;
190 
192  virtual int getDefLine() const = 0;
193 
195  virtual int getDefColumn() const = 0;
196 
201  virtual bool hasDocumentation() const = 0;
202 
204  virtual bool hasUserDocumentation() const = 0;
205 
209  virtual bool isLinkableInProject() const = 0;
210 
214  virtual bool isLinkable() const = 0;
215 
219  virtual bool isVisibleInProject() const = 0;
220 
222  virtual bool isVisible() const = 0;
223 
225  virtual bool isHidden() const = 0;
226 
230  virtual bool isArtificial() const = 0;
231 
237  virtual QCString getReference() const = 0;
238 
240  virtual bool isReference() const = 0;
241 
243  virtual QCString externalReference(const QCString &relPath) const = 0;
244 
246  virtual int getStartDefLine() const = 0;
247 
251  virtual int getStartBodyLine() const = 0;
252 
256  virtual int getEndBodyLine() const = 0;
257 
261  virtual const FileDef *getBodyDef() const = 0;
262 
264  virtual SrcLangExt getLanguage() const = 0;
265 
266  virtual const GroupList &partOfGroups() const = 0;
267  virtual bool isLinkableViaGroup() const = 0;
268 
269  virtual const RefItemVector &xrefListItems() const = 0;
270 
271  virtual const Definition *findInnerCompound(const QCString &name) const = 0;
272  virtual Definition *getOuterScope() const = 0;
273 
274  virtual const MemberVector &getReferencesMembers() const = 0;
275  virtual const MemberVector &getReferencedByMembers() const = 0;
276 
277  virtual bool hasSections() const = 0;
278  virtual bool hasSources() const = 0;
279 
281  virtual bool hasBriefDescription() const = 0;
282 
283  virtual QCString id() const = 0;
284 
286  virtual const SectionRefs &getSectionRefs() const = 0;
287 
288  virtual QCString navigationPathAsString() const = 0;
289  virtual QCString pathFragment() const = 0;
290 
291  //-----------------------------------------------------------------------------------
292  // --- cookie storage ----
293  //-----------------------------------------------------------------------------------
294  virtual void setCookie(Cookie *cookie) const = 0;
295  virtual Cookie *cookie() const = 0;
296 
297  //-----------------------------------------------------------------------------------
298  // --- symbol name ----
299  //-----------------------------------------------------------------------------------
300  virtual void _setSymbolName(const QCString &name) = 0;
301  virtual QCString _symbolName() const = 0;
302 
303  // ---------------------------------
304  virtual ~Definition() = default;
305 
306  private:
307  friend class DefinitionImpl;
308  friend DefinitionMutable* toDefinitionMutable(Definition *);
309  friend DefinitionMutable* toDefinitionMutable(const Definition *);
310  virtual DefinitionMutable *toDefinitionMutable_() = 0;
311  virtual const DefinitionImpl *toDefinitionImpl_() const = 0;
312 };
313 
315 {
316  public:
317 
318 
319  //-----------------------------------------------------------------------------------
320  // ---- setters -----
321  //-----------------------------------------------------------------------------------
322 
324  virtual void setName(const QCString &name) = 0;
325 
327  virtual void setId(const QCString &name) = 0;
328 
330  virtual void setDefFile(const QCString& df,int defLine,int defColumn) = 0;
331 
333  virtual void setDocumentation(const QCString &d,const QCString &docFile,int docLine,bool stripWhiteSpace=TRUE) = 0;
334 
338  virtual void setBriefDescription(const QCString &b,const QCString &briefFile,int briefLine) = 0;
339 
344  virtual void setInbodyDocumentation(const QCString &d,const QCString &docFile,int docLine) = 0;
345 
347  virtual void setReference(const QCString &r) = 0;
348 
349  // source references
350  virtual void setBodySegment(int defLine, int bls,int ble) = 0;
351  virtual void setBodyDef(const FileDef *fd) = 0;
352 
353  virtual void setRefItems(const RefItemVector &sli) = 0;
354  virtual void setOuterScope(Definition *d) = 0;
355 
356  virtual void setHidden(bool b) = 0;
357 
358  virtual void setArtificial(bool b) = 0;
359  virtual void setLanguage(SrcLangExt lang) = 0;
360  virtual void setLocalName(const QCString &name) = 0;
361 
362  //-----------------------------------------------------------------------------------
363  // --- actions ----
364  //-----------------------------------------------------------------------------------
365 
366  virtual void makePartOfGroup(const GroupDef *gd) = 0;
367 
371  virtual void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList) = 0;
372  virtual void addSourceReferencedBy(const MemberDef *d) = 0;
373  virtual void addSourceReferences(const MemberDef *d) = 0;
374  virtual void mergeRefItems(Definition *d) = 0;
375  virtual void addInnerCompound(const Definition *d) = 0;
376  virtual void addSectionsToIndex() = 0;
377  virtual void mergeReferences(const Definition *other) = 0;
378  virtual void mergeReferencedBy(const Definition *other) = 0;
379  virtual void computeTooltip() = 0;
380 
381  //-----------------------------------------------------------------------------------
382  // --- writing output ----
383  //-----------------------------------------------------------------------------------
384  virtual void writeSourceDef(OutputList &ol,const QCString &scopeName) const = 0;
385  virtual void writeInlineCode(OutputList &ol,const QCString &scopeName) const = 0;
386  virtual bool hasSourceRefs() const = 0;
387  virtual bool hasSourceReffedBy() const = 0;
388  virtual void writeSourceRefs(OutputList &ol,const QCString &scopeName) const = 0;
389  virtual void writeSourceReffedBy(OutputList &ol,const QCString &scopeName) const = 0;
390  virtual void writeNavigationPath(OutputList &ol) const = 0;
391  virtual void writeQuickMemberLinks(OutputList &,const MemberDef *) const = 0;
392  virtual void writeSummaryLinks(OutputList &) const = 0;
393  virtual void writeDocAnchorsToTagFile(TextStream &) const = 0;
394  virtual void writeToc(OutputList &ol, const LocalToc &lt) const = 0;
395 
396  // ---------------------------------
397  virtual ~DefinitionMutable() = default;
398 
399  private:
400  friend Definition* toDefinition(DefinitionMutable *);
401  virtual Definition *toDefinition_() = 0;
402 };
403 
404 Definition *toDefinition(DefinitionMutable *dm);
405 DefinitionMutable *toDefinitionMutable(Definition *d);
406 DefinitionMutable *toDefinitionMutable(const Definition *d);
407 
413 bool readCodeFragment(const QCString &fileName,
414  int &startLine,int &endLine,
415  QCString &result);
416 #endif
This file contains a number of basic enums and types.
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
A vector of MemberDef object.
Definition: memberlist.h:32
Text streaming class that buffers data.
Definition: textstream.h:33
A model of a file symbol.
Definition: filedef.h:73
SrcLangExt
Language as given by extension.
Definition: types.h:41
class that represents a list of constant references to sections.
Definition: section.h:98
Definition: types.h:301
Definition: definition.h:79
Definition: definition.h:314
Data associated with description found in the body.
Definition: definition.h:63
Data associated with a brief description.
Definition: definition.h:54
Definition: definitionimpl.h:26
class that provide information about a section.
Definition: section.h:49
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
Data associated with a detailed description.
Definition: definition.h:46
Definition: groupdef.h:127
DefType
Definition: definition.h:85
This is an alternative implementation of QCString.
Definition: qcstring.h:108
A model of a group of symbols.
Definition: groupdef.h:49