Main Page Namespace List Class Hierarchy Alphabetical List Data Structures File List Namespace Members 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.13 2002/08/25 15:27:48 data 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 #define FILE_EMPTY              0
    00036 #define FILE_CONSOLE    1
    00037 #define FILE_COMMAND    2
    00038 #define FILE_SET                3
    00039 #define FILE_INTERFACE  4
    00040 #define FILE_PARTICULE  5
    00041 #define FILE_BATCH              6
    00042 #define FILEUNKNOWN     7
    00043
    00044 enum { RO, WO, WOA, RW, RWA };
    00045
    00046 using namespace std;
    00047
    00048 class ExCFileDataAction {
    00049         private:
    00050                 string action;
    00051                 int command;
    00052                 string param;
    00053         public:
    00054                 ExCFileDataAction () {};
    00055                 ExCFileDataAction (string s, int c) { action = s; command = c; };
    00056                 void setAction (string s) { action = s; };
    00057                 string getAction (void) { return action; };
    00058
    00059                 void setCommand (int c) { command = c; };
    00060                 int getCommand (void) { return command; };
    00061
    00062                 void setParam (string p) { param = p; };
    00063                 string getParam (void) { return param; };
    00064
    00065                 void setActionCommand (string s, int c) { action = s; command = c; };
    00066                 void setActionCommand (string s, int c, string p) { action = s; command = c; param = p; };
    00067 };
    00068
    00069 class ExCFileData {
    00070         private:
    00071                 int type;
    00072                 vector<ExCFileDataAction> content;
    00073         public:
    00074                 ExCFileData () { type = FILE_EMPTY; };
    00075                 ExCFileData (int t, vector<ExCFileDataAction> s) { type = t; content = s; };
    00076                 void setType (int t) { type = t; };
    00077                 int getType (void) { return type; };
    00078                 void setContent (vector<ExCFileDataAction> s) { content = s; };
    00079                 void addElement (ExCFileDataAction s) { content.push_back (s); }
    00080                 vector<ExCFileDataAction> getContent (void) { return content; };
    00081 };
    00082
    00083 class ExCFile {
    00084         protected:
    00085                 string filename;
    00086                 ios_base::openmode mode;
    00087         public:
    00088                 ExCFile () {};
    00089                 ExCFile (string s) { filename = s; };
    00090                 ExCFile (string s, int m) { filename = s, setOpenMode (m); };
    00091                 virtual ~ExCFile ();
    00092                 bool open (void);
    00093                 bool close (void);
    00094                 void setOpenMode (int);
    00095                 ios_base::openmode getOpenMode (int);
    00096
    00097                 void setFileName (string s) { filename = s; };
    00098                 std::string getFileName (void) { return filename; };
    00099
    00100                 bool exist (void);
    00101                 vector<std::string> getContent (void);
    00102                 bool add (std::string);
    00103                 bool addLine (void);
    00104 };
    00105
    00106 class ExCFileReader : public ExCFile {
    00107         private:
    00108                 ExCFileData *file_data;
    00109         public:
    00110                 ExCFileReader () : ExCFile () { file_data = new ExCFileData; };
    00111                 ExCFileReader (string);
    00112                 ExCFileData getContent (void);
    00113 };
    00114
    00115 class ExCFileWriter : public ExCFile {
    00116         public:
    00117                 ExCFileWriter () : ExCFile () {};
    00118                 ExCFileWriter (string);
    00119                 void setContent (ExCFileData);
    00120 };
    00121
    00122 #endif // __EXCFILE_H