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 ,
  Requirement
}
Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)

Detailed Description

Node representing a normal section.

Definition at line 913 of file docnode.h.

Constructor & Destructor Documentation

◆ DocSection()

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

Definition at line 916 of file docnode.h.

916 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
DocParser * parser()
Definition docnode.h:98
DocNodeVariant * parent()
Definition docnode.h:90
QCString m_id
Definition docnode.h:927
int level() const
Definition docnode.h:918
int m_level
Definition docnode.h:926

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

922{ return m_file; }
QCString m_file
Definition docnode.h:930

References m_file.

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

◆ id()

QCString DocSection::id ( ) const
inline

Definition at line 921 of file docnode.h.

921{ return m_id; }

References m_id.

Referenced by DocSection().

◆ level()

◆ parse()

Token DocSection::parse ( )

Definition at line 5990 of file docnode.cpp.

5991{
5992 AUTO_TRACE("start {} level={}", parser()->context.token->sectionId, m_level);
5993 Token retval = Token::make_RetVal_OK();
5994 auto ns = AutoNodeStack(parser(),thisVariant());
5995
5996 if (!m_id.isEmpty())
5997 {
5998 const SectionInfo *sec = SectionManager::instance().find(m_id);
5999 if (sec)
6000 {
6001 m_file = sec->fileName();
6002 m_anchor = sec->label();
6003 QCString titleStr = sec->title();
6004 if (titleStr.isEmpty()) titleStr = sec->label();
6006 DocTitle *title = &std::get<DocTitle>(*m_title);
6007 title->parseFromString(thisVariant(),titleStr);
6008 }
6009 }
6010
6011 // first parse any number of paragraphs
6012 bool isFirst=TRUE;
6013 DocPara *lastPar=nullptr;
6014 do
6015 {
6016 children().append<DocPara>(parser(),thisVariant());
6017 DocPara *par = children().get_last<DocPara>();
6018 if (isFirst) { par->markFirst(); isFirst=FALSE; }
6019 retval=par->parse();
6020 if (!par->isEmpty())
6021 {
6022 if (lastPar) lastPar->markLast(FALSE);
6023 lastPar = par;
6024 }
6025 else
6026 {
6027 children().pop_back();
6028 }
6029 if (retval.is(TokenRetval::TK_LISTITEM))
6030 {
6031 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid list item found");
6032 }
6033 if (retval.is(TokenRetval::RetVal_Internal))
6034 {
6035 children().append<DocInternal>(parser(),thisVariant());
6036 retval = children().get_last<DocInternal>()->parse(m_level+1);
6037 if (retval.is(TokenRetval::RetVal_EndInternal))
6038 {
6039 retval = Token::make_RetVal_OK();
6040 }
6041 }
6042 } while (!retval.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF, TokenRetval::RetVal_Section, TokenRetval::RetVal_Subsection,
6043 TokenRetval::RetVal_Subsubsection, TokenRetval::RetVal_Paragraph, TokenRetval::RetVal_SubParagraph,
6044 TokenRetval::RetVal_SubSubParagraph, TokenRetval::RetVal_EndInternal)
6045 );
6046
6047 if (lastPar) lastPar->markLast();
6048
6049 while (true)
6050 {
6051 if (retval.is(TokenRetval::RetVal_Subsection) && m_level<=1)
6052 {
6053 // then parse any number of nested sections
6054 while (retval.is(TokenRetval::RetVal_Subsection)) // more sections follow
6055 {
6057 2,
6059 retval = children().get_last<DocSection>()->parse();
6060 }
6061 break;
6062 }
6063 else if (retval.is(TokenRetval::RetVal_Subsubsection) && m_level<=2)
6064 {
6065 if ((m_level <= 1) &&
6066 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
6067 {
6068 warn_doc_error(parser()->context.fileName,
6069 parser()->tokenizer.getLineNr(),
6070 "Unexpected subsubsection command found inside {}!",
6072 }
6073 // then parse any number of nested sections
6074 while (retval.is(TokenRetval::RetVal_Subsubsection)) // more sections follow
6075 {
6077 3,
6079 retval = children().get_last<DocSection>()->parse();
6080 }
6081 if (!(m_level < 2 && retval.is(TokenRetval::RetVal_Subsection))) break;
6082 }
6083 else if (retval.is(TokenRetval::RetVal_Paragraph) && m_level<=3)
6084 {
6085 if ((m_level <= 2) &&
6086 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
6087 {
6088 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
6089 "Unexpected paragraph command found inside {}!",
6091 }
6092 // then parse any number of nested sections
6093 while (retval.is(TokenRetval::RetVal_Paragraph)) // more sections follow
6094 {
6096 4,
6098 retval = children().get_last<DocSection>()->parse();
6099 }
6100 if (!(m_level<3 && (retval.is_any_of(TokenRetval::RetVal_Subsection,TokenRetval::RetVal_Subsubsection)))) break;
6101 }
6102 else if (retval.is(TokenRetval::RetVal_SubParagraph) && m_level<=4)
6103 {
6104 if ((m_level <= 3) &&
6105 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
6106 {
6107 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
6108 "Unexpected subparagraph command found inside {}!",
6110 }
6111 // then parse any number of nested sections
6112 while (retval.is(TokenRetval::RetVal_SubParagraph)) // more sections follow
6113 {
6115 5,
6117 retval = children().get_last<DocSection>()->parse();
6118 }
6119 if (!(m_level<4 && (retval.is_any_of(TokenRetval::RetVal_Subsection,TokenRetval::RetVal_Subsubsection,TokenRetval::RetVal_Paragraph)))) break;
6120 }
6121 else if (retval.is(TokenRetval::RetVal_SubSubParagraph) && m_level<=5)
6122 {
6123 if ((m_level <= 4) &&
6124 !AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
6125 {
6126 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
6127 "Unexpected subsubparagraph command found inside {}!",
6129 }
6130 // then parse any number of nested sections
6131 while (retval.is(TokenRetval::RetVal_SubSubParagraph)) // more sections follow
6132 {
6134 6,
6136 retval = children().get_last<DocSection>()->parse();
6137 }
6138 if (!(m_level<5 && (retval.is_any_of( TokenRetval::RetVal_Subsection, TokenRetval::RetVal_Subsubsection,
6139 TokenRetval::RetVal_Paragraph, TokenRetval::RetVal_SubParagraph)))) break;
6140 }
6141 else
6142 {
6143 break;
6144 }
6145 }
6146
6147 INTERNAL_ASSERT(retval.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF,
6148 TokenRetval::RetVal_Section, TokenRetval::RetVal_Subsection,
6149 TokenRetval::RetVal_Subsubsection, TokenRetval::RetVal_Paragraph,
6150 TokenRetval::RetVal_SubParagraph, TokenRetval::RetVal_SubSubParagraph,
6151 TokenRetval::RetVal_Internal, TokenRetval::RetVal_EndInternal)
6152 );
6153
6154 AUTO_TRACE_EXIT("retval={}", retval.to_string());
6155 return retval;
6156}
static AnchorGenerator & instance()
Returns the singleton instance.
Definition anchor.cpp:38
DocNodeList & children()
Definition docnode.h:143
DocNodeVariant * thisVariant()
Definition docnode.h:93
void markLast(bool v=TRUE)
Definition docnode.h:1086
DocParserContext context
std::unique_ptr< DocNodeVariant > m_title
Definition docnode.h:928
Token parse()
Definition docnode.cpp:5990
DocSection(DocParser *parser, DocNodeVariant *parent, int level, const QCString &id)
Definition docnode.h:916
const DocNodeVariant * title() const
Definition docnode.h:919
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:163
QCString label() const
Definition section.h:69
QCString fileName() const
Definition section.h:74
QCString title() const
Definition section.h:70
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:179
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:57
#define AUTO_TRACE(...)
Definition docnode.cpp:47
#define INTERNAL_ASSERT(x)
Definition docnode.cpp:52
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:49
std::unique_ptr< DocNodeVariant > createDocNode(Args &&...args)
Definition docnode.h:1492
#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:1396
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1407
TokenInfo * token
Definition docparser_p.h:94
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 929 of file docnode.h.

Referenced by anchor(), and parse().

◆ m_file

QCString DocSection::m_file
private

Definition at line 930 of file docnode.h.

Referenced by file(), and parse().

◆ m_id

QCString DocSection::m_id
private

Definition at line 927 of file docnode.h.

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

◆ m_level

int DocSection::m_level = 0
private

Definition at line 926 of file docnode.h.

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

◆ m_title

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

Definition at line 928 of file docnode.h.

Referenced by parse(), and title().


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