Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

rtkinputcsv.h

00001 /*<<<<<COPYRIGHT*/
00002 /*
00003  * RTK The report toolkit
00004  * Copyright (C) 2003 Francisco Santiago Capel Torres
00005 
00006  * rtkinputcsv.h RTK standard csv input object
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  */
00019 /*>>>>>COPYRIGHT*/
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 /*<<<<<INPUTCSV_CONSTRUCTOR*/
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 /*>>>>>INPUTCSV_CONSTRUCTOR*/
00045                         , pFile( 0 )
00046         {};
00047         ~InputCsv();
00048 
00049 /*<<<<<INPUTCSV_GETSET*/
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 /*>>>>>INPUTCSV_GETSET*/
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 }; // namespace
00089 
00090 #endif
00091 
00092 

Generated on Tue Feb 22 14:44:37 2005 for RTK. Report ToolKit by  doxygen 1.3.9.1