#pragma once #include #include #include #include #include #include #include #include #include namespace mbgl { namespace style { namespace conversion { template struct Converter> { optional> operator()(const Convertible& value, Error& error, bool allowDataExpressions, bool convertTokens) const; template PropertyValue maybeConvertTokens(const S& t) const { return PropertyValue(t); }; PropertyValue maybeConvertTokens(const std::string& t) const { return hasTokens(t) ? PropertyValue(PropertyExpression(convertTokenStringToExpression(t))) : PropertyValue(t); } PropertyValue maybeConvertTokens(const expression::Formatted& t) const { // This only works with a single-section `Formatted` created automatically // by parsing a plain-text `text-field` property. // Token conversion happens later than the initial string->Formatted conversion // General purpose `format` expressions with embedded tokens are not supported const std::string& firstUnformattedSection = t.sections[0].text; return hasTokens(firstUnformattedSection) ? PropertyValue(PropertyExpression(convertTokenStringToFormatExpression(firstUnformattedSection))) : PropertyValue(t); } }; } // namespace conversion } // namespace style } // namespace mbgl