1 /******************************************************************************
3 * $Id: filedef.h,v 1.32 2001/03/19 19:27:40 root Exp $
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
26 #include "definition.h"
27 #include "memberlist.h"
39 class MemberGroupSDict;
43 /** Class representing the data associated with a \#include statement. */
46 IncludeInfo() { fileDef=0; local=FALSE; indirect=FALSE; }
55 /** A model of a file symbol.
57 * An object of this class contains all file information that is gathered.
58 * This includes the members and compounds defined in the file.
60 * The member writeDocumentation() can be used to generate the page of
61 * documentation to HTML and LaTeX.
63 class FileDef : public Definition
65 friend class FileName;
68 //enum FileType { Source, Header, Unknown };
70 FileDef(const char *p,const char *n,const char *ref=0,const char *dn=0);
72 DefType definitionType() const { return TypeFile; }
74 /*! Returns the unique file name (this may include part of the path). */
77 if (Config_getBool("FULL_PATH_NAMES"))
80 return Definition::name();
82 QCString displayName(bool=TRUE) const { return name(); }
83 QCString fileName() const { return filename; }
85 QCString getOutputFileBase() const
86 { return convertNameToFile(diskname); }
87 QCString anchor() const
88 { return QCString(); }
90 QCString getFileBase() const
93 QCString getSourceFileBase() const;
95 /*! Returns the name of the verbatim copy of this file (if any). */
96 QCString includeName() const;
98 /*! Returns the absolute path including the file name. */
99 QCString absFilePath() const { return filepath; }
102 /*! Returns the name as it is used in the documentation */
103 QCString docName() const { return docname; }
105 void addSourceRef(int line,Definition *d,MemberDef *md);
106 Definition *getSourceDefinition(int lineNr);
107 MemberDef *getSourceMember(int lineNr);
109 /* Sets the name of the include file to \a n. */
110 //void setIncludeName(const char *n_) { incName=n_; }
112 /*! Returns the absolute path of this file. */
113 QCString getPath() const { return path; }
115 /*! Returns version of this file. */
116 QCString getVersion() const { return fileVersion; }
118 bool isLinkableInProject() const;
120 bool isLinkable() const
122 return isLinkableInProject() || isReference();
124 bool isIncluded(const QCString &name) const;
126 //bool isJava() const { return m_isJava; }
127 //bool isCSharp() const { return m_isCSharp; }
129 void writeDocumentation(OutputList &ol);
130 void writeMemberPages(OutputList &ol);
131 void writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const;
132 void writeSummaryLinks(OutputList &ol);
134 void writeSource(OutputList &ol);
136 friend void generatedFileNames();
137 void insertMember(MemberDef *md);
138 void insertClass(ClassDef *cd);
139 void insertNamespace(NamespaceDef *nd);
140 void computeAnchors();
142 void setPackageDef(PackageDef *pd) { package=pd; }
143 PackageDef *packageDef() const { return package; }
145 void setDirDef(DirDef *dd) { dir=dd; }
146 DirDef *getDirDef() const { return dir; }
148 void addUsingDirective(NamespaceDef *nd);
149 NamespaceSDict *getUsedNamespaces() const;
150 void addUsingDeclaration(Definition *def);
151 SDict<Definition> *getUsedClasses() const { return usingDeclList; }
152 void combineUsingRelations();
154 bool generateSourceFile() const;
155 void sortMemberLists();
157 void addIncludeDependency(FileDef *fd,const char *incName,bool local,bool imported,bool indirect);
158 void addIncludedByDependency(FileDef *fd,const char *incName,bool local,bool imported);
159 QList<IncludeInfo> *includeFileList() const { return includeList; }
160 QList<IncludeInfo> *includedByFileList() const { return includedByList; }
162 void addMembersToMemberGroup();
163 void distributeMemberGroupDocumentation();
164 void findSectionsInDocumentation();
165 void addIncludedUsingDirectives();
167 void addListReferences();
168 bool isDocumentationFile() const;
169 //bool includes(FileDef *incFile,QDict<FileDef> *includedFiles) const;
170 //bool includesByName(const QCString &name) const;
172 MemberList *getMemberList(MemberList::ListType lt) const;
173 const QList<MemberList> &getMemberLists() const { return m_memberLists; }
175 /* user defined member groups */
176 MemberGroupSDict *getMemberGroupSDict() const { return memberGroupSDict; }
177 NamespaceSDict *getNamespaceSDict() const { return namespaceSDict; }
178 ClassSDict *getClassSDict() const { return classSDict; }
184 * Retrieves the file version from version control system.
186 void acquireFileVersion();
189 MemberList *createMemberList(MemberList::ListType lt);
190 void addMemberToList(MemberList::ListType lt,MemberDef *md);
191 void writeMemberDeclarations(OutputList &ol,MemberList::ListType lt,const QCString &title);
192 void writeMemberDocumentation(OutputList &ol,MemberList::ListType lt,const QCString &title);
193 void writeIncludeFiles(OutputList &ol);
194 void writeIncludeGraph(OutputList &ol);
195 void writeIncludedByGraph(OutputList &ol);
196 void writeMemberGroups(OutputList &ol);
197 void writeAuthorSection(OutputList &ol);
198 void writeSourceLink(OutputList &ol);
199 void writeNamespaceDeclarations(OutputList &ol,const QCString &title);
200 void writeClassDeclarations(OutputList &ol,const QCString &title);
201 void writeInlineClasses(OutputList &ol);
202 void startMemberDeclarations(OutputList &ol);
203 void endMemberDeclarations(OutputList &ol);
204 void startMemberDocumentation(OutputList &ol);
205 void endMemberDocumentation(OutputList &ol);
206 void writeDetailedDescription(OutputList &ol,const QCString &title);
207 void writeBriefDescription(OutputList &ol);
209 QDict<IncludeInfo> *includeDict;
210 QList<IncludeInfo> *includeList;
211 QDict<IncludeInfo> *includedByDict;
212 QList<IncludeInfo> *includedByList;
213 NamespaceSDict *usingDirList;
214 SDict<Definition> *usingDeclList;
220 QIntDict<Definition> *srcDefDict;
221 QIntDict<MemberDef> *srcMemberDict;
223 QCString fileVersion;
226 QList<MemberList> m_memberLists;
227 MemberGroupSDict *memberGroupSDict;
228 NamespaceSDict *namespaceSDict;
229 ClassSDict *classSDict;
233 /** Class representing a list of FileDef objects. */
234 class FileList : public QList<FileDef>
237 FileList() : m_pathName("tmp") {}
238 FileList(const char *path) : QList<FileDef>(), m_pathName(path) {}
240 QCString path() const { return m_pathName; }
241 int compareItems(GCI item1,GCI item2)
243 FileDef *md1 = (FileDef *)item1;
244 FileDef *md2 = (FileDef *)item2;
245 return stricmp(md1->name(),md2->name());
251 class OutputNameList : public QList<FileList>
254 OutputNameList() : QList<FileList>() {}
256 int compareItems(GCI item1,GCI item2)
258 FileList *fl1 = (FileList *)item1;
259 FileList *fl2 = (FileList *)item2;
260 return stricmp(fl1->path(),fl2->path());
264 class OutputNameDict : public QDict<FileList>
267 OutputNameDict(int size) : QDict<FileList>(size) {}
273 /** Class representing an entry (file or sub directory) in a directory */
277 enum EntryKind { Dir, File };
278 DirEntry(DirEntry *parent,FileDef *fd)
279 : m_parent(parent), m_name(fd->name()), m_kind(File), m_fd(fd),
281 DirEntry(DirEntry *parent,QCString name)
282 : m_parent(parent), m_name(name), m_kind(Dir),
283 m_fd(0), m_isLast(FALSE) { }
284 virtual ~DirEntry() { }
285 EntryKind kind() const { return m_kind; }
286 FileDef *file() const { return m_fd; }
287 bool isLast() const { return m_isLast; }
288 void setLast(bool b) { m_isLast=b; }
289 DirEntry *parent() const { return m_parent; }
290 QCString name() const { return m_name; }
291 QCString path() const { return parent() ? parent()->path()+"/"+name() : name(); }
304 /** Class representing a directory tree of DirEntry objects. */
305 class Directory : public DirEntry
308 Directory(Directory *parent,const QCString &name)
309 : DirEntry(parent,name)
310 { m_children.setAutoDelete(TRUE); }
311 virtual ~Directory() {}
312 void addChild(DirEntry *d) { m_children.append(d); d->setLast(TRUE); }
313 QList<DirEntry> &children() { return m_children; }
314 void rename(const QCString &name) { m_name=name; }
315 void reParent(Directory *parent) { m_parent=parent; }
318 QList<DirEntry> m_children;
321 void generateFileTree();