summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression/coercion.cpp
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 /src/mbgl/style/expression/coercion.cpp
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 'src/mbgl/style/expression/coercion.cpp')
-rw-r--r--src/mbgl/style/expression/coercion.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/coercion.cpp b/src/mbgl/style/expression/coercion.cpp
index 56ab33fcfd..d9cd3ffdc9 100644
--- a/src/mbgl/style/expression/coercion.cpp
+++ b/src/mbgl/style/expression/coercion.cpp
@@ -81,6 +81,13 @@ Coercion::Coercion(type::Type type_, std::vector<std::unique_ptr<Expression>> in
}
}
+std::string Coercion::getOperator() const {
+ return getType().match(
+ [](const type::NumberType&) { return "to-number"; },
+ [](const type::ColorType&) { return "to-color"; },
+ [](const auto&) { assert(false); return ""; });
+}
+
using namespace mbgl::style::conversion;
ParseResult Coercion::parse(const Convertible& value, ParsingContext& ctx) {
static std::unordered_map<std::string, type::Type> types {