Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CsvDrv.h

00001 /*
00002  * \file CsvDrv.h
00003  *
00004  * Handling of csv files
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);      // may need unget for more than 1 char eol
00043     void ClearRecord();
00045     string FieldName(int n);
00046     void setError(int n);
00047 public:
00049     //
00055     CSVInStream(std::istream &p_is, char psep, char lFlag);
00057     virtual void First();
00059     virtual void Next();
00061     bool Eof();
00063     FieldList Fields;
00065     //
00068     int FieldCount()
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 // namespace ends
00094 }
00095 
00096 

Generated on Fri Jan 31 08:30:00 2003 for fbwrap by doxygen1.2.17