diff --git a/td/telegram/AccessRights.h b/td/telegram/AccessRights.h index fd0833ea..8beece72 100644 --- a/td/telegram/AccessRights.h +++ b/td/telegram/AccessRights.h @@ -8,6 +8,6 @@ namespace td { -enum class AccessRights { Read, Edit, Write }; +enum class AccessRights : int32 { Read, Edit, Write }; } // namespace td diff --git a/td/telegram/AuthManager.h b/td/telegram/AuthManager.h index 638be16b..1cdc9fe9 100644 --- a/td/telegram/AuthManager.h +++ b/td/telegram/AuthManager.h @@ -96,7 +96,7 @@ class SendCodeHelper { class PhoneNumberManager : public NetActor { public: - enum class Type { ChangePhone, VerifyPhone, ConfirmPhone }; + enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone }; PhoneNumberManager(Type type, ActorShared<> parent); void get_state(uint64 query_id); @@ -108,8 +108,8 @@ class PhoneNumberManager : public NetActor { private: Type type_; - enum class State { Ok, WaitCode } state_ = State::Ok; - enum class NetQueryType { None, SendCode, CheckCode }; + enum class State : int32 { Ok, WaitCode } state_ = State::Ok; + enum class NetQueryType : int32 { None, SendCode, CheckCode }; ActorShared<> parent_; uint64 query_id_ = 0; @@ -173,7 +173,7 @@ class AuthManager : public NetActor { LoggingOut, Closing } state_ = State::None; - enum class NetQueryType { + enum class NetQueryType : int32 { None, SignIn, SignUp, diff --git a/td/telegram/CallActor.h b/td/telegram/CallActor.h index 02960bb3..492f38a5 100644 --- a/td/telegram/CallActor.h +++ b/td/telegram/CallActor.h @@ -51,7 +51,7 @@ struct CallConnection { }; struct CallState { - enum class Type { Empty, Pending, ExchangingKey, Ready, HangingUp, Discarded, Error } type{Type::Empty}; + enum class Type : int32 { Empty, Pending, ExchangingKey, Ready, HangingUp, Discarded, Error } type{Type::Empty}; CallProtocol protocol; std::vector connections; @@ -97,7 +97,7 @@ class CallActor : public NetQueryCallback { int32 duration_{0}; int64 connection_id_{0}; - enum class State { + enum class State : int32 { Empty, SendRequestQuery, WaitRequestResult, diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index ccfae6b1..8d1d6218 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -51,9 +51,9 @@ struct BotData { bool need_location; }; -enum class ChannelType { Broadcast, Megagroup, Unknown }; +enum class ChannelType : uint8 { Broadcast, Megagroup, Unknown }; -enum class CheckDialogUsernameResult { Ok, Invalid, Occupied, PublicDialogsTooMuch, PublicGroupsUnavailable }; +enum class CheckDialogUsernameResult : uint8 { Ok, Invalid, Occupied, PublicDialogsTooMuch, PublicGroupsUnavailable }; class ContactsManager : public Actor { public: diff --git a/td/telegram/DeviceTokenManager.h b/td/telegram/DeviceTokenManager.h index 8858f85d..4d204d31 100644 --- a/td/telegram/DeviceTokenManager.h +++ b/td/telegram/DeviceTokenManager.h @@ -47,7 +47,7 @@ class DeviceTokenManager : public NetQueryCallback { SIZE }; struct TokenInfo { - enum class State { Sync, Unregister, Register }; + enum class State : int32 { Sync, Unregister, Register }; State state = State::Sync; string token; uint64 net_query_id = 0; diff --git a/td/telegram/DialogId.h b/td/telegram/DialogId.h index ac11ced8..1ad37b25 100644 --- a/td/telegram/DialogId.h +++ b/td/telegram/DialogId.h @@ -21,7 +21,7 @@ namespace td { -enum class DialogType { None, User, Chat, Channel, SecretChat }; +enum class DialogType : int32 { None, User, Chat, Channel, SecretChat }; class DialogId { static constexpr int64 MIN_SECRET_ID = -2002147483648ll; diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index 556d4bde..016509a3 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -374,17 +374,17 @@ DialogParticipantStatus get_dialog_participant_status( tl_object_ptr ChannelParticipantsFilter::get_input_channel_participants_filter() const { switch (type) { - case Recent: + case Type::Recent: return make_tl_object(); - case Administrators: + case Type::Administrators: return make_tl_object(); - case Search: + case Type::Search: return make_tl_object(query); - case Restricted: + case Type::Restricted: return make_tl_object(query); - case Banned: + case Type::Banned: return make_tl_object(query); - case Bots: + case Type::Bots: return make_tl_object(); default: UNREACHABLE(); @@ -394,34 +394,34 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const { ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr &filter) { if (filter == nullptr) { - type = Recent; + type = Type::Recent; return; } switch (filter->get_id()) { case td_api::supergroupMembersFilterRecent::ID: - type = Recent; + type = Type::Recent; return; case td_api::supergroupMembersFilterAdministrators::ID: - type = Administrators; + type = Type::Administrators; return; case td_api::supergroupMembersFilterSearch::ID: - type = Search; + type = Type::Search; query = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterRestricted::ID: - type = Restricted; + type = Type::Restricted; query = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterBanned::ID: - type = Banned; + type = Type::Banned; query = static_cast(filter.get())->query_; return; case td_api::supergroupMembersFilterBots::ID: - type = Bots; + type = Type::Bots; return; default: UNREACHABLE(); - type = Recent; + type = Type::Recent; } } diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index ab4c36a3..5bb3d22b 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -52,7 +52,7 @@ class DialogParticipantStatus { CAN_SEND_ANIMATIONS | CAN_SEND_GAMES | CAN_USE_INLINE_BOTS | CAN_ADD_WEB_PAGE_PREVIEWS; - enum class Type { Creator, Administrator, Member, Restricted, Left, Banned }; + enum class Type : int32 { Creator, Administrator, Member, Restricted, Left, Banned }; // all fields are logically const, but should be updated in update_restrictions() mutable Type type_; mutable uint32 flags_; @@ -239,7 +239,7 @@ struct DialogParticipant { }; class ChannelParticipantsFilter { - enum { Recent, Administrators, Search, Restricted, Banned, Bots } type; + enum class Type : int32 { Recent, Administrators, Search, Restricted, Banned, Bots } type; string query; public: @@ -248,7 +248,7 @@ class ChannelParticipantsFilter { tl_object_ptr get_input_channel_participants_filter() const; bool is_administrators() const { - return type == Administrators; + return type == Type::Administrators; } }; diff --git a/td/telegram/DocumentsManager.h b/td/telegram/DocumentsManager.h index edbc02d6..e515f2f0 100644 --- a/td/telegram/DocumentsManager.h +++ b/td/telegram/DocumentsManager.h @@ -32,7 +32,7 @@ class DocumentsManager { public: explicit DocumentsManager(Td *td); - enum class DocumentType { Unknown, Animation, Audio, General, Sticker, Video, VideoNote, VoiceNote }; + enum class DocumentType : int32 { Unknown, Animation, Audio, General, Sticker, Video, VideoNote, VoiceNote }; class RemoteDocument { public: diff --git a/td/telegram/MessagesDb.h b/td/telegram/MessagesDb.h index 86843dd5..e3e3e1f3 100644 --- a/td/telegram/MessagesDb.h +++ b/td/telegram/MessagesDb.h @@ -22,7 +22,7 @@ namespace td { // append only before Size -enum class SearchMessagesFilter { +enum class SearchMessagesFilter : int32 { Empty, Animation, Audio, diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 128ac01e..22a7de52 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -705,7 +705,7 @@ class DialogNotificationSettings { } }; -enum class NotificationSettingsScope { Private, Group }; +enum class NotificationSettingsScope : int32 { Private, Group }; class ScopeNotificationSettings { public: @@ -2663,7 +2663,7 @@ class MessagesManager : public Actor { KHeap ttl_heap_; Slot ttl_slot_; - enum YieldType { None, Ttl, TtlDb }; // None must be first + enum YieldType : int32 { None, Ttl, TtlDb }; // None must be first int32 ttl_db_expire_from_; int32 ttl_db_expire_till_; bool ttl_db_has_query_; diff --git a/td/telegram/PrivacyManager.h b/td/telegram/PrivacyManager.h index 820e435a..d8f3d6f0 100644 --- a/td/telegram/PrivacyManager.h +++ b/td/telegram/PrivacyManager.h @@ -67,7 +67,7 @@ class PrivacyManager : public NetQueryCallback { } private: - enum class Type { + enum class Type : int32 { AllowContacts, AllowAll, AllowUsers, diff --git a/td/telegram/SecretChatActor.h b/td/telegram/SecretChatActor.h index 7c8e04cc..d63459c1 100644 --- a/td/telegram/SecretChatActor.h +++ b/td/telegram/SecretChatActor.h @@ -136,8 +136,8 @@ class SecretChatActor : public NetQueryCallback { void binlog_replay_finish(); private: - enum class State { Empty, SendRequest, SendAccept, WaitRequestResponse, WaitAcceptResponse, Ready, Closed }; - enum { MAX_RESEND_COUNT = 1000 }; + enum class State : int32 { Empty, SendRequest, SendAccept, WaitRequestResponse, WaitAcceptResponse, Ready, Closed }; + static constexpr int32 MAX_RESEND_COUNT = 1000; // We have git state that should be shynchronized with db. // It is splitted into several parts because: @@ -198,7 +198,7 @@ class SecretChatActor : public NetQueryCallback { ttl = parser.fetch_int(); bool has_flags = (his_layer & HAS_FLAGS) != 0; if (has_flags) { - his_layer &= ~HAS_FLAGS; + his_layer &= static_cast(~HAS_FLAGS); my_layer = parser.fetch_int(); // for future usage BEGIN_PARSE_FLAGS(); @@ -206,7 +206,7 @@ class SecretChatActor : public NetQueryCallback { } } - enum { HAS_FLAGS = 1 << 31 }; + static constexpr uint32 HAS_FLAGS = 1u << 31; }; // PfsAction @@ -576,7 +576,7 @@ class SecretChatActor : public NetQueryCallback { int32 last_read_history_date_ = -1; Promise read_history_promise_; - enum SendFlag { + enum SendFlag : int32 { None = 0, External = 1, Push = 2, diff --git a/td/telegram/SecureManager.h b/td/telegram/SecureManager.h index 4d4b331a..02168295 100644 --- a/td/telegram/SecureManager.h +++ b/td/telegram/SecureManager.h @@ -91,7 +91,7 @@ class SetSecureValue : public NetQueryCallback { class UploadCallback; std::shared_ptr upload_callback_; - enum class State { WaitSecret, WaitSetValue } state_ = State::WaitSecret; + enum class State : int32 { WaitSecret, WaitSetValue } state_ = State::WaitSecret; class UploadCallback : public FileManager::UploadCallback { public: diff --git a/td/telegram/SequenceDispatcher.h b/td/telegram/SequenceDispatcher.h index 5ce46068..dbfbef90 100644 --- a/td/telegram/SequenceDispatcher.h +++ b/td/telegram/SequenceDispatcher.h @@ -30,7 +30,7 @@ class SequenceDispatcher : public NetQueryCallback { void close_silent(); private: - enum class State { Start, Wait, Finish, Dummy }; + enum class State : int32 { Start, Wait, Finish, Dummy }; struct Data { State state_; NetQueryRef net_query_ref_; diff --git a/td/telegram/StateManager.cpp b/td/telegram/StateManager.cpp index 6777f441..11171d54 100644 --- a/td/telegram/StateManager.cpp +++ b/td/telegram/StateManager.cpp @@ -58,12 +58,12 @@ void StateManager::do_on_network(NetType new_network_type, bool inc_generation) if (inc_generation) { network_generation_++; } - notify_flags(NetworkFlag); + notify_flag(Flag::Network); } void StateManager::on_online(bool is_online) { online_flag_ = is_online; - notify_flags(OnlineFlag); + notify_flag(Flag::Online); } void StateManager::on_proxy(bool use_proxy) { @@ -105,18 +105,21 @@ StateManager::State StateManager::get_real_state() const { return State::Ready; } -void StateManager::notify_flags(int32 flags) { +void StateManager::notify_flag(Flag flag) { for (auto it = callbacks_.begin(); it != callbacks_.end();) { - bool ok = true; - if (flags & OnlineFlag) { - ok &= (*it)->on_online(online_flag_); - } - if (flags & StateFlag) { - ok &= (*it)->on_state(flush_state_); - } - if (flags & NetworkFlag) { - ok &= (*it)->on_network(network_type_, network_generation_); - } + bool ok = [&] { + switch (flag) { + case Flag::Online: + return (*it)->on_online(online_flag_); + case Flag::State: + return (*it)->on_state(flush_state_); + case Flag::Network: + return (*it)->on_network(network_type_, network_generation_); + default: + UNREACHABLE(); + return true; + } + }(); if (ok) { ++it; } else { @@ -165,7 +168,7 @@ void StateManager::loop() { if (now >= pending_timestamp_ + delay) { has_timestamp_ = false; flush_state_ = pending_state_; - notify_flags(StateFlag); + notify_flag(Flag::State); } else { set_timeout_at(pending_timestamp_ + delay); } diff --git a/td/telegram/StateManager.h b/td/telegram/StateManager.h index cbe24c22..9582db7c 100644 --- a/td/telegram/StateManager.h +++ b/td/telegram/StateManager.h @@ -114,8 +114,8 @@ class StateManager final : public Actor { void inc_connect(); void dec_connect(); - enum Flags { OnlineFlag = 1, StateFlag = 2, NetworkFlag = 4 }; - void notify_flags(int32 flags); + enum class Flag : int32 { Online, State, Network }; + void notify_flag(Flag flag); void start_up() override; void loop() override; diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 74051602..fa62d584 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -230,7 +230,7 @@ class Td final : public NetQueryCallback { bool destroy_flag_ = false; int close_flag_ = 0; - enum class State { WaitParameters, Decrypt, Run, Close } state_ = State::WaitParameters; + enum class State : int32 { WaitParameters, Decrypt, Run, Close } state_ = State::WaitParameters; EncryptionInfo encryption_info_; vector>> result_handlers_; diff --git a/td/telegram/TopDialogManager.h b/td/telegram/TopDialogManager.h index c301e425..77407cd7 100644 --- a/td/telegram/TopDialogManager.h +++ b/td/telegram/TopDialogManager.h @@ -23,7 +23,7 @@ #include namespace td { -enum class TopDialogCategory { Correspondent, BotPM, BotInline, Group, Channel, Call, Size }; +enum class TopDialogCategory : int32 { Correspondent, BotPM, BotInline, Group, Channel, Call, Size }; inline TopDialogCategory top_dialog_category_from_td_api(const td_api::TopChatCategory &category) { switch (category.get_id()) { @@ -65,7 +65,7 @@ class TopDialogManager : public NetQueryCallback { bool is_active_{false}; bool was_first_sync_{false}; - enum class SyncState { None, Pending, Ok }; + enum class SyncState : int32 { None, Pending, Ok }; SyncState db_sync_state_ = SyncState::None; Timestamp first_unsync_change_; SyncState server_sync_state_ = SyncState::None; diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 9602fee7..b19f3d00 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -112,7 +112,7 @@ class UpdatesManager : public Actor { class State { public: - enum class Type { + enum class Type : int32 { General, RunningGetUpdatesState, RunningGetDifference, diff --git a/td/telegram/files/FileHashUploader.cpp b/td/telegram/files/FileHashUploader.cpp index 2408e16d..6af72c91 100644 --- a/td/telegram/files/FileHashUploader.cpp +++ b/td/telegram/files/FileHashUploader.cpp @@ -56,10 +56,10 @@ void FileHashUploader::loop() { } Status FileHashUploader::loop_impl() { - if (state_ == CalcSha) { + if (state_ == State::CalcSha) { TRY_STATUS(loop_sha()); } - if (state_ == NetRequest) { + if (state_ == State::NetRequest) { // messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document; auto hash = BufferSlice(32); sha256_final(&sha256_state_, hash.as_slice()); @@ -69,7 +69,7 @@ Status FileHashUploader::loop_impl() { LOG(INFO) << "Send getDocumentByHash request: " << to_string(query); auto ptr = G()->net_query_creator().create(create_storer(query)); G()->net_query_dispatcher().dispatch_with_callback(std::move(ptr), actor_shared(this)); - state_ = WaitNetResult; + state_ = State::WaitNetResult; } return Status::OK(); } @@ -102,7 +102,7 @@ Status FileHashUploader::loop_sha() { size_left_ -= narrow_cast(read_size); CHECK(size_left_ >= 0); if (size_left_ == 0) { - state_ = NetRequest; + state_ = State::NetRequest; return Status::OK(); } return Status::OK(); diff --git a/td/telegram/files/FileHashUploader.h b/td/telegram/files/FileHashUploader.h index d836c521..f47d5340 100644 --- a/td/telegram/files/FileHashUploader.h +++ b/td/telegram/files/FileHashUploader.h @@ -60,7 +60,7 @@ class FileHashUploader : public FileLoaderActor { ActorShared resource_manager_; - enum { CalcSha, NetRequest, WaitNetResult } state_ = CalcSha; + enum class State : int32 { CalcSha, NetRequest, WaitNetResult } state_ = State::CalcSha; bool stop_flag_ = false; Sha256State sha256_state_; diff --git a/td/telegram/files/FileLoader.cpp b/td/telegram/files/FileLoader.cpp index a7d02824..f6d855ed 100644 --- a/td/telegram/files/FileLoader.cpp +++ b/td/telegram/files/FileLoader.cpp @@ -123,7 +123,7 @@ Status FileLoader::do_loop() { } for (auto &query : check_info.queries) { G()->net_query_dispatcher().dispatch_with_callback( - std::move(query), actor_shared(this, UniqueId::next(UniqueId::Type::Default, CommonQueryKey))); + std::move(query), actor_shared(this, UniqueId::next(UniqueId::Type::Default, COMMON_QUERY_KEY))); } if (check_info.need_check) { parts_manager_.set_need_check(); @@ -209,7 +209,7 @@ void FileLoader::on_result(NetQueryPtr query) { if (id == blocking_id_) { blocking_id_ = 0; } - if (UniqueId::extract_key(id) == CommonQueryKey) { + if (UniqueId::extract_key(id) == COMMON_QUERY_KEY) { on_common_query(std::move(query)); return loop(); } diff --git a/td/telegram/files/FileLoader.h b/td/telegram/files/FileLoader.h index a97a5199..8ee3160d 100644 --- a/td/telegram/files/FileLoader.h +++ b/td/telegram/files/FileLoader.h @@ -95,7 +95,7 @@ class FileLoader : public FileLoaderActor { } private: - enum { CommonQueryKey = 2 }; + static constexpr uint8 COMMON_QUERY_KEY = 2; bool stop_flag_ = false; ActorShared resource_manager_; ResourceState resource_state_; diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index bd78637b..c4fd4ddc 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -157,7 +157,7 @@ constexpr int32 file_type_size = static_cast(FileType::Size); extern const char *file_type_name[file_type_size]; struct FileEncryptionKey { - enum class Type { None, Secret, Secure }; + enum class Type : int32 { None, Secret, Secure }; FileEncryptionKey() = default; FileEncryptionKey(Slice key, Slice iv) : key_iv_(key.size() + iv.size(), '\0'), type_(Type::Secret) { if (key.size() != 32 || iv.size() != 32) { @@ -459,7 +459,7 @@ class FullRemoteFileLocation { static constexpr int32 WEB_LOCATION_FLAG = 1 << 24; bool web_location_flag_{false}; DcId dc_id_; - enum class LocationType { Web, Photo, Common, None }; + enum class LocationType : int32 { Web, Photo, Common, None }; Variant variant_; LocationType location_type() const { diff --git a/td/telegram/files/FileManager.h b/td/telegram/files/FileManager.h index bfa4ab91..1f2bc076 100644 --- a/td/telegram/files/FileManager.h +++ b/td/telegram/files/FileManager.h @@ -368,7 +368,7 @@ class FileManager : public FileLoadManager::Callback { class Query { public: FileId file_id_; - enum Type { UploadByHash, Upload, Download, SetContent, Generate } type_; + enum Type : int32 { UploadByHash, Upload, Download, SetContent, Generate } type_; }; struct FileIdInfo { FileNodeId node_id_{0}; diff --git a/td/telegram/files/PartsManager.h b/td/telegram/files/PartsManager.h index 26c31d51..a2f07381 100644 --- a/td/telegram/files/PartsManager.h +++ b/td/telegram/files/PartsManager.h @@ -49,7 +49,7 @@ class PartsManager { static constexpr int MAX_PART_SIZE = 512 * (1 << 10); static constexpr int64 MAX_FILE_SIZE = MAX_PART_SIZE * MAX_PART_COUNT; - enum class PartStatus { Empty, Pending, Ready }; + enum class PartStatus : int32 { Empty, Pending, Ready }; bool need_check_{false}; int64 checked_prefix_size_{0}; diff --git a/td/telegram/files/ResourceManager.h b/td/telegram/files/ResourceManager.h index 48a32f18..e12f65b6 100644 --- a/td/telegram/files/ResourceManager.h +++ b/td/telegram/files/ResourceManager.h @@ -20,7 +20,7 @@ namespace td { class ResourceManager : public Actor { public: - enum class Mode { Baseline, Greedy }; + enum class Mode : int32 { Baseline, Greedy }; explicit ResourceManager(Mode mode) : mode_(mode) { } // use through ActorShared diff --git a/td/telegram/net/ConnectionCreator.h b/td/telegram/net/ConnectionCreator.h index 1c5dbc8d..7265cdab 100644 --- a/td/telegram/net/ConnectionCreator.h +++ b/td/telegram/net/ConnectionCreator.h @@ -98,7 +98,7 @@ class Proxy { return password_; } - enum class Type { None, Socks5 }; + enum class Type : int32 { None, Socks5 }; Type type() const { return type_; } diff --git a/td/telegram/net/DcAuthManager.h b/td/telegram/net/DcAuthManager.h index a8710f61..4806a8c8 100644 --- a/td/telegram/net/DcAuthManager.h +++ b/td/telegram/net/DcAuthManager.h @@ -31,7 +31,7 @@ class DcAuthManager : public NetQueryCallback { std::shared_ptr shared_auth_data; AuthState auth_state; - enum class State { Waiting, Export, Import, BeforeOk, Ok }; + enum class State : int32 { Waiting, Export, Import, BeforeOk, Ok }; State state = State::Waiting; uint64 wait_id; int32 export_id; diff --git a/td/telegram/net/DcId.h b/td/telegram/net/DcId.h index f258d340..092d9087 100644 --- a/td/telegram/net/DcId.h +++ b/td/telegram/net/DcId.h @@ -71,7 +71,7 @@ class DcId { } private: - enum { Empty = 0, MainDc = -1, Invalid = -2 }; + enum : int32 { Empty = 0, MainDc = -1, Invalid = -2 }; int32 dc_id_{Empty}; bool is_external_{false}; diff --git a/td/telegram/net/DcOptions.h b/td/telegram/net/DcOptions.h index 9ce5aeb4..191f0098 100644 --- a/td/telegram/net/DcOptions.h +++ b/td/telegram/net/DcOptions.h @@ -21,7 +21,7 @@ namespace td { class DcOption { // do not forget to update PrintFlags - enum Flags { IPv6 = 1, MediaOnly = 2, ObfuscatedTcpOnly = 4, Cdn = 8, Static = 16 }; + enum Flags : int32 { IPv6 = 1, MediaOnly = 2, ObfuscatedTcpOnly = 4, Cdn = 8, Static = 16 }; int32 flags = 0; DcId dc_id; diff --git a/td/telegram/net/DcOptionsSet.h b/td/telegram/net/DcOptionsSet.h index e57e9003..386cfad4 100644 --- a/td/telegram/net/DcOptionsSet.h +++ b/td/telegram/net/DcOptionsSet.h @@ -26,7 +26,7 @@ class DcOptionsSet { double ok_at{-1000}; double error_at{-1001}; double check_at{-1002}; - enum State { Ok, Error, Checking }; + enum State : int32 { Ok, Error, Checking }; void on_ok() { ok_at = Time::now_cached(); @@ -63,7 +63,7 @@ class DcOptionsSet { void reset(); private: - enum class State { Error, Ok, Checking }; + enum class State : int32 { Error, Ok, Checking }; struct OptionStat { Stat tcp_stat; diff --git a/td/telegram/net/NetQuery.h b/td/telegram/net/NetQuery.h index da1bdaed..003ac516 100644 --- a/td/telegram/net/NetQuery.h +++ b/td/telegram/net/NetQuery.h @@ -47,7 +47,7 @@ class NetQuery : public ListNode { NetQuery() = default; enum class State : int8 { Empty, Query, OK, Error }; - enum class Type { Common, Upload, Download, DownloadSmall }; + enum class Type : int8 { Common, Upload, Download, DownloadSmall }; enum class AuthFlag : int8 { Off, On }; enum class GzipFlag : int8 { Off, On }; enum Error : int32 { Resend = 202, Cancelled = 203, ResendInvokeAfter = 204 }; diff --git a/td/telegram/net/Session.h b/td/telegram/net/Session.h index 93f69a27..f2792bf3 100644 --- a/td/telegram/net/Session.h +++ b/td/telegram/net/Session.h @@ -94,7 +94,7 @@ class Session final // Just re-ask answer_id each time we get information about it. // Thought mtproto::Connection must ensure delivery of such query - enum class Mode { Tcp, Http } mode_ = Mode::Tcp; + enum class Mode : int8 { Tcp, Http } mode_ = Mode::Tcp; bool is_main_; bool is_cdn_; bool was_on_network_ = false; @@ -120,7 +120,7 @@ class Session final struct ConnectionInfo { int8 connection_id; Mode mode; - enum class State { Empty, Connecting, Ready } state = State::Empty; + enum class State : int8 { Empty, Connecting, Ready } state = State::Empty; mtproto::AuthKeyHandshake handshake; mtproto::AuthKeyHandshake tmp_handshake; unique_ptr connection;