diff options
author | Maksim Andrianov <maksimandrianov1@gmail.com> | 2018-09-08 22:18:00 +0300 |
---|---|---|
committer | Sergey Yershov <syershov@maps.me> | 2018-09-11 15:24:50 +0300 |
commit | be62b5dd209cb4b93c68ce0a7566deaaef720699 (patch) | |
tree | 6a97395471a929cb0c85d18f18104b91e1f0afa7 /base | |
parent | ad25c7d85a8a6760f2c6ef6946359f064937fe50 (diff) |
[generator] Added ways to region kv
Diffstat (limited to 'base')
-rw-r--r-- | base/geo_object_id.cpp | 11 | ||||
-rw-r--r-- | base/geo_object_id.hpp | 27 |
2 files changed, 25 insertions, 13 deletions
diff --git a/base/geo_object_id.cpp b/base/geo_object_id.cpp index 5120590be2..adaf312449 100644 --- a/base/geo_object_id.cpp +++ b/base/geo_object_id.cpp @@ -2,6 +2,7 @@ #include "base/assert.hpp" +#include <iostream> #include <sstream> namespace @@ -20,9 +21,7 @@ namespace base GeoObjectId::GeoObjectId(uint64_t encodedId) : m_encodedId(encodedId) {} GeoObjectId::GeoObjectId(GeoObjectId::Type type, uint64_t id) -{ - m_encodedId = (static_cast<uint64_t>(type) << 56) | id; -} + : m_encodedId((static_cast<uint64_t>(type) << 56) | id) {} uint64_t GeoObjectId::GetSerialId() const { @@ -68,6 +67,12 @@ GeoObjectId MakeOsmRelation(uint64_t id) return GeoObjectId(GeoObjectId::Type::ObsoleteOsmRelation, id); } +std::ostream & operator<<(std::ostream & os, GeoObjectId const & geoObjectId) +{ + os << geoObjectId.GetEncodedId(); + return os; +} + std::string DebugPrint(GeoObjectId::Type const & t) { switch (t) diff --git a/base/geo_object_id.hpp b/base/geo_object_id.hpp index 0ad64536c2..8d01f7db0d 100644 --- a/base/geo_object_id.hpp +++ b/base/geo_object_id.hpp @@ -2,6 +2,7 @@ #include <cstdint> #include <functional> +#include <iosfwd> #include <string> namespace base @@ -57,11 +58,10 @@ public: ObsoleteOsmRelation = 0xC0, }; - static const uint64_t kInvalid = 0ULL; + static constexpr uint64_t kInvalid = 0ULL; explicit GeoObjectId(uint64_t encodedId = kInvalid); - - GeoObjectId(Type type, uint64_t id); + explicit GeoObjectId(GeoObjectId::Type type, uint64_t id); // Returns the id that the object has within its source. uint64_t GetSerialId() const; @@ -81,13 +81,7 @@ private: uint64_t m_encodedId; }; -struct HashGeoObjectId : private std::hash<uint64_t> -{ - size_t operator()(GeoObjectId const & id) const - { - return std::hash<uint64_t>::operator()(id.GetEncodedId()); - } -}; +std::ostream & operator<<(std::ostream & os, GeoObjectId const & geoObjectId); // Helper functions for readability. GeoObjectId MakeOsmNode(uint64_t id); @@ -97,3 +91,16 @@ GeoObjectId MakeOsmRelation(uint64_t id); std::string DebugPrint(GeoObjectId::Type const & t); std::string DebugPrint(GeoObjectId const & id); } // namespace base + +namespace std +{ +template <> +struct hash<base::GeoObjectId> +{ + std::size_t operator()(base::GeoObjectId const & k) const + { + auto const hash = std::hash<uint64_t>(); + return hash(k.GetEncodedId()); + } +}; +} // namespace std |