#pragma once #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 kFormattedSectionID; using FormattedSectionID = variant; template optional toFormattedSectionID(const Variant& variant) { return variant.match( [] (double t) -> FormattedSectionID { return t; }, [] (const std::string& t) -> FormattedSectionID { return t;}, [] (const auto&) -> optional { return nullopt; }); } struct FormattedSection { FormattedSection(std::string text_, optional fontScale_, optional fontStack_, optional id_) : text(std::move(text_)) , fontScale(std::move(fontScale_)) , fontStack(std::move(fontStack_)) , id(std::move(id_)) {} std::string text; optional fontScale; optional fontStack; optional id; }; class Formatted { public: Formatted() = default; Formatted(const char* plainU8String) { sections.emplace_back(std::string(plainU8String), nullopt, nullopt, nullopt); } Formatted(std::vector sections_) : sections(std::move(sections_)) {} bool operator==(const Formatted& ) const; std::string toString() const; bool empty() const { return sections.empty() || sections.at(0).text.empty(); } std::vector sections; }; } // namespace expression namespace conversion { template <> struct Converter { public: optional operator()(const Convertible& value, Error& error) const; }; } // namespace conversion } // namespace style } // namespace mbgl