Add MessageTtlSetting class.
This commit is contained in:
parent
876932843a
commit
2913b7288b
@ -340,6 +340,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/MessagesDb.cpp
|
td/telegram/MessagesDb.cpp
|
||||||
td/telegram/MessageSearchFilter.cpp
|
td/telegram/MessageSearchFilter.cpp
|
||||||
td/telegram/MessagesManager.cpp
|
td/telegram/MessagesManager.cpp
|
||||||
|
td/telegram/MessageTtlSetting.cpp
|
||||||
td/telegram/misc.cpp
|
td/telegram/misc.cpp
|
||||||
td/telegram/net/AuthDataShared.cpp
|
td/telegram/net/AuthDataShared.cpp
|
||||||
td/telegram/net/ConnectionCreator.cpp
|
td/telegram/net/ConnectionCreator.cpp
|
||||||
@ -520,6 +521,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/MessagesDb.h
|
td/telegram/MessagesDb.h
|
||||||
td/telegram/MessageSearchFilter.h
|
td/telegram/MessageSearchFilter.h
|
||||||
td/telegram/MessagesManager.h
|
td/telegram/MessagesManager.h
|
||||||
|
td/telegram/MessageTtlSetting.h
|
||||||
td/telegram/misc.h
|
td/telegram/misc.h
|
||||||
td/telegram/net/AuthDataShared.h
|
td/telegram/net/AuthDataShared.h
|
||||||
td/telegram/net/ConnectionCreator.h
|
td/telegram/net/ConnectionCreator.h
|
||||||
|
27
td/telegram/MessageTtlSetting.cpp
Normal file
27
td/telegram/MessageTtlSetting.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// 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/MessageTtlSetting.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
bool MessageTtlSetting::is_empty() const {
|
||||||
|
return ttl_period_ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 MessageTtlSetting::get_message_ttl_setting_object() const {
|
||||||
|
return ttl_period_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs) {
|
||||||
|
return lhs.ttl_period_ == rhs.ttl_period_;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtlSetting &message_ttl_setting) {
|
||||||
|
return string_builder << "MessageTtlSetting[" << message_ttl_setting.ttl_period_ << "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
57
td/telegram/MessageTtlSetting.h
Normal file
57
td/telegram/MessageTtlSetting.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/td_api.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/StringBuilder.h"
|
||||||
|
#include "td/utils/tl_helpers.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
class MessageTtlSetting {
|
||||||
|
int32 ttl_period_ = 0;
|
||||||
|
|
||||||
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtlSetting &message_ttl_setting);
|
||||||
|
|
||||||
|
friend bool operator==(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs);
|
||||||
|
|
||||||
|
public:
|
||||||
|
MessageTtlSetting() = default;
|
||||||
|
|
||||||
|
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
|
||||||
|
MessageTtlSetting(T ttl_period) = delete;
|
||||||
|
|
||||||
|
explicit MessageTtlSetting(int32 ttl_period) : ttl_period_(ttl_period) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_empty() const;
|
||||||
|
|
||||||
|
int32 get_message_ttl_setting_object() const;
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const {
|
||||||
|
td::store(ttl_period_, storer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser) {
|
||||||
|
td::parse(ttl_period_, parser);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs);
|
||||||
|
|
||||||
|
inline bool operator!=(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtlSetting &message_ttl_setting);
|
||||||
|
|
||||||
|
} // namespace td
|
Loading…
Reference in New Issue
Block a user