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

3240 :
3242{
3243}
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89

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

Member Function Documentation

◆ appendLinkWord()

void DocSimpleSect::appendLinkWord ( const DString & word)

Definition at line 3340 of file docnode.cpp.

3341{
3342 DocPara *p=nullptr;
3343 if (children().empty() || (p=std::get_if<DocPara>(&children().back()))==nullptr)
3344 {
3345 children().append<DocPara>(parser(),thisVariant());
3346 p = children().get_last<DocPara>();
3347 }
3348 else
3349 {
3350 // Comma-separate <seealso> links.
3351 p->injectToken(Token::make_TK_WORD(),",");
3352 p->injectToken(Token::make_TK_WHITESPACE()," ");
3353 }
3354
3355 parser()->context.inSeeBlock=true;
3356 p->injectToken(Token::make_TK_LNKWORD(),word);
3357 parser()->context.inSeeBlock=false;
3358}
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:4157
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 3245 of file docnode.cpp.

3246{
3247 return m_title && std::get<DocTitle>(*m_title).hasTitle();
3248}
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 3250 of file docnode.cpp.

3251{
3252 AUTO_TRACE();
3253 auto ns = AutoNodeStack(parser(),thisVariant());
3254
3255 // handle case for user defined title
3256 if (userTitle)
3257 {
3259 std::get_if<DocTitle>(m_title.get())->parse();
3260 }
3261
3262 // add new paragraph as child
3263 if (!children().empty() && std::holds_alternative<DocPara>(children().back()))
3264 {
3265 std::get<DocPara>(children().back()).markLast(false);
3266 }
3267 bool markFirst = children().empty();
3268 if (needsSeparator)
3269 {
3270 children().append<DocSimpleSectSep>(parser(),thisVariant());
3271 }
3272 children().append<DocPara>(parser(),thisVariant());
3273 DocPara *par = children().get_last<DocPara>();
3274 if (markFirst)
3275 {
3276 par->markFirst();
3277 }
3278 par->markLast();
3279
3280 // parse the contents of the paragraph
3281 Token retval = par->parse();
3282
3283 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3284 return retval; // 0==EOF, TokenRetval::TK_NEWPARA, TokenRetval::TK_LISTITEM, TokenRetval::TK_ENDLIST, TokenRetval::RetVal_SimpleSec
3285}
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 3287 of file docnode.cpp.

3288{
3289 AUTO_TRACE();
3290 auto ns = AutoNodeStack(parser(),thisVariant());
3291
3293 DocTitle *title = &std::get<DocTitle>(*m_title);
3294 title->parseFromString(thisVariant(),parser()->context.token->name);
3295
3296 DString text = parser()->context.token->text;
3297 { DocParser::AutoSaveContext saveContext(*parser());
3299 }
3300
3301 return Token::make_RetVal_OK();
3302}
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:3227
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 3304 of file docnode.cpp.

3305{
3306 AUTO_TRACE();
3307 auto ns = AutoNodeStack(parser(),thisVariant());
3308
3309 Token retval = Token::make_RetVal_OK();
3310 for (;;)
3311 {
3312 // add new paragraph as child
3313 if (!children().empty() && std::holds_alternative<DocPara>(children().back()))
3314 {
3315 std::get<DocPara>(children().back()).markLast(false);
3316 }
3317 bool markFirst = children().empty();
3318 children().append<DocPara>(parser(),thisVariant());
3319 DocPara *par = children().get_last<DocPara>();
3320 if (markFirst)
3321 {
3322 par->markFirst();
3323 }
3324 par->markLast();
3325
3326 // parse the contents of the paragraph
3327 retval = par->parse();
3328 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
3329 if (retval.is(TokenRetval::RetVal_CloseXml))
3330 {
3331 retval = Token::make_RetVal_OK();
3332 break;
3333 }
3334 }
3335
3336 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3337 return retval;
3338}
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 3360 of file docnode.cpp.

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

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: