diff options
author | Lucas Wojciechowski <lucas@mapbox.com> | 2018-04-23 13:45:02 -0700 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-05-09 16:08:50 -0700 |
commit | 8dd21f0107180ce3837a7c2edf551e5be575e1dc (patch) | |
tree | b540d753cf90bb12cecda64ea1392b0640b6f69e | |
parent | d043b22825c409f26e7fc918da8d691acb9ea039 (diff) | |
download | qtlocation-mapboxgl-8dd21f0107180ce3837a7c2edf551e5be575e1dc.tar.gz |
Add convienience overload of `createCompoundExpression` which doesn't need an arg vector
-rw-r--r-- | include/mbgl/style/expression/compound_expression.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/style/expression/compound_expression.cpp | 18 | ||||
-rw-r--r-- | test/style/conversion/stringify.test.cpp | 5 |
3 files changed, 29 insertions, 4 deletions
diff --git a/include/mbgl/style/expression/compound_expression.hpp b/include/mbgl/style/expression/compound_expression.hpp index 6baaae862f..adb7a3ac71 100644 --- a/include/mbgl/style/expression/compound_expression.hpp +++ b/include/mbgl/style/expression/compound_expression.hpp @@ -142,6 +142,16 @@ ParseResult createCompoundExpression(const std::string& name, std::vector<std::unique_ptr<Expression>> args, ParsingContext& ctx); +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + ParsingContext& ctx); + + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + std::unique_ptr<Expression> arg2, + ParsingContext& ctx); + } // namespace expression } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 2937aed820..fb28eaf383 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -706,6 +706,24 @@ ParseResult createCompoundExpression(const Definition& definition, return ParseResult(); } + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + ParsingContext& ctx) { + std::vector<std::unique_ptr<Expression>> args; + args.push_back(std::move(arg1)); + return createCompoundExpression(name, std::move(args), ctx); +} + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + std::unique_ptr<Expression> arg2, + ParsingContext& ctx) { + std::vector<std::unique_ptr<Expression>> args; + args.push_back(std::move(arg1)); + args.push_back(std::move(arg2)); + return createCompoundExpression(name, std::move(args), ctx); +} } // namespace expression } // namespace style diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp index d84f556785..851301d515 100644 --- a/test/style/conversion/stringify.test.cpp +++ b/test/style/conversion/stringify.test.cpp @@ -78,10 +78,7 @@ TEST(Stringify, Filter) { ASSERT_EQ(stringify(Filter()), "null"); expression::ParsingContext context; - std::vector<std::unique_ptr<expression::Expression>> args; - args.push_back(std::make_unique<expression::Literal>(std::string("a"))); - args.push_back(std::make_unique<expression::Literal>(1.0)); - ASSERT_EQ(stringify(Filter(expression::createCompoundExpression("filter-==", std::move(args), context))), "[\"filter-==\",\"a\",1.0]"); + ASSERT_EQ(stringify(Filter(expression::createCompoundExpression("filter-==", std::make_unique<expression::Literal>(std::string("a")), std::make_unique<expression::Literal>(1.0), context))), "[\"filter-==\",\"a\",1.0]"); } TEST(Stringify, CameraFunction) { |