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 const CodeParserOptions &options
26 )
27{
28 int lineNr = options.startLine()!=-1 ? options.startLine() : 1;
29 size_t length = input.length();
30 size_t i=0;
31 while (i<length && (options.endLine()==-1 || lineNr<=options.endLine()))
32 {
33 size_t j=i;
34 while (j<length && input[j]!='\n') j++;
35 QCString lineStr = input.mid(i,j-i);
36 codeOutIntf.startCodeLine(lineNr);
37 if (options.fileDef() && options.showLineNumbers())
38 {
39 codeOutIntf.writeLineNumber(QCString(),QCString(),QCString(),lineNr,!options.inlineFragment());
40 }
41 if (!lineStr.isEmpty()) codeOutIntf.codify(lineStr.data());
42 codeOutIntf.endCodeLine();
43 lineNr++;
44 i=j+1;
45 }
46}
47
void parseCode(OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options) override
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Class representing a list of different code generators.
Definition outputlist.h:165
void endCodeLine()
Definition outputlist.h:267
void codify(const QCString &s)
Definition outputlist.h:235
void startCodeLine(int lineNr)
Definition outputlist.h:264
void writeLineNumber(const QCString &ref, const QCString &file, const QCString &anchor, int lineNumber, bool writeLineAnchor)
Definition outputlist.h:256
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:166
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
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:172
Options to configure the code parser.
Definition parserintf.h:78
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
bool showLineNumbers() const
Definition parserintf.h:88
bool inlineFragment() const
Definition parserintf.h:86
int startLine() const
Definition parserintf.h:84
SrcLangExt
Definition types.h:207