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

@@ -25,13 +25,16 @@ namespace
{
struct ClearVisitor
{
template<typename Cont>
void operator()(Cont & c, char const * /* name */) const { c.clear(); }
template <typename Cont>
void operator()(Cont & c, char const * /* name */) const
{
c.clear();
}
};
struct SortVisitor
{
template<typename Cont>
template <typename Cont>
void operator()(Cont & c, char const * /* name */) const
{
sort(c.begin(), c.end());
@@ -83,7 +86,7 @@ struct CheckSortedVisitor
}
};
template<typename T>
template <typename T>
void Append(vector<T> const & src, vector<T> & dst)
{
dst.insert(dst.end(), src.begin(), src.end());
@@ -143,8 +146,7 @@ void UpdateItems(set<Id> const & ids, vector<Item> & items)
}
template <class Item>
void ReadItems(uint32_t start, uint32_t end, string const & name, NonOwningReaderSource & src,
vector<Item> & items)
void ReadItems(uint32_t start, uint32_t end, string const & name, NonOwningReaderSource & src, vector<Item> & items)
{
Deserializer<NonOwningReaderSource> deserializer(src);
CHECK_EQUAL(src.Pos(), start, ("Wrong", TRANSIT_FILE_TAG, "section format. Table name:", name));
@@ -154,13 +156,11 @@ void ReadItems(uint32_t start, uint32_t end, string const & name, NonOwningReade
}
} // namespace
// DeserializerFromJson ---------------------------------------------------------------------------
DeserializerFromJson::DeserializerFromJson(json_t * node,
OsmIdToFeatureIdsMap const & osmIdToFeatureIds)
: m_node(node), m_osmIdToFeatureIds(osmIdToFeatureIds)
{
}
DeserializerFromJson::DeserializerFromJson(json_t * node, OsmIdToFeatureIdsMap const & osmIdToFeatureIds)
: m_node(node)
, m_osmIdToFeatureIds(osmIdToFeatureIds)
{}
void DeserializerFromJson::operator()(m2::PointD & p, char const * name)
{
@@ -169,7 +169,7 @@ void DeserializerFromJson::operator()(m2::PointD & p, char const * name)
// regular method.
json_t * item = nullptr;
if (name == nullptr)
item = m_node; // Array item case
item = m_node; // Array item case
else
item = base::GetJSONObligatoryField(m_node, name);
@@ -184,8 +184,7 @@ void DeserializerFromJson::operator()(FeatureIdentifiers & id, char const * name
string osmIdStr;
GetField(osmIdStr, name);
uint64_t osmIdNum;
CHECK(strings::to_uint64(osmIdStr, osmIdNum),
("Cann't convert osm id string:", osmIdStr, "to a number."));
CHECK(strings::to_uint64(osmIdStr, osmIdNum), ("Cann't convert osm id string:", osmIdStr, "to a number."));
base::GeoObjectId const osmId(osmIdNum);
auto const it = m_osmIdToFeatureIds.find(osmId);
if (it != m_osmIdToFeatureIds.cend())
@@ -196,8 +195,8 @@ void DeserializerFromJson::operator()(FeatureIdentifiers & id, char const * name
{
// Note. |osmId| corresponds to several feature ids. It may happen in case of stops,
// if a stop is present as a relation. It's a rare case.
LOG(LWARNING, ("Osm id:", osmId, "( encoded", osmId.GetEncodedId(), ") corresponds to",
it->second.size(), "feature ids."));
LOG(LWARNING,
("Osm id:", osmId, "( encoded", osmId.GetEncodedId(), ") corresponds to", it->second.size(), "feature ids."));
}
id.SetFeatureId(it->second[0]);
}
@@ -232,13 +231,12 @@ void GraphData::DeserializeFromJson(base::Json const & root, OsmIdToFeatureIdsMa
// Note. It's possible that two stops are connected with the same line several times
// in the same direction. It happens in Oslo metro (T-banen):
// https://en.wikipedia.org/wiki/Oslo_Metro#/media/File:Oslo_Metro_Map.svg branch 5.
base::SortUnique(m_edges,
[](Edge const & e1, Edge const & e2) {
if (e1 != e2)
return e1 < e2;
return e1.GetWeight() < e2.GetWeight();
},
[](Edge const & e1, Edge const & e2) { return e1 == e2; });
base::SortUnique(m_edges, [](Edge const & e1, Edge const & e2)
{
if (e1 != e2)
return e1 < e2;
return e1.GetWeight() < e2.GetWeight();
}, [](Edge const & e1, Edge const & e2) { return e1 == e2; });
}
void GraphData::Serialize(Writer & writer)
@@ -284,7 +282,8 @@ void GraphData::Serialize(Writer & writer)
void GraphData::DeserializeAll(Reader & reader)
{
DeserializeWith(reader, [this](NonOwningReaderSource & src) {
DeserializeWith(reader, [this](NonOwningReaderSource & src)
{
ReadStops(src);
ReadGates(src);
ReadEdges(src);
@@ -297,7 +296,8 @@ void GraphData::DeserializeAll(Reader & reader)
void GraphData::DeserializeForRouting(Reader & reader)
{
DeserializeWith(reader, [this](NonOwningReaderSource & src) {
DeserializeWith(reader, [this](NonOwningReaderSource & src)
{
ReadStops(src);
ReadGates(src);
ReadEdges(src);
@@ -308,7 +308,8 @@ void GraphData::DeserializeForRouting(Reader & reader)
void GraphData::DeserializeForRendering(Reader & reader)
{
DeserializeWith(reader, [this](NonOwningReaderSource & src) {
DeserializeWith(reader, [this](NonOwningReaderSource & src)
{
ReadStops(src);
src.Skip(m_header.m_transfersOffset - src.Pos());
ReadTransfers(src);
@@ -319,7 +320,8 @@ void GraphData::DeserializeForRendering(Reader & reader)
void GraphData::DeserializeForCrossMwm(Reader & reader)
{
DeserializeWith(reader, [this](NonOwningReaderSource & src) {
DeserializeWith(reader, [this](NonOwningReaderSource & src)
{
ReadStops(src);
src.Skip(m_header.m_edgesOffset - src.Pos());
ReadEdges(src);
@@ -364,8 +366,8 @@ void GraphData::CheckValidSortedUnique() const
bool GraphData::IsEmpty() const
{
// Note. |m_transfers| may be empty if GraphData instance is not empty.
return m_stops.empty() || m_gates.empty() || m_edges.empty() || m_lines.empty()
|| m_shapes.empty() || m_networks.empty();
return m_stops.empty() || m_gates.empty() || m_edges.empty() || m_lines.empty() || m_shapes.empty() ||
m_networks.empty();
}
void GraphData::Sort()
@@ -399,10 +401,8 @@ void GraphData::ClipLines(vector<m2::RegionD> const & borders)
// Set with stop ids with stops which are inside |borders|.
set<StopId> stopIdInside;
for (auto const & stop : m_stops)
{
if (m2::RegionsContain(borders, stop.GetPoint()))
stopIdInside.insert(stop.GetId());
}
set<StopId> hasNeighborInside;
for (auto const & edge : m_edges)
@@ -432,7 +432,8 @@ void GraphData::ClipLines(vector<m2::RegionD> const & borders)
CHECK_EQUAL(ranges.size(), 1, ());
vector<StopId> const & stopIds = ranges[0];
auto it = stopIds.begin();
while (it != stopIds.end()) {
while (it != stopIds.end())
{
while (it != stopIds.end() && stopIdInside.count(*it) == 0)
++it;
auto jt = it;
@@ -445,8 +446,8 @@ void GraphData::ClipLines(vector<m2::RegionD> const & borders)
if (!stopIdsToFill.empty())
{
lines.emplace_back(line.GetId(), line.GetNumber(), line.GetTitle(), line.GetType(),
line.GetColor(), line.GetNetworkId(), stopIdsToFill, line.GetInterval());
lines.emplace_back(line.GetId(), line.GetNumber(), line.GetTitle(), line.GetType(), line.GetColor(),
line.GetNetworkId(), stopIdsToFill, line.GetInterval());
}
}
@@ -458,10 +459,8 @@ void GraphData::ClipStops()
CHECK(is_sorted(m_stops.cbegin(), m_stops.cend()), ());
set<StopId> stopIds;
for (auto const & line : m_lines)
{
for (auto const & range : line.GetStopIds())
stopIds.insert(range.cbegin(), range.cend());
}
UpdateItems(stopIds, m_stops);
}
@@ -492,10 +491,8 @@ void GraphData::ClipEdges()
vector<Edge> edges;
for (auto const & edge : m_edges)
{
if (HasStop(m_stops, edge.GetStop1Id()) && HasStop(m_stops, edge.GetStop2Id()))
edges.push_back(edge);
}
SortVisitor{}(edges, nullptr /* name */);
m_edges.swap(edges);
@@ -515,10 +512,8 @@ void GraphData::ClipShapes()
vector<Shape> shapes;
for (auto const & shape : m_shapes)
{
if (shapeIdInEdges.count(shape.GetId()) != 0)
shapes.push_back(shape);
}
m_shapes.swap(shapes);
}