Q4Wine  2.0
Q4Wine is a Qt GUI for Wine.
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
q4wine::lib::DBEngine Class Reference

q4wine's SQLite3 engine warper. This class provides basic common SQL workflow, like making SQL queries, retrieving and inserting data. More...

#include <q4wine/src/lib/db.hpp>

Public Member Functions

bool open (std::string name)
 Open SQLite database. More...
 
bool init (void)
 Itialize database. Create tables and default bootsrap data on first startup. More...
 
bool exec (const std::string &sql_s) const
 Execute raw SQL statement. Use this fuction to call raw SQL statements. If you need to bind values, use overloaded function. More...
 
bool exec (const std::string &sql_s, const std::initializer_list< std::string > &args) const
 Prepare and execute SQL statement with provided arguments. More...
 
rows select (const std::string &sql_s) const
 Execute raw SQL statement and return the result. More...
 
rows select (const std::string &sql_s, const std::initializer_list< std::string > &args) const
 Prepare and execute SQL statement with provided arguments and return the result. More...
 
result select_one (const std::string &sql_s) const
 select Execute raw SQL statement and return the single result More...
 
result select_one (const std::string &sql_s, const std::initializer_list< std::string > &args) const
 Prepare and execute SQL statement with provided arguments and return the single result. More...
 
intptr_t get_id (void) const
 Get last insert rowid. More...
 
bool is_open (void) const
 Check if database already open. More...
 
void close (void) const
 Close database. Call this on app shutdown. More...
 

Static Public Member Functions

static DBEnginegetInstance ()
 Return instance of DBEngine object. Check current instance. If it is NULL then create a new one. Otherwise return existing one. More...
 

Protected Member Functions

 DBEngine (DBEngine const &)=delete
 
DBEngineoperator= (DBEngine const &)=delete
 
 DBEngine ()
 
 ~DBEngine ()
 

Static Protected Attributes

static DBEngineDBEngine_instance
 

Detailed Description

Author
Alexey S. Malakhov breze.nosp@m.rk@g.nosp@m.mail..nosp@m.com

Constructor & Destructor Documentation

q4wine::lib::DBEngine::DBEngine ( DBEngine const &  )
protecteddelete

Disable copy

q4wine::lib::DBEngine::DBEngine ( )
protected

Constructs an DBObject object.

q4wine::lib::DBEngine::~DBEngine ( )
protected

Destroys this DBEngine object.

Member Function Documentation

void q4wine::lib::DBEngine::close ( void  ) const
bool q4wine::lib::DBEngine::exec ( const std::string &  sql_s) const
See also
exec
Parameters
sql_sRaw SQL string
Returns
True on success.
bool q4wine::lib::DBEngine::exec ( const std::string &  sql_s,
const std::initializer_list< std::string > &  args 
) const
Parameters
sql_sRaw SQL string.
argsA list of values to bound.
Returns
True on success.
intptr_t q4wine::lib::DBEngine::get_id ( void  ) const
Returns
Row id
DBEngine * q4wine::lib::DBEngine::getInstance ( )
static
Returns
instance of DBEngine.
bool q4wine::lib::DBEngine::init ( void  )
Returns
True on success.
bool q4wine::lib::DBEngine::is_open ( void  ) const
Returns
True if db is open.
bool q4wine::lib::DBEngine::open ( std::string  name)
Parameters
nameA URI file name. The path component of the URI specifies the disk file that is the SQLite database to be opened. If the path component is omitted, then the database is stored in a temporary file that will be automatically deleted when the database connection closes.
Returns
True on success
DBEngine& q4wine::lib::DBEngine::operator= ( DBEngine const &  )
protecteddelete

Disable copy on =

rows q4wine::lib::DBEngine::select ( const std::string &  sql_s) const
Parameters
sql_sRaw SQL string.
Returns
Return a map of rows
See also
rows.
rows q4wine::lib::DBEngine::select ( const std::string &  sql_s,
const std::initializer_list< std::string > &  args 
) const
Parameters
sql_sRaw SQL string.
argsA list of values to bound.
Returns
A map of rows
See also
rows.
result q4wine::lib::DBEngine::select_one ( const std::string &  sql_s) const
Note
You don't need to specify SQL LIMIT command, this function will add it by default.
Parameters
sql_sRaw SQL string.
Returns
Return single result
See also
result.
result q4wine::lib::DBEngine::select_one ( const std::string &  sql_s,
const std::initializer_list< std::string > &  args 
) const
Note
You don't need to specify SQL LIMIT command, this function will add it by default.
Parameters
sql_sRaw SQL string.
argsA list of values to bound.
Returns
Return single result
See also
result.

Member Data Documentation

DBEngine * q4wine::lib::DBEngine::DBEngine_instance
staticprotected

Instance of DBEngine object.


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