Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
1578:07f23b90701a | 1585:9570ef94eaa3 |
---|---|
16 #ifndef SV_CSV_FORMAT_H | 16 #ifndef SV_CSV_FORMAT_H |
17 #define SV_CSV_FORMAT_H | 17 #define SV_CSV_FORMAT_H |
18 | 18 |
19 #include <QString> | 19 #include <QString> |
20 #include <QStringList> | 20 #include <QStringList> |
21 | |
22 #include <set> | |
21 | 23 |
22 #include "base/BaseTypes.h" | 24 #include "base/BaseTypes.h" |
23 | 25 |
24 class CSVFormat | 26 class CSVFormat |
25 { | 27 { |
75 | 77 |
76 CSVFormat() : // arbitrary defaults | 78 CSVFormat() : // arbitrary defaults |
77 m_modelType(TwoDimensionalModel), | 79 m_modelType(TwoDimensionalModel), |
78 m_timingType(ExplicitTiming), | 80 m_timingType(ExplicitTiming), |
79 m_timeUnits(TimeSeconds), | 81 m_timeUnits(TimeSeconds), |
80 m_separator(","), | 82 m_separator(""), |
81 m_sampleRate(44100), | 83 m_sampleRate(44100), |
82 m_windowSize(1024), | 84 m_windowSize(1024), |
83 m_columnCount(0), | 85 m_columnCount(0), |
84 m_variableColumnCount(false), | 86 m_variableColumnCount(false), |
85 m_audioSampleRange(SampleRangeOther), | 87 m_audioSampleRange(SampleRangeOther), |
118 int getWindowSize() const { return m_windowSize; } | 120 int getWindowSize() const { return m_windowSize; } |
119 int getColumnCount() const { return m_columnCount; } | 121 int getColumnCount() const { return m_columnCount; } |
120 AudioSampleRange getAudioSampleRange() const { return m_audioSampleRange; } | 122 AudioSampleRange getAudioSampleRange() const { return m_audioSampleRange; } |
121 bool getAllowQuoting() const { return m_allowQuoting; } | 123 bool getAllowQuoting() const { return m_allowQuoting; } |
122 QChar getSeparator() const { | 124 QChar getSeparator() const { |
123 if (m_separator == "") return ' '; | 125 if (m_separator == "") return ','; |
124 else return m_separator[0]; | 126 else return m_separator[0]; |
127 } | |
128 // set rather than QSet to ensure a fixed order | |
129 std::set<QChar> getPlausibleSeparators() const { | |
130 return m_plausibleSeparators; | |
125 } | 131 } |
126 | 132 |
127 void setModelType(ModelType t) { m_modelType = t; } | 133 void setModelType(ModelType t) { m_modelType = t; } |
128 void setTimingType(TimingType t) { m_timingType = t; } | 134 void setTimingType(TimingType t) { m_timingType = t; } |
129 void setTimeUnits(TimeUnits t) { m_timeUnits = t; } | 135 void setTimeUnits(TimeUnits t) { m_timeUnits = t; } |
155 | 161 |
156 protected: | 162 protected: |
157 ModelType m_modelType; | 163 ModelType m_modelType; |
158 TimingType m_timingType; | 164 TimingType m_timingType; |
159 TimeUnits m_timeUnits; | 165 TimeUnits m_timeUnits; |
160 QString m_separator; | 166 QString m_separator; // "" or a single char - basically QChar option |
167 std::set<QChar> m_plausibleSeparators; | |
161 sv_samplerate_t m_sampleRate; | 168 sv_samplerate_t m_sampleRate; |
162 int m_windowSize; | 169 int m_windowSize; |
163 | 170 |
164 int m_columnCount; | 171 int m_columnCount; |
165 bool m_variableColumnCount; | 172 bool m_variableColumnCount; |