diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/expression/compound_expression.cpp | 13 | ||||
-rw-r--r-- | src/mbgl/style/expression/value.cpp | 9 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 6e87167d5a..f5cbd7030b 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -310,12 +310,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("typeof", [](const Value& v) -> Result<std::string> { return toString(typeOf(v)); }); define("to-string", [](const Value& value) -> Result<std::string> { - return value.match( - [](const NullValue&) -> Result<std::string> { return std::string(); }, - [](const Color& c) -> Result<std::string> { return c.stringify(); }, // avoid quoting - [](const std::string& s) -> Result<std::string> { return s; }, // avoid quoting - [](const auto& v) -> Result<std::string> { return stringify(v); } - ); + return toString(value); }); define("to-boolean", [](const Value& v) -> Result<bool> { @@ -507,10 +502,10 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("downcase", [](const std::string& input) -> Result<std::string> { return platform::lowercase(input); }); - define("concat", [](const Varargs<std::string>& args) -> Result<std::string> { + define("concat", [](const Varargs<Value>& args) -> Result<std::string> { std::string s; - for (const std::string& arg : args) { - s += arg; + for (const Value& arg : args) { + s += toString(arg); } return s; }); diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp index f089c918cd..4bac8116c2 100644 --- a/src/mbgl/style/expression/value.cpp +++ b/src/mbgl/style/expression/value.cpp @@ -34,6 +34,15 @@ type::Type typeOf(const Value& value) { ); } +std::string toString(const Value& value) { + return value.match( + [](const NullValue&) { return std::string(); }, + [](const Color& c) { return c.stringify(); }, // avoid quoting + [](const std::string& s) { return s; }, // avoid quoting + [](const auto& v_) { return stringify(v_); } + ); +} + void writeJSON(rapidjson::Writer<rapidjson::StringBuffer>& writer, const Value& value) { value.match( [&] (const NullValue&) { writer.Null(); }, |