@@ -405,31 +405,37 @@ inline void choose(const CsvOutputType outputType, H1 h1Func, H2 h2Func, D dataF
405
405
}
406
406
}
407
407
408
- inline void printDateForCSV (const CsvOutputType outputType, std::string separator = std::string(" ," ))
408
+ inline void printDateForCSV (const CsvOutputType outputType, std::string separator = std::string(" ," ), std::string * out = nullptr )
409
409
{
410
+ std::ostringstream strstr;
411
+ std::ostream & stdcout = out ? strstr : std::cout;
410
412
choose (outputType,
411
- [&separator]() {
412
- std::cout << separator << separator; // Time
413
+ [&separator, &stdcout ]() {
414
+ stdcout << separator << separator; // Time
413
415
},
414
- [&separator]() {
415
- std::cout << " Date" << separator << " Time" << separator;
416
+ [&separator, &stdcout ]() {
417
+ stdcout << " Date" << separator << " Time" << separator;
416
418
},
417
- [&separator]() {
419
+ [&separator, &stdcout ]() {
418
420
std::pair<tm, uint64> tt{ pcm_localtime () };
419
- std::cout .precision (3 );
420
- char old_fill = std::cout .fill (' 0' );
421
- std::cout <<
421
+ stdcout .precision (3 );
422
+ char old_fill = stdcout .fill (' 0' );
423
+ stdcout <<
422
424
std::setw (4 ) << 1900 + tt.first .tm_year << ' -' <<
423
425
std::setw (2 ) << 1 + tt.first .tm_mon << ' -' <<
424
426
std::setw (2 ) << tt.first .tm_mday << separator <<
425
427
std::setw (2 ) << tt.first .tm_hour << ' :' <<
426
428
std::setw (2 ) << tt.first .tm_min << ' :' <<
427
429
std::setw (2 ) << tt.first .tm_sec << ' .' <<
428
430
std::setw (3 ) << tt.second << separator; // milliseconds
429
- std::cout .fill (old_fill);
430
- std::cout .setf (std::ios::fixed);
431
- std::cout .precision (2 );
431
+ stdcout .fill (old_fill);
432
+ stdcout .setf (std::ios::fixed);
433
+ stdcout .precision (2 );
432
434
});
435
+ if (out)
436
+ {
437
+ *out = strstr.str ();
438
+ }
433
439
}
434
440
435
441
inline void printDateForJson (const std::string& separator, const std::string &jsonSeparator)
0 commit comments