glim::Sqlite Class Reference

#include <sqlite.hpp>

List of all members.


Detailed Description

The database.

According to sqlite3_open documentation, only the thread that opened the database can safely access it. This restriction was relaxed, as described in the FAQ (the "Is SQLite threadsafe?" question), so we can use the library from multiple threads, but only if no more than one thread at a time accesses the database. This restriction is, in fact, beneficial if the database is used from a single application: by restricting access to a sigle thread at a time, we effectively avoid all deadlock issues.
This library goals are:

The library is targeted at SQLite setup which is not -DTHREADSAFE, since this is the default setup on UNIX architectures.

This file is a header-only library, whose sole dependencies should be standard STL and posix threading libraries. You can extract this file out of the "glim" library to include it separately in your project.

This library is targeted at UTF-8 API. There is no plans to support the UTF-16 API.

See also:


Public Types

enum  Flags { existing = 1 }
 Flags for the Sqlite constructor. More...

Public Member Functions

 Sqlite (std::string filename, int flags=0)
 Opens the database.
 ~Sqlite ()
 Closes the database.

Protected Attributes

std::string filename
 Filename the database was opened with; we need it to reopen the database on fork()s.
::sqlite3 * handler
::pthread_mutex_t mutex

Friends

class SqliteSession


Member Enumeration Documentation

enum glim::Sqlite::Flags
 

Flags for the Sqlite constructor.

Enumerator:
existing  The file will be checked for existence.

std::runtime_error is thrown if the file is not accessible; format of the error description is "$filename: $strerror".
Usage example:

 Sqlite db ("filename", Sqlite::existing); 


Constructor & Destructor Documentation

glim::Sqlite::Sqlite std::string  filename,
int  flags = 0
[inline]
 

Opens the database.

Parameters:
filename Database filename (UTF-8).
flags Optional. Currently there is the existing flag.
Exceptions:
std::runtime_error Thrown if we can't open the database.

glim::Sqlite::~Sqlite  )  [inline]
 

Closes the database.

Exceptions:
std::runtime_error Thrown if we can't close the database.


Member Data Documentation

std::string glim::Sqlite::filename [protected]
 

Filename the database was opened with; we need it to reopen the database on fork()s.

std::string is used to avoid memory allocation issues.


Generated on Fri Nov 24 20:57:37 2006 for libglim by  doxygen 1.4.6