#ifndef __CLASS_CLIENT_SESSION_H #define __CLASS_CLIENT_SESSION_H #include #include #include "proxysql.h" #include "cpp.h" #include "MySQL_Variables.h" //#include "../deps/json/json.hpp" //using json = nlohmann::json; #ifndef PROXYJSON #define PROXYJSON namespace nlohmann { class json; } #endif // PROXYJSON class MySQL_Session; class PgSQL_Session; #if 0 // this code was moved into Base_Session.h /** * @class Session_Regex * @brief Encapsulates regex operations for session handling. * * This class is used for matching patterns in SQL queries, specifically for * settings like sql_log_bin, sql_mode, and time_zone. * See issues #509 , #815 and #816 */ class Session_Regex { private: void* opt; void* re; char* s; public: Session_Regex(char* p); ~Session_Regex(); bool match(char* m); }; #endif // 0 template class TypeSelector { }; template class TypeSelector { public: TypeSelector(T* _ptr) : ptr(_ptr) { } ~TypeSelector() {} TypeSelector& operator=(T* _ptr) { ptr = _ptr; return *this; } T* operator->() { return ptr; } bool operator==(T* _ptr) { return (ptr == _ptr); } T& operator*() const noexcept { return *ptr; } explicit operator bool() { return ptr != nullptr; } operator T* () { return ptr; } private: T* ptr; }; /* Issues with forward class declaration template using Client_Session = TypeSelector; */ template class Client_Session : public TypeSelector { public: //Client_Session(const Client_Session&) = default; //Client_Session(Client_Session&&) = default; //Client_Session& operator=(const Client_Session&) = default; //Client_Session& operator=(Client_Session&&) = default; //~Client_Session() = default; using TypeSelector::TypeSelector; }; #define TO_CLIENT_SESSION(sess) Client_Session(sess) /* Issues with forward class declaration template using Query_Info_T = TypeSelector; */ template class Query_Info_T : public TypeSelector { public: using TypeSelector::TypeSelector; }; #define TO_QUERY_INFO(query_info) Query_Info_T(query_info) /* Issues with forward class declaration template using Data_Stream_T = TypeSelector; */ template class Data_Stream_T : public TypeSelector { public: using TypeSelector::TypeSelector; }; #define TO_DATA_STREAM(data_stream) Data_Stream_T(data_stream) /* Issues with forward class declaration template using Connection_Info_T = TypeSelector; */ template class Connection_Info_T : public TypeSelector { public: using TypeSelector::TypeSelector; }; #define TO_CONNECTION_INFO(connection_info) Connection_Info_T(connection_info) enum proxysql_session_type { PROXYSQL_SESSION_MYSQL, PROXYSQL_SESSION_ADMIN, PROXYSQL_SESSION_STATS, PROXYSQL_SESSION_SQLITE, PROXYSQL_SESSION_CLICKHOUSE, PROXYSQL_SESSION_MYSQL_EMU, PROXYSQL_SESSION_PGSQL, PROXYSQL_SESSION_NONE }; std::string proxysql_session_type_str(enum proxysql_session_type session_type); #endif /* __CLASS_CLIENT_SESSION_H */