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 }
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 2728 of file docnode.cpp.

2729{
2730 AUTO_TRACE();
2731 Token retval = Token::make_RetVal_OK();
2732 int num=1;
2733 auto ns = AutoNodeStack(parser(),thisVariant());
2734
2735 // get next token
2736 Token tok=parser()->tokenizer.lex();
2737 // skip whitespace and paragraph breaks
2738 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2739 // should find a html tag now
2740 if (tok.is(TokenRetval::TK_HTMLTAG))
2741 {
2742 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2743 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2744 {
2745 // ok, we can go on.
2746 }
2747 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2749 ) && parser()->context.token->endTag
2750 ) // found empty list
2751 {
2752 // add dummy item to obtain valid HTML
2753 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2754 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2755 retval = Token::make_RetVal_EndList();
2756 goto endlist;
2757 }
2758 else // found some other tag
2759 {
2760 // add dummy item to obtain valid HTML
2761 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2762 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2763 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2764 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2765 goto endlist;
2766 }
2767 }
2768 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
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(),"unexpected end of comment while looking"
2773 " for a html list item");
2774 goto endlist;
2775 }
2776 else // token other than html token
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 found {} token instead!",
2781 tok.to_string());
2782 goto endlist;
2783 }
2784
2785 do
2786 {
2787 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2788 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2789 retval=li->parse();
2790 } while (retval.is(TokenRetval::RetVal_ListItem));
2791
2792 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2793 {
2794 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2795 m_type==Unordered ? 'u' : 'o');
2796 }
2797
2798endlist:
2799 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2800 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2801}
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:1397
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1408
TokenInfo * token
Definition docparser_p.h:93
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 2803 of file docnode.cpp.

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

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: