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

Detailed Description

Node representing a HTML table row.

Definition at line 1251 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlRow()

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

Definition at line 1255 of file docnode.h.

DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
HtmlAttribList m_attribs
Definition docnode.h:1268
const HtmlAttribList & attribs() const
Definition docnode.h:1258
DocParser * parser()
Definition docnode.h:98
DocNodeVariant * parent()
Definition docnode.h:90

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

Member Function Documentation

◆ attribs()

const HtmlAttribList & DocHtmlRow::attribs ( ) const
inline

Definition at line 1258 of file docnode.h.

1258{ return m_attribs; }

References m_attribs.

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

◆ isHeading()

bool DocHtmlRow::isHeading ( ) const

Definition at line 2002 of file docnode.cpp.

2003{ // a row is a table heading if all cells are marked as such
2004 bool heading=TRUE;
2005 for (const auto &n : children())
2006 {
2007 const DocHtmlCell *cell = std::get_if<DocHtmlCell>(&n);
2008 if (cell && !cell->isHeading())
2009 {
2010 heading = FALSE;
2011 break;
2012 }
2013 }
2014 return !children().empty() && heading;
2015}
DocNodeList & children()
Definition docnode.h:143
bool isHeading() const
Definition docnode.h:1206
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 DocHtmlTable::numberHeaderRows(), DocbookDocVisitor::operator()(), RTFDocVisitor::operator()(), parse(), and parseXml().

◆ numCells()

size_t DocHtmlRow::numCells ( ) const
inline

Definition at line 1257 of file docnode.h.

1257{ 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 2077 of file docnode.cpp.

2078{
2079 AUTO_TRACE();
2080 Token retval = Token::make_RetVal_OK();
2081 auto ns = AutoNodeStack(parser(),thisVariant());
2082
2083 bool isHeading=FALSE;
2084 bool isFirst=TRUE;
2085 DocHtmlCell *cell=nullptr;
2086
2087 Token tok = skipSpacesForTable(parser());
2088 // should find a html tag now
2089 if (tok.is(TokenRetval::TK_HTMLTAG))
2090 {
2091 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2092 if (tagId==HtmlTagType::HTML_TD && !parser()->context.token->endTag) // found <td> tag
2093 {
2094 }
2095 else if (tagId==HtmlTagType::HTML_TH && !parser()->context.token->endTag) // found <th> tag
2096 {
2098 }
2099 else // found some other tag
2100 {
2101 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but "
2102 "found <{}{}> instead!",parser()->context.token->endTag ? "/" : "", parser()->context.token->name);
2103 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2104 goto endrow;
2105 }
2106 }
2107 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2108 {
2109 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2110 " for a html description title");
2111 goto endrow;
2112 }
2113 else // token other than html token
2114 {
2115 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found {} token instead!",
2116 tok.to_string());
2117 goto endrow;
2118 }
2119
2120 // parse one or more cells
2121 do
2122 {
2123 children().append<DocHtmlCell>(parser(),thisVariant(),
2125 isHeading);
2126 cell = children().get_last<DocHtmlCell>();
2127 cell->markFirst(isFirst);
2128 isFirst=FALSE;
2129 retval=cell->parse();
2130 isHeading = retval.is(TokenRetval::RetVal_TableHCell);
2131 //printf("DocHtmlRow:retval=%s\n",retval.to_string());
2132 if (retval.is(TokenRetval::RetVal_EndTableCell))
2133 {
2134 // get next token
2135 retval = skipSpacesForTable(parser());
2136 //printf("DocHtmlRow:retval= next=%s name=%s endTag=%d\n",retval.to_string(),qPrint(parser()->context.token->name),parser()->context.token->endTag);
2137 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2138 if (tok.is(TokenRetval::TK_HTMLTAG))
2139 {
2140 if ((tagId==HtmlTagType::HTML_TD || tagId==HtmlTagType::HTML_TH) &&
2141 !parser()->context.token->endTag) // found new <td> or <td> tag
2142 {
2143 retval = Token::make_RetVal_TableCell();
2145 }
2146 else if (tagId==HtmlTagType::HTML_TR)
2147 {
2148 if (parser()->context.token->endTag) // found </tr> tag
2149 {
2150 retval = Token::make_RetVal_EndTableRow();
2151 }
2152 else // found <tr> tag
2153 {
2154 retval = Token::make_RetVal_TableRow();
2155 }
2156 }
2157 else if (tagId==HtmlTagType::HTML_TABLE && parser()->context.token->endTag) // found </table>
2158 {
2159 retval = Token::make_RetVal_EndTable();
2160 }
2161 else // found some other tag
2162 {
2163 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td>, <th> or <tr> tag but "
2164 "found <{}{}> instead!",parser()->context.token->endTag ? "/" : "", parser()->context.token->name);
2165 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2166 goto endrow;
2167 }
2168 }
2169 else // token other than html token
2170 {
2171 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td>, <th> or <tr> tag but found {} token instead!",
2172 tok.to_string());
2173 goto endrow;
2174 }
2175 }
2176 }
2177 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2178 cell->markLast(TRUE);
2179
2180endrow:
2181 return retval;
2182}
void markLast(bool v=TRUE)
Definition docnode.h:1210
void markFirst(bool v=TRUE)
Definition docnode.h:1209
Token parse()
Definition docnode.cpp:1850
bool isHeading() const
Definition docnode.cpp:2002
DocNodeVariant * thisVariant()
Definition docnode.h:93
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:173
#define AUTO_TRACE(...)
Definition docnode.cpp:48
static Token skipSpacesForTable(DocParser *parser)
Definition docnode.cpp:2017
#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:1405
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1416
TokenInfo * token
Definition docparser_p.h:95
HtmlAttribList attribs

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

◆ parseXml()

Token DocHtmlRow::parseXml ( bool header)

Definition at line 2184 of file docnode.cpp.

2185{
2186 AUTO_TRACE();
2187 Token retval = Token::make_RetVal_OK();
2188 auto ns = AutoNodeStack(parser(),thisVariant());
2189
2190 bool isFirst=TRUE;
2191 DocHtmlCell *cell=nullptr;
2192
2193 // get next token
2194 Token tok=parser()->tokenizer.lex();
2195 // skip whitespace
2196 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2197 // should find a html tag now
2198 if (tok.is(TokenRetval::TK_HTMLTAG))
2199 {
2200 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2201 if (tagId==HtmlTagType::XML_TERM && !parser()->context.token->endTag) // found <term> tag
2202 {
2203 }
2204 else if (tagId==HtmlTagType::XML_DESCRIPTION && !parser()->context.token->endTag) // found <description> tag
2205 {
2206 }
2207 else // found some other tag
2208 {
2209 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <term> or <description> tag but "
2210 "found <{}> instead!",parser()->context.token->name);
2211 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2212 goto endrow;
2213 }
2214 }
2215 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2216 {
2217 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2218 " for a html description title");
2219 goto endrow;
2220 }
2221 else // token other than html token
2222 {
2223 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found {} token instead!",
2224 tok.to_string());
2225 goto endrow;
2226 }
2227
2228 do
2229 {
2231 cell = children().get_last<DocHtmlCell>();
2232 cell->markFirst(isFirst);
2233 isFirst=FALSE;
2234 retval=cell->parseXml();
2235 }
2236 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2237 cell->markLast(TRUE);
2238
2239endrow:
2240 return retval;
2241}
Token parseXml()
Definition docnode.cpp:1884

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

1264{ return m_rowIdx; }
uint32_t m_rowIdx
Definition docnode.h:1270

References m_rowIdx.

◆ setRowIndex()

void DocHtmlRow::setRowIndex ( uint32_t idx)
inlineprivate

Definition at line 1267 of file docnode.h.

1267{ m_rowIdx = idx; }

References m_rowIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ setVisibleCells()

void DocHtmlRow::setVisibleCells ( uint32_t n)
inline

Definition at line 1262 of file docnode.h.

1262{ m_visibleCells = n; }
uint32_t m_visibleCells
Definition docnode.h:1269

References m_visibleCells.

Referenced by DocHtmlTable::computeTableGrid().

◆ visibleCells()

uint32_t DocHtmlRow::visibleCells ( ) const
inline

Definition at line 1263 of file docnode.h.

1263{ return m_visibleCells; }

References m_visibleCells.

◆ DocHtmlTable

friend class DocHtmlTable
friend

Definition at line 1253 of file docnode.h.

References DocHtmlTable.

Referenced by DocHtmlTable.

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlRow::m_attribs
private

Definition at line 1268 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 1270 of file docnode.h.

Referenced by rowIndex(), and setRowIndex().

◆ m_visibleCells

uint32_t DocHtmlRow::m_visibleCells = 0
private

Definition at line 1269 of file docnode.h.

Referenced by setVisibleCells(), and visibleCells().


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