blob: 23836fcab4491f1d33f3975be8afb353f4f8e37f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// 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/CurrencyAmount.h"
#include "td/telegram/StarAmount.hpp"
#include "td/telegram/TonAmount.hpp"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void CurrencyAmount::store(StorerT &storer) const {
bool has_star_amount = star_amount_ != StarAmount();
bool has_ton_amount = ton_amount_ != TonAmount();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_star_amount);
STORE_FLAG(has_ton_amount);
END_STORE_FLAGS();
td::store(type_, storer);
if (has_star_amount) {
td::store(star_amount_, storer);
}
if (has_ton_amount) {
td::store(ton_amount_, storer);
}
}
template <class ParserT>
void CurrencyAmount::parse(ParserT &parser) {
bool has_star_amount;
bool has_ton_amount;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_star_amount);
PARSE_FLAG(has_ton_amount);
END_PARSE_FLAGS();
td::parse(type_, parser);
if (has_star_amount) {
td::parse(star_amount_, parser);
}
if (has_ton_amount) {
td::parse(ton_amount_, parser);
}
}
} // namespace td
|