Doxygen
Loading...
Searching...
No Matches
DocHtmlHeader Class Referencefinal

Node Html heading. More...

#include <src/docnode.h>

Inheritance diagram for DocHtmlHeader:
Collaboration diagram for DocHtmlHeader:

Public Member Functions

 DocHtmlHeader (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs, int level)
int level () const
const HtmlAttribList & attribs () const
Token parse ()
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

int m_level = 0
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 Html heading.

Definition at line 881 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlHeader()

DocHtmlHeader::DocHtmlHeader ( DocParser * parser,
DocNodeVariant * parent,
const HtmlAttribList & attribs,
int level )
inline

Definition at line 884 of file docnode.h.

884 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
HtmlAttribList m_attribs
Definition docnode.h:892
const HtmlAttribList & attribs() const
Definition docnode.h:887
int level() const
Definition docnode.h:886
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89

References attribs(), DocCompoundNode::DocCompoundNode(), level(), m_attribs, m_level, DocNode::parent(), and DocNode::parser().

Member Function Documentation

◆ attribs()

const HtmlAttribList & DocHtmlHeader::attribs ( ) const
inline

Definition at line 887 of file docnode.h.

887{ return m_attribs; }

References m_attribs.

Referenced by DocHtmlHeader(), and HtmlDocVisitor::operator()().

◆ level()

◆ parse()

Token DocHtmlHeader::parse ( )

Definition at line 1394 of file docnode.cpp.

1395{
1396 AUTO_TRACE();
1397 Token retval(TokenRetval::RetVal_OK);
1398 auto ns = AutoNodeStack(parser(),thisVariant());
1399
1400 Token tok = parser()->tokenizer.lex();
1401 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1402 {
1403 if (!parser()->defaultHandleToken(thisVariant(),tok,children()))
1404 {
1405 switch (tok.value())
1406 {
1407 case TokenRetval::TK_HTMLTAG:
1408 {
1409 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1410 if (tagId==HtmlTagType::HTML_H1 && parser()->context.token->endTag) // found </h1> tag
1411 {
1412 if (m_level!=1)
1413 {
1414 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h{:d}> ended with </h1>",
1415 m_level);
1416 }
1417 goto endheader;
1418 }
1419 else if (tagId==HtmlTagType::HTML_H2 && parser()->context.token->endTag) // found </h2> tag
1420 {
1421 if (m_level!=2)
1422 {
1423 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h{:d}> ended with </h2>",
1424 m_level);
1425 }
1426 goto endheader;
1427 }
1428 else if (tagId==HtmlTagType::HTML_H3 && parser()->context.token->endTag) // found </h3> tag
1429 {
1430 if (m_level!=3)
1431 {
1432 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h{:d}> ended with </h3>",
1433 m_level);
1434 }
1435 goto endheader;
1436 }
1437 else if (tagId==HtmlTagType::HTML_H4 && parser()->context.token->endTag) // found </h4> tag
1438 {
1439 if (m_level!=4)
1440 {
1441 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h{:d}> ended with </h4>",
1442 m_level);
1443 }
1444 goto endheader;
1445 }
1446 else if (tagId==HtmlTagType::HTML_H5 && parser()->context.token->endTag) // found </h5> tag
1447 {
1448 if (m_level!=5)
1449 {
1450 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h{:d}> ended with </h5>",
1451 m_level);
1452 }
1453 goto endheader;
1454 }
1455 else if (tagId==HtmlTagType::HTML_H6 && parser()->context.token->endTag) // found </h6> tag
1456 {
1457 if (m_level!=6)
1458 {
1459 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h{:d}> ended with </h6>",
1460 m_level);
1461 }
1462 goto endheader;
1463 }
1464 else if (tagId==HtmlTagType::HTML_A)
1465 {
1466 if (!parser()->context.token->endTag)
1467 {
1468 parser()->handleAHref(thisVariant(),children(),parser()->context.token->attribs);
1469 }
1470 }
1471 else if (tagId==HtmlTagType::HTML_BR)
1472 {
1473 children().append<DocLineBreak>(parser(),thisVariant(),parser()->context.token->attribs);
1474 }
1475 else
1476 {
1477 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected html tag <{}{}> found within <h{:d}> context",
1478 parser()->context.token->endTag?"/":"",parser()->context.token->name,m_level);
1479 }
1480 }
1481 break;
1482 default:
1483 char tmp[20];
1484 snprintf(tmp,20,"<h%d> tag",m_level);
1486 }
1487 }
1488 tok = parser()->tokenizer.lex();
1489 }
1490 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1491 {
1492 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected end of comment while inside"
1493 " <h{:d}> tag",m_level);
1494 }
1495endheader:
1497 return retval;
1498}
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
void handlePendingStyleCommands(DocNodeVariant *parent, DocNodeList &children, size_t numberOfElementsToClose=0)
DocTokenizer tokenizer
void errorHandleDefaultToken(DocNodeVariant *parent, Token tok, DocNodeList &children, const DString &txt)
Token handleAHref(DocNodeVariant *parent, DocNodeList &children, const HtmlAttribList &tagHtmlAttribs)
DocParserContext context
TokenRetval value() const
bool is_any_of(ARGS... args) const
HtmlAttribList attribs
HtmlTagType
Definition cmdmapper.h:174
#define AUTO_TRACE(...)
Definition docnode.cpp:53
#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, DocCompoundNode::children(), DocParser::context, DocParser::errorHandleDefaultToken(), DocParser::handleAHref(), DocParser::handlePendingStyleCommands(), HTML_A, HTML_BR, HTML_H1, HTML_H2, HTML_H3, HTML_H4, HTML_H5, HTML_H6, Mappers::htmlTagMapper, Token::is_any_of(), DocTokenizer::lex(), m_level, DocNode::parser(), DocNode::thisVariant(), DocParserContext::token, DocParser::tokenizer, Token::value(), and warn_doc_error.

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlHeader::m_attribs
private

Definition at line 892 of file docnode.h.

Referenced by attribs(), and DocHtmlHeader().

◆ m_level

int DocHtmlHeader::m_level = 0
private

Definition at line 891 of file docnode.h.

Referenced by DocHtmlHeader(), level(), and parse().


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