Doxygen
Loading...
Searching...
No Matches
definition.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2023 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef DEFINITION_H
17#define DEFINITION_H
18
19#include <vector>
20
21#include "types.h"
22#include "reflist.h"
23#include "construct.h"
24
25#ifdef _MSC_VER
26// To disable 'inherits via dominance' warnings with MSVC.
27// See also https://stackoverflow.com/a/14487243/784672
28#pragma warning( disable: 4250 )
29#endif
30
31class FileDef;
32class OutputList;
33class SectionRefs;
34class MemberDef;
35class MemberVector;
36class GroupDef;
37class GroupList;
38class SectionInfo;
39class Definition;
41class DefinitionImpl;
42class TextStream;
43
44/** Data associated with a detailed description. */
45struct DocInfo
46{
48 int line = -1;
50};
51
52/** Data associated with a brief description. */
60
61/** Data associated with description found in the body. */
63{
64 int defLine = -1; //!< line number of the start of the definition
65 int startLine = -1; //!< line number of the start of the definition's body
66 int endLine = -1; //!< line number of the end of the definition's body
67 const FileDef *fileDef = nullptr; //!< file definition containing the function body
68};
69
70/** The common base class of all entity definitions found in the sources.
71 *
72 * This can be a class or a member function, or a file, or a namespace, etc.
73 * Use definitionType() to find which type of definition this is.
74 */
76{
77 public:
79
80 /*! Types of derived classes */
94
95
96 //-----------------------------------------------------------------------------------
97 // ---- getters -----
98 //-----------------------------------------------------------------------------------
99
100 /*! Use this for dynamic inspection of the type of the derived class */
101 virtual DefType definitionType() const = 0;
102
103 /*! Used for syntax highlighting symbol class */
104 virtual CodeSymbolType codeSymbolType() const = 0;
105
106 /*! Returns TRUE if this is an alias of another definition */
107 virtual bool isAlias() const = 0;
108
109 /*! Returns the name of the definition */
110 virtual const QCString &name() const = 0;
111
112 /*! Returns TRUE iff this definition has an artificially generated name
113 * (typically starting with a @) that is used for nameless definitions
114 */
115 virtual bool isAnonymous() const = 0;
116
117 /*! Returns the name of the definition as it appears in the output */
118 virtual QCString displayName(bool includeScope=TRUE) const = 0;
119
120 /*! Returns the local name without any scope qualifiers. */
121 virtual const QCString &localName() const = 0;
122
123 /*! Returns the fully qualified name of this definition
124 */
125 virtual QCString qualifiedName() const = 0;
126
127 /*! Returns the name of this definition as it appears in the symbol map.
128 */
129 virtual QCString symbolName() const = 0;
130
131 /*! Returns the base file name (without extension) of this definition.
132 * as it is referenced to/written to disk.
133 */
134 virtual QCString getOutputFileBase() const = 0;
135
136 /*! Returns the anchor within a page where this item can be found */
137 virtual QCString anchor() const = 0;
138
139 /*! Returns the name of the source listing of this definition. */
140 virtual QCString getSourceFileBase() const = 0;
141
142 /*! Returns the anchor of the source listing of this definition. */
143 virtual QCString getSourceAnchor() const = 0;
144
145 /*! Returns the detailed description of this definition */
146 virtual QCString documentation() const = 0;
147
148 /*! Returns the line number at which the detailed documentation was found. */
149 virtual int docLine() const = 0;
150
151 /*! Returns the file in which the detailed documentation block was found.
152 * This can differ from getDefFileName().
153 */
154 virtual QCString docFile() const = 0;
155
156 /*! Returns the brief description of this definition. This can include commands. */
157 virtual QCString briefDescription(bool abbreviate=FALSE) const = 0;
158
159 /*! Returns a plain text version of the brief description suitable for use
160 * as a tool tip.
161 */
163
164 /*! Returns the line number at which the brief description was found. */
165 virtual int briefLine() const = 0;
166
167 /*! Returns the documentation found inside the body of a member */
168 virtual QCString inbodyDocumentation() const = 0;
169
170 /*! Returns the file in which the in body documentation was found */
171 virtual QCString inbodyFile() const = 0;
172
173 /*! Returns the line at which the first in body documentation
174 part was found */
175 virtual int inbodyLine() const = 0;
176
177 /*! Returns the file in which the brief description was found.
178 * This can differ from getDefFileName().
179 */
180 virtual QCString briefFile() const = 0;
181
182 /*! returns the file in which this definition was found */
183 virtual QCString getDefFileName() const = 0;
184
185 /*! returns the extension of the file in which this definition was found */
186 virtual QCString getDefFileExtension() const = 0;
187
188 /*! returns the line number at which the definition was found (can be the declaration) */
189 virtual int getDefLine() const = 0;
190
191 /*! returns the column number at which the definition was found */
192 virtual int getDefColumn() const = 0;
193
194 /*! Returns TRUE iff the definition is documented
195 * (which could be generated documentation)
196 * @see hasUserDocumentation()
197 */
198 virtual bool hasDocumentation() const = 0;
199
200 /*! Returns TRUE iff the definition is documented by the user. */
201 virtual bool hasUserDocumentation() const = 0;
202
203 /*! Returns TRUE iff it is possible to link to this item within this
204 * project.
205 */
206 virtual bool isLinkableInProject() const = 0;
207
208 /*! Returns TRUE iff it is possible to link to this item. This can
209 * be a link to another project imported via a tag file.
210 */
211 virtual bool isLinkable() const = 0;
212
213 /*! Returns TRUE iff the name is part of this project and
214 * may appear in the output
215 */
216 virtual bool isVisibleInProject() const = 0;
217
218 /*! Returns TRUE iff the name may appear in the output */
219 virtual bool isVisible() const = 0;
220
221 /*! Returns TRUE iff this item is supposed to be hidden from the output. */
222 virtual bool isHidden() const = 0;
223
224 /*! Returns TRUE if this entity was artificially introduced, for
225 * instance because it is used to show a template instantiation relation.
226 */
227 virtual bool isArtificial() const = 0;
228
229 /*! Returns TRUE iff this entity was exported from a C++20 module. */
230 virtual bool isExported() const = 0;
231
232 /*! If this definition was imported via a tag file, this function
233 * returns the tagfile for the external project. This can be
234 * translated into an external link target via
235 * Doxygen::tagDestinationDict
236 */
237 virtual QCString getReference() const = 0;
238
239 /*! Returns TRUE if this definition is imported via a tag file. */
240 virtual bool isReference() const = 0;
241
242 /*! Convenience method to return a resolved external link */
243 virtual QCString externalReference(const QCString &relPath) const = 0;
244
245 /*! Returns the first line of the implementation of this item. See also getDefLine() */
246 virtual int getStartDefLine() const = 0;
247
248 /*! Returns the first line of the body of this item (applicable to classes and
249 * functions).
250 */
251 virtual int getStartBodyLine() const = 0;
252
253 /*! Returns the last line of the body of this item (applicable to classes and
254 * functions).
255 */
256 virtual int getEndBodyLine() const = 0;
257
258 /*! Returns the file in which the body of this item is located or 0 if no
259 * body is available.
260 */
261 virtual const FileDef *getBodyDef() const = 0;
262
263 /** Returns the programming language this definition was written in. */
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
280
281 /** returns TRUE if this class has a brief description */
282 virtual bool hasBriefDescription() const = 0;
283
284 virtual QCString id() const = 0;
285
286 /** returns the section dictionary, only of importance for pagedef */
287 virtual const SectionRefs &getSectionRefs() const = 0;
288
289 virtual QCString navigationPathAsString() const = 0;
290 virtual QCString pathFragment() const = 0;
291
292 //-----------------------------------------------------------------------------------
293 // --- symbol name ----
294 //-----------------------------------------------------------------------------------
295 virtual void _setSymbolName(const QCString &name) = 0;
296 virtual QCString _symbolName() const = 0;
297
298 private:
299 friend class DefinitionImpl;
302 virtual const DefinitionImpl *toDefinitionImpl_() const = 0;
303};
304
306{
307 public:
309
310 //-----------------------------------------------------------------------------------
311 // ---- setters -----
312 //-----------------------------------------------------------------------------------
313
314 /*! Sets a new \a name for the definition */
315 virtual void setName(const QCString &name) = 0;
316
317 /*! Sets a unique id for the symbol. Used for libclang integration. */
318 virtual void setId(const QCString &name) = 0;
319
320 /*! Set a new file name and position */
321 virtual void setDefFile(const QCString& df,int defLine,int defColumn) = 0;
322
323 /*! Sets the documentation of this definition to \a d. */
324 virtual void setDocumentation(const QCString &d,const QCString &docFile,int docLine,bool stripWhiteSpace=TRUE) = 0;
325
326 /*! Sets the brief description of this definition to \a b.
327 * A dot is added to the sentence if not available.
328 */
329 virtual void setBriefDescription(const QCString &b,const QCString &briefFile,int briefLine) = 0;
330
331 /*! Set the documentation that was found inside the body of an item.
332 * If there was already some documentation set, the new documentation
333 * will be appended.
334 */
335 virtual void setInbodyDocumentation(const QCString &d,const QCString &docFile,int docLine) = 0;
336
337 /*! Sets the tag file id via which this definition was imported. */
338 virtual void setReference(const QCString &r) = 0;
339
340 // source references
341 virtual void setBodySegment(int defLine, int bls,int ble) = 0;
342 virtual void setBodyDef(const FileDef *fd) = 0;
343
344 virtual void setRefItems(const RefItemVector &sli) = 0;
345 virtual void setOuterScope(Definition *d) = 0;
346
347 virtual void setHidden(bool b) = 0;
348
349 virtual void setArtificial(bool b) = 0;
350 virtual void setExported(bool b) = 0;
351 virtual void setLanguage(SrcLangExt lang) = 0;
352 virtual void setLocalName(const QCString &name) = 0;
353
354 //-----------------------------------------------------------------------------------
355 // --- actions ----
356 //-----------------------------------------------------------------------------------
357
358 virtual void makePartOfGroup(GroupDef *gd) = 0;
359
360 /*! Add the list of anchors that mark the sections that are found in the
361 * documentation.
362 */
363 virtual void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList) = 0;
364 virtual void addSourceReferencedBy(MemberDef *d,const QCString &sourceRefName) = 0;
365 virtual void addSourceReferences(MemberDef *d,const QCString &sourceRefName) = 0;
366 virtual void mergeRefItems(Definition *d) = 0;
367 virtual void addInnerCompound(Definition *d) = 0;
368 virtual void mergeReferences(const Definition *other) = 0;
369 virtual void mergeReferencedBy(const Definition *other) = 0;
370 virtual void computeTooltip() = 0;
371
372 //-----------------------------------------------------------------------------------
373 // --- writing output ----
374 //-----------------------------------------------------------------------------------
375 virtual void writeSourceDef(OutputList &ol) const = 0;
376 virtual void writeInlineCode(OutputList &ol,const QCString &scopeName) const = 0;
377 virtual bool hasSourceRefs() const = 0;
378 virtual bool hasSourceReffedBy() const = 0;
379 virtual void writeSourceRefs(OutputList &ol,const QCString &scopeName) const = 0;
380 virtual void writeSourceReffedBy(OutputList &ol,const QCString &scopeName) const = 0;
381 virtual void writeNavigationPath(OutputList &ol) const = 0;
382 virtual void writeQuickMemberLinks(OutputList &,const MemberDef *) const = 0;
383 virtual void writeSummaryLinks(OutputList &) const = 0;
384 virtual void writeDocAnchorsToTagFile(TextStream &) const = 0;
385 virtual void writeToc(OutputList &ol, const LocalToc &lt) const = 0;
386
387 private:
389 virtual Definition *toDefinition_() = 0;
390};
391
394
395/** Reads a fragment from file \a fileName starting with line \a startLine
396 * and ending with line \a endLine. The result is returned as a string
397 * via \a result. The function returns TRUE if successful and FALSE
398 * in case of an error.
399 */
400bool readCodeFragment(const QCString &fileName,bool isMacro,
401 int &startLine,int &endLine,
402 QCString &result);
403#endif
The common base class of all entity definitions found in the sources.
Definition definition.h:76
virtual QCString docFile() const =0
virtual bool isVisible() const =0
virtual const QCString & localName() const =0
virtual int getEndBodyLine() const =0
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual bool hasSections() const =0
virtual bool isVisibleInProject() const =0
virtual int docLine() const =0
virtual const RefItemVector & xrefListItems() const =0
virtual QCString navigationPathAsString() const =0
virtual QCString getDefFileName() const =0
virtual bool isLinkable() const =0
virtual bool isLinkableViaGroup() const =0
virtual int getDefLine() const =0
virtual bool hasBriefDescription() const =0
returns TRUE if this class has a brief description
virtual DefType definitionType() const =0
virtual const SectionRefs & getSectionRefs() const =0
returns the section dictionary, only of importance for pagedef
virtual QCString pathFragment() const =0
virtual QCString anchor() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual QCString getSourceAnchor() const =0
virtual int inbodyLine() const =0
virtual DefinitionMutable * toDefinitionMutable_()=0
virtual const FileDef * getBodyDef() const =0
virtual int briefLine() const =0
virtual bool hasDocumentation() const =0
virtual QCString id() const =0
virtual bool isLinkableInProject() const =0
virtual QCString symbolName() const =0
virtual bool isExported() const =0
virtual bool hasSources() const =0
virtual QCString briefDescription(bool abbreviate=FALSE) const =0
virtual bool hasUserDocumentation() const =0
virtual bool isAnonymous() const =0
virtual bool isHidden() const =0
virtual const Definition * findInnerCompound(const QCString &name) const =0
virtual int getStartDefLine() const =0
virtual QCString getReference() const =0
virtual void _setSymbolName(const QCString &name)=0
virtual QCString getSourceFileBase() const =0
virtual const GroupList & partOfGroups() const =0
virtual QCString documentation() const =0
virtual QCString qualifiedName() const =0
virtual QCString displayName(bool includeScope=TRUE) const =0
virtual bool isAlias() const =0
virtual bool isArtificial() const =0
virtual QCString briefFile() const =0
virtual CodeSymbolType codeSymbolType() const =0
virtual QCString getOutputFileBase() const =0
virtual Definition * getOuterScope() const =0
virtual const MemberVector & getReferencedByMembers() const =0
virtual int getStartBodyLine() const =0
friend class DefinitionImpl
Definition definition.h:299
virtual QCString getDefFileExtension() const =0
virtual QCString _symbolName() const =0
virtual int getDefColumn() const =0
virtual bool isReference() const =0
virtual const MemberVector & getReferencesMembers() const =0
virtual QCString inbodyDocumentation() const =0
virtual const DefinitionImpl * toDefinitionImpl_() const =0
virtual QCString inbodyFile() const =0
virtual const QCString & name() const =0
friend DefinitionMutable * toDefinitionMutable(Definition *)
virtual QCString externalReference(const QCString &relPath) const =0
virtual void mergeReferencedBy(const Definition *other)=0
virtual bool hasSourceRefs() const =0
virtual void setExported(bool b)=0
virtual void setBodySegment(int defLine, int bls, int ble)=0
virtual void setName(const QCString &name)=0
virtual void setLocalName(const QCString &name)=0
virtual void setHidden(bool b)=0
virtual void mergeReferences(const Definition *other)=0
virtual bool hasSourceReffedBy() const =0
virtual void writeSourceRefs(OutputList &ol, const QCString &scopeName) const =0
virtual void setDocumentation(const QCString &d, const QCString &docFile, int docLine, bool stripWhiteSpace=TRUE)=0
virtual void setDefFile(const QCString &df, int defLine, int defColumn)=0
virtual void writeSummaryLinks(OutputList &) const =0
virtual Definition * toDefinition_()=0
virtual void addSourceReferences(MemberDef *d, const QCString &sourceRefName)=0
virtual void addInnerCompound(Definition *d)=0
virtual void writeQuickMemberLinks(OutputList &, const MemberDef *) const =0
virtual void addSectionsToDefinition(const std::vector< const SectionInfo * > &anchorList)=0
virtual void writeSourceDef(OutputList &ol) const =0
virtual void setInbodyDocumentation(const QCString &d, const QCString &docFile, int docLine)=0
virtual void writeInlineCode(OutputList &ol, const QCString &scopeName) const =0
virtual void setLanguage(SrcLangExt lang)=0
virtual void setOuterScope(Definition *d)=0
friend Definition * toDefinition(DefinitionMutable *)
virtual void writeSourceReffedBy(OutputList &ol, const QCString &scopeName) const =0
virtual void setArtificial(bool b)=0
virtual void writeToc(OutputList &ol, const LocalToc &lt) const =0
virtual void setId(const QCString &name)=0
virtual void mergeRefItems(Definition *d)=0
virtual void writeDocAnchorsToTagFile(TextStream &) const =0
virtual void makePartOfGroup(GroupDef *gd)=0
virtual void setBodyDef(const FileDef *fd)=0
virtual void setBriefDescription(const QCString &b, const QCString &briefFile, int briefLine)=0
virtual void setReference(const QCString &r)=0
virtual void addSourceReferencedBy(MemberDef *d, const QCString &sourceRefName)=0
virtual void writeNavigationPath(OutputList &ol) const =0
virtual void setRefItems(const RefItemVector &sli)=0
virtual void computeTooltip()=0
A model of a file symbol.
Definition filedef.h:99
A model of a group of symbols.
Definition groupdef.h:52
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
A vector of MemberDef object.
Definition memberlist.h:34
Class representing a list of output generators that are written to in parallel.
Definition outputlist.h:314
This is an alternative implementation of QCString.
Definition qcstring.h:101
class that provide information about a section.
Definition section.h:57
class that represents a list of constant references to sections.
Definition section.h:102
Text streaming class that buffers data.
Definition textstream.h:36
#define ABSTRACT_BASE_CLASS(cls)
Macro to implement rule of 5 for an abstract base class.
Definition construct.h:20
static QCString abbreviate(const QCString &s, const QCString &name)
bool readCodeFragment(const QCString &fileName, bool isMacro, int &startLine, int &endLine, QCString &result)
Reads a fragment from file fileName starting with line startLine and ending with line endLine.
DefinitionMutable * toDefinitionMutable(Definition *d)
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
std::vector< RefItem * > RefItemVector
Definition reflist.h:133
std::string_view stripWhiteSpace(std::string_view s)
Given a string view s, returns a new, narrower view on that string, skipping over any leading or trai...
Definition stringutil.h:72
Data associated with description found in the body.
Definition definition.h:63
int startLine
line number of the start of the definition's body
Definition definition.h:65
const FileDef * fileDef
file definition containing the function body
Definition definition.h:67
int endLine
line number of the end of the definition's body
Definition definition.h:66
int defLine
line number of the start of the definition
Definition definition.h:64
Data associated with a brief description.
Definition definition.h:54
QCString tooltip
Definition definition.h:56
QCString file
Definition definition.h:58
QCString doc
Definition definition.h:55
Data associated with a detailed description.
Definition definition.h:46
QCString doc
Definition definition.h:47
int line
Definition definition.h:48
QCString file
Definition definition.h:49
This file contains a number of basic enums and types.
CodeSymbolType
Definition types.h:319
SrcLangExt
Language as given by extension.
Definition types.h:42