Doxygen
Loading...
Searching...
No Matches
DocHtmlList Class Reference

Node representing a Html list. More...

#include <src/docnode.h>

Inheritance diagram for DocHtmlList:
Collaboration diagram for DocHtmlList:

Public Types

enum  Type { Unordered , Ordered }

Public Member Functions

 DocHtmlList (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs, Type t)
Type type () const
const HtmlAttribListattribs () const
Token parse ()
Token parseXml ()
Public Member Functions inherited from DocCompoundNode
 DocCompoundNode (DocParser *parser, DocNodeVariant *parent)
DocNodeListchildren ()
const DocNodeListchildren () const
Public Member Functions inherited from DocNode
 DocNode (DocParser *parser, DocNodeVariant *parent)
 ~DocNode ()=default
DocNodeVariantparent ()
const DocNodeVariantparent () const
DocNodeVariantthisVariant ()
const DocNodeVariantthisVariant () const
void setThisVariant (DocNodeVariant *thisVariant)
DocParserparser ()
const DocParserparser () const
void setParent (DocNodeVariant *parent)
bool isPreformatted () const

Private Attributes

Type m_type = Unordered
HtmlAttribList m_attribs

Additional Inherited Members

Protected Types inherited from DocNode
enum  RefType {
  Unknown , Anchor , Section , Table ,
  Requirement
}
Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)

Detailed Description

Node representing a Html list.

Definition at line 999 of file docnode.h.

Member Enumeration Documentation

◆ Type

Enumerator
Unordered 
Ordered 

Definition at line 1002 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlList()

DocHtmlList::DocHtmlList ( DocParser * parser,
DocNodeVariant * parent,
const HtmlAttribList & attribs,
Type t )
inline

Definition at line 1003 of file docnode.h.

1003 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
Type m_type
Definition docnode.h:1011
const HtmlAttribList & attribs() const
Definition docnode.h:1006
HtmlAttribList m_attribs
Definition docnode.h:1012
DocParser * parser()
Definition docnode.h:98
DocNodeVariant * parent()
Definition docnode.h:90

References attribs(), DocCompoundNode::DocCompoundNode(), m_attribs, m_type, DocNode::parent(), and DocNode::parser().

Member Function Documentation

◆ attribs()

◆ parse()

Token DocHtmlList::parse ( )

Definition at line 2746 of file docnode.cpp.

2747{
2748 AUTO_TRACE();
2749 Token retval = Token::make_RetVal_OK();
2750 int num=1;
2751 auto ns = AutoNodeStack(parser(),thisVariant());
2752
2753 // get next token
2754 Token tok=parser()->tokenizer.lex();
2755 // skip whitespace and paragraph breaks
2756 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2757 // should find a html tag now
2758 if (tok.is(TokenRetval::TK_HTMLTAG))
2759 {
2760 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2761 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2762 {
2763 // ok, we can go on.
2764 }
2765 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2767 ) && parser()->context.token->endTag
2768 ) // found empty list
2769 {
2770 // add dummy item to obtain valid HTML
2771 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2772 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2773 retval = Token::make_RetVal_EndList();
2774 goto endlist;
2775 }
2776 else // found some other tag
2777 {
2778 // add dummy item to obtain valid HTML
2779 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2780 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2781 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2782 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2783 goto endlist;
2784 }
2785 }
2786 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2787 {
2788 // add dummy item to obtain valid HTML
2789 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2790 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2791 " for a html list item");
2792 goto endlist;
2793 }
2794 else // token other than html token
2795 {
2796 // add dummy item to obtain valid HTML
2797 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2798 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but found {} token instead!",
2799 tok.to_string());
2800 goto endlist;
2801 }
2802
2803 do
2804 {
2805 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2806 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2807 retval=li->parse();
2808 } while (retval.is(TokenRetval::RetVal_ListItem));
2809
2810 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2811 {
2812 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2813 m_type==Unordered ? 'u' : 'o');
2814 }
2815
2816endlist:
2817 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2818 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2819}
DocNodeList & children()
Definition docnode.h:143
DocNodeVariant * thisVariant()
Definition docnode.h:93
DocTokenizer tokenizer
DocParserContext context
void pushBackHtmlTag(const QCString &tag)
bool is(TokenRetval rv) const
TOKEN_SPECIFICATIONS RETVAL_SPECIFICATIONS const char * to_string() const
bool is_any_of(ARGS... args) const
HtmlTagType
Definition cmdmapper.h:170
#define AUTO_TRACE(...)
Definition docnode.cpp:47
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:49
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
const Mapper< HtmlTagType > * htmlTagMapper
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1396
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1407
TokenInfo * token
Definition docparser_p.h:95
HtmlAttribList attribs

References DocNodeList::append(), TokenInfo::attribs, AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children(), DocParser::context, DocNodeList::get_last(), HTML_LI, HTML_OL, HTML_UL, Mappers::htmlTagMapper, Token::is(), Token::is_any_of(), DocTokenizer::lex(), m_type, Ordered, DocNode::parser(), DocTokenizer::pushBackHtmlTag(), DocNode::thisVariant(), Token::to_string(), DocParserContext::token, DocParser::tokenizer, Unordered, and warn_doc_error.

◆ parseXml()

Token DocHtmlList::parseXml ( )

Definition at line 2821 of file docnode.cpp.

2822{
2823 AUTO_TRACE();
2824 Token retval = Token::make_RetVal_OK();
2825 int num=1;
2826 auto ns = AutoNodeStack(parser(),thisVariant());
2827
2828 // get next token
2829 Token tok=parser()->tokenizer.lex();
2830 // skip whitespace and paragraph breaks
2831 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2832 // should find a html tag now
2833 if (tok.is(TokenRetval::TK_HTMLTAG))
2834 {
2835 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2836 //printf("parser()->context.token->name=%s parser()->context.token->endTag=%d\n",qPrint(parser()->context.token->name),parser()->context.token->endTag);
2837 if (tagId==HtmlTagType::XML_ITEM && !parser()->context.token->endTag) // found <item> tag
2838 {
2839 // ok, we can go on.
2840 }
2841 else // found some other tag
2842 {
2843 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but "
2844 "found <{}> instead!",parser()->context.token->name);
2845 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2846 goto endlist;
2847 }
2848 }
2849 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2850 {
2851 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2852 " for a html list item");
2853 goto endlist;
2854 }
2855 else // token other than html token
2856 {
2857 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but found {} token instead!",
2858 tok.to_string());
2859 goto endlist;
2860 }
2861
2862 do
2863 {
2864 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2865 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2866 retval=li->parseXml();
2867 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
2868 //printf("retval=%x parser()->context.token->name=%s\n",retval,qPrint(parser()->context.token->name));
2869 } while (retval.is(TokenRetval::RetVal_ListItem));
2870
2871 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2872 {
2873 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <list type=\"{}\"> block",
2874 m_type==Unordered ? "bullet" : "number");
2875 }
2876
2877endlist:
2878 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2879 return (retval.is_any_of(TokenRetval::RetVal_EndList,TokenRetval::RetVal_CloseXml) || parser()->context.token->name=="list") ?
2880 Token::make_RetVal_OK() : retval;
2881}

References DocNodeList::append(), TokenInfo::attribs, AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children(), DocParser::context, DocNodeList::get_last(), Mappers::htmlTagMapper, Token::is(), Token::is_any_of(), DocTokenizer::lex(), m_type, DocNode::parser(), DocTokenizer::pushBackHtmlTag(), DocNode::thisVariant(), Token::to_string(), DocParserContext::token, DocParser::tokenizer, Unordered, warn_doc_error, and XML_ITEM.

◆ type()

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlList::m_attribs
private

Definition at line 1012 of file docnode.h.

Referenced by attribs(), and DocHtmlList().

◆ m_type

Type DocHtmlList::m_type = Unordered
private

Definition at line 1011 of file docnode.h.

Referenced by DocHtmlList(), parse(), parseXml(), and type().


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