tdlight/td/telegram/BotMenuButton.h
2022-04-06 20:24:54 +03:00

78 lines
1.9 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// 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/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"
namespace td {
class Td;
class BotMenuButton {
string text_;
string url_;
friend bool operator==(const BotMenuButton &lhs, const BotMenuButton &rhs);
public:
BotMenuButton() = default;
BotMenuButton(string &&text, string &&url) : text_(std::move(text)), url_(std::move(url)) {
}
static unique_ptr<BotMenuButton> get_bot_menu_button(
telegram_api::object_ptr<telegram_api::BotMenuButton> &&bot_menu_button);
td_api::object_ptr<td_api::botMenuButton> get_bot_menu_button_object() const;
template <class StorerT>
void store(StorerT &storer) const {
bool has_text = !text_.empty();
bool has_url = !url_.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_text);
STORE_FLAG(has_url);
END_STORE_FLAGS();
if (has_text) {
td::store(text_, storer);
}
if (has_url) {
td::store(url_, storer);
}
}
template <class ParserT>
void parse(ParserT &parser) {
bool has_text;
bool has_url;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_text);
PARSE_FLAG(has_url);
END_PARSE_FLAGS();
if (has_text) {
td::parse(text_, parser);
}
if (has_url) {
td::parse(url_, parser);
}
}
};
bool operator==(const BotMenuButton &lhs, const BotMenuButton &rhs);
bool operator==(const unique_ptr<BotMenuButton> &lhs, const unique_ptr<BotMenuButton> &rhs);
inline bool operator!=(const unique_ptr<BotMenuButton> &lhs, const unique_ptr<BotMenuButton> &rhs) {
return !(lhs == rhs);
}
} // namespace td