Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -40,36 +40,38 @@ array<pair<LaneWay, char const *>, static_cast<size_t>(LaneWay::Count) + 1> cons
{LaneWay::SlightRight, "slight_right"},
{LaneWay::SharpRight, "sharp_right"},
{LaneWay::Reverse, "reverse"}}};
static_assert(g_laneWayNames.size() == static_cast<size_t>(LaneWay::Count) + 1,
"Check the size of g_laneWayNames");
static_assert(g_laneWayNames.size() == static_cast<size_t>(LaneWay::Count) + 1, "Check the size of g_laneWayNames");
array<pair<CarDirection, char const *>, static_cast<size_t>(CarDirection::Count)> const
g_turnNames = {{{CarDirection::None, "None"},
{CarDirection::GoStraight, "GoStraight"},
{CarDirection::TurnRight, "TurnRight"},
{CarDirection::TurnSharpRight, "TurnSharpRight"},
{CarDirection::TurnSlightRight, "TurnSlightRight"},
{CarDirection::TurnLeft, "TurnLeft"},
{CarDirection::TurnSharpLeft, "TurnSharpLeft"},
{CarDirection::TurnSlightLeft, "TurnSlightLeft"},
{CarDirection::UTurnLeft, "UTurnLeft"},
{CarDirection::UTurnRight, "UTurnRight"},
{CarDirection::EnterRoundAbout, "EnterRoundAbout"},
{CarDirection::LeaveRoundAbout, "LeaveRoundAbout"},
{CarDirection::StayOnRoundAbout, "StayOnRoundAbout"},
{CarDirection::StartAtEndOfStreet, "StartAtEndOfStreet"},
{CarDirection::ReachedYourDestination, "ReachedYourDestination"},
{CarDirection::ExitHighwayToLeft, "ExitHighwayToLeft"},
{CarDirection::ExitHighwayToRight, "ExitHighwayToRight"}}};
static_assert(g_turnNames.size() == static_cast<size_t>(CarDirection::Count),
"Check the size of g_turnNames");
array<pair<CarDirection, char const *>, static_cast<size_t>(CarDirection::Count)> const g_turnNames = {
{{CarDirection::None, "None"},
{CarDirection::GoStraight, "GoStraight"},
{CarDirection::TurnRight, "TurnRight"},
{CarDirection::TurnSharpRight, "TurnSharpRight"},
{CarDirection::TurnSlightRight, "TurnSlightRight"},
{CarDirection::TurnLeft, "TurnLeft"},
{CarDirection::TurnSharpLeft, "TurnSharpLeft"},
{CarDirection::TurnSlightLeft, "TurnSlightLeft"},
{CarDirection::UTurnLeft, "UTurnLeft"},
{CarDirection::UTurnRight, "UTurnRight"},
{CarDirection::EnterRoundAbout, "EnterRoundAbout"},
{CarDirection::LeaveRoundAbout, "LeaveRoundAbout"},
{CarDirection::StayOnRoundAbout, "StayOnRoundAbout"},
{CarDirection::StartAtEndOfStreet, "StartAtEndOfStreet"},
{CarDirection::ReachedYourDestination, "ReachedYourDestination"},
{CarDirection::ExitHighwayToLeft, "ExitHighwayToLeft"},
{CarDirection::ExitHighwayToRight, "ExitHighwayToRight"}}};
static_assert(g_turnNames.size() == static_cast<size_t>(CarDirection::Count), "Check the size of g_turnNames");
} // namespace
// SegmentRange -----------------------------------------------------------------------------------
SegmentRange::SegmentRange(FeatureID const & featureId, uint32_t startSegId, uint32_t endSegId,
bool forward, m2::PointD const & start, m2::PointD const & end)
: m_featureId(featureId), m_startSegId(startSegId), m_endSegId(endSegId), m_forward(forward),
m_start(start), m_end(end)
SegmentRange::SegmentRange(FeatureID const & featureId, uint32_t startSegId, uint32_t endSegId, bool forward,
m2::PointD const & start, m2::PointD const & end)
: m_featureId(featureId)
, m_startSegId(startSegId)
, m_endSegId(endSegId)
, m_forward(forward)
, m_start(start)
, m_end(end)
{
if (m_startSegId != m_endSegId)
CHECK_EQUAL(m_forward, m_startSegId < m_endSegId, (*this));
@@ -77,9 +79,8 @@ SegmentRange::SegmentRange(FeatureID const & featureId, uint32_t startSegId, uin
bool SegmentRange::operator==(SegmentRange const & rhs) const
{
return m_featureId == rhs.m_featureId && m_startSegId == rhs.m_startSegId &&
m_endSegId == rhs.m_endSegId && m_forward == rhs.m_forward && m_start == rhs.m_start &&
m_end == rhs.m_end;
return m_featureId == rhs.m_featureId && m_startSegId == rhs.m_startSegId && m_endSegId == rhs.m_endSegId &&
m_forward == rhs.m_forward && m_start == rhs.m_start && m_end == rhs.m_end;
}
bool SegmentRange::operator<(SegmentRange const & rhs) const
@@ -114,8 +115,8 @@ void SegmentRange::Clear()
bool SegmentRange::IsEmpty() const
{
return !m_featureId.IsValid() && m_startSegId == 0 && m_endSegId == 0 && m_forward &&
m_start == m2::PointD::Zero() && m_end == m2::PointD::Zero();
return !m_featureId.IsValid() && m_startSegId == 0 && m_endSegId == 0 && m_forward && m_start == m2::PointD::Zero() &&
m_end == m2::PointD::Zero();
}
FeatureID const & SegmentRange::GetFeature() const
@@ -138,14 +139,13 @@ bool SegmentRange::GetLastSegment(NumMwmIds const & numMwmIds, Segment & segment
return GetSegmentBySegId(m_endSegId, numMwmIds, segment);
}
bool SegmentRange::GetSegmentBySegId(uint32_t segId, NumMwmIds const & numMwmIds,
Segment & segment) const
bool SegmentRange::GetSegmentBySegId(uint32_t segId, NumMwmIds const & numMwmIds, Segment & segment) const
{
if (!m_featureId.IsValid())
return false;
segment = Segment(numMwmIds.GetId(platform::CountryFile(m_featureId.GetMwmName())),
m_featureId.m_index, segId, m_forward);
segment =
Segment(numMwmIds.GetId(platform::CountryFile(m_featureId.GetMwmName())), m_featureId.m_index, segId, m_forward);
return true;
}
@@ -153,13 +153,9 @@ string DebugPrint(SegmentRange const & segmentRange)
{
stringstream out;
out << "SegmentRange "
<< "{ m_featureId = " << DebugPrint(segmentRange.m_featureId)
<< ", m_startSegId = " << segmentRange.m_startSegId
<< ", m_endSegId = " << segmentRange.m_endSegId
<< ", m_forward = " << segmentRange.m_forward
<< ", m_start = " << DebugPrint(segmentRange.m_start)
<< ", m_end = " << DebugPrint(segmentRange.m_end)
<< " }";
<< "{ m_featureId = " << DebugPrint(segmentRange.m_featureId) << ", m_startSegId = " << segmentRange.m_startSegId
<< ", m_endSegId = " << segmentRange.m_endSegId << ", m_forward = " << segmentRange.m_forward
<< ", m_start = " << DebugPrint(segmentRange.m_start) << ", m_end = " << DebugPrint(segmentRange.m_end) << " }";
return out.str();
}
@@ -175,12 +171,9 @@ string DebugPrint(TurnItem const & turnItem)
{
stringstream out;
out << "TurnItem "
<< "{ m_index = " << turnItem.m_index
<< ", m_turn = " << DebugPrint(turnItem.m_turn)
<< ", m_lanes = " << ::DebugPrint(turnItem.m_lanes)
<< ", m_exitNum = " << turnItem.m_exitNum
<< ", m_pedestrianDir = " << DebugPrint(turnItem.m_pedestrianTurn)
<< " }";
<< "{ m_index = " << turnItem.m_index << ", m_turn = " << DebugPrint(turnItem.m_turn)
<< ", m_lanes = " << ::DebugPrint(turnItem.m_lanes) << ", m_exitNum = " << turnItem.m_exitNum
<< ", m_pedestrianDir = " << DebugPrint(turnItem.m_pedestrianTurn) << " }";
return out.str();
}
@@ -188,8 +181,7 @@ string DebugPrint(TurnItemDist const & turnItemDist)
{
stringstream out;
out << "TurnItemDist "
<< "{ m_turnItem = " << DebugPrint(turnItemDist.m_turnItem)
<< ", m_distMeters = " << turnItemDist.m_distMeters
<< "{ m_turnItem = " << DebugPrint(turnItemDist.m_turnItem) << ", m_distMeters = " << turnItemDist.m_distMeters
<< " }";
return out.str();
}
@@ -197,10 +189,8 @@ string DebugPrint(TurnItemDist const & turnItemDist)
string GetTurnString(CarDirection turn)
{
for (auto const & p : g_turnNames)
{
if (p.first == turn)
return p.second;
}
ASSERT(false, (static_cast<int>(turn)));
return "unknown CarDirection";
@@ -238,35 +228,25 @@ bool IsStayOnRoad(CarDirection t)
bool IsGoStraightOrSlightTurn(CarDirection t)
{
return (t == CarDirection::GoStraight || t == CarDirection::TurnSlightLeft ||
t == CarDirection::TurnSlightRight);
return (t == CarDirection::GoStraight || t == CarDirection::TurnSlightLeft || t == CarDirection::TurnSlightRight);
}
bool IsLaneWayConformedTurnDirection(LaneWay l, CarDirection t)
{
switch (t)
{
default:
return false;
case CarDirection::GoStraight:
return l == LaneWay::Through;
case CarDirection::TurnRight:
return l == LaneWay::Right;
case CarDirection::TurnSharpRight:
return l == LaneWay::SharpRight;
case CarDirection::TurnSlightRight:
case CarDirection::ExitHighwayToRight:
return l == LaneWay::SlightRight;
case CarDirection::TurnLeft:
return l == LaneWay::Left;
case CarDirection::TurnSharpLeft:
return l == LaneWay::SharpLeft;
case CarDirection::TurnSlightLeft:
case CarDirection::ExitHighwayToLeft:
return l == LaneWay::SlightLeft;
case CarDirection::UTurnLeft:
case CarDirection::UTurnRight:
return l == LaneWay::Reverse;
default: return false;
case CarDirection::GoStraight: return l == LaneWay::Through;
case CarDirection::TurnRight: return l == LaneWay::Right;
case CarDirection::TurnSharpRight: return l == LaneWay::SharpRight;
case CarDirection::TurnSlightRight:
case CarDirection::ExitHighwayToRight: return l == LaneWay::SlightRight;
case CarDirection::TurnLeft: return l == LaneWay::Left;
case CarDirection::TurnSharpLeft: return l == LaneWay::SharpLeft;
case CarDirection::TurnSlightLeft:
case CarDirection::ExitHighwayToLeft: return l == LaneWay::SlightLeft;
case CarDirection::UTurnLeft:
case CarDirection::UTurnRight: return l == LaneWay::Reverse;
}
}
@@ -274,33 +254,22 @@ bool IsLaneWayConformedTurnDirectionApproximately(LaneWay l, CarDirection t)
{
switch (t)
{
default:
return false;
case CarDirection::GoStraight:
return l == LaneWay::Through || l == LaneWay::SlightRight || l == LaneWay::SlightLeft;
case CarDirection::TurnRight:
return l == LaneWay::Right || l == LaneWay::SharpRight || l == LaneWay::SlightRight;
case CarDirection::TurnSharpRight:
return l == LaneWay::SharpRight || l == LaneWay::Right;
case CarDirection::TurnSlightRight:
return l == LaneWay::SlightRight || l == LaneWay::Through || l == LaneWay::Right;
case CarDirection::TurnLeft:
return l == LaneWay::Left || l == LaneWay::SlightLeft || l == LaneWay::SharpLeft;
case CarDirection::TurnSharpLeft:
return l == LaneWay::SharpLeft || l == LaneWay::Left;
case CarDirection::TurnSlightLeft:
return l == LaneWay::SlightLeft || l == LaneWay::Through || l == LaneWay::Left;
case CarDirection::UTurnLeft:
case CarDirection::UTurnRight:
return l == LaneWay::Reverse;
case CarDirection::ExitHighwayToLeft:
return l == LaneWay::SlightLeft || l == LaneWay::Left;
case CarDirection::ExitHighwayToRight:
return l == LaneWay::SlightRight || l == LaneWay::Right;
default: return false;
case CarDirection::GoStraight: return l == LaneWay::Through || l == LaneWay::SlightRight || l == LaneWay::SlightLeft;
case CarDirection::TurnRight: return l == LaneWay::Right || l == LaneWay::SharpRight || l == LaneWay::SlightRight;
case CarDirection::TurnSharpRight: return l == LaneWay::SharpRight || l == LaneWay::Right;
case CarDirection::TurnSlightRight: return l == LaneWay::SlightRight || l == LaneWay::Through || l == LaneWay::Right;
case CarDirection::TurnLeft: return l == LaneWay::Left || l == LaneWay::SlightLeft || l == LaneWay::SharpLeft;
case CarDirection::TurnSharpLeft: return l == LaneWay::SharpLeft || l == LaneWay::Left;
case CarDirection::TurnSlightLeft: return l == LaneWay::SlightLeft || l == LaneWay::Through || l == LaneWay::Left;
case CarDirection::UTurnLeft:
case CarDirection::UTurnRight: return l == LaneWay::Reverse;
case CarDirection::ExitHighwayToLeft: return l == LaneWay::SlightLeft || l == LaneWay::Left;
case CarDirection::ExitHighwayToRight: return l == LaneWay::SlightRight || l == LaneWay::Right;
}
}
bool IsLaneUnrestricted(const SingleLaneInfo & lane)
bool IsLaneUnrestricted(SingleLaneInfo const & lane)
{
/// @todo Is there any reason to store None single lane?
return lane.m_lane.size() == 1 && lane.m_lane[0] == LaneWay::None;
@@ -312,9 +281,7 @@ void SplitLanes(string const & lanesString, char delimiter, vector<string> & lan
istringstream lanesStream(lanesString);
string token;
while (getline(lanesStream, token, delimiter))
{
lanes.push_back(token);
}
}
bool ParseSingleLane(string const & laneString, char delimiter, TSingleLane & lane)
@@ -331,10 +298,7 @@ bool ParseSingleLane(string const & laneString, char delimiter, TSingleLane & la
while (getline(laneStream, token, delimiter))
{
auto const it = find_if(g_laneWayNames.begin(), g_laneWayNames.end(),
[&token](pair<LaneWay, string> const & p)
{
return p.second == token;
});
[&token](pair<LaneWay, string> const & p) { return p.second == token; });
if (it == g_laneWayNames.end())
return false;
lane.push_back(it->first);
@@ -368,10 +332,7 @@ bool ParseLanes(string lanesString, vector<SingleLaneInfo> & lanes)
string DebugPrint(LaneWay const l)
{
auto const it = find_if(g_laneWayNames.begin(), g_laneWayNames.end(),
[&l](pair<LaneWay, string> const & p)
{
return p.first == l;
});
[&l](pair<LaneWay, string> const & p) { return p.first == l; });
if (it == g_laneWayNames.end())
{