Mercurial > hg > svcore
comparison data/model/BasicCompressedDenseThreeDimensionalModel.cpp @ 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 |
comparison
equal
deleted
inserted
replaced
1832:7c92c644db20 | 1833:21c792334c2e |
---|---|
496 BasicCompressedDenseThreeDimensionalModel::getCompletion() const | 496 BasicCompressedDenseThreeDimensionalModel::getCompletion() const |
497 { | 497 { |
498 return m_completion; | 498 return m_completion; |
499 } | 499 } |
500 | 500 |
501 QString | 501 QVector<QString> |
502 BasicCompressedDenseThreeDimensionalModel::getDelimitedDataHeaderLine(QString delimiter, | 502 BasicCompressedDenseThreeDimensionalModel::getStringExportHeaders(DataExportOptions) |
503 DataExportOptions) const | 503 const |
504 { | 504 { |
505 QStringList list; | 505 QVector<QString> sv; |
506 for (int i = 0; i < m_yBinCount; ++i) { | 506 for (int i = 0; i < m_yBinCount; ++i) { |
507 list << QString("Bin%1").arg(i+1); | 507 sv.push_back(QString("Bin%1").arg(i+1)); |
508 } | 508 } |
509 return list.join(delimiter); | 509 return sv; |
510 } | 510 } |
511 | 511 |
512 QString | 512 QVector<QVector<QString>> |
513 BasicCompressedDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter, | 513 BasicCompressedDenseThreeDimensionalModel::toStringExportRows(DataExportOptions, |
514 DataExportOptions, | 514 sv_frame_t startFrame, |
515 sv_frame_t startFrame, | 515 sv_frame_t duration) |
516 sv_frame_t duration) const | 516 const |
517 { | 517 { |
518 QReadLocker locker(&m_lock); | 518 QReadLocker locker(&m_lock); |
519 QString s; | 519 |
520 QVector<QVector<QString>> rows; | |
521 | |
520 for (int i = 0; in_range_for(m_data, i); ++i) { | 522 for (int i = 0; in_range_for(m_data, i); ++i) { |
521 Column c = getColumn(i); | 523 Column c = getColumn(i); |
522 sv_frame_t fr = m_startFrame + i * m_resolution; | 524 sv_frame_t fr = m_startFrame + i * m_resolution; |
523 if (fr >= startFrame && fr < startFrame + duration) { | 525 if (fr >= startFrame && fr < startFrame + duration) { |
524 QStringList list; | 526 QVector<QString> row; |
525 for (int j = 0; in_range_for(c, j); ++j) { | 527 for (int j = 0; in_range_for(c, j); ++j) { |
526 list << QString("%1").arg(c.at(j)); | 528 row << QString("%1").arg(c.at(j)); |
527 } | 529 } |
528 s += list.join(delimiter) + "\n"; | 530 rows.push_back(row); |
529 } | 531 } |
530 } | 532 } |
531 return s; | 533 |
534 return rows; | |
532 } | 535 } |
533 | 536 |
534 void | 537 void |
535 BasicCompressedDenseThreeDimensionalModel::toXml(QTextStream &out, | 538 BasicCompressedDenseThreeDimensionalModel::toXml(QTextStream &out, |
536 QString indent, | 539 QString indent, |