00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef INPUTCSV_H
00021 #define INPUTCSV_H
00022
00023 class QFile;
00024
00025 #include "rtkinput.h"
00026
00031 namespace RTK
00032 {
00033
00034 class InputCsv : public Input
00035 {
00036
00037 public:
00038 InputCsv(const String& filename = String::null, const String& delimiters = ",",
00039 const String& quote = "\"", int headerlines = 1,
00040 const String& name = String::null, const String& driver = String::null)
00041 :Input(name, driver),
00042 mFilename(filename), mDelimiters(delimiters),
00043 mQuote(quote), mHeaderLines(headerlines)
00044
00045 , pFile( 0 )
00046 {};
00047 ~InputCsv();
00048
00049
00050 public:
00052 const String& getFilename() const { return mFilename; };
00054 void setFilename(const String& filename) { mFilename = filename; };
00056 const String& getDelimiters() const { return mDelimiters; };
00058 void setDelimiters(const String& delimiters) { mDelimiters = delimiters; };
00060 const String& getQuote() const { return mQuote; };
00062 void setQuote(const String& quote) { mQuote = quote; };
00064 int getHeaderLines() const { return mHeaderLines; };
00066 void setHeaderLines(int headerlines) { mHeaderLines = headerlines; };
00067 protected:
00068 String mFilename;
00069 String mDelimiters;
00070 String mQuote;
00071 int mHeaderLines;
00072
00073
00074 public:
00075 bool init();
00076 bool next();
00077 int fieldPos( const String &name ) const;
00078 Variant getValue(const String &fldname);
00079
00080 private:
00081 QFile *pFile;
00082 QTextStream *pTextStream;
00083 QValueList<QString> mRowValues;
00084 Variant correctType(Variant::Type t, const String &value);
00085
00086 };
00087
00088 };
00089
00090 #endif
00091
00092