Database Class Reference

Connection information and pool. More...

#include <Database.h>

List of all members.

Public Types

typedef std::list
< OPENDB * > 
opendb_v
 The pool of open database connections.

Public Member Functions

 Database (const std::string &database)
 Construc a Database that uses the specified filename.
virtual ~Database ()
 Destructor.
bool Connected ()
 try to establish connection with given host
OPENDBgrabdb ()
 Request a database connection.
void freedb (OPENDB *odb)
 Free the database connection.
std::string safestr (const std::string &)
 Escape string - change all ' to ''.
std::string xmlsafestr (const std::string &)
 Make string xml safe.
int64_t a2bigint (const std::string &)
 Convert string to 64-bit integer.
uint64_t a2ubigint (const std::string &)
 Convert string to unsigned 64-bit integer.

Classes

struct  OPENDB
 Connection pool struct. More...


Detailed Description

Connection information and pool.

Definition at line 47 of file Database.h.


Constructor & Destructor Documentation

Database::Database ( const std::string &  database  ) 

Construc a Database that uses the specified filename.

virtual Database::~Database (  )  [virtual]

Destructor.


Member Function Documentation

OPENDB* Database::grabdb (  ) 

Request a database connection.

The "grabdb" method is used by the Query class, so that each object instance of Query gets a unique database connection. I will reimplement your connection check logic in the Query class, as that's where the database connection is really used. It should be used something like this. { Query q(db); if (!q.Connected()) return false; q.execute("delete * from user"); // well maybe not }

When the Query object is deleted, then "freedb" is called - the database connection stays open in the m_opendbs vector. New Query objects can then reuse old connections.

void Database::freedb ( OPENDB odb  ) 

Free the database connection.

std::string Database::safestr ( const std::string &   ) 

Escape string - change all ' to ''.

std::string Database::xmlsafestr ( const std::string &   ) 

Make string xml safe.

int64_t Database::a2bigint ( const std::string &   ) 

Convert string to 64-bit integer.

uint64_t Database::a2ubigint ( const std::string &   ) 

Convert string to unsigned 64-bit integer.


Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo