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

#include <docparser.h>

Inheritance diagram for DocHtmlList:
CompAccept< DocHtmlList > DocNode

Public Types

enum  Type { Unordered, Ordered }
 
- 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
}
 

Public Member Functions

 DocHtmlList (DocNode *parent, const HtmlAttribList &attribs, Type t)
 
Kind kind () const
 
Type type () const
 
void accept (DocVisitor *v)
 
const HtmlAttribListattribs () const
 
int parse ()
 
int parseXml ()
 
- Public Member Functions inherited from CompAccept< DocHtmlList >
 CompAccept ()
 
virtual ~CompAccept ()
 
void accept (DocHtmlList *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

Type m_type
 
HtmlAttribList m_attribs
 

Additional Inherited Members

- Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)
 
- Protected Attributes inherited from CompAccept< DocHtmlList >
QList< DocNodem_children
 
- Protected Attributes inherited from DocNode
DocNodem_parent
 

Detailed Description

Node representing a Html list

Definition at line 1027 of file docparser.h.

Member Enumeration Documentation

Enumerator
Unordered 
Ordered 

Definition at line 1030 of file docparser.h.

Constructor & Destructor Documentation

DocHtmlList::DocHtmlList ( DocNode parent,
const HtmlAttribList attribs,
Type  t 
)
inline

Definition at line 1031 of file docparser.h.

1031  :
1032  m_type(t), m_attribs(attribs) { m_parent = parent; }
DocNode * parent() const
Definition: docparser.h:147
DocNode * m_parent
Definition: docparser.h:163
HtmlAttribList m_attribs
Definition: docparser.h:1042

Member Function Documentation

void DocHtmlList::accept ( DocVisitor v)
inlinevirtual

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

Parameters
vAbstract visitor.

Implements DocNode.

Definition at line 1035 of file docparser.h.

void accept(T *obj, DocVisitor *v)
Definition: docparser.h:177
const HtmlAttribList& DocHtmlList::attribs ( ) const
inline

Definition at line 1036 of file docparser.h.

1036 { return m_attribs; }
HtmlAttribList m_attribs
Definition: docparser.h:1042
Kind DocHtmlList::kind ( ) const
inlinevirtual

Returns the kind of node. Provides runtime type information

Implements DocNode.

Definition at line 1033 of file docparser.h.

int DocHtmlList::parse ( )

Definition at line 4130 of file docparser.cpp.

4131 {
4132  DBG(("DocHtmlList::parse() start\n"));
4133  int retval=RetVal_OK;
4134  int num=1;
4135  g_nodeStack.push(this);
4136 
4137  // get next token
4138  int tok=doctokenizerYYlex();
4139  // skip whitespace and paragraph breaks
4140  while (tok==TK_WHITESPACE || tok==TK_NEWPARA) tok=doctokenizerYYlex();
4141  // should find a html tag now
4142  if (tok==TK_HTMLTAG)
4143  {
4144  int tagId=Mappers::htmlTagMapper->map(g_token->name);
4145  if (tagId==HTML_LI && !g_token->endTag) // found <li> tag
4146  {
4147  // ok, we can go on.
4148  }
4149  else if (((m_type==Unordered && tagId==HTML_UL) ||
4150  (m_type==Ordered && tagId==HTML_OL)
4151  ) && g_token->endTag
4152  ) // found empty list
4153  {
4154  // add dummy item to obtain valid HTML
4157  retval = RetVal_EndList;
4158  goto endlist;
4159  }
4160  else // found some other tag
4161  {
4162  // add dummy item to obtain valid HTML
4164  warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <li> tag but "
4165  "found <%s%s> instead!",g_token->endTag?"/":"",qPrint(g_token->name));
4167  goto endlist;
4168  }
4169  }
4170  else if (tok==0) // premature end of comment
4171  {
4172  // add dummy item to obtain valid HTML
4174  warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected end of comment while looking"
4175  " for a html list item");
4176  goto endlist;
4177  }
4178  else // token other than html token
4179  {
4180  // add dummy item to obtain valid HTML
4182  warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <li> tag but found %s token instead!",
4183  tokToString(tok));
4184  goto endlist;
4185  }
4186 
4187  do
4188  {
4189  DocHtmlListItem *li=new DocHtmlListItem(this,g_token->attribs,num++);
4190  m_children.append(li);
4191  retval=li->parse();
4192  } while (retval==RetVal_ListItem);
4193 
4194  if (retval==0)
4195  {
4196  warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected end of comment while inside <%cl> block",
4197  m_type==Unordered ? 'u' : 'o');
4198  }
4199 
4200 endlist:
4201  DBG(("DocHtmlList::parse() end retval=%x\n",retval));
4202  DocNode *n=g_nodeStack.pop();
4203  ASSERT(n==this);
4204  return retval==RetVal_EndList ? RetVal_OK : retval;
4205 }
static QCString g_fileName
Definition: docparser.cpp:95
QList< DocNode > m_children
Definition: docparser.h:189
void append(const type *d)
Definition: qlist.h:73
#define DBG(x)
Definition: docparser.cpp:59
int doctokenizerYYlineno
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
static Mapper * htmlTagMapper
Definition: cmdmapper.h:220
static QStack< DocNode > g_nodeStack
Definition: docparser.cpp:91
TokenInfo * g_token
int doctokenizerYYlex(void)
void push(const type *d)
Definition: qstack.h:58
void doctokenizerYYpushBackHtmlTag(const char *tag)
std::void_t< T > n
int map(const char *n)
Definition: cmdmapper.cpp:225
type * pop()
Definition: qstack.h:59
HtmlAttribList attribs
Definition: doctokenizer.h:102
QCString name
Definition: doctokenizer.h:77
const char * tokToString(int token)
A list of Html attributes.
Definition: htmlattrib.h:32
const char * qPrint(const char *s)
Definition: qcstring.h:797
#define ASSERT(x)
Definition: qglobal.h:590
int DocHtmlList::parseXml ( )

Definition at line 4207 of file docparser.cpp.

4208 {
4209  DBG(("DocHtmlList::parseXml() start\n"));
4210  int retval=RetVal_OK;
4211  int num=1;
4212  g_nodeStack.push(this);
4213 
4214  // get next token
4215  int tok=doctokenizerYYlex();
4216  // skip whitespace and paragraph breaks
4217  while (tok==TK_WHITESPACE || tok==TK_NEWPARA) tok=doctokenizerYYlex();
4218  // should find a html tag now
4219  if (tok==TK_HTMLTAG)
4220  {
4221  int tagId=Mappers::htmlTagMapper->map(g_token->name);
4222  //printf("g_token->name=%s g_token->endTag=%d\n",qPrint(g_token->name),g_token->endTag);
4223  if (tagId==XML_ITEM && !g_token->endTag) // found <item> tag
4224  {
4225  // ok, we can go on.
4226  }
4227  else // found some other tag
4228  {
4229  warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <item> tag but "
4230  "found <%s> instead!",qPrint(g_token->name));
4232  goto endlist;
4233  }
4234  }
4235  else if (tok==0) // premature end of comment
4236  {
4237  warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected end of comment while looking"
4238  " for a html list item");
4239  goto endlist;
4240  }
4241  else // token other than html token
4242  {
4243  warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <item> tag but found %s token instead!",
4244  tokToString(tok));
4245  goto endlist;
4246  }
4247 
4248  do
4249  {
4250  DocHtmlListItem *li=new DocHtmlListItem(this,g_token->attribs,num++);
4251  m_children.append(li);
4252  retval=li->parseXml();
4253  if (retval==0) break;
4254  //printf("retval=%x g_token->name=%s\n",retval,qPrint(g_token->name));
4255  } while (retval==RetVal_ListItem);
4256 
4257  if (retval==0)
4258  {
4259  warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected end of comment while inside <list type=\"%s\"> block",
4260  m_type==Unordered ? "bullet" : "number");
4261  }
4262 
4263 endlist:
4264  DBG(("DocHtmlList::parseXml() end retval=%x\n",retval));
4265  DocNode *n=g_nodeStack.pop();
4266  ASSERT(n==this);
4267  return retval==RetVal_EndList ||
4268  (retval==RetVal_CloseXml || g_token->name=="list") ?
4269  RetVal_OK : retval;
4270 }
static QCString g_fileName
Definition: docparser.cpp:95
QList< DocNode > m_children
Definition: docparser.h:189
void append(const type *d)
Definition: qlist.h:73
#define DBG(x)
Definition: docparser.cpp:59
int doctokenizerYYlineno
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
static Mapper * htmlTagMapper
Definition: cmdmapper.h:220
static QStack< DocNode > g_nodeStack
Definition: docparser.cpp:91
TokenInfo * g_token
int doctokenizerYYlex(void)
void push(const type *d)
Definition: qstack.h:58
void doctokenizerYYpushBackHtmlTag(const char *tag)
std::void_t< T > n
int map(const char *n)
Definition: cmdmapper.cpp:225
type * pop()
Definition: qstack.h:59
HtmlAttribList attribs
Definition: doctokenizer.h:102
QCString name
Definition: doctokenizer.h:77
const char * tokToString(int token)
const char * qPrint(const char *s)
Definition: qcstring.h:797
#define ASSERT(x)
Definition: qglobal.h:590
Type DocHtmlList::type ( ) const
inline

Definition at line 1034 of file docparser.h.

1034 { return m_type; }

Member Data Documentation

HtmlAttribList DocHtmlList::m_attribs
private

Definition at line 1042 of file docparser.h.

Type DocHtmlList::m_type
private

Definition at line 1041 of file docparser.h.


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