Chris@148: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@148: 
Chris@148: /*
Chris@148:     Sonic Visualiser
Chris@148:     An audio file viewer and annotation editor.
Chris@148:     Centre for Digital Music, Queen Mary, University of London.
Chris@148:     This file copyright 2006 Chris Cannam.
Chris@148:     
Chris@148:     This program is free software; you can redistribute it and/or
Chris@148:     modify it under the terms of the GNU General Public License as
Chris@148:     published by the Free Software Foundation; either version 2 of the
Chris@148:     License, or (at your option) any later version.  See the file
Chris@148:     COPYING included with this distribution for more information.
Chris@148: */
Chris@148: 
Chris@1362: #ifndef SV_CSV_FILE_READER_H
Chris@1362: #define SV_CSV_FILE_READER_H
Chris@148: 
Chris@148: #include "DataFileReader.h"
Chris@148: 
Chris@392: #include "CSVFormat.h"
Chris@392: 
Chris@1038: #include "base/BaseTypes.h"
Chris@1038: 
Chris@148: #include <QList>
Chris@148: #include <QStringList>
Chris@1116: #include <QIODevice>
Chris@148: 
Chris@148: class QFile;
Chris@148: 
Chris@148: class CSVFileReader : public DataFileReader
Chris@148: {
Chris@148: public:
Chris@1009:     /**
Chris@1009:      * Construct a CSVFileReader to read the CSV file at the given
Chris@1009:      * path, with the given format.
Chris@1009:      */
Chris@1047:     CSVFileReader(QString path, CSVFormat format, sv_samplerate_t mainModelSampleRate);
Chris@1009: 
Chris@1009:     /**
Chris@1009:      * Construct a CSVFileReader to read from the given
Chris@1009:      * QIODevice. Caller retains ownership of the QIODevice: the
Chris@1009:      * CSVFileReader will not close or delete it and it must outlive
Chris@1009:      * the CSVFileReader.
Chris@1009:      */
Chris@1047:     CSVFileReader(QIODevice *device, CSVFormat format, sv_samplerate_t mainModelSampleRate);
Chris@1009: 
Chris@148:     virtual ~CSVFileReader();
Chris@148: 
Chris@148:     virtual bool isOK() const;
Chris@148:     virtual QString getError() const;
Chris@1009: 
Chris@148:     virtual Model *load() const;
Chris@148: 
Chris@148: protected:
Chris@392:     CSVFormat m_format;
Chris@1009:     QIODevice *m_device;
Chris@1009:     bool m_ownDevice;
Chris@1030:     QString m_filename;
Chris@148:     QString m_error;
Chris@631:     mutable int m_warnings;
Chris@1047:     sv_samplerate_t m_mainModelSampleRate;
Chris@631: 
Chris@1047:     sv_frame_t convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate,
Chris@1038:                                 int windowSize) const;
Chris@148: };
Chris@148: 
Chris@148: 
Chris@148: #endif
Chris@148: