libsq3  2007.10.18
Classes | Typedefs | Functions
sq3 Namespace Reference

The sq3 namespace encapsulates an OO sqlite3 API very similar to the sqlite3x API, but this one uses no exception handling (i.e., it doesn't throw on errors). More...

Classes

struct  sqlite3_finalizer
 A specialized dtor to close sqlite3 handles, for use with refcount::rcptr<sqlite3,sqlite3_finalizer >. More...
 
struct  statement_reset_finalizer
 A specialized dtor to reset (not close) sq3::statement objects, for use with refcount::rcptr<sqlite3,statement_reset_finalizer>. More...
 
struct  sqlite3_stmt_reset_finalizer
 A specialized dtor to call reset sqlite3_stmt handles(), for use with refcount::rcptr<sqlite3,sqlite3_stmt_reset_finalizer>. More...
 
struct  sqlite3_stmt_finalizer
 A specialized dtor to finalize sqlite3_stmt handles, for use with refcount::rcptr<sqlite3,sqlite3_stmt_finalizer>. More...
 
class  database
 Encapsulates a connection to an sqlite database. More...
 
class  transaction
 This type represents a transaction block in an SQL session. More...
 
class  cursor
 This type is for stepping through a db query result. More...
 
class  statement
 This class represents a prepared database statement. More...
 
class  log_db
 log_db is a simple logging database for use with arbitrary applications. More...
 
class  settings_db
 settings_db ia a very simplistic key/value pair database for use with the sq3 database layer. More...
 

Typedefs

typedef sqlite_int64 int64_t
 The type used for signed 64-bit integer operations.
 
typedef sqlite_uint64 uint64_t
 The type used for unsigned 64-bit integer operations.
 
typedef char unsigned sqlite3_text_char_t
 The published result codes from the sqlite3 API. More...
 

Functions

bool rc_is_okay (int rc)
 rc_is_okay() is an easy way to check if rc is one of SQLITE_OK, SQLITE_ROW, or SQLITE_DONE. More...
 

Detailed Description

The sq3 namespace encapsulates an OO sqlite3 API very similar to the sqlite3x API, but this one uses no exception handling (i.e., it doesn't throw on errors).

It is intended to be an alternative for platforms/projects where exceptions are not desired or not available.

Wide-char support does not currently work. (On my platform (gcc/linux) wchar_t is 4 bytes and sqlite3 wants 2-bytes wide chars for UTF16 text.)

This code was written by stephan beal (steph.nosp@m.an@s.nosp@m.11n.n.nosp@m.et) and is released into the Public Domain. It was modelled heavily after code written by Cory Nelson, but was reimplemented from scratch for use on a PocketPC platform where throwing exceptions wasn't allowed.

This code's home page is:

http://s11n.net/sqlite/

Change history (only "significant" changes documented here):

Typedef Documentation

typedef char unsigned sq3::sqlite3_text_char_t

The published result codes from the sqlite3 API.

A char type used by some of the sqlite3 API to represent text data. This is really annoying, but sqlite3's API explicitely uses UNSIGNED char arrays for a couple of strings, while using signed char arrays for almost everything else.

Definition at line 127 of file sq3.hpp.

Function Documentation

bool sq3::rc_is_okay ( int  rc)

rc_is_okay() is an easy way to check if rc is one of SQLITE_OK, SQLITE_ROW, or SQLITE_DONE.

This function returns true if rc is one of those values, else false. (Code which accepts arbitrary SQL from a user often has to accept any of those three result codes as success.)

Definition at line 56 of file sq3.cpp.

Referenced by sq3::database::clear(), sq3::settings_db::get(), and sq3::log_db::log().