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 }
Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)

Detailed Description

Node representing a Html list.

Definition at line 994 of file docnode.h.

Member Enumeration Documentation

◆ Type

Enumerator
Unordered 
Ordered 

Definition at line 997 of file docnode.h.

997{ Unordered, Ordered };

Constructor & Destructor Documentation

◆ DocHtmlList()

DocHtmlList::DocHtmlList ( DocParser * parser,
DocNodeVariant * parent,
const HtmlAttribList & attribs,
Type t )
inline

Definition at line 998 of file docnode.h.

998 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:140
Type m_type
Definition docnode.h:1006
const HtmlAttribList & attribs() const
Definition docnode.h:1001
HtmlAttribList m_attribs
Definition docnode.h:1007
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 2551 of file docnode.cpp.

2552{
2553 AUTO_TRACE();
2554 Token retval = Token::make_RetVal_OK();
2555 int num=1;
2556 auto ns = AutoNodeStack(parser(),thisVariant());
2557
2558 // get next token
2559 Token tok=parser()->tokenizer.lex();
2560 // skip whitespace and paragraph breaks
2561 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2562 // should find a html tag now
2563 if (tok.is(TokenRetval::TK_HTMLTAG))
2564 {
2565 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2566 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2567 {
2568 // ok, we can go on.
2569 }
2570 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2572 ) && parser()->context.token->endTag
2573 ) // found empty list
2574 {
2575 // add dummy item to obtain valid HTML
2576 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2577 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2578 retval = Token::make_RetVal_EndList();
2579 goto endlist;
2580 }
2581 else // found some other tag
2582 {
2583 // add dummy item to obtain valid HTML
2584 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2585 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2586 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2587 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2588 goto endlist;
2589 }
2590 }
2591 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2592 {
2593 // add dummy item to obtain valid HTML
2594 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2595 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2596 " for a html list item");
2597 goto endlist;
2598 }
2599 else // token other than html token
2600 {
2601 // add dummy item to obtain valid HTML
2602 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2603 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but found {} token instead!",
2604 tok.to_string());
2605 goto endlist;
2606 }
2607
2608 do
2609 {
2610 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2611 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2612 retval=li->parse();
2613 } while (retval.is(TokenRetval::RetVal_ListItem));
2614
2615 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2616 {
2617 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2618 m_type==Unordered ? 'u' : 'o');
2619 }
2620
2621endlist:
2622 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2623 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2624}
DocNodeList & children()
Definition docnode.h:142
DocNodeVariant * thisVariant()
Definition docnode.h:92
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:169
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:48
#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:1394
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1405
TokenInfo * token
Definition docparser_p.h:92
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 2626 of file docnode.cpp.

2627{
2628 AUTO_TRACE();
2629 Token retval = Token::make_RetVal_OK();
2630 int num=1;
2631 auto ns = AutoNodeStack(parser(),thisVariant());
2632
2633 // get next token
2634 Token tok=parser()->tokenizer.lex();
2635 // skip whitespace and paragraph breaks
2636 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2637 // should find a html tag now
2638 if (tok.is(TokenRetval::TK_HTMLTAG))
2639 {
2640 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2641 //printf("parser()->context.token->name=%s parser()->context.token->endTag=%d\n",qPrint(parser()->context.token->name),parser()->context.token->endTag);
2642 if (tagId==HtmlTagType::XML_ITEM && !parser()->context.token->endTag) // found <item> tag
2643 {
2644 // ok, we can go on.
2645 }
2646 else // found some other tag
2647 {
2648 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but "
2649 "found <{}> instead!",parser()->context.token->name);
2650 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2651 goto endlist;
2652 }
2653 }
2654 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2655 {
2656 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2657 " for a html list item");
2658 goto endlist;
2659 }
2660 else // token other than html token
2661 {
2662 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but found {} token instead!",
2663 tok.to_string());
2664 goto endlist;
2665 }
2666
2667 do
2668 {
2669 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2670 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2671 retval=li->parseXml();
2672 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
2673 //printf("retval=%x parser()->context.token->name=%s\n",retval,qPrint(parser()->context.token->name));
2674 } while (retval.is(TokenRetval::RetVal_ListItem));
2675
2676 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2677 {
2678 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <list type=\"{}\"> block",
2679 m_type==Unordered ? "bullet" : "number");
2680 }
2681
2682endlist:
2683 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2684 return (retval.is_any_of(TokenRetval::RetVal_EndList,TokenRetval::RetVal_CloseXml) || parser()->context.token->name=="list") ?
2685 Token::make_RetVal_OK() : retval;
2686}

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 1007 of file docnode.h.

Referenced by attribs(), and DocHtmlList().

◆ m_type

Type DocHtmlList::m_type = Unordered
private

Definition at line 1006 of file docnode.h.

Referenced by DocHtmlList(), parse(), parseXml(), and type().


The documentation for this class was generated from the following files: