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

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 HtmlAttribListattribs () const
 
Token parse ()
 
- 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

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

Definition at line 866 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlHeader()

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

Definition at line 869 of file docnode.h.

869 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:140
HtmlAttribList m_attribs
Definition docnode.h:877
const HtmlAttribList & attribs() const
Definition docnode.h:872
int level() const
Definition docnode.h:871
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 872 of file docnode.h.

872{ return m_attribs; }

References m_attribs.

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

◆ level()

◆ parse()

Token DocHtmlHeader::parse ( )

Definition at line 1265 of file docnode.cpp.

1266{
1267 AUTO_TRACE();
1268 Token retval(TokenRetval::RetVal_OK);
1269 auto ns = AutoNodeStack(parser(),thisVariant());
1270
1271 Token tok = parser()->tokenizer.lex();
1272 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1273 {
1274 if (!parser()->defaultHandleToken(thisVariant(),tok,children()))
1275 {
1276 switch (tok.value())
1277 {
1278 case TokenRetval::TK_HTMLTAG:
1279 {
1280 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1281 if (tagId==HtmlTagType::HTML_H1 && parser()->context.token->endTag) // found </h1> tag
1282 {
1283 if (m_level!=1)
1284 {
1285 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h%d> ended with </h1>",
1286 m_level);
1287 }
1288 goto endheader;
1289 }
1290 else if (tagId==HtmlTagType::HTML_H2 && parser()->context.token->endTag) // found </h2> tag
1291 {
1292 if (m_level!=2)
1293 {
1294 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h%d> ended with </h2>",
1295 m_level);
1296 }
1297 goto endheader;
1298 }
1299 else if (tagId==HtmlTagType::HTML_H3 && parser()->context.token->endTag) // found </h3> tag
1300 {
1301 if (m_level!=3)
1302 {
1303 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h%d> ended with </h3>",
1304 m_level);
1305 }
1306 goto endheader;
1307 }
1308 else if (tagId==HtmlTagType::HTML_H4 && parser()->context.token->endTag) // found </h4> tag
1309 {
1310 if (m_level!=4)
1311 {
1312 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h%d> ended with </h4>",
1313 m_level);
1314 }
1315 goto endheader;
1316 }
1317 else if (tagId==HtmlTagType::HTML_H5 && parser()->context.token->endTag) // found </h5> tag
1318 {
1319 if (m_level!=5)
1320 {
1321 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h%d> ended with </h5>",
1322 m_level);
1323 }
1324 goto endheader;
1325 }
1326 else if (tagId==HtmlTagType::HTML_H6 && parser()->context.token->endTag) // found </h6> tag
1327 {
1328 if (m_level!=6)
1329 {
1330 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"<h%d> ended with </h6>",
1331 m_level);
1332 }
1333 goto endheader;
1334 }
1335 else if (tagId==HtmlTagType::HTML_A)
1336 {
1337 if (!parser()->context.token->endTag)
1338 {
1339 parser()->handleAHref(thisVariant(),children(),parser()->context.token->attribs);
1340 }
1341 }
1342 else if (tagId==HtmlTagType::HTML_BR)
1343 {
1344 children().append<DocLineBreak>(parser(),thisVariant(),parser()->context.token->attribs);
1345 }
1346 else
1347 {
1348 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected html tag <%s%s> found within <h%d> context",
1349 parser()->context.token->endTag?"/":"",qPrint(parser()->context.token->name),m_level);
1350 }
1351 }
1352 break;
1353 default:
1354 char tmp[20];
1355 qsnprintf(tmp,20,"<h%d>tag",m_level);
1357 }
1358 }
1359 tok = parser()->tokenizer.lex();
1360 }
1361 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1362 {
1363 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected end of comment while inside"
1364 " <h%d> tag",m_level);
1365 }
1366endheader:
1368 return retval;
1369}
DocNodeList & children()
Definition docnode.h:142
DocNodeVariant * thisVariant()
Definition docnode.h:92
DocTokenizer tokenizer
Token handleAHref(DocNodeVariant *parent, DocNodeList &children, const HtmlAttribList &tagHtmlAttribs)
void handlePendingStyleCommands(DocNodeVariant *parent, DocNodeList &children)
DocParserContext context
void errorHandleDefaultToken(DocNodeVariant *parent, Token tok, DocNodeList &children, const QCString &txt)
TokenRetval value() const
bool is_any_of(ARGS... args) const
HtmlTagType
Definition cmdmapper.h:169
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define warn_doc_error(file, line, fmt,...)
Definition message.h:74
const Mapper< HtmlTagType > * htmlTagMapper
#define qsnprintf
Definition qcstring.h:49
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
TokenInfo * token
Definition docparser_p.h:92
HtmlAttribList attribs

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

Referenced by attribs(), and DocHtmlHeader().

◆ m_level

int DocHtmlHeader::m_level = 0
private

Definition at line 876 of file docnode.h.

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


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