-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmysql_c_api_foundation.h
More file actions
81 lines (55 loc) · 1.61 KB
/
Copy pathmysql_c_api_foundation.h
File metadata and controls
81 lines (55 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* mysql_c_api_foundation header file is a cplusplus header.
* it is to integrate with mysql c api easily
* it is just a wrapper of mysql c api mysql_real_connection functionalities.
* By WuyfCR7
*/
#ifndef _MYSQL_C_API_FOUNDATION_H_
#define _MYSQL_C_API_FOUNDATION_H_
#ifdef _MSC_VER > 1000
#pragma once
#endif
#include <mysql_c_api_error.h>
#include <boost\bind.hpp>
#include <boost\asio.hpp>
#include <boost\thread.hpp>
#include <boost\smart_ptr.hpp>
#include <boost\noncopyable.hpp>
class MySQLFoundationWrapper:public boost::noncopyable{
private:
/// wait timeout seconds, timer interval seconds
unsigned int timeout_seconds_;
long timer_interval_seconds_;
/// connection information
std::string host_;
std::string user_;
std::string password_;
unsigned int port_;
boost::asio::io_service service_;
boost::asio::deadline_timer timer_;
boost::shared_ptr<boost::thread> ios_running_thread_;
/// mysql
MYSQL mysql_;
char reconnect_value_;
/// connection information
bool disconnect_;
public:
bool is_connection_;
private:
MySQLErrInfo connect();
public:
// timeout_seconds_, timer_interval_seconds_, host_, user_, password_, port_
MySQLFoundationWrapper(unsigned int, long, std::string, std::string, std::string, unsigned int);
~MySQLFoundationWrapper();
MySQLErrInfo start();
void end();
void wait();
const char* getHost() const;
const char* getUser() const;
const char* getPassword() const;
unsigned int getPort() const;
MYSQL* getMySQL();
const MYSQL* getMySQL() const;
void ping_timer_callback(const boost::system::error_code&);
};
#endif