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

Generic code parser. More...

#include <src/fileparser.h>

Inheritance diagram for FileCodeParser:
Collaboration diagram for FileCodeParser:

Public Member Functions

void parseCode (OutputCodeList &codeOutIntf, const DString &scopeName, const DString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options) override
 Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
void resetCodeParserState () override
 Resets the state of the code parser.

Detailed Description

Generic code parser.

Definition at line 22 of file fileparser.h.

Member Function Documentation

◆ parseCode()

void FileCodeParser::parseCode ( OutputCodeList & codeOutList,
const DString & scopeName,
const DString & input,
SrcLangExt lang,
bool stripCodeComments,
const CodeParserOptions & options )
overridevirtual

Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.

Parameters
[in]codeOutListinterface for writing the result.
[in]scopeNameName of scope to which the code belongs.
[in]inputActual code in the form of a string
[in]langThe programming language of the code fragment.
[in]stripCodeCommentssignals whether or not for the code block the doxygen comments should be stripped.
[in]optionsAdditional options to configure the parser.

Implements CodeParserInterface.

Definition at line 20 of file fileparser.cpp.

27{
28 int lineNr = options.startLine()!=-1 ? options.startLine() : 1;
29 size_t length = input.length();
30 size_t i=0;
31 while (i<length && (options.endLine()==-1 || lineNr<=options.endLine()))
32 {
33 size_t j=i;
34 while (j<length && input[j]!='\n') j++;
35 DString lineStr = input.mid(i,j-i);
36 codeOutIntf.startCodeLine(lineNr);
37 if (options.fileDef() && options.showLineNumbers())
38 {
39 codeOutIntf.writeLineNumber(DString(),DString(),DString(),lineNr,!options.inlineFragment());
40 }
41 if (!lineStr.empty()) codeOutIntf.codify(lineStr.data());
42 codeOutIntf.endCodeLine();
43 lineNr++;
44 i=j+1;
45 }
46}
DString()=default
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
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
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:156
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
bool showLineNumbers() const
Definition parserintf.h:88
bool inlineFragment() const
Definition parserintf.h:86
int startLine() const
Definition parserintf.h:84

References OutputCodeList::codify(), DString::data(), DString::DString(), DString::empty(), OutputCodeList::endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::fileDef(), CodeParserOptions::inlineFragment(), DString::length(), DString::mid(), CodeParserOptions::showLineNumbers(), OutputCodeList::startCodeLine(), CodeParserOptions::startLine(), and OutputCodeList::writeLineNumber().

◆ resetCodeParserState()

void FileCodeParser::resetCodeParserState ( )
inlineoverridevirtual

Resets the state of the code parser.

Since multiple code fragments can together form a single example, an explicit function is used to reset the code parser state.

See also
parseCode()

Implements CodeParserInterface.

Definition at line 32 of file fileparser.h.

32{}

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