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 DString &, // scopeName
22 const DString & 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 DString lineStr = input.mid(i,j-i);
36 codeOutIntf.startCodeLine(lineNr);
37 if (options.fileDef() && options.showLineNumbers())
38 {
39 codeOutIntf.writeLineNumber(DString(),DString(),DString(),lineNr,!options.inlineFragment());
40 }
41 if (!lineStr.empty()) codeOutIntf.codify(lineStr.data());
42 codeOutIntf.endCodeLine();
43 lineNr++;
44 i=j+1;
45 }
46}
47
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:322
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:161
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:155
void parseCode(OutputCodeList &codeOutIntf, const DString &scopeName, const DString &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:162
void writeLineNumber(const DString &ref, const DString &file, const DString &anchor, int lineNumber, bool writeLineAnchor)
Definition outputlist.h:253
void endCodeLine()
Definition outputlist.h:264
void startCodeLine(int lineNr)
Definition outputlist.h:261
void codify(const DString &s)
Definition outputlist.h:232
Options to configure the code parser.
Definition parserintf.h:77
const FileDef * fileDef() const
Definition parserintf.h:82
int endLine() const
Definition parserintf.h:84
bool showLineNumbers() const
Definition parserintf.h:87
bool inlineFragment() const
Definition parserintf.h:85
int startLine() const
Definition parserintf.h:83
SrcLangExt
Definition types.h:207