comparison data/fileio/CSVFileReader.cpp @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents 920699b6989d
children 26cf6d5251ec
comparison
equal deleted inserted replaced
1037:bf0e5944289b 1038:cc27f35aa75c
93 CSVFileReader::getError() const 93 CSVFileReader::getError() const
94 { 94 {
95 return m_error; 95 return m_error;
96 } 96 }
97 97
98 int 98 sv_frame_t
99 CSVFileReader::convertTimeValue(QString s, int lineno, int sampleRate, 99 CSVFileReader::convertTimeValue(QString s, int lineno, int sampleRate,
100 int windowSize) const 100 int windowSize) const
101 { 101 {
102 QRegExp nonNumericRx("[^0-9eE.,+-]"); 102 QRegExp nonNumericRx("[^0-9eE.,+-]");
103 int warnLimit = 10; 103 int warnLimit = 10;
104 104
105 CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits(); 105 CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits();
106 106
107 int calculatedFrame = 0; 107 sv_frame_t calculatedFrame = 0;
108 108
109 bool ok = false; 109 bool ok = false;
110 QString numeric = s; 110 QString numeric = s;
111 numeric.remove(nonNumericRx); 111 numeric.remove(nonNumericRx);
112 112
113 if (timeUnits == CSVFormat::TimeSeconds) { 113 if (timeUnits == CSVFormat::TimeSeconds) {
114 114
115 double time = numeric.toDouble(&ok); 115 double time = numeric.toDouble(&ok);
116 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok); 116 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
117 calculatedFrame = int(time * sampleRate + 0.5); 117 calculatedFrame = sv_frame_t(time * sampleRate + 0.5);
118 118
119 } else if (timeUnits == CSVFormat::TimeMilliseconds) { 119 } else if (timeUnits == CSVFormat::TimeMilliseconds) {
120 120
121 double time = numeric.toDouble(&ok); 121 double time = numeric.toDouble(&ok);
122 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok); 122 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
123 calculatedFrame = int((time / 1000.0) * sampleRate + 0.5); 123 calculatedFrame = sv_frame_t((time / 1000.0) * sampleRate + 0.5);
124 124
125 } else { 125 } else {
126 126
127 long n = numeric.toLong(&ok); 127 long n = numeric.toLong(&ok);
128 if (n >= 0) calculatedFrame = n; 128 if (n >= 0) calculatedFrame = n;
187 unsigned int warnings = 0, warnLimit = 10; 187 unsigned int warnings = 0, warnLimit = 10;
188 unsigned int lineno = 0; 188 unsigned int lineno = 0;
189 189
190 float min = 0.0, max = 0.0; 190 float min = 0.0, max = 0.0;
191 191
192 int frameNo = 0; 192 sv_frame_t frameNo = 0;
193 int duration = 0; 193 sv_frame_t duration = 0;
194 int endFrame = 0; 194 sv_frame_t endFrame = 0;
195 195
196 bool haveAnyValue = false; 196 bool haveAnyValue = false;
197 bool haveEndTime = false; 197 bool haveEndTime = false;
198 bool pitchLooksLikeMIDI = true; 198 bool pitchLooksLikeMIDI = true;
199 199
200 int startFrame = 0; // for calculation of dense model resolution 200 sv_frame_t startFrame = 0; // for calculation of dense model resolution
201 bool firstEverValue = true; 201 bool firstEverValue = true;
202 202
203 std::map<QString, int> labelCountMap; 203 std::map<QString, int> labelCountMap;
204 204
205 int valueColumns = 0; 205 int valueColumns = 0;
371 if (firstEverValue) { 371 if (firstEverValue) {
372 startFrame = frameNo; 372 startFrame = frameNo;
373 model3->setStartFrame(startFrame); 373 model3->setStartFrame(startFrame);
374 } else if (lineno == 1 && 374 } else if (lineno == 1 &&
375 timingType == CSVFormat::ExplicitTiming) { 375 timingType == CSVFormat::ExplicitTiming) {
376 model3->setResolution(frameNo - startFrame); 376 model3->setResolution(int(frameNo - startFrame));
377 } 377 }
378 378
379 firstEverValue = false; 379 firstEverValue = false;
380 380
381 if (!ok) { 381 if (!ok) {