00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef PARSER_H
00013 #define PARSER_H
00014
00015 #include <iostream>
00016
00017 using namespace std;
00018
00019 enum charType {integer, alpha};
00020
00021 class Parser {
00022 private:
00023
00024 string filename;
00025 istream& infile;
00026 string delims;
00027 int line_num, line_pos;
00028
00029 public:
00031 Parser(string, istream&, string);
00032
00033 Parser(string, istream&, string, int, int);
00034
00036 ~Parser(){};
00037
00038
00039
00040 void reset();
00041
00042 string getToken();
00043
00044 string getSingleToken();
00045
00046 string peekAtToken();
00047
00048 bool charIsDelim(char);
00049
00050 string getAlphaToken();
00051
00052 string getFileToken();
00053
00054 string getStringBetween(string);
00055
00056 string getStringBetween(string, string);
00057
00058 string getStringBetweenMatched(char, char);
00059
00060 string getStringBefore(string);
00061
00062
00063 string getKey();
00064
00065 bool getBoolToken();
00066
00067 uint getUIntToken();
00068
00069 int getIntToken();
00070
00071 double getFloatToken();
00072
00073 bool jumpToNext(string );
00074
00075 void nextTokenMustBe(string);
00076
00077 bool nextTokenIs(string);
00078
00079 bool nextSingleTokenIs(string);
00080
00081 bool nextTokenIs(charType);
00082
00083 void chuck(string);
00084
00085
00086
00087 bool isBool(const string&);
00088
00089 bool isUInt(const string&);
00090
00091 bool isInt(const string&);
00092
00093 bool isFloat(const string&);
00094
00095 bool isAlpha(const string&);
00096
00097 bool isFile(const string&);
00098
00099 int getLineNum() {return line_num;};
00100
00101 int getLinePos() {return line_pos;};
00102
00103 string getFileName() {return filename;};
00104
00105 bool atEnd();
00106
00107 void outputRemaining(ostream&);
00108
00109 };
00110
00111 #endif