summaryrefslogtreecommitdiff
path: root/include/mbgl/style/expression/expression.hpp
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-02-08 15:23:29 -0800
committerChris Loer <chris.loer@mapbox.com>2018-02-16 14:07:33 -0800
commit8635dab4c38fcd67962819224093d0be95f5ed43 (patch)
treeac9d769aabbce2c01b4dc932ec9686b8647fd0c7 /include/mbgl/style/expression/expression.hpp
parent341eb7645f98fb1835607dbe68b2bd74b0f6ec8a (diff)
downloadqtlocation-mapboxgl-8635dab4c38fcd67962819224093d0be95f5ed43.tar.gz
[core] Implement Expression::serialize()
Issue #10714 - Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...] - Custom implementations of `serialize` for Expression types that don't follow the pattern - expression::Value -> mbgl::Value converter - node_expression bindings to expose `serialize`
Diffstat (limited to 'include/mbgl/style/expression/expression.hpp')
-rw-r--r--include/mbgl/style/expression/expression.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/mbgl/style/expression/expression.hpp b/include/mbgl/style/expression/expression.hpp
index cf9fa0cb21..c41ac0b5f1 100644
--- a/include/mbgl/style/expression/expression.hpp
+++ b/include/mbgl/style/expression/expression.hpp
@@ -135,6 +135,17 @@ public:
* complete set of outputs is statically undecidable.
*/
virtual std::vector<optional<Value>> possibleOutputs() const = 0;
+
+ virtual mbgl::Value serialize() const {
+ std::vector<mbgl::Value> serialized;
+ serialized.emplace_back(getOperator());
+ eachChild([&](const Expression &child) {
+ serialized.emplace_back(child.serialize());
+ });
+ return serialized;
+ };
+
+ virtual std::string getOperator() const = 0;
protected:
template <typename T>