00001 #ifndef _WINC_PARSE
00002 #define _WINC_PARSE
00003
00004 #include <WXP/File.h>
00005 #include <WXP/Filename.h>
00006 #include <WXP/String.h>
00007
00008 namespace WXP {
00009 class Parse {
00010 Filename filename;
00011 int ind;
00012 File file;
00013 File hfile;
00014 bool opened;
00015
00016 bool use_hfile;
00017 bool use_awips;
00018
00019 char sheader[80];
00020 char sawip[80];
00021 char sid[80];
00022
00023 char header[80];
00024 char awip[80];
00025 char data[500];
00026
00027 int pline_status;
00028 int line_status;
00029 bool next_hdr;
00030 bool new_prod;
00031
00032 int loc;
00033 int hloc;
00034
00035 int found;
00036 int ifound;
00037
00038 int end_dollar;
00039 int end_blank;
00040
00041 int lnum;
00042
00043 bool compare( const char *pattern );
00044 int newFile();
00045
00046 public:
00047 static const int START = 0x1;
00048 static const int SEQ = 0x2;
00049 static const int HEADER = 0x3;
00050 static const int AWIP = 0x4;
00051 static const int SDATA = 0x5;
00052 static const int DATA = 0x10;
00053 static const int BLANK = 0x11;
00054 static const int DOLLAR = 0x12;
00055 static const int LOCATE = 0x13;
00056 static const int VTEC = 0x14;
00057 static const int LATLON = 0x15;
00058 static const int DESC = 0x16;
00059
00060 Parse();
00061 Parse( const char *str );
00062 int init();
00063 int setParam( const char *str );
00064 int open( Filename &filename );
00065 int open( const char *filename );
00066 bool isOpen();
00067 int rewind();
00068 int close();
00072 inline int useHdrFile( bool val ){ use_hfile = val; return 1; };
00073 inline int useAwipsHdr( bool val ){ use_awips = val; return 1; };
00074 bool isNewProd();
00075 int setHeader( const char *string );
00076 int setId( const char *id );
00077 const char *getHeader();
00078 const char *getAwip();
00079 inline int getLineStatus(){ return line_status; };
00080 int tell();
00081 int seek( int loc );
00082 int getLoc();
00083 int getHeaderLoc();
00084 int getFileInd();
00085 int setLoc( int byte );
00086 int setLoc( int rind, int byte );
00087 int getLine( char *string, int len );
00088 int getLine( String &line );
00089 bool isData();
00090
00091 static bool compare( const char *header, const char *awip, const char *pattern );
00092 static bool checkZone( const char *line, const char *str );
00093 enum Type { RAW, WXP };
00094 };
00095 }
00096 #endif