tntdb Namespace Reference

Namespaces

namespace  mysql
 This namespace contains the implementation of the Mysql driver for tntdb.
namespace  oracle
 This namespace contains the implementation of the Oracle driver for tntdb.
namespace  postgresql
 This namespace contains the implementation of the PostgreSQL driver for tntdb.
namespace  replicate
namespace  sqlite
 This namespace contains the implementation of the Sqlite driver for tntdb.

Classes

class  Blob
 Binary large objects. More...
class  BlobStreamBuf
 streambuf for reading from a tntdb::Blob More...
class  BlobIStream
 istream for reading from a tntdb::Blob More...
class  Connection
 This class holds a connection to a database. More...
class  Result
 The class holds a resultset of a query. More...
class  Row
 Row represents a row, which is fetched from the database. More...
class  RowReader
 A RowReader is a class which helps reading multiple columns from a row. More...
class  Statement
 This class represents an SQL statement. More...
class  Hostvar
 Helper class to hold a Statement and a column name. More...
class  Value
 The class Value represents a value, which is fetched from the database. More...
class  ConnectionPool
class  ConnectionPools
class  Date
 This class holds a date. More...
class  Datetime
 This class holds a date and a time. More...
class  Decimal
class  Error
 Base class for database errors. More...
class  NotFound
 Exception thrown when selectRow or selectValue doesn't fetch any data. More...
class  NullValue
 Exception thrown when a Value::get...() is called on a NULL value. More...
class  TypeError
 Exception thrown when a Value can't be converted to a requested type. More...
class  SqlError
 Exception thrown when the execution of an SQL statement caused an error. More...
class  FieldNotFound
class  IBlob
 Implementation base of Blob values. More...
class  IConnection
class  IStmtCacheConnection
class  IConnectionManager
class  ICursor
class  IResult
 common inteface for resultset More...
class  IRow
 common interface for row-types More...
class  IStatement
class  IValue
 common inteface for resultvalues More...
class  BlobImpl
 Default Blob value implementation. More...
struct  BlobDataInitializer
class  PoolConnection
class  ResultImpl
class  RowImpl
class  ValueImpl
class  LibraryManager
class  SqlBuilder
 Helper class for building sql statements. More...
class  StmtEvent
class  StmtParser
 Search host variables. More...
class  Time
 This class holds a time. More...
class  Transaction
 The class Transaction monitors the state of a transaction on a database connection. More...

Typedefs

typedef Statement::const_iterator Cursor
 Alternative name for the statement iterator.

Functions

Connection connect (const std::string &url)
 Establish a connection to a database.
Connection connectCached (const std::string &url)
 Fetch a connection from a pool or create a new one.
void dropCached (unsigned keep=0)
 Release unused connections; keep the given number of connections.
void dropCached (const std::string &url, unsigned keep=0)
 Release unused connections with the given database url; keep the given number of connections.
void setMaxPoolSize (unsigned max)
 Set the maximum pool size for new connection pools.
unsigned getMaxPoolSize ()
 Get the current setting for maximum pool size (see setMaxPoolSize())
void operator<< (Hostvar &hostvar, const cxxtools::Date &dt)
 This operator can be used to pass a cxxtools::Date object to the database.
bool operator>> (const Value &value, cxxtools::Date &out)
 This operator can be used to retrieve a cxxtools::Date object from the database.
void operator<< (Hostvar &hostvar, const cxxtools::DateTime &dt)
 This operator can be used to pass a cxxtools::DateTime object to the database.
bool operator>> (const Value &value, cxxtools::DateTime &out)
 This operator can be used to retrieve a cxxtools::DateTime object from the database.
void operator<< (Hostvar &hostvar, const cxxtools::Time &tim)
 This operator can be used to pass a cxxtools::Time object to the database.
bool operator>> (const Value &value, cxxtools::Time &out)
 This operator can be used to retrieve a cxxtools::Time object from the database.
template<int64_t Resolution>
void operator<< (Hostvar &hostvar, const cxxtools::WeakTimespan< Resolution > &ts)
 This operator can be used to pass a timespan object to the database.
template<int64_t Resolution>
bool operator>> (const Value &value, cxxtools::WeakTimespan< Resolution > &out)
 This operator can be used to retrieve a timespan object from the database.
std::istream & operator>> (std::istream &in, Decimal &dec)
std::ostream & operator<< (std::ostream &out, const Decimal &dec)
Result::const_iterator begin (const Result &stmt)
 C++11 style begin function for tntdb::Result.
Result::const_iterator end (const Result &stmt)
 C++11 style end function for tntdb::Result.
Row::const_iterator begin (const Row &stmt)
 C++11 style begin function for tntdb::Row.
Row::const_iterator end (const Row &stmt)
 C++11 style end function for tntdb::Row.
void operator<<= (cxxtools::SerializationInfo &si, const Value &value)
 Makes tntdb::Value serializable in cxxtools serialization framework.
void operator<<= (cxxtools::SerializationInfo &si, const Row &row)
 Makes tntdb::Row serializable in cxxtools serialization framework.
void operator<<= (cxxtools::SerializationInfo &si, const Result &res)
 Makes tntdb::Result serializable in cxxtools serialization framework.
void operator<<= (cxxtools::SerializationInfo &si, const Statement &res)
 Makes tntdb::Statement serializable in cxxtools serialization framework.
void operator>>= (const cxxtools::SerializationInfo &si, Statement &stmt)
 Serialize operator for tntdb::Statement.
template<typename T >
Statementoperator<<= (Statement &stmt, const T &obj)
 Serialize objects into tntdb::Statement.
template<typename T >
void operator>>= (const Row &row, T &obj)
Statement::const_iterator begin (const Statement &stmt, unsigned fetchsize=100)
 C++11 style begin function for tntdb::Statement.
Statement::const_iterator end (const Statement &stmt)
 C++11 style end function for tntdb::Statement.
void operator<< (Hostvar &hostvar, bool data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, int data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, long data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, unsigned data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, unsigned long data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, int32_t data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, uint32_t data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, int64_t data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, uint64_t data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const Decimal &data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, float data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, double data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, char data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const std::string &data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const char *data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const cxxtools::String &data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const Blob &data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const Date &data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const Time &data)
 Set operators for host variables.
void operator<< (Hostvar &hostvar, const Datetime &data)
 Set operators for host variables.
template<typename T >
void operator<< (Hostvar &hostvar, const std::vector< T > &data)
 Set operators for host variables.
template<typename T >
void operator<< (Hostvar &hostvar, const std::list< T > &data)
 Set operators for host variables.
template<typename T >
void operator<< (Hostvar &hostvar, const std::deque< T > &data)
 Set operators for host variables.
template<typename T >
void operator<< (Hostvar &hostvar, const std::set< T > &data)
 Set operators for host variables.
template<typename T >
void operator<< (Hostvar &hostvar, const std::multiset< T > &data)
 Set operators for host variables.
bool operator>> (const Value &value, bool &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, short &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, int &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, long &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, unsigned short &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, unsigned &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, unsigned long &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, int32_t &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, uint32_t &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, int64_t &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, uint64_t &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, Decimal &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, float &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, double &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, char &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, std::string &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, cxxtools::String &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, Blob &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, Date &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, Time &out)
 Extraction operators for standard types.
bool operator>> (const Value &value, Datetime &out)
 Extraction operators for standard types.

Typedef Documentation

Alternative name for the statement iterator.

It may be easier to write and read.

Function Documentation

Result::const_iterator tntdb::begin ( const Result &  stmt)
inline

C++11 style begin function for tntdb::Result.

Statement::const_iterator tntdb::begin ( const Statement &  stmt,
unsigned  fetchsize = 100 
)
inline

C++11 style begin function for tntdb::Statement.

Row::const_iterator tntdb::begin ( const Row &  stmt)
inline

C++11 style begin function for tntdb::Row.

Connection tntdb::connect ( const std::string &  url)

Establish a connection to a database.

The url is prefixed with a driver name followed by a colon and a driver-specific part. If the connection can't be established, an exception derived from tntdb::Error is thrown.

Examples:

tntdb::Connection sqConn = tntdb::connect("sqlite:mydatabase.db");
tntdb::Connection pgConn = tntdb::connect("postgresql:dbname=DS2 user=web passwd=web");
tntdb::Connection myConn = tntdb::connect("mysql:db=DS2;user=web;passwd=web");
tntdb::Connection orConn = tntdb::connect("oracle:XE;user=hr;passwd=hr");
Connection tntdb::connectCached ( const std::string &  url)

Fetch a connection from a pool or create a new one.

A static pool of connections is kept in memory. This function looks in this pool if there is a connection with the given url. If found, the connection is removed from the pool and returned. When the returned Connection object is destroyed (and all copies are too), the actual connection is put back into the pool.

When there is no connection with the given url in the pool, a new connection is established.

void tntdb::dropCached ( unsigned  keep = 0)

Release unused connections; keep the given number of connections.

void tntdb::dropCached ( const std::string &  url,
unsigned  keep = 0 
)

Release unused connections with the given database url; keep the given number of connections.

Result::const_iterator tntdb::end ( const Result &  stmt)
inline

C++11 style end function for tntdb::Result.

Statement::const_iterator tntdb::end ( const Statement &  stmt)
inline

C++11 style end function for tntdb::Statement.

Row::const_iterator tntdb::end ( const Row &  stmt)
inline

C++11 style end function for tntdb::Row.

unsigned tntdb::getMaxPoolSize ( )

Get the current setting for maximum pool size (see setMaxPoolSize())

void tntdb::operator<< ( Hostvar &  hostvar,
const cxxtools::Date dt 
)
inline

This operator can be used to pass a cxxtools::Date object to the database.

tntdb::Statement stmt = conn.prepare("select ... where dt = :dt");
cxxtools::Date dt(2011, 5, 3);
stmt.set("dt", dt);
void tntdb::operator<< ( Hostvar &  hostvar,
const cxxtools::DateTime dt 
)
inline

This operator can be used to pass a cxxtools::DateTime object to the database.

tntdb::Statement stmt = conn.prepare("select ... where dt = :dt");
cxxtools::DateTime dt(2011, 5, 3, 18, 45, 30);
stmt.set("dt", dt);
void tntdb::operator<< ( Hostvar &  hostvar,
const cxxtools::Time tim 
)
inline

This operator can be used to pass a cxxtools::Time object to the database.

tntdb::Statement stmt = conn.prepare("select ... where tim = :tim");
cxxtools::Time tim(18, 45, 30);
stmt.set("tim", tim);
template<int64_t Resolution>
void tntdb::operator<< ( Hostvar &  hostvar,
const cxxtools::WeakTimespan< Resolution > &  ts 
)

This operator can be used to pass a timespan object to the database.

The operator expects a numeric column, which is set to the number of specified units.

tntdb::Statement stmt = conn.prepare("select ... where ts = :ts");
stmt.set("ts", cxxtools::Milliseconds(500));
std::ostream& tntdb::operator<< ( std::ostream &  out,
const Decimal &  dec 
)
void tntdb::operator<< ( Hostvar &  hostvar,
bool  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
int  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
long  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
unsigned  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
unsigned long  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
int32_t  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
uint32_t  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
int64_t  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
uint64_t  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const Decimal &  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
float  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
double  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
char  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const std::string &  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const char *  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const cxxtools::String data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const Blob &  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const Date &  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const Time &  data 
)
inline

Set operators for host variables.

void tntdb::operator<< ( Hostvar &  hostvar,
const Datetime &  data 
)
inline

Set operators for host variables.

template<typename T >
void tntdb::operator<< ( Hostvar &  hostvar,
const std::vector< T > &  data 
)

Set operators for host variables.

template<typename T >
void tntdb::operator<< ( Hostvar &  hostvar,
const std::list< T > &  data 
)

Set operators for host variables.

template<typename T >
void tntdb::operator<< ( Hostvar &  hostvar,
const std::deque< T > &  data 
)

Set operators for host variables.

template<typename T >
void tntdb::operator<< ( Hostvar &  hostvar,
const std::set< T > &  data 
)

Set operators for host variables.

template<typename T >
void tntdb::operator<< ( Hostvar &  hostvar,
const std::multiset< T > &  data 
)

Set operators for host variables.

void tntdb::operator<<= ( cxxtools::SerializationInfo si,
const Value &  value 
)

Makes tntdb::Value serializable in cxxtools serialization framework.

void tntdb::operator<<= ( cxxtools::SerializationInfo si,
const Row &  row 
)

Makes tntdb::Row serializable in cxxtools serialization framework.

void tntdb::operator<<= ( cxxtools::SerializationInfo si,
const Result &  res 
)

Makes tntdb::Result serializable in cxxtools serialization framework.

void tntdb::operator<<= ( cxxtools::SerializationInfo si,
const Statement &  res 
)

Makes tntdb::Statement serializable in cxxtools serialization framework.

template<typename T >
Statement& tntdb::operator<<= ( Statement &  stmt,
const T &  obj 
)

Serialize objects into tntdb::Statement.

This sets the placeholder variables in statement to the value of the object to serialize.

Example: /code MyObject obj = ...; stmt = db.prepare("insert into ..."); stmt <<= obj; // this serializes MyObject into the statement // by using the serialization operator of MyObject // and setting the members in the statement one by one

stmt.execute(); /endcode

bool tntdb::operator>> ( const Value &  value,
cxxtools::Date out 
)
inline

This operator can be used to retrieve a cxxtools::Date object from the database.

tntdb::Statement sel = conn.prepare("select dt from ...");
if (v.get(dt))
std::cout << "dt=" << dt.toIsoString() << std::endl;
else
std::cout << "dt is null" << std::endl;
bool tntdb::operator>> ( const Value &  value,
cxxtools::Time out 
)
inline

This operator can be used to retrieve a cxxtools::Time object from the database.

tntdb::Statement sel = conn.prepare("select tim from ...");
if (v.get(tim))
std::cout << "tim=" << tim.toIsoString() << std::endl;
else
std::cout << "tim is null" << std::endl;
bool tntdb::operator>> ( const Value &  value,
cxxtools::DateTime out 
)
inline

This operator can be used to retrieve a cxxtools::DateTime object from the database.

tntdb::Statement sel = conn.prepare("select dt from ...");
if (v.get(dt))
std::cout << "dt=" << dt.toIsoString() << std::endl;
else
std::cout << "dt is null" << std::endl;
template<int64_t Resolution>
bool tntdb::operator>> ( const Value &  value,
cxxtools::WeakTimespan< Resolution > &  out 
)

This operator can be used to retrieve a timespan object from the database.

A numeric value is read from the database and interpreted as a number of specified units.

tntdb::Statement sel = conn.prepare("select tim from ...");
if (v.get(tim))
std::cout << "tim=" << tim << std::endl;
else
std::cout << "tim is null" << std::endl;
bool tntdb::operator>> ( const Value &  value,
bool &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
short &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
int &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
long &  out 
)
inline

Extraction operators for standard types.

std::istream& tntdb::operator>> ( std::istream &  in,
Decimal &  dec 
)
bool tntdb::operator>> ( const Value &  value,
unsigned short &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
unsigned &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
unsigned long &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
int32_t &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
uint32_t &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
int64_t &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
uint64_t &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
Decimal &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
float &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
double &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
char &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
std::string &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
cxxtools::String out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
Blob &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
Date &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
Time &  out 
)
inline

Extraction operators for standard types.

bool tntdb::operator>> ( const Value &  value,
Datetime &  out 
)
inline

Extraction operators for standard types.

void tntdb::operator>>= ( const cxxtools::SerializationInfo si,
Statement &  stmt 
)

Serialize operator for tntdb::Statement.

template<typename T >
void tntdb::operator>>= ( const Row &  row,
T &  obj 
)
void tntdb::setMaxPoolSize ( unsigned  max)

Set the maximum pool size for new connection pools.

When the maximum number of connections to a specific url is reached, connectCached blocks until a connection is available.

This setting do not affect pools with active connections. You have to release all connections and clear the pool of all connections to your database with dropCached(url) for this setting to take effect.