Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
1832:7c92c644db20 | 1833:21c792334c2e |
---|---|
364 } | 364 } |
365 | 365 |
366 return n; | 366 return n; |
367 } | 367 } |
368 | 368 |
369 QString getDelimitedDataHeaderLine(QString delimiter, | 369 QVector<QString> |
370 DataExportOptions opts, | 370 getStringExportHeaders(DataExportOptions opts, |
371 ExportNameOptions nameOpts) const { | 371 ExportNameOptions nameOpts) const { |
372 | 372 |
373 QStringList list; | 373 QStringList list; |
374 | 374 |
375 // These are considered API rather than human-readable text - | 375 // These are considered API rather than human-readable text - |
376 // they shouldn't be translated | 376 // they shouldn't be translated |
398 if (m_uri != "") { | 398 if (m_uri != "") { |
399 list << nameOpts.uriAttributeName; | 399 list << nameOpts.uriAttributeName; |
400 } | 400 } |
401 | 401 |
402 list << "label"; | 402 list << "label"; |
403 | 403 |
404 return list.join(delimiter).toUpper(); | 404 QVector<QString> sv; |
405 } | 405 for (QString s: list) { |
406 | 406 sv.push_back(s.toUpper()); |
407 QString toDelimitedDataString(QString delimiter, | 407 } |
408 DataExportOptions opts, | 408 return sv; |
409 sv_samplerate_t sampleRate) const { | 409 } |
410 | |
411 QVector<QString> | |
412 toStringExportRow(DataExportOptions opts, | |
413 sv_samplerate_t sampleRate) const { | |
414 | |
410 QStringList list; | 415 QStringList list; |
411 | 416 |
412 if (opts & DataExportWriteTimeInFrames) { | 417 if (opts & DataExportWriteTimeInFrames) { |
413 list << QString("%1").arg(m_frame); | 418 list << QString("%1").arg(m_frame); |
414 } else { | 419 } else { |
439 // used in the custom Image model exporter. We shouldn't | 444 // used in the custom Image model exporter. We shouldn't |
440 // change the column ordering unless (until?) we provide a | 445 // change the column ordering unless (until?) we provide a |
441 // facility for the user to customise it | 446 // facility for the user to customise it |
442 if (m_uri != "") list << m_uri; | 447 if (m_uri != "") list << m_uri; |
443 if (m_label != "") list << m_label; | 448 if (m_label != "") list << m_label; |
444 | 449 |
445 return list.join(delimiter); | 450 return list.toVector(); |
446 } | 451 } |
447 | 452 |
448 uint hash(uint seed = 0) const { | 453 uint hash(uint seed = 0) const { |
449 uint h = qHash(m_label, seed); | 454 uint h = qHash(m_label, seed); |
450 if (m_haveValue) h ^= qHash(m_value); | 455 if (m_haveValue) h ^= qHash(m_value); |