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/Location.h"
10 #include "td/telegram/td_api.h"
11 #include "td/telegram/telegram_api.h"
12 
13 #include "td/utils/common.h"
14 #include "td/utils/StringBuilder.h"
15 #include "td/utils/tl_helpers.h"
16 
17 namespace td {
18 
19 class DialogLocation {
20   Location location_;
21   string address_;
22 
23   friend bool operator==(const DialogLocation &lhs, const DialogLocation &rhs);
24   friend bool operator!=(const DialogLocation &lhs, const DialogLocation &rhs);
25 
26   friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogLocation &location);
27 
28  public:
29   DialogLocation() = default;
30 
31   explicit DialogLocation(telegram_api::object_ptr<telegram_api::ChannelLocation> &&channel_location_ptr);
32 
33   explicit DialogLocation(td_api::object_ptr<td_api::chatLocation> &&chat_location);
34 
35   bool empty() const;
36 
37   td_api::object_ptr<td_api::chatLocation> get_chat_location_object() const;
38 
39   telegram_api::object_ptr<telegram_api::InputGeoPoint> get_input_geo_point() const;
40 
41   const string &get_address() const;
42 
43   template <class StorerT>
store(StorerT & storer)44   void store(StorerT &storer) const {
45     using td::store;
46     store(location_, storer);
47     store(address_, storer);
48   }
49 
50   template <class ParserT>
parse(ParserT & parser)51   void parse(ParserT &parser) {
52     using td::parse;
53     parse(location_, parser);
54     parse(address_, parser);
55   }
56 };
57 
58 bool operator==(const DialogLocation &lhs, const DialogLocation &rhs);
59 bool operator!=(const DialogLocation &lhs, const DialogLocation &rhs);
60 
61 StringBuilder &operator<<(StringBuilder &string_builder, const DialogLocation &location);
62 
63 }  // namespace td
64