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, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=nullptr, bool showLineNumbers=TRUE, const Definition *searchCtx=nullptr, bool collectXRefs=TRUE) 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.
 
- Public Member Functions inherited from CodeParserInterface

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,
bool isExampleBlock,
const QCString & exampleName = QCString(),
const FileDef * fileDef = nullptr,
int startLine = -1,
int endLine = -1,
bool inlineFragment = FALSE,
const MemberDef * memberDef = nullptr,
bool showLineNumbers = TRUE,
const Definition * searchCtx = nullptr,
bool collectXRefs = TRUE )
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]isExampleBlockTRUE iff the code is part of an example.
[in]exampleNameName of the example.
[in]fileDefFile definition to which the code is associated.
[in]startLineStarting line in case of a code fragment.
[in]endLineEnding line of the code fragment.
[in]inlineFragmentCode fragment that is to be shown inline as part of the documentation.
[in]memberDefMember definition to which the code is associated (non null in case of an inline fragment for a member).
[in]showLineNumbersif set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment
[in]searchCtxcontext under which search data has to be stored.
[in]collectXRefscollect cross-reference relations.

Implements CodeParserInterface.

Definition at line 20 of file fileparser.cpp.

36{
37 int lineNr = startLine!=-1 ? startLine : 1;
38 size_t length = input.length();
39 size_t i=0;
40 while (i<length && (endLine==-1 || lineNr<=endLine))
41 {
42 size_t j=i;
43 while (j<length && input[j]!='\n') j++;
44 QCString lineStr = input.mid(i,j-i);
45 codeOutIntf.startCodeLine(lineNr);
46 if (fileDef != nullptr && showLineNumbers)
47 {
48 codeOutIntf.writeLineNumber(QCString(),QCString(),QCString(),lineNr,!inlineFragment);
49 }
50 if (!lineStr.isEmpty()) codeOutIntf.codify(lineStr.data());
51 codeOutIntf.endCodeLine();
52 lineNr++;
53 i=j+1;
54 }
55}
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
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:159

References OutputCodeList::codify(), QCString::data(), OutputCodeList::endCodeLine(), QCString::isEmpty(), QCString::length(), QCString::mid(), OutputCodeList::startCodeLine(), 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 41 of file fileparser.h.

41{}

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