tntdb
1.4
|
Main namespace for Tntdb. More...
Classes | |
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 | 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... | |
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... | |
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 > | |
Statement & | operator<<= (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... | |
bool | operator>> (const Value &value, bool &out) |
Extraction operators for standard types. More... | |
bool | operator>> (const Value &value, short &out) |
bool | operator>> (const Value &value, int &out) |
bool | operator>> (const Value &value, long &out) |
bool | operator>> (const Value &value, unsigned short &out) |
bool | operator>> (const Value &value, unsigned &out) |
bool | operator>> (const Value &value, unsigned long &out) |
bool | operator>> (const Value &value, int32_t &out) |
bool | operator>> (const Value &value, uint32_t &out) |
bool | operator>> (const Value &value, int64_t &out) |
bool | operator>> (const Value &value, uint64_t &out) |
bool | operator>> (const Value &value, Decimal &out) |
bool | operator>> (const Value &value, float &out) |
bool | operator>> (const Value &value, double &out) |
bool | operator>> (const Value &value, char &out) |
bool | operator>> (const Value &value, std::string &out) |
bool | operator>> (const Value &value, cxxtools::String &out) |
bool | operator>> (const Value &value, Blob &out) |
bool | operator>> (const Value &value, Date &out) |
bool | operator>> (const Value &value, Time &out) |
bool | operator>> (const Value &value, Datetime &out) |
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... | |
Main namespace for Tntdb.
All Tntdb code is in this namespace.
Alternative name for the statement iterator.
It may be easier to write and read.
|
inline |
C++11 style begin function for tntdb::Result.
|
inline |
C++11 style begin function for tntdb::Row.
|
inline |
C++11 style begin function for tntdb::Statement.
unsigned tntdb::cachedConnections | ( | ) |
Returns the number of cached connections.
Note that connections, which are in use are not counted.
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.
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:
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.
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.
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.
|
inline |
C++11 style end function for tntdb::Result.
|
inline |
C++11 style end function for tntdb::Row.
|
inline |
C++11 style end function for tntdb::Statement.
unsigned tntdb::getMaxPoolSize | ( | ) |
Get the current setting for maximum pool size (see setMaxPoolSize())
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
Set operators for host variables.
Set operators for host variables.
Set operators for host variables.
void tntdb::operator<< | ( | Hostvar & | hostvar, |
const std::deque< T > & | data | ||
) |
Set operators for host variables.
void tntdb::operator<< | ( | Hostvar & | hostvar, |
const std::list< T > & | data | ||
) |
Set operators for host variables.
void tntdb::operator<< | ( | Hostvar & | hostvar, |
const std::multiset< T > & | data | ||
) |
Set operators for host variables.
void tntdb::operator<< | ( | Hostvar & | hostvar, |
const std::set< T > & | data | ||
) |
Set operators for host variables.
|
inline |
Set operators for host variables.
void tntdb::operator<< | ( | Hostvar & | hostvar, |
const std::vector< T > & | data | ||
) |
Set operators for host variables.
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
|
inline |
Set operators for host variables.
void tntdb::operator<<= | ( | cxxtools::SerializationInfo & | si, |
const Result & | res | ||
) |
Makes tntdb::Result 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 Statement & | res | ||
) |
Makes tntdb::Statement serializable in cxxtools serialization framework.
void tntdb::operator<<= | ( | cxxtools::SerializationInfo & | si, |
const Value & | value | ||
) |
Makes tntdb::Value serializable in cxxtools serialization framework.
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
|
inline |
Extraction operators for standard types.
void tntdb::operator>>= | ( | const cxxtools::SerializationInfo & | si, |
Statement & | stmt | ||
) |
Serialize operator for tntdb::Statement.
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.