00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __FFI_H
00035 #define __FFI_H
00036
00037 #include <stdlib.h>
00038 #include <ctype.h>
00039
00040 #include <iostream>
00041 using std::cout;
00042 using std::cin;
00043 using std::cerr;
00044 using std::ostream;
00045 using std::endl;
00046
00047 #include <fstream>
00048 using std::ifstream;
00049 using std::istringstream;
00050
00051 #include <iomanip>
00052 using std::setw;
00053 using std::ios;
00054 using std::setprecision;
00055
00056 #include <string>
00057 using std::string;
00058
00059 #include "OFELI_Config.h"
00060 #include "util.h"
00061 #include "fparser.h"
00062
00063 namespace OFELI {
00064
00086 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00087 #define LENGTH_CMD 30
00088 #define LINE_LENGTH 120
00089 #define NB_CMD 12
00090 #define FFI_ASCII 0
00091 #define FFI_BINARY 1
00092
00093 int _is_number(const string &);
00094 #endif
00095
00096 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00097 struct ErrorInFFI {
00098 int Message(const char *file, size_t line, int code, const string &p1=" ", const string &p2=" ");
00099 };
00100 #endif
00101
00102
00103 class FFI
00104 {
00105
00106 public:
00107
00109 FFI();
00110
00113 FFI(const string &file);
00114
00119 FFI(const string &file, const string &ident);
00120
00122 FFI(const FFI &ff);
00123
00125 ~FFI();
00126
00129 void open(const string &file);
00130
00135 void open(const string &file, const string &ident);
00136
00137 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00138 void open(const string &file, const string &ident, int c);
00139 void Open(const string &file) { open(file); }
00140 void Open(const string &file, const string &ident) { open(file,ident); }
00141 void Open(const string &file, const string &ident, int c) { open(file,ident,c); }
00142 #endif
00143
00145 void Close(void) { _is->close(); }
00146
00149 int getI(const string &msg="0");
00150
00153 double getD(const string &msg="0");
00154
00157 void setKeywords(const valarray<string> &s);
00158
00161 int getKW(const string &msg="0");
00162
00165 string getS(const string &msg="0");
00166
00169 string getE(const string &msg="0");
00170
00173 FFI & operator=(const FFI &ff);
00174
00176 string getIdent() const { return _ident; }
00177
00178 private:
00179
00180 size_t _msg, _string_nb;
00181 string _input_file, _token, _ident;
00182 char _buffer[121];
00183 ErrorInFFI _e;
00184 bool _in, _non_fatal, _comment, _eol;
00185 valarray<string> _kw;
00186 ifstream *_is;
00187 istringstream *_iss;
00188
00189 int get_token();
00190 };
00191
00192 }
00193
00194 #endif