Doxygen
Loading...
Searching...
No Matches
DocSection Class Reference

Node representing a normal section. More...

#include <src/docnode.h>

Inheritance diagram for DocSection:
Collaboration diagram for DocSection:

Public Member Functions

 DocSection (DocParser *parser, DocNodeVariant *parent, int level, const QCString &id)
int level () const
const DocNodeVarianttitle () const
QCString anchor () const
QCString id () const
QCString file () const
Token parse ()
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

int m_level = 0
QCString m_id
std::unique_ptr< DocNodeVariantm_title
QCString m_anchor
QCString m_file

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 normal section.

Definition at line 908 of file docnode.h.

Constructor & Destructor Documentation

◆ DocSection()

DocSection::DocSection ( DocParser * parser,
DocNodeVariant * parent,
int level,
const QCString & id )
inline

Definition at line 911 of file docnode.h.

911 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:140
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89
QCString m_id
Definition docnode.h:922
int level() const
Definition docnode.h:913
int m_level
Definition docnode.h:921

References DocCompoundNode::DocCompoundNode(), id(), level(), m_id, m_level, DocNode::parent(), and DocNode::parser().

Referenced by parse().

Member Function Documentation

◆ anchor()

QCString DocSection::anchor ( ) const
inline

◆ file()

QCString DocSection::file ( ) const
inline

Definition at line 917 of file docnode.h.

917{ return m_file; }
QCString m_file
Definition docnode.h:925

References m_file.

Referenced by DocbookDocVisitor::operator()(), LatexDocVisitor::operator()(), RTFDocVisitor::operator()(), and XmlDocVisitor::operator()().

◆ id()

QCString DocSection::id ( ) const
inline

Definition at line 916 of file docnode.h.

916{ return m_id; }

References m_id.

Referenced by DocSection().

◆ level()

◆ parse()

Token DocSection::parse ( )

Definition at line 5784 of file docnode.cpp.

5785{
5786 AUTO_TRACE("start {} level={}", parser()->context.token->sectionId, m_level);
5787 Token retval = Token::make_RetVal_OK();
5788 auto ns = AutoNodeStack(parser(),thisVariant());
5789
5790 if (!m_id.isEmpty())
5791 {
5792 const SectionInfo *sec = SectionManager::instance().find(m_id);
5793 if (sec)
5794 {
5795 m_file = sec->fileName();
5796 m_anchor = sec->label();
5797 QCString titleStr = sec->title();
5798 if (titleStr.isEmpty()) titleStr = sec->label();
5800 DocTitle *title = &std::get<DocTitle>(*m_title);
5801 title->parseFromString(thisVariant(),titleStr);
5802 }
5803 }
5804
5805 // first parse any number of paragraphs
5806 bool isFirst=TRUE;
5807 DocPara *lastPar=nullptr;
5808 do
5809 {
5810 children().append<DocPara>(parser(),thisVariant());
5811 DocPara *par = children().get_last<DocPara>();
5812 if (isFirst) { par->markFirst(); isFirst=FALSE; }
5813 retval=par->parse();
5814 if (!par->isEmpty())
5815 {
5816 if (lastPar) lastPar->markLast(FALSE);
5817 lastPar = par;
5818 }
5819 else
5820 {
5821 children().pop_back();
5822 }
5823 if (retval.is(TokenRetval::TK_LISTITEM))
5824 {
5825 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid list item found");
5826 }
5827 if (retval.is(TokenRetval::RetVal_Internal))
5828 {
5829 children().append<DocInternal>(parser(),thisVariant());
5830 retval = children().get_last<DocInternal>()->parse(m_level+1);
5831 if (retval.is(TokenRetval::RetVal_EndInternal))
5832 {
5833 retval = Token::make_RetVal_OK();
5834 }
5835 }
5836 } while (!retval.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF, TokenRetval::RetVal_Section, TokenRetval::RetVal_Subsection,
5837 TokenRetval::RetVal_Subsubsection, TokenRetval::RetVal_Paragraph, TokenRetval::RetVal_SubParagraph,
5838 TokenRetval::RetVal_SubSubParagraph, TokenRetval::RetVal_EndInternal)
5839 );
5840
5841 if (lastPar) lastPar->markLast();
5842
5843 while (true)
5844 {
5845 if (retval.is(TokenRetval::RetVal_Subsection) && m_level<=1)
5846 {
5847 // then parse any number of nested sections
5848 while (retval.is(TokenRetval::RetVal_Subsection)) // more sections follow
5849 {
5851 2,
5853 retval = children().get_last<DocSection>()->parse();
5854 }
5855 break;
5856 }
5857 else if (retval.is(TokenRetval::RetVal_Subsubsection) && m_level<=2)
5858 {
5859 if ((m_level <= 1) &&
5860 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
5861 {
5862 warn_doc_error(parser()->context.fileName,
5863 parser()->tokenizer.getLineNr(),
5864 "Unexpected subsubsection command found inside {}!",
5866 }
5867 // then parse any number of nested sections
5868 while (retval.is(TokenRetval::RetVal_Subsubsection)) // more sections follow
5869 {
5871 3,
5873 retval = children().get_last<DocSection>()->parse();
5874 }
5875 if (!(m_level < 2 && retval.is(TokenRetval::RetVal_Subsection))) break;
5876 }
5877 else if (retval.is(TokenRetval::RetVal_Paragraph) && m_level<=3)
5878 {
5879 if ((m_level <= 2) &&
5880 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
5881 {
5882 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
5883 "Unexpected paragraph command found inside {}!",
5885 }
5886 // then parse any number of nested sections
5887 while (retval.is(TokenRetval::RetVal_Paragraph)) // more sections follow
5888 {
5890 4,
5892 retval = children().get_last<DocSection>()->parse();
5893 }
5894 if (!(m_level<3 && (retval.is_any_of(TokenRetval::RetVal_Subsection,TokenRetval::RetVal_Subsubsection)))) break;
5895 }
5896 else if (retval.is(TokenRetval::RetVal_SubParagraph) && m_level<=4)
5897 {
5898 if ((m_level <= 3) &&
5899 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
5900 {
5901 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
5902 "Unexpected subparagraph command found inside {}!",
5904 }
5905 // then parse any number of nested sections
5906 while (retval.is(TokenRetval::RetVal_SubParagraph)) // more sections follow
5907 {
5909 5,
5911 retval = children().get_last<DocSection>()->parse();
5912 }
5913 if (!(m_level<4 && (retval.is_any_of(TokenRetval::RetVal_Subsection,TokenRetval::RetVal_Subsubsection,TokenRetval::RetVal_Paragraph)))) break;
5914 }
5915 else if (retval.is(TokenRetval::RetVal_SubSubParagraph) && m_level<=5)
5916 {
5917 if ((m_level <= 4) &&
5918 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
5919 {
5920 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
5921 "Unexpected subsubparagraph command found inside {}!",
5923 }
5924 // then parse any number of nested sections
5925 while (retval.is(TokenRetval::RetVal_SubSubParagraph)) // more sections follow
5926 {
5928 6,
5930 retval = children().get_last<DocSection>()->parse();
5931 }
5932 if (!(m_level<5 && (retval.is_any_of( TokenRetval::RetVal_Subsection, TokenRetval::RetVal_Subsubsection,
5933 TokenRetval::RetVal_Paragraph, TokenRetval::RetVal_SubParagraph)))) break;
5934 }
5935 else
5936 {
5937 break;
5938 }
5939 }
5940
5941 INTERNAL_ASSERT(retval.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF,
5942 TokenRetval::RetVal_Section, TokenRetval::RetVal_Subsection,
5943 TokenRetval::RetVal_Subsubsection, TokenRetval::RetVal_Paragraph,
5944 TokenRetval::RetVal_SubParagraph, TokenRetval::RetVal_SubSubParagraph,
5945 TokenRetval::RetVal_Internal, TokenRetval::RetVal_EndInternal)
5946 );
5947
5948 AUTO_TRACE_EXIT("retval={}", retval.to_string());
5949 return retval;
5950}
static AnchorGenerator & instance()
Returns the singleton instance.
Definition anchor.cpp:38
DocNodeList & children()
Definition docnode.h:142
DocNodeVariant * thisVariant()
Definition docnode.h:92
void markLast(bool v=TRUE)
Definition docnode.h:1081
DocParserContext context
std::unique_ptr< DocNodeVariant > m_title
Definition docnode.h:923
Token parse()
Definition docnode.cpp:5784
DocSection(DocParser *parser, DocNodeVariant *parent, int level, const QCString &id)
Definition docnode.h:911
const DocNodeVariant * title() const
Definition docnode.h:914
void pop_back()
removes the last element
Definition growvector.h:115
const T * find(const std::string &key) const
Definition linkedmap.h:47
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
QCString label() const
Definition section.h:68
QCString fileName() const
Definition section.h:73
QCString title() const
Definition section.h:69
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:175
bool is(TokenRetval rv) const
TOKEN_SPECIFICATIONS RETVAL_SPECIFICATIONS const char * to_string() const
bool is_any_of(ARGS... args) const
static const char * g_sectionLevelToName[]
Definition docnode.cpp:56
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define INTERNAL_ASSERT(x)
Definition docnode.cpp:51
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:48
std::unique_ptr< DocNodeVariant > createDocNode(Args &&...args)
Definition docnode.h:1486
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1394
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1405
TokenInfo * token
Definition docparser_p.h:92
QCString sectionId

References DocNodeList::append(), AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children(), DocParser::context, createDocNode(), DocSection(), FALSE, SectionInfo::fileName(), LinkedMap< T, Hash, KeyEqual, Map >::find(), g_sectionLevelToName, DocNodeList::get_last(), AnchorGenerator::instance(), SectionManager::instance(), INTERNAL_ASSERT, Token::is(), Token::is_any_of(), QCString::isEmpty(), SectionInfo::label(), m_anchor, m_file, m_id, m_level, m_title, DocPara::markLast(), parse(), DocNode::parser(), GrowVector< T >::pop_back(), TokenInfo::sectionId, DocNode::thisVariant(), title(), SectionInfo::title(), Token::to_string(), DocParserContext::token, TRUE, and warn_doc_error.

Referenced by parse().

◆ title()

Member Data Documentation

◆ m_anchor

QCString DocSection::m_anchor
private

Definition at line 924 of file docnode.h.

Referenced by anchor(), and parse().

◆ m_file

QCString DocSection::m_file
private

Definition at line 925 of file docnode.h.

Referenced by file(), and parse().

◆ m_id

QCString DocSection::m_id
private

Definition at line 922 of file docnode.h.

Referenced by DocSection(), id(), and parse().

◆ m_level

int DocSection::m_level = 0
private

Definition at line 921 of file docnode.h.

Referenced by DocSection(), level(), and parse().

◆ m_title

std::unique_ptr<DocNodeVariant> DocSection::m_title
private

Definition at line 923 of file docnode.h.

Referenced by parse(), and title().


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