1 /******************************************************************************
5 * Copyright (C) 1997-2014 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.
38 /** Data associated with a detailed description. */
46 /** Data associated with a brief description. */
55 /** Data associated with description found in the body. */
58 int startLine; //!< line number of the start of the definition
59 int endLine; //!< line number of the end of the definition
60 FileDef *fileDef; //!< file definition containing the function body
63 /** Abstract interface for a Definition or DefinitionList */
68 virtual ~DefinitionIntf() {}
69 /*! Types of derived classes */
82 /*! Use this for dynamic inspection of the type of the derived class */
83 virtual DefType definitionType() const = 0;
86 /** The common base class of all entity definitions found in the sources.
88 * This can be a class or a member function, or a file, or a namespace, etc.
89 * Use definitionType() to find which type of definition this is.
91 class Definition : public DefinitionIntf
95 /*! Create a new definition */
97 const char *defFileName,int defLine,int defColumn,
98 const char *name,const char *b=0,const char *d=0,
101 /*! Destroys the definition */
102 virtual ~Definition();
104 //-----------------------------------------------------------------------------------
105 // ---- getters -----
106 //-----------------------------------------------------------------------------------
108 /*! Returns the name of the definition */
109 const QCString& name() const { return m_name; }
111 /*! Returns the name of the definition as it appears in the output */
112 virtual QCString displayName(bool includeScope=TRUE) const = 0;
114 /*! Returns the local name without any scope qualifiers. */
115 QCString localName() const;
117 /*! Returns the fully qualified name of this definition
119 virtual QCString qualifiedName() const;
121 /*! Returns the name of this definition as it appears in the symbol map.
123 QCString symbolName() const;
125 /*! Returns the base file name (without extension) of this definition.
126 * as it is referenced to/written to disk.
128 virtual QCString getOutputFileBase() const = 0;
130 /*! Returns the anchor within a page where this item can be found */
131 virtual QCString anchor() const = 0;
133 /*! Returns the name of the source listing of this definition. */
134 virtual QCString getSourceFileBase() const;
136 /*! Returns the anchor of the source listing of this definition. */
137 virtual QCString getSourceAnchor() const;
139 /*! Returns the detailed description of this definition */
140 virtual QCString documentation() const;
142 /*! Returns the line number at which the detailed documentation was found. */
145 /*! Returns the file in which the detailed documentation block was found.
146 * This can differ from getDefFileName().
148 QCString docFile() const;
150 /*! Returns the brief description of this definition. This can include commands. */
151 virtual QCString briefDescription(bool abbreviate=FALSE) const;
153 /*! Returns a plain text version of the brief description suitable for use
156 QCString briefDescriptionAsTooltip() const;
158 /*! Returns the line number at which the brief description was found. */
159 int briefLine() const;
161 /*! Returns the documentation found inside the body of a member */
162 QCString inbodyDocumentation() const;
164 /*! Returns the file in which the in body documentation was found */
165 QCString inbodyFile() const;
167 /*! Returns the line at which the first in body documentation
169 int inbodyLine() const;
171 /*! Returns the file in which the brief description was found.
172 * This can differ from getDefFileName().
174 QCString briefFile() const;
176 /*! returns the file in which this definition was found */
177 QCString getDefFileName() const;
179 /*! returns the extension of the file in which this definition was found */
180 QCString getDefFileExtension() const;
182 /*! returns the line number at which the definition was found */
183 int getDefLine() const { return m_defLine; }
185 /*! returns the column number at which the definition was found */
186 int getDefColumn() const { return m_defColumn; }
188 /*! Returns TRUE iff the definition is documented
189 * (which could be generated documentation)
190 * @see hasUserDocumentation()
192 virtual bool hasDocumentation() const;
194 /*! Returns TRUE iff the definition is documented by the user. */
195 virtual bool hasUserDocumentation() const;
197 /*! Returns TRUE iff it is possible to link to this item within this
200 virtual bool isLinkableInProject() const = 0;
202 /*! Returns TRUE iff it is possible to link to this item. This can
203 * be a link to another project imported via a tag file.
205 virtual bool isLinkable() const = 0;
207 /*! Returns TRUE iff the name is part of this project and
208 * may appear in the output
210 virtual bool isVisibleInProject() const;
212 /*! Returns TRUE iff the name may appear in the output */
213 virtual bool isVisible() const;
215 /*! Returns TRUE iff this item is supposed to be hidden from the output. */
216 bool isHidden() const;
218 /*! returns TRUE if this entity was artificially introduced, for
219 * instance because it is used to show a template instantiation relation.
221 bool isArtificial() const;
223 /*! If this definition was imported via a tag file, this function
224 * returns the tagfile for the external project. This can be
225 * translated into an external link target via
226 * Doxygen::tagDestinationDict
228 virtual QCString getReference() const;
230 /*! Returns TRUE if this definition is imported via a tag file. */
231 virtual bool isReference() const;
233 /*! Returns the first line of the body of this item (applicable to classes and
236 int getStartBodyLine() const;
238 /*! Returns the last line of the body of this item (applicable to classes and
241 int getEndBodyLine() const;
243 /*! Returns the file in which the body of this item is located or 0 if no
246 FileDef *getBodyDef() const;
248 /** Returns the programming language this definition was written in. */
249 SrcLangExt getLanguage() const;
251 GroupList *partOfGroups() const;
253 QList<ListItemInfo> *xrefListItems() const;
255 virtual Definition *findInnerCompound(const char *name);
256 virtual Definition *getOuterScope() const;
258 MemberSDict *getReferencesMembers() const;
259 MemberSDict *getReferencedByMembers() const;
261 bool hasSections() const;
262 bool hasSources() const;
264 /** returns TRUE if this class has a brief description */
265 bool hasBriefDescription() const;
269 //-----------------------------------------------------------------------------------
270 // ---- setters -----
271 //-----------------------------------------------------------------------------------
273 /*! Sets a new \a name for the definition */
274 void setName(const char *name);
276 /*! Sets a unique id for the symbol. Used for libclang integration. */
277 void setId(const char *name);
279 /*! Sets the documentation of this definition to \a d. */
280 virtual void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
282 /*! Sets the brief description of this definition to \a b.
283 * A dot is added to the sentence if not available.
285 virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine);
287 /*! Set the documentation that was found inside the body of an item.
288 * If there was already some documentation set, the new documentation
291 virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine);
293 /*! Sets the tag file id via which this definition was imported. */
294 void setReference(const char *r);
296 /*! Add the list of anchors that mark the sections that are found in the
299 void addSectionsToDefinition(QList<SectionInfo> *anchorList);
302 void setBodySegment(int bls,int ble);
303 void setBodyDef(FileDef *fd);
304 void addSourceReferencedBy(MemberDef *d);
305 void addSourceReferences(MemberDef *d);
307 void setRefItems(const QList<ListItemInfo> *sli);
308 void mergeRefItems(Definition *d);
309 virtual void addInnerCompound(Definition *d);
310 virtual void setOuterScope(Definition *d);
312 virtual void setHidden(bool b);
314 void setArtificial(bool b);
315 void setLanguage(SrcLangExt lang);
317 //-----------------------------------------------------------------------------------
319 //-----------------------------------------------------------------------------------
321 QCString convertNameToFile(const char *name,bool allowDots=FALSE) const;
322 void writeSourceDef(OutputList &ol,const char *scopeName);
323 void writeInlineCode(OutputList &ol,const char *scopeName);
324 void writeSourceRefs(OutputList &ol,const char *scopeName);
325 void writeSourceReffedBy(OutputList &ol,const char *scopeName);
326 void makePartOfGroup(GroupDef *gd);
327 //void writePathFragment(OutputList &ol) const;
328 void writeNavigationPath(OutputList &ol) const;
329 QCString navigationPathAsString() const;
330 virtual void writeQuickMemberLinks(OutputList &,MemberDef *) const {}
331 virtual void writeSummaryLinks(OutputList &) {}
332 QCString pathFragment() const;
334 /*! Writes the documentation anchors of the definition to
335 * the Doxygen::tagFile stream.
337 void writeDocAnchorsToTagFile();
338 void setLocalName(const QCString name);
340 void addSectionsToIndex();
341 void writeToc(OutputList &ol);
345 Definition(const Definition &d);
348 static void addToMap(const char *name,Definition *d);
349 static void removeFromMap(Definition *d);
351 void _setSymbolName(const QCString &name);
353 int _getXRefListId(const char *listName) const;
354 void _writeSourceRefList(OutputList &ol,const char *scopeName,
355 const QCString &text,MemberSDict *members,bool);
356 void _setBriefDescription(const char *b,const char *briefFile,int briefLine);
357 void _setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace,bool atTop);
358 void _setInbodyDocumentation(const char *d,const char *docFile,int docLine);
359 bool _docsAlreadyAdded(const QCString &doc,QCString &sigList);
360 DefinitionImpl *m_impl; // internal structure holding all private data
363 QCString m_symbolName;
368 /** A list of Definition objects. */
369 class DefinitionList : public QList<Definition>, public DefinitionIntf
373 DefType definitionType() const { return TypeSymbolList; }
374 int compareValues(const Definition *item1,const Definition *item2) const
376 return qstricmp(item1->name(),item2->name());
381 /** An iterator for Definition objects in a DefinitionList. */
382 class DefinitionListIterator : public QListIterator<Definition>
385 DefinitionListIterator(const DefinitionList &l) :
386 QListIterator<Definition>(l) {}
387 ~DefinitionListIterator() {}
390 /** Reads a fragment from file \a fileName starting with line \a startLine
391 * and ending with line \a endLine. The result is returned as a string
392 * via \a result. The function returns TRUE if successful and FALSE
393 * in case of an error.
395 bool readCodeFragment(const char *fileName,
396 int &startLine,int &endLine,