nedfilebuffer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __NEDFILEBUFFER_H
00018 #define __NEDFILEBUFFER_H
00019
00020 #include "nedparser.h"
00021
00022 NAMESPACE_BEGIN
00023
00032 class NEDXML_API NEDFileBuffer
00033 {
00034 private:
00035 enum {COMMENT_LINE, BLANK_LINE, CODE_LINE};
00036
00037 char *wholeFile;
00038
00039 int numLines;
00040 char **lineBeg;
00041
00042 char *end;
00043 char savedChar;
00044
00045 char *commentBuf;
00046 int commentBufLen;
00047
00048 private:
00049 int getLineType(int lineNumber);
00050 int getLineType(const char *s);
00051 bool lineContainsCode(const char *s);
00052 int getLineIndent(int lineNumber);
00053 int getLineIndent(const char *s);
00054 char *getPosition(int line, int column);
00055
00056 bool indexLines();
00057 int topLineOfBannerComment(int li);
00058 char *stripComment(const char *s);
00059
00060 YYLTYPE getFileCommentPos();
00061 YYLTYPE getBannerCommentPos(YYLTYPE pos);
00062 YYLTYPE getTrailingCommentPos(YYLTYPE pos);
00063
00064 public:
00068 NEDFileBuffer();
00069
00073 ~NEDFileBuffer();
00074
00080 bool readFile(const char *filename);
00081
00087 bool setData(const char *data);
00088
00096 const char *get(YYLTYPE pos);
00097
00101 const char *getFileComment();
00102
00106 const char *getBannerComment(YYLTYPE pos);
00107
00111 const char *getTrailingComment(YYLTYPE pos);
00112
00117 const char *getNextInnerComment(YYLTYPE& pos);
00118
00122 YYLTYPE getFullTextPos();
00123
00127 const char *getFullText();
00128
00133 void trimSpaceAndComments(YYLTYPE& pos);
00134 };
00135
00136 NAMESPACE_END
00137
00138
00139 #endif
00140