1 // 2 // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 // 7 #pragma once 8 9 #include "td/telegram/telegram_api.h" 10 11 #include "td/utils/common.h" 12 #include "td/utils/StringBuilder.h" 13 14 #include <functional> 15 16 namespace td { 17 18 class InputGroupCallId { 19 int64 group_call_id = 0; 20 int64 access_hash = 0; 21 22 public: 23 InputGroupCallId() = default; 24 25 explicit InputGroupCallId(const tl_object_ptr<telegram_api::inputGroupCall> &input_group_call); 26 InputGroupCallId(int64 group_call_id,int64 access_hash)27 InputGroupCallId(int64 group_call_id, int64 access_hash) : group_call_id(group_call_id), access_hash(access_hash) { 28 } 29 30 bool operator==(const InputGroupCallId &other) const { 31 return group_call_id == other.group_call_id; 32 } 33 34 bool operator!=(const InputGroupCallId &other) const { 35 return !(*this == other); 36 } 37 is_identical(const InputGroupCallId & other)38 bool is_identical(const InputGroupCallId &other) const { 39 return group_call_id == other.group_call_id && access_hash == other.access_hash; 40 } 41 is_valid()42 bool is_valid() const { 43 return group_call_id != 0; 44 } 45 get_hash()46 std::size_t get_hash() const { 47 return std::hash<int64>()(group_call_id); 48 } 49 50 tl_object_ptr<telegram_api::inputGroupCall> get_input_group_call() const; 51 52 template <class StorerT> store(StorerT & storer)53 void store(StorerT &storer) const { 54 storer.store_long(group_call_id); 55 storer.store_long(access_hash); 56 } 57 58 template <class ParserT> parse(ParserT & parser)59 void parse(ParserT &parser) { 60 group_call_id = parser.fetch_long(); 61 access_hash = parser.fetch_long(); 62 } 63 64 friend StringBuilder &operator<<(StringBuilder &string_builder, InputGroupCallId input_group_call_id); 65 }; 66 67 struct InputGroupCallIdHash { operatorInputGroupCallIdHash68 std::size_t operator()(InputGroupCallId input_group_call_id) const { 69 return input_group_call_id.get_hash(); 70 } 71 }; 72 73 } // namespace td 74