aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/GiveawayParameters.hpp
blob: e740a9a4a865118bf1640313fd8f918af38438a2 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// 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/GiveawayParameters.h"

#include "td/utils/tl_helpers.h"

namespace td {

template <class StorerT>
void GiveawayParameters::store(StorerT &storer) const {
  bool has_additional_channel_ids = !additional_channel_ids_.empty();
  bool has_country_codes = !country_codes_.empty();
  bool has_prize_description = !prize_description_.empty();
  BEGIN_STORE_FLAGS();
  STORE_FLAG(only_new_subscribers_);
  STORE_FLAG(has_additional_channel_ids);
  STORE_FLAG(has_country_codes);
  STORE_FLAG(winners_are_visible_);
  STORE_FLAG(has_prize_description);
  END_STORE_FLAGS();
  td::store(boosted_channel_id_, storer);
  if (has_additional_channel_ids) {
    td::store(additional_channel_ids_, storer);
  }
  td::store(date_, storer);
  if (has_country_codes) {
    td::store(country_codes_, storer);
  }
  if (has_prize_description) {
    td::store(prize_description_, storer);
  }
}

template <class ParserT>
void GiveawayParameters::parse(ParserT &parser) {
  bool has_additional_channel_ids;
  bool has_country_codes;
  bool has_prize_description;
  BEGIN_PARSE_FLAGS();
  PARSE_FLAG(only_new_subscribers_);
  PARSE_FLAG(has_additional_channel_ids);
  PARSE_FLAG(has_country_codes);
  PARSE_FLAG(winners_are_visible_);
  PARSE_FLAG(has_prize_description);
  END_PARSE_FLAGS();
  td::parse(boosted_channel_id_, parser);
  if (has_additional_channel_ids) {
    td::parse(additional_channel_ids_, parser);
  }
  td::parse(date_, parser);
  if (has_country_codes) {
    td::parse(country_codes_, parser);
  }
  if (has_prize_description) {
    td::parse(prize_description_, parser);
  }
}

}  // namespace td