annotate data/fileio/CSVFileReader.h @ 1030:920699b6989d

Use filename as object name when reading data file to model (so it shows in the resulting layer name)
author Chris Cannam
date Fri, 13 Feb 2015 13:30:28 +0000
parents e369dd281cf2
children cc27f35aa75c
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@148 23 #include <QList>
Chris@148 24 #include <QStringList>
Chris@148 25
Chris@148 26 class QFile;
Chris@148 27
Chris@148 28 class CSVFileReader : public DataFileReader
Chris@148 29 {
Chris@148 30 public:
Chris@1009 31 /**
Chris@1009 32 * Construct a CSVFileReader to read the CSV file at the given
Chris@1009 33 * path, with the given format.
Chris@1009 34 */
Chris@929 35 CSVFileReader(QString path, CSVFormat format, int mainModelSampleRate);
Chris@1009 36
Chris@1009 37 /**
Chris@1009 38 * Construct a CSVFileReader to read from the given
Chris@1009 39 * QIODevice. Caller retains ownership of the QIODevice: the
Chris@1009 40 * CSVFileReader will not close or delete it and it must outlive
Chris@1009 41 * the CSVFileReader.
Chris@1009 42 */
Chris@1009 43 CSVFileReader(QIODevice *device, CSVFormat format, int mainModelSampleRate);
Chris@1009 44
Chris@148 45 virtual ~CSVFileReader();
Chris@148 46
Chris@148 47 virtual bool isOK() const;
Chris@148 48 virtual QString getError() const;
Chris@1009 49
Chris@148 50 virtual Model *load() const;
Chris@148 51
Chris@148 52 protected:
Chris@392 53 CSVFormat m_format;
Chris@1009 54 QIODevice *m_device;
Chris@1009 55 bool m_ownDevice;
Chris@1030 56 QString m_filename;
Chris@148 57 QString m_error;
Chris@631 58 mutable int m_warnings;
Chris@929 59 int m_mainModelSampleRate;
Chris@631 60
Chris@929 61 int convertTimeValue(QString, int lineno, int sampleRate,
Chris@929 62 int windowSize) const;
Chris@148 63 };
Chris@148 64
Chris@148 65
Chris@148 66 #endif
Chris@148 67