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

Node representing a HTML table caption. More...

#include <src/docnode.h>

Inheritance diagram for DocHtmlCaption:
Collaboration diagram for DocHtmlCaption:

Public Member Functions

 DocHtmlCaption (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs)
const HtmlAttribList & attribs () const
Token parse ()
bool hasCaptionId () const
DString file () const
DString anchor () const
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

HtmlAttribList m_attribs
bool m_hasCaptionId = false
DString m_file
DString m_anchor

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 caption.

Definition at line 1232 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlCaption()

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

Definition at line 1791 of file docnode.cpp.

1793{
1794 m_hasCaptionId = false;
1795 for (const auto &opt : attribs)
1796 {
1797 if (opt.name=="id" && !opt.value.empty()) // interpret id attribute as an anchor
1798 {
1799 const SectionInfo *sec = SectionManager::instance().find(opt.value);
1800 if (sec)
1801 {
1802 //printf("Found anchor %s\n",qPrint(id));
1803 m_file = sec->fileName();
1804 m_anchor = sec->label();
1805 m_hasCaptionId = true;
1806 }
1807 else
1808 {
1809 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"Invalid caption id '{}'",opt.value);
1810 }
1811 }
1812 else // copy attribute
1813 {
1814 m_attribs.push_back(opt);
1815 }
1816 }
1817}
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
HtmlAttribList m_attribs
Definition docnode.h:1243
bool m_hasCaptionId
Definition docnode.h:1244
DString m_anchor
Definition docnode.h:1246
const HtmlAttribList & attribs() const
Definition docnode.h:1236
DString m_file
Definition docnode.h:1245
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89
DocTokenizer tokenizer
DocParserContext context
int getLineNr() const
const T * find(const std::string &key) const
Definition linkedmap.h:47
DString fileName() const
Definition section.h:74
DString label() const
Definition section.h:69
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:179
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112

References attribs(), DocParser::context, DocCompoundNode::DocCompoundNode(), DocParserContext::fileName, SectionInfo::fileName(), LinkedMap< T, Hash, KeyEqual, Map >::find(), DocTokenizer::getLineNr(), SectionManager::instance(), SectionInfo::label(), m_anchor, m_attribs, m_file, m_hasCaptionId, DocNode::parent(), DocNode::parser(), DocParser::tokenizer, and warn_doc_error.

Member Function Documentation

◆ anchor()

DString DocHtmlCaption::anchor ( ) const
inline

◆ attribs()

const HtmlAttribList & DocHtmlCaption::attribs ( ) const
inline

Definition at line 1236 of file docnode.h.

1236{ return m_attribs; }

References m_attribs.

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

◆ file()

DString DocHtmlCaption::file ( ) const
inline

◆ hasCaptionId()

bool DocHtmlCaption::hasCaptionId ( ) const
inline

Definition at line 1238 of file docnode.h.

1238{ return m_hasCaptionId; }

References m_hasCaptionId.

◆ parse()

Token DocHtmlCaption::parse ( )

Definition at line 1819 of file docnode.cpp.

1820{
1821 AUTO_TRACE();
1822 Token retval = Token::make_TK_NONE();
1823 auto ns = AutoNodeStack(parser(),thisVariant());
1824 Token tok = parser()->tokenizer.lex();
1825 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1826 {
1827 if (!parser()->defaultHandleToken(thisVariant(),tok,children()))
1828 {
1829 switch (tok.value())
1830 {
1831 case TokenRetval::TK_HTMLTAG:
1832 {
1833 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1834 if (tagId==HtmlTagType::HTML_CAPTION && parser()->context.token->endTag) // found </caption> tag
1835 {
1836 retval = Token::make_RetVal_OK();
1837 goto endcaption;
1838 }
1839 else
1840 {
1841 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected html tag <{}{}> found within <caption> context",
1842 parser()->context.token->endTag?"/":"",parser()->context.token->name);
1843 }
1844 }
1845 break;
1846 case TokenRetval::TK_COMMAND_AT:
1847 // fall through
1848 case TokenRetval::TK_COMMAND_BS:
1849 {
1850 DString cmdName=parser()->context.token->name;
1851 bool isJavaLink=false;
1852 switch (Mappers::cmdMapper->map(cmdName))
1853 {
1855 {
1856 tok=parser()->tokenizer.lex();
1857 if (!tok.is(TokenRetval::TK_WHITESPACE))
1858 {
1859 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected whitespace after '{:c}{}' command",
1860 tok.command_to_char(),cmdName);
1861 }
1862 else
1863 {
1865 tok=parser()->tokenizer.lex(); // get the reference id
1866 if (!tok.is(TokenRetval::TK_WORD))
1867 {
1868 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected token {} as the argument of '{:c}{}' command",
1869 tok.to_string(),tok.command_to_char(),cmdName);
1870 }
1871 else
1872 {
1874 children().get_last<DocRef>()->parse(tok.command_to_char(),cmdName);
1875 }
1877 }
1878 }
1879 break;
1881 isJavaLink=true;
1882 // fall through
1884 {
1885 tok=parser()->tokenizer.lex();
1886 if (!tok.is(TokenRetval::TK_WHITESPACE))
1887 {
1888 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected whitespace after \\{} command",
1889 cmdName);
1890 }
1891 else
1892 {
1894 tok=parser()->tokenizer.lex();
1895 if (!tok.is(TokenRetval::TK_WORD))
1896 {
1897 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected token {} as the argument of \\{} command",
1898 tok.to_string(),cmdName);
1899 }
1900 else
1901 {
1904 DocLink *lnk = children().get_last<DocLink>();
1905 DString leftOver = lnk->parse(isJavaLink);
1906 if (!leftOver.empty())
1907 {
1908 children().append<DocWord>(parser(),thisVariant(),leftOver);
1909 }
1910 }
1911 }
1912 }
1913 break;
1915 {
1916 children().append<DocLineBreak>(parser(),thisVariant(),parser()->context.token->attribs);
1917 }
1918 break;
1919 default:
1920 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Illegal command '{:c}{}' found as part of a <caption> tag",
1921 tok.command_to_char(),cmdName);
1922 }
1923 }
1924 break;
1925 default:
1926 parser()->errorHandleDefaultToken(thisVariant(),tok,children(),"<caption> tag");
1927 break;
1928 }
1929 }
1930 tok = parser()->tokenizer.lex();
1931 }
1932 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1933 {
1934 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected end of comment while inside"
1935 " <caption> tag");
1936 }
1937endcaption:
1939 return retval;
1940}
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
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1415
void handlePendingStyleCommands(DocNodeVariant *parent, DocNodeList &children, size_t numberOfElementsToClose=0)
void errorHandleDefaultToken(DocNodeVariant *parent, Token tok, DocNodeList &children, const DString &txt)
void setStateLink()
void setStatePara()
bool is(TokenRetval rv) const
TOKEN_SPECIFICATIONS RETVAL_SPECIFICATIONS const char * to_string() const
TokenRetval value() const
bool is_any_of(ARGS... args) const
char command_to_char() const
HtmlAttribList attribs
DString name
HtmlTagType
Definition cmdmapper.h:174
#define AUTO_TRACE(...)
Definition docnode.cpp:53
const Mapper< HtmlTagType > * htmlTagMapper
const Mapper< CommandType > * cmdMapper
TokenInfo * token
Definition docparser_p.h:94

References DocNodeList::append(), TokenInfo::attribs, AUTO_TRACE, DocCompoundNode::children(), CMD_JAVALINK, CMD_LINEBREAK, CMD_LINK, CMD_REF, Mappers::cmdMapper, Token::command_to_char(), DocParser::context, DocParserContext::context, DocParser::errorHandleDefaultToken(), DocNodeList::get_last(), DocParser::handlePendingStyleCommands(), HTML_CAPTION, Mappers::htmlTagMapper, Token::is(), Token::is_any_of(), DocTokenizer::lex(), TokenInfo::name, parse(), DocNode::parser(), DocTokenizer::setStateLink(), DocTokenizer::setStatePara(), DocTokenizer::setStateRef(), DocNode::thisVariant(), Token::to_string(), DocParserContext::token, DocParser::tokenizer, Token::value(), and warn_doc_error.

Referenced by parse().

Member Data Documentation

◆ m_anchor

DString DocHtmlCaption::m_anchor
private

Definition at line 1246 of file docnode.h.

Referenced by anchor(), and DocHtmlCaption().

◆ m_attribs

HtmlAttribList DocHtmlCaption::m_attribs
private

Definition at line 1243 of file docnode.h.

Referenced by attribs(), and DocHtmlCaption().

◆ m_file

DString DocHtmlCaption::m_file
private

Definition at line 1245 of file docnode.h.

Referenced by DocHtmlCaption(), and file().

◆ m_hasCaptionId

bool DocHtmlCaption::m_hasCaptionId = false
private

Definition at line 1244 of file docnode.h.

Referenced by DocHtmlCaption(), and hasCaptionId().


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