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@1362
|
16 #ifndef SV_CSV_FILE_READER_H
|
Chris@1362
|
17 #define SV_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@1116
|
27 #include <QIODevice>
|
Chris@148
|
28
|
Chris@148
|
29 class QFile;
|
Chris@1491
|
30 class ProgressReporter;
|
Chris@148
|
31
|
Chris@148
|
32 class CSVFileReader : public DataFileReader
|
Chris@148
|
33 {
|
Chris@148
|
34 public:
|
Chris@1009
|
35 /**
|
Chris@1009
|
36 * Construct a CSVFileReader to read the CSV file at the given
|
Chris@1009
|
37 * path, with the given format.
|
Chris@1009
|
38 */
|
Chris@1488
|
39 CSVFileReader(QString path, CSVFormat format,
|
Chris@1491
|
40 sv_samplerate_t mainModelSampleRate,
|
Chris@1491
|
41 ProgressReporter *reporter = 0);
|
Chris@1009
|
42
|
Chris@1009
|
43 /**
|
Chris@1009
|
44 * Construct a CSVFileReader to read from the given
|
Chris@1009
|
45 * QIODevice. Caller retains ownership of the QIODevice: the
|
Chris@1009
|
46 * CSVFileReader will not close or delete it and it must outlive
|
Chris@1009
|
47 * the CSVFileReader.
|
Chris@1009
|
48 */
|
Chris@1488
|
49 CSVFileReader(QIODevice *device, CSVFormat format,
|
Chris@1491
|
50 sv_samplerate_t mainModelSampleRate,
|
Chris@1491
|
51 ProgressReporter *reporter = 0);
|
Chris@1009
|
52
|
Chris@148
|
53 virtual ~CSVFileReader();
|
Chris@148
|
54
|
Chris@148
|
55 virtual bool isOK() const;
|
Chris@148
|
56 virtual QString getError() const;
|
Chris@1009
|
57
|
Chris@148
|
58 virtual Model *load() const;
|
Chris@148
|
59
|
Chris@148
|
60 protected:
|
Chris@392
|
61 CSVFormat m_format;
|
Chris@1009
|
62 QIODevice *m_device;
|
Chris@1009
|
63 bool m_ownDevice;
|
Chris@1030
|
64 QString m_filename;
|
Chris@148
|
65 QString m_error;
|
Chris@631
|
66 mutable int m_warnings;
|
Chris@1047
|
67 sv_samplerate_t m_mainModelSampleRate;
|
Chris@1491
|
68 qint64 m_fileSize;
|
Chris@1491
|
69 mutable qint64 m_readCount;
|
Chris@1491
|
70 mutable int m_progress;
|
Chris@1491
|
71 ProgressReporter *m_reporter;
|
Chris@631
|
72
|
Chris@1047
|
73 sv_frame_t convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate,
|
Chris@1038
|
74 int windowSize) const;
|
Chris@1519
|
75
|
Chris@1519
|
76 QString getConvertedAudioFilePath() const;
|
Chris@148
|
77 };
|
Chris@148
|
78
|
Chris@148
|
79
|
Chris@148
|
80 #endif
|
Chris@148
|
81
|