My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
definition.h
Go to the documentation of this file.
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 <qlist.h>
22 #include <qdict.h>
23 
24 #include "types.h"
25 
26 class FileDef;
27 class OutputList;
28 class SectionDict;
29 class MemberSDict;
30 class MemberDef;
31 class GroupDef;
32 class GroupList;
33 struct ListItemInfo;
34 struct SectionInfo;
35 class Definition;
36 class DefinitionImpl;
37 class FTextStream;
38 
40 struct DocInfo
41 {
42  QCString doc;
43  int line;
44  QCString file;
45 };
46 
48 struct BriefInfo
49 {
50  QCString doc;
51  QCString tooltip;
52  int line;
53  QCString file;
54 };
55 
57 struct BodyInfo
58 {
59  int startLine;
60  int endLine;
62 };
63 
66 {
67  public:
69  virtual ~DefinitionIntf() {}
71  enum DefType
72  {
73  TypeClass = 0,
74  TypeFile = 1,
76  TypeMember = 3,
77  TypeGroup = 4,
79  TypePage = 6,
80  TypeDir = 7,
82  };
84  virtual DefType definitionType() const = 0;
85 };
86 
92 class Definition : public DefinitionIntf
93 {
94  public:
95  struct Cookie
96  {
97  virtual ~Cookie() {}
98  };
99 
101  Definition(
102  const char *defFileName,int defLine,int defColumn,
103  const char *name,const char *b=0,const char *d=0,
104  bool isSymbol=TRUE);
105 
107  virtual ~Definition();
108 
109  //-----------------------------------------------------------------------------------
110  // ---- getters -----
111  //-----------------------------------------------------------------------------------
112 
114  const QCString& name() const { return m_name; }
115 
117  virtual QCString displayName(bool includeScope=TRUE) const = 0;
118 
120  QCString localName() const;
121 
124  virtual QCString qualifiedName() const;
125 
128  QCString symbolName() const;
129 
133  virtual QCString getOutputFileBase() const = 0;
134 
136  virtual QCString anchor() const = 0;
137 
139  virtual QCString getSourceFileBase() const;
140 
142  virtual QCString getSourceAnchor() const;
143 
145  virtual QCString documentation() const;
146 
148  int docLine() const;
149 
153  QCString docFile() const;
154 
156  virtual QCString briefDescription(bool abbreviate=FALSE) const;
157 
161  QCString briefDescriptionAsTooltip() const;
162 
164  int briefLine() const;
165 
167  QCString inbodyDocumentation() const;
168 
170  QCString inbodyFile() const;
171 
174  int inbodyLine() const;
175 
179  QCString briefFile() const;
180 
182  QCString getDefFileName() const;
183 
185  QCString getDefFileExtension() const;
186 
188  int getDefLine() const { return m_defLine; }
189 
191  int getDefColumn() const { return m_defColumn; }
192 
197  virtual bool hasDocumentation() const;
198 
200  virtual bool hasUserDocumentation() const;
201 
205  virtual bool isLinkableInProject() const = 0;
206 
210  virtual bool isLinkable() const = 0;
211 
215  virtual bool isVisibleInProject() const;
216 
218  virtual bool isVisible() const;
219 
221  bool isHidden() const;
222 
226  bool isArtificial() const;
227 
233  virtual QCString getReference() const;
234 
236  virtual bool isReference() const;
237 
239  QCString externalReference(const QCString &relPath) const;
240 
244  int getStartBodyLine() const;
245 
249  int getEndBodyLine() const;
250 
254  FileDef *getBodyDef() const;
255 
257  SrcLangExt getLanguage() const;
258 
259  GroupList *partOfGroups() const;
260  bool isLinkableViaGroup() const;
261 
262  QList<ListItemInfo> *xrefListItems() const;
263 
264  virtual Definition *findInnerCompound(const char *name);
265  virtual Definition *getOuterScope() const;
266 
269 
270  bool hasSections() const;
271  bool hasSources() const;
272 
274  bool hasBriefDescription() const;
275 
276  QCString id() const;
277 
278  //-----------------------------------------------------------------------------------
279  // ---- setters -----
280  //-----------------------------------------------------------------------------------
281 
283  virtual void setName(const char *name);
284 
286  void setId(const char *name);
287 
289  virtual void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
290 
294  virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine);
295 
300  virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine);
301 
303  void setReference(const char *r);
304 
308  void addSectionsToDefinition(QList<SectionInfo> *anchorList);
309 
310  // source references
311  void setBodySegment(int bls,int ble);
312  void setBodyDef(FileDef *fd);
315 
316  void setRefItems(const QList<ListItemInfo> *sli);
317  void mergeRefItems(Definition *d);
318  virtual void addInnerCompound(Definition *d);
319  virtual void setOuterScope(Definition *d);
320 
321  virtual void setHidden(bool b);
322 
323  void setArtificial(bool b);
324  void setLanguage(SrcLangExt lang);
325 
326  //-----------------------------------------------------------------------------------
327  // --- actions ----
328  //-----------------------------------------------------------------------------------
329 
330  void writeSourceDef(OutputList &ol,const char *scopeName);
331  void writeInlineCode(OutputList &ol,const char *scopeName);
332  void writeSourceRefs(OutputList &ol,const char *scopeName);
333  void writeSourceReffedBy(OutputList &ol,const char *scopeName);
334  void makePartOfGroup(GroupDef *gd);
335  //void writePathFragment(OutputList &ol) const;
336  void writeNavigationPath(OutputList &ol) const;
337  QCString navigationPathAsString() const;
338  virtual void writeQuickMemberLinks(OutputList &,MemberDef *) const {}
339  virtual void writeSummaryLinks(OutputList &) {}
340  QCString pathFragment() const;
341 
346  void setLocalName(const QCString name);
347 
348  void addSectionsToIndex();
349  void writeToc(OutputList &ol);
350 
352  Cookie *cookie() const { return m_cookie; }
353 
354  protected:
355 
356  Definition(const Definition &d);
357 
358  private:
359  static void addToMap(const char *name,Definition *d);
360  static void removeFromMap(Definition *d);
361 
362  void _setSymbolName(const QCString &name);
363 
364  int _getXRefListId(const char *listName) const;
365  void _writeSourceRefList(OutputList &ol,const char *scopeName,
366  const QCString &text,MemberSDict *members,bool);
367  void _setBriefDescription(const char *b,const char *briefFile,int briefLine);
368  void _setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace,bool atTop);
369  void _setInbodyDocumentation(const char *d,const char *docFile,int docLine);
370  bool _docsAlreadyAdded(const QCString &doc,QCString &sigList);
371  DefinitionImpl *m_impl; // internal structure holding all private data
372  QCString m_name;
374  QCString m_symbolName;
378 };
379 
381 class DefinitionList : public QList<Definition>, public DefinitionIntf
382 {
383  public:
386  int compareValues(const Definition *item1,const Definition *item2) const
387  {
388  return qstricmp(item1->name(),item2->name());
389  }
390 
391 };
392 
394 class DefinitionListIterator : public QListIterator<Definition>
395 {
396  public:
398  QListIterator<Definition>(l) {}
400 };
401 
407 bool readCodeFragment(const char *fileName,
408  int &startLine,int &endLine,
409  QCString &result);
410 #endif