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>
32 typedef std::vector<std::variant<bool, int, long, unsigned long long, std::string, const char*>>
sql_parameters;
77 int player_id,
int offset, std::string search_game_name,
int search_content_type, std::string search_content);
108 std::string
get_user_string(
const std::string& table,
const std::string& column,
const std::string& name);
116 int get_user_int(
const std::string& table,
const std::string& column,
const std::string& name);
125 void write_user_int(
const std::string& column,
const std::string& name,
int value);
137 const std::string& version,
138 const std::string& name,
147 void update_game_end(
const std::string& uuid,
int game_id,
const std::string& replay_location);
154 const std::string& username,
157 const std::string& faction,
158 const std::string& version,
159 const std::string& source,
160 const std::string& current_user,
161 const std::string& leaders);
168 const std::string&
type,
169 const std::string& name,
170 const std::string&
id,
171 const std::string& addon_id,
172 const std::string& addon_version);
188 const std::string&
id,
189 const std::string& name,
190 const std::string&
type,
191 const std::string& version,
194 const std::string uploader);
199 unsigned long long insert_login(
const std::string& username,
const std::string& ip,
const std::string& version);
220 const std::string& instance_version,
const std::string&
id,
const std::string& version);
227 const std::string& instance_version,
const std::string&
id,
const std::string& username,
int is_primary);
238 const std::string& instance_version,
const std::string&
id,
const std::string author,
int is_primary);
304 mariadb::connection_ref connection,
rs_base& base,
const std::string& sql,
const sql_parameters& params);
314 mariadb::connection_ref connection,
const std::string& sql,
const sql_parameters& params);
342 mariadb::connection_ref connection,
const std::string& sql,
const sql_parameters& params);
352 unsigned long long modify(mariadb::connection_ref connection,
const std::string& sql,
const sql_parameters& params);
364 mariadb::connection_ref connection,
const std::string& sql,
const sql_parameters& params);
375 mariadb::connection_ref connection,
const std::string& sql,
const sql_parameters& params);
A config object defines a single node in a WML file, with access to child nodes.
This class is responsible for handling the database connections as well as executing queries and hand...
void delete_addon_authors(const std::string &instance_version, const std::string &id)
bool do_any_authors_exist(const std::string &instance_version, const std::string &id)
void update_addon_download_count(const std::string &instance_version, const std::string &id, const std::string &version)
mariadb::statement_ref query(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
For a given connection, set the provided SQL and parameters on a statement.
std::string db_tournament_query_
The text of the SQL query to use to retrieve any currently active tournaments.
bool topic_id_exists(int topic_id)
int async_test_query(int limit)
bool is_user_author(const std::string &instance_version, const std::string &id, const std::string &username, int is_primary)
mariadb::connection_ref connection_
The actual connection to the database.
long get_forum_id(const std::string &name)
long get_single_long(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
std::unique_ptr< simple_wml::document > get_game_history(int player_id, int offset, std::string search_game_name, int search_content_type, std::string search_content)
This is an asynchronous query that is executed on a separate connection to retrieve the game history ...
unsigned long long modify(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
Executes non-select statements (ie: insert, update, delete).
void get_ips_for_user(const std::string &username, std::ostringstream *out)
bool is_user_in_group(const std::string &name, int group_id)
std::string db_addon_authors_table_
The name of the table that contains the add-on authors information.
bool user_exists(const std::string &name)
void get_users_for_ip(const std::string &ip, std::ostringstream *out)
mariadb::result_set_ref select(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
Executes a select statement.
void insert_addon_author(const std::string &instance_version, const std::string &id, const std::string author, int is_primary)
std::string get_single_string(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
unsigned long long modify_get_id(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
Executes non-select statements (ie: insert, update, delete), but primarily intended for inserts that ...
std::string db_banlist_table_
The name of the table that contains forum ban information.
unsigned long long insert_login(const std::string &username, const std::string &ip, const std::string &version)
mariadb::connection_ref create_connection()
Creates a new connection object from the account.
std::string db_extra_table_
The name of the table that contains additional user information.
void update_logout(unsigned long long login_id)
std::string db_addon_info_table_
The name of the table that contains add-on information.
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.
bool exists(mariadb::connection_ref connection, const std::string &sql, const sql_parameters ¶ms)
std::string db_game_content_info_table_
The name of the table that contains game content information.
bool extra_row_exists(const std::string &name)
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_user_group_table_
The name of the table that contains forum group information.
void get_complex_results(mariadb::connection_ref connection, rs_base &base, const std::string &sql, const sql_parameters ¶ms)
Queries can return data with various types that can't be easily fit into a pre-determined structure.
mariadb::account_ref account_
The account used to connect to the database.
void set_oos_flag(const std::string &uuid, int game_id)
void update_game_end(const std::string &uuid, int game_id, const std::string &replay_location)
std::string db_game_info_table_
The name of the table that contains game-level information.
std::string db_game_player_info_table_
The name of the table that contains player-level information per game.
std::string db_connection_history_table_
The name of the table that contains user connection history.
int get_user_int(const std::string &table, const std::string &column, const std::string &name)
ban_check get_ban_info(const std::string &name, const std::string &ip)
std::string db_topics_table_
The name of the table that contains phpbb forum thread information.
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, const std::string uploader)
std::string get_user_string(const std::string &table, const std::string &column, const std::string &name)
std::string db_users_table_
The name of the table that contains forum user information.
dbconn(const config &c)
Initializes the synchronous query connection as well as the account object that has the connection se...
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)
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, const std::string &leaders)
std::string get_tournaments()
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 &addon_id, const std::string &addon_version)
Definitions for the interface to Wesnoth Markup Language (WML).
std::vector< std::variant< bool, int, long, unsigned long long, std::string, const char * > > sql_parameters