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

Member Enumeration Documentation

◆ Type

Enumerator
Unordered 
Ordered 

Definition at line 996 of file docnode.h.

996{ Unordered, Ordered };

Constructor & Destructor Documentation

◆ DocHtmlList()

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

Definition at line 997 of file docnode.h.

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

2537{
2538 AUTO_TRACE();
2539 Token retval = Token::make_RetVal_OK();
2540 int num=1;
2541 auto ns = AutoNodeStack(parser(),thisVariant());
2542
2543 // get next token
2544 Token tok=parser()->tokenizer.lex();
2545 // skip whitespace and paragraph breaks
2546 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2547 // should find a html tag now
2548 if (tok.is(TokenRetval::TK_HTMLTAG))
2549 {
2550 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2551 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2552 {
2553 // ok, we can go on.
2554 }
2555 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2557 ) && parser()->context.token->endTag
2558 ) // found empty list
2559 {
2560 // add dummy item to obtain valid HTML
2561 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2562 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2563 retval = Token::make_RetVal_EndList();
2564 goto endlist;
2565 }
2566 else // found some other tag
2567 {
2568 // add dummy item to obtain valid HTML
2569 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2570 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2571 "found <%s%s> instead!",parser()->context.token->endTag?"/":"",qPrint(parser()->context.token->name));
2572 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2573 goto endlist;
2574 }
2575 }
2576 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2577 {
2578 // add dummy item to obtain valid HTML
2579 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2580 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2581 " for a html list item");
2582 goto endlist;
2583 }
2584 else // token other than html token
2585 {
2586 // add dummy item to obtain valid HTML
2587 children().append<DocHtmlListItem>(parser(),thisVariant(),HtmlAttribList(),1);
2588 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but found %s token instead!",
2589 tok.to_string());
2590 goto endlist;
2591 }
2592
2593 do
2594 {
2595 children().append<DocHtmlListItem>(parser(),thisVariant(),parser()->context.token->attribs,num++);
2596 DocHtmlListItem *li = children().get_last<DocHtmlListItem>();
2597 retval=li->parse();
2598 } while (retval.is(TokenRetval::RetVal_ListItem));
2599
2600 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2601 {
2602 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <%cl> block",
2603 m_type==Unordered ? 'u' : 'o');
2604 }
2605
2606endlist:
2607 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2608 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2609}
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:74
const Mapper< HtmlTagType > * htmlTagMapper
const char * qPrint(const char *s)
Definition qcstring.h:672
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1393
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1404
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(), qPrint(), DocNode::thisVariant(), Token::to_string(), DocParserContext::token, DocParser::tokenizer, Unordered, and warn_doc_error.

◆ parseXml()

Token DocHtmlList::parseXml ( )

Definition at line 2611 of file docnode.cpp.

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

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(), qPrint(), 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 1006 of file docnode.h.

Referenced by attribs(), and DocHtmlList().

◆ m_type

Type DocHtmlList::m_type = Unordered
private

Definition at line 1005 of file docnode.h.

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


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