54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
#include "outputcsv.hh"
|
|
#include "request.hh"
|
|
#include "resultlist.hh"
|
|
#include "mobile.hh"
|
|
|
|
#include <sstream>
|
|
|
|
using namespace std ;
|
|
|
|
|
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
const string OutputCSV::result_to_csv(const Result &result)
|
|
{
|
|
ostringstream csv_line ;
|
|
|
|
csv_line << result.get_algorithm() ;
|
|
|
|
Point3D position = result.get_position() ;
|
|
csv_line
|
|
<< ';' << position.get_x()
|
|
<< ';' << position.get_y()
|
|
<< ';' << position.get_z() ;
|
|
|
|
return csv_line.str() ;
|
|
}
|
|
|
|
|
|
const string OutputCSV::results_to_csv(const ResultList &results)
|
|
{
|
|
ostringstream csv_line ;
|
|
|
|
const Request *const request = results.get_request() ;
|
|
if (request != NULL)
|
|
{
|
|
if (request->get_mobile() != NULL)
|
|
csv_line << request->get_mobile()->get_mac_addr() ;
|
|
csv_line
|
|
<< ';' << static_cast<uint_fast16_t>(request->get_type())
|
|
<< ';' << request->get_time_sent() ;
|
|
}
|
|
else
|
|
csv_line << ";;;" ;
|
|
|
|
const vector<Result> &res = results.get_results() ;
|
|
for (vector<Result>::const_iterator r = res.begin() ; r != res.end() ;
|
|
++r)
|
|
csv_line << ';' << result_to_csv(*r) ;
|
|
|
|
return csv_line.str() ;
|
|
}
|