dodo  0.0.1
A C++ library to create containerized Linux services
dodo::persist::sqlite Namespace Reference

C++ API to SQLite. More...

Data Structures

class  Database
 A STL friendly wrapper around the great sqlite3. More...
 
class  DDL
 Data Definition Language, SQL that takes no parameters, returns no data such as CREATE TABLE. More...
 
class  DML
 Data Modification Language statements can take bind values. More...
 
class  Query
 Queries can take bind values and return select lists. More...
 
class  Statement
 Generic SQL Statement. More...
 

Typedefs

typedef int(* WaitHandler) (void *, int)
 Prototype for wait/busy handlers. More...
 

Functions

static void sqlite_ext_ceil (sqlite3_context *context, int argc, sqlite3_value **argv)
 Ceiling function extension for SQLite. More...
 
static void sqlite_ext_floor (sqlite3_context *context, int argc, sqlite3_value **argv)
 Floor function extension for SQLite. More...
 
static void sqlite_ext_log2 (sqlite3_context *context, int argc, sqlite3_value **argv)
 Base 2 logarithm extension for SQLite. More...
 
static void sqlite_ext_pow (sqlite3_context *context, int argc, sqlite3_value **argv)
 Power function extension for SQLite. More...
 

Detailed Description

C++ API to SQLite.

An example of the basics (src/examples/sqlite/sqlite.cpp):

#include <dodo.hpp>
#include <cstdio>
using namespace dodo;
int main() {
int exit_code = 0;
const std::string database_name = "mydb.sqlite";
try {
{
// open existing or create new database
persist::sqlite::Database db( database_name );
// create a schema
persist::sqlite::DDL schema( db );
schema.prepare( "CREATE TABLE IF NOT EXISTS foo ( foo NOT NULL PRIMARY KEY)" );
schema.execute();
// setup an insert statement
persist::sqlite::DML insert( db );
insert.prepare( "INSERT INTO foo (foo) VALUES (?)" );
insert.bind( 1, "insert1" );
// start a transaction
db.beginTransaction();
insert.execute();
// reset the query for re-execute with different value
insert.reset(true);
insert.bind( 1, "insert2" );
insert.execute();
db.commit();
// other persist::sqlite::Database objects will now see the inserts
// query and step the result set
qry.prepare( "select foo from foo order by foo" );
while ( qry.step() ) {
std::cout << qry.getText(0) << std::endl;
}
}
}
catch ( const std::exception &e ) {
// as the db object is now destructed, any un-comitted transaction is rolled back and the database is closed.
std::cerr << e.what() << std::endl;
exit_code = 1;
}
// delete the database file
remove( database_name.c_str() );
return exit_code;
}

Typedef Documentation

◆ WaitHandler

typedef int(* dodo::persist::sqlite::WaitHandler) (void *, int)

Prototype for wait/busy handlers.

Definition at line 43 of file sqlite.hpp.

Function Documentation

◆ sqlite_ext_ceil()

static void dodo::persist::sqlite::sqlite_ext_ceil ( sqlite3_context *  context,
int  argc,
sqlite3_value **  argv 
)
static

Ceiling function extension for SQLite.

Parameters
contextSQLite context.
argcThe number of arguments to this function.
argvThe arguments to this funcxtion.

Definition at line 89 of file sqlite.cpp.

Referenced by dodo::persist::sqlite::Database::Database().

Here is the caller graph for this function:

◆ sqlite_ext_floor()

static void dodo::persist::sqlite::sqlite_ext_floor ( sqlite3_context *  context,
int  argc,
sqlite3_value **  argv 
)
static

Floor function extension for SQLite.

Parameters
contextSQLite context.
argcThe number of arguments to this function.
argvThe arguments to this funcxtion.

Definition at line 112 of file sqlite.cpp.

Referenced by dodo::persist::sqlite::Database::Database().

Here is the caller graph for this function:

◆ sqlite_ext_log2()

static void dodo::persist::sqlite::sqlite_ext_log2 ( sqlite3_context *  context,
int  argc,
sqlite3_value **  argv 
)
static

Base 2 logarithm extension for SQLite.

Parameters
contextSQLite context.
argcThe number of arguments to this function.
argvThe arguments to this funcxtion.

Definition at line 67 of file sqlite.cpp.

Referenced by dodo::persist::sqlite::Database::Database().

Here is the caller graph for this function:

◆ sqlite_ext_pow()

static void dodo::persist::sqlite::sqlite_ext_pow ( sqlite3_context *  context,
int  argc,
sqlite3_value **  argv 
)
static

Power function extension for SQLite.

Parameters
contextSQLite context.
argcThe number of arguments to this function.
argvThe arguments to this funcxtion.

Definition at line 44 of file sqlite.cpp.

Referenced by dodo::persist::sqlite::Database::Database().

Here is the caller graph for this function:
dodo::persist::sqlite::Query
Queries can take bind values and return select lists.
Definition: sqlite.hpp:387
dodo
A C++ platform interface to lean Linux services tailored for containerized deployment.
Definition: application.hpp:29
dodo.hpp
Includes all dodo headers.
dodo::persist::sqlite::DML
Data Modification Language statements can take bind values.
Definition: sqlite.hpp:294
dodo::persist::sqlite::Database
A STL friendly wrapper around the great sqlite3.
Definition: sqlite.hpp:52
dodo::persist::sqlite::DDL
Data Definition Language, SQL that takes no parameters, returns no data such as CREATE TABLE.
Definition: sqlite.hpp:261