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 /include/mbgl/style/expression/compound_expression.hpp | |
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 'include/mbgl/style/expression/compound_expression.hpp')
-rw-r--r-- | include/mbgl/style/expression/compound_expression.hpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/include/mbgl/style/expression/compound_expression.hpp b/include/mbgl/style/expression/compound_expression.hpp index 8b74027578..6baaae862f 100644 --- a/include/mbgl/style/expression/compound_expression.hpp +++ b/include/mbgl/style/expression/compound_expression.hpp @@ -40,14 +40,16 @@ namespace detail { // each CompoundExpression definition's type::Type data from the type of its // "evaluate" function. struct SignatureBase { - SignatureBase(type::Type result_, variant<std::vector<type::Type>, VarargsType> params_) : + SignatureBase(type::Type result_, variant<std::vector<type::Type>, VarargsType> params_, std::string name_) : result(std::move(result_)), - params(std::move(params_)) + params(std::move(params_)), + name(std::move(name_)) {} virtual ~SignatureBase() = default; - virtual std::unique_ptr<Expression> makeExpression(const std::string& name, std::vector<std::unique_ptr<Expression>>) const = 0; + virtual std::unique_ptr<Expression> makeExpression(std::vector<std::unique_ptr<Expression>>) const = 0; type::Type result; variant<std::vector<type::Type>, VarargsType> params; + std::string name; }; } // namespace detail @@ -111,6 +113,10 @@ public: } return false; } + + std::string getOperator() const override { + return signature.name; + } private: Signature signature; @@ -128,8 +134,7 @@ struct CompoundExpressionRegistry { ParseResult parseCompoundExpression(const std::string name, const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); -ParseResult createCompoundExpression(const std::string& name, - const CompoundExpressionRegistry::Definition& definition, +ParseResult createCompoundExpression(const CompoundExpressionRegistry::Definition& definition, std::vector<std::unique_ptr<Expression>> args, ParsingContext& ctx); |