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);
136 const std::string& uuid,
138 const std::string& version,
139 const std::string& name,
148 void update_game_end(
const std::string& uuid,
int game_id,
const std::string& replay_location);
154 const std::string& uuid,
156 const std::string& username,
159 const std::string& faction,
160 const std::string& version,
161 const std::string& source,
162 const std::string& current_user,
163 const std::string& leaders);
169 const std::string& uuid,
171 const std::string&
type,
172 const std::string& name,
173 const std::string&
id,
174 const std::string& addon_id,
175 const std::string& addon_version);
191 const std::string& instance_version,
192 const std::string&
id,
193 const std::string& name,
194 const std::string&
type,
195 const std::string& version,
198 const std::string& uploader);
203 unsigned long long insert_login(
const std::string& username,
const std::string& ip,
const std::string& version);
224 const std::string& instance_version,
const std::string&
id,
const std::string& version);
231 const std::string& instance_version,
const std::string&
id,
const std::string& username,
int is_primary);
242 const std::string& instance_version,
const std::string&
id,
const std::string& author,
int is_primary);
308 const mariadb::connection_ref& connection,
rs_base& base,
const std::string& sql,
const sql_parameters& params);
318 const mariadb::connection_ref& connection,
const std::string& sql,
const sql_parameters& params);
346 const mariadb::connection_ref& connection,
const std::string& sql,
const sql_parameters& params);
356 unsigned long long modify(
const mariadb::connection_ref& connection,
const std::string& sql,
const sql_parameters& params);
368 const mariadb::connection_ref& connection,
const std::string& sql,
const sql_parameters& params);
379 const 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)
void insert_addon_author(const std::string &instance_version, const std::string &id, const std::string &author, int is_primary)
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)
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.
bool exists(const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms)
long get_forum_id(const std::string &name)
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 ...
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)
long get_single_long(const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms)
std::string get_single_string(const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms)
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.
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 get_complex_results(const 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.
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.
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.
mariadb::statement_ref query(const 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_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)
unsigned long long modify(const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms)
Executes non-select statements (ie: insert, update, delete).
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)
ban_check get_ban_info(const std::string &name, const std::string &ip)
unsigned long long modify_get_id(const 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_topics_table_
The name of the table that contains phpbb forum thread information.
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)
mariadb::result_set_ref select(const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms)
Executes a select statement.
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