diff base/Event.h @ 1833:21c792334c2e sensible-delimited-data-strings

Rewrite all the DelimitedDataString stuff so as to return vectors of individual cell strings rather than having the classes add the delimiters themselves. Rename accordingly to names based on StringExport. Take advantage of this in the CSV writer code so as to properly quote cells that contain delimiter characters.
author Chris Cannam
date Fri, 03 Apr 2020 17:11:05 +0100
parents fd5a87f3c5b4
children b4b11af915f4
line wrap: on
line diff
--- a/base/Event.h	Fri Apr 03 12:12:02 2020 +0100
+++ b/base/Event.h	Fri Apr 03 17:11:05 2020 +0100
@@ -366,9 +366,9 @@
         return n;
     }
 
-    QString getDelimitedDataHeaderLine(QString delimiter,
-                                       DataExportOptions opts,
-                                       ExportNameOptions nameOpts) const {
+    QVector<QString>
+    getStringExportHeaders(DataExportOptions opts,
+                           ExportNameOptions nameOpts) const {
 
         QStringList list;
 
@@ -400,13 +400,18 @@
         }
         
         list << "label";
+
+        QVector<QString> sv;
+        for (QString s: list) {
+            sv.push_back(s.toUpper());
+        }
+        return sv;
+    }
+
+    QVector<QString>
+    toStringExportRow(DataExportOptions opts,
+                      sv_samplerate_t sampleRate) const {
         
-        return list.join(delimiter).toUpper();
-    }
-    
-    QString toDelimitedDataString(QString delimiter,
-                                  DataExportOptions opts,
-                                  sv_samplerate_t sampleRate) const {
         QStringList list;
 
         if (opts & DataExportWriteTimeInFrames) {
@@ -441,8 +446,8 @@
         // facility for the user to customise it
         if (m_uri != "") list << m_uri;
         if (m_label != "") list << m_label;
-        
-        return list.join(delimiter);
+
+        return list.toVector();
     }
     
     uint hash(uint seed = 0) const {