diff 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
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.h	Fri Nov 14 13:51:33 2014 +0000
+++ b/data/fileio/CSVFileReader.h	Fri Nov 14 17:23:27 2014 +0000
@@ -28,16 +28,31 @@
 class CSVFileReader : public DataFileReader
 {
 public:
+    /**
+     * Construct a CSVFileReader to read the CSV file at the given
+     * path, with the given format.
+     */
     CSVFileReader(QString path, CSVFormat format, int mainModelSampleRate);
+
+    /**
+     * Construct a CSVFileReader to read from the given
+     * QIODevice. Caller retains ownership of the QIODevice: the
+     * CSVFileReader will not close or delete it and it must outlive
+     * the CSVFileReader.
+     */
+    CSVFileReader(QIODevice *device, CSVFormat format, int mainModelSampleRate);
+
     virtual ~CSVFileReader();
 
     virtual bool isOK() const;
     virtual QString getError() const;
+
     virtual Model *load() const;
 
 protected:
     CSVFormat m_format;
-    QFile *m_file;
+    QIODevice *m_device;
+    bool m_ownDevice;
     QString m_error;
     mutable int m_warnings;
     int m_mainModelSampleRate;