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

Constructor & Destructor Documentation

◆ DocHtmlRow()

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

Definition at line 1247 of file docnode.h.

DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
HtmlAttribList m_attribs
Definition docnode.h:1260
const HtmlAttribList & attribs() const
Definition docnode.h:1250
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 1250 of file docnode.h.

1250{ return m_attribs; }

References m_attribs.

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

◆ isHeading()

bool DocHtmlRow::isHeading ( ) const

Definition at line 1943 of file docnode.cpp.

1944{ // a row is a table heading if all cells are marked as such
1945 bool heading=TRUE;
1946 for (const auto &n : children())
1947 {
1948 const DocHtmlCell *cell = std::get_if<DocHtmlCell>(&n);
1949 if (cell && !cell->isHeading())
1950 {
1951 heading = FALSE;
1952 break;
1953 }
1954 }
1955 return !children().empty() && heading;
1956}
DocNodeList & children()
Definition docnode.h:143
bool isHeading() const
Definition docnode.h:1198
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 1249 of file docnode.h.

1249{ 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 2018 of file docnode.cpp.

2019{
2020 AUTO_TRACE();
2021 Token retval = Token::make_RetVal_OK();
2022 auto ns = AutoNodeStack(parser(),thisVariant());
2023
2024 bool isHeading=FALSE;
2025 bool isFirst=TRUE;
2026 DocHtmlCell *cell=nullptr;
2027
2028 Token tok = skipSpacesForTable(parser());
2029 // should find a html tag now
2030 if (tok.is(TokenRetval::TK_HTMLTAG))
2031 {
2032 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2033 if (tagId==HtmlTagType::HTML_TD && !parser()->context.token->endTag) // found <td> tag
2034 {
2035 }
2036 else if (tagId==HtmlTagType::HTML_TH && !parser()->context.token->endTag) // found <th> tag
2037 {
2039 }
2040 else // found some other tag
2041 {
2042 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but "
2043 "found <{}{}> instead!",parser()->context.token->endTag ? "/" : "", parser()->context.token->name);
2044 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2045 goto endrow;
2046 }
2047 }
2048 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2049 {
2050 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2051 " for a html description title");
2052 goto endrow;
2053 }
2054 else // token other than html token
2055 {
2056 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found {} token instead!",
2057 tok.to_string());
2058 goto endrow;
2059 }
2060
2061 // parse one or more cells
2062 do
2063 {
2064 children().append<DocHtmlCell>(parser(),thisVariant(),
2066 isHeading);
2067 cell = children().get_last<DocHtmlCell>();
2068 cell->markFirst(isFirst);
2069 isFirst=FALSE;
2070 retval=cell->parse();
2071 isHeading = retval.is(TokenRetval::RetVal_TableHCell);
2072 //printf("DocHtmlRow:retval=%s\n",retval.to_string());
2073 if (retval.is(TokenRetval::RetVal_EndTableCell))
2074 {
2075 // get next token
2076 retval = skipSpacesForTable(parser());
2077 //printf("DocHtmlRow:retval= next=%s name=%s endTag=%d\n",retval.to_string(),qPrint(parser()->context.token->name),parser()->context.token->endTag);
2078 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2079 if (tok.is(TokenRetval::TK_HTMLTAG))
2080 {
2081 if ((tagId==HtmlTagType::HTML_TD || tagId==HtmlTagType::HTML_TH) &&
2082 !parser()->context.token->endTag) // found new <td> or <td> tag
2083 {
2084 retval = Token::make_RetVal_TableCell();
2086 }
2087 else if (tagId==HtmlTagType::HTML_TR)
2088 {
2089 if (parser()->context.token->endTag) // found </tr> tag
2090 {
2091 retval = Token::make_RetVal_EndTableRow();
2092 }
2093 else // found <tr> tag
2094 {
2095 retval = Token::make_RetVal_TableRow();
2096 }
2097 }
2098 else if (tagId==HtmlTagType::HTML_TABLE && parser()->context.token->endTag) // found </table>
2099 {
2100 retval = Token::make_RetVal_EndTable();
2101 }
2102 else // found some other tag
2103 {
2104 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td>, <th> or <tr> tag but "
2105 "found <{}{}> instead!",parser()->context.token->endTag ? "/" : "", parser()->context.token->name);
2106 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2107 goto endrow;
2108 }
2109 }
2110 else // token other than html token
2111 {
2112 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td>, <th> or <tr> tag but found {} token instead!",
2113 tok.to_string());
2114 goto endrow;
2115 }
2116 }
2117 }
2118 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2119 cell->markLast(TRUE);
2120
2121endrow:
2122 return retval;
2123}
void markLast(bool v=TRUE)
Definition docnode.h:1202
void markFirst(bool v=TRUE)
Definition docnode.h:1201
Token parse()
Definition docnode.cpp:1791
bool isHeading() const
Definition docnode.cpp:1943
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:170
#define AUTO_TRACE(...)
Definition docnode.cpp:47
static Token skipSpacesForTable(DocParser *parser)
Definition docnode.cpp:1958
#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:1397
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1408
TokenInfo * token
Definition docparser_p.h:93
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 2125 of file docnode.cpp.

2126{
2127 AUTO_TRACE();
2128 Token retval = Token::make_RetVal_OK();
2129 auto ns = AutoNodeStack(parser(),thisVariant());
2130
2131 bool isFirst=TRUE;
2132 DocHtmlCell *cell=nullptr;
2133
2134 // get next token
2135 Token tok=parser()->tokenizer.lex();
2136 // skip whitespace
2137 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2138 // should find a html tag now
2139 if (tok.is(TokenRetval::TK_HTMLTAG))
2140 {
2141 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2142 if (tagId==HtmlTagType::XML_TERM && !parser()->context.token->endTag) // found <term> tag
2143 {
2144 }
2145 else if (tagId==HtmlTagType::XML_DESCRIPTION && !parser()->context.token->endTag) // found <description> tag
2146 {
2147 }
2148 else // found some other tag
2149 {
2150 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <term> or <description> tag but "
2151 "found <{}> instead!",parser()->context.token->name);
2152 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2153 goto endrow;
2154 }
2155 }
2156 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2157 {
2158 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2159 " for a html description title");
2160 goto endrow;
2161 }
2162 else // token other than html token
2163 {
2164 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found {} token instead!",
2165 tok.to_string());
2166 goto endrow;
2167 }
2168
2169 do
2170 {
2172 cell = children().get_last<DocHtmlCell>();
2173 cell->markFirst(isFirst);
2174 isFirst=FALSE;
2175 retval=cell->parseXml();
2176 }
2177 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2178 cell->markLast(TRUE);
2179
2180endrow:
2181 return retval;
2182}
Token parseXml()
Definition docnode.cpp:1825

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

1256{ return m_rowIdx; }
uint32_t m_rowIdx
Definition docnode.h:1262

References m_rowIdx.

◆ setRowIndex()

void DocHtmlRow::setRowIndex ( uint32_t idx)
inlineprivate

Definition at line 1259 of file docnode.h.

1259{ m_rowIdx = idx; }

References m_rowIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ setVisibleCells()

void DocHtmlRow::setVisibleCells ( uint32_t n)
inline

Definition at line 1254 of file docnode.h.

1254{ m_visibleCells = n; }
uint32_t m_visibleCells
Definition docnode.h:1261

References m_visibleCells.

Referenced by DocHtmlTable::computeTableGrid().

◆ visibleCells()

uint32_t DocHtmlRow::visibleCells ( ) const
inline

Definition at line 1255 of file docnode.h.

1255{ return m_visibleCells; }

References m_visibleCells.

◆ DocHtmlTable

friend class DocHtmlTable
friend

Definition at line 1245 of file docnode.h.

References DocHtmlTable.

Referenced by DocHtmlTable.

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlRow::m_attribs
private

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

Referenced by rowIndex(), and setRowIndex().

◆ m_visibleCells

uint32_t DocHtmlRow::m_visibleCells = 0
private

Definition at line 1261 of file docnode.h.

Referenced by setVisibleCells(), and visibleCells().


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