#pragma once #include #include #include #include #include #include #include namespace mbgl { namespace style { namespace expression { extern const char* const kFormattedSectionFontScale; extern const char* const kFormattedSectionTextFont; extern const char* const kFormattedSectionTextColor; struct FormattedSection { explicit FormattedSection(std::string text_, std::optional fontScale_, std::optional fontStack_, std::optional textColor_) : text(std::move(text_)), fontScale(std::move(fontScale_)), fontStack(std::move(fontStack_)), textColor(std::move(textColor_)) {} explicit FormattedSection(Image image_) : image(std::move(image_)) {} std::string text; std::optional image; std::optional fontScale; std::optional fontStack; std::optional textColor; }; class Formatted { public: Formatted() = default; Formatted(const char* plainU8String) { sections.emplace_back(std::string(plainU8String), std::nullopt, std::nullopt, std::nullopt); } Formatted(std::vector sections_) : sections(std::move(sections_)) {} bool operator==(const Formatted&) const; std::string toString() const; mbgl::Value toObject() const; bool empty() const; std::vector sections; }; } // namespace expression namespace conversion { template <> struct Converter { public: std::optional operator()(const Convertible& value, Error& error) const; }; template <> struct ValueFactory { static Value make(const expression::Formatted& formatted) { return formatted.toObject(); } }; } // namespace conversion } // namespace style } // namespace mbgl