xc
Classes | Public Types | Public Member Functions | List of all members
Database Class Reference

Classes

class  Mutex
 Mutex container class, used by Lock. More...
 
struct  OPENDB
 Connection pool struct. More...
 

Public Types

typedef std::list< OPENDB * > opendb_v
 

Public Member Functions

 Database (const std::string &database, IError *=NULL)
 Use file.
 
 Database (Mutex &, const std::string &database, IError *=NULL)
 Use file + thread safe.
 
bool Connected (void)
 try to establish connection with given host
 
void RegErrHandler (IError *)
 
void error (Query &, const char *format,...)
 
void error (Query &, const std::string &)
 
OPENDBgrabdb ()
 Request a database connection. More...
 
void freedb (OPENDB *odb)
 
std::string safestr (const std::string &)
 Escape string - change all ' to ''. More...
 
std::string xmlsafestr (const std::string &)
 Make string xml safe. More...
 
int64_t a2bigint (const std::string &)
 Convert string to 64-bit integer. More...
 
uint64_t a2ubigint (const std::string &)
 Convert string to unsigned 64-bit integer. More...
 
const std::string & getName (void) const
 

Member Function Documentation

◆ a2bigint()

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

Convert string to 64-bit integer.

◆ a2ubigint()

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

Convert string to unsigned 64-bit integer.

◆ grabdb()

Database::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.

◆ safestr()

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

Escape string - change all ' to ''.

◆ xmlsafestr()

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

Make string xml safe.


The documentation for this class was generated from the following files: