annotate data/fileio/CSVFileReader.h @ 1061:c1e43c8d2527 tonioni

Thread-local debug was causing crash on exit with Qt 5.4.x. But we introduced that because QDebug itself was crashing when used from multiple threads. Replace with simpler fstream version
author Chris Cannam
date Tue, 31 Mar 2015 10:36:52 +0100
parents 26cf6d5251ec
children 7f8eb7379280 e22bfe8ca248
rev   line source
Chris@148 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@148 2
Chris@148 3 /*
Chris@148 4 Sonic Visualiser
Chris@148 5 An audio file viewer and annotation editor.
Chris@148 6 Centre for Digital Music, Queen Mary, University of London.
Chris@148 7 This file copyright 2006 Chris Cannam.
Chris@148 8
Chris@148 9 This program is free software; you can redistribute it and/or
Chris@148 10 modify it under the terms of the GNU General Public License as
Chris@148 11 published by the Free Software Foundation; either version 2 of the
Chris@148 12 License, or (at your option) any later version. See the file
Chris@148 13 COPYING included with this distribution for more information.
Chris@148 14 */
Chris@148 15
Chris@148 16 #ifndef _CSV_FILE_READER_H_
Chris@148 17 #define _CSV_FILE_READER_H_
Chris@148 18
Chris@148 19 #include "DataFileReader.h"
Chris@148 20
Chris@392 21 #include "CSVFormat.h"
Chris@392 22
Chris@1038 23 #include "base/BaseTypes.h"
Chris@1038 24
Chris@148 25 #include <QList>
Chris@148 26 #include <QStringList>
Chris@148 27
Chris@148 28 class QFile;
Chris@148 29
Chris@148 30 class CSVFileReader : public DataFileReader
Chris@148 31 {
Chris@148 32 public:
Chris@1009 33 /**
Chris@1009 34 * Construct a CSVFileReader to read the CSV file at the given
Chris@1009 35 * path, with the given format.
Chris@1009 36 */
Chris@1047 37 CSVFileReader(QString path, CSVFormat format, sv_samplerate_t mainModelSampleRate);
Chris@1009 38
Chris@1009 39 /**
Chris@1009 40 * Construct a CSVFileReader to read from the given
Chris@1009 41 * QIODevice. Caller retains ownership of the QIODevice: the
Chris@1009 42 * CSVFileReader will not close or delete it and it must outlive
Chris@1009 43 * the CSVFileReader.
Chris@1009 44 */
Chris@1047 45 CSVFileReader(QIODevice *device, CSVFormat format, sv_samplerate_t mainModelSampleRate);
Chris@1009 46
Chris@148 47 virtual ~CSVFileReader();
Chris@148 48
Chris@148 49 virtual bool isOK() const;
Chris@148 50 virtual QString getError() const;
Chris@1009 51
Chris@148 52 virtual Model *load() const;
Chris@148 53
Chris@148 54 protected:
Chris@392 55 CSVFormat m_format;
Chris@1009 56 QIODevice *m_device;
Chris@1009 57 bool m_ownDevice;
Chris@1030 58 QString m_filename;
Chris@148 59 QString m_error;
Chris@631 60 mutable int m_warnings;
Chris@1047 61 sv_samplerate_t m_mainModelSampleRate;
Chris@631 62
Chris@1047 63 sv_frame_t convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate,
Chris@1038 64 int windowSize) const;
Chris@148 65 };
Chris@148 66
Chris@148 67
Chris@148 68 #endif
Chris@148 69