|
1 /****************************************************************************** |
|
2 * |
|
3 * |
|
4 * |
|
5 * Copyright (C) 1997-2008 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 "config.h" |
|
26 #include "definition.h" |
|
27 #include "memberlist.h" |
|
28 #include "util.h" |
|
29 |
|
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 |
|
43 struct IncludeInfo |
|
44 { |
|
45 IncludeInfo() { fileDef=0; local=FALSE; } |
|
46 ~IncludeInfo() {} |
|
47 FileDef *fileDef; |
|
48 QCString includeName; |
|
49 bool local; |
|
50 bool imported; |
|
51 }; |
|
52 |
|
53 /*! \class FileDef filedef.h |
|
54 \brief A File definition. |
|
55 |
|
56 An object of this class contains all file information that is gathered. |
|
57 This includes the members and compounds defined in the file. |
|
58 |
|
59 The member writeDocumentation() can be used to generate the page of |
|
60 documentation to HTML and LaTeX. |
|
61 */ |
|
62 |
|
63 class FileDef : public Definition |
|
64 { |
|
65 friend class FileName; |
|
66 |
|
67 public: |
|
68 //enum FileType { Source, Header, Unknown }; |
|
69 |
|
70 FileDef(const char *p,const char *n,const char *ref=0,const char *dn=0); |
|
71 ~FileDef(); |
|
72 DefType definitionType() const { return TypeFile; } |
|
73 |
|
74 /*! Returns the unique file name (this may include part of the path). */ |
|
75 QCString name() const |
|
76 { |
|
77 if (Config_getBool("FULL_PATH_NAMES")) |
|
78 return filename; |
|
79 else |
|
80 return Definition::name(); |
|
81 } |
|
82 |
|
83 QCString fileName() const |
|
84 { |
|
85 return filename; |
|
86 } |
|
87 |
|
88 QCString getOutputFileBase() const |
|
89 { return convertNameToFile(diskname); } |
|
90 |
|
91 QCString getFileBase() const |
|
92 { return diskname; } |
|
93 |
|
94 QCString getSourceFileBase() const; |
|
95 |
|
96 /*! Returns the name of the verbatim copy of this file (if any). */ |
|
97 QCString includeName() const; |
|
98 |
|
99 /*! Returns the absolute path including the file name. */ |
|
100 QCString absFilePath() const { return filepath; } |
|
101 |
|
102 |
|
103 /*! Returns the name as it is used in the documentation */ |
|
104 QCString docName() const { return docname; } |
|
105 |
|
106 void addSourceRef(int line,Definition *d,MemberDef *md); |
|
107 Definition *getSourceDefinition(int lineNr); |
|
108 MemberDef *getSourceMember(int lineNr); |
|
109 |
|
110 /* Sets the name of the include file to \a n. */ |
|
111 //void setIncludeName(const char *n_) { incName=n_; } |
|
112 |
|
113 /*! Returns the absolute path of this file. */ |
|
114 QCString getPath() const { return path; } |
|
115 |
|
116 /*! Returns version of this file. */ |
|
117 QCString getVersion() const { return fileVersion; } |
|
118 |
|
119 bool isLinkableInProject() const; |
|
120 |
|
121 bool isLinkable() const |
|
122 { |
|
123 return isLinkableInProject() || isReference(); |
|
124 } |
|
125 bool isIncluded(const QCString &name) const; |
|
126 |
|
127 bool isJava() const { return m_isJava; } |
|
128 |
|
129 void writeDocumentation(OutputList &ol); |
|
130 void writeMemberPages(OutputList &ol); |
|
131 void writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const; |
|
132 |
|
133 void writeSource(OutputList &ol); |
|
134 void parseSource(); |
|
135 friend void generatedFileNames(); |
|
136 void insertMember(MemberDef *md); |
|
137 void insertClass(ClassDef *cd); |
|
138 void insertNamespace(NamespaceDef *nd); |
|
139 void computeAnchors(); |
|
140 |
|
141 void setPackageDef(PackageDef *pd) { package=pd; } |
|
142 PackageDef *packageDef() const { return package; } |
|
143 |
|
144 void setDirDef(DirDef *dd) { dir=dd; } |
|
145 DirDef *getDirDef() const { return dir; } |
|
146 |
|
147 void addUsingDirective(NamespaceDef *nd); |
|
148 NamespaceSDict *getUsedNamespaces() const; |
|
149 void addUsingDeclaration(Definition *def); |
|
150 SDict<Definition> *getUsedClasses() const { return usingDeclList; } |
|
151 void combineUsingRelations(); |
|
152 |
|
153 bool generateSourceFile() const; |
|
154 |
|
155 void addIncludeDependency(FileDef *fd,const char *incName,bool local,bool imported); |
|
156 void addIncludedByDependency(FileDef *fd,const char *incName,bool local,bool imported); |
|
157 QList<IncludeInfo> *includeFileList() const { return includeList; } |
|
158 QList<IncludeInfo> *includedByFileList() const { return includedByList; } |
|
159 |
|
160 void addMembersToMemberGroup(); |
|
161 void distributeMemberGroupDocumentation(); |
|
162 void findSectionsInDocumentation(); |
|
163 void addIncludedUsingDirectives(); |
|
164 |
|
165 void addListReferences(); |
|
166 bool isDocumentationFile() const; |
|
167 |
|
168 MemberList *getMemberList(MemberList::ListType lt) const; |
|
169 const QList<MemberList> &getMemberLists() const { return m_memberLists; } |
|
170 |
|
171 /* user defined member groups */ |
|
172 MemberGroupSDict *getMemberGroupSDict() const { return memberGroupSDict; } |
|
173 NamespaceSDict *getNamespaceSDict() const { return namespaceSDict; } |
|
174 ClassSDict *getClassSDict() const { return classSDict; } |
|
175 |
|
176 bool visited; |
|
177 |
|
178 protected: |
|
179 /** |
|
180 * Retrieves the file version from version control system. |
|
181 */ |
|
182 void acquireFileVersion(); |
|
183 |
|
184 private: |
|
185 MemberList *createMemberList(MemberList::ListType lt); |
|
186 void addMemberToList(MemberList::ListType lt,MemberDef *md); |
|
187 void writeMemberDeclarations(OutputList &ol,MemberList::ListType lt,const QCString &title); |
|
188 void writeMemberDocumentation(OutputList &ol,MemberList::ListType lt,const QCString &title); |
|
189 void writeIncludeFiles(OutputList &ol); |
|
190 void writeIncludeGraph(OutputList &ol); |
|
191 void writeIncludedByGraph(OutputList &ol); |
|
192 void writeMemberGroups(OutputList &ol); |
|
193 void writeAuthorSection(OutputList &ol); |
|
194 void writeSourceLink(OutputList &ol); |
|
195 void writeNamespaceDeclarations(OutputList &ol,const QCString &title); |
|
196 void writeClassDeclarations(OutputList &ol,const QCString &title); |
|
197 void startMemberDeclarations(OutputList &ol); |
|
198 void endMemberDeclarations(OutputList &ol); |
|
199 void startMemberDocumentation(OutputList &ol); |
|
200 void endMemberDocumentation(OutputList &ol); |
|
201 void writeDetailedDescription(OutputList &ol,const QCString &title); |
|
202 void writeBriefDescription(OutputList &ol); |
|
203 |
|
204 QDict<IncludeInfo> *includeDict; |
|
205 QList<IncludeInfo> *includeList; |
|
206 QDict<IncludeInfo> *includedByDict; |
|
207 QList<IncludeInfo> *includedByList; |
|
208 NamespaceSDict *usingDirList; |
|
209 SDict<Definition> *usingDeclList; |
|
210 QCString path; |
|
211 QCString filepath; |
|
212 QCString diskname; |
|
213 QCString filename; |
|
214 QCString docname; |
|
215 QIntDict<Definition> *srcDefDict; |
|
216 QIntDict<MemberDef> *srcMemberDict; |
|
217 bool isSource; |
|
218 bool m_isJava; |
|
219 QCString fileVersion; |
|
220 PackageDef *package; |
|
221 DirDef *dir; |
|
222 QList<MemberList> m_memberLists; |
|
223 MemberGroupSDict *memberGroupSDict; |
|
224 NamespaceSDict *namespaceSDict; |
|
225 ClassSDict *classSDict; |
|
226 bool m_subGrouping; |
|
227 }; |
|
228 |
|
229 |
|
230 class FileList : public QList<FileDef> |
|
231 { |
|
232 public: |
|
233 FileList() : m_pathName("tmp") {} |
|
234 FileList(const char *path) : QList<FileDef>(), m_pathName(path) {} |
|
235 ~FileList() {} |
|
236 QCString path() const { return m_pathName; } |
|
237 int compareItems(GCI item1,GCI item2) |
|
238 { |
|
239 FileDef *md1 = (FileDef *)item1; |
|
240 FileDef *md2 = (FileDef *)item2; |
|
241 return stricmp(md1->name(),md2->name()); |
|
242 } |
|
243 private: |
|
244 QCString m_pathName; |
|
245 }; |
|
246 |
|
247 class OutputNameList : public QList<FileList> |
|
248 { |
|
249 public: |
|
250 OutputNameList() : QList<FileList>() {} |
|
251 ~OutputNameList() {} |
|
252 int compareItems(GCI item1,GCI item2) |
|
253 { |
|
254 FileList *fl1 = (FileList *)item1; |
|
255 FileList *fl2 = (FileList *)item2; |
|
256 return stricmp(fl1->path(),fl2->path()); |
|
257 } |
|
258 }; |
|
259 |
|
260 class OutputNameDict : public QDict<FileList> |
|
261 { |
|
262 public: |
|
263 OutputNameDict(int size) : QDict<FileList>(size) {} |
|
264 ~OutputNameDict() {} |
|
265 }; |
|
266 |
|
267 class Directory; |
|
268 |
|
269 class DirEntry |
|
270 { |
|
271 public: |
|
272 enum EntryKind { Dir, File }; |
|
273 DirEntry(DirEntry *parent,FileDef *fd) |
|
274 : m_parent(parent), m_name(fd->name()), m_kind(File), m_fd(fd), |
|
275 m_isLast(FALSE) { } |
|
276 DirEntry(DirEntry *parent,QCString name) |
|
277 : m_parent(parent), m_name(name), m_kind(Dir), |
|
278 m_fd(0), m_isLast(FALSE) { } |
|
279 virtual ~DirEntry() { } |
|
280 EntryKind kind() const { return m_kind; } |
|
281 FileDef *file() const { return m_fd; } |
|
282 bool isLast() const { return m_isLast; } |
|
283 void setLast(bool b) { m_isLast=b; } |
|
284 DirEntry *parent() const { return m_parent; } |
|
285 QCString name() const { return m_name; } |
|
286 QCString path() const { return parent() ? parent()->path()+"/"+name() : name(); } |
|
287 |
|
288 protected: |
|
289 DirEntry *m_parent; |
|
290 QCString m_name; |
|
291 |
|
292 private: |
|
293 EntryKind m_kind; |
|
294 FileDef *m_fd; |
|
295 int num; |
|
296 bool m_isLast; |
|
297 }; |
|
298 |
|
299 class Directory : public DirEntry |
|
300 { |
|
301 public: |
|
302 Directory(Directory *parent,const QCString &name) |
|
303 : DirEntry(parent,name) |
|
304 { m_children.setAutoDelete(TRUE); } |
|
305 virtual ~Directory() {} |
|
306 void addChild(DirEntry *d) { m_children.append(d); d->setLast(TRUE); } |
|
307 QList<DirEntry> &children() { return m_children; } |
|
308 void rename(const QCString &name) { m_name=name; } |
|
309 void reParent(Directory *parent) { m_parent=parent; } |
|
310 |
|
311 private: |
|
312 QList<DirEntry> m_children; |
|
313 }; |
|
314 |
|
315 //void generateFileTree(QTextStream &t); |
|
316 void generateFileTree(); |
|
317 |
|
318 #endif |
|
319 |