Allow to output FormattedText to StringBuilder.

GitOrigin-RevId: 8ffffb2305ebe531f5dcb9118f9333367afb1238
This commit is contained in:
levlam 2020-03-11 04:09:23 +03:00
parent 1433b3d82a
commit ee0e60e097
2 changed files with 10 additions and 4 deletions

View File

@ -149,6 +149,14 @@ vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<
return result;
}
StringBuilder &operator<<(StringBuilder &string_builder, const FormattedText &text) {
return string_builder << '"' << text.text << "\" with entities " << text.entities;
}
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text) {
return td_api::make_object<td_api::formattedText>(text.text, get_text_entities_object(text.entities));
}
static bool is_word_character(uint32 code) {
switch (get_unicode_simple_category(code)) {
case UnicodeSimpleCategory::Letter:
@ -160,10 +168,6 @@ static bool is_word_character(uint32 code) {
}
}
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text) {
return td_api::make_object<td_api::formattedText>(text.text, get_text_entities_object(text.entities));
}
/*
static bool is_word_boundary(uint32 a, uint32 b) {
return is_word_character(a) ^ is_word_character(b);

View File

@ -113,6 +113,8 @@ struct FormattedText {
void parse(ParserT &parser);
};
StringBuilder &operator<<(StringBuilder &string_builder, const FormattedText &text);
inline bool operator==(const FormattedText &lhs, const FormattedText &rhs) {
return lhs.text == rhs.text && lhs.entities == rhs.entities;
}