Improve field names style.

This commit is contained in:
levlam 2021-10-23 21:56:37 +03:00
parent c24501f2d9
commit 47d4c08de2
3 changed files with 52 additions and 51 deletions

View File

@ -14801,7 +14801,7 @@ DialogParticipants ContactsManager::search_private_chat_participants(UserId my_u
const string &query, int32 limit, const string &query, int32 limit,
DialogParticipantsFilter filter) const { DialogParticipantsFilter filter) const {
vector<DialogId> dialog_ids; vector<DialogId> dialog_ids;
switch (filter.type) { switch (filter.type_) {
case DialogParticipantsFilter::Type::Contacts: case DialogParticipantsFilter::Type::Contacts:
if (peer_user_id.is_valid() && is_user_contact(peer_user_id)) { if (peer_user_id.is_valid() && is_user_contact(peer_user_id)) {
dialog_ids.push_back(DialogId(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<td_api::SupergroupMembersFilter> request_filter; td_api::object_ptr<td_api::SupergroupMembersFilter> request_filter;
string additional_query; string additional_query;
int32 additional_limit = 0; int32 additional_limit = 0;
switch (filter.type) { switch (filter.type_) {
case DialogParticipantsFilter::Type::Contacts: case DialogParticipantsFilter::Type::Contacts:
request_filter = td_api::make_object<td_api::supergroupMembersFilterContacts>(); request_filter = td_api::make_object<td_api::supergroupMembersFilterContacts>();
break; break;
@ -14880,7 +14880,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin
break; break;
case DialogParticipantsFilter::Type::Mention: case DialogParticipantsFilter::Type::Mention:
request_filter = request_filter =
td_api::make_object<td_api::supergroupMembersFilterMention>(query, filter.top_thread_message_id.get()); td_api::make_object<td_api::supergroupMembersFilterMention>(query, filter.top_thread_message_id_.get());
break; break;
case DialogParticipantsFilter::Type::Bots: case DialogParticipantsFilter::Type::Bots:
request_filter = td_api::make_object<td_api::supergroupMembersFilterBots>(); request_filter = td_api::make_object<td_api::supergroupMembersFilterBots>();
@ -14888,7 +14888,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin
default: default:
UNREACHABLE(); UNREACHABLE();
} }
switch (filter.type) { switch (filter.type_) {
case DialogParticipantsFilter::Type::Contacts: case DialogParticipantsFilter::Type::Contacts:
case DialogParticipantsFilter::Type::Administrators: case DialogParticipantsFilter::Type::Administrators:
case DialogParticipantsFilter::Type::Bots: 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) { auto is_dialog_participant_suitable = [this, filter](const DialogParticipant &participant) {
switch (filter.type) { switch (filter.type_) {
case DialogParticipantsFilter::Type::Contacts: case DialogParticipantsFilter::Type::Contacts:
return participant.dialog_id.get_type() == DialogType::User && return participant.dialog_id.get_type() == DialogType::User &&
is_user_contact(participant.dialog_id.get_user_id()); is_user_contact(participant.dialog_id.get_user_id());

View File

@ -770,30 +770,30 @@ td_api::object_ptr<td_api::chatMembers> DialogParticipants::get_chat_members_obj
tl_object_ptr<telegram_api::ChannelParticipantsFilter> tl_object_ptr<telegram_api::ChannelParticipantsFilter>
ChannelParticipantsFilter::get_input_channel_participants_filter() const { ChannelParticipantsFilter::get_input_channel_participants_filter() const {
switch (type) { switch (type_) {
case Type::Recent: case Type::Recent:
return make_tl_object<telegram_api::channelParticipantsRecent>(); return make_tl_object<telegram_api::channelParticipantsRecent>();
case Type::Contacts: case Type::Contacts:
return make_tl_object<telegram_api::channelParticipantsContacts>(query); return make_tl_object<telegram_api::channelParticipantsContacts>(query_);
case Type::Administrators: case Type::Administrators:
return make_tl_object<telegram_api::channelParticipantsAdmins>(); return make_tl_object<telegram_api::channelParticipantsAdmins>();
case Type::Search: case Type::Search:
return make_tl_object<telegram_api::channelParticipantsSearch>(query); return make_tl_object<telegram_api::channelParticipantsSearch>(query_);
case Type::Mention: { case Type::Mention: {
int32 flags = 0; int32 flags = 0;
if (!query.empty()) { if (!query_.empty()) {
flags |= telegram_api::channelParticipantsMentions::Q_MASK; 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; flags |= telegram_api::channelParticipantsMentions::TOP_MSG_ID_MASK;
} }
return make_tl_object<telegram_api::channelParticipantsMentions>( return make_tl_object<telegram_api::channelParticipantsMentions>(
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: case Type::Restricted:
return make_tl_object<telegram_api::channelParticipantsBanned>(query); return make_tl_object<telegram_api::channelParticipantsBanned>(query_);
case Type::Banned: case Type::Banned:
return make_tl_object<telegram_api::channelParticipantsKicked>(query); return make_tl_object<telegram_api::channelParticipantsKicked>(query_);
case Type::Bots: case Type::Bots:
return make_tl_object<telegram_api::channelParticipantsBots>(); return make_tl_object<telegram_api::channelParticipantsBots>();
default: default:
@ -804,67 +804,67 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const {
ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr<td_api::SupergroupMembersFilter> &filter) { ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr<td_api::SupergroupMembersFilter> &filter) {
if (filter == nullptr) { if (filter == nullptr) {
type = Type::Recent; type_ = Type::Recent;
return; return;
} }
switch (filter->get_id()) { switch (filter->get_id()) {
case td_api::supergroupMembersFilterRecent::ID: case td_api::supergroupMembersFilterRecent::ID:
type = Type::Recent; type_ = Type::Recent;
return; return;
case td_api::supergroupMembersFilterContacts::ID: case td_api::supergroupMembersFilterContacts::ID:
type = Type::Contacts; type_ = Type::Contacts;
query = static_cast<const td_api::supergroupMembersFilterContacts *>(filter.get())->query_; query_ = static_cast<const td_api::supergroupMembersFilterContacts *>(filter.get())->query_;
return; return;
case td_api::supergroupMembersFilterAdministrators::ID: case td_api::supergroupMembersFilterAdministrators::ID:
type = Type::Administrators; type_ = Type::Administrators;
return; return;
case td_api::supergroupMembersFilterSearch::ID: case td_api::supergroupMembersFilterSearch::ID:
type = Type::Search; type_ = Type::Search;
query = static_cast<const td_api::supergroupMembersFilterSearch *>(filter.get())->query_; query_ = static_cast<const td_api::supergroupMembersFilterSearch *>(filter.get())->query_;
return; return;
case td_api::supergroupMembersFilterMention::ID: { case td_api::supergroupMembersFilterMention::ID: {
auto mention_filter = static_cast<const td_api::supergroupMembersFilterMention *>(filter.get()); auto mention_filter = static_cast<const td_api::supergroupMembersFilterMention *>(filter.get());
type = Type::Mention; type_ = Type::Mention;
query = mention_filter->query_; query_ = mention_filter->query_;
top_thread_message_id = MessageId(mention_filter->message_thread_id_); top_thread_message_id_ = MessageId(mention_filter->message_thread_id_);
if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server()) { if (!top_thread_message_id_.is_valid() || !top_thread_message_id_.is_server()) {
top_thread_message_id = MessageId(); top_thread_message_id_ = MessageId();
} }
return; return;
} }
case td_api::supergroupMembersFilterRestricted::ID: case td_api::supergroupMembersFilterRestricted::ID:
type = Type::Restricted; type_ = Type::Restricted;
query = static_cast<const td_api::supergroupMembersFilterRestricted *>(filter.get())->query_; query_ = static_cast<const td_api::supergroupMembersFilterRestricted *>(filter.get())->query_;
return; return;
case td_api::supergroupMembersFilterBanned::ID: case td_api::supergroupMembersFilterBanned::ID:
type = Type::Banned; type_ = Type::Banned;
query = static_cast<const td_api::supergroupMembersFilterBanned *>(filter.get())->query_; query_ = static_cast<const td_api::supergroupMembersFilterBanned *>(filter.get())->query_;
return; return;
case td_api::supergroupMembersFilterBots::ID: case td_api::supergroupMembersFilterBots::ID:
type = Type::Bots; type_ = Type::Bots;
return; return;
default: default:
UNREACHABLE(); UNREACHABLE();
type = Type::Recent; type_ = Type::Recent;
} }
} }
StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter) { StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter) {
switch (filter.type) { switch (filter.type_) {
case ChannelParticipantsFilter::Type::Recent: case ChannelParticipantsFilter::Type::Recent:
return string_builder << "Recent"; return string_builder << "Recent";
case ChannelParticipantsFilter::Type::Contacts: case ChannelParticipantsFilter::Type::Contacts:
return string_builder << "Contacts \"" << filter.query << '"'; return string_builder << "Contacts \"" << filter.query_ << '"';
case ChannelParticipantsFilter::Type::Administrators: case ChannelParticipantsFilter::Type::Administrators:
return string_builder << "Administrators"; return string_builder << "Administrators";
case ChannelParticipantsFilter::Type::Search: case ChannelParticipantsFilter::Type::Search:
return string_builder << "Search \"" << filter.query << '"'; return string_builder << "Search \"" << filter.query_ << '"';
case ChannelParticipantsFilter::Type::Mention: 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: case ChannelParticipantsFilter::Type::Restricted:
return string_builder << "Restricted \"" << filter.query << '"'; return string_builder << "Restricted \"" << filter.query_ << '"';
case ChannelParticipantsFilter::Type::Banned: case ChannelParticipantsFilter::Type::Banned:
return string_builder << "Banned \"" << filter.query << '"'; return string_builder << "Banned \"" << filter.query_ << '"';
case ChannelParticipantsFilter::Type::Bots: case ChannelParticipantsFilter::Type::Bots:
return string_builder << "Bots"; return string_builder << "Bots";
default: default:
@ -874,7 +874,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipan
} }
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipantsFilter &filter) { StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipantsFilter &filter) {
switch (filter.type) { switch (filter.type_) {
case DialogParticipantsFilter::Type::Contacts: case DialogParticipantsFilter::Type::Contacts:
return string_builder << "Contacts"; return string_builder << "Contacts";
case DialogParticipantsFilter::Type::Administrators: case DialogParticipantsFilter::Type::Administrators:

View File

@ -448,9 +448,10 @@ struct DialogParticipants {
}; };
class ChannelParticipantsFilter { class ChannelParticipantsFilter {
enum class Type : int32 { Recent, Contacts, Administrators, Search, Mention, Restricted, Banned, Bots } type; enum class Type : int32 { Recent, Contacts, Administrators, Search, Mention, Restricted, Banned, Bots };
string query; Type type_;
MessageId top_thread_message_id; string query_;
MessageId top_thread_message_id_;
friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter); friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter);
@ -460,31 +461,31 @@ class ChannelParticipantsFilter {
tl_object_ptr<telegram_api::ChannelParticipantsFilter> get_input_channel_participants_filter() const; tl_object_ptr<telegram_api::ChannelParticipantsFilter> get_input_channel_participants_filter() const;
bool is_administrators() const { bool is_administrators() const {
return type == Type::Administrators; return type_ == Type::Administrators;
} }
bool is_bots() const { bool is_bots() const {
return type == Type::Bots; return type_ == Type::Bots;
} }
bool is_recent() const { bool is_recent() const {
return type == Type::Recent; return type_ == Type::Recent;
} }
bool is_contacts() const { bool is_contacts() const {
return type == Type::Contacts; return type_ == Type::Contacts;
} }
bool is_search() const { bool is_search() const {
return type == Type::Search; return type_ == Type::Search;
} }
bool is_restricted() const { bool is_restricted() const {
return type == Type::Restricted; return type_ == Type::Restricted;
} }
bool is_banned() const { 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 { class DialogParticipantsFilter {
public: public:
enum class Type : int32 { Contacts, Administrators, Members, Restricted, Banned, Mention, Bots }; enum class Type : int32 { Contacts, Administrators, Members, Restricted, Banned, Mention, Bots };
Type type; Type type_;
MessageId top_thread_message_id; MessageId top_thread_message_id_;
explicit DialogParticipantsFilter(Type type, MessageId top_thread_message_id = MessageId()) 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) {
} }
}; };