Doxygen
fileparser.cpp
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2015 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #include "fileparser.h"
17 #include "outputgen.h"
18 
20  const QCString &, // scopeName
21  const QCString & input,
22  SrcLangExt, // lang
23  bool, // isExampleBlock
24  const QCString &, // exampleName
25  const FileDef * fileDef,
26  int startLine,
27  int endLine,
28  bool inlineFragment,
29  const MemberDef *, // memberDef
30  bool showLineNumbers,
31  const Definition *, // searchCtx,
32  bool // collectXRefs
33  )
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 }
54 
CodeOutputInterface::writeLineNumber
virtual void writeLineNumber(const QCString &ref, const QCString &file, const QCString &anchor, int lineNumber, bool writeLineAnchor)=0
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
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
SrcLangExt
SrcLangExt
Language as given by extension
Definition: types.h:41
FileCodeParser::parseCode
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.
Definition: fileparser.cpp:19
CodeOutputInterface::codify
virtual void codify(const QCString &s)=0
CodeOutputInterface::endCodeLine
virtual void endCodeLine()=0
CodeOutputInterface::startCodeLine
virtual void startCodeLine(bool hasLineNumbers)=0
outputgen.h
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
fileparser.h
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
CodeOutputInterface
Output interface for code parser.
Definition: outputgen.h:61
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
FileDef
A model of a file symbol.
Definition: filedef.h:73
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108