Main Page Modules Class Hierarchy Compound List File List Compound Members

# nedfilebuffer.h

    00001 //==========================================================================
    00002 //   NEDFILEBUFFER.H -
    00003 //            part of OMNeT++
    00004 //
    00005 //==========================================================================
    00006
    00007 /*--------------------------------------------------------------*
    00008   Copyright (C) 2002-2003 Andras Varga
    00009
    00010   This file is distributed WITHOUT ANY WARRANTY. See the file
    00011   `license' for details on this and other legal matters.
    00012 *--------------------------------------------------------------*/
    00013
    00014 #ifndef __NEDFILEBUFFER_H
    00015 #define __NEDFILEBUFFER_H
    00016
    00017 #include "nedparser.h"   // for YYLTYPE
    00018
    00027 class NEDFileBuffer
    00028 {
    00029   private:
    00030     enum {COMMENT_LINE, BLANK_LINE, CODE_LINE};
    00031
    00032     char *wholeFile;
    00033
    00034     int numLines;
    00035     char **lineBeg;
    00036
    00037     char *end;
    00038     char savedChar;
    00039
    00040     char *commentBuf;
    00041     int commentBufLen;
    00042
    00043   private:
    00044     int lineType(char *s);
    00045     int lineContainsCode(char *s);
    00046     int getIndent(char *s);
    00047     int lastColumn(char *s);
    00048     char *getPosition(int line, int column);
    00049
    00050     bool indexLines();
    00051     int topLineOfBannerComment(int li);
    00052     char *stripComment(const char *s, int numlines);
    00053
    00054   public:
    00058     NEDFileBuffer();
    00059
    00063     ~NEDFileBuffer();
    00064
    00070     bool readFile(const char *filename);
    00071
    00077     bool setData(const char *data);
    00078
    00086     const char *get(YYLTYPE pos);
    00087
    00091     const char *getFileComment();
    00092
    00096     const char *getBannerComment(YYLTYPE pos);
    00097
    00101     const char *getTrailingComment(YYLTYPE pos);
    00102 };
    00103
    00104 #endif
    00105