00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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