00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PARSE_H_
00023 #define PARSE_H_
00024
00025 #include "../Config.h"
00026 #include <string>
00027 #include <map>
00028 #include <set>
00029
00030 #include "ParseDebug.h"
00031 #include "ParseAction.h"
00032 #include "../Util/StringUtil.h"
00033
00034 using namespace std;
00035
00036 typedef hash_map<std::string,Parse::ParseAction*> ActionMap_t;
00037
00052 namespace Parse {
00061 class Parser {
00062 public:
00063
00067 virtual ~Parser();
00068
00074 void addAction(string identifier, ParseAction* dynPtrAction);
00075
00080 virtual void read()=0;
00081 protected:
00082 ActionMap_t actionMap;
00083 private:
00084
00085
00086
00087 };
00088
00095 class SimpleParser : public Parser {
00096 public:
00100 SimpleParser(istream &inputFile);
00101
00116 virtual void read();
00117 private:
00118 std::istream& input;
00119 };
00120
00137 class CommandLineParser: public Parser {
00138 public:
00146 CommandLineParser(int argc, char* argv[], string tagChars="-");
00147 virtual void read();
00148 private:
00149 int argc;
00150 char** argv;
00151 string tagChars;
00152 };
00153
00155 class DelegateToSubParser : public ParseAction {
00156 public:
00160 DelegateToSubParser(Parser* parser);
00161 virtual ~DelegateToSubParser();
00162 void getValue(istream& input);
00163 private:
00164 Parser* parser;
00165 };
00166
00167 };
00168
00169 #endif // ifndef PARSE_H_
00170