2021-03-15 16:32:28 +01:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
#include "td/telegram/GroupCallParticipantOrder.h"
|
|
|
|
|
2021-03-15 16:53:51 +01:00
|
|
|
#include "td/utils/misc.h"
|
2021-05-17 14:21:11 +02:00
|
|
|
#include "td/utils/SliceBuilder.h"
|
2021-03-15 16:53:51 +01:00
|
|
|
|
2021-03-15 16:32:28 +01:00
|
|
|
#include <limits>
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2021-05-07 01:10:37 +02:00
|
|
|
GroupCallParticipantOrder GroupCallParticipantOrder::min() {
|
2021-07-09 17:48:10 +02:00
|
|
|
return GroupCallParticipantOrder(false, 0, 0, 1);
|
2021-05-07 01:10:37 +02:00
|
|
|
}
|
|
|
|
|
2021-03-15 16:32:28 +01:00
|
|
|
GroupCallParticipantOrder GroupCallParticipantOrder::max() {
|
2021-07-09 17:48:10 +02:00
|
|
|
return GroupCallParticipantOrder(true, std::numeric_limits<int32>::max(), std::numeric_limits<int64>::max(),
|
2021-03-15 16:32:28 +01:00
|
|
|
std::numeric_limits<int32>::max());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GroupCallParticipantOrder::is_valid() const {
|
|
|
|
return *this != GroupCallParticipantOrder();
|
|
|
|
}
|
|
|
|
|
2021-03-15 16:53:51 +01:00
|
|
|
string GroupCallParticipantOrder::get_group_call_participant_order_object() const {
|
2021-04-05 00:19:08 +02:00
|
|
|
if (!is_valid()) {
|
|
|
|
return string();
|
|
|
|
}
|
2021-07-09 17:48:10 +02:00
|
|
|
return PSTRING() << (has_video ? '1' : '0') << lpad0(to_string(active_date), 10)
|
|
|
|
<< lpad0(to_string(raise_hand_rating), 19) << lpad0(to_string(joined_date), 10);
|
2021-03-15 16:32:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
|
2021-07-09 17:48:10 +02:00
|
|
|
return lhs.has_video == rhs.has_video && lhs.active_date == rhs.active_date && lhs.joined_date == rhs.joined_date &&
|
2021-03-15 16:32:28 +01:00
|
|
|
lhs.raise_hand_rating == rhs.raise_hand_rating;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
|
2021-07-09 17:48:10 +02:00
|
|
|
auto lhs_has_video = static_cast<int32>(lhs.has_video);
|
|
|
|
auto rhs_has_video = static_cast<int32>(rhs.has_video);
|
|
|
|
return std::tie(lhs_has_video, lhs.active_date, lhs.raise_hand_rating, lhs.joined_date) <
|
|
|
|
std::tie(rhs_has_video, rhs.active_date, rhs.raise_hand_rating, rhs.joined_date);
|
2021-03-15 16:32:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<=(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
|
|
|
|
return !(rhs < lhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
|
|
|
|
return rhs < lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>=(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
|
|
|
|
return !(lhs < rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder,
|
|
|
|
const GroupCallParticipantOrder &group_call_participant_order) {
|
2021-07-09 17:48:10 +02:00
|
|
|
return string_builder << group_call_participant_order.has_video << '/' << group_call_participant_order.active_date
|
|
|
|
<< '/' << group_call_participant_order.raise_hand_rating << '/'
|
2021-03-15 16:32:28 +01:00
|
|
|
<< group_call_participant_order.joined_date;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|