acl/lib_acl_cpp/include/acl_cpp/db/mysql_conf.hpp

156 lines
3.2 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
2015-08-12 16:48:24 +08:00
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
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
/**
* <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
/**
* <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
/**
* <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
/**
* <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
/**
* <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&}
*/
mysql_conf& set_dblimit(size_t dblimit);
2017-05-08 09:49:30 +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
/**
* <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
/**
* <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
/**
* <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 int {timeout}
* @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
/**
* <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&}
*/
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_;
}
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_;
}
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_;
}
const char* get_charset() const
{
return charset_;
}
2015-08-12 16:48:24 +08:00
private:
char* dbaddr_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
char* dbname_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
char* dbkey_; // dbname@dbaddr
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
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)