#pragma once #include #include #include #include #include "Definitions.h" namespace ts { namespace server { class TSServer; } namespace token { enum TokenType : uint8_t { TOKEN_SERVER, TOKEN_CHANNEL }; struct TokenEntry { TokenEntry(const std::string &token, TokenType type, GroupId groupId, ChannelId channelId, const std::chrono::time_point &created, const std::string &description); std::string token; TokenType type; //token_type GroupId groupId; //token_id1 ChannelId channelId; //token_id2 std::chrono::time_point created; std::string description; }; class TokenManager { public: TokenManager(server::TSServer*); ~TokenManager(); bool loadTokens(); std::vector> avariableTokes(){ return tokens; } std::shared_ptr findToken(std::string); std::shared_ptr createToken(TokenType, GroupId, std::string, ChannelId = 0, std::string token = ""); bool deleteToke(const std::string&); private: int loadTokenFromDb(int length, char** values, char** columns); server::TSServer* handle; std::vector> tokens; }; } } DEFINE_VARIABLE_TRANSFORM(ts::token::TokenType, VARTYPE_INT, std::to_string((uint8_t) in), static_cast(in.as()));