connection.h

来自「天之炼狱1服务器端源文件游戏服务端不完整」· C头文件 代码 · 共 128 行

H
128
字号
////////////////////////////////////////////////////////////////////////// File Name 	: Connection.h// Written by	: Gday29@ewestsoft.com// Description	: 单捞鸥海捞胶客狼 楷搬阑 淬寸窍绰 努贰胶////////////////////////////////////////////////////////////////////////#ifndef __CONNECTION_H__#define __CONNECTION_H__// include files#include "Types.h"#include "Exception.h"#include <mysql/mysql.h>#include "Mutex.h"// forward declarationclass Statement;////////////////////////////////////////////////////////////////////////// class Connection;//// 单捞磐 海捞胶俊 楷搬窍绊, 包府茄促.////////////////////////////////////////////////////////////////////////class Connection {public:		// constructor    Connection() throw(Error);	// constructor(1-time connection)    Connection(string host, string db, string user, string password, uint port = 0) throw(SQLConnectException, Error);    	// destructor	~Connection() throw(Error);    // close the connection to database	void close() throw(SQLConnectException, Error);		// 单捞鸥海捞胶俊 楷搬阑 矫档茄促.	void connect(string host, string db, string user, string password, uint port = 0) throw(SQLConnectException);	// 单捞鸥海捞胶俊 楷搬阑 矫档茄促.	void connect() throw(SQLConnectException);		// check the connection 	bool isConnected() const throw() { return m_bConnected; }	bool operator !() const throw() { return m_bConnected == false; }		// Statement 按眉甫 积己秦辑 府畔茄促.	Statement * createStatement() throw();			// get the MYSQL object	MYSQL * getMYSQL() throw() { return &m_Mysql; }		// get MS's host name(ip)	string getHost() const throw() { return m_Host; }	// get MS's service port	uint getPort() const throw() { return m_Port; }	// get database name	string getDatabase() const throw() { return m_Database; }	// get user id 	string getUser() const throw() { return m_User; }	// get user password	string getPassword() const throw() { return m_Password; }	// get connection's name	string getName() const throw() { return m_Name; }	// set connection's name	void setName(string name) throw() { m_Name = name; }	// get/set busy status	bool isBusy(void) const throw() { return m_bBusy;}	void setBusy(bool busy=true) throw() { m_bBusy = busy;}	// get error	string getError() throw() { return mysql_error(&m_Mysql); }	// lock/unlock	void lock() throw(Error) { m_Mutex.lock(); }	void unlock() throw(Error) { m_Mutex.unlock(); }	private:		// ??    MYSQL m_Mysql;	// is connected?	bool m_bConnected;	// DBMS 啊 款康登绰 龋胶飘 疙	string m_Host;	// DBMS 狼 楷搬 器飘	uint m_Port;	// 单捞鸥海捞胶 捞抚	string m_Database;	// 荤侩磊 酒捞叼	string m_User;	// 荤侩磊 菩胶况靛	string m_Password;	// connection name(DatabaseManager 俊辑 荤侩且 虐蔼)	string m_Name;	// 泅犁 荤侩吝牢 目池记牢啊?	bool m_bBusy;	// 悼矫 孽府甫 阜扁 困茄 lock	Mutex m_Mutex;};#endif // __CONNECTION_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?