-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreportGenerator.cpp
27 lines (23 loc) · 984 Bytes
/
reportGenerator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "reportGenerator.hpp"
#include <sstream>
#include <iomanip>
std::string generateReport(upRouteMap& routes)
{
std::ostringstream mainstream;
std::string report = "";
float length = 0;
for (routeMap::iterator routeMapIt = (*routes).begin(); routeMapIt != (*routes).end(); routeMapIt++)
{
int routeInDepot = 1;
for (auto routeIt = (*routeMapIt).second.begin(); routeIt != (*routeMapIt).second.end(); routeIt++)
{
std::ostringstream linestream;
linestream << (*routeMapIt).first << " "<< routeInDepot++ << " " << std::fixed << std::setw( 8 ) << std::setprecision( 2 ) <<(*routeIt)->routeLength()<< " " <<
(*routeIt)->getRouteLoad() << " " <<(*routeIt)->getCustomerString()<<"\r\n";
length += (*routeIt)->routeLength();
report = report + linestream.str();
}
}
mainstream << length << "\r\n"<<report;
return mainstream.str();
}