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 HtmlAttribListattribs () const
Token parse ()
bool hasCaptionId () const
DString file () const
DString anchor () 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 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 1781 of file docnode.cpp.

1783{
1784 m_hasCaptionId = false;
1785 for (const auto &opt : attribs)
1786 {
1787 if (opt.name=="id" && !opt.value.empty()) // interpret id attribute as an anchor
1788 {
1789 const SectionInfo *sec = SectionManager::instance().find(opt.value);
1790 if (sec)
1791 {
1792 //printf("Found anchor %s\n",qPrint(id));
1793 m_file = sec->fileName();
1794 m_anchor = sec->label();
1795 m_hasCaptionId = true;
1796 }
1797 else
1798 {
1799 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"Invalid caption id '{}'",opt.value);
1800 }
1801 }
1802 else // copy attribute
1803 {
1804 m_attribs.push_back(opt);
1805 }
1806 }
1807}
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 1809 of file docnode.cpp.

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