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 1008 of file docnode.h.

Member Enumeration Documentation

◆ Type

Enumerator
Unordered 
Ordered 

Definition at line 1011 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlList()

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

Definition at line 1012 of file docnode.h.

1012 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
Type m_type
Definition docnode.h:1020
const HtmlAttribList & attribs() const
Definition docnode.h:1015
HtmlAttribList m_attribs
Definition docnode.h:1021
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 2787 of file docnode.cpp.

2788{
2789 AUTO_TRACE();
2790 Token retval = Token::make_RetVal_OK();
2791 int num=1;
2792 auto ns = AutoNodeStack(parser(),thisVariant());
2793
2794 // get next token
2795 Token tok=parser()->tokenizer.lex();
2796 // skip whitespace and paragraph breaks
2797 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2798 // should find a html tag now
2799 if (tok.is(TokenRetval::TK_HTMLTAG))
2800 {
2801 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2802 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2803 {
2804 // ok, we can go on.
2805 }
2806 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2808 ) && parser()->context.token->endTag
2809 ) // found empty list
2810 {
2811 // add dummy item to obtain valid HTML
2812 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2813 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2814 retval = Token::make_RetVal_EndList();
2815 goto endlist;
2816 }
2817 else // found some other tag
2818 {
2819 // add dummy item to obtain valid HTML
2820 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2821 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2822 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2823 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2824 goto endlist;
2825 }
2826 }
2827 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2828 {
2829 // add dummy item to obtain valid HTML
2830 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2831 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2832 " for a html list item");
2833 goto endlist;
2834 }
2835 else // token other than html token
2836 {
2837 // add dummy item to obtain valid HTML
2838 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2839 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> 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->parse();
2849 } while (retval.is(TokenRetval::RetVal_ListItem));
2850
2851 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2852 {
2853 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2854 m_type==Unordered ? 'u' : 'o');
2855 }
2856
2857endlist:
2858 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2859 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2860}
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:173
#define AUTO_TRACE(...)
Definition docnode.cpp:48
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:50
#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:1405
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1416
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 2862 of file docnode.cpp.

2863{
2864 AUTO_TRACE();
2865 Token retval = Token::make_RetVal_OK();
2866 int num=1;
2867 auto ns = AutoNodeStack(parser(),thisVariant());
2868
2869 // get next token
2870 Token tok=parser()->tokenizer.lex();
2871 // skip whitespace and paragraph breaks
2872 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2873 // should find a html tag now
2874 if (tok.is(TokenRetval::TK_HTMLTAG))
2875 {
2876 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2877 //printf("parser()->context.token->name=%s parser()->context.token->endTag=%d\n",qPrint(parser()->context.token->name),parser()->context.token->endTag);
2878 if (tagId==HtmlTagType::XML_ITEM && !parser()->context.token->endTag) // found <item> tag
2879 {
2880 // ok, we can go on.
2881 }
2882 else // found some other tag
2883 {
2884 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but "
2885 "found <{}> instead!",parser()->context.token->name);
2886 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2887 goto endlist;
2888 }
2889 }
2890 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2891 {
2892 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2893 " for a html list item");
2894 goto endlist;
2895 }
2896 else // token other than html token
2897 {
2898 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but found {} token instead!",
2899 tok.to_string());
2900 goto endlist;
2901 }
2902
2903 do
2904 {
2905 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2906 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2907 retval=li->parseXml();
2908 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
2909 //printf("retval=%x parser()->context.token->name=%s\n",retval,qPrint(parser()->context.token->name));
2910 } while (retval.is(TokenRetval::RetVal_ListItem));
2911
2912 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2913 {
2914 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <list type=\"{}\"> block",
2915 m_type==Unordered ? "bullet" : "number");
2916 }
2917
2918endlist:
2919 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2920 return (retval.is_any_of(TokenRetval::RetVal_EndList,TokenRetval::RetVal_CloseXml) || parser()->context.token->name=="list") ?
2921 Token::make_RetVal_OK() : retval;
2922}

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 1021 of file docnode.h.

Referenced by attribs(), and DocHtmlList().

◆ m_type

Type DocHtmlList::m_type = Unordered
private

Definition at line 1020 of file docnode.h.

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


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