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;
int32 thumbnail_type = 0;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
// for dialog photos
@ -46,11 +41,6 @@ struct PhotoSizeSource {
DialogId dialog_id;
int64 dialog_access_hash = 0;
bool is_big = false;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
// for sticker set thumbnails
@ -66,11 +56,6 @@ struct PhotoSizeSource {
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);
}
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
PhotoSizeSource() = default;

View File

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