Doxygen
Loading...
Searching...
No Matches
fileparser.cpp
Go to the documentation of this file.
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#include "outputlist.h"
19
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}
56
The common base class of all entity definitions found in the sources.
Definition definition.h:76
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.
A model of a file symbol.
Definition filedef.h:99
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
Class representing a list of different code generators.
Definition outputlist.h:164
void endCodeLine()
Definition outputlist.h:266
void codify(const QCString &s)
Definition outputlist.h:234
void startCodeLine(int lineNr)
Definition outputlist.h:263
void writeLineNumber(const QCString &ref, const QCString &file, const QCString &anchor, int lineNumber, bool writeLineAnchor)
Definition outputlist.h:255
This is an alternative implementation of QCString.
Definition qcstring.h:101
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
SrcLangExt
Language as given by extension.
Definition types.h:42