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

Node representing a simple section. More...

#include <src/docnode.h>

Inheritance diagram for DocSimpleSect:
Collaboration diagram for DocSimpleSect:

Public Types

enum  Type {
  Unknown , See , Return , Author ,
  Authors , Version , Since , Date ,
  Note , Warning , Copyright , Pre ,
  Post , Invar , Remark , Attention ,
  Important , User , Rcs
}

Public Member Functions

 DocSimpleSect (DocParser *parser, DocNodeVariant *parent, Type t)
Type type () const
DString typeString () const
Token parse (bool userTitle, bool needsSeparator)
Token parseRcs ()
Token parseXml ()
void appendLinkWord (const DString &word)
bool hasTitle () const
const DocNodeVariant * title () 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

Type m_type = Unknown
std::unique_ptr< DocNodeVariant > m_title

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

Definition at line 1025 of file docnode.h.

Member Enumeration Documentation

◆ Type

Enumerator
Unknown 
See 
Return 
Author 
Authors 
Version 
Since 
Date 
Note 
Warning 
Copyright 
Pre 
Post 
Invar 
Remark 
Attention 
Important 
User 
Rcs 

Definition at line 1028 of file docnode.h.

Constructor & Destructor Documentation

◆ DocSimpleSect()

DocSimpleSect::DocSimpleSect ( DocParser * parser,
DocNodeVariant * parent,
Type t )

Definition at line 3234 of file docnode.cpp.

3234 :
3236{
3237}
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89

References DocCompoundNode::DocCompoundNode(), m_type, DocNode::parent(), and DocNode::parser().

Member Function Documentation

◆ appendLinkWord()

void DocSimpleSect::appendLinkWord ( const DString & word)

Definition at line 3334 of file docnode.cpp.

3335{
3336 DocPara *p=nullptr;
3337 if (children().empty() || (p=std::get_if<DocPara>(&children().back()))==nullptr)
3338 {
3339 children().append<DocPara>(parser(),thisVariant());
3340 p = children().get_last<DocPara>();
3341 }
3342 else
3343 {
3344 // Comma-separate <seealso> links.
3345 p->injectToken(Token::make_TK_WORD(),",");
3346 p->injectToken(Token::make_TK_WHITESPACE()," ");
3347 }
3348
3349 parser()->context.inSeeBlock=true;
3350 p->injectToken(Token::make_TK_LNKWORD(),word);
3351 parser()->context.inSeeBlock=false;
3352}
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
bool injectToken(Token tok, const DString &tokText)
Definition docnode.cpp:4142
DocParserContext context

References DocNodeList::append(), DocCompoundNode::children(), DocParser::context, DocNodeList::get_last(), DocPara::injectToken(), DocParserContext::inSeeBlock, DocNode::parser(), and DocNode::thisVariant().

◆ hasTitle()

bool DocSimpleSect::hasTitle ( ) const

Definition at line 3239 of file docnode.cpp.

3240{
3241 return m_title && std::get<DocTitle>(*m_title).hasTitle();
3242}
std::unique_ptr< DocNodeVariant > m_title
Definition docnode.h:1046

References m_title.

Referenced by DocbookDocVisitor::operator()().

◆ parse()

Token DocSimpleSect::parse ( bool userTitle,
bool needsSeparator )

Definition at line 3244 of file docnode.cpp.

3245{
3246 AUTO_TRACE();
3247 auto ns = AutoNodeStack(parser(),thisVariant());
3248
3249 // handle case for user defined title
3250 if (userTitle)
3251 {
3253 std::get_if<DocTitle>(m_title.get())->parse();
3254 }
3255
3256 // add new paragraph as child
3257 if (!children().empty() && std::holds_alternative<DocPara>(children().back()))
3258 {
3259 std::get<DocPara>(children().back()).markLast(false);
3260 }
3261 bool markFirst = children().empty();
3262 if (needsSeparator)
3263 {
3264 children().append<DocSimpleSectSep>(parser(),thisVariant());
3265 }
3266 children().append<DocPara>(parser(),thisVariant());
3267 DocPara *par = children().get_last<DocPara>();
3268 if (markFirst)
3269 {
3270 par->markFirst();
3271 }
3272 par->markLast();
3273
3274 // parse the contents of the paragraph
3275 Token retval = par->parse();
3276
3277 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3278 return retval; // 0==EOF, TokenRetval::TK_NEWPARA, TokenRetval::TK_LISTITEM, TokenRetval::TK_ENDLIST, TokenRetval::RetVal_SimpleSec
3279}
bool empty() const
checks whether the container is empty
Definition growvector.h:140
TOKEN_SPECIFICATIONS RETVAL_SPECIFICATIONS const char * to_string() const
#define AUTO_TRACE(...)
Definition docnode.cpp:53
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:55
std::unique_ptr< DocNodeVariant > createDocNode(Args &&...args)
Definition docnode.h:1500

References DocNodeList::append(), AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children(), createDocNode(), GrowVector< T >::empty(), DocNodeList::get_last(), m_title, DocPara::markLast(), DocNode::parser(), DocNode::thisVariant(), and Token::to_string().

Referenced by DocPara::handleSimpleSection().

◆ parseRcs()

Token DocSimpleSect::parseRcs ( )

Definition at line 3281 of file docnode.cpp.

3282{
3283 AUTO_TRACE();
3284 auto ns = AutoNodeStack(parser(),thisVariant());
3285
3287 DocTitle *title = &std::get<DocTitle>(*m_title);
3288 title->parseFromString(thisVariant(),parser()->context.token->name);
3289
3290 DString text = parser()->context.token->text;
3291 { DocParser::AutoSaveContext saveContext(*parser());
3293 }
3294
3295 return Token::make_RetVal_OK();
3296}
Token internalValidatingParseDoc(DocNodeVariant *parent, DocNodeList &children, const DString &doc)
const DocNodeVariant * title() const
Definition docnode.h:1042
void parseFromString(DocNodeVariant *, const DString &title)
Definition docnode.cpp:3221
DString text
TokenInfo * token
Definition docparser_p.h:94

References AUTO_TRACE, DocCompoundNode::children(), DocParser::context, createDocNode(), DocParser::internalValidatingParseDoc(), m_title, DocTitle::parseFromString(), DocNode::parser(), TokenInfo::text, DocNode::thisVariant(), title(), and DocParserContext::token.

◆ parseXml()

Token DocSimpleSect::parseXml ( )

Definition at line 3298 of file docnode.cpp.

3299{
3300 AUTO_TRACE();
3301 auto ns = AutoNodeStack(parser(),thisVariant());
3302
3303 Token retval = Token::make_RetVal_OK();
3304 for (;;)
3305 {
3306 // add new paragraph as child
3307 if (!children().empty() && std::holds_alternative<DocPara>(children().back()))
3308 {
3309 std::get<DocPara>(children().back()).markLast(false);
3310 }
3311 bool markFirst = children().empty();
3312 children().append<DocPara>(parser(),thisVariant());
3313 DocPara *par = children().get_last<DocPara>();
3314 if (markFirst)
3315 {
3316 par->markFirst();
3317 }
3318 par->markLast();
3319
3320 // parse the contents of the paragraph
3321 retval = par->parse();
3322 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
3323 if (retval.is(TokenRetval::RetVal_CloseXml))
3324 {
3325 retval = Token::make_RetVal_OK();
3326 break;
3327 }
3328 }
3329
3330 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3331 return retval;
3332}
bool is(TokenRetval rv) const
bool is_any_of(ARGS... args) const

References DocNodeList::append(), AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children(), GrowVector< T >::empty(), DocNodeList::get_last(), Token::is(), Token::is_any_of(), DocPara::markLast(), DocNode::parser(), DocNode::thisVariant(), and Token::to_string().

Referenced by DocPara::handleSimpleSection().

◆ title()

◆ type()

◆ typeString()

DString DocSimpleSect::typeString ( ) const

Definition at line 3354 of file docnode.cpp.

3355{
3356 switch (m_type)
3357 {
3358 case Unknown: break;
3359 case See: return "see";
3360 case Return: return "return";
3361 case Author: // fall through
3362 case Authors: return "author";
3363 case Version: return "version";
3364 case Since: return "since";
3365 case Date: return "date";
3366 case Note: return "note";
3367 case Warning: return "warning";
3368 case Pre: return "pre";
3369 case Post: return "post";
3370 case Copyright: return "copyright";
3371 case Invar: return "invariant";
3372 case Remark: return "remark";
3373 case Attention: return "attention";
3374 case Important: return "important";
3375 case User: return "user";
3376 case Rcs: return "rcs";
3377 }
3378 return "unknown";
3379}

References Attention, Author, Authors, Copyright, Date, Important, Invar, m_type, Note, Post, Pre, Rcs, Remark, Return, See, Since, Unknown, User, Version, and Warning.

Referenced by HtmlDocVisitor::operator()().

Member Data Documentation

◆ m_title

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

Definition at line 1046 of file docnode.h.

Referenced by hasTitle(), parse(), parseRcs(), and title().

◆ m_type

Type DocSimpleSect::m_type = Unknown
private

Definition at line 1045 of file docnode.h.

Referenced by DocSimpleSect(), type(), and typeString().


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