nedfilebuffer.h

Go to the documentation of this file.
00001 //==========================================================================
00002 //  NEDFILEBUFFER.H - part of
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 //==========================================================================
00008 
00009 /*--------------------------------------------------------------*
00010   Copyright (C) 2002-2008 Andras Varga
00011   Copyright (C) 2006-2008 OpenSim Ltd.
00012 
00013   This file is distributed WITHOUT ANY WARRANTY. See the file
00014   `license' for details on this and other legal matters.
00015 *--------------------------------------------------------------*/
00016 
00017 #ifndef __NEDFILEBUFFER_H
00018 #define __NEDFILEBUFFER_H
00019 
00020 #include "nedparser.h"   // for YYLTYPE
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 
Generated on Tue Dec 2 11:16:31 2014 for OMNeT++ NEDXML by  doxygen 1.6.3