Skip to main content

FileCodeParser Class

Generic code parser. More...

Declaration​

class FileCodeParser { ... }

Included Headers​

#include <src/fileparser.h>

Base class​

classCodeParserInterface

Abstract interface for code parsers. More...

Public Member Functions Index​

voidparseCode (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. More...

voidresetCodeParserState () override

Resets the state of the code parser. More...

Description​

Generic code parser.

Definition at line 22 of file fileparser.h.

Public Member Functions​

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)
virtual

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

Parameters
[in] codeOutList

interface for writing the result.

[in] scopeName

Name of scope to which the code belongs.

[in] input

Actual code in the form of a string

[in] lang

The programming language of the code fragment.

[in] stripCodeComments

signals whether or not for the code block the doxygen comments should be stripped.

[in] isExampleBlock

TRUE iff the code is part of an example.

[in] exampleName

Name of the example.

[in] fileDef

File definition to which the code is associated.

[in] startLine

Starting line in case of a code fragment.

[in] endLine

Ending line of the code fragment.

[in] inlineFragment

Code fragment that is to be shown inline as part of the documentation.

[in] memberDef

Member definition to which the code is associated (non null in case of an inline fragment for a member).

[in] showLineNumbers

if set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment

[in] searchCtx

context under which search data has to be stored.

[in] collectXRefs

collect cross-reference relations.

Declaration at line 25 of file fileparser.h, definition at line 20 of file fileparser.cpp.

21 const QCString &, // scopeName
22 const QCString & input,
23 SrcLangExt, // lang
24 bool, // stripCodeComments
25 bool, // isExampleBlock
26 const QCString &, // exampleName
27 const FileDef * fileDef,
28 int startLine,
29 int endLine,
30 bool inlineFragment,
31 const MemberDef *, // memberDef
32 bool showLineNumbers,
33 const Definition *, // searchCtx,
34 bool // collectXRefs
35 )
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}

References OutputCodeList::codify, QCString::data, OutputCodeList::endCodeLine, QCString::isEmpty, QCString::length, QCString::mid, OutputCodeList::startCodeLine and OutputCodeList::writeLineNumber.

resetCodeParserState()​

void FileCodeParser::resetCodeParserState ()
inline virtual

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()

Definition at line 41 of file fileparser.h.

41 void resetCodeParserState() override {}

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.14.0.