Doxygen
FileCodeParser类 参考

Generic code parser 更多...

#include <fileparser.h>

+ 类 FileCodeParser 继承关系图:
+ FileCodeParser 的协作图:

Public 成员函数

virtual ~FileCodeParser ()
 
void parseCode (CodeOutputInterface &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=0, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=0, bool showLineNumbers=TRUE, const Definition *searchCtx=0, bool collectXRefs=TRUE)
 Parses a source file or fragment with the goal to produce highlighted and cross-referenced output. 更多...
 
void resetCodeParserState ()
 Resets the state of the code parser. 更多...
 
- Public 成员函数 继承自 CodeParserInterface
virtual ~CodeParserInterface ()
 

详细描述

Generic code parser

在文件 fileparser.h22 行定义.

构造及析构函数说明

◆ ~FileCodeParser()

virtual FileCodeParser::~FileCodeParser ( )
inlinevirtual

在文件 fileparser.h38 行定义.

41 {}

成员函数说明

◆ parseCode()

void FileCodeParser::parseCode ( CodeOutputInterface codeOutIntf,
const QCString scopeName,
const QCString input,
SrcLangExt  lang,
bool  isExampleBlock,
const QCString exampleName = QCString(),
const FileDef fileDef = 0,
int  startLine = -1,
int  endLine = -1,
bool  inlineFragment = FALSE,
const MemberDef memberDef = 0,
bool  showLineNumbers = TRUE,
const Definition searchCtx = 0,
bool  collectXRefs = TRUE 
)
virtual

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

参数
[in]codeOutIntfAbstract interface 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]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.

实现了 CodeParserInterface.

在文件 fileparser.cpp19 行定义.

34 {
35  int lineNr = startLine!=-1 ? startLine : 1;
36  int length = input.length();
37  int i=0;
38  while (i<length && (endLine==-1 || lineNr<=endLine))
39  {
40  int j=i;
41  while (j<length && input[j]!='\n') j++;
42  QCString lineStr = input.mid(i,j-i);
43  codeOutIntf.startCodeLine(fileDef != 0 && showLineNumbers);
44  if (fileDef != 0 && showLineNumbers)
45  {
46  codeOutIntf.writeLineNumber(QCString(),QCString(),QCString(),lineNr,!inlineFragment);
47  }
48  if (!lineStr.isEmpty()) codeOutIntf.codify(lineStr.data());
49  codeOutIntf.endCodeLine();
50  lineNr++;
51  i=j+1;
52  }
53 }

引用了 CodeOutputInterface::codify(), QCString::data(), CodeOutputInterface::endCodeLine(), QCString::isEmpty(), QCString::length(), QCString::mid(), CodeOutputInterface::startCodeLine() , 以及 CodeOutputInterface::writeLineNumber().

◆ resetCodeParserState()

void FileCodeParser::resetCodeParserState ( )
inlinevirtual

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.

参见
parseCode()

实现了 CodeParserInterface.

在文件 fileparser.h54 行定义.


该类的文档由以下文件生成:
CodeOutputInterface::writeLineNumber
virtual void writeLineNumber(const QCString &ref, const QCString &file, const QCString &anchor, int lineNumber, bool writeLineAnchor)=0
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
CodeOutputInterface::codify
virtual void codify(const QCString &s)=0
CodeOutputInterface::endCodeLine
virtual void endCodeLine()=0
CodeOutputInterface::startCodeLine
virtual void startCodeLine(bool hasLineNumbers)=0
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
QCString::data
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:153
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108