MCPcopy Create free account
hub / github.com/IENT/YUView / readHeaderFromFile

Method readHeaderFromFile

YUViewLib/src/statistics/StatisticsFileCSV.cpp:345–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345void StatisticsFileCSV::readHeaderFromFile(StatisticsData &statisticsData)
346{
347 // TODO: Why is there a try block here? I see no throwing of anything ...
348 // We should get rid of this and just set an error and return on failure.
349 try
350 {
351 if (!this->file.isOk())
352 return;
353
354 statisticsData.clear();
355
356 // scan header lines first
357 // also count the lines per Frame for more efficient memory allocation
358 // if an ID is used twice, the data of the first gets overwritten
359 bool typeParsingActive = false;
360 StatisticsType aType;
361
362 while (!this->file.atEnd())
363 {
364 // read one line
365 auto aLineByteArray = this->file.readLine();
366 QString aLine(aLineByteArray);
367
368 // get components of this line
369 auto rowItemList = parseCSVLine(aLine, ';');
370
371 if (rowItemList[0].isEmpty())
372 continue;
373
374 // either a new type or a line which is not header finishes the last type
375 if (((rowItemList[1] == "type") || (rowItemList[0][0] != '%')) && typeParsingActive)
376 {
377 // Last type is complete. Store this initial state.
378 aType.setInitialState();
379 statisticsData.addStatType(aType);
380
381 // start from scratch for next item
382 aType = StatisticsType();
383 typeParsingActive = false;
384
385 // if we found a non-header line, stop here
386 if (rowItemList[0][0] != '%')
387 return;
388 }
389
390 if (rowItemList[1] == "type") // new type
391 {
392 aType.typeID = rowItemList[2].toInt();
393 aType.typeName = rowItemList[3];
394
395 // The next entry (4) is "map", "range", or "vector"
396 if (rowItemList.count() >= 5)
397 {
398 if (rowItemList[4] == "map" || rowItemList[4] == "range")
399 {
400 aType.hasValueData = true;
401 aType.renderValueData = true;
402 }

Callers 1

StatisticsFileCSVMethod · 0.95

Calls 13

parseCSVLineFunction · 0.85
ColorClass · 0.85
ColorMapperClass · 0.85
SizeClass · 0.85
isOkMethod · 0.80
readLineMethod · 0.80
setInitialStateMethod · 0.80
addStatTypeMethod · 0.80
StatisticsTypeClass · 0.70
clearMethod · 0.45
atEndMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected