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

Generic code parser. More...

#include <src/fileparser.h>

Inheritance diagram for FileCodeParser:
Collaboration diagram for FileCodeParser:

Public Member Functions

void parseCode (OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &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 QCString & scopeName,
const QCString & 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 QCString lineStr = input.mid(i,j-i);
36 codeOutIntf.startCodeLine(lineNr);
37 if (options.fileDef() && options.showLineNumbers())
38 {
39 codeOutIntf.writeLineNumber(QCString(),QCString(),QCString(),lineNr,!options.inlineFragment());
40 }
41 if (!lineStr.isEmpty()) codeOutIntf.codify(lineStr.data());
42 codeOutIntf.endCodeLine();
43 lineNr++;
44 i=j+1;
45 }
46}
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
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(), QCString::data(), OutputCodeList::endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::fileDef(), CodeParserOptions::inlineFragment(), QCString::isEmpty(), QCString::length(), QCString::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: