# HG changeset patch # User Lucas Thompson # Date 1523955829 -3600 # Node ID 09c2ba31a711988ce01cf2ea36a0ea478ffe550e # Parent de385fed1197772cf13d4a0316ae7d07adafd50c Formatting and naming changes more in line with SV conventions. diff -r de385fed1197 -r 09c2ba31a711 data/fileio/CSVFileWriter.cpp --- a/data/fileio/CSVFileWriter.cpp Tue Apr 17 10:03:49 2018 +0100 +++ b/data/fileio/CSVFileWriter.cpp Tue Apr 17 10:03:49 2018 +0100 @@ -88,7 +88,7 @@ bool completed = false; for (const auto& bounds : selection->getSelections()) { - completed = CSV::writeToStreamInChunks( + completed = CSVStreamWriter::writeInChunks( out, *m_model, bounds, diff -r de385fed1197 -r 09c2ba31a711 data/fileio/CSVFileWriter.h --- a/data/fileio/CSVFileWriter.h Tue Apr 17 10:03:49 2018 +0100 +++ b/data/fileio/CSVFileWriter.h Tue Apr 17 10:03:49 2018 +0100 @@ -35,13 +35,12 @@ QString delimiter = ",", DataExportOptions options = DataExportDefaults); - CSVFileWriter( - QString path, - Model *model, - ProgressReporter *reporter, - QString delimiter = ",", - DataExportOptions options = DataExportDefaults - ) : CSVFileWriter(path, model, delimiter, options) + CSVFileWriter(QString path, + Model *model, + ProgressReporter *reporter, + QString delimiter = ",", + DataExportOptions options = DataExportDefaults) + : CSVFileWriter(path, model, delimiter, options) { m_reporter = reporter; } diff -r de385fed1197 -r 09c2ba31a711 data/fileio/CSVStreamWriter.h --- a/data/fileio/CSVStreamWriter.h Tue Apr 17 10:03:49 2018 +0100 +++ b/data/fileio/CSVStreamWriter.h Tue Apr 17 10:03:49 2018 +0100 @@ -4,7 +4,7 @@ Sonic Visualiser An audio file viewer and annotation editor. Centre for Digital Music, Queen Mary, University of London. - This file copyright 2017 Lucas Thompson. + This file copyright 2017 Queen Mary, University of London. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -13,8 +13,8 @@ COPYING included with this distribution for more information. */ -#ifndef _CSV_STREAM_WRITER_H_ -#define _CSV_STREAM_WRITER_H_ +#ifndef CSV_STREAM_WRITER_H +#define CSV_STREAM_WRITER_H #include "base/BaseTypes.h" #include "base/Selection.h" @@ -24,20 +24,17 @@ #include #include -namespace CSV +namespace CSVStreamWriter { -using Completed = bool; template -auto writeToStreamInChunks( - OutStream& oss, - const Model& model, - const Selection& extents, - ProgressReporter* reporter = nullptr, - QString delimiter = ",", - DataExportOptions options = DataExportDefaults, - const sv_frame_t blockSize = 16384 -) -> Completed +bool writeInChunks(OutStream& oss, + const Model& model, + const Selection& extents, + ProgressReporter* reporter = nullptr, + QString delimiter = ",", + DataExportOptions options = DataExportDefaults, + const sv_frame_t blockSize = 16384) { if (blockSize <= 0) return false; sv_frame_t readPtr = extents.isEmpty() ? @@ -76,17 +73,15 @@ } template -auto writeToStreamInChunks( - OutStream& oss, - const Model& model, - ProgressReporter* reporter = nullptr, - QString delimiter = ",", - DataExportOptions options = DataExportDefaults, - const sv_frame_t blockSize = 16384 -) -> Completed +bool writeInChunks(OutStream& oss, + const Model& model, + ProgressReporter* reporter = nullptr, + QString delimiter = ",", + DataExportOptions options = DataExportDefaults, + const sv_frame_t blockSize = 16384) { const Selection empty; - return CSV::writeToStreamInChunks( + return CSV::writeInChunks( oss, model, empty, @@ -96,5 +91,5 @@ blockSize ); } -} // namespace +} // namespace CSVStreamWriter #endif \ No newline at end of file diff -r de385fed1197 -r 09c2ba31a711 data/fileio/test/CSVStreamWriterTest.h --- a/data/fileio/test/CSVStreamWriterTest.h Tue Apr 17 10:03:49 2018 +0100 +++ b/data/fileio/test/CSVStreamWriterTest.h Tue Apr 17 10:03:49 2018 +0100 @@ -4,7 +4,7 @@ Sonic Visualiser An audio file viewer and annotation editor. Centre for Digital Music, Queen Mary, University of London. - This file copyright 2017 Lucas Thompson. + This file copyright 2017 Queen Mary, University of London. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -87,7 +87,7 @@ MockWaveModel mwm({ DC, DC }, 16, 4); std::ostringstream oss; - const auto result = CSV::writeToStreamInChunks(oss, mwm); + const auto result = CSVStreamWriter::writeInChunks(oss, mwm); QVERIFY( oss.str() == getExpectedString() ); QVERIFY( result ); } @@ -100,7 +100,7 @@ std::ostringstream oss; const auto writeStreamWithBlockSize = [&](int blockSize) { - return CSV::writeToStreamInChunks( + return CSVStreamWriter::writeInChunks( oss, mwm, &reporter, @@ -144,7 +144,7 @@ StubReporter reporter { []() -> bool { return true; } }; std::ostringstream oss; - const auto cancelImmediately = CSV::writeToStreamInChunks( + const auto cancelImmediately = CSVStreamWriter::writeInChunks( oss, mwm, &reporter, @@ -158,7 +158,7 @@ StubReporter cancelMidway { [&]() { return cancelMidway.getCallCount() == 3; } }; - const auto cancelledMidway = CSV::writeToStreamInChunks( + const auto cancelledMidway = CSVStreamWriter::writeInChunks( oss, mwm, &cancelMidway,