00001
00002
00003
00004
00005
00006
00007 #include <FBwField.h>
00008 #include <FBwFieldList.h>
00009 #include <fstream>
00010
00011 namespace fbwrap
00012 {
00013
00015
00024 class CSVInStream
00025 {
00026 std::istream &is;
00027 char sep;
00028 char LiteralFlag;
00029 int ErrCode;
00030 protected:
00031 int nRecs;
00032
00033
00037 bool ReadField(string &s);
00039 void ReadRecord();
00041 bool CheckLineEnd(char c);
00043
00045
00046 void setError(int n);
00047 public:
00049
00055
00057
00059
00061
00063
00065
00068
00069 {
00070 return Fields.Count();
00071 }
00072 enum errorCodes {e_no_error,e_cant_open,e_not_opened };
00073 };
00074
00076 class CSVInFile : public CSVInStream
00077 {
00078 std::ifstream ifs;
00079 public:
00085 CSVInFile(string filename,char sep=';', char Flag='"'):
00086 CSVInStream(ifs,sep,Flag)
00087 {
00088 ifs.open(filename.c_str());
00089 }
00090
00091 };
00092
00093
00094 }
00095
00096