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

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