diff data/fileio/CSVFormat.h @ 1585:9570ef94eaa3

Add mechanism to retrieve the set of plausible separators found in CSV-like file when guessing its format
author Chris Cannam
date Wed, 09 Jan 2019 14:39:50 +0000
parents 64ef24ebb19c
children f0ffc88a36b3
line wrap: on
line diff
--- a/data/fileio/CSVFormat.h	Wed Nov 14 15:46:35 2018 +0000
+++ b/data/fileio/CSVFormat.h	Wed Jan 09 14:39:50 2019 +0000
@@ -19,6 +19,8 @@
 #include <QString>
 #include <QStringList>
 
+#include <set>
+
 #include "base/BaseTypes.h"
 
 class CSVFormat
@@ -77,7 +79,7 @@
         m_modelType(TwoDimensionalModel),
         m_timingType(ExplicitTiming),
         m_timeUnits(TimeSeconds),
-        m_separator(","),
+        m_separator(""),
         m_sampleRate(44100),
         m_windowSize(1024),
         m_columnCount(0),
@@ -120,9 +122,13 @@
     AudioSampleRange getAudioSampleRange() const { return m_audioSampleRange; }
     bool         getAllowQuoting()  const { return m_allowQuoting;  }
     QChar        getSeparator()     const { 
-        if (m_separator == "") return ' ';
+        if (m_separator == "") return ',';
         else return m_separator[0];
     }
+    // set rather than QSet to ensure a fixed order
+    std::set<QChar> getPlausibleSeparators() const {
+        return m_plausibleSeparators;
+    }
 
     void setModelType(ModelType t)        { m_modelType    = t; }
     void setTimingType(TimingType t)      { m_timingType   = t; }
@@ -157,7 +163,8 @@
     ModelType    m_modelType;
     TimingType   m_timingType;
     TimeUnits    m_timeUnits;
-    QString      m_separator;
+    QString      m_separator; // "" or a single char - basically QChar option
+    std::set<QChar> m_plausibleSeparators;
     sv_samplerate_t m_sampleRate;
     int          m_windowSize;