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(), 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 340 of file docnode.cpp.

341{
342 if (parser()->context.includeFileName.empty())
343 {
344 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
345 "No previous '\\include' or '\\dontinclude' command for '\\{}' present",
346 typeAsString());
347 }
348 bool found = false;
349
351 const char *p = parser()->context.includeFileText.data();
352 size_t l = parser()->context.includeFileLength;
353 size_t o = parser()->context.includeFileOffset;
354 int il = parser()->context.includeFileLine;
355 AUTO_TRACE("text={} off={} len={}",Trace::trunc(p),o,l);
356 size_t so = o, bo = 0;
357 bool nonEmpty = false;
358 switch(type())
359 {
360 case Line:
361 while (o<l)
362 {
363 char c = p[o];
364 if (c=='\n')
365 {
367 if (nonEmpty) break; // we have a pattern to match
368 so=o+1; // no pattern, skip empty line
369 }
370 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
371 {
372 nonEmpty=true;
373 }
374 o++;
375 }
376 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
377 {
378 m_line = il;
380 found = true;
381 AUTO_TRACE_ADD("\\line {}",Trace::trunc(m_text));
382 }
383 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
386 break;
387 case SkipLine:
388 while (o<l)
389 {
390 so=o;
391 while (o<l)
392 {
393 char c = p[o];
394 if (c=='\n')
395 {
397 if (nonEmpty) break; // we have a pattern to match
398 so=o+1; // no pattern, skip empty line
399 }
400 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
401 {
402 nonEmpty=true;
403 }
404 o++;
405 }
406 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
407 {
408 m_line = il;
410 found = true;
411 AUTO_TRACE_ADD("\\skipline {}",Trace::trunc(m_text));
412 break;
413 }
414 o++; // skip new line
415 }
416 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
419 break;
420 case Skip:
421 while (o<l)
422 {
423 so=o;
424 while (o<l)
425 {
426 char c = p[o];
427 if (c=='\n')
428 {
430 if (nonEmpty) break; // we have a pattern to match
431 so=o+1; // no pattern, skip empty line
432 }
433 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
434 {
435 nonEmpty=true;
436 }
437 o++;
438 }
439 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
440 {
441 found = true;
442 break;
443 }
444 o++; // skip new line
445 }
446 parser()->context.includeFileOffset = so; // set pointer to start of new line
449 break;
450 case Until:
451 bo=o;
452 while (o<l)
453 {
454 so=o;
455 while (o<l)
456 {
457 char c = p[o];
458 if (c=='\n')
459 {
461 if (nonEmpty) break; // we have a pattern to match
462 so=o+1; // no pattern, skip empty line
463 }
464 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
465 {
466 nonEmpty=true;
467 }
468 o++;
469 }
470 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
471 {
472 m_line = il;
474 found = true;
475 AUTO_TRACE_ADD("\\until {}",Trace::trunc(m_text));
476 break;
477 }
478 o++; // skip new line
479 }
480 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
483 break;
484 }
485 if (!found)
486 {
487 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
488 "referenced pattern '{}' for command '\\{}' not found",m_pattern,typeAsString());
489 }
490}
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: