tdlight/td/telegram/MessageInputReplyTo.hpp

81 lines
2.0 KiB
C++
Raw Normal View History

2023-10-24 14:02:57 +02:00
//
2024-01-01 01:07:21 +01:00
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
2023-10-24 14:02:57 +02:00
//
// 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/MessageInputReplyTo.h"
#include "td/telegram/MessageOrigin.hpp"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void MessageInputReplyTo::store(StorerT &storer) const {
bool has_message_id = message_id_.is_valid();
bool has_story_full_id = story_full_id_.is_valid();
2023-10-27 12:06:38 +02:00
bool has_quote = !quote_.text.empty();
bool has_dialog_id = dialog_id_.is_valid();
2023-11-10 11:29:37 +01:00
bool has_quote_position = quote_position_ != 0;
2023-10-24 14:02:57 +02:00
BEGIN_STORE_FLAGS();
STORE_FLAG(has_message_id);
STORE_FLAG(has_story_full_id);
2023-10-27 12:06:38 +02:00
STORE_FLAG(has_quote);
STORE_FLAG(has_dialog_id);
2023-11-10 11:29:37 +01:00
STORE_FLAG(has_quote_position);
2023-10-24 14:02:57 +02:00
END_STORE_FLAGS();
if (has_message_id) {
td::store(message_id_, storer);
}
if (has_story_full_id) {
td::store(story_full_id_, storer);
}
2023-10-27 12:06:38 +02:00
if (has_quote) {
td::store(quote_, storer);
}
if (has_dialog_id) {
td::store(dialog_id_, storer);
}
2023-11-10 11:29:37 +01:00
if (has_quote_position) {
td::store(quote_position_, storer);
}
2023-10-24 14:02:57 +02:00
}
template <class ParserT>
void MessageInputReplyTo::parse(ParserT &parser) {
2023-10-27 12:06:38 +02:00
bool has_message_id;
bool has_story_full_id;
bool has_quote;
bool has_dialog_id;
2023-11-10 11:29:37 +01:00
bool has_quote_position;
2023-10-24 14:02:57 +02:00
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_message_id);
PARSE_FLAG(has_story_full_id);
2023-10-27 12:06:38 +02:00
PARSE_FLAG(has_quote);
PARSE_FLAG(has_dialog_id);
2023-11-10 11:29:37 +01:00
PARSE_FLAG(has_quote_position);
2023-10-24 14:02:57 +02:00
END_PARSE_FLAGS();
if (has_message_id) {
td::parse(message_id_, parser);
}
if (has_story_full_id) {
td::parse(story_full_id_, parser);
}
2023-10-27 12:06:38 +02:00
if (has_quote) {
td::parse(quote_, parser);
2023-10-29 00:25:21 +02:00
remove_unallowed_quote_entities(quote_);
2023-10-27 12:06:38 +02:00
}
if (has_dialog_id) {
td::parse(dialog_id_, parser);
}
2023-11-10 11:29:37 +01:00
if (has_quote_position) {
td::parse(quote_position_, parser);
}
2023-10-24 14:02:57 +02:00
}
} // namespace td