Add ServerMessageId.h.

GitOrigin-RevId: f71d1f41f84c2263890875271f47f938e792aa55
This commit is contained in:
levlam 2019-11-26 19:33:18 +03:00
parent decae25ea4
commit 099e767b6b
14 changed files with 66 additions and 39 deletions

View File

@ -630,6 +630,7 @@ set(TDLIB_SOURCE
td/telegram/SecureValue.h
td/telegram/SendCodeHelper.h
td/telegram/SequenceDispatcher.h
td/telegram/ServerMessageId.h
td/telegram/SetWithPosition.h
td/telegram/StateManager.h
td/telegram/StickerSetId.h

View File

@ -8,6 +8,7 @@
#include "td/telegram/MessageId.h"
#include "td/telegram/MessagesDb.h"
#include "td/telegram/NotificationId.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"

View File

@ -30,6 +30,7 @@
#include "td/telegram/Photo.h"
#include "td/telegram/Photo.hpp"
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/StickerSetId.hpp"
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"

View File

@ -8,6 +8,7 @@
#include "td/telegram/DialogId.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/ServerMessageId.h"
#include "td/utils/StringBuilder.h"

View File

@ -8,6 +8,7 @@
#include "td/telegram/MessageEntity.h"
#include "td/telegram/misc.h"
#include "td/telegram/ServerMessageId.h"
#include "td/utils/logging.h"

View File

@ -46,6 +46,7 @@
#include "td/telegram/secret_api.hpp"
#include "td/telegram/SecureValue.h"
#include "td/telegram/SecureValue.hpp"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/StickersManager.hpp"
#include "td/telegram/Td.h"

View File

@ -7,6 +7,7 @@
#pragma once
#include "td/telegram/DialogId.h"
#include "td/telegram/ServerMessageId.h"
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
@ -18,44 +19,6 @@
namespace td {
class ServerMessageId {
int32 id = 0;
public:
ServerMessageId() = default;
explicit ServerMessageId(int32 message_id) : id(message_id) {
}
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
ServerMessageId(T message_id) = delete;
bool is_valid() const {
return id > 0;
}
int32 get() const {
return id;
}
bool operator==(const ServerMessageId &other) const {
return id == other.id;
}
bool operator!=(const ServerMessageId &other) const {
return id != other.id;
}
template <class StorerT>
void store(StorerT &storer) const {
storer.store_int(id);
}
template <class ParserT>
void parse(ParserT &parser) {
id = parser.fetch_int();
}
};
enum class MessageType : int32 { None, Server, Local, YetUnsent };
class MessageId {

View File

@ -9,6 +9,7 @@
#include "td/telegram/DialogId.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/NotificationId.h"
#include "td/telegram/ServerMessageId.h"
#include "td/actor/PromiseFuture.h"

View File

@ -38,6 +38,7 @@
#include "td/telegram/RestrictionReason.h"
#include "td/telegram/SecretChatId.h"
#include "td/telegram/SecretInputMedia.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"

View File

@ -24,6 +24,7 @@
#include "td/telegram/Photo.h"
#include "td/telegram/Photo.hpp"
#include "td/telegram/SecretChatId.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"

View File

@ -8,8 +8,8 @@
#include "td/actor/PromiseFuture.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/Photo.h"
#include "td/telegram/ServerMessageId.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"

View File

@ -8,6 +8,7 @@
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/SecretChatId.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/UniqueId.h"
#include "td/telegram/secret_api.hpp"

View File

@ -0,0 +1,53 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
//
// 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 <type_traits>
namespace td {
class ServerMessageId {
int32 id = 0;
public:
ServerMessageId() = default;
explicit ServerMessageId(int32 message_id) : id(message_id) {
}
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
ServerMessageId(T message_id) = delete;
bool is_valid() const {
return id > 0;
}
int32 get() const {
return id;
}
bool operator==(const ServerMessageId &other) const {
return id == other.id;
}
bool operator!=(const ServerMessageId &other) const {
return id != other.id;
}
template <class StorerT>
void store(StorerT &storer) const {
storer.store_int(id);
}
template <class ParserT>
void parse(ParserT &parser) {
id = parser.fetch_int();
}
};
} // namespace td

View File

@ -33,6 +33,7 @@
#include "td/telegram/PrivacyManager.h"
#include "td/telegram/SecretChatId.h"
#include "td/telegram/SecretChatsManager.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/StickerSetId.h"
#include "td/telegram/StickersManager.h"