1 /******************************************************************************
5 * Copyright (C) 1997-2015 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.
25 #include "definition.h"
27 #include "memberlist.h"
39 class MemberGroupSDict;
44 /** Class representing the data associated with a \#include statement. */
47 IncludeInfo() : fileDef(0), local(FALSE), imported(FALSE), indirect(FALSE) {}
56 /** A model of a file symbol.
58 * An object of this class contains all file information that is gathered.
59 * This includes the members and compounds defined in the file.
61 * The member writeDocumentation() can be used to generate the page of
62 * documentation to HTML and LaTeX.
64 class FileDef : public Definition
67 //enum FileType { Source, Header, Unknown };
69 FileDef(const char *p,const char *n,const char *ref=0,const char *dn=0);
72 // ----------------------------------------------------------------------
74 DefType definitionType() const { return TypeFile; }
76 /*! Returns the unique file name (this may include part of the path). */
77 QCString name() const;
78 QCString displayName(bool=TRUE) const { return name(); }
79 QCString fileName() const { return m_fileName; }
81 QCString getOutputFileBase() const;
83 QCString anchor() const { return QCString(); }
85 QCString getSourceFileBase() const;
87 /*! Returns the name of the verbatim copy of this file (if any). */
88 QCString includeName() const;
90 QCString includeDependencyGraphFileName() const;
92 QCString includedByDependencyGraphFileName() const;
94 /*! Returns the absolute path including the file name. */
95 QCString absFilePath() const { return m_filePath; }
97 /*! Returns the name as it is used in the documentation */
98 const QCString &docName() const { return m_docname; }
100 /*! Returns TRUE if this file is a source file. */
101 bool isSource() const { return m_isSource; }
103 bool isDocumentationFile() const;
105 Definition *getSourceDefinition(int lineNr) const;
106 MemberDef *getSourceMember(int lineNr) const;
108 /*! Returns the absolute path of this file. */
109 QCString getPath() const { return m_path; }
111 /*! Returns version of this file. */
112 QCString getVersion() const { return m_fileVersion; }
114 bool isLinkableInProject() const;
116 bool isLinkable() const { return isLinkableInProject() || isReference(); }
117 bool isIncluded(const QCString &name) const;
119 PackageDef *packageDef() const { return m_package; }
120 DirDef *getDirDef() const { return m_dir; }
121 NamespaceSDict *getUsedNamespaces() const;
122 SDict<Definition> *getUsedClasses() const { return m_usingDeclList; }
123 QList<IncludeInfo> *includeFileList() const { return m_includeList; }
124 QList<IncludeInfo> *includedByFileList() const { return m_includedByList; }
125 void getAllIncludeFilesRecursively(QStrList &incFiles) const;
127 MemberList *getMemberList(MemberListType lt) const;
128 const QList<MemberList> &getMemberLists() const { return m_memberLists; }
130 /* user defined member groups */
131 MemberGroupSDict *getMemberGroupSDict() const { return m_memberGroupSDict; }
132 NamespaceSDict *getNamespaceSDict() const { return m_namespaceSDict; }
133 ClassSDict *getClassSDict() const { return m_classSDict; }
135 QCString title() const;
136 bool hasDetailedDescription() const;
137 QCString fileVersion() const;
139 bool subGrouping() const { return m_subGrouping; }
141 //---------------------------------
143 void addSourceRef(int line,Definition *d,MemberDef *md);
145 void writeDocumentation(OutputList &ol);
146 void writeMemberPages(OutputList &ol);
147 void writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const;
148 void writeSummaryLinks(OutputList &ol);
149 void writeTagFile(FTextStream &t);
152 void writeSource(OutputList &ol,bool sameTu,QStrList &filesInSameTu);
153 void parseSource(bool sameTu,QStrList &filesInSameTu);
154 void finishParsing();
155 void setDiskName(const QCString &name);
157 void insertMember(MemberDef *md);
158 void insertClass(ClassDef *cd);
159 void insertNamespace(NamespaceDef *nd);
160 void computeAnchors();
162 void setPackageDef(PackageDef *pd) { m_package=pd; }
163 void setDirDef(DirDef *dd) { m_dir=dd; }
165 void addUsingDirective(NamespaceDef *nd);
166 void addUsingDeclaration(Definition *def);
167 void combineUsingRelations();
169 bool generateSourceFile() const;
170 void sortMemberLists();
172 void addIncludeDependency(FileDef *fd,const char *incName,bool local,bool imported,bool indirect);
173 void addIncludedByDependency(FileDef *fd,const char *incName,bool local,bool imported);
175 void addMembersToMemberGroup();
176 void distributeMemberGroupDocumentation();
177 void findSectionsInDocumentation();
178 void addIncludedUsingDirectives();
180 void addListReferences();
181 //bool includes(FileDef *incFile,QDict<FileDef> *includedFiles) const;
182 //bool includesByName(const QCString &name) const;
187 * Retrieves the file version from version control system.
189 void acquireFileVersion();
192 MemberList *createMemberList(MemberListType lt);
193 void addMemberToList(MemberListType lt,MemberDef *md);
194 void writeMemberDeclarations(OutputList &ol,MemberListType lt,const QCString &title);
195 void writeMemberDocumentation(OutputList &ol,MemberListType lt,const QCString &title);
196 void writeIncludeFiles(OutputList &ol);
197 void writeIncludeGraph(OutputList &ol);
198 void writeIncludedByGraph(OutputList &ol);
199 void writeMemberGroups(OutputList &ol);
200 void writeAuthorSection(OutputList &ol);
201 void writeSourceLink(OutputList &ol);
202 void writeNamespaceDeclarations(OutputList &ol,const QCString &title,
203 bool isConstantGroup);
204 void writeClassDeclarations(OutputList &ol,const QCString &title,ClassSDict *d);
205 void writeInlineClasses(OutputList &ol);
206 void startMemberDeclarations(OutputList &ol);
207 void endMemberDeclarations(OutputList &ol);
208 void startMemberDocumentation(OutputList &ol);
209 void endMemberDocumentation(OutputList &ol);
210 void writeDetailedDescription(OutputList &ol,const QCString &title);
211 void writeBriefDescription(OutputList &ol);
212 void writeClassesToTagFile(FTextStream &t,ClassSDict *d);
214 QDict<IncludeInfo> *m_includeDict;
215 QList<IncludeInfo> *m_includeList;
216 QDict<IncludeInfo> *m_includedByDict;
217 QList<IncludeInfo> *m_includedByList;
218 NamespaceSDict *m_usingDirList;
219 SDict<Definition> *m_usingDeclList;
222 QCString m_inclDepFileName;
223 QCString m_inclByDepFileName;
224 QCString m_outputDiskName;
227 QIntDict<Definition> *m_srcDefDict;
228 QIntDict<MemberDef> *m_srcMemberDict;
230 QCString m_fileVersion;
231 PackageDef *m_package;
233 QList<MemberList> m_memberLists;
234 MemberGroupSDict *m_memberGroupSDict;
235 NamespaceSDict *m_namespaceSDict;
236 ClassSDict *m_classSDict;
237 ClassSDict *m_interfaceSDict;
238 ClassSDict *m_structSDict;
239 ClassSDict *m_exceptionSDict;
243 /** Class representing a list of FileDef objects. */
244 class FileList : public QList<FileDef>
247 FileList() : m_pathName("tmp") {}
248 FileList(const char *path) : QList<FileDef>(), m_pathName(path) {}
250 QCString path() const { return m_pathName; }
252 int compareValues(const FileDef *md1,const FileDef *md2) const
254 return qstricmp(md1->name(),md2->name());
259 class OutputNameList : public QList<FileList>
262 OutputNameList() : QList<FileList>() {}
265 int compareValues(const FileList *fl1,const FileList *fl2) const
267 return qstricmp(fl1->path(),fl2->path());
271 class OutputNameDict : public QDict<FileList>
274 OutputNameDict(int size) : QDict<FileList>(size) {}
280 /** Class representing an entry (file or sub directory) in a directory */
284 enum EntryKind { Dir, File };
285 DirEntry(DirEntry *parent,FileDef *fd)
286 : m_parent(parent), m_name(fd->name()), m_kind(File), m_fd(fd),
288 DirEntry(DirEntry *parent,QCString name)
289 : m_parent(parent), m_name(name), m_kind(Dir),
290 m_fd(0), m_isLast(FALSE) { }
291 virtual ~DirEntry() { }
292 EntryKind kind() const { return m_kind; }
293 FileDef *file() const { return m_fd; }
294 bool isLast() const { return m_isLast; }
295 void setLast(bool b) { m_isLast=b; }
296 DirEntry *parent() const { return m_parent; }
297 QCString name() const { return m_name; }
298 QCString path() const { return parent() ? parent()->path()+"/"+name() : name(); }
310 /** Class representing a directory tree of DirEntry objects. */
311 class Directory : public DirEntry
314 Directory(Directory *parent,const QCString &name)
315 : DirEntry(parent,name)
316 { m_children.setAutoDelete(TRUE); }
317 virtual ~Directory() {}
318 void addChild(DirEntry *d) { m_children.append(d); d->setLast(TRUE); }
319 QList<DirEntry> &children() { return m_children; }
320 void rename(const QCString &name) { m_name=name; }
321 void reParent(Directory *parent) { m_parent=parent; }
324 QList<DirEntry> m_children;
327 void generateFileTree();