Blame src/definition.h

Packit Service 50c9f2
/******************************************************************************
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * 
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Copyright (C) 1997-2015 by Dimitri van Heesch.
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Permission to use, copy, modify, and distribute this software and its
Packit Service 50c9f2
 * documentation under the terms of the GNU General Public License is hereby 
Packit Service 50c9f2
 * granted. No representations are made about the suitability of this software 
Packit Service 50c9f2
 * for any purpose. It is provided "as is" without express or implied warranty.
Packit Service 50c9f2
 * See the GNU General Public License for more details.
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Documents produced by Doxygen are derivative works derived from the
Packit Service 50c9f2
 * input used in their production; they are not affected by this license.
Packit Service 50c9f2
 *
Packit Service 50c9f2
 */
Packit Service 50c9f2
Packit Service 50c9f2
#ifndef DEFINITION_H
Packit Service 50c9f2
#define DEFINITION_H
Packit Service 50c9f2
Packit Service 50c9f2
#include <qlist.h>
Packit Service 50c9f2
#include <qdict.h>
Packit Service 50c9f2
Packit Service 50c9f2
#include "types.h"
Packit Service 50c9f2
Packit Service 50c9f2
class FileDef;
Packit Service 50c9f2
class OutputList;
Packit Service 50c9f2
class SectionDict;
Packit Service 50c9f2
class MemberSDict;
Packit Service 50c9f2
class MemberDef;
Packit Service 50c9f2
class GroupDef;
Packit Service 50c9f2
class GroupList;
Packit Service 50c9f2
struct ListItemInfo;
Packit Service 50c9f2
struct SectionInfo;
Packit Service 50c9f2
class Definition;
Packit Service 50c9f2
class DefinitionImpl;
Packit Service 50c9f2
class FTextStream;
Packit Service 50c9f2
  
Packit Service 50c9f2
/** Data associated with a detailed description. */
Packit Service 50c9f2
struct DocInfo
Packit Service 50c9f2
{
Packit Service 50c9f2
    QCString doc;  
Packit Service 50c9f2
    int      line;
Packit Service 50c9f2
    QCString file;
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
/** Data associated with a brief description. */
Packit Service 50c9f2
struct BriefInfo
Packit Service 50c9f2
{
Packit Service 50c9f2
    QCString doc;  
Packit Service 50c9f2
    QCString tooltip;  
Packit Service 50c9f2
    int      line;
Packit Service 50c9f2
    QCString file;
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
/** Data associated with description found in the body. */
Packit Service 50c9f2
struct BodyInfo
Packit Service 50c9f2
{
Packit Service 50c9f2
    int      startLine;   //!< line number of the start of the definition
Packit Service 50c9f2
    int      endLine;     //!< line number of the end of the definition
Packit Service 50c9f2
    FileDef *fileDef;     //!< file definition containing the function body
Packit Service 50c9f2
};
Packit Service 50c9f2
    
Packit Service 50c9f2
/** Abstract interface for a Definition or DefinitionList */
Packit Service 50c9f2
class DefinitionIntf
Packit Service 50c9f2
{
Packit Service 50c9f2
  public:
Packit Service 50c9f2
    DefinitionIntf() {}
Packit Service 50c9f2
    virtual ~DefinitionIntf() {}
Packit Service 50c9f2
    /*! Types of derived classes */
Packit Service 50c9f2
    enum DefType 
Packit Service 50c9f2
    { 
Packit Service 50c9f2
      TypeClass      = 0, 
Packit Service 50c9f2
      TypeFile       = 1, 
Packit Service 50c9f2
      TypeNamespace  = 2, 
Packit Service 50c9f2
      TypeMember     = 3, 
Packit Service 50c9f2
      TypeGroup      = 4, 
Packit Service 50c9f2
      TypePackage    = 5, 
Packit Service 50c9f2
      TypePage       = 6, 
Packit Service 50c9f2
      TypeDir        = 7, 
Packit Service 50c9f2
      TypeSymbolList = 8
Packit Service 50c9f2
    };
Packit Service 50c9f2
    /*! Use this for dynamic inspection of the type of the derived class */
Packit Service 50c9f2
    virtual DefType definitionType() const = 0;
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
/** The common base class of all entity definitions found in the sources. 
Packit Service 50c9f2
 *
Packit Service 50c9f2
 *  This can be a class or a member function, or a file, or a namespace, etc.
Packit Service 50c9f2
 *  Use definitionType() to find which type of definition this is.
Packit Service 50c9f2
 */
Packit Service 50c9f2
class Definition : public DefinitionIntf
Packit Service 50c9f2
{
Packit Service 50c9f2
  public:
Packit Service 50c9f2
    struct Cookie
Packit Service 50c9f2
    {
Packit Service 50c9f2
      virtual ~Cookie() {}
Packit Service 50c9f2
    };
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Create a new definition */
Packit Service 50c9f2
    Definition(
Packit Service 50c9f2
        const char *defFileName,int defLine,int defColumn,
Packit Service 50c9f2
        const char *name,const char *b=0,const char *d=0,
Packit Service 50c9f2
        bool isSymbol=TRUE);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Destroys the definition */
Packit Service 50c9f2
    virtual ~Definition();
Packit Service 50c9f2
Packit Service 50c9f2
    //-----------------------------------------------------------------------------------
Packit Service 50c9f2
    // ----  getters -----
Packit Service 50c9f2
    //-----------------------------------------------------------------------------------
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the name of the definition */
Packit Service 50c9f2
    const QCString& name() const { return m_name; }
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the name of the definition as it appears in the output */
Packit Service 50c9f2
    virtual QCString displayName(bool includeScope=TRUE) const = 0;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the local name without any scope qualifiers. */
Packit Service 50c9f2
    QCString localName() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the fully qualified name of this definition
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual QCString qualifiedName() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the name of this definition as it appears in the symbol map.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    QCString symbolName() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the base file name (without extension) of this definition.
Packit Service 50c9f2
     *  as it is referenced to/written to disk.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual QCString getOutputFileBase() const = 0;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the anchor within a page where this item can be found */
Packit Service 50c9f2
    virtual QCString anchor() const = 0;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the name of the source listing of this definition. */
Packit Service 50c9f2
    virtual QCString getSourceFileBase() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the anchor of the source listing of this definition. */
Packit Service 50c9f2
    virtual QCString getSourceAnchor() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the detailed description of this definition */
Packit Service 50c9f2
    virtual QCString documentation() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the line number at which the detailed documentation was found. */
Packit Service 50c9f2
    int docLine() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the file in which the detailed documentation block was found.
Packit Service 50c9f2
     *  This can differ from getDefFileName().
Packit Service 50c9f2
     */
Packit Service 50c9f2
    QCString docFile() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the brief description of this definition. This can include commands. */
Packit Service 50c9f2
    virtual QCString briefDescription(bool abbreviate=FALSE) const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns a plain text version of the brief description suitable for use
Packit Service 50c9f2
     *  as a tool tip. 
Packit Service 50c9f2
     */
Packit Service 50c9f2
    QCString briefDescriptionAsTooltip() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the line number at which the brief description was found. */
Packit Service 50c9f2
    int briefLine() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the documentation found inside the body of a member */
Packit Service 50c9f2
    QCString inbodyDocumentation() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the file in which the in body documentation was found */
Packit Service 50c9f2
    QCString inbodyFile() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the line at which the first in body documentation 
Packit Service 50c9f2
        part was found */
Packit Service 50c9f2
    int inbodyLine() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the file in which the brief description was found. 
Packit Service 50c9f2
     *  This can differ from getDefFileName().
Packit Service 50c9f2
     */
Packit Service 50c9f2
    QCString briefFile() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! returns the file in which this definition was found */
Packit Service 50c9f2
    QCString getDefFileName() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! returns the extension of the file in which this definition was found */
Packit Service 50c9f2
    QCString getDefFileExtension() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! returns the line number at which the definition was found */
Packit Service 50c9f2
    int getDefLine() const { return m_defLine; }
Packit Service 50c9f2
Packit Service 50c9f2
    /*! returns the column number at which the definition was found */
Packit Service 50c9f2
    int getDefColumn() const { return m_defColumn; }
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff the definition is documented 
Packit Service 50c9f2
     *  (which could be generated documentation) 
Packit Service 50c9f2
     *  @see hasUserDocumentation()
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual bool hasDocumentation() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff the definition is documented by the user. */
Packit Service 50c9f2
    virtual bool hasUserDocumentation() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff it is possible to link to this item within this
Packit Service 50c9f2
     *  project. 
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual bool isLinkableInProject() const = 0;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff it is possible to link to this item. This can
Packit Service 50c9f2
     *  be a link to another project imported via a tag file. 
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual bool isLinkable() const = 0;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff the name is part of this project and 
Packit Service 50c9f2
     *  may appear in the output 
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual bool isVisibleInProject() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff the name may appear in the output */
Packit Service 50c9f2
    virtual bool isVisible() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE iff this item is supposed to be hidden from the output. */
Packit Service 50c9f2
    bool isHidden() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! returns TRUE if this entity was artificially introduced, for 
Packit Service 50c9f2
     *  instance because it is used to show a template instantiation relation. 
Packit Service 50c9f2
     */
Packit Service 50c9f2
    bool isArtificial() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! If this definition was imported via a tag file, this function
Packit Service 50c9f2
     *  returns the tagfile for the external project. This can be
Packit Service 50c9f2
     *  translated into an external link target via 
Packit Service 50c9f2
     *  Doxygen::tagDestinationDict
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual QCString getReference() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns TRUE if this definition is imported via a tag file. */
Packit Service 50c9f2
    virtual bool isReference() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Convenience method to return a resolved external link */
Packit Service 50c9f2
    QCString externalReference(const QCString &relPath) const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the first line of the body of this item (applicable to classes and 
Packit Service 50c9f2
     *  functions).
Packit Service 50c9f2
     */
Packit Service 50c9f2
    int getStartBodyLine() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the last line of the body of this item (applicable to classes and 
Packit Service 50c9f2
     *  functions).
Packit Service 50c9f2
     */
Packit Service 50c9f2
    int getEndBodyLine() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Returns the file in which the body of this item is located or 0 if no
Packit Service 50c9f2
     *  body is available.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    FileDef *getBodyDef() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /** Returns the programming language this definition was written in. */
Packit Service 50c9f2
    SrcLangExt getLanguage() const;
Packit Service 50c9f2
Packit Service 50c9f2
    GroupList *partOfGroups() const;
Packit Service 50c9f2
    bool isLinkableViaGroup() const;
Packit Service 50c9f2
Packit Service 50c9f2
    QList<ListItemInfo> *xrefListItems() const;
Packit Service 50c9f2
Packit Service 50c9f2
    virtual Definition *findInnerCompound(const char *name) const ;
Packit Service 50c9f2
    virtual Definition *getOuterScope() const;
Packit Service 50c9f2
Packit Service 50c9f2
    MemberSDict *getReferencesMembers() const;
Packit Service 50c9f2
    MemberSDict *getReferencedByMembers() const;
Packit Service 50c9f2
Packit Service 50c9f2
    bool hasSections() const;
Packit Service 50c9f2
    bool hasSources() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /** returns TRUE if this class has a brief description */
Packit Service 50c9f2
    bool hasBriefDescription() const;
Packit Service 50c9f2
Packit Service 50c9f2
    QCString id() const;
Packit Service 50c9f2
Packit Service 50c9f2
    //-----------------------------------------------------------------------------------
Packit Service 50c9f2
    // ----  setters -----
Packit Service 50c9f2
    //-----------------------------------------------------------------------------------
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Sets a new \a name for the definition */
Packit Service 50c9f2
    virtual void setName(const char *name);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Sets a unique id for the symbol. Used for libclang integration. */
Packit Service 50c9f2
    void setId(const char *name);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Sets the documentation of this definition to \a d. */
Packit Service 50c9f2
    virtual void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Sets the brief description of this definition to \a b.
Packit Service 50c9f2
     *  A dot is added to the sentence if not available.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Set the documentation that was found inside the body of an item.
Packit Service 50c9f2
     *  If there was already some documentation set, the new documentation
Packit Service 50c9f2
     *  will be appended.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Sets the tag file id via which this definition was imported. */
Packit Service 50c9f2
    void setReference(const char *r);
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Add the list of anchors that mark the sections that are found in the 
Packit Service 50c9f2
     * documentation.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    void addSectionsToDefinition(QList<SectionInfo> *anchorList);
Packit Service 50c9f2
Packit Service 50c9f2
    // source references
Packit Service 50c9f2
    void setBodySegment(int bls,int ble);
Packit Service 50c9f2
    void setBodyDef(FileDef *fd);
Packit Service 50c9f2
    void addSourceReferencedBy(MemberDef *d);
Packit Service 50c9f2
    void addSourceReferences(MemberDef *d);
Packit Service 50c9f2
Packit Service 50c9f2
    void setRefItems(const QList<ListItemInfo> *sli);
Packit Service 50c9f2
    void mergeRefItems(Definition *d);
Packit Service 50c9f2
    virtual void addInnerCompound(Definition *d);
Packit Service 50c9f2
    virtual void setOuterScope(Definition *d);
Packit Service 50c9f2
Packit Service 50c9f2
    virtual void setHidden(bool b);
Packit Service 50c9f2
Packit Service 50c9f2
    void setArtificial(bool b);
Packit Service 50c9f2
    void setLanguage(SrcLangExt lang);
Packit Service 50c9f2
Packit Service 50c9f2
    //-----------------------------------------------------------------------------------
Packit Service 50c9f2
    // --- actions ----
Packit Service 50c9f2
    //-----------------------------------------------------------------------------------
Packit Service 50c9f2
Packit Service 50c9f2
    void writeSourceDef(OutputList &ol,const char *scopeName);
Packit Service 50c9f2
    void writeInlineCode(OutputList &ol,const char *scopeName);
Packit Service 50c9f2
    void writeSourceRefs(OutputList &ol,const char *scopeName);
Packit Service 50c9f2
    void writeSourceReffedBy(OutputList &ol,const char *scopeName);
Packit Service 50c9f2
    void makePartOfGroup(GroupDef *gd);
Packit Service 50c9f2
    //void writePathFragment(OutputList &ol) const;
Packit Service 50c9f2
    void writeNavigationPath(OutputList &ol) const;
Packit Service 50c9f2
    QCString navigationPathAsString() const;
Packit Service 50c9f2
    virtual void writeQuickMemberLinks(OutputList &,MemberDef *) const {}
Packit Service 50c9f2
    virtual void writeSummaryLinks(OutputList &) {}
Packit Service 50c9f2
    QCString pathFragment() const;
Packit Service 50c9f2
Packit Service 50c9f2
    /*! Writes the documentation anchors of the definition to 
Packit Service 50c9f2
     *  the Doxygen::tagFile stream.
Packit Service 50c9f2
     */
Packit Service 50c9f2
    void writeDocAnchorsToTagFile(FTextStream &);
Packit Service 50c9f2
    void setLocalName(const QCString name);
Packit Service 50c9f2
Packit Service 50c9f2
    void addSectionsToIndex();
Packit Service 50c9f2
    void writeToc(OutputList &ol);
Packit Service 50c9f2
Packit Service 50c9f2
    void setCookie(Cookie *cookie) { delete m_cookie; m_cookie = cookie; }
Packit Service 50c9f2
    Cookie *cookie() const { return m_cookie; }
Packit Service 50c9f2
Packit Service 50c9f2
  protected:
Packit Service 50c9f2
Packit Service 50c9f2
    Definition(const Definition &d);
Packit Service 50c9f2
Packit Service 50c9f2
  private: 
Packit Service 50c9f2
    static void addToMap(const char *name,Definition *d);
Packit Service 50c9f2
    static void removeFromMap(Definition *d);
Packit Service 50c9f2
Packit Service 50c9f2
    void _setSymbolName(const QCString &name);
Packit Service 50c9f2
Packit Service 50c9f2
    int  _getXRefListId(const char *listName) const;
Packit Service 50c9f2
    void _writeSourceRefList(OutputList &ol,const char *scopeName,
Packit Service 50c9f2
                       const QCString &text,MemberSDict *members,bool);
Packit Service 50c9f2
    void _setBriefDescription(const char *b,const char *briefFile,int briefLine);
Packit Service 50c9f2
    void _setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace,bool atTop);
Packit Service 50c9f2
    void _setInbodyDocumentation(const char *d,const char *docFile,int docLine);
Packit Service 50c9f2
    bool _docsAlreadyAdded(const QCString &doc,QCString &sigList);
Packit Service 50c9f2
    DefinitionImpl *m_impl; // internal structure holding all private data
Packit Service 50c9f2
    QCString m_name;
Packit Service 50c9f2
    bool m_isSymbol;
Packit Service 50c9f2
    QCString m_symbolName;
Packit Service 50c9f2
    int m_defLine;
Packit Service 50c9f2
    int m_defColumn;
Packit Service 50c9f2
    Cookie *m_cookie;
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
/** A list of Definition objects. */
Packit Service 50c9f2
class DefinitionList : public QList<Definition>, public DefinitionIntf
Packit Service 50c9f2
{
Packit Service 50c9f2
  public:
Packit Service 50c9f2
    ~DefinitionList() {}
Packit Service 50c9f2
    DefType definitionType() const { return TypeSymbolList; }
Packit Service 50c9f2
    int compareValues(const Definition *item1,const Definition *item2) const
Packit Service 50c9f2
    {
Packit Service 50c9f2
      return qstricmp(item1->name(),item2->name());
Packit Service 50c9f2
    }
Packit Service 50c9f2
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
/** An iterator for Definition objects in a DefinitionList. */
Packit Service 50c9f2
class DefinitionListIterator : public QListIterator<Definition>
Packit Service 50c9f2
{
Packit Service 50c9f2
  public:
Packit Service 50c9f2
    DefinitionListIterator(const DefinitionList &l) :
Packit Service 50c9f2
      QListIterator<Definition>(l) {}
Packit Service 50c9f2
    ~DefinitionListIterator() {}
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
/** Reads a fragment from file \a fileName starting with line \a startLine
Packit Service 50c9f2
 *  and ending with line \a endLine. The result is returned as a string 
Packit Service 50c9f2
 *  via \a result. The function returns TRUE if successful and FALSE 
Packit Service 50c9f2
 *  in case of an error.
Packit Service 50c9f2
 */
Packit Service 50c9f2
bool readCodeFragment(const char *fileName, 
Packit Service 50c9f2
                      int &startLine,int &endLine,
Packit Service 50c9f2
                      QCString &result);
Packit Service 50c9f2
#endif