tntdb  1.4
tntdb Namespace Reference

Main namespace for Tntdb. More...

Classes

class  Blob
 Binary large objects. More...
 
class  BlobIStream
 istream for reading from a tntdb::Blob More...
 
class  BlobStreamBuf
 streambuf for reading from a tntdb::Blob More...
 
class  Connection
 This class holds a connection to a 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  FieldNotFound
 
class  Hostvar
 Helper class to hold a Statement and a column name. More...
 
class  LibraryManager
 
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  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  SqlBuilder
 Helper class for building sql statements. More...
 
class  SqlError
 Exception thrown when the execution of an SQL statement caused an error. More...
 
class  Statement
 This class represents an SQL statement. 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...
 
class  TypeError
 Exception thrown when a Value can't be converted to a requested type. More...
 
class  Value
 The class Value represents a value, which is fetched from the database. More...
 

Typedefs

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

Functions

Connection connect (const std::string &url, const std::string &username, const std::string &password)
 Establish a connection to a database. More...
 
Connection connect (const std::string &url)
 
Connection connectCached (const std::string &url, const std::string &username, const std::string &password)
 Fetch a connection from a pool or create a new one. More...
 
Connection connectCached (const std::string &url)
 
unsigned cachedConnections ()
 Returns the number of cached connections. More...
 
unsigned cachedConnections (const std::string &url, const std::string &username, const std::string &password)
 Returns the number of cached connections for the specified url. More...
 
unsigned cachedConnections (const std::string &url)
 
unsigned dropCached (unsigned keep=0)
 Release unused connections; keep the given number of connections. More...
 
unsigned dropCached (const std::string &url, const std::string &username="", const std::string &password="", unsigned keep=0)
 Release unused connections with the given database url; keep the given number of connections Note that connections, which are in use are not freed. More...
 
unsigned dropCached (const std::string &url, unsigned keep)
 
void setMaxPoolSize (unsigned max)
 Set the maximum pool size for new connection pools. More...
 
unsigned getMaxPoolSize ()
 Get the current setting for maximum pool size (see setMaxPoolSize()) More...
 
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. More...
 
Result::const_iterator end (const Result &stmt)
 C++11 style end function for tntdb::Result. More...
 
Row::const_iterator begin (const Row &stmt)
 C++11 style begin function for tntdb::Row. More...
 
Row::const_iterator end (const Row &stmt)
 C++11 style end function for tntdb::Row. More...
 
void operator<<= (cxxtools::SerializationInfo &si, const Value &value)
 Makes tntdb::Value serializable in cxxtools serialization framework. More...
 
void operator<<= (cxxtools::SerializationInfo &si, const Row &row)
 Makes tntdb::Row serializable in cxxtools serialization framework. More...
 
void operator<<= (cxxtools::SerializationInfo &si, const Result &res)
 Makes tntdb::Result serializable in cxxtools serialization framework. More...
 
void operator<<= (cxxtools::SerializationInfo &si, const Statement &res)
 Makes tntdb::Statement serializable in cxxtools serialization framework. More...
 
void operator>>= (const cxxtools::SerializationInfo &si, Statement &stmt)
 Serialize operator for tntdb::Statement. More...
 
template<typename T >
Statementoperator<<= (Statement &stmt, const T &obj)
 Serialize objects into tntdb::Statement. More...
 
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. More...
 
Statement::const_iterator end (const Statement &stmt)
 C++11 style end function for tntdb::Statement. More...
 
void operator<< (Hostvar &hostvar, bool data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, int data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, long data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, unsigned data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, unsigned long data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, int32_t data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, uint32_t data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, int64_t data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, uint64_t data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const Decimal &data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, float data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, double data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, char data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const std::string &data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const char *data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const cxxtools::String &data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const Blob &data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const Date &data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const Time &data)
 Set operators for host variables. More...
 
void operator<< (Hostvar &hostvar, const Datetime &data)
 Set operators for host variables. More...
 
template<typename T >
void operator<< (Hostvar &hostvar, const std::vector< T > &data)
 Set operators for host variables. More...
 
template<typename T >
void operator<< (Hostvar &hostvar, const std::list< T > &data)
 Set operators for host variables. More...
 
template<typename T >
void operator<< (Hostvar &hostvar, const std::deque< T > &data)
 Set operators for host variables. More...
 
template<typename T >
void operator<< (Hostvar &hostvar, const std::set< T > &data)
 Set operators for host variables. More...
 
template<typename T >
void operator<< (Hostvar &hostvar, const std::multiset< T > &data)
 Set operators for host variables. More...
 
bool operator>> (const Value &value, bool &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, short &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, int &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, long &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, unsigned short &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, unsigned &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, unsigned long &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, int32_t &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, uint32_t &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, int64_t &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, uint64_t &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, Decimal &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, float &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, double &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, char &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, std::string &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, cxxtools::String &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, Blob &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, Date &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, Time &out)
 Extraction operators for standard types. More...
 
bool operator>> (const Value &value, Datetime &out)
 Extraction operators for standard types. More...
 

Detailed Description

Main namespace for Tntdb.

All Tntdb code is in this namespace.

Typedef Documentation

◆ Cursor

Alternative name for the statement iterator.

It may be easier to write and read.

Function Documentation

◆ begin() [1/3]

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

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

◆ begin() [2/3]

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

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

◆ begin() [3/3]

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

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

◆ cachedConnections() [1/2]

unsigned tntdb::cachedConnections ( )

Returns the number of cached connections.

Note that connections, which are in use are not counted.

◆ cachedConnections() [2/2]

unsigned tntdb::cachedConnections ( const std::string &  url,
const std::string &  username,
const std::string &  password 
)

Returns the number of cached connections for the specified url.

Note that connections, which are in use are not counted.

◆ connect()

Connection tntdb::connect ( const std::string &  url,
const std::string &  username,
const std::string &  password 
)

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.

In the url the string "%u" is replaced with the username and "%p" is replaced with the password. The password parameter and the url with the replaced username and password fields is never logged.

To specify the text "%u" or "%p" in the connection string the '' can be escaped with backslash like this: "\%u".

Examples:

tntdb::Connection sqConn = tntdb::connect("sqlite:mydatabase.db");
tntdb::Connection pgConn = tntdb::connect("postgresql:dbname=DS2 user=%u passwd=%p", "web", "webpw");
tntdb::Connection myConn = tntdb::connect("mysql:db=DS2;user=%u;passwd=%p", "web", "webpw");
tntdb::Connection orConn = tntdb::connect("oracle:XE;user=%u;passwd=%p", "hr", "hr");

◆ connectCached()

Connection tntdb::connectCached ( const std::string &  url,
const std::string &  username,
const std::string &  password 
)

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.

◆ dropCached() [1/2]

unsigned tntdb::dropCached ( unsigned  keep = 0)

Release unused connections; keep the given number of connections.

Returns the number of connections freed. Note that connections, which are in use are not freed.

◆ dropCached() [2/2]

unsigned tntdb::dropCached ( const std::string &  url,
const std::string &  username = "",
const std::string &  password = "",
unsigned  keep = 0 
)

Release unused connections with the given database url; keep the given number of connections Note that connections, which are in use are not freed.

◆ end() [1/3]

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

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

◆ end() [2/3]

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

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

◆ end() [3/3]

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

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

◆ getMaxPoolSize()

unsigned tntdb::getMaxPoolSize ( )

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

◆ operator<<() [1/25]

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

Set operators for host variables.

◆ operator<<() [2/25]

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

Set operators for host variables.

◆ operator<<() [3/25]

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

Set operators for host variables.

◆ operator<<() [4/25]

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

Set operators for host variables.

◆ operator<<() [5/25]

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

Set operators for host variables.

◆ operator<<() [6/25]

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

Set operators for host variables.

◆ operator<<() [7/25]

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

Set operators for host variables.

◆ operator<<() [8/25]

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

Set operators for host variables.

◆ operator<<() [9/25]

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

Set operators for host variables.

◆ operator<<() [10/25]

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

Set operators for host variables.

◆ operator<<() [11/25]

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

Set operators for host variables.

◆ operator<<() [12/25]

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

Set operators for host variables.

◆ operator<<() [13/25]

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

Set operators for host variables.

◆ operator<<() [14/25]

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

Set operators for host variables.

◆ operator<<() [15/25]

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

Set operators for host variables.

◆ operator<<() [16/25]

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

Set operators for host variables.

◆ operator<<() [17/25]

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

Set operators for host variables.

◆ operator<<() [18/25]

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

Set operators for host variables.

◆ operator<<() [19/25]

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

Set operators for host variables.

◆ operator<<() [20/25]

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

Set operators for host variables.

◆ operator<<() [21/25]

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

Set operators for host variables.

◆ operator<<() [22/25]

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

Set operators for host variables.

◆ operator<<() [23/25]

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

Set operators for host variables.

◆ operator<<() [24/25]

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

Set operators for host variables.

◆ operator<<() [25/25]

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

Set operators for host variables.

◆ operator<<=() [1/5]

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

Makes tntdb::Value serializable in cxxtools serialization framework.

◆ operator<<=() [2/5]

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

Makes tntdb::Row serializable in cxxtools serialization framework.

◆ operator<<=() [3/5]

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

Makes tntdb::Result serializable in cxxtools serialization framework.

◆ operator<<=() [4/5]

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

Makes tntdb::Statement serializable in cxxtools serialization framework.

◆ operator<<=() [5/5]

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

◆ operator>>() [1/21]

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

Extraction operators for standard types.

◆ operator>>() [2/21]

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

Extraction operators for standard types.

◆ operator>>() [3/21]

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

Extraction operators for standard types.

◆ operator>>() [4/21]

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

Extraction operators for standard types.

◆ operator>>() [5/21]

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

Extraction operators for standard types.

◆ operator>>() [6/21]

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

Extraction operators for standard types.

◆ operator>>() [7/21]

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

Extraction operators for standard types.

◆ operator>>() [8/21]

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

Extraction operators for standard types.

◆ operator>>() [9/21]

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

Extraction operators for standard types.

◆ operator>>() [10/21]

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

Extraction operators for standard types.

◆ operator>>() [11/21]

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

Extraction operators for standard types.

◆ operator>>() [12/21]

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

Extraction operators for standard types.

◆ operator>>() [13/21]

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

Extraction operators for standard types.

◆ operator>>() [14/21]

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

Extraction operators for standard types.

◆ operator>>() [15/21]

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

Extraction operators for standard types.

◆ operator>>() [16/21]

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

Extraction operators for standard types.

◆ operator>>() [17/21]

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

Extraction operators for standard types.

◆ operator>>() [18/21]

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

Extraction operators for standard types.

◆ operator>>() [19/21]

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

Extraction operators for standard types.

◆ operator>>() [20/21]

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

Extraction operators for standard types.

◆ operator>>() [21/21]

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

Extraction operators for standard types.

◆ operator>>=()

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

Serialize operator for tntdb::Statement.

◆ setMaxPoolSize()

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.