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/coding
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-10-25 16:00:22 +0300
committerTatiana Yan <tatiana.kondakova@gmail.com>2018-10-26 17:10:18 +0300
commitbf1693e86e4fd1a447ad6017a4b5826340ca2d7d (patch)
tree76d32f6fd20c5589e8f16207f35bc3ff501f76ca /coding
parente2f510d63a64d609aa64c4c3634175ea96d67bef (diff)
[eye] map object events serdes+storage+migration
Diffstat (limited to 'coding')
-rw-r--r--coding/serdes_json.hpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/coding/serdes_json.hpp b/coding/serdes_json.hpp
index c570a84a51..cedcd56acf 100644
--- a/coding/serdes_json.hpp
+++ b/coding/serdes_json.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "geometry/latlon.hpp"
+
#include "base/exception.hpp"
#include "base/scope_guard.hpp"
@@ -130,6 +132,14 @@ public:
(*this)(static_cast<std::underlying_type_t<T>>(t), name);
}
+ void operator()(ms::LatLon const & ll, char const * name = nullptr)
+ {
+ NewScopeWith(base::NewJSONObject(), name, [this, &ll] {
+ (*this)(ll.lat, "lat");
+ (*this)(ll.lon, "lon");
+ });
+ }
+
protected:
template <typename Fn>
void NewScopeWith(base::JSONPtr json_object, char const * name, Fn && fn)
@@ -218,8 +228,8 @@ public:
RestoreContext(outerContext);
}
- template <typename T>
- void operator()(std::unordered_set<T> & dest, char const * name = nullptr)
+ template <typename T, typename H>
+ void operator()(std::unordered_set<T, H> & dest, char const * name = nullptr)
{
json_t * outerContext = SaveContext(name);
@@ -241,6 +251,12 @@ public:
RestoreContext(outerContext);
}
+ template <typename T>
+ void operator()(std::unordered_set<T> & dest, char const * name = nullptr)
+ {
+ (*this)<std::unordered_set<T>::key_type, std::unordered_set<T>::hasher>(dest, name);
+ }
+
template <typename T, size_t N>
void operator()(std::array<T, N> & dst, char const * name = nullptr)
{
@@ -314,6 +330,14 @@ public:
t = static_cast<T>(res);
}
+ void operator()(ms::LatLon & ll, char const * name = nullptr)
+ {
+ json_t * outerContext = SaveContext(name);
+ (*this)(ll.lat, "lat");
+ (*this)(ll.lon, "lon");
+ RestoreContext(outerContext);
+ }
+
protected:
json_t * SaveContext(char const * name = nullptr)
{