Public Member Functions | Private Attributes | List of all members
DocLink Class Reference

#include <docparser.h>

Inheritance diagram for DocLink:
CompAccept< DocLink > DocNode

Public Member Functions

 DocLink (DocNode *parent, const QCString &target)
 
QCString parse (bool, bool isXmlLink=FALSE)
 
Kind kind () const
 
QCString file () const
 
QCString relPath () const
 
QCString ref () const
 
QCString anchor () const
 
void accept (DocVisitor *v)
 
- Public Member Functions inherited from CompAccept< DocLink >
 CompAccept ()
 
virtual ~CompAccept ()
 
void accept (DocLink *obj, DocVisitor *v)
 
const QList< DocNode > & children () const
 
QList< DocNode > & children ()
 
- Public Member Functions inherited from DocNode
 DocNode ()
 
virtual ~DocNode ()
 
DocNodeparent () const
 
void setParent (DocNode *parent)
 
bool isPreformatted () const
 

Private Attributes

QCString m_file
 
QCString m_relPath
 
QCString m_ref
 
QCString m_anchor
 
QCString m_refText
 

Additional Inherited Members

- Public Types inherited from DocNode
enum  Kind {
  Kind_Root = 0, Kind_Word = 1, Kind_WhiteSpace = 2, Kind_Para = 3,
  Kind_AutoList = 4, Kind_AutoListItem = 5, Kind_Symbol = 6, Kind_URL = 7,
  Kind_StyleChange = 8, Kind_SimpleSect = 9, Kind_Title = 10, Kind_SimpleList = 11,
  Kind_SimpleListItem = 12, Kind_Section = 13, Kind_Verbatim = 14, Kind_XRefItem = 15,
  Kind_HtmlList = 16, Kind_HtmlListItem = 17, Kind_HtmlDescList = 18, Kind_HtmlDescData = 19,
  Kind_HtmlDescTitle = 20, Kind_HtmlTable = 21, Kind_HtmlRow = 22, Kind_HtmlCell = 23,
  Kind_HtmlCaption = 24, Kind_LineBreak = 25, Kind_HorRuler = 26, Kind_Anchor = 27,
  Kind_IndexEntry = 28, Kind_Internal = 29, Kind_HRef = 30, Kind_Include = 31,
  Kind_IncOperator = 32, Kind_HtmlHeader = 33, Kind_Image = 34, Kind_DotFile = 35,
  Kind_Link = 36, Kind_Ref = 37, Kind_Formula = 38, Kind_SecRefItem = 39,
  Kind_SecRefList = 40, Kind_SimpleSectSep = 41, Kind_LinkedWord = 42, Kind_ParamSect = 43,
  Kind_ParamList = 44, Kind_InternalRef = 45, Kind_Copy = 46, Kind_Text = 47,
  Kind_MscFile = 48, Kind_HtmlBlockQuote = 49, Kind_VhdlFlow = 50, Kind_ParBlock = 51,
  Kind_DiaFile = 52
}
 
- Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)
 
- Protected Attributes inherited from CompAccept< DocLink >
QList< DocNodem_children
 
- Protected Attributes inherited from DocNode
DocNodem_parent
 

Detailed Description

Node representing a link to some item

Definition at line 800 of file docparser.h.

Constructor & Destructor Documentation

DocLink::DocLink ( DocNode parent,
const QCString target 
)

Definition at line 2638 of file docparser.cpp.

2639 {
2640  m_parent = parent;
2641  Definition *compound = 0;
2642  QCString anchor;
2643  m_refText = target;
2644  m_relPath = g_relPath;
2645  if (!m_refText.isEmpty() && m_refText.at(0)=='#')
2646  {
2648  }
2650  &compound,anchor))
2651  {
2652  m_anchor = anchor;
2653  if (compound && compound->isLinkable())
2654  {
2655  m_file = compound->getOutputFileBase();
2656  m_ref = compound->getReference();
2657  }
2658  else if (compound && compound->definitionType()==Definition::TypeFile &&
2659  ((FileDef*)compound)->generateSourceFile()
2660  ) // undocumented file that has source code we can link to
2661  {
2662  m_file = compound->getSourceFileBase();
2663  m_ref = compound->getReference();
2664  }
2665  return;
2666  }
2667 
2668  // bogus link target
2669  warn_doc_error(g_fileName,doctokenizerYYlineno,"unable to resolve link to `%s' for \\link command",
2670  qPrint(target));
2671 }
DocNode * parent() const
Definition: docparser.h:147
static QCString g_fileName
Definition: docparser.cpp:95
virtual bool isLinkable() const =0
virtual QCString getReference() const
bool resolveLink(const char *scName, const char *lr, bool, Definition **resContext, QCString &resAnchor)
Definition: util.cpp:4753
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
char & at(uint i) const
Definition: qcstring.h:326
int doctokenizerYYlineno
static QCString g_relPath
Definition: docparser.cpp:96
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
virtual QCString getOutputFileBase() const =0
virtual DefType definitionType() const =0
DocNode * m_parent
Definition: docparser.h:163
virtual QCString getSourceFileBase() const
Definition: definition.cpp:885
QCString right(uint len) const
Definition: qcstring.cpp:231
static QCString g_context
Definition: docparser.cpp:87
static QCString stripKnownExtensions(const char *text)
Definition: docparser.cpp:625
static bool g_inSeeBlock
Definition: docparser.cpp:88
const char * qPrint(const char *s)
Definition: qcstring.h:797

Member Function Documentation

void DocLink::accept ( DocVisitor v)
inlinevirtual

Acceptor function for node visitors. Part of the visitor pattern.

Parameters
vAbstract visitor.

Implements DocNode.

Definition at line 810 of file docparser.h.

810 { CompAccept<DocLink>::accept(this,v); }
void accept(T *obj, DocVisitor *v)
Definition: docparser.h:177
QCString DocLink::anchor ( ) const
inline

Definition at line 809 of file docparser.h.

809 { return m_anchor; }
QCString DocLink::file ( ) const
inline

Definition at line 806 of file docparser.h.

806 { return m_file; }
Kind DocLink::kind ( ) const
inlinevirtual

Returns the kind of node. Provides runtime type information

Implements DocNode.

Definition at line 805 of file docparser.h.

805 { return Kind_Link; }
QCString DocLink::parse ( bool  isJavaLink,
bool  isXmlLink = FALSE 
)

Definition at line 2674 of file docparser.cpp.

2675 {
2676  QCString result;
2677  g_nodeStack.push(this);
2678  DBG(("DocLink::parse() start\n"));
2679 
2680  int tok;
2681  while ((tok=doctokenizerYYlex()))
2682  {
2683  if (!defaultHandleToken(this,tok,m_children,FALSE))
2684  {
2685  switch (tok)
2686  {
2687  case TK_COMMAND:
2688  switch (Mappers::cmdMapper->map(g_token->name))
2689  {
2690  case CMD_ENDLINK:
2691  if (isJavaLink)
2692  {
2693  warn_doc_error(g_fileName,doctokenizerYYlineno,"{@link.. ended with @endlink command");
2694  }
2695  goto endlink;
2696  default:
2697  warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a \\link",
2698  qPrint(g_token->name));
2699  break;
2700  }
2701  break;
2702  case TK_SYMBOL:
2703  warn_doc_error(g_fileName,doctokenizerYYlineno,"Unsupported symbol %s found",
2704  qPrint(g_token->name));
2705  break;
2706  case TK_HTMLTAG:
2707  if (g_token->name!="see" || !isXmlLink)
2708  {
2709  warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected xml/html command %s found",
2710  qPrint(g_token->name));
2711  }
2712  goto endlink;
2713  case TK_LNKWORD:
2714  case TK_WORD:
2715  if (isJavaLink) // special case to detect closing }
2716  {
2717  QCString w = g_token->name;
2718  int p;
2719  if (w=="}")
2720  {
2721  goto endlink;
2722  }
2723  else if ((p=w.find('}'))!=-1)
2724  {
2725  uint l=w.length();
2726  m_children.append(new DocWord(this,w.left(p)));
2727  if ((uint)p<l-1) // something left after the } (for instance a .)
2728  {
2729  result=w.right(l-p-1);
2730  }
2731  goto endlink;
2732  }
2733  }
2734  m_children.append(new DocWord(this,g_token->name));
2735  break;
2736  default:
2737  warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected token %s",
2738  tokToString(tok));
2739  break;
2740  }
2741  }
2742  }
2743  if (tok==0)
2744  {
2745  warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected end of comment while inside"
2746  " link command\n");
2747  }
2748 endlink:
2749 
2750  if (m_children.isEmpty()) // no link text
2751  {
2752  m_children.append(new DocWord(this,m_refText));
2753  }
2754 
2756  DBG(("DocLink::parse() end\n"));
2757  DocNode *n=g_nodeStack.pop();
2758  ASSERT(n==this);
2759  return result;
2760 }
static QCString g_fileName
Definition: docparser.cpp:95
QList< DocNode > m_children
Definition: docparser.h:189
static QCString result
uint length() const
Definition: qcstring.h:195
void append(const type *d)
Definition: qlist.h:73
#define DBG(x)
Definition: docparser.cpp:59
int doctokenizerYYlineno
const bool FALSE
Definition: qglobal.h:370
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
QCString left(uint len) const
Definition: qcstring.cpp:213
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
static QStack< DocNode > g_nodeStack
Definition: docparser.cpp:91
static QStrList * l
Definition: config.cpp:1044
TokenInfo * g_token
int doctokenizerYYlex(void)
void push(const type *d)
Definition: qstack.h:58
bool isEmpty() const
Definition: qlist.h:67
static void handlePendingStyleCommands(DocNode *parent, QList< DocNode > &children)
Definition: docparser.cpp:957
QCString right(uint len) const
Definition: qcstring.cpp:231
std::void_t< T > n
p
Definition: test.py:223
type * pop()
Definition: qstack.h:59
static bool defaultHandleToken(DocNode *parent, int tok, QList< DocNode > &children, bool handleWord=TRUE)
Definition: docparser.cpp:1331
static Mapper * cmdMapper
Definition: cmdmapper.h:219
QCString name
Definition: doctokenizer.h:77
const char * tokToString(int token)
unsigned uint
Definition: qglobal.h:351
const char * qPrint(const char *s)
Definition: qcstring.h:797
#define ASSERT(x)
Definition: qglobal.h:590
QCString DocLink::ref ( ) const
inline

Definition at line 808 of file docparser.h.

808 { return m_ref; }
QCString DocLink::relPath ( ) const
inline

Definition at line 807 of file docparser.h.

807 { return m_relPath; }

Member Data Documentation

QCString DocLink::m_anchor
private

Definition at line 816 of file docparser.h.

QCString DocLink::m_file
private

Definition at line 813 of file docparser.h.

QCString DocLink::m_ref
private

Definition at line 815 of file docparser.h.

QCString DocLink::m_refText
private

Definition at line 817 of file docparser.h.

QCString DocLink::m_relPath
private

Definition at line 814 of file docparser.h.


The documentation for this class was generated from the following files: