// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/telegram/files/FileId.h" #include "td/telegram/logevent/LogEvent.h" #include "td/telegram/Photo.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/utils/common.h" #include "td/utils/FlatHashMap.h" #include "td/utils/Slice.h" namespace td { struct GetWebPageBlockObjectContext; class Td; class WebPageBlock { protected: enum class Type : int32 { Title, Subtitle, AuthorDate, Header, Subheader, Paragraph, Preformatted, Footer, Divider, Anchor, List, BlockQuote, PullQuote, Animation, Photo, Video, Cover, Embedded, EmbeddedPost, Collage, Slideshow, ChatLink, Audio, Kicker, Table, Details, RelatedArticles, Map, VoiceNote, Size }; virtual Type get_type() const = 0; template static void call_impl(Type type, const WebPageBlock *ptr, F &&f); template void store(StorerT &storer) const; template static unique_ptr parse(ParserT &parser); template friend void store_web_page_block(const unique_ptr &block, StorerT &storer); template friend void parse_web_page_block(unique_ptr &block, ParserT &parser); using Context = GetWebPageBlockObjectContext; public: WebPageBlock() = default; WebPageBlock(const WebPageBlock &) = delete; WebPageBlock &operator=(const WebPageBlock &) = delete; WebPageBlock(WebPageBlock &&) = delete; WebPageBlock &operator=(WebPageBlock &&) = delete; virtual ~WebPageBlock() = default; virtual void append_file_ids(const Td *td, vector &file_ids) const = 0; virtual td_api::object_ptr get_page_block_object(Context *context) const = 0; }; void store(const unique_ptr &block, LogEventStorerCalcLength &storer); void store(const unique_ptr &block, LogEventStorerUnsafe &storer); void parse(unique_ptr &block, LogEventParser &parser); vector> get_web_page_blocks( Td *td, vector> page_block_ptrs, const FlatHashMap &animations, const FlatHashMap &audios, const FlatHashMap &documents, const FlatHashMap> &photos, const FlatHashMap &videos, const FlatHashMap &voice_notes); vector> get_page_blocks_object( const vector> &page_blocks, Td *td, Slice base_url, Slice real_url); } // namespace td