Better AuthManager storers and parsers.

GitOrigin-RevId: 20e1e7ed3591d1f99c0661164360822dd6d0b3e6
This commit is contained in:
levlam 2018-03-14 22:47:08 +03:00
parent c9a9e386e5
commit 6855704b52
3 changed files with 10 additions and 14 deletions

View File

@ -51,7 +51,7 @@ class SendCodeHelper {
static constexpr int32 SENT_CODE_FLAG_HAS_TIMEOUT = 1 << 2;
struct AuthenticationCodeInfo {
enum class Type { None, Message, Sms, Call, FlashCall };
enum class Type : int32 { None, Message, Sms, Call, FlashCall };
Type type = Type::None;
int32 length = 0;
string pattern;
@ -141,7 +141,7 @@ class AuthManager : public NetActor {
private:
static constexpr size_t MAX_NAME_LENGTH = 255; // server side limit
enum class State { None, WaitPhoneNumber, WaitCode, WaitPassword, Ok, LoggingOut, Closing } state_ = State::None;
enum class State : int32 { None, WaitPhoneNumber, WaitCode, WaitPassword, Ok, LoggingOut, Closing } state_ = State::None;
enum class NetQueryType {
None,
SignIn,

View File

@ -12,16 +12,14 @@ namespace td {
template <class T>
void SendCodeHelper::AuthenticationCodeInfo::store(T &storer) const {
using td::store;
store(static_cast<int>(type), storer);
store(type, storer);
store(length, storer);
store(pattern, storer);
}
template <class T>
void SendCodeHelper::AuthenticationCodeInfo::parse(T &parser) {
using td::parse;
int32 type_int;
parse(type_int, parser);
type = narrow_cast<decltype(type)>(type_int);
parse(type, parser);
parse(length, parser);
parse(pattern, parser);
}
@ -52,7 +50,7 @@ template <class T>
void AuthManager::DbState::store(T &storer) const {
using td::store;
CHECK(state_ == State::WaitCode);
store(static_cast<int32>(state_), storer);
store(state_, storer);
store(api_id_, storer);
store(api_hash_, storer);
store(send_code_helper_, storer);
@ -61,9 +59,7 @@ void AuthManager::DbState::store(T &storer) const {
template <class T>
void AuthManager::DbState::parse(T &parser) {
using td::parse;
int32 state;
parse(state, parser);
state_ = narrow_cast<State>(state);
parse(state_, parser);
parse(api_id_, parser);
parse(api_hash_, parser);
parse(send_code_helper_, parser);