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:85
DocParser * parser()
Definition docnode.h:98
DocNodeVariant * parent()
Definition docnode.h:90

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

324{
325 if (parser()->context.includeFileName.empty())
326 {
327 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
328 "No previous '\\include' or '\\dontinclude' command for '\\{}' present",
329 typeAsString());
330 }
331 bool found = false;
332
334 const char *p = parser()->context.includeFileText.data();
335 size_t l = parser()->context.includeFileLength;
336 size_t o = parser()->context.includeFileOffset;
337 int il = parser()->context.includeFileLine;
338 AUTO_TRACE("text={} off={} len={}",Trace::trunc(p),o,l);
339 size_t so = o, bo = 0;
340 bool nonEmpty = false;
341 switch(type())
342 {
343 case Line:
344 while (o<l)
345 {
346 char c = p[o];
347 if (c=='\n')
348 {
350 if (nonEmpty) break; // we have a pattern to match
351 so=o+1; // no pattern, skip empty line
352 }
353 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
354 {
355 nonEmpty=true;
356 }
357 o++;
358 }
359 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
360 {
361 m_line = il;
363 found = true;
364 AUTO_TRACE_ADD("\\line {}",Trace::trunc(m_text));
365 }
366 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
369 break;
370 case SkipLine:
371 while (o<l)
372 {
373 so=o;
374 while (o<l)
375 {
376 char c = p[o];
377 if (c=='\n')
378 {
380 if (nonEmpty) break; // we have a pattern to match
381 so=o+1; // no pattern, skip empty line
382 }
383 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
384 {
385 nonEmpty=true;
386 }
387 o++;
388 }
389 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
390 {
391 m_line = il;
393 found = true;
394 AUTO_TRACE_ADD("\\skipline {}",Trace::trunc(m_text));
395 break;
396 }
397 o++; // skip new line
398 }
399 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
402 break;
403 case Skip:
404 while (o<l)
405 {
406 so=o;
407 while (o<l)
408 {
409 char c = p[o];
410 if (c=='\n')
411 {
413 if (nonEmpty) break; // we have a pattern to match
414 so=o+1; // no pattern, skip empty line
415 }
416 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
417 {
418 nonEmpty=true;
419 }
420 o++;
421 }
422 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
423 {
424 found = true;
425 break;
426 }
427 o++; // skip new line
428 }
429 parser()->context.includeFileOffset = so; // set pointer to start of new line
432 break;
433 case Until:
434 bo=o;
435 while (o<l)
436 {
437 so=o;
438 while (o<l)
439 {
440 char c = p[o];
441 if (c=='\n')
442 {
444 if (nonEmpty) break; // we have a pattern to match
445 so=o+1; // no pattern, skip empty line
446 }
447 else if (!isspace(static_cast<uint8_t>(c))) // no white space char
448 {
449 nonEmpty=true;
450 }
451 o++;
452 }
453 if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=DString::npos)
454 {
455 m_line = il;
457 found = true;
458 AUTO_TRACE_ADD("\\until {}",Trace::trunc(m_text));
459 break;
460 }
461 o++; // skip new line
462 }
463 parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
466 break;
467 }
468 if (!found)
469 {
470 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
471 "referenced pattern '{}' for command '\\{}' not found",m_pattern,typeAsString());
472 }
473}
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:323
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:153
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:183
size_t find(char c, size_t pos=0) const
Definition dstring.h:244
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:162
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:51
#define AUTO_TRACE(...)
Definition docnode.cpp:50
#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:92
size_t includeFileLength
Definition docparser_p.h:90
DString includeFileText
Definition docparser_p.h:88
DString includeFileName
Definition docparser_p.h:87
size_t includeFileOffset
Definition docparser_p.h:89

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: