Mercurial > hg > svcore
comparison transform/CSVFeatureWriter.cpp @ 1300:4a2bc07ec0fb 3.0-integration
Make CSV feature writer produce the same output with Qt 5.6 and 5.7+
author | Chris Cannam |
---|---|
date | Fri, 25 Nov 2016 17:33:44 +0000 |
parents | d094598f84bd |
children | 87ae75da6527 |
comparison
equal
deleted
inserted
replaced
1299:838a45cff62d | 1300:4a2bc07ec0fb |
---|---|
274 if (summaryType != "") { | 274 if (summaryType != "") { |
275 stream << m_separator << summaryType.c_str(); | 275 stream << m_separator << summaryType.c_str(); |
276 } | 276 } |
277 | 277 |
278 for (unsigned int j = 0; j < f.values.size(); ++j) { | 278 for (unsigned int j = 0; j < f.values.size(); ++j) { |
279 stream << m_separator << QString("%1").arg(f.values[j], 0, 'g', m_digits); | 279 |
280 QString number = QString("%1").arg(f.values[j], 0, 'g', m_digits); | |
281 | |
282 // Qt pre-5.6 zero pads single-digit exponents to two digits; | |
283 // Qt 5.7+ doesn't by default. But we want both to produce the | |
284 // same output. Getting the new behaviour from standard APIs | |
285 // in Qt 5.6 isn't possible I think; getting the old behaviour | |
286 // from Qt 5.7 is possible but fiddly, involving setting up an | |
287 // appropriate locale and using the %L specifier. We could | |
288 // doubtless do it with sprintf but Qt is a known quantity at | |
289 // this point. Let's just convert the old format to the new. | |
290 number.replace("e-0", "e-"); | |
291 | |
292 stream << m_separator << number; | |
280 } | 293 } |
281 | 294 |
282 if (f.label != "") { | 295 if (f.label != "") { |
283 stream << m_separator << "\"" << f.label.c_str() << "\""; | 296 stream << m_separator << "\"" << f.label.c_str() << "\""; |
284 } | 297 } |