diff base/EventSeries.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 c546429d4c2f
children
line wrap: on
line diff
--- a/base/EventSeries.h	Fri Apr 03 12:12:02 2020 +0100
+++ b/base/EventSeries.h	Fri Apr 03 17:11:05 2020 +0100
@@ -19,6 +19,8 @@
 #include "XmlExportable.h"
 
 #include <set>
+#include <string>
+#include <vector>
 #include <functional>
 
 #include <QMutex>
@@ -221,24 +223,24 @@
                Event::ExportNameOptions) const;
 
     /**
-     * Emit a label for each column that would be written by
-     * toDelimitedDataString, separated by the given delimiter.
+     * Return a label for each column that would be written by
+     * toStringExportRows.
      */
-    QString getDelimitedDataHeaderLine(QString delimiter,
-                                       DataExportOptions options,
-                                       Event::ExportNameOptions) const;
+    QVector<QString>
+    getStringExportHeaders(DataExportOptions options,
+                           Event::ExportNameOptions) const;
     
     /**
-     * Emit events starting within the given range to a delimited
-     * (e.g. comma-separated) data format.
+     * Emit events starting within the given range as string rows
+     * ready for conversion to an e.g. comma-separated data format.
      */
-    QString toDelimitedDataString(QString delimiter,
-                                  DataExportOptions options,
-                                  sv_frame_t startFrame,
-                                  sv_frame_t duration,
-                                  sv_samplerate_t sampleRate,
-                                  sv_frame_t resolution,
-                                  Event fillEvent) const;
+    QVector<QVector<QString>>
+    toStringExportRows(DataExportOptions options,
+                       sv_frame_t startFrame,
+                       sv_frame_t duration,
+                       sv_samplerate_t sampleRate,
+                       sv_frame_t resolution,
+                       Event fillEvent) const;
     
 private:
     mutable QMutex m_mutex;