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

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:97
DocNodeVariant * parent()
Definition docnode.h:89

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

Member Function Documentation

◆ attribs()

◆ parse()

Token DocHtmlList::parse ( )

Definition at line 2792 of file docnode.cpp.

2793{
2794 AUTO_TRACE();
2795 Token retval = Token::make_RetVal_OK();
2796 int num=1;
2797 auto ns = AutoNodeStack(parser(),thisVariant());
2798
2799 // get next token
2800 Token tok=parser()->tokenizer.lex();
2801 // skip whitespace and paragraph breaks
2802 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2803 // should find a html tag now
2804 if (tok.is(TokenRetval::TK_HTMLTAG))
2805 {
2806 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2807 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2808 {
2809 // ok, we can go on.
2810 }
2811 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2813 ) && parser()->context.token->endTag
2814 ) // found empty list
2815 {
2816 // add dummy item to obtain valid HTML
2817 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2818 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2819 retval = Token::make_RetVal_EndList();
2820 goto endlist;
2821 }
2822 else // found some other tag
2823 {
2824 // add dummy item to obtain valid HTML
2825 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2826 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2827 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2828 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2829 goto endlist;
2830 }
2831 }
2832 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2833 {
2834 // add dummy item to obtain valid HTML
2835 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2836 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2837 " for a html list item");
2838 goto endlist;
2839 }
2840 else // token other than html token
2841 {
2842 // add dummy item to obtain valid HTML
2843 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2844 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but found {} token instead!",
2845 tok.to_string());
2846 goto endlist;
2847 }
2848
2849 do
2850 {
2851 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2852 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2853 retval=li->parse();
2854 } while (retval.is(TokenRetval::RetVal_ListItem));
2855
2856 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2857 {
2858 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2859 m_type==Unordered ? 'u' : 'o');
2860 }
2861
2862endlist:
2863 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2864 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2865}
DocNodeList & children()
Definition docnode.h:143
DocNodeVariant * thisVariant()
Definition docnode.h:92
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
DocTokenizer tokenizer
DocParserContext context
void pushBackHtmlTag(const DString &tag)
bool is(TokenRetval rv) const
TOKEN_SPECIFICATIONS RETVAL_SPECIFICATIONS const char * to_string() const
bool is_any_of(ARGS... args) const
HtmlAttribList attribs
HtmlTagType
Definition cmdmapper.h:174
#define AUTO_TRACE(...)
Definition docnode.cpp:53
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:55
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
const Mapper< HtmlTagType > * htmlTagMapper
TokenInfo * token
Definition docparser_p.h:94

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

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

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: