tdlight/td/telegram/PremiumGiftOption.hpp

78 lines
1.8 KiB
C++
Raw Normal View History

2022-07-01 14:57:38 +02:00
//
// 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/PremiumGiftOption.h"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void PremiumGiftOption::store(StorerT &storer) const {
bool has_months = months_ != 0;
bool has_currency = !currency_.empty();
bool has_amount = amount_ != 0;
bool has_bot_url = !bot_url_.empty();
bool has_store_product = !store_product_.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_months);
STORE_FLAG(has_currency);
STORE_FLAG(has_amount);
STORE_FLAG(has_bot_url);
STORE_FLAG(has_store_product);
END_STORE_FLAGS();
if (has_months) {
td::store(months_, storer);
}
if (has_currency) {
td::store(currency_, storer);
}
if (has_amount) {
td::store(amount_, storer);
}
if (has_bot_url) {
td::store(bot_url_, storer);
}
if (has_store_product) {
td::store(store_product_, storer);
}
}
template <class ParserT>
void PremiumGiftOption::parse(ParserT &parser) {
bool has_months;
bool has_currency;
bool has_amount;
bool has_bot_url;
bool has_store_product;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_months);
PARSE_FLAG(has_currency);
PARSE_FLAG(has_amount);
PARSE_FLAG(has_bot_url);
PARSE_FLAG(has_store_product);
END_PARSE_FLAGS();
if (has_months) {
td::parse(months_, parser);
}
if (has_currency) {
td::parse(currency_, parser);
}
if (has_amount) {
td::parse(amount_, parser);
}
if (has_bot_url) {
td::parse(bot_url_, parser);
}
if (has_store_product) {
td::parse(store_product_, parser);
}
}
} // namespace td