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 HtmlAttribList & attribs () const
Token parse ()
Token parseXml ()
Public Member Functions inherited from DocCompoundNode
 DocCompoundNode (DocParser *parser, DocNodeVariant *parent)
DocNodeList & children ()
const DocNodeList & children () const
Public Member Functions inherited from DocNode
 DocNode (DocParser *parser, DocNodeVariant *parent)
 ~DocNode ()=default
DocNodeVariant * parent ()
const DocNodeVariant * parent () const
DocNodeVariant * thisVariant ()
const DocNodeVariant * thisVariant () const
void setThisVariant (DocNodeVariant *thisVariant)
DocParser * parser ()
const DocParser * parser () 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(), m_attribs, m_type, DocNode::parent(), and DocNode::parser().

Member Function Documentation

◆ attribs()

◆ parse()

Token DocHtmlList::parse ( )

Definition at line 2887 of file docnode.cpp.

2888{
2889 AUTO_TRACE();
2890 Token retval = Token::make_RetVal_OK();
2891 int num=1;
2892 auto ns = AutoNodeStack(parser(),thisVariant());
2893
2894 // get next token
2895 Token tok=parser()->tokenizer.lex();
2896 // skip whitespace and paragraph breaks
2897 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2898 // should find a html tag now
2899 if (tok.is(TokenRetval::TK_HTMLTAG))
2900 {
2901 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2902 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2903 {
2904 // ok, we can go on.
2905 }
2906 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2908 ) && parser()->context.token->endTag
2909 ) // found empty list
2910 {
2911 // add dummy item to obtain valid HTML
2912 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2913 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2914 retval = Token::make_RetVal_EndList();
2915 goto endlist;
2916 }
2917 else // found some other tag
2918 {
2919 // add dummy item to obtain valid HTML
2920 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2921 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2922 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2923 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2924 goto endlist;
2925 }
2926 }
2927 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2928 {
2929 // add dummy item to obtain valid HTML
2930 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2931 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2932 " for a html list item");
2933 goto endlist;
2934 }
2935 else // token other than html token
2936 {
2937 // add dummy item to obtain valid HTML
2938 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2939 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but found {} token instead!",
2940 tok.to_string());
2941 goto endlist;
2942 }
2943
2944 do
2945 {
2946 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2947 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2948 retval=li->parse();
2949 } while (retval.is(TokenRetval::RetVal_ListItem));
2950
2951 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2952 {
2953 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2954 m_type==Unordered ? 'u' : 'o');
2955 }
2956
2957endlist:
2958 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2959 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2960}
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 2962 of file docnode.cpp.

2963{
2964 AUTO_TRACE();
2965 Token retval = Token::make_RetVal_OK();
2966 int num=1;
2967 auto ns = AutoNodeStack(parser(),thisVariant());
2968
2969 // get next token
2970 Token tok=parser()->tokenizer.lex();
2971 // skip whitespace and paragraph breaks
2972 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2973 // should find a html tag now
2974 if (tok.is(TokenRetval::TK_HTMLTAG))
2975 {
2976 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2977 //printf("parser()->context.token->name=%s parser()->context.token->endTag=%d\n",qPrint(parser()->context.token->name),parser()->context.token->endTag);
2978 if (tagId==HtmlTagType::XML_ITEM && !parser()->context.token->endTag) // found <item> tag
2979 {
2980 // ok, we can go on.
2981 }
2982 else // found some other tag
2983 {
2984 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but "
2985 "found <{}> instead!",parser()->context.token->name);
2986 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2987 goto endlist;
2988 }
2989 }
2990 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2991 {
2992 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2993 " for a html list item");
2994 goto endlist;
2995 }
2996 else // token other than html token
2997 {
2998 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but found {} token instead!",
2999 tok.to_string());
3000 goto endlist;
3001 }
3002
3003 do
3004 {
3005 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
3006 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
3007 retval=li->parseXml();
3008 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
3009 //printf("retval=%x parser()->context.token->name=%s\n",retval,qPrint(parser()->context.token->name));
3010 } while (retval.is(TokenRetval::RetVal_ListItem));
3011
3012 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
3013 {
3014 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <list type=\"{}\"> block",
3015 m_type==Unordered ? "bullet" : "number");
3016 }
3017
3018endlist:
3019 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3020 return (retval.is_any_of(TokenRetval::RetVal_EndList,TokenRetval::RetVal_CloseXml) || parser()->context.token->name=="list") ?
3021 Token::make_RetVal_OK() : retval;
3022}

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: