summaryrefslogtreecommitdiff
path: root/expression-test
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-26 17:53:49 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-27 13:08:53 +0300
commitf3146e43cd19bdf85957d6d62132ac7c31eacc50 (patch)
tree34ba28b265d95911ccc07915b5162eb8edeba792 /expression-test
parent34ab7be2251bc8f6afca29c7a2ce3b6f1bc7cb10 (diff)
downloadqtlocation-mapboxgl-f3146e43cd19bdf85957d6d62132ac7c31eacc50.tar.gz
[core] ValueFactory for `expression::formatted`, other improvements
Diffstat (limited to 'expression-test')
-rw-r--r--expression-test/expression_test_parser.cpp28
1 files changed, 1 insertions, 27 deletions
diff --git a/expression-test/expression_test_parser.cpp b/expression-test/expression_test_parser.cpp
index 3c194ffee0..546a96b3e0 100644
--- a/expression-test/expression_test_parser.cpp
+++ b/expression-test/expression_test_parser.cpp
@@ -439,33 +439,7 @@ optional<Value> toValue(const expression::Value& exprValue) {
std::vector<Value> color { double(c.r), double(c.g), double(c.b), double(c.a) };
return {Value{std::move(color)}};
},
- [](const expression::Formatted& formatted) -> optional<Value> {
- std::unordered_map<std::string, Value> serialized;
- std::vector<Value> sections;
- for (const auto& section : formatted.sections) {
- std::unordered_map<std::string, Value> serializedSection;
- serializedSection.emplace("text", section.text);
- if (section.fontScale) {
- serializedSection.emplace("scale", *section.fontScale);
- } else {
- serializedSection.emplace("scale", NullValue());
- }
- if (section.fontStack) {
- std::string fontStackString;
- serializedSection.emplace("fontStack", fontStackToString(*section.fontStack));
- } else {
- serializedSection.emplace("fontStack", NullValue());
- }
- if (section.textColor) {
- serializedSection.emplace("textColor", section.textColor->toObject());
- } else {
- serializedSection.emplace("textColor", NullValue());
- }
- sections.emplace_back(serializedSection);
- }
- serialized.emplace("sections", sections);
- return {Value{std::move(serialized)}};
- },
+ [](const expression::Formatted& formatted) -> optional<Value> { return {formatted.toObject()}; },
[](const std::vector<expression::Value>& values) -> optional<Value> {
std::vector<Value> mbglValues;
for (const auto& value : values) {