tdlight/td/telegram/MessageForwardInfo.hpp

108 lines
2.7 KiB
C++
Raw Normal View History

2024-01-11 16:20:53 +01:00
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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
2024-01-11 17:11:16 +01:00
#include "td/telegram/DialogId.h"
2024-01-11 16:20:53 +01:00
#include "td/telegram/MessageForwardInfo.h"
2024-01-11 17:11:16 +01:00
#include "td/telegram/MessageId.h"
2024-01-11 16:20:53 +01:00
#include "td/telegram/MessageOrigin.hpp"
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"
namespace td {
2024-01-11 20:33:12 +01:00
template <class StorerT>
void LastForwardedMessageInfo::store(StorerT &storer) const {
2024-01-11 22:23:33 +01:00
bool has_sender_dialog_id = sender_dialog_id_.is_valid();
bool has_sender_name = !sender_name_.empty();
bool has_date = date_ > 0;
2024-01-11 20:33:12 +01:00
BEGIN_STORE_FLAGS();
2024-01-11 22:23:33 +01:00
STORE_FLAG(has_sender_dialog_id);
STORE_FLAG(has_sender_name);
STORE_FLAG(has_date);
STORE_FLAG(is_outgoing_);
2024-01-11 20:33:12 +01:00
END_STORE_FLAGS();
td::store(dialog_id_, storer);
td::store(message_id_, storer);
2024-01-11 22:23:33 +01:00
if (has_sender_dialog_id) {
td::store(sender_dialog_id_, storer);
}
if (has_sender_name) {
td::store(sender_name_, storer);
}
if (has_date) {
td::store(date_, storer);
}
2024-01-11 20:33:12 +01:00
}
template <class ParserT>
void LastForwardedMessageInfo::parse(ParserT &parser) {
2024-01-11 22:23:33 +01:00
bool has_sender_dialog_id;
bool has_sender_name;
bool has_date;
2024-01-11 20:33:12 +01:00
BEGIN_PARSE_FLAGS();
2024-01-11 22:23:33 +01:00
PARSE_FLAG(has_sender_dialog_id);
PARSE_FLAG(has_sender_name);
PARSE_FLAG(has_date);
PARSE_FLAG(is_outgoing_);
2024-01-11 20:33:12 +01:00
END_PARSE_FLAGS();
td::parse(dialog_id_, parser);
td::parse(message_id_, parser);
2024-01-11 22:23:33 +01:00
if (has_sender_dialog_id) {
td::parse(sender_dialog_id_, parser);
}
if (has_sender_name) {
td::parse(sender_name_, parser);
}
if (has_date) {
td::parse(date_, parser);
}
2024-01-11 20:33:12 +01:00
validate();
}
2024-01-11 16:20:53 +01:00
template <class StorerT>
void MessageForwardInfo::store(StorerT &storer) const {
2024-01-11 20:33:12 +01:00
bool has_last_message_info = !last_message_info_.is_empty();
bool has_psa_type = !psa_type_.empty();
2024-01-11 16:20:53 +01:00
BEGIN_STORE_FLAGS();
STORE_FLAG(is_imported_);
2024-01-11 20:33:12 +01:00
STORE_FLAG(has_last_message_info);
2024-01-11 16:20:53 +01:00
STORE_FLAG(has_psa_type);
END_STORE_FLAGS();
td::store(origin_, storer);
td::store(date_, storer);
2024-01-11 20:33:12 +01:00
if (has_last_message_info) {
td::store(last_message_info_, storer);
2024-01-11 16:20:53 +01:00
}
if (has_psa_type) {
td::store(psa_type_, storer);
2024-01-11 16:20:53 +01:00
}
}
template <class ParserT>
void MessageForwardInfo::parse(ParserT &parser) {
2024-01-11 20:33:12 +01:00
bool has_last_message_info;
2024-01-11 16:20:53 +01:00
bool has_psa_type;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_imported_);
2024-01-11 20:33:12 +01:00
PARSE_FLAG(has_last_message_info);
2024-01-11 16:20:53 +01:00
PARSE_FLAG(has_psa_type);
END_PARSE_FLAGS();
td::parse(origin_, parser);
td::parse(date_, parser);
2024-01-11 20:33:12 +01:00
if (has_last_message_info) {
td::parse(last_message_info_, parser);
2024-01-11 16:20:53 +01:00
}
if (has_psa_type) {
td::parse(psa_type_, parser);
2024-01-11 16:20:53 +01:00
}
}
} // namespace td