diff data/fileio/CSVFormat.h @ 631:3a5ee4b6c9ad

* Complete the overhaul of CSV file import; now you can pick the purpose for each column in the file, and SV should do the rest. The most significant practical improvement here is that we can now handle files in which time and duration do not necessarily appear in known columns.
author Chris Cannam
date Mon, 19 Jul 2010 17:08:56 +0000
parents 11a664058dd8
children 69cc0454ed72
line wrap: on
line diff
--- a/data/fileio/CSVFormat.h	Fri Jul 16 16:51:39 2010 +0000
+++ b/data/fileio/CSVFormat.h	Mon Jul 19 17:08:56 2010 +0000
@@ -34,11 +34,6 @@
 	ImplicitTiming
     };
 
-    enum DurationType {
-        Durations,
-        EndTimes
-    };
-    
     enum TimeUnits {
 	TimeSeconds,
 	TimeAudioFrames,
@@ -65,14 +60,12 @@
     CSVFormat() : // arbitrary defaults
         m_modelType(TwoDimensionalModel),
         m_timingType(ExplicitTiming),
-        m_durationType(Durations),
         m_timeUnits(TimeSeconds),
         m_separator(","),
         m_sampleRate(44100),
         m_windowSize(1024),
         m_columnCount(0),
         m_variableColumnCount(false),
-        m_behaviour(QString::KeepEmptyParts),
         m_allowQuoting(true),
         m_maxExampleCols(0)
     { }
@@ -90,43 +83,42 @@
  
     ModelType    getModelType()     const { return m_modelType;     }
     TimingType   getTimingType()    const { return m_timingType;    }
-    DurationType getDurationType()  const { return m_durationType;  }
     TimeUnits    getTimeUnits()     const { return m_timeUnits;     }
-    QString      getSeparator()     const { return m_separator;     }
     size_t       getSampleRate()    const { return m_sampleRate;    }
     size_t       getWindowSize()    const { return m_windowSize;    }
     int          getColumnCount()   const { return m_columnCount;   }
-    
-    QString::SplitBehavior getSplitBehaviour() const { return m_behaviour; }
-    QList<ColumnPurpose> getColumnPurposes() const { return m_columnPurposes; }
+    bool         getAllowQuoting()  const { return m_allowQuoting;  }
+    QChar        getSeparator()     const { 
+        if (m_separator == "") return ' ';
+        else return m_separator[0];
+    }
 
-    ColumnPurpose getColumnPurpose(int i) { return m_columnPurposes[i]; }
-	
     void setModelType(ModelType t)        { m_modelType    = t; }
     void setTimingType(TimingType t)      { m_timingType   = t; }
-    void setDurationType(DurationType t)  { m_durationType = t; }
     void setTimeUnits(TimeUnits t)        { m_timeUnits    = t; }
-    void setSeparator(QString s)          { m_separator    = s; }
+    void setSeparator(QChar s)            { m_separator    = s; }
     void setSampleRate(size_t r)          { m_sampleRate   = r; }
     void setWindowSize(size_t s)          { m_windowSize   = s; }
     void setColumnCount(int c)            { m_columnCount  = c; }
+    void setAllowQuoting(bool q)          { m_allowQuoting = q; }
 
-    void setSplitBehaviour(QString::SplitBehavior b) { m_behaviour = b; }
+    QList<ColumnPurpose> getColumnPurposes() const { return m_columnPurposes; }
     void setColumnPurposes(QList<ColumnPurpose> cl) { m_columnPurposes = cl; }
+
+    ColumnPurpose getColumnPurpose(int i);
+    ColumnPurpose getColumnPurpose(int i) const;
+    void setColumnPurpose(int i, ColumnPurpose p);
     
-    void setColumnPurpose(int i, ColumnPurpose p) { m_columnPurposes[i] = p; }
-
     // read-only; only valid if format has been guessed:
     QList<ColumnQualities> getColumnQualities() const { return m_columnQualities; }
 
     // read-only; only valid if format has been guessed:
     QList<QStringList> getExample() const { return m_example; }
     int getMaxExampleCols() const { return m_maxExampleCols; }
-
+	
 protected:
     ModelType    m_modelType;
     TimingType   m_timingType;
-    DurationType m_durationType;
     TimeUnits    m_timeUnits;
     QString      m_separator;
     size_t       m_sampleRate;
@@ -140,7 +132,6 @@
 
     QList<float> m_prevValues;
 
-    QString::SplitBehavior m_behaviour;
     bool m_allowQuoting;
 
     QList<QStringList> m_example;