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/utils/common.h"
10 #include "td/utils/StringBuilder.h"
11 
12 #include <functional>
13 #include <type_traits>
14 
15 namespace td {
16 
17 class StickerSetId {
18   int64 id = 0;
19 
20  public:
21   StickerSetId() = default;
22 
StickerSetId(int64 sticker_set_id)23   explicit constexpr StickerSetId(int64 sticker_set_id) : id(sticker_set_id) {
24   }
25   template <class T, typename = std::enable_if_t<std::is_convertible<T, int64>::value>>
26   StickerSetId(T sticker_set_id) = delete;
27 
is_valid()28   bool is_valid() const {
29     return id != 0;
30   }
31 
get()32   int64 get() const {
33     return id;
34   }
35 
36   bool operator==(const StickerSetId &other) const {
37     return id == other.id;
38   }
39 
40   bool operator!=(const StickerSetId &other) const {
41     return id != other.id;
42   }
43 };
44 
45 struct StickerSetIdHash {
operatorStickerSetIdHash46   std::size_t operator()(StickerSetId sticker_set_id) const {
47     return std::hash<int64>()(sticker_set_id.get());
48   }
49 };
50 
51 inline StringBuilder &operator<<(StringBuilder &string_builder, StickerSetId sticker_set_id) {
52   return string_builder << "sticker set " << sticker_set_id.get();
53 }
54 
55 }  // namespace td
56