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 22 of file fileparser.cpp.

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

References OutputCodeList::codify(), DString::data(), 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: