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 DocNodeVarianttitle () 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

Type m_type = Unknown
std::unique_ptr< DocNodeVariantm_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 3224 of file docnode.cpp.

3224 :
3226{
3227}
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 3324 of file docnode.cpp.

3325{
3326 DocPara *p=nullptr;
3327 if (children().empty() || (p=std::get_if<DocPara>(&children().back()))==nullptr)
3328 {
3329 children().append<DocPara>(parser(),thisVariant());
3330 p = children().get_last<DocPara>();
3331 }
3332 else
3333 {
3334 // Comma-separate <seealso> links.
3335 p->injectToken(Token::make_TK_WORD(),",");
3336 p->injectToken(Token::make_TK_WHITESPACE()," ");
3337 }
3338
3339 parser()->context.inSeeBlock=true;
3340 p->injectToken(Token::make_TK_LNKWORD(),word);
3341 parser()->context.inSeeBlock=false;
3342}
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:4132
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 3229 of file docnode.cpp.

3230{
3231 return m_title && std::get<DocTitle>(*m_title).hasTitle();
3232}
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 3234 of file docnode.cpp.

3235{
3236 AUTO_TRACE();
3237 auto ns = AutoNodeStack(parser(),thisVariant());
3238
3239 // handle case for user defined title
3240 if (userTitle)
3241 {
3243 std::get_if<DocTitle>(m_title.get())->parse();
3244 }
3245
3246 // add new paragraph as child
3247 if (!children().empty() && std::holds_alternative<DocPara>(children().back()))
3248 {
3249 std::get<DocPara>(children().back()).markLast(false);
3250 }
3251 bool markFirst = children().empty();
3252 if (needsSeparator)
3253 {
3254 children().append<DocSimpleSectSep>(parser(),thisVariant());
3255 }
3256 children().append<DocPara>(parser(),thisVariant());
3257 DocPara *par = children().get_last<DocPara>();
3258 if (markFirst)
3259 {
3260 par->markFirst();
3261 }
3262 par->markLast();
3263
3264 // parse the contents of the paragraph
3265 Token retval = par->parse();
3266
3267 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3268 return retval; // 0==EOF, TokenRetval::TK_NEWPARA, TokenRetval::TK_LISTITEM, TokenRetval::TK_ENDLIST, TokenRetval::RetVal_SimpleSec
3269}
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 3271 of file docnode.cpp.

3272{
3273 AUTO_TRACE();
3274 auto ns = AutoNodeStack(parser(),thisVariant());
3275
3277 DocTitle *title = &std::get<DocTitle>(*m_title);
3278 title->parseFromString(thisVariant(),parser()->context.token->name);
3279
3280 DString text = parser()->context.token->text;
3281 { DocParser::AutoSaveContext saveContext(*parser());
3283 }
3284
3285 return Token::make_RetVal_OK();
3286}
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:3211
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 3288 of file docnode.cpp.

3289{
3290 AUTO_TRACE();
3291 auto ns = AutoNodeStack(parser(),thisVariant());
3292
3293 Token retval = Token::make_RetVal_OK();
3294 for (;;)
3295 {
3296 // add new paragraph as child
3297 if (!children().empty() && std::holds_alternative<DocPara>(children().back()))
3298 {
3299 std::get<DocPara>(children().back()).markLast(false);
3300 }
3301 bool markFirst = children().empty();
3302 children().append<DocPara>(parser(),thisVariant());
3303 DocPara *par = children().get_last<DocPara>();
3304 if (markFirst)
3305 {
3306 par->markFirst();
3307 }
3308 par->markLast();
3309
3310 // parse the contents of the paragraph
3311 retval = par->parse();
3312 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
3313 if (retval.is(TokenRetval::RetVal_CloseXml))
3314 {
3315 retval = Token::make_RetVal_OK();
3316 break;
3317 }
3318 }
3319
3320 AUTO_TRACE_EXIT("retval={}",retval.to_string());
3321 return retval;
3322}
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 3344 of file docnode.cpp.

3345{
3346 switch (m_type)
3347 {
3348 case Unknown: break;
3349 case See: return "see";
3350 case Return: return "return";
3351 case Author: // fall through
3352 case Authors: return "author";
3353 case Version: return "version";
3354 case Since: return "since";
3355 case Date: return "date";
3356 case Note: return "note";
3357 case Warning: return "warning";
3358 case Pre: return "pre";
3359 case Post: return "post";
3360 case Copyright: return "copyright";
3361 case Invar: return "invariant";
3362 case Remark: return "remark";
3363 case Attention: return "attention";
3364 case Important: return "important";
3365 case User: return "user";
3366 case Rcs: return "rcs";
3367 }
3368 return "unknown";
3369}

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: