Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
Database_SQLite3 Class Referenceabstract

#include <database-sqlite3.h>

+ Inheritance diagram for Database_SQLite3:
+ Collaboration diagram for Database_SQLite3:

Public Member Functions

virtual ~Database_SQLite3 ()
 
void beginSave () override
 
void endSave () override
 
bool initialized () const override
 
void verifyDatabase () override
 

Protected Member Functions

 Database_SQLite3 (const std::string &savedir, const std::string &dbname)
 
bool checkTable (const char *table)
 
bool checkColumn (const char *table, const char *column)
 
void str_to_sqlite (sqlite3_stmt *s, int iCol, std::string_view str) const
 
void blob_to_sqlite (sqlite3_stmt *s, int iCol, std::string_view str) const
 
void int_to_sqlite (sqlite3_stmt *s, int iCol, int val) const
 
void int64_to_sqlite (sqlite3_stmt *s, int iCol, s64 val) const
 
void double_to_sqlite (sqlite3_stmt *s, int iCol, double val) const
 
std::string_view sqlite_to_string_view (sqlite3_stmt *s, int iCol)
 
std::string sqlite_to_string (sqlite3_stmt *s, int iCol)
 
std::string_view sqlite_to_blob (sqlite3_stmt *s, int iCol)
 
s32 sqlite_to_int (sqlite3_stmt *s, int iCol)
 
u32 sqlite_to_uint (sqlite3_stmt *s, int iCol)
 
s64 sqlite_to_int64 (sqlite3_stmt *s, int iCol)
 
u64 sqlite_to_uint64 (sqlite3_stmt *s, int iCol)
 
float sqlite_to_float (sqlite3_stmt *s, int iCol)
 
const v3f sqlite_to_v3f (sqlite3_stmt *s, int iCol)
 
void sqlite3_vrfy (int s, std::string_view m="", int r=SQLITE_OK) const
 
void sqlite3_vrfy (const int s, const int r, std::string_view m="") const
 
virtual void createDatabase ()=0
 
virtual void initStatements ()=0
 

Protected Attributes

sqlite3 * m_database = nullptr
 

Private Member Functions

void openDatabase ()
 

Static Private Member Functions

static int busyHandler (void *data, int count)
 

Private Attributes

bool m_initialized = false
 
const std::string m_savedir
 
const std::string m_dbname
 
sqlite3_stmt * m_stmt_begin = nullptr
 
sqlite3_stmt * m_stmt_end = nullptr
 
u64 m_busy_handler_data [2]
 

Constructor & Destructor Documentation

◆ ~Database_SQLite3()

Database_SQLite3::~Database_SQLite3 ( )
virtual

◆ Database_SQLite3()

Database_SQLite3::Database_SQLite3 ( const std::string & savedir,
const std::string & dbname )
protected

Member Function Documentation

◆ beginSave()

void Database_SQLite3::beginSave ( )
overridevirtual

Implements Database.

References m_stmt_begin, SQLRES, and verifyDatabase().

Referenced by AuthDatabaseSQLite3::createAuth(), AuthDatabaseSQLite3::saveAuth(), and PlayerDatabaseSQLite3::savePlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blob_to_sqlite()

void Database_SQLite3::blob_to_sqlite ( sqlite3_stmt * s,
int iCol,
std::string_view str ) const
inlineprotected

References sqlite3_vrfy().

Referenced by ModStorageDatabaseSQLite3::getModEntry(), ModStorageDatabaseSQLite3::hasModEntry(), ModStorageDatabaseSQLite3::removeModEntry(), MapDatabaseSQLite3::saveBlock(), and ModStorageDatabaseSQLite3::setModEntry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ busyHandler()

int Database_SQLite3::busyHandler ( void * data,
int count )
staticprivate

References BUSY_ERROR_INTERVAL, BUSY_FATAL_TRESHOLD, BUSY_INFO_TRESHOLD, BUSY_WARNING_TRESHOLD, errorstream, porting::getTimeMs(), infostream, and warningstream.

Referenced by openDatabase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkColumn()

bool Database_SQLite3::checkColumn ( const char * table,
const char * column )
protected

References FINALIZE_STATEMENT, m_database, PREPARE_STATEMENT, sqlite_to_string_view(), and table.

Referenced by MapDatabaseSQLite3::initStatements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTable()

bool Database_SQLite3::checkTable ( const char * table)
protected

References FINALIZE_STATEMENT, m_database, PREPARE_STATEMENT, str_to_sqlite(), and table.

Referenced by MapDatabaseSQLite3::initStatements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDatabase()

virtual void Database_SQLite3::createDatabase ( )
protectedpure virtual

Implemented in AuthDatabaseSQLite3, MapDatabaseSQLite3, ModStorageDatabaseSQLite3, and PlayerDatabaseSQLite3.

Referenced by openDatabase().

+ Here is the caller graph for this function:

◆ double_to_sqlite()

void Database_SQLite3::double_to_sqlite ( sqlite3_stmt * s,
int iCol,
double val ) const
inlineprotected

References sqlite3_vrfy().

Referenced by PlayerDatabaseSQLite3::savePlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ endSave()

void Database_SQLite3::endSave ( )
overridevirtual

Implements Database.

References m_stmt_end, SQLRES, and verifyDatabase().

Referenced by AuthDatabaseSQLite3::createAuth(), AuthDatabaseSQLite3::saveAuth(), and PlayerDatabaseSQLite3::savePlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialized()

bool Database_SQLite3::initialized ( ) const
inlineoverridevirtual
Returns
true if database connection is open

Reimplemented from Database.

References m_initialized.

◆ initStatements()

virtual void Database_SQLite3::initStatements ( )
protectedpure virtual

Implemented in AuthDatabaseSQLite3, MapDatabaseSQLite3, ModStorageDatabaseSQLite3, and PlayerDatabaseSQLite3.

Referenced by verifyDatabase().

+ Here is the caller graph for this function:

◆ int64_to_sqlite()

void Database_SQLite3::int64_to_sqlite ( sqlite3_stmt * s,
int iCol,
s64 val ) const
inlineprotected

References sqlite3_vrfy().

Referenced by MapDatabaseSQLite3::bindPos(), AuthDatabaseSQLite3::createAuth(), AuthDatabaseSQLite3::getAuth(), AuthDatabaseSQLite3::saveAuth(), PlayerDatabaseSQLite3::savePlayer(), and AuthDatabaseSQLite3::writePrivileges().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ int_to_sqlite()

void Database_SQLite3::int_to_sqlite ( sqlite3_stmt * s,
int iCol,
int val ) const
inlineprotected

References sqlite3_vrfy().

Referenced by MapDatabaseSQLite3::bindPos(), PlayerDatabaseSQLite3::loadPlayer(), and PlayerDatabaseSQLite3::savePlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openDatabase()

void Database_SQLite3::openDatabase ( )
private

References busyHandler(), fs::CreateAllDirs(), createDatabase(), DIR_DELIM, errorstream, g_settings, Settings::getU16(), itos(), m_busy_handler_data, m_database, m_dbname, m_savedir, fs::PathExists(), and SQLOK.

Referenced by verifyDatabase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sqlite3_vrfy() [1/2]

void Database_SQLite3::sqlite3_vrfy ( const int s,
const int r,
std::string_view m = "" ) const
inlineprotected

References sqlite3_vrfy().

+ Here is the call graph for this function:

◆ sqlite3_vrfy() [2/2]

◆ sqlite_to_blob()

std::string_view Database_SQLite3::sqlite_to_blob ( sqlite3_stmt * s,
int iCol )
inlineprotected

Referenced by ModStorageDatabaseSQLite3::getModEntries(), ModStorageDatabaseSQLite3::getModEntry(), ModStorageDatabaseSQLite3::getModKeys(), and MapDatabaseSQLite3::loadBlock().

+ Here is the caller graph for this function:

◆ sqlite_to_float()

float Database_SQLite3::sqlite_to_float ( sqlite3_stmt * s,
int iCol )
inlineprotected

Referenced by PlayerDatabaseSQLite3::loadPlayer(), and sqlite_to_v3f().

+ Here is the caller graph for this function:

◆ sqlite_to_int()

s32 Database_SQLite3::sqlite_to_int ( sqlite3_stmt * s,
int iCol )
inlineprotected

Referenced by MapDatabaseSQLite3::listAllLoadableBlocks(), and PlayerDatabaseSQLite3::loadPlayer().

+ Here is the caller graph for this function:

◆ sqlite_to_int64()

s64 Database_SQLite3::sqlite_to_int64 ( sqlite3_stmt * s,
int iCol )
inlineprotected

Referenced by AuthDatabaseSQLite3::getAuth(), and MapDatabaseSQLite3::listAllLoadableBlocks().

+ Here is the caller graph for this function:

◆ sqlite_to_string()

std::string Database_SQLite3::sqlite_to_string ( sqlite3_stmt * s,
int iCol )
inlineprotected

References sqlite_to_string_view().

Referenced by PlayerDatabaseSQLite3::loadPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sqlite_to_string_view()

std::string_view Database_SQLite3::sqlite_to_string_view ( sqlite3_stmt * s,
int iCol )
inlineprotected

Referenced by checkColumn(), AuthDatabaseSQLite3::getAuth(), ModStorageDatabaseSQLite3::listMods(), AuthDatabaseSQLite3::listNames(), PlayerDatabaseSQLite3::listPlayers(), PlayerDatabaseSQLite3::loadPlayer(), and sqlite_to_string().

+ Here is the caller graph for this function:

◆ sqlite_to_uint()

u32 Database_SQLite3::sqlite_to_uint ( sqlite3_stmt * s,
int iCol )
inlineprotected

Referenced by AuthDatabaseSQLite3::createAuth(), AuthDatabaseSQLite3::getAuth(), and PlayerDatabaseSQLite3::loadPlayer().

+ Here is the caller graph for this function:

◆ sqlite_to_uint64()

u64 Database_SQLite3::sqlite_to_uint64 ( sqlite3_stmt * s,
int iCol )
inlineprotected

◆ sqlite_to_v3f()

const v3f Database_SQLite3::sqlite_to_v3f ( sqlite3_stmt * s,
int iCol )
inlineprotected

References sqlite_to_float().

Referenced by PlayerDatabaseSQLite3::loadPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_to_sqlite()

void Database_SQLite3::str_to_sqlite ( sqlite3_stmt * s,
int iCol,
std::string_view str ) const
inlineprotected

◆ verifyDatabase()

Member Data Documentation

◆ m_busy_handler_data

u64 Database_SQLite3::m_busy_handler_data[2]
private

Referenced by openDatabase().

◆ m_database

◆ m_dbname

const std::string Database_SQLite3::m_dbname
private

Referenced by openDatabase().

◆ m_initialized

bool Database_SQLite3::m_initialized = false
private

Referenced by initialized(), and verifyDatabase().

◆ m_savedir

const std::string Database_SQLite3::m_savedir
private

Referenced by openDatabase().

◆ m_stmt_begin

sqlite3_stmt* Database_SQLite3::m_stmt_begin = nullptr
private

Referenced by beginSave().

◆ m_stmt_end

sqlite3_stmt* Database_SQLite3::m_stmt_end = nullptr
private

Referenced by endSave().


The documentation for this class was generated from the following files: