Add MessageEntity.hpp.

GitOrigin-RevId: 424a9918012d2285a04beead79c6edad1fb7ca28
This commit is contained in:
levlam 2018-04-02 01:45:51 +03:00
parent 92e9550ebd
commit f63a73b6a6
5 changed files with 62 additions and 34 deletions

View File

@ -547,6 +547,7 @@ set(TDLIB_SOURCE
td/telegram/files/FileId.hpp
td/telegram/files/FileManager.hpp
td/telegram/Game.hpp
td/telegram/MessageEntity.hpp
td/telegram/Payments.hpp
td/telegram/Photo.hpp
td/telegram/ReplyMarkup.hpp

View File

@ -8,6 +8,7 @@
#include "td/telegram/Game.h"
#include "td/telegram/AnimationsManager.hpp"
#include "td/telegram/MessageEntity.hpp"
#include "td/telegram/Photo.hpp"
#include "td/telegram/Version.h"

View File

@ -12,7 +12,6 @@
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/tl_helpers.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"
@ -76,34 +75,11 @@ class MessageEntity {
return !(*this == rhs);
}
// TODO move to hpp
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
store(type, storer);
store(offset, storer);
store(length, storer);
if (type == Type::PreCode || type == Type::TextUrl) {
store(argument, storer);
}
if (type == Type::MentionName) {
store(user_id, storer);
}
}
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
parse(type, parser);
parse(offset, parser);
parse(length, parser);
if (type == Type::PreCode || type == Type::TextUrl) {
parse(argument, parser);
}
if (type == Type::MentionName) {
parse(user_id, parser);
}
}
void parse(ParserT &parser);
};
StringBuilder &operator<<(StringBuilder &string_builder, const MessageEntity &message_entity);
@ -113,16 +89,10 @@ struct FormattedText {
vector<MessageEntity> entities;
template <class StorerT>
void store(StorerT &storer) const {
td::store(text, storer);
td::store(entities, storer);
}
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser) {
td::parse(text, parser);
td::parse(entities, parser);
}
void parse(ParserT &parser);
};
inline bool operator==(const FormattedText &lhs, const FormattedText &rhs) {

View File

@ -0,0 +1,55 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
//
// 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/MessageEntity.h"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void MessageEntity::store(StorerT &storer) const {
using td::store;
store(type, storer);
store(offset, storer);
store(length, storer);
if (type == Type::PreCode || type == Type::TextUrl) {
store(argument, storer);
}
if (type == Type::MentionName) {
store(user_id, storer);
}
}
template <class ParserT>
void MessageEntity::parse(ParserT &parser) {
using td::parse;
parse(type, parser);
parse(offset, parser);
parse(length, parser);
if (type == Type::PreCode || type == Type::TextUrl) {
parse(argument, parser);
}
if (type == Type::MentionName) {
parse(user_id, parser);
}
}
template <class StorerT>
void FormattedText::store(StorerT &storer) const {
td::store(text, storer);
td::store(entities, storer);
}
template <class ParserT>
void FormattedText::parse(ParserT &parser) {
td::parse(text, parser);
td::parse(entities, parser);
}
} // namespace td

View File

@ -32,6 +32,7 @@
#include "td/telegram/HashtagHints.h"
#include "td/telegram/InlineQueriesManager.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessageEntity.hpp"
#include "td/telegram/MessagesDb.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/NetActor.h"