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

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

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

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: