summaryrefslogtreecommitdiff
path: root/src
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 /src
parent34ab7be2251bc8f6afca29c7a2ce3b6f1bc7cb10 (diff)
downloadqtlocation-mapboxgl-f3146e43cd19bdf85957d6d62132ac7c31eacc50.tar.gz
[core] ValueFactory for `expression::formatted`, other improvements
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/expression/formatted.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/formatted.cpp b/src/mbgl/style/expression/formatted.cpp
index 5d45806ecb..4591a50ed1 100644
--- a/src/mbgl/style/expression/formatted.cpp
+++ b/src/mbgl/style/expression/formatted.cpp
@@ -35,6 +35,35 @@ std::string Formatted::toString() const {
return result;
}
+mbgl::Value Formatted::toObject() const {
+ mapbox::base::ValueObject result;
+ mapbox::base::ValueArray sectionValues;
+ sectionValues.reserve(sections.size());
+ for (const auto& section : sections) {
+ mapbox::base::ValueObject 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());
+ }
+ sectionValues.emplace_back(serializedSection);
+ }
+ result.emplace("sections", std::move(sectionValues));
+ return result;
+}
+
} // namespace expression
namespace conversion {