summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLValueEvaluator.h
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-08-17 13:38:02 +0200
committerFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-09-02 22:42:05 +0200
commitd77a13eb7320722c48c8a18240adf99615c4b85f (patch)
tree1017781b310e434f943e4ad38b57f319ad7a3a58 /platform/darwin/src/MGLValueEvaluator.h
parent6a39cf5aaece81c7a531b12321dd503004cc45b8 (diff)
downloadqtlocation-mapboxgl-d77a13eb7320722c48c8a18240adf99615c4b85f.tar.gz
[ios] Added support for filters (NSPredicate)
[ios, macos] cleaned up filters [ios] added a filter example [ios] utest filters [ios, macos] nested predicates [ios] refactored [ios] filter -> NSPredicate [ios] fixed mbgl::Any/AllFilter -> NSPredicate [ios] translate nested mbgl::NotIn filters [ios] cleanup and added more utests [ios] fixed a bug in the None filter conversion and improved utests [ios, macos] doc [macos] added missing category [ios, macos] additional utests [ios, macos] updated documentation
Diffstat (limited to 'platform/darwin/src/MGLValueEvaluator.h')
-rw-r--r--platform/darwin/src/MGLValueEvaluator.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLValueEvaluator.h b/platform/darwin/src/MGLValueEvaluator.h
new file mode 100644
index 0000000000..b53cdaa8d2
--- /dev/null
+++ b/platform/darwin/src/MGLValueEvaluator.h
@@ -0,0 +1,49 @@
+#import <Foundation/Foundation.h>
+
+#import <mbgl/util/geometry.hpp>
+
+/**
+ Recursively transforms a C++ type into the corresponding Foundation type.
+ */
+class ValueEvaluator {
+public:
+ id operator()(const mbgl::NullValue &) const {
+ return [NSNull null];
+ }
+
+ id operator()(const bool &value) const {
+ return value ? @YES : @NO;
+ }
+
+ id operator()(const uint64_t &value) const {
+ return @(value);
+ }
+
+ id operator()(const int64_t &value) const {
+ return @(value);
+ }
+
+ id operator()(const double &value) const {
+ return @(value);
+ }
+
+ id operator()(const std::string &value) const {
+ return @(value.c_str());
+ }
+
+ id operator()(const std::vector<mbgl::Value> &values) const {
+ NSMutableArray *objects = [NSMutableArray arrayWithCapacity:values.size()];
+ for (const auto &v : values) {
+ [objects addObject:mbgl::Value::visit(v, *this)];
+ }
+ return objects;
+ }
+
+ id operator()(const std::unordered_map<std::string, mbgl::Value> &items) const {
+ NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:items.size()];
+ for (auto &item : items) {
+ attributes[@(item.first.c_str())] = mbgl::Value::visit(item.second, *this);
+ }
+ return attributes;
+ }
+};