From 0aa0f7f17dd0198f710b022326446ae6e863bf9a Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Fri, 12 May 2017 15:31:35 +0300 Subject: [PATCH] review fixes --- base/stl_add.hpp | 2 +- generator/altitude_generator.cpp | 2 +- generator/booking_dataset.cpp | 8 ++++---- .../booking_quality_check/booking_addr_match.cpp | 4 ++-- generator/borders_generator.cpp | 1 + generator/generator_tests/osm_type_test.cpp | 7 ++++--- generator/intermediate_data.hpp | 5 ++--- generator/restaurants_info/restaurants_info.cpp | 2 +- generator/restriction_generator.cpp | 3 ++- generator/restriction_writer.cpp | 2 +- generator/routing_helpers.cpp | 6 +++--- generator/sponsored_dataset.hpp | 14 ++++++++------ 12 files changed, 30 insertions(+), 26 deletions(-) diff --git a/base/stl_add.hpp b/base/stl_add.hpp index 34bc821ab6..3051617b46 100644 --- a/base/stl_add.hpp +++ b/base/stl_add.hpp @@ -8,7 +8,7 @@ namespace my { -typedef std::initializer_list StringIL; +using StringIL = std::initializer_list; /// @todo(y): replace this hand-written helper function by /// std::make_unique when it will be available in C++14 diff --git a/generator/altitude_generator.cpp b/generator/altitude_generator.cpp index cca34b39c1..13c8dd1442 100644 --- a/generator/altitude_generator.cpp +++ b/generator/altitude_generator.cpp @@ -142,7 +142,7 @@ public: bool IsFeatureAltitudesSorted() { return std::is_sorted(m_featureAltitudes.begin(), m_featureAltitudes.end(), - my::LessBy(&Processor::FeatureAltitude::m_featureId)); + my::LessBy(&Processor::FeatureAltitude::m_featureId)); } private: diff --git a/generator/booking_dataset.cpp b/generator/booking_dataset.cpp index 1366e32456..30b088c221 100644 --- a/generator/booking_dataset.cpp +++ b/generator/booking_dataset.cpp @@ -17,7 +17,7 @@ namespace generator // BookingHotel ------------------------------------------------------------------------------------ BookingHotel::BookingHotel(std::string const & src) { - vector rec; + std::vector rec; strings::ParseCSVRow(src, '\t', rec); CHECK_EQUAL(rec.size(), FieldsCount(), ("Error parsing hotels.tsv line:", boost::replace_all_copy(src, "\t", "\\t"))); @@ -62,7 +62,7 @@ bool BookingDataset::NecessaryMatchingConditionHolds(FeatureBuilder1 const & fb) template <> void BookingDataset::PreprocessMatchedOsmObject(ObjectId, FeatureBuilder1 & fb, - function const fn) const + std::function const fn) const { // Turn a hotel into a simple building. if (fb.GetGeomType() == feature::GEOM_AREA) @@ -89,7 +89,7 @@ void BookingDataset::PreprocessMatchedOsmObject(ObjectId, FeatureBuilder1 & fb, template <> void BookingDataset::BuildObject(Object const & hotel, - function const & fn) const + std::function const & fn) const { FeatureBuilder1 fb; FeatureParams params; @@ -117,7 +117,7 @@ void BookingDataset::BuildObject(Object const & hotel, if (!hotel.m_translations.empty()) { // TODO(mgsergio): Move parsing to the hotel costruction stage. - vector parts; + std::vector parts; strings::ParseCSVRow(hotel.m_translations, '|', parts); CHECK_EQUAL(parts.size() % 3, 0, ("Invalid translation string:", hotel.m_translations)); for (size_t i = 0; i < parts.size(); i += 3) diff --git a/generator/booking_quality_check/booking_addr_match.cpp b/generator/booking_quality_check/booking_addr_match.cpp index 1f97a78780..8b491b6144 100644 --- a/generator/booking_quality_check/booking_addr_match.cpp +++ b/generator/booking_quality_check/booking_addr_match.cpp @@ -92,12 +92,12 @@ int main(int argc, char * argv[]) ++matchedNum; std::cout << "[" << i << "/" << bookingDataset.Size() << "] Hotel: " << hotel.address << " AddLoc: " << hotel.translations << " --> " << hotel.street << " " - << hotel.houseNumber << endl; + << hotel.houseNumber << std::endl; } } std::cout << "Num of hotels: " << bookingDataset.Size() << " matched: " << matchedNum - << " Empty addresses: " << emptyAddr << endl; + << " Empty addresses: " << emptyAddr << std::endl; return 0; } diff --git a/generator/borders_generator.cpp b/generator/borders_generator.cpp index 6682f8f996..b884c938cb 100644 --- a/generator/borders_generator.cpp +++ b/generator/borders_generator.cpp @@ -4,6 +4,7 @@ #include "base/logging.hpp" #include "base/string_utils.hpp" + #include #include #include diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index f7ab669f77..00af901795 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -42,11 +42,11 @@ UNIT_TEST(OsmType_SkipDummy) namespace { - void DumpTypes(vector const & v) + void DumpTypes(std::vector const & v) { Classificator const & c = classif(); for (size_t i = 0; i < v.size(); ++i) - std::cout << c.GetFullObjectName(v[i]) << endl; + std::cout << c.GetFullObjectName(v[i]) << std::endl; } void DumpParsedTypes(char const * arr[][2], size_t count) @@ -60,7 +60,8 @@ namespace DumpTypes(params.m_Types); } - void TestSurfaceTypes(std::string const & surface, std::string const & smoothness, std::string const & grade, char const * value) + void TestSurfaceTypes(std::string const & surface, std::string const & smoothness, + std::string const & grade, char const * value) { OsmElement e; e.AddTag("highway", "unclassified"); diff --git a/generator/intermediate_data.hpp b/generator/intermediate_data.hpp index a0328eb677..42d3fb4fc6 100644 --- a/generator/intermediate_data.hpp +++ b/generator/intermediate_data.hpp @@ -12,13 +12,12 @@ #include #include #include +#include #include #include #include #include -#include - #include "defines.hpp" /// Classes for reading and writing any data in file with map of offsets for @@ -192,7 +191,7 @@ public: uint64_t pos = 0; if (!m_offsets.GetValueByKey(id, pos)) { - LOG_SHORT(LWARNING, ("Can't std::find offset in file", m_offsets.GetFileName(), "by id", id)); + LOG_SHORT(LWARNING, ("Can't find offset in file", m_offsets.GetFileName(), "by id", id)); return false; } diff --git a/generator/restaurants_info/restaurants_info.cpp b/generator/restaurants_info/restaurants_info.cpp index 78327b795a..9c36efa076 100644 --- a/generator/restaurants_info/restaurants_info.cpp +++ b/generator/restaurants_info/restaurants_info.cpp @@ -95,7 +95,7 @@ feature::GenerateInfo GetGenerateInfo() return info; } -void DumpRestaurants(std::vector const & features, ostream & out) +void DumpRestaurants(std::vector const & features, std::ostream & out) { for (auto const & f : features) { diff --git a/generator/restriction_generator.cpp b/generator/restriction_generator.cpp index 4db7b0ed87..5b9ba48445 100644 --- a/generator/restriction_generator.cpp +++ b/generator/restriction_generator.cpp @@ -32,7 +32,8 @@ bool BuildRoadRestrictions(std::string const & mwmPath, std::string const & rest auto const firstOnlyIt = std::lower_bound(restrictions.cbegin(), restrictions.cend(), - Restriction(Restriction::Type::Only, {} /* links */), my::LessBy(&Restriction::m_type)); + Restriction(Restriction::Type::Only, {} /* links */), + my::LessBy(&Restriction::m_type)); RestrictionHeader header; header.m_noRestrictionCount = base::checked_cast(std::distance(restrictions.cbegin(), firstOnlyIt)); diff --git a/generator/restriction_writer.cpp b/generator/restriction_writer.cpp index 89ef445d9e..47821e963c 100644 --- a/generator/restriction_writer.cpp +++ b/generator/restriction_writer.cpp @@ -18,7 +18,7 @@ namespace { using namespace routing; -vector> const kRestrictionTypes = +std::vector> const kRestrictionTypes = {{"no_right_turn", Restriction::Type::No}, {"no_left_turn", Restriction::Type::No}, {"no_u_turn", Restriction::Type::No}, {"no_straight_on", Restriction::Type::No}, {"no_entry", Restriction::Type::No}, {"no_exit", Restriction::Type::No}, diff --git a/generator/routing_helpers.cpp b/generator/routing_helpers.cpp index 6e72d210f3..0d5376079a 100644 --- a/generator/routing_helpers.cpp +++ b/generator/routing_helpers.cpp @@ -13,7 +13,7 @@ using std::string; namespace { template -bool ForEachRoadFromFile(std::string const & filename, ToDo && toDo) +bool ForEachRoadFromFile(string const & filename, ToDo && toDo) { gen::OsmID2FeatureID osmIdsToFeatureIds; try @@ -46,7 +46,7 @@ void AddFeatureId(osm::Id osmId, uint32_t featureId, map &osm osmIdToFeatureId.insert(make_pair(osmId, featureId)); } -bool ParseOsmIdToFeatureIdMapping(std::string const & osmIdsToFeatureIdPath, +bool ParseOsmIdToFeatureIdMapping(string const & osmIdsToFeatureIdPath, map & osmIdToFeatureId) { return ForEachRoadFromFile(osmIdsToFeatureIdPath, [&](uint32_t featureId, osm::Id osmId) { @@ -54,7 +54,7 @@ bool ParseOsmIdToFeatureIdMapping(std::string const & osmIdsToFeatureIdPath, }); } -bool ParseFeatureIdToOsmIdMapping(std::string const & osmIdsToFeatureIdPath, +bool ParseFeatureIdToOsmIdMapping(string const & osmIdsToFeatureIdPath, map & featureIdToOsmId) { featureIdToOsmId.clear(); diff --git a/generator/sponsored_dataset.hpp b/generator/sponsored_dataset.hpp index 4527df6a36..9bd0f1daf0 100644 --- a/generator/sponsored_dataset.hpp +++ b/generator/sponsored_dataset.hpp @@ -33,14 +33,16 @@ public: static double constexpr kDistanceLimitInMeters = 150; static size_t constexpr kMaxSelectedElements = 3; - explicit SponsoredDataset(std::string const & dataPath, std::string const & addressReferencePath = std::string()); - explicit SponsoredDataset(istream & dataSource, std::string const & addressReferencePath = std::string()); + explicit SponsoredDataset(std::string const & dataPath, + std::string const & addressReferencePath = std::string()); + explicit SponsoredDataset(std::istream & dataSource, + std::string const & addressReferencePath = std::string()); size_t Size() const { return m_objects.size(); } Object const & GetObjectById(ObjectId id) const; Object & GetObjectById(ObjectId id); - vector GetNearestObjects(ms::LatLon const & latLon, size_t limit, + std::vector GetNearestObjects(ms::LatLon const & latLon, size_t limit, double maxDistance = 0.0) const; /// @return true if |fb| satisfies some necessary conditions to match one or serveral @@ -64,7 +66,7 @@ protected: private: Index m_index; - unique_ptr m_coder; + std::unique_ptr m_coder; }; // TODO(mgsergio): Get rid of Box since boost::rtree supports point as value type. @@ -72,7 +74,7 @@ protected: // instead of boost::geometry::cs::cartesian. using Point = boost::geometry::model::point; using Box = boost::geometry::model::box; - using Value = pair; + using Value = std::pair; // Create the rtree using default constructor. boost::geometry::index::rtree> m_rtree; @@ -80,7 +82,7 @@ protected: void BuildObject(Object const & object, std::function const & fn) const; - void LoadData(istream & src, std::string const & addressReferencePath); + void LoadData(std::istream & src, std::string const & addressReferencePath); /// @return an id of a matched object or kInvalidObjectId on failure. ObjectId FindMatchingObjectIdImpl(FeatureBuilder1 const & fb) const;