comparison data/fileio/CSVFileReader.h @ 1009:e369dd281cf2

Provide reader from QIODevice
author Chris Cannam
date Fri, 14 Nov 2014 17:23:27 +0000
parents 59e7fe1b1003
children 920699b6989d
comparison
equal deleted inserted replaced
1008:d9e0e59a1581 1009:e369dd281cf2
26 class QFile; 26 class QFile;
27 27
28 class CSVFileReader : public DataFileReader 28 class CSVFileReader : public DataFileReader
29 { 29 {
30 public: 30 public:
31 /**
32 * Construct a CSVFileReader to read the CSV file at the given
33 * path, with the given format.
34 */
31 CSVFileReader(QString path, CSVFormat format, int mainModelSampleRate); 35 CSVFileReader(QString path, CSVFormat format, int mainModelSampleRate);
36
37 /**
38 * Construct a CSVFileReader to read from the given
39 * QIODevice. Caller retains ownership of the QIODevice: the
40 * CSVFileReader will not close or delete it and it must outlive
41 * the CSVFileReader.
42 */
43 CSVFileReader(QIODevice *device, CSVFormat format, int mainModelSampleRate);
44
32 virtual ~CSVFileReader(); 45 virtual ~CSVFileReader();
33 46
34 virtual bool isOK() const; 47 virtual bool isOK() const;
35 virtual QString getError() const; 48 virtual QString getError() const;
49
36 virtual Model *load() const; 50 virtual Model *load() const;
37 51
38 protected: 52 protected:
39 CSVFormat m_format; 53 CSVFormat m_format;
40 QFile *m_file; 54 QIODevice *m_device;
55 bool m_ownDevice;
41 QString m_error; 56 QString m_error;
42 mutable int m_warnings; 57 mutable int m_warnings;
43 int m_mainModelSampleRate; 58 int m_mainModelSampleRate;
44 59
45 int convertTimeValue(QString, int lineno, int sampleRate, 60 int convertTimeValue(QString, int lineno, int sampleRate,