@@ -405,31 +405,37 @@ inline void choose(const CsvOutputType outputType, H1 h1Func, H2 h2Func, D dataF
405405 }
406406}
407407
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 )
409409{
410+ std::ostringstream strstr;
411+ std::ostream & stdcout = out ? strstr : std::cout;
410412 choose (outputType,
411- [&separator]() {
412- std::cout << separator << separator; // Time
413+ [&separator, &stdcout ]() {
414+ stdcout << separator << separator; // Time
413415 },
414- [&separator]() {
415- std::cout << " Date" << separator << " Time" << separator;
416+ [&separator, &stdcout ]() {
417+ stdcout << " Date" << separator << " Time" << separator;
416418 },
417- [&separator]() {
419+ [&separator, &stdcout ]() {
418420 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 <<
422424 std::setw (4 ) << 1900 + tt.first .tm_year << ' -' <<
423425 std::setw (2 ) << 1 + tt.first .tm_mon << ' -' <<
424426 std::setw (2 ) << tt.first .tm_mday << separator <<
425427 std::setw (2 ) << tt.first .tm_hour << ' :' <<
426428 std::setw (2 ) << tt.first .tm_min << ' :' <<
427429 std::setw (2 ) << tt.first .tm_sec << ' .' <<
428430 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 );
432434 });
435+ if (out)
436+ {
437+ *out = strstr.str ();
438+ }
433439}
434440
435441inline void printDateForJson (const std::string& separator, const std::string &jsonSeparator)
0 commit comments