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

Node representing a include/dontinclude operator block. More...

#include <src/docnode.h>

Inheritance diagram for DocIncOperator:
Collaboration diagram for DocIncOperator:

Public Types

enum  Type { Line , SkipLine , Skip , Until }

Public Member Functions

 DocIncOperator (DocParser *parser, DocNodeVariant *parent, Type t, const DString &pat, const DString &context, bool stripCodeComments, bool isExample, const DString &exampleFile)
Type type () const
const char * typeAsString () const
int line () const
bool showLineNo () const
DString text () const
DString pattern () const
DString context () const
bool isFirst () const
bool isLast () const
void markFirst (bool v=true)
void markLast (bool v=true)
bool stripCodeComments () const
bool isExample () const
DString exampleFile () const
DString includeFileName () const
void parse ()
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 = Line
int m_line = 0
bool m_showLineNo = false
DString m_text
DString m_pattern
DString m_context
bool m_isFirst = false
bool m_isLast = false
bool m_stripCodeComments = true
bool m_isExample = false
DString m_exampleFile
DString m_includeFileName

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 include/dontinclude operator block.

Definition at line 476 of file docnode.h.

Member Enumeration Documentation

◆ Type

Enumerator
Line 
SkipLine 
Skip 
Until 

Definition at line 479 of file docnode.h.

Constructor & Destructor Documentation

◆ DocIncOperator()

DocIncOperator::DocIncOperator ( DocParser * parser,
DocNodeVariant * parent,
Type t,
const DString & pat,
const DString & context,
bool stripCodeComments,
bool isExample,
const DString & exampleFile )
inline

Definition at line 480 of file docnode.h.

bool m_stripCodeComments
Definition docnode.h:521
bool stripCodeComments() const
Definition docnode.h:506
DString m_context
Definition docnode.h:518
DString context() const
Definition docnode.h:501
DString exampleFile() const
Definition docnode.h:508
DString m_exampleFile
Definition docnode.h:523
bool m_isExample
Definition docnode.h:522
DString m_pattern
Definition docnode.h:517
bool isExample() const
Definition docnode.h:507
DocNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:84
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89

References context(), DocNode::DocNode(), exampleFile(), isExample(), m_context, m_exampleFile, m_isExample, m_isFirst, m_isLast, m_pattern, m_stripCodeComments, m_type, DocNode::parent(), DocNode::parser(), and stripCodeComments().

Member Function Documentation

◆ context()

◆ exampleFile()

◆ includeFileName()

◆ isExample()

◆ isFirst()

bool DocIncOperator::isFirst ( ) const
inline

◆ isLast()

bool DocIncOperator::isLast ( ) const
inline

◆ line()

int DocIncOperator::line ( ) const
inline

◆ markFirst()

void DocIncOperator::markFirst ( bool v = true)
inline

Definition at line 504 of file docnode.h.

504{ m_isFirst = v; }

References m_isFirst.

◆ markLast()

void DocIncOperator::markLast ( bool v = true)
inline

Definition at line 505 of file docnode.h.

505{ m_isLast = v; }

References m_isLast.

Referenced by DocPara::handleIncludeOperator().

◆ parse()

void DocIncOperator::parse ( )

Definition at line 334 of file docnode.cpp.

335{
336 if (parser()->context.includeFileName.empty())
337 {
338 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
339 "No previous '\\include' or '\\dontinclude' command for '\\{}' present",
340 typeAsString());
341 }
342 bool found = false;
343
345 const char *p = parser()->context.includeFileText.data();
346 size_t l = parser()->context.includeFileLength;
347 size_t o = parser()->context.includeFileOffset;
348 int il = parser()->context.includeFileLine;
349 AUTO_TRACE("text={} off={} len={}",Trace::trunc(p),o,l);
350 size_t so = o, bo = 0;
351 bool nonEmpty = false;
352 switch(type())
353 {
354 case Line:
355 while (o<l)
356 {
357 char c = p[o];
358 if (c=='\n')
359 {
361 if (nonEmpty) break; // we have a pattern to match
362 so=o+1; // no pattern, skip empty line
363 }
364 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
365 {
366 nonEmpty=true;
367 }
368 o++;
369 }
370 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
371 {
372 m_line = il;
374 found = true;
375 AUTO_TRACE_ADD("\\line {}",Trace::trunc(m_text));
376 }
377 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
380 break;
381 case SkipLine:
382 while (o<l)
383 {
384 so=o;
385 while (o<l)
386 {
387 char c = p[o];
388 if (c=='\n')
389 {
391 if (nonEmpty) break; // we have a pattern to match
392 so=o+1; // no pattern, skip empty line
393 }
394 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
395 {
396 nonEmpty=true;
397 }
398 o++;
399 }
400 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
401 {
402 m_line = il;
404 found = true;
405 AUTO_TRACE_ADD("\\skipline {}",Trace::trunc(m_text));
406 break;
407 }
408 o++; // skip new line
409 }
410 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
413 break;
414 case Skip:
415 while (o<l)
416 {
417 so=o;
418 while (o<l)
419 {
420 char c = p[o];
421 if (c=='\n')
422 {
424 if (nonEmpty) break; // we have a pattern to match
425 so=o+1; // no pattern, skip empty line
426 }
427 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
428 {
429 nonEmpty=true;
430 }
431 o++;
432 }
433 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
434 {
435 found = true;
436 break;
437 }
438 o++; // skip new line
439 }
440 parser()->context.includeFileOffset = so; // set pointer to start of new line
443 break;
444 case Until:
445 bo=o;
446 while (o<l)
447 {
448 so=o;
449 while (o<l)
450 {
451 char c = p[o];
452 if (c=='\n')
453 {
455 if (nonEmpty) break; // we have a pattern to match
456 so=o+1; // no pattern, skip empty line
457 }
458 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
459 {
460 nonEmpty=true;
461 }
462 o++;
463 }
464 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
465 {
466 m_line = il;
468 found = true;
469 AUTO_TRACE_ADD("\\until {}",Trace::trunc(m_text));
470 break;
471 }
472 o++; // skip new line
473 }
474 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
477 break;
478 }
479 if (!found)
480 {
481 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
482 "referenced pattern '{}' for command '\\{}' not found",m_pattern,typeAsString());
483 }
484}
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
size_t find(char c, size_t pos=0) const
Definition dstring.h:239
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
const char * typeAsString() const
Definition docnode.h:486
DString m_text
Definition docnode.h:516
Type type() const
Definition docnode.h:485
bool m_showLineNo
Definition docnode.h:515
DocParserContext context
#define AUTO_TRACE_ADD(...)
Definition docnode.cpp:54
#define AUTO_TRACE(...)
Definition docnode.cpp:53
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
DString trunc(const DString &s, size_t numChars=15)
Definition trace.h:56
bool includeFileShowLineNo
Definition docparser_p.h:91
size_t includeFileLength
Definition docparser_p.h:89
DString includeFileText
Definition docparser_p.h:87
DString includeFileName
Definition docparser_p.h:86
size_t includeFileOffset
Definition docparser_p.h:88

References AUTO_TRACE, AUTO_TRACE_ADD, context(), DocParser::context, DString::data(), DString::empty(), DString::find(), DocParserContext::includeFileLength, DocParserContext::includeFileLine, DocParserContext::includeFileName, DocParserContext::includeFileOffset, DocParserContext::includeFileShowLineNo, DocParserContext::includeFileText, Line, m_includeFileName, m_line, m_pattern, m_showLineNo, m_stripCodeComments, m_text, DString::mid(), DString::npos, DocNode::parser(), Skip, SkipLine, DocParserContext::stripCodeComments, Trace::trunc(), type(), typeAsString(), Until, and warn_doc_error.

◆ pattern()

DString DocIncOperator::pattern ( ) const
inline

Definition at line 500 of file docnode.h.

500{ return m_pattern; }

References m_pattern.

Referenced by PrintDocVisitor::operator()().

◆ showLineNo()

bool DocIncOperator::showLineNo ( ) const
inline

◆ stripCodeComments()

◆ text()

◆ type()

◆ typeAsString()

const char * DocIncOperator::typeAsString ( ) const
inline

Definition at line 486 of file docnode.h.

487 {
488 switch(m_type)
489 {
490 case Line: return "line";
491 case SkipLine: return "skipline";
492 case Skip: return "skip";
493 case Until: return "until";
494 }
495 return "";
496 }

References Line, m_type, Skip, SkipLine, and Until.

Referenced by parse().

Member Data Documentation

◆ m_context

DString DocIncOperator::m_context
private

Definition at line 518 of file docnode.h.

Referenced by context(), and DocIncOperator().

◆ m_exampleFile

DString DocIncOperator::m_exampleFile
private

Definition at line 523 of file docnode.h.

Referenced by DocIncOperator(), and exampleFile().

◆ m_includeFileName

DString DocIncOperator::m_includeFileName
private

Definition at line 524 of file docnode.h.

Referenced by includeFileName(), and parse().

◆ m_isExample

bool DocIncOperator::m_isExample = false
private

Definition at line 522 of file docnode.h.

Referenced by DocIncOperator(), and isExample().

◆ m_isFirst

bool DocIncOperator::m_isFirst = false
private

Definition at line 519 of file docnode.h.

Referenced by DocIncOperator(), isFirst(), and markFirst().

◆ m_isLast

bool DocIncOperator::m_isLast = false
private

Definition at line 520 of file docnode.h.

Referenced by DocIncOperator(), isLast(), and markLast().

◆ m_line

int DocIncOperator::m_line = 0
private

Definition at line 514 of file docnode.h.

Referenced by line(), and parse().

◆ m_pattern

DString DocIncOperator::m_pattern
private

Definition at line 517 of file docnode.h.

Referenced by DocIncOperator(), parse(), and pattern().

◆ m_showLineNo

bool DocIncOperator::m_showLineNo = false
private

Definition at line 515 of file docnode.h.

Referenced by parse(), and showLineNo().

◆ m_stripCodeComments

bool DocIncOperator::m_stripCodeComments = true
private

Definition at line 521 of file docnode.h.

Referenced by DocIncOperator(), parse(), and stripCodeComments().

◆ m_text

DString DocIncOperator::m_text
private

Definition at line 516 of file docnode.h.

Referenced by parse(), and text().

◆ m_type

Type DocIncOperator::m_type = Line
private

Definition at line 513 of file docnode.h.

Referenced by DocIncOperator(), type(), and typeAsString().


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