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 Chris@148: #include Chris@1116: #include Chris@148: Chris@148: class QFile; Chris@1491: class ProgressReporter; 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@1488: CSVFileReader(QString path, CSVFormat format, Chris@1491: sv_samplerate_t mainModelSampleRate, Chris@1491: ProgressReporter *reporter = 0); 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@1488: CSVFileReader(QIODevice *device, CSVFormat format, Chris@1491: sv_samplerate_t mainModelSampleRate, Chris@1491: ProgressReporter *reporter = 0); Chris@1009: Chris@148: virtual ~CSVFileReader(); Chris@148: Chris@1580: bool isOK() const override; Chris@1580: QString getError() const override; Chris@1009: Chris@1580: Model *load() const override; 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@1491: qint64 m_fileSize; Chris@1491: mutable qint64 m_readCount; Chris@1491: mutable int m_progress; Chris@1491: ProgressReporter *m_reporter; Chris@631: Chris@1047: sv_frame_t convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate, Chris@1038: int windowSize) const; Chris@1519: Chris@1519: QString getConvertedAudioFilePath() const; Chris@148: }; Chris@148: Chris@148: Chris@148: #endif Chris@148: