comparison base/StringBits.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 48e9f538e6e9
children 91056142abd0
comparison
equal deleted inserted replaced
1832:7c92c644db20 1833:21c792334c2e
149 separator == ' ' ? QString::SkipEmptyParts : 149 separator == ' ' ? QString::SkipEmptyParts :
150 QString::KeepEmptyParts); 150 QString::KeepEmptyParts);
151 } 151 }
152 } 152 }
153 153
154 QString
155 StringBits::joinDelimited(QVector<QString> row, QString delimiter)
156 {
157 QString s;
158 for (auto col: row) {
159 if (s != "") {
160 s += delimiter;
161 }
162 if (col.contains(delimiter)) {
163 col.replace("\"", "\"\"");
164 col = "\"" + col + "\"";
165 }
166 s += col;
167 }
168 return s;
169 }
170