External store and parse for PhotoSizeSource.

GitOrigin-RevId: a00393e74bc083de4e2da6d7f25fec051f0d70fc
This commit is contained in:
levlam 2019-06-19 03:31:04 +03:00
parent 9a77b26a8a
commit e6082852d9
2 changed files with 22 additions and 43 deletions

View File

@ -27,11 +27,6 @@ struct PhotoSizeSource {
FileType file_type; FileType file_type;
int32 thumbnail_type = 0; int32 thumbnail_type = 0;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
}; };
// for dialog photos // for dialog photos
@ -46,11 +41,6 @@ struct PhotoSizeSource {
DialogId dialog_id; DialogId dialog_id;
int64 dialog_access_hash = 0; int64 dialog_access_hash = 0;
bool is_big = false; bool is_big = false;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
}; };
// for sticker set thumbnails // for sticker set thumbnails
@ -66,11 +56,6 @@ struct PhotoSizeSource {
tl_object_ptr<telegram_api::InputStickerSet> get_input_sticker_set() const { tl_object_ptr<telegram_api::InputStickerSet> get_input_sticker_set() const {
return make_tl_object<telegram_api::inputStickerSetID>(sticker_set_id, sticker_set_access_hash); return make_tl_object<telegram_api::inputStickerSetID>(sticker_set_id, sticker_set_access_hash);
} }
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
}; };
PhotoSizeSource() = default; PhotoSizeSource() = default;

View File

@ -13,52 +13,46 @@
namespace td { namespace td {
template <class StorerT> template <class StorerT>
void PhotoSizeSource::Thumbnail::store(StorerT &storer) const { void store(const PhotoSizeSource::Thumbnail &source, StorerT &storer) {
using td::store; store(source.file_type, storer);
store(file_type, storer); store(source.thumbnail_type, storer);
store(thumbnail_type, storer);
} }
template <class ParserT> template <class ParserT>
void PhotoSizeSource::Thumbnail::parse(ParserT &parser) { void parse(PhotoSizeSource::Thumbnail &source, ParserT &parser) {
using td::parse; parse(source.file_type, parser);
parse(file_type, parser); parse(source.thumbnail_type, parser);
parse(thumbnail_type, parser); if (source.thumbnail_type < 0 || source.thumbnail_type > 255) {
if (thumbnail_type < 0 || thumbnail_type > 255) {
parser.set_error("Wrong thumbnail type"); parser.set_error("Wrong thumbnail type");
} }
} }
template <class StorerT> template <class StorerT>
void PhotoSizeSource::StickerSetThumbnail::store(StorerT &storer) const { void store(const PhotoSizeSource::StickerSetThumbnail &source, StorerT &storer) {
using td::store; store(source.sticker_set_id, storer);
store(sticker_set_id, storer); store(source.sticker_set_access_hash, storer);
store(sticker_set_access_hash, storer);
} }
template <class ParserT> template <class ParserT>
void PhotoSizeSource::StickerSetThumbnail::parse(ParserT &parser) { void parse(PhotoSizeSource::StickerSetThumbnail &source, ParserT &parser) {
using td::parse; parse(source.sticker_set_id, parser);
parse(sticker_set_id, parser); parse(source.sticker_set_access_hash, parser);
parse(sticker_set_access_hash, parser);
} }
template <class StorerT> template <class StorerT>
void PhotoSizeSource::DialogPhoto::store(StorerT &storer) const { void store(const PhotoSizeSource::DialogPhoto &source, StorerT &storer) {
using td::store; store(source.dialog_id, storer);
store(dialog_id, storer); store(source.dialog_access_hash, storer);
store(dialog_access_hash, storer); store(source.is_big, storer);
store(is_big, storer);
} }
template <class ParserT> template <class ParserT>
void PhotoSizeSource::DialogPhoto::parse(ParserT &parser) { void parse(PhotoSizeSource::DialogPhoto &source, ParserT &parser) {
using td::parse; parse(source.dialog_id, parser);
parse(dialog_id, parser); parse(source.dialog_access_hash, parser);
parse(dialog_access_hash, parser); parse(source.is_big, parser);
parse(is_big, parser);
switch (dialog_id.get_type()) { switch (source.dialog_id.get_type()) {
case DialogType::SecretChat: case DialogType::SecretChat:
case DialogType::None: case DialogType::None:
parser.set_error("Invalid chat id"); parser.set_error("Invalid chat id");