32 inline void str_to_sqlite(sqlite3_stmt *s,
int iCol, std::string_view str)
const
34 sqlite3_vrfy(sqlite3_bind_text(s, iCol, str.data(), str.size(), NULL));
44 sqlite3_vrfy(sqlite3_bind_int64(s, iCol, (sqlite3_int64) val));
55 const char* text =
reinterpret_cast<const char*
>(sqlite3_column_text(s, iCol));
56 return text ? std::string_view(text) : std::string_view();
69 const char *data =
reinterpret_cast<const char*
>(sqlite3_column_blob(s, iCol));
71 return std::string_view();
72 size_t len = sqlite3_column_bytes(s, iCol);
73 return std::string_view(data, len);
78 return sqlite3_column_int(s, iCol);
83 return (u32) sqlite3_column_int(s, iCol);
88 return (s64) sqlite3_column_int64(s, iCol);
93 return (u64) sqlite3_column_int64(s, iCol);
98 return (
float) sqlite3_column_double(s, iCol);
108 inline void sqlite3_vrfy(
int s, std::string_view m =
"",
int r = SQLITE_OK)
const
112 msg.append(
": ").append(sqlite3_errmsg(
m_database));
117 inline void sqlite3_vrfy(
const int s,
const int r, std::string_view m =
"")
const
162 void bindPos(sqlite3_stmt *stmt,
const v3s16 &pos,
int index = 1);
215 virtual bool deleteAuth(
const std::string &name);
216 virtual void listNames(std::vector<std::string> &res);
244 virtual void getModKeys(
const std::string &modname, std::vector<std::string> *storage);
245 virtual bool getModEntry(
const std::string &modname,
246 const std::string &key, std::string *value);
247 virtual bool hasModEntry(
const std::string &modname,
const std::string &key);
248 virtual bool setModEntry(
const std::string &modname,
249 const std::string &key,std::string_view value);
250 virtual bool removeModEntry(
const std::string &modname,
const std::string &key);
252 virtual void listMods(std::vector<std::string> *res);
Definition database-sqlite3.h:207
virtual void listNames(std::vector< std::string > &res)
Definition database-sqlite3.cpp:719
sqlite3_stmt * m_stmt_list_names
Definition database-sqlite3.h:230
virtual bool deleteAuth(const std::string &name)
Definition database-sqlite3.cpp:705
virtual void createDatabase()
Definition database-sqlite3.cpp:602
sqlite3_stmt * m_stmt_read
Definition database-sqlite3.h:226
sqlite3_stmt * m_stmt_write
Definition database-sqlite3.h:227
sqlite3_stmt * m_stmt_delete
Definition database-sqlite3.h:229
sqlite3_stmt * m_stmt_create
Definition database-sqlite3.h:228
virtual bool getAuth(const std::string &name, AuthEntry &res)
Definition database-sqlite3.cpp:643
AuthDatabaseSQLite3(const std::string &savedir)
Definition database-sqlite3.cpp:584
virtual ~AuthDatabaseSQLite3()
Definition database-sqlite3.cpp:589
sqlite3_stmt * m_stmt_delete_privs
Definition database-sqlite3.h:233
virtual void reload()
Definition database-sqlite3.cpp:729
sqlite3_stmt * m_stmt_read_privs
Definition database-sqlite3.h:231
virtual bool createAuth(AuthEntry &authEntry)
Definition database-sqlite3.cpp:683
virtual void initStatements()
Definition database-sqlite3.cpp:627
virtual void writePrivileges(const AuthEntry &authEntry)
Definition database-sqlite3.cpp:734
sqlite3_stmt * m_stmt_last_insert_rowid
Definition database-sqlite3.h:234
sqlite3_stmt * m_stmt_write_privs
Definition database-sqlite3.h:232
virtual bool saveAuth(const AuthEntry &authEntry)
Definition database-sqlite3.cpp:666
Definition exceptions.h:40
Definition database-sqlite3.h:17
std::string_view sqlite_to_blob(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:67
void openDatabase()
Definition database-sqlite3.cpp:124
bool initialized() const
Definition database-sqlite3.h:24
sqlite3 * m_database
Definition database-sqlite3.h:126
virtual ~Database_SQLite3()
Definition database-sqlite3.cpp:174
void str_to_sqlite(sqlite3_stmt *s, int iCol, std::string_view str) const
Definition database-sqlite3.h:32
std::string_view sqlite_to_string_view(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:53
void sqlite3_vrfy(int s, std::string_view m="", int r=SQLITE_OK) const
Definition database-sqlite3.h:108
std::string m_dbname
Definition database-sqlite3.h:134
float sqlite_to_float(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:96
virtual void initStatements()=0
s64 m_busy_handler_data[2]
Definition database-sqlite3.h:139
void int64_to_sqlite(sqlite3_stmt *s, int iCol, s64 val) const
Definition database-sqlite3.h:42
void verifyDatabase()
Definition database-sqlite3.cpp:160
void endSave()
Definition database-sqlite3.cpp:116
sqlite3_stmt * m_stmt_end
Definition database-sqlite3.h:137
sqlite3_stmt * m_stmt_begin
Definition database-sqlite3.h:136
std::string sqlite_to_string(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:60
s32 sqlite_to_int(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:76
u64 sqlite_to_uint64(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:91
s64 sqlite_to_int64(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:86
void double_to_sqlite(sqlite3_stmt *s, int iCol, double val) const
Definition database-sqlite3.h:47
virtual void createDatabase()=0
bool m_initialized
Definition database-sqlite3.h:131
Database_SQLite3(const std::string &savedir, const std::string &dbname)
Definition database-sqlite3.cpp:102
u32 sqlite_to_uint(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:81
void sqlite3_vrfy(const int s, const int r, std::string_view m="") const
Definition database-sqlite3.h:117
static int busyHandler(void *data, int count)
Definition database-sqlite3.cpp:56
const v3f sqlite_to_v3f(sqlite3_stmt *s, int iCol)
Definition database-sqlite3.h:101
void int_to_sqlite(sqlite3_stmt *s, int iCol, int val) const
Definition database-sqlite3.h:37
std::string m_savedir
Definition database-sqlite3.h:133
void beginSave()
Definition database-sqlite3.cpp:108
Definition database-sqlite3.h:145
sqlite3_stmt * m_stmt_list
Definition database-sqlite3.h:167
sqlite3_stmt * m_stmt_write
Definition database-sqlite3.h:166
sqlite3_stmt * m_stmt_delete
Definition database-sqlite3.h:168
void listAllLoadableBlocks(std::vector< v3s16 > &dst)
Definition database-sqlite3.cpp:279
void beginSave()
Definition database-sqlite3.h:155
virtual void createDatabase()
Definition database-sqlite3.cpp:201
void endSave()
Definition database-sqlite3.h:156
sqlite3_stmt * m_stmt_read
Definition database-sqlite3.h:165
void loadBlock(const v3s16 &pos, std::string *block)
Definition database-sqlite3.cpp:260
virtual ~MapDatabaseSQLite3()
Definition database-sqlite3.cpp:192
MapDatabaseSQLite3(const std::string &savedir)
Definition database-sqlite3.cpp:186
bool deleteBlock(const v3s16 &pos)
Definition database-sqlite3.cpp:230
virtual void initStatements()
Definition database-sqlite3.cpp:214
bool saveBlock(const v3s16 &pos, std::string_view data)
Definition database-sqlite3.cpp:246
void bindPos(sqlite3_stmt *stmt, const v3s16 &pos, int index=1)
Definition database-sqlite3.cpp:224
Definition database-sqlite3.h:238
ModStorageDatabaseSQLite3(const std::string &savedir)
Definition database-sqlite3.cpp:747
sqlite3_stmt * m_stmt_set
Definition database-sqlite3.h:266
virtual void getModEntries(const std::string &modname, StringMap *storage)
Definition database-sqlite3.cpp:792
virtual bool getModEntry(const std::string &modname, const std::string &key, std::string *value)
Definition database-sqlite3.cpp:822
sqlite3_stmt * m_stmt_get
Definition database-sqlite3.h:264
virtual ~ModStorageDatabaseSQLite3()
Definition database-sqlite3.cpp:752
sqlite3_stmt * m_stmt_has
Definition database-sqlite3.h:265
virtual bool removeModEntries(const std::string &modname)
Definition database-sqlite3.cpp:892
sqlite3_stmt * m_stmt_get_all
Definition database-sqlite3.h:262
sqlite3_stmt * m_stmt_remove_all
Definition database-sqlite3.h:268
virtual void getModKeys(const std::string &modname, std::vector< std::string > *storage)
Definition database-sqlite3.cpp:807
sqlite3_stmt * m_stmt_remove
Definition database-sqlite3.h:267
virtual void initStatements()
Definition database-sqlite3.cpp:778
virtual void beginSave()
Definition database-sqlite3.h:254
virtual bool removeModEntry(const std::string &modname, const std::string &key)
Definition database-sqlite3.cpp:876
sqlite3_stmt * m_stmt_get_keys
Definition database-sqlite3.h:263
virtual void endSave()
Definition database-sqlite3.h:255
virtual void createDatabase()
Definition database-sqlite3.cpp:763
virtual void listMods(std::vector< std::string > *res)
Definition database-sqlite3.cpp:905
virtual bool hasModEntry(const std::string &modname, const std::string &key)
Definition database-sqlite3.cpp:842
virtual bool setModEntry(const std::string &modname, const std::string &key, std::string_view value)
Definition database-sqlite3.cpp:859
Definition database-sqlite3.h:172
sqlite3_stmt * m_stmt_player_add_inventory
Definition database-sqlite3.h:197
sqlite3_stmt * m_stmt_player_load_inventory_items
Definition database-sqlite3.h:196
bool playerDataExists(const std::string &name)
Definition database-sqlite3.cpp:407
sqlite3_stmt * m_stmt_player_remove_inventory_items
Definition database-sqlite3.h:200
bool loadPlayer(RemotePlayer *player, PlayerSAO *sao)
Definition database-sqlite3.cpp:506
virtual ~PlayerDatabaseSQLite3()
Definition database-sqlite3.cpp:299
sqlite3_stmt * m_stmt_player_load_inventory
Definition database-sqlite3.h:195
bool removePlayer(const std::string &name)
Definition database-sqlite3.cpp:559
virtual void initStatements()
Definition database-sqlite3.cpp:372
void listPlayers(std::vector< std::string > &res)
Definition database-sqlite3.cpp:570
sqlite3_stmt * m_stmt_player_metadata_load
Definition database-sqlite3.h:201
sqlite3_stmt * m_stmt_player_add_inventory_items
Definition database-sqlite3.h:198
virtual void createDatabase()
Definition database-sqlite3.cpp:318
sqlite3_stmt * m_stmt_player_remove
Definition database-sqlite3.h:193
sqlite3_stmt * m_stmt_player_remove_inventory
Definition database-sqlite3.h:199
sqlite3_stmt * m_stmt_player_list
Definition database-sqlite3.h:194
sqlite3_stmt * m_stmt_player_update
Definition database-sqlite3.h:192
sqlite3_stmt * m_stmt_player_load
Definition database-sqlite3.h:190
sqlite3_stmt * m_stmt_player_metadata_add
Definition database-sqlite3.h:203
void savePlayer(RemotePlayer *player)
Definition database-sqlite3.cpp:416
sqlite3_stmt * m_stmt_player_metadata_remove
Definition database-sqlite3.h:202
PlayerDatabaseSQLite3(const std::string &savedir)
Definition database-sqlite3.cpp:293
sqlite3_stmt * m_stmt_player_add
Definition database-sqlite3.h:191
Definition player_sao.h:56
Definition remoteplayer.h:26
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
std::unordered_map< std::string, std::string > StringMap
Definition string.h:65