This repository has been archived on 2020-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
tdlib-fork/td/telegram/FullMessageId.h
levlam 917a3af6ac Fix some includes.
GitOrigin-RevId: c82e599631dd678f2c69fbf7fd3e9b3cd23ed965
2019-11-26 21:57:48 +03:00

69 lines
1.7 KiB
C++

//
// 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/telegram/DialogId.h"
#include "td/telegram/MessageId.h"
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
namespace td {
struct FullMessageId {
private:
DialogId dialog_id;
MessageId message_id;
public:
FullMessageId() : dialog_id(), message_id() {
}
FullMessageId(DialogId dialog_id, MessageId message_id) : dialog_id(dialog_id), message_id(message_id) {
}
bool operator==(const FullMessageId &other) const {
return dialog_id == other.dialog_id && message_id == other.message_id;
}
bool operator!=(const FullMessageId &other) const {
return !(*this == other);
}
DialogId get_dialog_id() const {
return dialog_id;
}
MessageId get_message_id() const {
return message_id;
}
template <class StorerT>
void store(StorerT &storer) const {
dialog_id.store(storer);
message_id.store(storer);
}
template <class ParserT>
void parse(ParserT &parser) {
dialog_id.parse(parser);
message_id.parse(parser);
}
};
struct FullMessageIdHash {
std::size_t operator()(FullMessageId full_message_id) const {
return DialogIdHash()(full_message_id.get_dialog_id()) * 2023654985u +
MessageIdHash()(full_message_id.get_message_id());
}
};
inline StringBuilder &operator<<(StringBuilder &string_builder, FullMessageId full_message_id) {
return string_builder << full_message_id.get_message_id() << " in " << full_message_id.get_dialog_id();
}
} // namespace td