doxygen
definitionimpl.h
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2019 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 DEFINITIONIMPL_H
19 #define DEFINITIONIMPL_H
20 
21 #include <unordered_map>
22 #include <string>
23 
24 #include "definition.h"
25 
27 {
28  public:
30  Definition *def,
31  const QCString &defFileName,int defLine,int defColumn,
32  const QCString &name,const char *b=0,const char *d=0,
33  bool isSymbol=TRUE);
34  virtual ~DefinitionImpl();
35 
36  QCString name() const;
37  bool isAnonymous() const;
38  QCString localName() const;
39  QCString qualifiedName() const;
40  QCString symbolName() const;
41  QCString getSourceFileBase() const;
42  QCString getSourceAnchor() const;
43  QCString documentation() const;
44  int docLine() const;
45  QCString docFile() const;
46  QCString briefDescription(bool abbreviate=FALSE) const;
47  QCString briefDescriptionAsTooltip() const;
48  int briefLine() const;
49  QCString inbodyDocumentation() const;
50  QCString inbodyFile() const;
51  int inbodyLine() const;
52  QCString briefFile() const;
53  QCString getDefFileName() const;
54  QCString getDefFileExtension() const;
55  int getDefLine() const;
56  int getDefColumn() const;
57  bool hasDocumentation() const;
58  bool hasUserDocumentation() const;
59  bool isVisibleInProject() const;
60  bool isVisible() const;
61  bool isHidden() const;
62  bool isArtificial() const;
63  QCString getReference() const;
64  bool isReference() const;
65  QCString externalReference(const QCString &relPath) const;
66  int getStartDefLine() const;
67  int getStartBodyLine() const;
68  int getEndBodyLine() const;
69  const FileDef *getBodyDef() const;
70  SrcLangExt getLanguage() const;
71  const GroupList &partOfGroups() const;
72  bool isLinkableViaGroup() const;
73  const RefItemVector &xrefListItems() const;
74  const Definition *findInnerCompound(const QCString &name) const;
75  Definition *getOuterScope() const;
76  const MemberVector &getReferencesMembers() const;
77  const MemberVector &getReferencedByMembers() const;
78  bool hasSections() const;
79  bool hasSources() const;
80  bool hasBriefDescription() const;
81  QCString id() const;
82  const SectionRefs &getSectionRefs() const;
83  void setName(const QCString &name);
84  void setId(const QCString &name);
85  void setDefFile(const QCString& df,int defLine,int defColumn);
86  void setDocumentation(const QCString &d,const QCString &docFile,int docLine,bool stripWhiteSpace=TRUE);
87  void setBriefDescription(const QCString &b,const QCString &briefFile,int briefLine);
88  void setInbodyDocumentation(const QCString &d,const QCString &docFile,int docLine);
89  void setReference(const QCString &r);
90  void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList);
91  void setBodySegment(int defLine,int bls,int ble);
92  void setBodyDef(const FileDef *fd);
93  void addSourceReferencedBy(const MemberDef *d);
94  void addSourceReferences(const MemberDef *d);
95  void setRefItems(const RefItemVector &sli);
96  void mergeRefItems(Definition *d);
97  void mergeReferences(const Definition *other);
98  void mergeReferencedBy(const Definition *other);
99  void addInnerCompound(const Definition *d);
100  void setOuterScope(Definition *d);
101  void setHidden(bool b);
102  void setArtificial(bool b);
103  void setLanguage(SrcLangExt lang);
104  void writeSourceDef(OutputList &ol,const QCString &scopeName) const;
105  void writeInlineCode(OutputList &ol,const QCString &scopeName) const;
106  bool hasSourceRefs() const;
107  bool hasSourceReffedBy() const;
108  void writeSourceRefs(OutputList &ol,const QCString &scopeName) const;
109  void writeSourceReffedBy(OutputList &ol,const QCString &scopeName) const;
110  void makePartOfGroup(const GroupDef *gd);
111  void writeNavigationPath(OutputList &ol) const;
113  void writeQuickMemberLinks(OutputList &,const MemberDef *) const;
114  void writeSummaryLinks(OutputList &) const;
115  QCString pathFragment() const;
116  void writeDocAnchorsToTagFile(TextStream &) const;
117  void setLocalName(const QCString &name);
118  void addSectionsToIndex();
119  void writeToc(OutputList &ol, const LocalToc &lt) const;
120  void computeTooltip();
121  void _setSymbolName(const QCString &name);
122  QCString _symbolName() const;
123 
124  DefinitionImpl(const DefinitionImpl &d);
125 
126  private:
127 
128  int _getXRefListId(const QCString &listName) const;
129  void _writeSourceRefList(OutputList &ol,const QCString &scopeName,const QCString &text,
130  const std::unordered_map<std::string,const MemberDef *> &members,bool) const;
131  void _setBriefDescription(const QCString &b,const QCString &briefFile,int briefLine);
132  void _setDocumentation(const QCString &d,const QCString &docFile,int docLine,bool stripWhiteSpace,bool atTop);
133  void _setInbodyDocumentation(const QCString &d,const QCString &docFile,int docLine);
134  bool _docsAlreadyAdded(const QCString &doc,QCString &sigList);
135 
136  // PIMPL idiom
137  class IMPL;
138  IMPL *m_impl; // internal structure holding all private data
139 };
140 
141 template<class Base>
142 class DefinitionMixin : public Base
143 {
144  public:
147  const QCString &defFileName,int defLine,int defColumn,
148  const QCString &name,const char *b=0,const char *d=0,
149  bool isSymbol=TRUE) : m_impl(this,defFileName,defLine,defColumn,name,b,d,isSymbol) {}
150  virtual ~DefinitionMixin() {}
151 
152  virtual bool isAlias() const { return FALSE; }
153 
154  //======== Definition
155  virtual QCString name() const { return m_impl.name(); }
156  virtual bool isAnonymous() const { return m_impl.isAnonymous(); }
157  virtual QCString localName() const { return m_impl.localName(); }
158  virtual QCString qualifiedName() const { return m_impl.qualifiedName(); }
159  virtual QCString symbolName() const { return m_impl.symbolName(); }
160  virtual QCString getSourceFileBase() const { return m_impl.getSourceFileBase(); }
161  virtual QCString getSourceAnchor() const { return m_impl.getSourceAnchor(); }
162  virtual QCString documentation() const { return m_impl.documentation(); }
163  virtual int docLine() const { return m_impl.docLine(); }
164  virtual QCString docFile() const { return m_impl.docFile(); }
165  virtual QCString briefDescription(bool abbreviate=FALSE) const { return m_impl.briefDescription(abbreviate); }
166  virtual QCString briefDescriptionAsTooltip() const { return m_impl.briefDescriptionAsTooltip(); }
167  virtual int briefLine() const { return m_impl.briefLine(); }
168  virtual QCString inbodyDocumentation() const { return m_impl.inbodyDocumentation(); }
169  virtual QCString inbodyFile() const { return m_impl.inbodyFile(); }
170  virtual int inbodyLine() const { return m_impl.inbodyLine(); }
171  virtual QCString briefFile() const { return m_impl.briefFile(); }
172  virtual QCString getDefFileName() const { return m_impl.getDefFileName(); }
173  virtual QCString getDefFileExtension() const { return m_impl.getDefFileExtension(); }
174  virtual int getDefLine() const { return m_impl.getDefLine(); }
175  virtual int getDefColumn() const { return m_impl.getDefColumn(); }
176  virtual bool hasDocumentation() const { return m_impl.hasDocumentation(); }
177  virtual bool hasUserDocumentation() const { return m_impl.hasUserDocumentation(); }
178  virtual bool isVisibleInProject() const { return m_impl.isVisibleInProject(); }
179  virtual bool isVisible() const { return m_impl.isVisible(); }
180  virtual bool isHidden() const { return m_impl.isHidden(); }
181  virtual bool isArtificial() const { return m_impl.isArtificial(); }
182  virtual QCString getReference() const { return m_impl.getReference(); }
183  virtual bool isReference() const { return m_impl.isReference(); }
184  virtual QCString externalReference(const QCString &relPath) const { return m_impl.externalReference(relPath); }
185  virtual int getStartDefLine() const { return m_impl.getStartDefLine(); }
186  virtual int getStartBodyLine() const { return m_impl.getStartBodyLine(); }
187  virtual int getEndBodyLine() const { return m_impl.getEndBodyLine(); }
188  virtual const FileDef *getBodyDef() const { return m_impl.getBodyDef(); }
189  virtual SrcLangExt getLanguage() const { return m_impl.getLanguage(); }
190  virtual const GroupList &partOfGroups() const { return m_impl.partOfGroups(); }
191  virtual bool isLinkableViaGroup() const { return m_impl.isLinkableViaGroup(); }
192  virtual const RefItemVector &xrefListItems() const { return m_impl.xrefListItems(); }
193  virtual const Definition *findInnerCompound(const QCString &name) const { return m_impl.findInnerCompound(name); }
194  virtual Definition *getOuterScope() const { return m_impl.getOuterScope(); }
195  virtual const MemberVector &getReferencesMembers() const { return m_impl.getReferencesMembers(); }
196  virtual const MemberVector &getReferencedByMembers() const { return m_impl.getReferencedByMembers(); }
197  virtual bool hasSections() const { return m_impl.hasSections(); }
198  virtual bool hasSources() const { return m_impl.hasSources(); }
199  virtual bool hasBriefDescription() const { return m_impl.hasBriefDescription(); }
200  virtual QCString id() const { return m_impl.id(); }
201  virtual const SectionRefs &getSectionRefs() const { return m_impl.getSectionRefs(); }
202 
203  //======== DefinitionMutable
204  virtual void setName(const QCString &name) { m_impl.setName(name); }
205  virtual void setId(const QCString &name) { m_impl.setId(name); }
206  virtual void setDefFile(const QCString& df,int defLine,int defColumn)
207  { m_impl.setDefFile(df,defLine,defColumn); }
208  virtual void setDocumentation(const QCString &doc,const QCString &docFile,int docLine,bool stripWhiteSpace=TRUE)
209  { m_impl.setDocumentation(doc,docFile,docLine,stripWhiteSpace); }
210  virtual void setBriefDescription(const QCString &brief,const QCString &briefFile,int briefLine)
211  { m_impl.setBriefDescription(brief,briefFile,briefLine); }
212  virtual void setInbodyDocumentation(const QCString &doc,const QCString &docFile,int docLine)
213  { m_impl.setInbodyDocumentation(doc,docFile,docLine); }
214  virtual void setReference(const QCString &r)
215  { m_impl.setReference(r); }
216  virtual void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList)
217  { m_impl.addSectionsToDefinition(anchorList); }
218  virtual void setBodySegment(int defLine,int bls,int ble)
219  { m_impl.setBodySegment(defLine,bls,ble); }
220  virtual void setBodyDef(const FileDef *fd)
221  { m_impl.setBodyDef(fd); }
222  virtual void addSourceReferencedBy(const MemberDef *md)
223  { m_impl.addSourceReferencedBy(md); }
224  virtual void addSourceReferences(const MemberDef *md)
225  { m_impl.addSourceReferences(md); }
226  virtual void setRefItems(const RefItemVector &sli)
227  { m_impl.setRefItems(sli); }
228  virtual void mergeRefItems(Definition *def)
229  { m_impl.mergeRefItems(def); }
230  virtual void mergeReferences(const Definition *other)
231  { m_impl.mergeReferences(other); }
232  virtual void mergeReferencedBy(const Definition *other)
233  { m_impl.mergeReferencedBy(other); }
234  virtual void addInnerCompound(const Definition *def)
235  { m_impl.addInnerCompound(def); }
236  virtual void setOuterScope(Definition *def)
237  { m_impl.setOuterScope(def); }
238  virtual void setHidden(bool b)
239  { m_impl.setHidden(b); }
240  virtual void setArtificial(bool b)
241  { m_impl.setArtificial(b); }
242  virtual void setLanguage(SrcLangExt lang)
243  { m_impl.setLanguage(lang); }
244  virtual void writeSourceDef(OutputList &ol,const QCString &scopeName) const
245  { m_impl.writeSourceDef(ol,scopeName); }
246  virtual void writeInlineCode(OutputList &ol,const QCString &scopeName) const
247  { m_impl.writeInlineCode(ol,scopeName); }
248  virtual bool hasSourceRefs() const
249  { return m_impl.hasSourceRefs(); }
250  virtual bool hasSourceReffedBy() const
251  { return m_impl.hasSourceReffedBy(); }
252  virtual void writeSourceRefs(OutputList &ol,const QCString &scopeName) const
253  { m_impl.writeSourceRefs(ol,scopeName); }
254  virtual void writeSourceReffedBy(OutputList &ol,const QCString &scopeName) const
255  { m_impl.writeSourceReffedBy(ol,scopeName); }
256  virtual void makePartOfGroup(const GroupDef *gd)
257  { m_impl.makePartOfGroup(gd); }
258  virtual void writeNavigationPath(OutputList &ol) const
259  { m_impl.writeNavigationPath(ol); }
260  virtual QCString navigationPathAsString() const
261  { return m_impl.navigationPathAsString(); }
262  virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *md) const
263  { m_impl.writeQuickMemberLinks(ol,md); }
264  virtual void writeSummaryLinks(OutputList &ol) const
265  { m_impl.writeSummaryLinks(ol); }
266  virtual QCString pathFragment() const
267  { return m_impl.pathFragment(); }
268  virtual void writeDocAnchorsToTagFile(TextStream &fs) const
269  { m_impl.writeDocAnchorsToTagFile(fs); }
270  virtual void setLocalName(const QCString &name)
271  { m_impl.setLocalName(name); }
272  virtual void addSectionsToIndex()
273  { m_impl.addSectionsToIndex(); }
274  virtual void writeToc(OutputList &ol, const LocalToc &lt) const
275  { m_impl.writeToc(ol,lt); }
276  virtual void computeTooltip()
277  { m_impl.computeTooltip(); }
278  virtual void _setSymbolName(const QCString &name)
279  { m_impl._setSymbolName(name); }
280  virtual QCString _symbolName() const
281  { return m_impl._symbolName(); }
282 
283  protected:
284 
285  DefinitionMixin(const DefinitionMixin &def) = default;
286 
287  private:
288  virtual Definition *toDefinition_() { return this; }
289  virtual DefinitionMutable *toDefinitionMutable_() { return this; }
290  virtual const DefinitionImpl *toDefinitionImpl_() const { return &m_impl; }
291 
292  DefinitionImpl m_impl;
293 };
294 
296 {
297  public:
298  DefinitionAliasImpl(Definition *def,const Definition *scope,const Definition *alias);
299  virtual ~DefinitionAliasImpl();
300  void init();
301  void deinit();
302  QCString name() const;
303  QCString qualifiedName() const;
304  private:
305  Definition *m_def;
306  const Definition *m_scope;
307  QCString m_symbolName;
308  QCString m_qualifiedName;
309 };
310 
311 template<class Base>
312 class DefinitionAliasMixin : public Base
313 {
314  public:
315  DefinitionAliasMixin(const Definition *scope,const Definition *alias)
316  : m_impl(this,scope,alias), m_scope(scope), m_alias(alias) {}
317 
318  void init() { m_impl.init(); }
319  void deinit() { m_impl.deinit(); }
320 
321  virtual ~DefinitionAliasMixin() = default;
322 
323  virtual bool isAlias() const { return TRUE; }
324 
325  //======== Definition
326  virtual QCString name() const
327  { return m_impl.name(); }
328  virtual bool isAnonymous() const
329  { return m_alias->isAnonymous(); }
330  virtual QCString localName() const
331  { return m_alias->localName(); }
332  virtual QCString qualifiedName() const
333  { return m_impl.qualifiedName(); }
334  virtual QCString symbolName() const
335  { return m_alias->symbolName(); }
336  virtual QCString getSourceFileBase() const
337  { return m_alias->getSourceFileBase(); }
338  virtual QCString getSourceAnchor() const
339  { return m_alias->getSourceAnchor(); }
340  virtual QCString documentation() const
341  { return m_alias->documentation(); }
342  virtual int docLine() const
343  { return m_alias->docLine(); }
344  virtual QCString docFile() const
345  { return m_alias->docFile(); }
346  virtual QCString briefDescription(bool abbreviate=FALSE) const
347  { return m_alias->briefDescription(abbreviate); }
348  virtual QCString briefDescriptionAsTooltip() const
349  { return m_alias->briefDescriptionAsTooltip(); }
350  virtual int briefLine() const
351  { return m_alias->briefLine(); }
352  virtual QCString inbodyDocumentation() const
353  { return m_alias->inbodyDocumentation(); }
354  virtual QCString inbodyFile() const
355  { return m_alias->inbodyFile(); }
356  virtual int inbodyLine() const
357  { return m_alias->inbodyLine(); }
358  virtual QCString briefFile() const
359  { return m_alias->briefFile(); }
360  virtual QCString getDefFileName() const
361  { return m_alias->getDefFileName(); }
362  virtual QCString getDefFileExtension() const
363  { return m_alias->getDefFileExtension(); }
364  virtual int getDefLine() const
365  { return m_alias->getDefLine(); }
366  virtual int getDefColumn() const
367  { return m_alias->getDefColumn(); }
368  virtual bool hasDocumentation() const
369  { return m_alias->hasDocumentation(); }
370  virtual bool hasUserDocumentation() const
371  { return m_alias->hasUserDocumentation(); }
372  virtual bool isVisibleInProject() const
373  { return m_alias->isVisibleInProject(); }
374  virtual bool isVisible() const
375  { return m_alias->isVisible(); }
376  virtual bool isHidden() const
377  { return m_alias->isHidden(); }
378  virtual bool isArtificial() const
379  { return m_alias->isArtificial(); }
380  virtual QCString getReference() const
381  { return m_alias->getReference(); }
382  virtual bool isReference() const
383  { return m_alias->isReference(); }
384  virtual QCString externalReference(const QCString &relPath) const
385  { return m_alias->externalReference(relPath); }
386  virtual int getStartDefLine() const
387  { return m_alias->getStartDefLine(); }
388  virtual int getStartBodyLine() const
389  { return m_alias->getStartBodyLine(); }
390  virtual int getEndBodyLine() const
391  { return m_alias->getEndBodyLine(); }
392  virtual const FileDef *getBodyDef() const
393  { return m_alias->getBodyDef(); }
394  virtual SrcLangExt getLanguage() const
395  { return m_alias->getLanguage(); }
396  virtual const GroupList &partOfGroups() const
397  { return m_alias->partOfGroups(); }
398  virtual bool isLinkableViaGroup() const
399  { return m_alias->isLinkableViaGroup(); }
400  virtual const RefItemVector &xrefListItems() const
401  { return m_alias->xrefListItems(); }
402  virtual const Definition *findInnerCompound(const QCString &name) const
403  { return m_alias->findInnerCompound(name); }
404  virtual Definition *getOuterScope() const
405  { return const_cast<Definition*>(m_scope); }
406  virtual const MemberVector &getReferencesMembers() const
407  { return m_alias->getReferencesMembers(); }
408  virtual const MemberVector &getReferencedByMembers() const
409  { return m_alias->getReferencedByMembers(); }
410  virtual bool hasSections() const
411  { return m_alias->hasSections(); }
412  virtual bool hasSources() const
413  { return m_alias->hasSources(); }
414  virtual bool hasBriefDescription() const
415  { return m_alias->hasBriefDescription(); }
416  virtual QCString id() const
417  { return m_alias->id(); }
418  virtual const SectionRefs &getSectionRefs() const
419  { return m_alias->getSectionRefs(); }
420  virtual QCString navigationPathAsString() const
421  { return m_alias->navigationPathAsString(); }
422  virtual QCString pathFragment() const
423  { return m_alias->pathFragment(); }
424 
425  protected:
426  const Definition *getAlias() const { return m_alias; }
427  const Definition *getScope() const { return m_scope; }
428 
429  private:
430  virtual Definition *toDefinition_() { return this; }
431  virtual DefinitionMutable *toDefinitionMutable_() { return 0; }
432  virtual const DefinitionImpl *toDefinitionImpl_() const { return 0; }
433 
434  virtual void _setSymbolName(const QCString &name) { m_symbolName = name; }
435  virtual QCString _symbolName() const { return m_symbolName; }
436  DefinitionAliasImpl m_impl;
437  const Definition *m_scope;
438  const Definition *m_alias;
439  QCString m_symbolName;
440 };
441 
442 #endif
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
DefinitionMixin(const QCString &defFileName, int defLine, int defColumn, const QCString &name, const char *b=0, const char *d=0, bool isSymbol=TRUE)
Definition: definitionimpl.h:146
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
QCString navigationPathAsString() const
Definition: definition.cpp:1337
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
Definition: definitionimpl.h:295
class that represents a list of constant references to sections.
Definition: section.h:98
Definition: types.h:301
Private data associated with a Symbol DefinitionImpl object.
Definition: definition.cpp:41
Definition: definition.h:308
Definition: definitionimpl.h:26
virtual const FileDef * getBodyDef() const =0
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
void writeInlineCode(OutputList &ol, const QCString &scopeName) const
Definition: definition.cpp:964
Definition: groupdef.h:127
Definition: definitionimpl.h:312
This is an alternative implementation of QCString.
Definition: qcstring.h:108
A model of a group of symbols.
Definition: groupdef.h:49
void writeSourceDef(OutputList &ol, const QCString &scopeName) const
Definition: definition.cpp:892
Definition: definitionimpl.h:142