From 713299c429ab494e4cc3347d9dcd76b67ba2522c Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Tue, 25 Feb 2020 10:19:56 +0200 Subject: [core] Add layer serialization method --- include/mbgl/style/filter.hpp | 2 ++ include/mbgl/style/layer.hpp | 2 ++ include/mbgl/style/layers/layer.hpp.ejs | 1 + 3 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp index c9dc9fb1ec..e0623a20d4 100644 --- a/include/mbgl/style/filter.hpp +++ b/include/mbgl/style/filter.hpp @@ -28,6 +28,8 @@ public: bool operator()(const expression::EvaluationContext& context) const; + operator bool() const { return expression || legacyFilter; } + friend bool operator==(const Filter& lhs, const Filter& rhs) { if (!lhs.expression || !rhs.expression) { return lhs.expression == rhs.expression; diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index c80312bc23..840ef9ce88 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -114,6 +114,7 @@ public: optional setVisibility(const conversion::Convertible& value); virtual StyleProperty getProperty(const std::string&) const = 0; + virtual Value serialize() const; // Private implementation // TODO : We should not have public mutable data members. @@ -140,6 +141,7 @@ public: protected: virtual Mutable mutableBaseImpl() const = 0; + void serializeProperty(Value&, const StyleProperty&, const char* propertyName, bool isPaint) const; LayerObserver* observer; mapbox::base::WeakPtrFactory weakFactory {this}; diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs index 3709f53bee..aecbe25601 100644 --- a/include/mbgl/style/layers/layer.hpp.ejs +++ b/include/mbgl/style/layers/layer.hpp.ejs @@ -40,6 +40,7 @@ public: optional setProperty(const std::string& name, const conversion::Convertible& value) final; StyleProperty getProperty(const std::string& name) const final; + Value serialize() const final; <% if (layoutProperties.length) { -%> // Layout properties -- cgit v1.2.1