diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-02-08 15:23:29 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-02-28 16:09:09 -0800 |
commit | 75feda12f17dececadf72986c45af78fe18afc56 (patch) | |
tree | bb68d8bfa883b3d72f696d9a56a9244169610651 /src/mbgl/style/expression/literal.cpp | |
parent | f4833a2c4e760aac8f461110135e8180c63e0782 (diff) | |
download | qtlocation-mapboxgl-75feda12f17dececadf72986c45af78fe18afc56.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/literal.cpp')
-rw-r--r-- | src/mbgl/style/expression/literal.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/literal.cpp b/src/mbgl/style/expression/literal.cpp index 7e79fcbfe6..8a63980dba 100644 --- a/src/mbgl/style/expression/literal.cpp +++ b/src/mbgl/style/expression/literal.cpp @@ -102,6 +102,14 @@ ParseResult Literal::parse(const Convertible& value, ParsingContext& ctx) { } } +mbgl::Value Literal::serialize() const { + if (getType().is<type::Array>() || getType().is<type::ObjectType>()) { + return std::vector<mbgl::Value>{{ getOperator(), *fromExpressionValue<mbgl::Value>(value) }}; + } else { + return *fromExpressionValue<mbgl::Value>(value); + } +} + } // namespace expression } // namespace style } // namespace mbgl |