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(), DocCompoundNode::DocCompoundNode(), m_attribs, m_type, DocNode::parent(), and DocNode::parser().

Member Function Documentation

◆ attribs()

◆ parse()

Token DocHtmlList::parse ( )

Definition at line 2881 of file docnode.cpp.

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

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

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: