Unify names of ParserT/StorerT classes.

GitOrigin-RevId: 69df5062e20cc87c0778e1b125ab46575c365377
This commit is contained in:
levlam 2019-02-21 20:54:20 +03:00
parent e6b0b19ea8
commit 4d5fb2902c
36 changed files with 423 additions and 435 deletions

View File

@ -38,8 +38,8 @@ class ObjectImpl {
message_id_ = auth_data->next_message_id(Time::now_cached());
seq_no_ = auth_data->next_seq_no(need_ack);
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
if (empty()) {
return;
}
@ -84,8 +84,8 @@ class CancelVectorImpl {
}
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
for (auto &s : storers_) {
storer.store_storer(s);
}
@ -107,8 +107,8 @@ class QueryImpl {
QueryImpl(const MtprotoQuery &query, Slice header) : query_(query), header_(header) {
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
storer.store_binary(query_.message_id);
storer.store_binary(query_.seq_no);
Slice header = this->header_;
@ -155,8 +155,8 @@ class QueryVectorImpl {
QueryVectorImpl(const vector<MtprotoQuery> &to_send, Slice header) : to_send_(to_send), header_(header) {
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
if (to_send_.empty()) {
return;
}
@ -175,8 +175,8 @@ class ContainerImpl {
ContainerImpl(int32 cnt, Storer &storer) : cnt_(cnt), storer_(storer) {
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
storer.store_binary(mtproto_api::msg_container::ID);
storer.store_binary(cnt_);
storer.store_storer(storer_);
@ -271,8 +271,8 @@ class CryptoImpl {
}
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
switch (type_) {
case OnlyAck:
return storer.store_storer(ack_storer_);

View File

@ -23,8 +23,8 @@ class NoCryptoImpl {
}
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
storer.store_binary(message_id_);
storer.store_binary(static_cast<int32>(data_.size() + pad_.size()));
storer.store_storer(data_);

View File

@ -24,10 +24,8 @@
#include <unordered_map>
namespace td {
class Td;
} // namespace td
namespace td {
class Td;
class AnimationsManager : public Actor {
public:
@ -78,11 +76,11 @@ class AnimationsManager : public Actor {
void remove_saved_animation(const tl_object_ptr<td_api::InputFile> &input_file, Promise<Unit> &&promise);
template <class T>
void store_animation(FileId file_id, T &storer) const;
template <class StorerT>
void store_animation(FileId file_id, StorerT &storer) const;
template <class T>
FileId parse_animation(T &parser);
template <class ParserT>
FileId parse_animation(ParserT &parser);
string get_animation_search_text(FileId file_id) const;

View File

@ -17,8 +17,8 @@
namespace td {
template <class T>
void AnimationsManager::store_animation(FileId file_id, T &storer) const {
template <class StorerT>
void AnimationsManager::store_animation(FileId file_id, StorerT &storer) const {
auto it = animations_.find(file_id);
CHECK(it != animations_.end());
const Animation *animation = it->second.get();
@ -30,8 +30,8 @@ void AnimationsManager::store_animation(FileId file_id, T &storer) const {
store(file_id, storer);
}
template <class T>
FileId AnimationsManager::parse_animation(T &parser) {
template <class ParserT>
FileId AnimationsManager::parse_animation(ParserT &parser) {
auto animation = make_unique<Animation>();
if (parser.version() >= static_cast<int32>(Version::AddDurationToAnimation)) {
parse(animation->duration, parser);

View File

@ -19,10 +19,8 @@
#include <unordered_map>
namespace td {
class Td;
} // namespace td
namespace td {
class Td;
class AudiosManager {
public:
@ -51,11 +49,11 @@ class AudiosManager {
bool merge_audios(FileId new_id, FileId old_id, bool can_delete_old);
template <class T>
void store_audio(FileId file_id, T &storer) const;
template <class StorerT>
void store_audio(FileId file_id, StorerT &storer) const;
template <class T>
FileId parse_audio(T &parser);
template <class ParserT>
FileId parse_audio(ParserT &parser);
string get_audio_search_text(FileId file_id) const;

View File

@ -16,8 +16,8 @@
namespace td {
template <class T>
void AudiosManager::store_audio(FileId file_id, T &storer) const {
template <class StorerT>
void AudiosManager::store_audio(FileId file_id, StorerT &storer) const {
auto it = audios_.find(file_id);
CHECK(it != audios_.end());
const Audio *audio = it->second.get();
@ -30,8 +30,8 @@ void AudiosManager::store_audio(FileId file_id, T &storer) const {
store(file_id, storer);
}
template <class T>
FileId AudiosManager::parse_audio(T &parser) {
template <class ParserT>
FileId AudiosManager::parse_audio(ParserT &parser) {
auto audio = make_unique<Audio>();
parse(audio->file_name, parser);
parse(audio->mime_type, parser);

View File

@ -87,10 +87,10 @@ class AuthManager : public NetActor {
bool has_recovery_ = false;
string email_address_pattern_;
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
struct DbState {
@ -128,10 +128,10 @@ class AuthManager : public NetActor {
return state;
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
bool load_state();

View File

@ -17,8 +17,8 @@
namespace td {
template <class T>
void AuthManager::WaitPasswordState::store(T &storer) const {
template <class StorerT>
void AuthManager::WaitPasswordState::store(StorerT &storer) const {
using td::store;
store(current_client_salt_, storer);
store(current_server_salt_, storer);
@ -31,8 +31,8 @@ void AuthManager::WaitPasswordState::store(T &storer) const {
store(email_address_pattern_, storer);
}
template <class T>
void AuthManager::WaitPasswordState::parse(T &parser) {
template <class ParserT>
void AuthManager::WaitPasswordState::parse(ParserT &parser) {
using td::parse;
parse(current_client_salt_, parser);
parse(current_server_salt_, parser);
@ -45,8 +45,8 @@ void AuthManager::WaitPasswordState::parse(T &parser) {
parse(email_address_pattern_, parser);
}
template <class T>
void AuthManager::DbState::store(T &storer) const {
template <class StorerT>
void AuthManager::DbState::store(StorerT &storer) const {
using td::store;
bool has_terms_of_service = !terms_of_service_.get_id().empty();
bool is_pbkdf2_supported = true;
@ -74,8 +74,8 @@ void AuthManager::DbState::store(T &storer) const {
}
}
template <class T>
void AuthManager::DbState::parse(T &parser) {
template <class ParserT>
void AuthManager::DbState::parse(ParserT &parser) {
using td::parse;
bool has_terms_of_service = false;
bool is_pbkdf2_supported = false;

View File

@ -101,11 +101,11 @@ class DocumentsManager {
bool merge_documents(FileId new_id, FileId old_id, bool can_delete_old);
template <class T>
void store_document(FileId file_id, T &storer) const;
template <class StorerT>
void store_document(FileId file_id, StorerT &storer) const;
template <class T>
FileId parse_document(T &parser);
template <class ParserT>
FileId parse_document(ParserT &parser);
string get_document_search_text(FileId file_id) const;

View File

@ -16,8 +16,8 @@
namespace td {
template <class T>
void DocumentsManager::store_document(FileId file_id, T &storer) const {
template <class StorerT>
void DocumentsManager::store_document(FileId file_id, StorerT &storer) const {
LOG(DEBUG) << "Store document " << file_id;
auto it = documents_.find(file_id);
CHECK(it != documents_.end());
@ -28,8 +28,8 @@ void DocumentsManager::store_document(FileId file_id, T &storer) const {
store(file_id, storer);
}
template <class T>
FileId DocumentsManager::parse_document(T &parser) {
template <class ParserT>
FileId DocumentsManager::parse_document(ParserT &parser) {
auto document = make_unique<Document>();
parse(document->file_name, parser);
parse(document->mime_type, parser);

View File

@ -32,16 +32,16 @@ struct TempPasswordState {
tl_object_ptr<td_api::temporaryPasswordState> as_td_api() const;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
CHECK(has_temp_password);
store(temp_password, storer);
store(valid_until, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
has_temp_password = true;
parse(temp_password, parser);

View File

@ -51,8 +51,8 @@ class SecretImpl {
public:
explicit SecretImpl(const Storer &data) : data(data) {
}
template <class T>
void do_store(T &storer) const {
template <class StorerT>
void do_store(StorerT &storer) const {
storer.store_binary(static_cast<int32>(data.size()));
storer.store_storer(data);
}

View File

@ -48,10 +48,10 @@ class SendCodeHelper {
return phone_registered_;
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
private:
static constexpr int32 AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL = 1 << 0;
@ -71,10 +71,10 @@ class SendCodeHelper {
: type(type), length(length), pattern(std::move(pattern)) {
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
string phone_number_;

View File

@ -12,24 +12,24 @@
namespace td {
template <class T>
void SendCodeHelper::AuthenticationCodeInfo::store(T &storer) const {
template <class StorerT>
void SendCodeHelper::AuthenticationCodeInfo::store(StorerT &storer) const {
using td::store;
store(type, storer);
store(length, storer);
store(pattern, storer);
}
template <class T>
void SendCodeHelper::AuthenticationCodeInfo::parse(T &parser) {
template <class ParserT>
void SendCodeHelper::AuthenticationCodeInfo::parse(ParserT &parser) {
using td::parse;
parse(type, parser);
parse(length, parser);
parse(pattern, parser);
}
template <class T>
void SendCodeHelper::store(T &storer) const {
template <class StorerT>
void SendCodeHelper::store(StorerT &storer) const {
using td::store;
store(phone_number_, storer);
store(phone_registered_, storer);
@ -39,8 +39,8 @@ void SendCodeHelper::store(T &storer) const {
store(next_code_timestamp_, storer);
}
template <class T>
void SendCodeHelper::parse(T &parser) {
template <class ParserT>
void SendCodeHelper::parse(ParserT &parser) {
using td::parse;
parse(phone_number_, parser);
parse(phone_registered_, parser);

View File

@ -31,10 +31,8 @@
#include <utility>
namespace td {
class Td;
} // namespace td
namespace td {
class Td;
class StickersManager : public Actor {
public:
@ -213,11 +211,11 @@ class StickersManager : public Actor {
bool merge_stickers(FileId new_id, FileId old_id, bool can_delete_old);
template <class T>
void store_sticker(FileId file_id, bool in_sticker_set, T &storer) const;
template <class StorerT>
void store_sticker(FileId file_id, bool in_sticker_set, StorerT &storer) const;
template <class T>
FileId parse_sticker(bool in_sticker_set, T &parser);
template <class ParserT>
FileId parse_sticker(bool in_sticker_set, ParserT &parser);
void on_uploaded_sticker_file(FileId file_id, tl_object_ptr<telegram_api::MessageMedia> media,
Promise<Unit> &&promise);
@ -430,17 +428,17 @@ class StickersManager : public Actor {
void save_favorite_stickers_to_database();
template <class T>
void store_sticker_set(const StickerSet *sticker_set, bool with_stickers, T &storer) const;
template <class StorerT>
void store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer) const;
template <class T>
void parse_sticker_set(StickerSet *sticker_set, T &parser);
template <class ParserT>
void parse_sticker_set(StickerSet *sticker_set, ParserT &parser);
template <class T>
void store_sticker_set_id(int64 sticker_set_id, T &storer) const;
template <class StorerT>
void store_sticker_set_id(int64 sticker_set_id, StorerT &storer) const;
template <class T>
void parse_sticker_set_id(int64 &sticker_set_id, T &parser);
template <class ParserT>
void parse_sticker_set_id(int64 &sticker_set_id, ParserT &parser);
Result<std::tuple<FileId, bool, bool>> prepare_input_file(const tl_object_ptr<td_api::InputFile> &input_file);

View File

@ -20,8 +20,8 @@
namespace td {
template <class T>
void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, T &storer) const {
template <class StorerT>
void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT &storer) const {
auto it = stickers_.find(file_id);
CHECK(it != stickers_.end());
const Sticker *sticker = it->second.get();
@ -52,8 +52,8 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, T &stor
}
}
template <class T>
FileId StickersManager::parse_sticker(bool in_sticker_set, T &parser) {
template <class ParserT>
FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
auto sticker = make_unique<Sticker>();
bool has_sticker_set_access_hash;
bool in_sticker_set_stored;
@ -91,8 +91,8 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, T &parser) {
return on_get_sticker(std::move(sticker), false); // data in the database is always outdated
}
template <class T>
void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with_stickers, T &storer) const {
template <class StorerT>
void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer) const {
size_t stickers_limit = with_stickers ? sticker_set->sticker_ids.size() : 5;
bool is_full = sticker_set->sticker_ids.size() <= stickers_limit;
bool was_loaded = sticker_set->was_loaded && is_full;
@ -138,8 +138,8 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
}
}
template <class T>
void StickersManager::parse_sticker_set(StickerSet *sticker_set, T &parser) {
template <class ParserT>
void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser) {
CHECK(sticker_set != nullptr);
CHECK(!sticker_set->was_loaded);
bool was_inited = sticker_set->is_inited;
@ -243,8 +243,8 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, T &parser) {
}
}
template <class T>
void StickersManager::store_sticker_set_id(int64 sticker_set_id, T &storer) const {
template <class StorerT>
void StickersManager::store_sticker_set_id(int64 sticker_set_id, StorerT &storer) const {
CHECK(sticker_set_id != 0);
const StickerSet *sticker_set = get_sticker_set(sticker_set_id);
CHECK(sticker_set != nullptr);
@ -252,8 +252,8 @@ void StickersManager::store_sticker_set_id(int64 sticker_set_id, T &storer) cons
store(sticker_set->access_hash, storer);
}
template <class T>
void StickersManager::parse_sticker_set_id(int64 &sticker_set_id, T &parser) {
template <class ParserT>
void StickersManager::parse_sticker_set_id(int64 &sticker_set_id, ParserT &parser) {
parse(sticker_set_id, parser);
int64 sticker_set_access_hash;
parse(sticker_set_access_hash, parser);

View File

@ -45,8 +45,8 @@ class TermsOfService {
return td_api::make_object<td_api::termsOfService>(get_formatted_text_object(text_), min_user_age_, show_popup_);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
BEGIN_STORE_FLAGS();
STORE_FLAG(show_popup_);
@ -56,8 +56,8 @@ class TermsOfService {
store(min_user_age_, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(show_popup_);

View File

@ -222,34 +222,34 @@ void TopDialogManager::update_rating_e_decay() {
rating_e_decay_ = G()->shared_config().get_option_integer("rating_e_decay", rating_e_decay_);
}
template <class T>
void parse(TopDialogManager::TopDialog &top_dialog, T &parser) {
using ::td::parse;
parse(top_dialog.dialog_id, parser);
parse(top_dialog.rating, parser);
}
template <class T>
void store(const TopDialogManager::TopDialog &top_dialog, T &storer) {
template <class StorerT>
void store(const TopDialogManager::TopDialog &top_dialog, StorerT &storer) {
using ::td::store;
store(top_dialog.dialog_id, storer);
store(top_dialog.rating, storer);
}
template <class T>
void parse(TopDialogManager::TopDialogs &top_dialogs, T &parser) {
template <class ParserT>
void parse(TopDialogManager::TopDialog &top_dialog, ParserT &parser) {
using ::td::parse;
parse(top_dialogs.rating_timestamp, parser);
parse(top_dialogs.dialogs, parser);
parse(top_dialog.dialog_id, parser);
parse(top_dialog.rating, parser);
}
template <class T>
void store(const TopDialogManager::TopDialogs &top_dialogs, T &storer) {
template <class StorerT>
void store(const TopDialogManager::TopDialogs &top_dialogs, StorerT &storer) {
using ::td::store;
store(top_dialogs.rating_timestamp, storer);
store(top_dialogs.dialogs, storer);
}
template <class ParserT>
void parse(TopDialogManager::TopDialogs &top_dialogs, ParserT &parser) {
using ::td::parse;
parse(top_dialogs.rating_timestamp, parser);
parse(top_dialogs.dialogs, parser);
}
double TopDialogManager::rating_add(double now, double rating_timestamp) const {
return std::exp((now - rating_timestamp) / rating_e_decay_);
}

View File

@ -101,14 +101,14 @@ class TopDialogManager : public NetQueryCallback {
double rating_timestamp = 0;
std::vector<TopDialog> dialogs;
};
template <class T>
friend void parse(TopDialog &top_dialog, T &parser);
template <class T>
friend void store(const TopDialog &top_dialog, T &storer);
template <class T>
friend void parse(TopDialogs &top_dialogs, T &parser);
template <class T>
friend void store(const TopDialogs &top_dialogs, T &storer);
template <class StorerT>
friend void store(const TopDialog &top_dialog, StorerT &storer);
template <class ParserT>
friend void parse(TopDialog &top_dialog, ParserT &parser);
template <class StorerT>
friend void store(const TopDialogs &top_dialogs, StorerT &storer);
template <class ParserT>
friend void parse(TopDialogs &top_dialogs, ParserT &parser);
std::array<TopDialogs, static_cast<size_t>(TopDialogCategory::Size)> by_category_;

View File

@ -19,10 +19,8 @@
#include <unordered_map>
namespace td {
class Td;
} // namespace td
namespace td {
class Td;
class VideoNotesManager {
public:
@ -50,11 +48,11 @@ class VideoNotesManager {
bool merge_video_notes(FileId new_id, FileId old_id, bool can_delete_old);
template <class T>
void store_video_note(FileId file_id, T &storer) const;
template <class StorerT>
void store_video_note(FileId file_id, StorerT &storer) const;
template <class T>
FileId parse_video_note(T &parser);
template <class ParserT>
FileId parse_video_note(ParserT &parser);
private:
class VideoNote {

View File

@ -16,8 +16,8 @@
namespace td {
template <class T>
void VideoNotesManager::store_video_note(FileId file_id, T &storer) const {
template <class StorerT>
void VideoNotesManager::store_video_note(FileId file_id, StorerT &storer) const {
auto it = video_notes_.find(file_id);
CHECK(it != video_notes_.end());
const VideoNote *video_note = it->second.get();
@ -27,8 +27,8 @@ void VideoNotesManager::store_video_note(FileId file_id, T &storer) const {
store(file_id, storer);
}
template <class T>
FileId VideoNotesManager::parse_video_note(T &parser) {
template <class ParserT>
FileId VideoNotesManager::parse_video_note(ParserT &parser) {
auto video_note = make_unique<VideoNote>();
parse(video_note->duration, parser);
parse(video_note->dimensions, parser);

View File

@ -19,10 +19,8 @@
#include <unordered_map>
namespace td {
class Td;
} // namespace td
namespace td {
class Td;
class VideosManager {
public:
@ -53,11 +51,11 @@ class VideosManager {
bool merge_videos(FileId new_id, FileId old_id, bool can_delete_old);
template <class T>
void store_video(FileId file_id, T &storer) const;
template <class StorerT>
void store_video(FileId file_id, StorerT &storer) const;
template <class T>
FileId parse_video(T &parser);
template <class ParserT>
FileId parse_video(ParserT &parser);
string get_video_search_text(FileId file_id) const;

View File

@ -16,8 +16,8 @@
namespace td {
template <class T>
void VideosManager::store_video(FileId file_id, T &storer) const {
template <class StorerT>
void VideosManager::store_video(FileId file_id, StorerT &storer) const {
auto it = videos_.find(file_id);
CHECK(it != videos_.end());
const Video *video = it->second.get();
@ -36,8 +36,8 @@ void VideosManager::store_video(FileId file_id, T &storer) const {
}
}
template <class T>
FileId VideosManager::parse_video(T &parser) {
template <class ParserT>
FileId VideosManager::parse_video(ParserT &parser) {
auto video = make_unique<Video>();
BEGIN_PARSE_FLAGS();
PARSE_FLAG(video->has_stickers);

View File

@ -17,10 +17,8 @@
#include <unordered_map>
namespace td {
class Td;
} // namespace td
namespace td {
class Td;
class VoiceNotesManager {
public:
@ -43,11 +41,11 @@ class VoiceNotesManager {
bool merge_voice_notes(FileId new_id, FileId old_id, bool can_delete_old);
template <class T>
void store_voice_note(FileId file_id, T &storer) const;
template <class StorerT>
void store_voice_note(FileId file_id, StorerT &storer) const;
template <class T>
FileId parse_voice_note(T &parser);
template <class ParserT>
FileId parse_voice_note(ParserT &parser);
private:
class VoiceNote {

View File

@ -15,8 +15,8 @@
namespace td {
template <class T>
void VoiceNotesManager::store_voice_note(FileId file_id, T &storer) const {
template <class StorerT>
void VoiceNotesManager::store_voice_note(FileId file_id, StorerT &storer) const {
auto it = voice_notes_.find(file_id);
CHECK(it != voice_notes_.end());
const VoiceNote *voice_note = it->second.get();
@ -26,8 +26,8 @@ void VoiceNotesManager::store_voice_note(FileId file_id, T &storer) const {
store(file_id, storer);
}
template <class T>
FileId VoiceNotesManager::parse_voice_note(T &parser) {
template <class ParserT>
FileId VoiceNotesManager::parse_voice_note(ParserT &parser) {
auto voice_note = make_unique<VoiceNote>();
parse(voice_note->mime_type, parser);
parse(voice_note->duration, parser);

View File

@ -144,8 +144,8 @@ class WebPagesManager::WebPageInstantView {
bool is_loaded = false;
bool was_loaded_from_database = false;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_url = !url.empty();
BEGIN_STORE_FLAGS();
@ -164,8 +164,8 @@ class WebPagesManager::WebPageInstantView {
CHECK(!is_empty);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_url;
BEGIN_PARSE_FLAGS();
@ -216,8 +216,8 @@ class WebPagesManager::WebPage {
mutable uint64 logevent_id = 0;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_type = !type.empty();
bool has_site_name = !site_name.empty();
@ -312,8 +312,8 @@ class WebPagesManager::WebPage {
}
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_type;
bool has_site_name;
@ -455,8 +455,8 @@ class WebPagesManager::RichText {
return type == Type::Plain && content.empty();
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(type, storer);
store(content, storer);
@ -469,8 +469,8 @@ class WebPagesManager::RichText {
}
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(type, parser);
parse(content, parser);
@ -497,15 +497,15 @@ class WebPagesManager::PageBlockCaption {
RichText text;
RichText credit;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(text, storer);
store(credit, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(text, parser);
if (parser.version() >= static_cast<int32>(Version::SupportInstantView2_0)) {
@ -529,8 +529,8 @@ class WebPagesManager::PageBlockTableCell {
int32 colspan = 1;
int32 rowspan = 1;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_text = !text.empty();
bool has_colspan = colspan != 1;
@ -558,8 +558,8 @@ class WebPagesManager::PageBlockTableCell {
}
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_text;
bool has_colspan;
@ -598,8 +598,8 @@ class WebPagesManager::RelatedArticle {
string author;
int32 published_date = 0;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_title = !title.empty();
bool has_description = !description.empty();
@ -632,8 +632,8 @@ class WebPagesManager::RelatedArticle {
}
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_title;
bool has_description;
@ -715,16 +715,16 @@ class WebPagesManager::PageBlock {
PageBlock &operator=(PageBlock &&) = delete;
virtual ~PageBlock() = default;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
Type type = get_type();
store(type, storer);
call_impl(type, this, [&](const auto *object) { store(*object, storer); });
}
template <class T>
static unique_ptr<PageBlock> parse(T &parser) {
template <class ParserT>
static unique_ptr<PageBlock> parse(ParserT &parser) {
using ::td::parse;
Type type;
parse(type, parser);
@ -743,13 +743,13 @@ class WebPagesManager::PageBlock {
static void call_impl(Type type, const PageBlock *ptr, F &&f);
};
template <class T>
void store(const unique_ptr<WebPagesManager::PageBlock> &block, T &storer) {
template <class StorerT>
void store(const unique_ptr<WebPagesManager::PageBlock> &block, StorerT &storer) {
block->store(storer);
}
template <class T>
void parse(unique_ptr<WebPagesManager::PageBlock> &block, T &parser) {
template <class ParserT>
void parse(unique_ptr<WebPagesManager::PageBlock> &block, ParserT &parser) {
block = WebPagesManager::PageBlock::parse(parser);
}
@ -774,14 +774,14 @@ class WebPagesManager::PageBlockTitle : public PageBlock {
return make_tl_object<td_api::pageBlockTitle>(get_rich_text_object(title));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(title, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(title, parser);
}
@ -807,14 +807,14 @@ class WebPagesManager::PageBlockSubtitle : public PageBlock {
return make_tl_object<td_api::pageBlockSubtitle>(get_rich_text_object(subtitle));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(subtitle, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(subtitle, parser);
}
@ -841,15 +841,15 @@ class WebPagesManager::PageBlockAuthorDate : public PageBlock {
return make_tl_object<td_api::pageBlockAuthorDate>(get_rich_text_object(author), date);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(author, storer);
store(date, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(author, parser);
parse(date, parser);
@ -876,14 +876,14 @@ class WebPagesManager::PageBlockHeader : public PageBlock {
return make_tl_object<td_api::pageBlockHeader>(get_rich_text_object(header));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(header, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(header, parser);
}
@ -909,14 +909,14 @@ class WebPagesManager::PageBlockSubheader : public PageBlock {
return make_tl_object<td_api::pageBlockSubheader>(get_rich_text_object(subheader));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(subheader, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(subheader, parser);
}
@ -942,14 +942,14 @@ class WebPagesManager::PageBlockKicker : public PageBlock {
return make_tl_object<td_api::pageBlockKicker>(get_rich_text_object(kicker));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(kicker, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(kicker, parser);
}
@ -975,14 +975,14 @@ class WebPagesManager::PageBlockParagraph : public PageBlock {
return make_tl_object<td_api::pageBlockParagraph>(get_rich_text_object(text));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(text, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(text, parser);
}
@ -1009,15 +1009,15 @@ class WebPagesManager::PageBlockPreformatted : public PageBlock {
return make_tl_object<td_api::pageBlockPreformatted>(get_rich_text_object(text), language);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(text, storer);
store(language, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(text, parser);
parse(language, parser);
@ -1044,14 +1044,14 @@ class WebPagesManager::PageBlockFooter : public PageBlock {
return make_tl_object<td_api::pageBlockFooter>(get_rich_text_object(footer));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(footer, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(footer, parser);
}
@ -1070,12 +1070,12 @@ class WebPagesManager::PageBlockDivider : public PageBlock {
return make_tl_object<td_api::pageBlockDivider>();
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
}
};
@ -1098,14 +1098,14 @@ class WebPagesManager::PageBlockAnchor : public PageBlock {
return make_tl_object<td_api::pageBlockAnchor>(name);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(name, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(name, parser);
}
@ -1117,15 +1117,15 @@ class WebPagesManager::PageBlockList : public PageBlock {
string label;
vector<unique_ptr<PageBlock>> page_blocks;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(label, storer);
store(page_blocks, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(label, parser);
parse(page_blocks, parser);
@ -1163,14 +1163,14 @@ class WebPagesManager::PageBlockList : public PageBlock {
transform(items, [](const Item &item) { return get_page_block_list_item_object(item); }));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(items, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
if (parser.version() >= static_cast<int32>(Version::SupportInstantView2_0)) {
@ -1222,15 +1222,15 @@ class WebPagesManager::PageBlockBlockQuote : public PageBlock {
return make_tl_object<td_api::pageBlockBlockQuote>(get_rich_text_object(text), get_rich_text_object(credit));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(text, storer);
store(credit, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(text, parser);
parse(credit, parser);
@ -1259,15 +1259,15 @@ class WebPagesManager::PageBlockPullQuote : public PageBlock {
return make_tl_object<td_api::pageBlockPullQuote>(get_rich_text_object(text), get_rich_text_object(credit));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(text, storer);
store(credit, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(text, parser);
parse(credit, parser);
@ -1308,8 +1308,8 @@ class WebPagesManager::PageBlockAnimation : public PageBlock {
get_page_block_caption_object(caption), need_autoplay);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_empty_animation = !animation_file_id.is_valid();
@ -1324,8 +1324,8 @@ class WebPagesManager::PageBlockAnimation : public PageBlock {
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_empty_animation;
@ -1374,8 +1374,8 @@ class WebPagesManager::PageBlockPhoto : public PageBlock {
get_page_block_caption_object(caption), url);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(photo, storer);
store(caption, storer);
@ -1383,8 +1383,8 @@ class WebPagesManager::PageBlockPhoto : public PageBlock {
store(web_page_id, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(photo, parser);
parse(caption, parser);
@ -1432,8 +1432,8 @@ class WebPagesManager::PageBlockVideo : public PageBlock {
get_page_block_caption_object(caption), need_autoplay, is_looped);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_empty_video = !video_file_id.is_valid();
@ -1449,8 +1449,8 @@ class WebPagesManager::PageBlockVideo : public PageBlock {
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_empty_video;
@ -1494,14 +1494,14 @@ class WebPagesManager::PageBlockCover : public PageBlock {
return make_tl_object<td_api::pageBlockCover>(cover->get_page_block_object());
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(cover, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(cover, parser);
}
@ -1544,8 +1544,8 @@ class WebPagesManager::PageBlockEmbedded : public PageBlock {
dimensions.height, get_page_block_caption_object(caption), is_full_width, allow_scrolling);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_full_width);
@ -1559,8 +1559,8 @@ class WebPagesManager::PageBlockEmbedded : public PageBlock {
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_full_width);
@ -1613,8 +1613,8 @@ class WebPagesManager::PageBlockEmbeddedPost : public PageBlock {
get_page_block_objects(page_blocks), get_page_block_caption_object(caption));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(url, storer);
store(author, storer);
@ -1624,8 +1624,8 @@ class WebPagesManager::PageBlockEmbeddedPost : public PageBlock {
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(url, parser);
parse(author, parser);
@ -1662,15 +1662,15 @@ class WebPagesManager::PageBlockCollage : public PageBlock {
get_page_block_caption_object(caption));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(page_blocks, storer);
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(page_blocks, parser);
parse(caption, parser);
@ -1703,15 +1703,15 @@ class WebPagesManager::PageBlockSlideshow : public PageBlock {
get_page_block_caption_object(caption));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(page_blocks, storer);
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(page_blocks, parser);
parse(caption, parser);
@ -1742,16 +1742,16 @@ class WebPagesManager::PageBlockChatLink : public PageBlock {
title, get_chat_photo_object(G()->td().get_actor_unsafe()->file_manager_.get(), &photo), username);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(title, storer);
store(photo, storer);
store(username, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(title, parser);
parse(photo, parser);
@ -1791,8 +1791,8 @@ class WebPagesManager::PageBlockAudio : public PageBlock {
get_page_block_caption_object(caption));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
bool has_empty_audio = !audio_file_id.is_valid();
@ -1806,8 +1806,8 @@ class WebPagesManager::PageBlockAudio : public PageBlock {
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
bool has_empty_audio;
@ -1862,8 +1862,8 @@ class WebPagesManager::PageBlockTable : public PageBlock {
is_striped);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_bordered);
@ -1873,8 +1873,8 @@ class WebPagesManager::PageBlockTable : public PageBlock {
store(cells, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_bordered);
@ -1912,8 +1912,8 @@ class WebPagesManager::PageBlockDetails : public PageBlock {
is_open);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_open);
@ -1922,8 +1922,8 @@ class WebPagesManager::PageBlockDetails : public PageBlock {
store(page_blocks, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_open);
@ -1967,15 +1967,15 @@ class WebPagesManager::PageBlockRelatedArticles : public PageBlock {
std::move(related_article_objects));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(header, storer);
store(related_articles, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(header, parser);
parse(related_articles, parser);
@ -2007,8 +2007,8 @@ class WebPagesManager::PageBlockMap : public PageBlock {
dimensions.height, get_page_block_caption_object(caption));
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using ::td::store;
store(location, storer);
store(zoom, storer);
@ -2016,8 +2016,8 @@ class WebPagesManager::PageBlockMap : public PageBlock {
store(caption, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using ::td::parse;
parse(location, parser);
parse(zoom, parser);

View File

@ -138,11 +138,11 @@ class WebPagesManager : public Actor {
class WebPageLogEvent;
template <class T>
friend void store(const unique_ptr<PageBlock> &block, T &storer);
template <class StorerT>
friend void store(const unique_ptr<PageBlock> &block, StorerT &storer);
template <class T>
friend void parse(unique_ptr<PageBlock> &block, T &parser);
template <class ParserT>
friend void parse(unique_ptr<PageBlock> &block, ParserT &parser);
void update_web_page(unique_ptr<WebPage> web_page, WebPageId web_page_id, bool from_binlog, bool from_database);

View File

@ -444,8 +444,8 @@ class FileManager : public FileLoadManager::Callback {
template <class StorerT>
void store_file(FileId file_id, StorerT &storer, int32 ttl = 5) const;
template <class StorerT>
FileId parse_file(StorerT &parser);
template <class ParserT>
FileId parse_file(ParserT &parser);
private:
static constexpr char PERSISTENT_ID_VERSION = 2;

View File

@ -30,14 +30,14 @@ struct FileTypeStat {
int32 cnt{0};
};
template <class T>
void store(const FileTypeStat &stat, T &storer) {
template <class StorerT>
void store(const FileTypeStat &stat, StorerT &storer) {
using ::td::store;
store(stat.size, storer);
store(stat.cnt, storer);
}
template <class T>
void parse(FileTypeStat &stat, T &parser) {
template <class ParserT>
void parse(FileTypeStat &stat, ParserT &parser) {
using ::td::parse;
parse(stat.size, parser);
parse(stat.cnt, parser);

View File

@ -60,8 +60,8 @@ struct EncryptedInputFile {
int32 parts = 0;
int32 key_fingerprint = 0;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
store(magic, storer);
store(type, storer);
@ -80,8 +80,8 @@ struct EncryptedInputFile {
return type == Empty;
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
int32 got_magic;
@ -154,8 +154,8 @@ struct EncryptedFileLocation {
tl_object_ptr<telegram_api::encryptedFile> as_encrypted_file() {
return make_tl_object<telegram_api::encryptedFile>(id, access_hash, size, dc_id, key_fingerprint);
}
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
store(magic, storer);
store(id, storer);
@ -165,8 +165,8 @@ struct EncryptedFileLocation {
store(key_fingerprint, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
int32 got_magic;
@ -221,8 +221,8 @@ class InboundSecretMessage : public LogEventHelper<InboundSecretMessage, SecretC
bool has_encrypted_file = false;
bool is_pending = false;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
BEGIN_STORE_FLAGS();
@ -249,8 +249,8 @@ class InboundSecretMessage : public LogEventHelper<InboundSecretMessage, SecretC
}
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
BEGIN_PARSE_FLAGS();
@ -323,8 +323,8 @@ class OutboundSecretMessage : public LogEventHelper<OutboundSecretMessage, Secre
// 3. can_rewrite_with_empty // false for almost all service messages
// TODO: combine these two functions into one macros hell. Or a lambda hell.
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
store(chat_id, storer);
@ -353,8 +353,8 @@ class OutboundSecretMessage : public LogEventHelper<OutboundSecretMessage, Secre
}
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
parse(chat_id, parser);
@ -395,14 +395,14 @@ class CloseSecretChat : public LogEventHelper<CloseSecretChat, SecretChatEvent>
static constexpr Type type = SecretChatEvent::Type::CloseSecretChat;
int32 chat_id = 0;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
store(chat_id, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
parse(chat_id, parser);
}
@ -419,16 +419,16 @@ class CreateSecretChat : public LogEventHelper<CreateSecretChat, SecretChatEvent
int32 user_id = 0;
int64 user_access_hash = 0;
template <class T>
void store(T &storer) const {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
store(random_id, storer);
store(user_id, storer);
store(user_access_hash, storer);
}
template <class T>
void parse(T &parser) {
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
parse(random_id, parser);
parse(user_id, parser);

View File

@ -198,26 +198,8 @@ class ConnectionCreator::ProxyInfo {
IPAddress ip_address_;
};
template <class T>
void Proxy::parse(T &parser) {
using td::parse;
parse(type_, parser);
if (type_ == Proxy::Type::Socks5 || type_ == Proxy::Type::HttpTcp || type_ == Proxy::Type::HttpCaching) {
parse(server_, parser);
parse(port_, parser);
parse(user_, parser);
parse(password_, parser);
} else if (type_ == Proxy::Type::Mtproto) {
parse(server_, parser);
parse(port_, parser);
parse(secret_, parser);
} else {
LOG_CHECK(type_ == Proxy::Type::None) << static_cast<int32>(type_);
}
}
template <class T>
void Proxy::store(T &storer) const {
template <class StorerT>
void Proxy::store(StorerT &storer) const {
using td::store;
store(type_, storer);
if (type_ == Proxy::Type::Socks5 || type_ == Proxy::Type::HttpTcp || type_ == Proxy::Type::HttpCaching) {
@ -234,6 +216,24 @@ void Proxy::store(T &storer) const {
}
}
template <class ParserT>
void Proxy::parse(ParserT &parser) {
using td::parse;
parse(type_, parser);
if (type_ == Proxy::Type::Socks5 || type_ == Proxy::Type::HttpTcp || type_ == Proxy::Type::HttpCaching) {
parse(server_, parser);
parse(port_, parser);
parse(user_, parser);
parse(password_, parser);
} else if (type_ == Proxy::Type::Mtproto) {
parse(server_, parser);
parse(port_, parser);
parse(secret_, parser);
} else {
LOG_CHECK(type_ == Proxy::Type::None) << static_cast<int32>(type_);
}
}
StringBuilder &operator<<(StringBuilder &string_builder, const Proxy &proxy) {
switch (proxy.type()) {
case Proxy::Type::Socks5:

View File

@ -118,11 +118,11 @@ class Proxy {
return type_;
}
template <class T>
void parse(T &parser);
template <class StorerT>
void store(StorerT &storer) const;
template <class T>
void store(T &storer) const;
template <class ParserT>
void parse(ParserT &parser);
private:
Type type_{Type::None};

View File

@ -22,8 +22,8 @@
namespace td {
template <class T>
static void store(const NetStatsData &net_stats, T &storer) {
template <class StorerT>
static void store(const NetStatsData &net_stats, StorerT &storer) {
using ::td::store;
store(net_stats.read_size, storer);
store(net_stats.write_size, storer);
@ -31,8 +31,8 @@ static void store(const NetStatsData &net_stats, T &storer) {
store(net_stats.duration, storer);
}
template <class T>
static void parse(NetStatsData &net_stats, T &parser) {
template <class ParserT>
static void parse(NetStatsData &net_stats, ParserT &parser) {
using ::td::parse;
parse(net_stats.read_size, parser);
parse(net_stats.write_size, parser);

View File

@ -20,19 +20,19 @@ template <class Func, std::int32_t constructor_id>
class TlFetchBoxed {
public:
template <class ParserT>
static auto parse(ParserT &p) -> decltype(Func::parse(p)) {
if (p.fetch_int() != constructor_id) {
p.set_error("Wrong constructor found");
return decltype(Func::parse(p))();
static auto parse(ParserT &parser) -> decltype(Func::parse(parser)) {
if (parser.fetch_int() != constructor_id) {
parser.set_error("Wrong constructor found");
return decltype(Func::parse(parser))();
}
return Func::parse(p);
return Func::parse(parser);
}
};
class TlFetchTrue {
public:
template <class ParserT>
static bool parse(ParserT &p) {
static bool parse(ParserT &parser) {
return true;
}
};
@ -40,16 +40,16 @@ class TlFetchTrue {
class TlFetchBool {
public:
template <class ParserT>
static bool parse(ParserT &p) {
static bool parse(ParserT &parser) {
constexpr std::int32_t ID_BOOL_FALSE = 0xbc799737;
constexpr std::int32_t ID_BOOL_TRUE = 0x997275b5;
std::int32_t c = p.fetch_int();
std::int32_t c = parser.fetch_int();
if (c == ID_BOOL_TRUE) {
return true;
}
if (c != ID_BOOL_FALSE) {
p.set_error("Bool expected");
parser.set_error("Bool expected");
}
return false;
}
@ -58,40 +58,40 @@ class TlFetchBool {
class TlFetchInt {
public:
template <class ParserT>
static std::int32_t parse(ParserT &p) {
return p.fetch_int();
static std::int32_t parse(ParserT &parser) {
return parser.fetch_int();
}
};
class TlFetchLong {
public:
template <class ParserT>
static std::int64_t parse(ParserT &p) {
return p.fetch_long();
static std::int64_t parse(ParserT &parser) {
return parser.fetch_long();
}
};
class TlFetchDouble {
public:
template <class ParserT>
static double parse(ParserT &p) {
return p.fetch_double();
static double parse(ParserT &parser) {
return parser.fetch_double();
}
};
class TlFetchInt128 {
public:
template <class ParserT>
static UInt128 parse(ParserT &p) {
return p.template fetch_binary<UInt128>();
static UInt128 parse(ParserT &parser) {
return parser.template fetch_binary<UInt128>();
}
};
class TlFetchInt256 {
public:
template <class ParserT>
static UInt256 parse(ParserT &p) {
return p.template fetch_binary<UInt256>();
static UInt256 parse(ParserT &parser) {
return parser.template fetch_binary<UInt256>();
}
};
@ -99,8 +99,8 @@ template <class T>
class TlFetchString {
public:
template <class ParserT>
static T parse(ParserT &p) {
return p.template fetch_string<T>();
static T parse(ParserT &parser) {
return parser.template fetch_string<T>();
}
};
@ -108,8 +108,8 @@ template <class T>
class TlFetchBytes {
public:
template <class ParserT>
static T parse(ParserT &p) {
return p.template fetch_string<T>();
static T parse(ParserT &parser) {
return parser.template fetch_string<T>();
}
};
@ -117,15 +117,15 @@ template <class Func>
class TlFetchVector {
public:
template <class ParserT>
static auto parse(ParserT &p) -> std::vector<decltype(Func::parse(p))> {
const std::uint32_t multiplicity = p.fetch_int();
std::vector<decltype(Func::parse(p))> v;
if (p.get_left_len() < multiplicity) {
p.set_error("Wrong vector length");
static auto parse(ParserT &parser) -> std::vector<decltype(Func::parse(parser))> {
const std::uint32_t multiplicity = parser.fetch_int();
std::vector<decltype(Func::parse(parser))> v;
if (parser.get_left_len() < multiplicity) {
parser.set_error("Wrong vector length");
} else {
v.reserve(multiplicity);
for (std::uint32_t i = 0; i < multiplicity; i++) {
v.push_back(Func::parse(p));
v.push_back(Func::parse(parser));
}
}
return v;
@ -136,8 +136,8 @@ template <class T>
class TlFetchObject {
public:
template <class ParserT>
static tl_object_ptr<T> parse(ParserT &p) {
return T::fetch(p);
static tl_object_ptr<T> parse(ParserT &parser) {
return T::fetch(parser);
}
};

View File

@ -20,9 +20,9 @@ template <class Func, std::int32_t constructor_id>
class TlStoreBoxed {
public:
template <class T, class StorerT>
static void store(const T &x, StorerT &s) {
s.store_binary(constructor_id);
Func::store(x, s);
static void store(const T &x, StorerT &storer) {
storer.store_binary(constructor_id);
Func::store(x, storer);
}
};
@ -30,27 +30,27 @@ template <class Func>
class TlStoreBoxedUnknown {
public:
template <class T, class StorerT>
static void store(const T &x, StorerT &s) {
s.store_binary(x->get_id());
Func::store(x, s);
static void store(const T &x, StorerT &storer) {
storer.store_binary(x->get_id());
Func::store(x, storer);
}
};
class TlStoreBool {
public:
template <class StorerT>
static void store(const bool &x, StorerT &s) {
static void store(const bool &x, StorerT &storer) {
constexpr std::int32_t ID_BOOL_FALSE = 0xbc799737;
constexpr std::int32_t ID_BOOL_TRUE = 0x997275b5;
s.store_binary(x ? ID_BOOL_TRUE : ID_BOOL_FALSE);
storer.store_binary(x ? ID_BOOL_TRUE : ID_BOOL_FALSE);
}
};
class TlStoreTrue {
public:
template <class StorerT>
static void store(const bool &x, StorerT &s) {
static void store(const bool &x, StorerT &storer) {
// currently nothing to do
}
};
@ -58,16 +58,16 @@ class TlStoreTrue {
class TlStoreBinary {
public:
template <class T, class StorerT>
static void store(const T &x, StorerT &s) {
s.store_binary(x);
static void store(const T &x, StorerT &storer) {
storer.store_binary(x);
}
};
class TlStoreString {
public:
template <class T, class StorerT>
static void store(const T &x, StorerT &s) {
s.store_string(x);
static void store(const T &x, StorerT &storer) {
storer.store_string(x);
}
};
@ -75,10 +75,10 @@ template <class Func>
class TlStoreVector {
public:
template <class T, class StorerT>
static void store(const T &vec, StorerT &s) {
s.store_binary(narrow_cast<int32>(vec.size()));
static void store(const T &vec, StorerT &storer) {
storer.store_binary(narrow_cast<int32>(vec.size()));
for (auto &val : vec) {
Func::store(val, s);
Func::store(val, storer);
}
}
};
@ -86,8 +86,8 @@ class TlStoreVector {
class TlStoreObject {
public:
template <class T, class StorerT>
static void store(const tl_object_ptr<T> &obj, StorerT &s) {
return obj->store(s);
static void store(const tl_object_ptr<T> &obj, StorerT &storer) {
return obj->store(storer);
}
};

View File

@ -94,14 +94,14 @@ class Timestamp {
}
};
template <class T>
void parse(Timestamp &timestamp, T &parser) {
timestamp = Timestamp::in(parser.fetch_double() - Clocks::system());
}
template <class T>
void store(const Timestamp &timestamp, T &storer) {
template <class StorerT>
void store(const Timestamp &timestamp, StorerT &storer) {
storer.store_binary(timestamp.at() - Time::now() + Clocks::system());
}
template <class ParserT>
void parse(Timestamp &timestamp, ParserT &parser) {
timestamp = Timestamp::in(parser.fetch_double() - Clocks::system());
}
} // namespace td