blob: 91bf39594b0a58ad55f408622e8a4917b052c5c9 (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include "routing/vehicle_mask.hpp"
#include <sstream>
#include <string>
#include "base/assert.hpp"
using namespace std;
namespace routing
{
string DebugPrint(VehicleType vehicleType)
{
switch (vehicleType)
{
case VehicleType::Pedestrian: return "Pedestrian";
case VehicleType::Bicycle: return "Bicycle";
case VehicleType::Car: return "Car";
case VehicleType::Transit: return "Transit";
case VehicleType::Count: return "Count";
}
UNREACHABLE();
}
string ToString(VehicleType vehicleType) { return DebugPrint(vehicleType); }
void FromString(string const & s, VehicleType & vehicleType)
{
if (s == "Pedestrian")
vehicleType = VehicleType::Pedestrian;
else if (s == "Bicycle")
vehicleType = VehicleType::Bicycle;
else if (s == "Car")
vehicleType = VehicleType::Car;
else if (s == "Transit")
vehicleType = VehicleType::Transit;
else
{
ASSERT(false, ("Could not read VehicleType from string", s));
vehicleType = VehicleType::Count;
}
}
string DebugPrint(VehicleMask vehicleMask)
{
ostringstream oss;
oss << "VehicleMask [";
bool first = true;
for (size_t i = 0; i < static_cast<size_t>(VehicleType::Count); ++i)
{
auto const vt = static_cast<VehicleType>(i);
if ((vehicleMask & GetVehicleMask(vt)) == 0)
continue;
if (!first)
oss << ", ";
first = false;
oss << DebugPrint(vt);
}
oss << "]";
return oss.str();
}
} // namespace routing
|