From ee0e60e09749e65101895572bea50921429c7a1c Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 11 Mar 2020 04:09:23 +0300 Subject: [PATCH] Allow to output FormattedText to StringBuilder. GitOrigin-RevId: 8ffffb2305ebe531f5dcb9118f9333367afb1238 --- td/telegram/MessageEntity.cpp | 12 ++++++++---- td/telegram/MessageEntity.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 7bc3cf6b..907d4a8a 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -149,6 +149,14 @@ vector> 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 get_formatted_text_object(const FormattedText &text) { + return td_api::make_object(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 get_formatted_text_object(const FormattedText &text) { - return td_api::make_object(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); diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index 437909d6..47ad7302 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -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; }