CSVFileReader.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_CSV_FILE_READER_H
17 #define SV_CSV_FILE_READER_H
18 
19 #include "DataFileReader.h"
20 
21 #include "CSVFormat.h"
22 
23 #include "base/BaseTypes.h"
24 
25 #include <QList>
26 #include <QStringList>
27 #include <QIODevice>
28 
29 class QFile;
30 class ProgressReporter;
31 
33 {
34 public:
39  CSVFileReader(QString path, CSVFormat format,
40  sv_samplerate_t mainModelSampleRate,
41  ProgressReporter *reporter = 0);
42 
49  CSVFileReader(QIODevice *device, CSVFormat format,
50  sv_samplerate_t mainModelSampleRate,
51  ProgressReporter *reporter = 0);
52 
53  virtual ~CSVFileReader();
54 
55  bool isOK() const override;
56  QString getError() const override;
57 
58  Model *load() const override;
59 
60 protected:
62  QIODevice *m_device;
64  QString m_filename;
65  QString m_error;
66  mutable int m_warnings;
68  qint64 m_fileSize;
69  mutable qint64 m_readCount;
70  mutable int m_progress;
72 
73  bool convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate,
74  int windowSize, sv_frame_t &calculatedFrame) const;
75 
76  QString getConvertedAudioFilePath() const;
77 };
78 
79 
80 #endif
81 
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
QString getConvertedAudioFilePath() const
QString m_error
Definition: CSVFileReader.h:65
CSVFormat m_format
Definition: CSVFileReader.h:61
qint64 m_readCount
Definition: CSVFileReader.h:69
QString m_filename
Definition: CSVFileReader.h:64
CSVFileReader(QString path, CSVFormat format, sv_samplerate_t mainModelSampleRate, ProgressReporter *reporter=0)
Construct a CSVFileReader to read the CSV file at the given path, with the given format.
qint64 m_fileSize
Definition: CSVFileReader.h:68
ProgressReporter * m_reporter
Definition: CSVFileReader.h:71
bool isOK() const override
Return true if the file appears to be of the correct type.
sv_samplerate_t m_mainModelSampleRate
Definition: CSVFileReader.h:67
Model is the base class for all data models that represent any sort of data on a time scale based on ...
Definition: Model.h:51
bool convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate, int windowSize, sv_frame_t &calculatedFrame) const
Model * load() const override
Read the file and return the corresponding data model.
QIODevice * m_device
Definition: CSVFileReader.h:62
QString getError() const override
virtual ~CSVFileReader()