2021-02-09 14:05:00 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2021-02-09 14:05:00 +01:00
|
|
|
//
|
|
|
|
// 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/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
2021-02-25 13:56:26 +01:00
|
|
|
#include <type_traits>
|
|
|
|
|
2021-02-09 14:05:00 +01:00
|
|
|
namespace td {
|
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
class MessageTtl {
|
|
|
|
int32 period_ = 0;
|
2021-02-09 14:05:00 +01:00
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtl &message_ttl);
|
2021-02-09 14:05:00 +01:00
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
friend bool operator==(const MessageTtl &lhs, const MessageTtl &rhs);
|
2021-02-09 14:05:00 +01:00
|
|
|
|
|
|
|
public:
|
2021-12-21 12:06:15 +01:00
|
|
|
MessageTtl() = default;
|
2021-02-09 14:05:00 +01:00
|
|
|
|
|
|
|
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
|
2021-12-21 12:06:15 +01:00
|
|
|
MessageTtl(T period) = delete;
|
2021-02-09 14:05:00 +01:00
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
explicit MessageTtl(int32 period) : period_(period) {
|
2021-02-09 14:05:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool is_empty() const;
|
|
|
|
|
2022-12-28 19:46:16 +01:00
|
|
|
int32 get_message_auto_delete_time_object() const;
|
2021-02-09 14:05:00 +01:00
|
|
|
|
2022-11-29 13:44:12 +01:00
|
|
|
int32 get_input_ttl_period() const;
|
|
|
|
|
2021-02-09 14:05:00 +01:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const {
|
2021-12-21 12:06:15 +01:00
|
|
|
td::store(period_, storer);
|
2021-02-09 14:05:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
2021-12-21 12:06:15 +01:00
|
|
|
td::parse(period_, parser);
|
2021-02-09 14:05:00 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
bool operator==(const MessageTtl &lhs, const MessageTtl &rhs);
|
2021-02-09 14:05:00 +01:00
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
inline bool operator!=(const MessageTtl &lhs, const MessageTtl &rhs) {
|
2021-02-09 14:05:00 +01:00
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtl &message_ttl);
|
2021-02-09 14:05:00 +01:00
|
|
|
|
|
|
|
} // namespace td
|