filedef.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 FILEDEF_H
19 #define FILEDEF_H
20 
21 #include "index.h"
22 #include <qlist.h>
23 #include <qintdict.h>
24 #include <qdict.h>
25 #include "definition.h"
26 #include "sortdict.h"
27 #include "memberlist.h"
28 
29 class MemberList;
30 class FileDef;
31 class FileList;
32 class ClassSDict;
33 class ClassDef;
34 class ClassList;
35 class MemberDef;
36 class OutputList;
37 class NamespaceDef;
38 class NamespaceSDict;
39 class MemberGroupSDict;
40 class PackageDef;
41 class DirDef;
42 class FTextStream;
43 
44 /** Class representing the data associated with a \#include statement. */
46 {
51  bool local;
52  bool imported;
53  bool indirect;
54 };
55 
56 /** A model of a file symbol.
57  *
58  * An object of this class contains all file information that is gathered.
59  * This includes the members and compounds defined in the file.
60  *
61  * The member writeDocumentation() can be used to generate the page of
62  * documentation to HTML and LaTeX.
63  */
64 class FileDef : public Definition
65 {
66  friend class FileName;
67 
68  public:
69  //enum FileType { Source, Header, Unknown };
70 
71  FileDef(const char *p,const char *n,const char *ref=0,const char *dn=0);
72  ~FileDef();
73 
74  // ----------------------------------------------------------------------
75 
76  DefType definitionType() const { return TypeFile; }
77 
78  /*! Returns the unique file name (this may include part of the path). */
79  QCString name() const;
80  QCString displayName(bool=TRUE) const { return name(); }
81  QCString fileName() const { return m_fileName; }
82 
84  { return convertNameToFile(m_diskName); }
85 
86  QCString anchor() const { return QCString(); }
87 
88  QCString getFileBase() const { return m_diskName; }
89 
90  QCString getSourceFileBase() const;
91 
92  /*! Returns the name of the verbatim copy of this file (if any). */
93  QCString includeName() const;
94 
95  /*! Returns the absolute path including the file name. */
96  QCString absFilePath() const { return m_filePath; }
97 
98  /*! Returns the name as it is used in the documentation */
99  const QCString &docName() const { return m_docname; }
100 
101  /*! Returns TRUE if this file is a source file. */
102  bool isSource() const { return m_isSource; }
103 
104  bool isDocumentationFile() const;
105 
106  Definition *getSourceDefinition(int lineNr) const;
107  MemberDef *getSourceMember(int lineNr) const;
108 
109  /*! Returns the absolute path of this file. */
110  QCString getPath() const { return m_path; }
111 
112  /*! Returns version of this file. */
113  QCString getVersion() const { return m_fileVersion; }
114 
115  bool isLinkableInProject() const;
116 
117  bool isLinkable() const { return isLinkableInProject() || isReference(); }
118  bool isIncluded(const QCString &name) const;
119 
120  PackageDef *packageDef() const { return m_package; }
121  DirDef *getDirDef() const { return m_dir; }
122  NamespaceSDict *getUsedNamespaces() const;
123  SDict<Definition> *getUsedClasses() const { return m_usingDeclList; }
124  QList<IncludeInfo> *includeFileList() const { return m_includeList; }
125  QList<IncludeInfo> *includedByFileList() const { return m_includedByList; }
126  void getAllIncludeFilesRecursively(QStrList &incFiles) const;
127 
128  MemberList *getMemberList(MemberListType lt) const;
129  const QList<MemberList> &getMemberLists() const { return m_memberLists; }
130 
131  /* user defined member groups */
132  MemberGroupSDict *getMemberGroupSDict() const { return m_memberGroupSDict; }
133  NamespaceSDict *getNamespaceSDict() const { return m_namespaceSDict; }
134  ClassSDict *getClassSDict() const { return m_classSDict; }
135 
136  QCString title() const;
137  bool hasDetailedDescription() const;
138  QCString fileVersion() const;
139 
140  bool subGrouping() const { return m_subGrouping; }
141 
142  //---------------------------------
143 
144  void addSourceRef(int line,Definition *d,MemberDef *md);
145 
146  void writeDocumentation(OutputList &ol);
147  void writeMemberPages(OutputList &ol);
148  void writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const;
149  void writeSummaryLinks(OutputList &ol);
150  void writeTagFile(FTextStream &t);
151 
152  void startParsing();
153  void writeSource(OutputList &ol,bool sameTu,QStrList &filesInSameTu);
154  void parseSource(bool sameTu,QStrList &filesInSameTu);
155  void finishParsing();
156 
157  friend void generatedFileNames();
158  void insertMember(MemberDef *md);
159  void insertClass(ClassDef *cd);
160  void insertNamespace(NamespaceDef *nd);
161  void computeAnchors();
162 
163  void setPackageDef(PackageDef *pd) { m_package=pd; }
164  void setDirDef(DirDef *dd) { m_dir=dd; }
165 
167  void addUsingDeclaration(Definition *def);
168  void combineUsingRelations();
169 
170  bool generateSourceFile() const;
171  void sortMemberLists();
172 
173  void addIncludeDependency(FileDef *fd,const char *incName,bool local,bool imported,bool indirect);
174  void addIncludedByDependency(FileDef *fd,const char *incName,bool local,bool imported);
175 
179  void addIncludedUsingDirectives();
180 
181  void addListReferences();
182  //bool includes(FileDef *incFile,QDict<FileDef> *includedFiles) const;
183  //bool includesByName(const QCString &name) const;
184  bool visited;
185 
186  protected:
187  /**
188  * Retrieves the file version from version control system.
189  */
190  void acquireFileVersion();
191 
192  private:
193  MemberList *createMemberList(MemberListType lt);
194  void addMemberToList(MemberListType lt,MemberDef *md);
195  void writeMemberDeclarations(OutputList &ol,MemberListType lt,const QCString &title);
196  void writeMemberDocumentation(OutputList &ol,MemberListType lt,const QCString &title);
197  void writeIncludeFiles(OutputList &ol);
198  void writeIncludeGraph(OutputList &ol);
199  void writeIncludedByGraph(OutputList &ol);
200  void writeMemberGroups(OutputList &ol);
201  void writeAuthorSection(OutputList &ol);
202  void writeSourceLink(OutputList &ol);
203  void writeNamespaceDeclarations(OutputList &ol,const QCString &title,
204  bool isConstantGroup);
205  void writeClassDeclarations(OutputList &ol,const QCString &title);
206  void writeInlineClasses(OutputList &ol);
207  void startMemberDeclarations(OutputList &ol);
208  void endMemberDeclarations(OutputList &ol);
209  void startMemberDocumentation(OutputList &ol);
210  void endMemberDocumentation(OutputList &ol);
211  void writeDetailedDescription(OutputList &ol,const QCString &title);
212  void writeBriefDescription(OutputList &ol);
213 
214  QDict<IncludeInfo> *m_includeDict;
216  QDict<IncludeInfo> *m_includedByDict;
229  PackageDef *m_package;
236 };
237 
238 /** Class representing a list of FileDef objects. */
239 class FileList : public QList<FileDef>
240 {
241  public:
242  FileList() : m_pathName("tmp") {}
243  FileList(const char *path) : QList<FileDef>(), m_pathName(path) {}
245  QCString path() const { return m_pathName; }
246  private:
247  int compareValues(const FileDef *md1,const FileDef *md2) const
248  {
249  return qstricmp(md1->name(),md2->name());
250  }
252 };
253 
254 class OutputNameList : public QList<FileList>
255 {
256  public:
259  private:
260  int compareValues(const FileList *fl1,const FileList *fl2) const
261  {
262  return qstricmp(fl1->path(),fl2->path());
263  }
264 };
265 
266 class OutputNameDict : public QDict<FileList>
267 {
268  public:
269  OutputNameDict(int size) : QDict<FileList>(size) {}
271 };
272 
273 class Directory;
274 
275 /** Class representing an entry (file or sub directory) in a directory */
276 class DirEntry
277 {
278  public:
279  enum EntryKind { Dir, File };
281  : m_parent(parent), m_name(fd->name()), m_kind(File), m_fd(fd),
282  m_isLast(FALSE) { }
284  : m_parent(parent), m_name(name), m_kind(Dir),
285  m_fd(0), m_isLast(FALSE) { }
286  virtual ~DirEntry() { }
287  EntryKind kind() const { return m_kind; }
288  FileDef *file() const { return m_fd; }
289  bool isLast() const { return m_isLast; }
290  void setLast(bool b) { m_isLast=b; }
291  DirEntry *parent() const { return m_parent; }
292  QCString name() const { return m_name; }
293  QCString path() const { return parent() ? parent()->path()+"/"+name() : name(); }
294 
295  protected:
298 
299  private:
302  bool m_isLast;
303 };
304 
305 /** Class representing a directory tree of DirEntry objects. */
306 class Directory : public DirEntry
307 {
308  public:
310  : DirEntry(parent,name)
311  { m_children.setAutoDelete(TRUE); }
312  virtual ~Directory() {}
313  void addChild(DirEntry *d) { m_children.append(d); d->setLast(TRUE); }
314  QList<DirEntry> &children() { return m_children; }
315  void rename(const QCString &name) { m_name=name; }
316  void reParent(Directory *parent) { m_parent=parent; }
317 
318  private:
320 };
321 
322 void generateFileTree();
323 
324 #endif
325 
static QCString name
Definition: declinfo.cpp:673
QCString anchor() const
Definition: filedef.h:86
virtual ~Directory()
Definition: filedef.h:312
virtual ~DirEntry()
Definition: filedef.h:286
bool m_isSource
Definition: filedef.h:227
QCString path() const
Definition: filedef.h:245
ClassSDict * getClassSDict() const
Definition: filedef.h:134
DirEntry * parent() const
Definition: filedef.h:291
OutputNameDict(int size)
Definition: filedef.h:269
QDict< IncludeInfo > * m_includeDict
Definition: filedef.h:214
bool isLinkable() const
Definition: filedef.h:117
~FileList()
Definition: filedef.h:244
~IncludeInfo()
Definition: filedef.h:48
QCString displayName(bool=TRUE) const
Definition: filedef.h:80
static void sortMemberLists()
Definition: doxygen.cpp:8066
QCString m_fileName
Definition: filedef.h:223
bool subGrouping() const
Definition: filedef.h:140
QCString m_docname
Definition: filedef.h:224
QCString m_path
Definition: filedef.h:220
Directory(Directory *parent, const QCString &name)
Definition: filedef.h:309
bool isSource() const
Definition: filedef.h:102
EntryKind m_kind
Definition: filedef.h:300
bool visited
Definition: filedef.h:184
const bool FALSE
Definition: qglobal.h:370
int compareValues(const FileList *fl1, const FileList *fl2) const
Definition: filedef.h:260
DirEntry(DirEntry *parent, FileDef *fd)
Definition: filedef.h:280
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
DirDef * getDirDef() const
Definition: filedef.h:121
QCString getFileBase() const
Definition: filedef.h:88
FileList()
Definition: filedef.h:242
PackageDef * m_package
Definition: filedef.h:229
static void combineUsingRelations()
Definition: doxygen.cpp:8184
QList< MemberList > m_memberLists
Definition: filedef.h:231
MemberGroupSDict * m_memberGroupSDict
Definition: filedef.h:232
bool isLast() const
Definition: filedef.h:289
QIntDict< Definition > * m_srcDefDict
Definition: filedef.h:225
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
QIntDict< MemberDef > * m_srcMemberDict
Definition: filedef.h:226
bool indirect
Definition: filedef.h:53
static void addMembersToMemberGroup()
Definition: doxygen.cpp:8223
QCString m_filePath
Definition: filedef.h:221
FileList(const char *path)
Definition: filedef.h:243
NamespaceSDict * getNamespaceSDict() const
Definition: filedef.h:133
int qstricmp(const char *str1, const char *str2)
Definition: qcstring.cpp:567
static void findSectionsInDocumentation()
Definition: doxygen.cpp:8301
ClassSDict * m_classSDict
Definition: filedef.h:234
QCString name() const
Definition: filedef.cpp:1193
SDict< Definition > * m_usingDeclList
Definition: filedef.h:219
QList< IncludeInfo > * includeFileList() const
Definition: filedef.h:124
std::void_t< T > n
NamespaceSDict * m_usingDirList
Definition: filedef.h:218
static void addListReferences()
Definition: doxygen.cpp:5192
void setLast(bool b)
Definition: filedef.h:290
bool m_isLast
Definition: filedef.h:302
static void distributeMemberGroupDocumentation()
Definition: doxygen.cpp:8262
p
Definition: test.py:223
NamespaceSDict * m_namespaceSDict
Definition: filedef.h:233
QCString name() const
Definition: filedef.h:292
Definition: dirdef.h:44
const QList< MemberList > & getMemberLists() const
Definition: filedef.h:129
IncludeInfo()
Definition: filedef.h:47
bool imported
Definition: filedef.h:52
QCString includeName
Definition: filedef.h:50
static void writeTagFile()
Definition: doxygen.cpp:10604
void rename(const QCString &name)
Definition: filedef.h:315
bool m_subGrouping
Definition: filedef.h:235
SDict< Definition > * getUsedClasses() const
Definition: filedef.h:123
FileDef * file() const
Definition: filedef.h:288
QCString absFilePath() const
Definition: filedef.h:96
PackageDef * packageDef() const
Definition: filedef.h:120
QCString getOutputFileBase() const
Definition: filedef.h:83
QList< IncludeInfo > * m_includedByList
Definition: filedef.h:217
bool local
Definition: filedef.h:51
FileDef * fileDef
Definition: filedef.h:49
void generateFileTree()
Definition: filedef.cpp:1664
DefType definitionType() const
Definition: filedef.h:76
QCString m_name
Definition: filedef.h:297
QList< IncludeInfo > * includedByFileList() const
Definition: filedef.h:125
void setPackageDef(PackageDef *pd)
Definition: filedef.h:163
QList< DirEntry > m_children
Definition: filedef.h:319
QCString m_pathName
Definition: filedef.h:251
QCString getPath() const
Definition: filedef.h:110
QCString fileName() const
Definition: filedef.h:81
void line(double t, double *p, double &x, double &y, double &z)
static void addUsingDirective(const char *name)
Definition: code.cpp:11194
QCString convertNameToFile(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:5354
MemberGroupSDict * getMemberGroupSDict() const
Definition: filedef.h:132
QDict< IncludeInfo > * m_includedByDict
Definition: filedef.h:216
void addChild(DirEntry *d)
Definition: filedef.h:313
static bool * b
Definition: config.cpp:1043
FileDef * m_fd
Definition: filedef.h:301
static void getAllIncludeFilesRecursively(QDict< void > *filesVisited, const FileDef *fd, QStrList &incFiles)
Definition: filedef.cpp:1883
MemberListType
Definition: types.h:104
QCString m_fileVersion
Definition: filedef.h:228
QList< IncludeInfo > * m_includeList
Definition: filedef.h:215
EntryKind kind() const
Definition: filedef.h:287
DirEntry * m_parent
Definition: filedef.h:296
void setDirDef(DirDef *dd)
Definition: filedef.h:164
QList< DirEntry > & children()
Definition: filedef.h:314
DirEntry(DirEntry *parent, QCString name)
Definition: filedef.h:283
DirDef * m_dir
Definition: filedef.h:230
int compareValues(const FileDef *md1, const FileDef *md2) const
Definition: filedef.h:247
const QCString & docName() const
Definition: filedef.h:99
void reParent(Directory *parent)
Definition: filedef.h:316
def parent(G, child, parent_type)
Definition: graph.py:67
const bool TRUE
Definition: qglobal.h:371
QCString getVersion() const
Definition: filedef.h:113
QCString path() const
Definition: filedef.h:293
QCString m_diskName
Definition: filedef.h:222