summaryrefslogtreecommitdiff
path: root/include/mbgl/style
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-06-29 12:56:44 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-07-23 09:12:26 -0700
commit1d8664a2ae3822ba4d45973640c0068c65a237e7 (patch)
tree62160340b72f987ac340c5807552a7033e9269ac /include/mbgl/style
parentbfe714eebe1fd5a8563db92e46220775aa82e3e0 (diff)
downloadqtlocation-mapboxgl-1d8664a2ae3822ba4d45973640c0068c65a237e7.tar.gz
Keep original input for filters using legacy syntax.
Diffstat (limited to 'include/mbgl/style')
-rw-r--r--include/mbgl/style/filter.hpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp
index ce4015bb69..c9dc9fb1ec 100644
--- a/include/mbgl/style/filter.hpp
+++ b/include/mbgl/style/filter.hpp
@@ -11,14 +11,18 @@
namespace mbgl {
namespace style {
-
+
class Filter {
public:
optional<std::shared_ptr<const expression::Expression>> expression;
-
+private:
+ optional<mbgl::Value> legacyFilter;
+public:
Filter() : expression() {}
- Filter(expression::ParseResult _expression) : expression(std::move(*_expression)) {
+ Filter(expression::ParseResult _expression, optional<mbgl::Value> _filter = {})
+ : expression(std::move(*_expression)),
+ legacyFilter(std::move(_filter)){
assert(!expression || *expression != nullptr);
}
@@ -35,6 +39,16 @@ public:
friend bool operator!=(const Filter& lhs, const Filter& rhs) {
return !(lhs == rhs);
}
+
+ mbgl::Value serialize() const {
+ if (legacyFilter) {
+ return *legacyFilter;
+ }
+ else if (expression) {
+ return (**expression).serialize();
+ }
+ return NullValue();
+ }
};
} // namespace style