Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorMaksim Andrianov <maksimandrianov1@gmail.com>2018-09-08 22:18:00 +0300
committerSergey Yershov <syershov@maps.me>2018-09-11 15:24:50 +0300
commitbe62b5dd209cb4b93c68ce0a7566deaaef720699 (patch)
tree6a97395471a929cb0c85d18f18104b91e1f0afa7 /base
parentad25c7d85a8a6760f2c6ef6946359f064937fe50 (diff)
[generator] Added ways to region kv
Diffstat (limited to 'base')
-rw-r--r--base/geo_object_id.cpp11
-rw-r--r--base/geo_object_id.hpp27
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