2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-08-12 16:48:24 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2015-08-12 16:48:24 +08:00
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API mysql_conf
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-05-08 09:49:30 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param dbaddr {const char*} <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ TCP <EFBFBD>ӿڻ<EFBFBD>
|
|
|
|
|
* UNIX <EFBFBD><EFBFBD><EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Ϊ TCP <EFBFBD>ӿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ʽΪ<EFBFBD><EFBFBD>ip:port, <EFBFBD><EFBFBD>Ϊ UNIX
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>/xxx/xxx/xxx.sock
|
|
|
|
|
* @param dbname {const char*} <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf(const char* dbaddr, const char* dbname);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param conf {const mysql_conf&} <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf(const mysql_conf& conf);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
2015-08-12 16:48:24 +08:00
|
|
|
|
~mysql_conf();
|
|
|
|
|
|
2017-05-08 09:49:30 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>˺<EFBFBD>
|
|
|
|
|
* @param dbuser {const char*} <EFBFBD><EFBFBD>Ϊ<EFBFBD>ǿ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ʱָ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>˺<EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf& set_dbuser(const char* dbuser);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param dbpass {const char*} <EFBFBD><EFBFBD>Ϊ<EFBFBD>ǿ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ʱָ<EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf& set_dbpass(const char* dbpass);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param dblimit {size_t} <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD>Ϊ 0 ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-14 17:28:30 +08:00
|
|
|
|
mysql_conf& set_dblimit(size_t dblimit);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> mysql <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @param dbflags {unsigned long}
|
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf& set_dbflags(unsigned long dbflags);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD>Զ<EFBFBD><EFBFBD>ύ
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @param on {bool}
|
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf& set_auto_commit(bool on);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>ij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @param timeout {int}
|
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf& set_conn_timeout(int timeout);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param timeout {int}
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-08-12 16:48:24 +08:00
|
|
|
|
mysql_conf& set_rw_timeout(int timeout);
|
2017-05-08 09:49:30 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
2017-05-08 09:49:30 +08:00
|
|
|
|
* @param charset {const char*}
|
|
|
|
|
* @return {mysql_conf&}
|
|
|
|
|
*/
|
2015-10-25 14:15:07 +08:00
|
|
|
|
mysql_conf& set_charset(const char* charset);
|
2015-08-12 16:48:24 +08:00
|
|
|
|
|
|
|
|
|
const char* get_dbaddr() const
|
|
|
|
|
{
|
|
|
|
|
return dbaddr_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* get_dbname() const
|
|
|
|
|
{
|
|
|
|
|
return dbname_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-25 14:15:07 +08:00
|
|
|
|
const char* get_dbkey() const
|
|
|
|
|
{
|
|
|
|
|
return dbkey_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-12 16:48:24 +08:00
|
|
|
|
const char* get_dbuser() const
|
|
|
|
|
{
|
|
|
|
|
return dbuser_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* get_dbpass() const
|
|
|
|
|
{
|
|
|
|
|
return dbpass_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-14 17:28:30 +08:00
|
|
|
|
size_t get_dblimit() const
|
2015-08-12 16:48:24 +08:00
|
|
|
|
{
|
|
|
|
|
return dblimit_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long get_dbflags() const
|
|
|
|
|
{
|
|
|
|
|
return dbflags_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool get_auto_commit() const
|
|
|
|
|
{
|
|
|
|
|
return auto_commit_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_conn_timeout() const
|
|
|
|
|
{
|
|
|
|
|
return conn_timeout_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_rw_timeout() const
|
|
|
|
|
{
|
|
|
|
|
return rw_timeout_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-25 14:15:07 +08:00
|
|
|
|
const char* get_charset() const
|
|
|
|
|
{
|
|
|
|
|
return charset_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-12 16:48:24 +08:00
|
|
|
|
private:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
char* dbaddr_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
char* dbname_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
2015-10-25 14:15:07 +08:00
|
|
|
|
char* dbkey_; // dbname@dbaddr
|
2019-07-28 10:31:56 +08:00
|
|
|
|
char* dbuser_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF>˺<EFBFBD>
|
|
|
|
|
char* dbpass_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char* charset_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
size_t dblimit_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
unsigned long dbflags_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʱ<EFBFBD>ı<EFBFBD>־λ
|
|
|
|
|
bool auto_commit_; // <20>Ƿ<EFBFBD><C7B7>Զ<EFBFBD><D4B6>ύ<EFBFBD>ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int conn_timeout_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ij<EFBFBD>ʱʱ<CAB1><CAB1>
|
|
|
|
|
int rw_timeout_; // <20><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ͨ<EFBFBD>ŵij<C5B5>ʱʱ<CAB1><CAB1>
|
2015-08-12 16:48:24 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
|