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 1797 of file docnode.cpp.

1799{
1800 m_hasCaptionId = false;
1801 for (const auto &opt : attribs)
1802 {
1803 if (opt.name=="id" && !opt.value.empty()) // interpret id attribute as an anchor
1804 {
1805 const SectionInfo *sec = SectionManager::instance().find(opt.value);
1806 if (sec)
1807 {
1808 //printf("Found anchor %s\n",qPrint(id));
1809 m_file = sec->fileName();
1810 m_anchor = sec->label();
1811 m_hasCaptionId = true;
1812 }
1813 else
1814 {
1815 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"Invalid caption id '{}'",opt.value);
1816 }
1817 }
1818 else // copy attribute
1819 {
1820 m_attribs.push_back(opt);
1821 }
1822 }
1823}
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, 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 1825 of file docnode.cpp.

1826{
1827 AUTO_TRACE();
1828 Token retval = Token::make_TK_NONE();
1829 auto ns = AutoNodeStack(parser(),thisVariant());
1830 Token tok = parser()->tokenizer.lex();
1831 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1832 {
1833 if (!parser()->defaultHandleToken(thisVariant(),tok,children()))
1834 {
1835 switch (tok.value())
1836 {
1837 case TokenRetval::TK_HTMLTAG:
1838 {
1839 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1840 if (tagId==HtmlTagType::HTML_CAPTION && parser()->context.token->endTag) // found </caption> tag
1841 {
1842 retval = Token::make_RetVal_OK();
1843 goto endcaption;
1844 }
1845 else
1846 {
1847 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected html tag <{}{}> found within <caption> context",
1848 parser()->context.token->endTag?"/":"",parser()->context.token->name);
1849 }
1850 }
1851 break;
1852 case TokenRetval::TK_COMMAND_AT:
1853 // fall through
1854 case TokenRetval::TK_COMMAND_BS:
1855 {
1856 DString cmdName=parser()->context.token->name;
1857 bool isJavaLink=false;
1858 switch (Mappers::cmdMapper->map(cmdName))
1859 {
1861 {
1862 tok=parser()->tokenizer.lex();
1863 if (!tok.is(TokenRetval::TK_WHITESPACE))
1864 {
1865 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected whitespace after '{:c}{}' command",
1866 tok.command_to_char(),cmdName);
1867 }
1868 else
1869 {
1871 tok=parser()->tokenizer.lex(); // get the reference id
1872 if (!tok.is(TokenRetval::TK_WORD))
1873 {
1874 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected token {} as the argument of '{:c}{}' command",
1875 tok.to_string(),tok.command_to_char(),cmdName);
1876 }
1877 else
1878 {
1880 children().get_last<DocRef>()->parse(tok.command_to_char(),cmdName);
1881 }
1883 }
1884 }
1885 break;
1887 isJavaLink=true;
1888 // fall through
1890 {
1891 tok=parser()->tokenizer.lex();
1892 if (!tok.is(TokenRetval::TK_WHITESPACE))
1893 {
1894 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected whitespace after \\{} command",
1895 cmdName);
1896 }
1897 else
1898 {
1900 tok=parser()->tokenizer.lex();
1901 if (!tok.is(TokenRetval::TK_WORD))
1902 {
1903 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected token {} as the argument of \\{} command",
1904 tok.to_string(),cmdName);
1905 }
1906 else
1907 {
1910 DocLink *lnk = children().get_last<DocLink>();
1911 DString leftOver = lnk->parse(isJavaLink);
1912 if (!leftOver.empty())
1913 {
1914 children().append<DocWord>(parser(),thisVariant(),leftOver);
1915 }
1916 }
1917 }
1918 }
1919 break;
1921 {
1922 children().append<DocLineBreak>(parser(),thisVariant(),parser()->context.token->attribs);
1923 }
1924 break;
1925 default:
1926 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Illegal command '{:c}{}' found as part of a <caption> tag",
1927 tok.command_to_char(),cmdName);
1928 }
1929 }
1930 break;
1931 default:
1932 parser()->errorHandleDefaultToken(thisVariant(),tok,children(),"<caption> tag");
1933 break;
1934 }
1935 }
1936 tok = parser()->tokenizer.lex();
1937 }
1938 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1939 {
1940 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected end of comment while inside"
1941 " <caption> tag");
1942 }
1943endcaption:
1945 return retval;
1946}
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: