From 47d4c08de27502e6f355be63820bd14cc2c71bb8 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 23 Oct 2021 21:56:37 +0300 Subject: [PATCH] Improve field names style. --- td/telegram/ContactsManager.cpp | 10 ++--- td/telegram/DialogParticipant.cpp | 66 +++++++++++++++---------------- td/telegram/DialogParticipant.h | 27 +++++++------ 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 7198b4ace..009caab15 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -14801,7 +14801,7 @@ DialogParticipants ContactsManager::search_private_chat_participants(UserId my_u const string &query, int32 limit, DialogParticipantsFilter filter) const { vector dialog_ids; - switch (filter.type) { + switch (filter.type_) { case DialogParticipantsFilter::Type::Contacts: if (peer_user_id.is_valid() && is_user_contact(peer_user_id)) { dialog_ids.push_back(DialogId(peer_user_id)); @@ -14862,7 +14862,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin td_api::object_ptr request_filter; string additional_query; int32 additional_limit = 0; - switch (filter.type) { + switch (filter.type_) { case DialogParticipantsFilter::Type::Contacts: request_filter = td_api::make_object(); break; @@ -14880,7 +14880,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin break; case DialogParticipantsFilter::Type::Mention: request_filter = - td_api::make_object(query, filter.top_thread_message_id.get()); + td_api::make_object(query, filter.top_thread_message_id_.get()); break; case DialogParticipantsFilter::Type::Bots: request_filter = td_api::make_object(); @@ -14888,7 +14888,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin default: UNREACHABLE(); } - switch (filter.type) { + switch (filter.type_) { case DialogParticipantsFilter::Type::Contacts: case DialogParticipantsFilter::Type::Administrators: case DialogParticipantsFilter::Type::Bots: @@ -14988,7 +14988,7 @@ void ContactsManager::do_search_chat_participants(ChatId chat_id, const string & } auto is_dialog_participant_suitable = [this, filter](const DialogParticipant &participant) { - switch (filter.type) { + switch (filter.type_) { case DialogParticipantsFilter::Type::Contacts: return participant.dialog_id.get_type() == DialogType::User && is_user_contact(participant.dialog_id.get_user_id()); diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index 229cbaf5a..effd77333 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -770,30 +770,30 @@ td_api::object_ptr DialogParticipants::get_chat_members_obj tl_object_ptr ChannelParticipantsFilter::get_input_channel_participants_filter() const { - switch (type) { + switch (type_) { case Type::Recent: return make_tl_object(); case Type::Contacts: - return make_tl_object(query); + return make_tl_object(query_); case Type::Administrators: return make_tl_object(); case Type::Search: - return make_tl_object(query); + return make_tl_object(query_); case Type::Mention: { int32 flags = 0; - if (!query.empty()) { + if (!query_.empty()) { flags |= telegram_api::channelParticipantsMentions::Q_MASK; } - if (top_thread_message_id.is_valid()) { + if (top_thread_message_id_.is_valid()) { flags |= telegram_api::channelParticipantsMentions::TOP_MSG_ID_MASK; } return make_tl_object( - flags, query, top_thread_message_id.get_server_message_id().get()); + flags, query_, top_thread_message_id_.get_server_message_id().get()); } case Type::Restricted: - return make_tl_object(query); + return make_tl_object(query_); case Type::Banned: - return make_tl_object(query); + return make_tl_object(query_); case Type::Bots: return make_tl_object(); default: @@ -804,67 +804,67 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const { ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr &filter) { if (filter == nullptr) { - type = Type::Recent; + type_ = Type::Recent; return; } switch (filter->get_id()) { case td_api::supergroupMembersFilterRecent::ID: - type = Type::Recent; + type_ = Type::Recent; return; case td_api::supergroupMembersFilterContacts::ID: - type = Type::Contacts; - query = static_cast(filter.get())->query_; + type_ = Type::Contacts; + query_ = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterAdministrators::ID: - type = Type::Administrators; + type_ = Type::Administrators; return; case td_api::supergroupMembersFilterSearch::ID: - type = Type::Search; - query = static_cast(filter.get())->query_; + type_ = Type::Search; + query_ = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterMention::ID: { auto mention_filter = static_cast(filter.get()); - type = Type::Mention; - query = mention_filter->query_; - top_thread_message_id = MessageId(mention_filter->message_thread_id_); - if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server()) { - top_thread_message_id = MessageId(); + type_ = Type::Mention; + query_ = mention_filter->query_; + top_thread_message_id_ = MessageId(mention_filter->message_thread_id_); + if (!top_thread_message_id_.is_valid() || !top_thread_message_id_.is_server()) { + top_thread_message_id_ = MessageId(); } return; } case td_api::supergroupMembersFilterRestricted::ID: - type = Type::Restricted; - query = static_cast(filter.get())->query_; + type_ = Type::Restricted; + query_ = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterBanned::ID: - type = Type::Banned; - query = static_cast(filter.get())->query_; + type_ = Type::Banned; + query_ = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterBots::ID: - type = Type::Bots; + type_ = Type::Bots; return; default: UNREACHABLE(); - type = Type::Recent; + type_ = Type::Recent; } } StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter) { - switch (filter.type) { + switch (filter.type_) { case ChannelParticipantsFilter::Type::Recent: return string_builder << "Recent"; case ChannelParticipantsFilter::Type::Contacts: - return string_builder << "Contacts \"" << filter.query << '"'; + return string_builder << "Contacts \"" << filter.query_ << '"'; case ChannelParticipantsFilter::Type::Administrators: return string_builder << "Administrators"; case ChannelParticipantsFilter::Type::Search: - return string_builder << "Search \"" << filter.query << '"'; + return string_builder << "Search \"" << filter.query_ << '"'; case ChannelParticipantsFilter::Type::Mention: - return string_builder << "Mention \"" << filter.query << "\" in thread of " << filter.top_thread_message_id; + return string_builder << "Mention \"" << filter.query_ << "\" in thread of " << filter.top_thread_message_id_; case ChannelParticipantsFilter::Type::Restricted: - return string_builder << "Restricted \"" << filter.query << '"'; + return string_builder << "Restricted \"" << filter.query_ << '"'; case ChannelParticipantsFilter::Type::Banned: - return string_builder << "Banned \"" << filter.query << '"'; + return string_builder << "Banned \"" << filter.query_ << '"'; case ChannelParticipantsFilter::Type::Bots: return string_builder << "Bots"; default: @@ -874,7 +874,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipan } StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipantsFilter &filter) { - switch (filter.type) { + switch (filter.type_) { case DialogParticipantsFilter::Type::Contacts: return string_builder << "Contacts"; case DialogParticipantsFilter::Type::Administrators: diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index f746f450f..3f779b1f7 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -448,9 +448,10 @@ struct DialogParticipants { }; class ChannelParticipantsFilter { - enum class Type : int32 { Recent, Contacts, Administrators, Search, Mention, Restricted, Banned, Bots } type; - string query; - MessageId top_thread_message_id; + enum class Type : int32 { Recent, Contacts, Administrators, Search, Mention, Restricted, Banned, Bots }; + Type type_; + string query_; + MessageId top_thread_message_id_; friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter); @@ -460,31 +461,31 @@ class ChannelParticipantsFilter { tl_object_ptr get_input_channel_participants_filter() const; bool is_administrators() const { - return type == Type::Administrators; + return type_ == Type::Administrators; } bool is_bots() const { - return type == Type::Bots; + return type_ == Type::Bots; } bool is_recent() const { - return type == Type::Recent; + return type_ == Type::Recent; } bool is_contacts() const { - return type == Type::Contacts; + return type_ == Type::Contacts; } bool is_search() const { - return type == Type::Search; + return type_ == Type::Search; } bool is_restricted() const { - return type == Type::Restricted; + return type_ == Type::Restricted; } bool is_banned() const { - return type == Type::Banned; + return type_ == Type::Banned; } }; @@ -493,11 +494,11 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipan class DialogParticipantsFilter { public: enum class Type : int32 { Contacts, Administrators, Members, Restricted, Banned, Mention, Bots }; - Type type; - MessageId top_thread_message_id; + Type type_; + MessageId top_thread_message_id_; explicit DialogParticipantsFilter(Type type, MessageId top_thread_message_id = MessageId()) - : type(type), top_thread_message_id(top_thread_message_id) { + : type_(type), top_thread_message_id_(top_thread_message_id) { } };