Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ExCFile.h

Go to the documentation of this file.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (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.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  * $Id: ExCFile.h,v 1.12 2002/08/06 16:52:58 binny Exp $
00021  *
00022  */
00023  
00024 #ifndef __EXCFILE_H
00025 #define __EXCFILE_H
00026 
00027 #include <iostream>
00028 #include <fstream>
00029 #include <string>
00030 #include <vector>
00031 
00032 #include "ExDefine.h"
00033 
00034 
00035 enum { FILE_EMPTY,
00036         FILE_CONSOLE,
00037         FILE_COMMAND, 
00038         FILE_SET,
00039         FILE_INTERFACE,
00040         FILE_PARTICULE,
00041         FILE_BATCH,
00042         FILE_UNKNOWN
00043 };
00044 
00045 enum { RO, WO, WOA, RW, RWA };
00046 
00047 using namespace std;
00048 
00049 class ExCFileDataAction {
00050         private:
00051                 string action;
00052                 int command;
00053                 string param;
00054         public:
00055                 ExCFileDataAction () {};
00056                 ExCFileDataAction (string s, int c) { action = s; command = c; };
00057                 void setAction (string s) { action = s; };              
00058                 string getAction (void) { return action; };
00059                 
00060                 void setCommand (int c) { command = c; };
00061                 int getCommand (void) { return command; };
00062                 
00063                 void setParam (string p) { param = p; };
00064                 string getParam (void) { return param; };
00065                 
00066                 void setActionCommand (string s, int c) { action = s; command = c; };
00067                 void setActionCommand (string s, int c, string p) { action = s; command = c; param = p; };
00068 };
00069 
00070 class ExCFileData {
00071         private:                
00072                 int type;
00073                 vector<ExCFileDataAction> content;
00074         public:
00075                 ExCFileData () { type = FILE_EMPTY; };
00076                 ExCFileData (int t, vector<ExCFileDataAction> s) { type = t; content = s; };
00077                 void setType (int t) { type = t; };
00078                 int getType (void) { return type; };
00079                 void setContent (vector<ExCFileDataAction> s) { content = s; };
00080                 void addElement (ExCFileDataAction s) { content.push_back (s); }
00081                 vector<ExCFileDataAction> getContent (void) { return content; };
00082 };
00083 
00084 class ExCFile {
00085         protected:
00086                 string filename;
00087                 ios_base::openmode mode;
00088         public:
00089                 ExCFile () {};
00090                 ExCFile (string s) { filename = s; };
00091                 ExCFile (string s, int m) { filename = s, setOpenMode (m); };
00092                 virtual ~ExCFile ();
00093                 bool open (void);
00094                 bool close (void);
00095                 void setOpenMode (int);
00096                 ios_base::openmode getOpenMode (int);
00097                 
00098                 void setFileName (string s) { filename = s; };
00099                 std::string getFileName (void) { return filename; };
00100                 
00101                 bool exist (void);
00102                 vector<std::string> getContent (void);
00103                 bool add (std::string);
00104                 bool addLine (void);
00105 };
00106 
00107 class ExCFileReader : public ExCFile {
00108         private:
00109                 ExCFileData *file_data;
00110         public:
00111                 ExCFileReader () : ExCFile () { file_data = new ExCFileData; };
00112                 ExCFileReader (string);
00113                 ExCFileData getContent (void);
00114 };
00115 
00116 class ExCFileWriter : public ExCFile {
00117         public:
00118                 ExCFileWriter () : ExCFile () {};
00119                 ExCFileWriter (string);
00120                 void setContent (ExCFileData);
00121 };
00122 
00123 #endif // __EXCFILE_H

Generated on Tue Aug 6 20:27:06 2002 for ExNihilo by doxygen1.2.17