22 #include <mysql/mysql.h> 23 #include "mariadb++/account.hpp" 24 #include "mariadb++/connection.hpp" 25 #include "mariadb++/statement.hpp" 26 #include "mariadb++/result_set.hpp" 27 #include "mariadb++/exceptions.hpp" 30 #include <unordered_map> 69 std::unique_ptr<simple_wml::document>
get_game_history(
int player_id,
int offset);
98 std::string
get_user_string(
const std::string& table,
const std::string& column,
const std::string& name);
106 int get_user_int(
const std::string& table,
const std::string& column,
const std::string& name);
115 void write_user_int(
const std::string& column,
const std::string& name,
int value);
125 void insert_game_info(
const std::string& uuid,
int game_id,
const std::string& version,
const std::string& name,
int reload,
int observers,
int is_public,
int has_password);
130 void update_game_end(
const std::string& uuid,
int game_id,
const std::string& replay_location);
135 void insert_game_player_info(
const std::string& uuid,
int game_id,
const std::string& username,
int side_number,
int is_host,
const std::string& faction,
const std::string& version,
const std::string& source,
const std::string& current_user);
140 unsigned long long insert_game_content_info(
const std::string& uuid,
int game_id,
const std::string&
type,
const std::string& name,
const std::string&
id,
const std::string& source,
const std::string& version);
145 void set_oos_flag(
const std::string& uuid,
int game_id);
155 void insert_addon_info(
const std::string& instance_version,
const std::string&
id,
const std::string& name,
const std::string& type,
const std::string& version,
bool forum_auth,
int topic_id);
160 unsigned long long insert_login(
const std::string& username,
const std::string& ip,
const std::string& version);
175 void get_ips_for_user(
const std::string& username, std::ostringstream* out);
232 template<
typename... Args>
242 template<
typename... Args>
243 std::string
get_single_string(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
252 template<
typename... Args>
253 long get_single_long(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
261 template<
typename... Args>
262 bool exists(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
272 template<
typename... Args>
273 mariadb::result_set_ref
select(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
283 template<
typename... Args>
284 unsigned long long modify(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
294 template<
typename... Args>
295 unsigned long long modify_get_id(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
305 template<
typename... Args>
306 mariadb::statement_ref
query(mariadb::connection_ref connection,
const std::string& sql, Args&&... args);
316 template<
typename Arg,
typename... Args>
317 void prepare(mariadb::statement_ref stmt,
int i, Arg arg, Args&&... args);
328 template<
typename Arg>
329 int prepare(mariadb::statement_ref stmt,
int i, Arg arg);
334 void prepare(mariadb::statement_ref stmt,
int i);
std::string db_tournament_query_
The text of the SQL query to use to retrieve any currently active tournaments.
void prepare(mariadb::statement_ref stmt, int i, Arg arg, Args &&... args)
The next parameter to be added is split off from the parameter pack.
void insert_addon_info(const std::string &instance_version, const std::string &id, const std::string &name, const std::string &type, const std::string &version, bool forum_auth, int topic_id)
int async_test_query(int limit)
std::string get_user_string(const std::string &table, const std::string &column, const std::string &name)
std::string db_game_info_table_
The name of the table that contains game-level information.
void update_logout(unsigned long long login_id)
bool topic_id_exists(int topic_id)
std::string get_tournaments()
unsigned long long modify_get_id(mariadb::connection_ref connection, const std::string &sql, Args &&... args)
Executes non-select statements (ie: insert, update, delete), but primarily intended for inserts that ...
void insert_game_info(const std::string &uuid, int game_id, const std::string &version, const std::string &name, int reload, int observers, int is_public, int has_password)
std::string db_banlist_table_
The name of the table that contains forum ban information.
std::string db_topics_table_
The name of the table that contains phpbb forum thread information.
void get_complex_results(mariadb::connection_ref connection, rs_base &base, const std::string &sql, Args &&... args)
Queries can return data with various types that can't be easily fit into a pre-determined structure...
int get_user_int(const std::string &table, const std::string &column, const std::string &name)
unsigned long long insert_game_content_info(const std::string &uuid, int game_id, const std::string &type, const std::string &name, const std::string &id, const std::string &source, const std::string &version)
Definitions for the interface to Wesnoth Markup Language (WML).
std::string get_single_string(mariadb::connection_ref connection, const std::string &sql, Args &&... args)
mariadb::connection_ref create_connection()
Creates a new connection object from the account.
This class is responsible for handling the database connections as well as executing queries and hand...
std::string db_addon_info_table_
The name of the table that contains add-on information.
dbconn(const config &c)
Initializes the synchronous query connection as well as the account object that has the connection se...
std::string db_connection_history_table_
The name of the table that contains user connection history.
mariadb::connection_ref connection_
The actual connection to the database.
void write_user_int(const std::string &column, const std::string &name, int value)
The provided value is updated if a row exists or a new row inserted otherwise.
mariadb::account_ref account_
The account used to connect to the database.
long get_single_long(mariadb::connection_ref connection, const std::string &sql, Args &&... args)
unsigned long long modify(mariadb::connection_ref connection, const std::string &sql, Args &&... args)
Executes non-select statements (ie: insert, update, delete).
bool is_user_in_group(const std::string &name, int group_id)
void get_users_for_ip(const std::string &ip, std::ostringstream *out)
std::string db_game_player_info_table_
The name of the table that contains player-level information per game.
std::string db_game_content_info_table_
The name of the table that contains game content information.
void set_oos_flag(const std::string &uuid, int game_id)
bool user_exists(const std::string &name)
void get_ips_for_user(const std::string &username, std::ostringstream *out)
std::unique_ptr< simple_wml::document > get_game_history(int player_id, int offset)
This is an asynchronous query that is executed on a separate connection to retrieve the game history ...
std::string db_user_group_table_
The name of the table that contains forum group information.
long get_forum_id(const std::string &name)
mariadb::statement_ref query(mariadb::connection_ref connection, const std::string &sql, Args &&... args)
Begins recursively unpacking of the parameter pack in order to be able to call the correct parameteri...
void log_sql_exception(const std::string &text, const mariadb::exception::base &e)
This is used to write out error text when an SQL-related exception occurs.
std::string db_users_table_
The name of the table that contains forum user information.
void insert_game_player_info(const std::string &uuid, int game_id, const std::string &username, int side_number, int is_host, const std::string &faction, const std::string &version, const std::string &source, const std::string ¤t_user)
mariadb::result_set_ref select(mariadb::connection_ref connection, const std::string &sql, Args &&... args)
Executes a select statement.
ban_check get_ban_info(const std::string &name, const std::string &ip)
A config object defines a single node in a WML file, with access to child nodes.
unsigned long long insert_login(const std::string &username, const std::string &ip, const std::string &version)
std::string db_extra_table_
The name of the table that contains additional user information.
void update_game_end(const std::string &uuid, int game_id, const std::string &replay_location)
bool extra_row_exists(const std::string &name)
bool exists(mariadb::connection_ref connection, const std::string &sql, Args &&... args)