| 1407 | } |
| 1408 | |
| 1409 | void SerializerService::serializeStatistics(StatisticsHistoryData const& statistics, std::ostream& stream) |
| 1410 | { |
| 1411 | //header row |
| 1412 | auto writeLabelAllColors = [&stream](auto const& name) { |
| 1413 | for (int i = 0; i < MAX_COLORS; ++i) { |
| 1414 | if (i != 0) { |
| 1415 | stream << ","; |
| 1416 | } |
| 1417 | stream << name << " (color " << i << ")"; |
| 1418 | } |
| 1419 | stream << "," << name << " (accumulated)"; |
| 1420 | }; |
| 1421 | |
| 1422 | int index = 0; |
| 1423 | for (auto const& [colName, colorDependent]: ColumnDescriptions) { |
| 1424 | if (index != 0) { |
| 1425 | stream << ", "; |
| 1426 | } |
| 1427 | if (!colorDependent) { |
| 1428 | stream << colName; |
| 1429 | } |
| 1430 | else { |
| 1431 | writeLabelAllColors(colName); |
| 1432 | } |
| 1433 | ++index; |
| 1434 | } |
| 1435 | stream << std::endl; |
| 1436 | |
| 1437 | //content |
| 1438 | for (auto dataPoints : statistics) { |
| 1439 | std::vector<std::string> entries; |
| 1440 | save(entries, dataPoints); |
| 1441 | stream << boost::join(entries, ",") << std::endl; |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | void SerializerService::deserializeStatistics(StatisticsHistoryData& statistics, std::istream& stream) |
| 1446 | { |