#pragma once namespace google { namespace protobuf { class Descriptor; class Message; } } namespace a8 { namespace mysql { class Connection; class Query; } } namespace f8 { typedef void (*ReadCsvMetaFileCallback)(const std::string&); bool ReadCsvMetaFile(const std::string& filename, google::protobuf::Message* prototype, std::function push_back_func); template bool ReadCsvMetaFile(const std::string& filename, std::list& meta_list, ReadCsvMetaFileCallback callback_func = nullptr) { if (callback_func) { callback_func(filename); } T dummy; return ReadCsvMetaFile(filename, &dummy, [&meta_list] (google::protobuf::Message* msg) { T t; t.CopyFrom(*msg); meta_list.emplace_back(t); }); } template static void RepeatedFieldToVector(const T1& t1, T2& t2) { t2.clear(); for (auto& val : t1) { t2.push_back(val); } } template static void RepeatedFieldToSet(const T1& t1, T2& t2) { t2.clear(); for (auto& val : t1) { t2.insert(val); } } template static void VectorToRepeatedField(const T1& t1, T2& t2) { t2.Clear(); for (auto& val : t1) { *t2.Add() = val; } } template static void SetToRepeatedField(const T1& t1, T2& t2) { t2.Clear(); for (auto& val : t1) { *t2.Add() = val; } } void InitMysqlConnection(a8::mysql::Query* query); void CheckMysqlConnection(a8::mysql::Connection* conn, a8::mysql::Query* query, std::string dbhost, int port, std::string dbuser, std::string dbpasswd, std::string gamedb); bool CheckRegisterTimeInSessionId(const std::string& accountid, const std::string& sessionid); time_t ExtractRegisterTimeFromSessionId(const std::string& sessionid); bool IsValidSessionId(const std::string& accountid, const std::string& sessionid); int ExtractGameIdFromAccountId(const std::string& accountid); int ExtractChannelIdFromAccountId(const std::string& accountid); bool IsOnlineEnv(); }