Hosting courtesy of Sourceforge

SourceForge Logo
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Parse.h

Go to the documentation of this file.
00001 //
00002 //      Copyright (C) 2002 Robert Renaud
00003 //
00004 //      This program is free software; you can redistribute it and/or
00005 //      modify it under the terms of the GNU General Public License
00006 //      as published by the Free Software Foundation; either version 2
00007 //      of the License, or (at your option) any later version.
00008 //
00009 //      This program is distributed in the hope that it will be useful,
00010 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 //
00013 //      See the GNU General Public License for more details.
00014 //
00015 //      You should have received a copy of the GNU General Public License
00016 //      along with this program; if not, write to the Free Software
00017 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 
00020 //Parse.h
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                 // implement this later perhaps, would need to copy all ParseActions in map
00085                 // so ugly dangling pointer things dont happen
00086         //      Parser(const Parser& otherParser) : input(otherParser.input) { }
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 }; // namespace Parse
00168 
00169 #endif // ifndef PARSE_H_
00170 

Generated on Tue May 21 07:26:51 2002 for BomberLAN by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001