#include <sqldb.h>
Inheritance diagram for Dv::Sql::Db:
Public Member Functions | |
virtual | ~Db () |
Since this class will be subclassed, its destructor must be virtual. | |
bool | ok () const |
Return true iff status is ok; e.g. db was succesfully opened. | |
operator bool () const | |
Same as Dv::Sql::Db::ok(). | |
bool | operator! () const |
Same as !DvSql::Db::ok(). | |
std::string | err () const |
Return string representation of last error. | |
std::string | host () const |
Name of host machine on which database resides. | |
std::string | database () const |
Name of current database of connection. | |
std::ostream * | log () const |
Logging is turned on if log()!=0. | |
void | log (std::ostream *os) |
Turn logging on/off, see Db::log(). | |
virtual bool | database (const std::string &database)=0 |
Switch connection to database, return true iff succeeded. | |
virtual std::vector< std::string > | databases ()=0 |
Return names of available databases. | |
virtual std::vector< std::string > | tables ()=0 |
Return names of tables in databases. | |
virtual std::vector< Field > | fields (const std::string &table)=0 |
Return fields in table. | |
Protected Member Functions | |
bool | ok (bool b) |
Set status. | |
void | err (const std::string &s) |
Set error string returned by Dv::Sql::err(). | |
void | name (const std::string &dbname) |
Set database name. | |
virtual Command_ * | command_ (Command &)=0 |
Return dbms-specific command. | |
Db (const char *name, const char *host) | |
Constructor. | |
Private Member Functions | |
Db (const Db &) | |
Cctor is forbidden. | |
Db & | operator= (const Db &) |
Assignment is forbidden. | |
Private Attributes | |
std::string | host_ |
bool | ok_ |
std::string | err_ |
std::ostream * | log_ |
std::string | name_ |
Name of database, may be "". | |
Friends | |
class | Command |
Friend. |
Definition at line 138 of file sqldb.h.
|
Since this class will be subclassed, its destructor must be virtual. The destructor will close the connection. Reimplemented in Dv::MySql::Db. |
|
Constructor. The constructor takes the name of the database and the name of the host where the database resides. If name == 0, there is no database yet, if host == 0, we use "localhost" Copy ctor and assignment are forbidden. |
|
Cctor is forbidden.
Reimplemented in Dv::MySql::Db. |
|
Return true iff status is ok; e.g. db was succesfully opened.
Definition at line 150 of file sqldb.h. References ok_. |
|
Same as Dv::Sql::Db::ok().
Definition at line 152 of file sqldb.h. References ok_. |
|
Same as !DvSql::Db::ok().
Definition at line 154 of file sqldb.h. References ok_. |
|
Return string representation of last error.
Definition at line 157 of file sqldb.h. References err_. |
|
Name of host machine on which database resides.
Definition at line 159 of file sqldb.h. References host_. |
|
Name of current database of connection.
Reimplemented in Dv::MySql::Db. Definition at line 161 of file sqldb.h. References name_. |
|
Logging is turned on if log()!=0. The amount of logging is decided by the DBMS-dependent classes. E.g. Dv::MySql::Db logs the execution of every command as well as indication of the result. Definition at line 168 of file sqldb.h. References log_. |
|
Turn logging on/off, see Db::log().
Definition at line 170 of file sqldb.h. References log_. |
|
Switch connection to database, return true iff succeeded.
Implemented in Dv::MySql::Db. |
|
Return names of available databases.
Implemented in Dv::MySql::Db. |
|
Return names of tables in databases.
Implemented in Dv::MySql::Db. |
|
Return fields in table.
Implemented in Dv::MySql::Db. |
|
Set status.
Definition at line 183 of file sqldb.h. References ok_. |
|
Set error string returned by Dv::Sql::err().
Definition at line 185 of file sqldb.h. References err_. |
|
Set database name.
Definition at line 187 of file sqldb.h. References name_. |
|
Return dbms-specific command. Factory method; a concrete subclass X of Db implements this to return (a pointer to) an instance of the subclass of Command_ corresponding to X's Command_. |
|
Assignment is forbidden.
Reimplemented in Dv::MySql::Db. |
|
Friend.
|
|
Definition at line 208 of file sqldb.h. Referenced by host(). |
|
Definition at line 209 of file sqldb.h. Referenced by ok(), operator bool(), and operator!(). |
|
Definition at line 210 of file sqldb.h. Referenced by err(). |
|
Definition at line 211 of file sqldb.h. Referenced by log(). |
|
Name of database, may be "".
Definition at line 214 of file sqldb.h. Referenced by database(), and name(). |