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

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

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

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: