Mercurial > hg > svcore
diff base/StringBits.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 | 64ef24ebb19c |
children | 91056142abd0 |
line wrap: on
line diff
--- a/base/StringBits.h Fri Apr 03 12:12:02 2020 +0100 +++ b/base/StringBits.h Fri Apr 03 17:11:05 2020 +0100 @@ -55,6 +55,16 @@ * analogous to the behaviour of splitQuoted). */ static QStringList split(QString s, QChar separator, bool quoted); + + /** + * Join a vector of strings into a single string, with the + * delimiter as the joining string. If a string contains the + * delimiter already, quote it with double-quotes, replacing any + * existing double-quotes within it by a pair of double-quotes, as + * specified in RFC 4180 Common Format and MIME Type for + * Comma-Separated Values (CSV) Files. + */ + static QString joinDelimited(QVector<QString> row, QString delimiter); }; #endif