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.
39 /** Data associated with a detailed description. */
47 /** Data associated with a brief description. */
56 /** Data associated with description found in the body. */
59 int startLine; //!< line number of the start of the definition
60 int endLine; //!< line number of the end of the definition
61 FileDef *fileDef; //!< file definition containing the function body
64 /** Abstract interface for a Definition or DefinitionList */
69 virtual ~DefinitionIntf() {}
70 /*! Types of derived classes */
83 /*! Use this for dynamic inspection of the type of the derived class */
84 virtual DefType definitionType() const = 0;
87 /** The common base class of all entity definitions found in the sources.
89 * This can be a class or a member function, or a file, or a namespace, etc.
90 * Use definitionType() to find which type of definition this is.
92 class Definition : public DefinitionIntf
100 /*! Create a new definition */
102 const char *defFileName,int defLine,int defColumn,
103 const char *name,const char *b=0,const char *d=0,
106 /*! Destroys the definition */
107 virtual ~Definition();
109 //-----------------------------------------------------------------------------------
110 // ---- getters -----
111 //-----------------------------------------------------------------------------------
113 /*! Returns the name of the definition */
114 const QCString& name() const { return m_name; }
116 /*! Returns the name of the definition as it appears in the output */
117 virtual QCString displayName(bool includeScope=TRUE) const = 0;
119 /*! Returns the local name without any scope qualifiers. */
120 QCString localName() const;
122 /*! Returns the fully qualified name of this definition
124 virtual QCString qualifiedName() const;
126 /*! Returns the name of this definition as it appears in the symbol map.
128 QCString symbolName() const;
130 /*! Returns the base file name (without extension) of this definition.
131 * as it is referenced to/written to disk.
133 virtual QCString getOutputFileBase() const = 0;
135 /*! Returns the anchor within a page where this item can be found */
136 virtual QCString anchor() const = 0;
138 /*! Returns the name of the source listing of this definition. */
139 virtual QCString getSourceFileBase() const;
141 /*! Returns the anchor of the source listing of this definition. */
142 virtual QCString getSourceAnchor() const;
144 /*! Returns the detailed description of this definition */
145 virtual QCString documentation() const;
147 /*! Returns the line number at which the detailed documentation was found. */
150 /*! Returns the file in which the detailed documentation block was found.
151 * This can differ from getDefFileName().
153 QCString docFile() const;
155 /*! Returns the brief description of this definition. This can include commands. */
156 virtual QCString briefDescription(bool abbreviate=FALSE) const;
158 /*! Returns a plain text version of the brief description suitable for use
161 QCString briefDescriptionAsTooltip() const;
163 /*! Returns the line number at which the brief description was found. */
164 int briefLine() const;
166 /*! Returns the documentation found inside the body of a member */
167 QCString inbodyDocumentation() const;
169 /*! Returns the file in which the in body documentation was found */
170 QCString inbodyFile() const;
172 /*! Returns the line at which the first in body documentation
174 int inbodyLine() const;
176 /*! Returns the file in which the brief description was found.
177 * This can differ from getDefFileName().
179 QCString briefFile() const;
181 /*! returns the file in which this definition was found */
182 QCString getDefFileName() const;
184 /*! returns the extension of the file in which this definition was found */
185 QCString getDefFileExtension() const;
187 /*! returns the line number at which the definition was found */
188 int getDefLine() const { return m_defLine; }
190 /*! returns the column number at which the definition was found */
191 int getDefColumn() const { return m_defColumn; }
193 /*! Returns TRUE iff the definition is documented
194 * (which could be generated documentation)
195 * @see hasUserDocumentation()
197 virtual bool hasDocumentation() const;
199 /*! Returns TRUE iff the definition is documented by the user. */
200 virtual bool hasUserDocumentation() const;
202 /*! Returns TRUE iff it is possible to link to this item within this
205 virtual bool isLinkableInProject() const = 0;
207 /*! Returns TRUE iff it is possible to link to this item. This can
208 * be a link to another project imported via a tag file.
210 virtual bool isLinkable() const = 0;
212 /*! Returns TRUE iff the name is part of this project and
213 * may appear in the output
215 virtual bool isVisibleInProject() const;
217 /*! Returns TRUE iff the name may appear in the output */
218 virtual bool isVisible() const;
220 /*! Returns TRUE iff this item is supposed to be hidden from the output. */
221 bool isHidden() const;
223 /*! returns TRUE if this entity was artificially introduced, for
224 * instance because it is used to show a template instantiation relation.
226 bool isArtificial() const;
228 /*! If this definition was imported via a tag file, this function
229 * returns the tagfile for the external project. This can be
230 * translated into an external link target via
231 * Doxygen::tagDestinationDict
233 virtual QCString getReference() const;
235 /*! Returns TRUE if this definition is imported via a tag file. */
236 virtual bool isReference() const;
238 /*! Convenience method to return a resolved external link */
239 QCString externalReference(const QCString &relPath) const;
241 /*! Returns the first line of the body of this item (applicable to classes and
244 int getStartBodyLine() const;
246 /*! Returns the last line of the body of this item (applicable to classes and
249 int getEndBodyLine() const;
251 /*! Returns the file in which the body of this item is located or 0 if no
254 FileDef *getBodyDef() const;
256 /** Returns the programming language this definition was written in. */
257 SrcLangExt getLanguage() const;
259 GroupList *partOfGroups() const;
260 bool isLinkableViaGroup() const;
262 QList<ListItemInfo> *xrefListItems() const;
264 virtual Definition *findInnerCompound(const char *name) const ;
265 virtual Definition *getOuterScope() const;
267 MemberSDict *getReferencesMembers() const;
268 MemberSDict *getReferencedByMembers() const;
270 bool hasSections() const;
271 bool hasSources() const;
273 /** returns TRUE if this class has a brief description */
274 bool hasBriefDescription() const;
278 /** returns the section dictionary, only of importance for pagedef */
279 SectionDict * getSectionDict(void);
281 //-----------------------------------------------------------------------------------
282 // ---- setters -----
283 //-----------------------------------------------------------------------------------
285 /*! Sets a new \a name for the definition */
286 virtual void setName(const char *name);
288 /*! Sets a unique id for the symbol. Used for libclang integration. */
289 void setId(const char *name);
291 /*! Sets the documentation of this definition to \a d. */
292 virtual void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
294 /*! Sets the brief description of this definition to \a b.
295 * A dot is added to the sentence if not available.
297 virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine);
299 /*! Set the documentation that was found inside the body of an item.
300 * If there was already some documentation set, the new documentation
303 virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine);
305 /*! Sets the tag file id via which this definition was imported. */
306 void setReference(const char *r);
308 /*! Add the list of anchors that mark the sections that are found in the
311 void addSectionsToDefinition(QList<SectionInfo> *anchorList);
314 void setBodySegment(int bls,int ble);
315 void setBodyDef(FileDef *fd);
316 void addSourceReferencedBy(MemberDef *d);
317 void addSourceReferences(MemberDef *d);
319 void setRefItems(const QList<ListItemInfo> *sli);
320 void mergeRefItems(Definition *d);
321 virtual void addInnerCompound(Definition *d);
322 virtual void setOuterScope(Definition *d);
324 virtual void setHidden(bool b);
326 void setArtificial(bool b);
327 void setLanguage(SrcLangExt lang);
329 //-----------------------------------------------------------------------------------
331 //-----------------------------------------------------------------------------------
333 void writeSourceDef(OutputList &ol,const char *scopeName);
334 void writeInlineCode(OutputList &ol,const char *scopeName);
335 void writeSourceRefs(OutputList &ol,const char *scopeName);
336 void writeSourceReffedBy(OutputList &ol,const char *scopeName);
337 void makePartOfGroup(GroupDef *gd);
338 //void writePathFragment(OutputList &ol) const;
339 void writeNavigationPath(OutputList &ol) const;
340 QCString navigationPathAsString() const;
341 virtual void writeQuickMemberLinks(OutputList &,MemberDef *) const {}
342 virtual void writeSummaryLinks(OutputList &) {}
343 QCString pathFragment() const;
345 /*! Writes the documentation anchors of the definition to
346 * the Doxygen::tagFile stream.
348 void writeDocAnchorsToTagFile(FTextStream &);
349 void setLocalName(const QCString name);
351 void addSectionsToIndex();
352 void writeToc(OutputList &ol, const LocalToc <);
354 void setCookie(Cookie *cookie) { delete m_cookie; m_cookie = cookie; }
355 Cookie *cookie() const { return m_cookie; }
359 Definition(const Definition &d);
362 static void addToMap(const char *name,Definition *d);
363 static void removeFromMap(Definition *d);
365 void _setSymbolName(const QCString &name);
367 int _getXRefListId(const char *listName) const;
368 void _writeSourceRefList(OutputList &ol,const char *scopeName,
369 const QCString &text,MemberSDict *members,bool);
370 void _setBriefDescription(const char *b,const char *briefFile,int briefLine);
371 void _setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace,bool atTop);
372 void _setInbodyDocumentation(const char *d,const char *docFile,int docLine);
373 bool _docsAlreadyAdded(const QCString &doc,QCString &sigList);
374 DefinitionImpl *m_impl; // internal structure holding all private data
377 QCString m_symbolName;
383 /** A list of Definition objects. */
384 class DefinitionList : public QList<Definition>, public DefinitionIntf
388 DefType definitionType() const { return TypeSymbolList; }
389 int compareValues(const Definition *item1,const Definition *item2) const
391 return qstricmp(item1->name(),item2->name());
396 /** An iterator for Definition objects in a DefinitionList. */
397 class DefinitionListIterator : public QListIterator<Definition>
400 DefinitionListIterator(const DefinitionList &l) :
401 QListIterator<Definition>(l) {}
402 ~DefinitionListIterator() {}
405 /** Reads a fragment from file \a fileName starting with line \a startLine
406 * and ending with line \a endLine. The result is returned as a string
407 * via \a result. The function returns TRUE if successful and FALSE
408 * in case of an error.
410 bool readCodeFragment(const char *fileName,
411 int &startLine,int &endLine,