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

Node representing a HTML table row. More...

#include <src/docnode.h>

+ Inheritance diagram for DocHtmlRow:
+ Collaboration diagram for DocHtmlRow:

Public Member Functions

 DocHtmlRow (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs)
 
size_t numCells () const
 
const HtmlAttribListattribs () const
 
Token parse ()
 
Token parseXml (bool header)
 
bool isHeading () const
 
void setVisibleCells (uint32_t n)
 
uint32_t visibleCells () const
 
uint32_t rowIndex () const
 
- 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 Member Functions

void setRowIndex (uint32_t idx)
 

Private Attributes

HtmlAttribList m_attribs
 
uint32_t m_visibleCells = 0
 
uint32_t m_rowIdx = static_cast<uint32_t>(-1)
 

Friends

class DocHtmlTable
 

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 table row.

Definition at line 1225 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlRow()

DocHtmlRow::DocHtmlRow ( DocParser * parser,
DocNodeVariant * parent,
const HtmlAttribList & attribs )
inline

Definition at line 1229 of file docnode.h.

DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:140
HtmlAttribList m_attribs
Definition docnode.h:1242
const HtmlAttribList & attribs() const
Definition docnode.h:1232
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89

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

Member Function Documentation

◆ attribs()

const HtmlAttribList & DocHtmlRow::attribs ( ) const
inline

Definition at line 1232 of file docnode.h.

1232{ return m_attribs; }

References m_attribs.

Referenced by DocHtmlRow(), DocbookDocVisitor::operator()(), and HtmlDocVisitor::operator()().

◆ isHeading()

bool DocHtmlRow::isHeading ( ) const

Definition at line 1881 of file docnode.cpp.

1882{ // a row is a table heading if all cells are marked as such
1883 bool heading=TRUE;
1884 for (const auto &n : children())
1885 {
1886 const DocHtmlCell *cell = std::get_if<DocHtmlCell>(&n);
1887 if (cell && !cell->isHeading())
1888 {
1889 heading = FALSE;
1890 break;
1891 }
1892 }
1893 return !children().empty() && heading;
1894}
DocNodeList & children()
Definition docnode.h:142
bool isHeading() const
Definition docnode.h:1180
bool empty() const
checks whether the container is empty
Definition growvector.h:140
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References DocCompoundNode::children(), GrowVector< T >::empty(), FALSE, DocHtmlCell::isHeading(), and TRUE.

Referenced by DocbookDocVisitor::operator()(), LatexDocVisitor::operator()(), RTFDocVisitor::operator()(), parse(), and parseXml().

◆ numCells()

size_t DocHtmlRow::numCells ( ) const
inline

Definition at line 1231 of file docnode.h.

1231{ return children().size(); }
size_t size() const
returns the number of elements
Definition growvector.h:93

References DocCompoundNode::children(), and GrowVector< T >::size().

Referenced by RTFDocVisitor::operator()().

◆ parse()

Token DocHtmlRow::parse ( )

Definition at line 1896 of file docnode.cpp.

1897{
1898 AUTO_TRACE();
1899 Token retval = Token::make_RetVal_OK();
1900 auto ns = AutoNodeStack(parser(),thisVariant());
1901
1902 bool isHeading=FALSE;
1903 bool isFirst=TRUE;
1904 DocHtmlCell *cell=nullptr;
1905
1906 // get next token
1907 Token tok=parser()->tokenizer.lex();
1908 // skip whitespace
1909 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
1910 // should find a html tag now
1911 if (tok.is(TokenRetval::TK_HTMLTAG))
1912 {
1913 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1914 if (tagId==HtmlTagType::HTML_TD && !parser()->context.token->endTag) // found <td> tag
1915 {
1916 }
1917 else if (tagId==HtmlTagType::HTML_TH && !parser()->context.token->endTag) // found <th> tag
1918 {
1920 }
1921 else // found some other tag
1922 {
1923 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but "
1924 "found <%s> instead!",qPrint(parser()->context.token->name));
1925 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
1926 goto endrow;
1927 }
1928 }
1929 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
1930 {
1931 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
1932 " for a html description title");
1933 goto endrow;
1934 }
1935 else // token other than html token
1936 {
1937 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found %s token instead!",
1938 tok.to_string());
1939 goto endrow;
1940 }
1941
1942 // parse one or more cells
1943 do
1944 {
1945 children().append<DocHtmlCell>(parser(),thisVariant(),
1947 isHeading);
1948 cell = children().get_last<DocHtmlCell>();
1949 cell->markFirst(isFirst);
1950 isFirst=FALSE;
1951 retval=cell->parse();
1952 isHeading = retval.is(TokenRetval::RetVal_TableHCell);
1953 }
1954 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
1955 cell->markLast(TRUE);
1956
1957endrow:
1958 return retval;
1959}
void markLast(bool v=TRUE)
Definition docnode.h:1184
void markFirst(bool v=TRUE)
Definition docnode.h:1183
Token parse()
Definition docnode.cpp:1729
bool isHeading() const
Definition docnode.cpp:1881
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:167
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define warn_doc_error(file, line, fmt,...)
Definition message.h:74
const Mapper< HtmlTagType > * htmlTagMapper
const char * qPrint(const char *s)
Definition qcstring.h:661
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1379
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1390
TokenInfo * token
Definition docparser_p.h:92
HtmlAttribList attribs

References DocNodeList::append(), TokenInfo::attribs, AUTO_TRACE, DocCompoundNode::children(), DocParser::context, FALSE, DocNodeList::get_last(), HTML_TD, HTML_TH, Mappers::htmlTagMapper, Token::is(), Token::is_any_of(), isHeading(), DocTokenizer::lex(), DocHtmlCell::markFirst(), DocHtmlCell::markLast(), DocHtmlCell::parse(), DocNode::parser(), DocTokenizer::pushBackHtmlTag(), qPrint(), DocNode::thisVariant(), Token::to_string(), DocParserContext::token, DocParser::tokenizer, TRUE, and warn_doc_error.

◆ parseXml()

Token DocHtmlRow::parseXml ( bool header)

Definition at line 1961 of file docnode.cpp.

1962{
1963 AUTO_TRACE();
1964 Token retval = Token::make_RetVal_OK();
1965 auto ns = AutoNodeStack(parser(),thisVariant());
1966
1967 bool isFirst=TRUE;
1968 DocHtmlCell *cell=nullptr;
1969
1970 // get next token
1971 Token tok=parser()->tokenizer.lex();
1972 // skip whitespace
1973 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
1974 // should find a html tag now
1975 if (tok.is(TokenRetval::TK_HTMLTAG))
1976 {
1977 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1978 if (tagId==HtmlTagType::XML_TERM && !parser()->context.token->endTag) // found <term> tag
1979 {
1980 }
1981 else if (tagId==HtmlTagType::XML_DESCRIPTION && !parser()->context.token->endTag) // found <description> tag
1982 {
1983 }
1984 else // found some other tag
1985 {
1986 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <term> or <description> tag but "
1987 "found <%s> instead!",qPrint(parser()->context.token->name));
1988 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
1989 goto endrow;
1990 }
1991 }
1992 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
1993 {
1994 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
1995 " for a html description title");
1996 goto endrow;
1997 }
1998 else // token other than html token
1999 {
2000 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found %s token instead!",
2001 tok.to_string());
2002 goto endrow;
2003 }
2004
2005 do
2006 {
2008 cell = children().get_last<DocHtmlCell>();
2009 cell->markFirst(isFirst);
2010 isFirst=FALSE;
2011 retval=cell->parseXml();
2012 }
2013 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2014 cell->markLast(TRUE);
2015
2016endrow:
2017 return retval;
2018}
Token parseXml()
Definition docnode.cpp:1763

References DocNodeList::append(), TokenInfo::attribs, AUTO_TRACE, DocCompoundNode::children(), DocParser::context, FALSE, DocNodeList::get_last(), Mappers::htmlTagMapper, Token::is(), Token::is_any_of(), isHeading(), DocTokenizer::lex(), DocHtmlCell::markFirst(), DocHtmlCell::markLast(), DocNode::parser(), DocHtmlCell::parseXml(), DocTokenizer::pushBackHtmlTag(), qPrint(), DocNode::thisVariant(), Token::to_string(), DocParserContext::token, DocParser::tokenizer, TRUE, warn_doc_error, XML_DESCRIPTION, and XML_TERM.

◆ rowIndex()

uint32_t DocHtmlRow::rowIndex ( ) const
inline

Definition at line 1238 of file docnode.h.

1238{ return m_rowIdx; }
uint32_t m_rowIdx
Definition docnode.h:1244

References m_rowIdx.

Referenced by LatexDocVisitor::operator()().

◆ setRowIndex()

void DocHtmlRow::setRowIndex ( uint32_t idx)
inlineprivate

Definition at line 1241 of file docnode.h.

1241{ m_rowIdx = idx; }

References m_rowIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ setVisibleCells()

void DocHtmlRow::setVisibleCells ( uint32_t n)
inline

Definition at line 1236 of file docnode.h.

1236{ m_visibleCells = n; }
uint32_t m_visibleCells
Definition docnode.h:1243

References m_visibleCells.

Referenced by DocHtmlTable::computeTableGrid().

◆ visibleCells()

uint32_t DocHtmlRow::visibleCells ( ) const
inline

Definition at line 1237 of file docnode.h.

1237{ return m_visibleCells; }

References m_visibleCells.

Friends And Related Symbol Documentation

◆ DocHtmlTable

friend class DocHtmlTable
friend

Definition at line 1227 of file docnode.h.

References DocHtmlTable.

Referenced by DocHtmlTable.

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlRow::m_attribs
private

Definition at line 1242 of file docnode.h.

Referenced by attribs(), and DocHtmlRow().

◆ m_rowIdx

uint32_t DocHtmlRow::m_rowIdx = static_cast<uint32_t>(-1)
private

Definition at line 1244 of file docnode.h.

Referenced by rowIndex(), and setRowIndex().

◆ m_visibleCells

uint32_t DocHtmlRow::m_visibleCells = 0
private

Definition at line 1243 of file docnode.h.

Referenced by setVisibleCells(), and visibleCells().


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