libmysql_static_proxy.h
6.38 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MYSQL_LIBMYSQL_STATIC_H_
#define _MYSQL_LIBMYSQL_STATIC_H_
#include "mysql_client_api.h"
#include <cppconn/config.h>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
namespace sql
{
namespace mysql
{
namespace util
{
template <class T>
class Singleton: public boost::noncopyable
{
protected:
Singleton() {}
public:
static boost::shared_ptr<T> & theInstance() {
//shared::ptr is used only to be able to use in getCApiHandle
static boost::shared_ptr<T> instance(new T());
return instance;
}
};
// macros to use in private/protected part of singleton-ed class
#define CCPP_SINGLETON(classname) classname();\
friend class sql::mysql::util::Singleton<classname>
}
namespace NativeAPI
{
class LibmysqlStaticProxy : public IMySQLCAPI, public ::sql::mysql::util::Singleton< LibmysqlStaticProxy >
{
private:
CCPP_SINGLETON(LibmysqlStaticProxy);
public:
virtual ~LibmysqlStaticProxy();
// MySQL C-API calls wrappers
my_ulonglong affected_rows(MYSQL* mysql);
my_bool autocommit(MYSQL*, my_bool);
void close(MYSQL* mysql);
my_bool commit(MYSQL* mysql);
void data_seek(MYSQL_RES*, my_ulonglong);
void debug(const char*);
unsigned int mysql_errno(MYSQL* mysql);
const char* error(MYSQL* mysql);
MYSQL_FIELD* fetch_field(MYSQL_RES*);
MYSQL_FIELD* fetch_field_direct(MYSQL_RES*, unsigned int);
unsigned long* fetch_lengths(MYSQL_RES*);
MYSQL_ROW fetch_row(MYSQL_RES*);
unsigned int field_count(MYSQL* mysql);
void free_result(MYSQL_RES*);
unsigned long get_client_version();
const char* get_server_info(MYSQL* mysql);
unsigned long get_server_version(MYSQL* mysql);
MYSQL* init(MYSQL* mysql);
int library_init(int, char**, char**);
void library_end();
my_bool more_results(MYSQL* mysql);
int next_result(MYSQL* mysql);
unsigned int num_fields(MYSQL_RES*);
my_ulonglong num_rows(MYSQL_RES*);
int options(MYSQL*, enum mysql_option, const void*);
int ping(MYSQL*);
int query(MYSQL*, const char*);
MYSQL* real_connect(MYSQL* mysql,
const char* host,
const char* user,
const char* passwd,
const char* db,
unsigned int port,
const char* unix_socket,
unsigned long client_flag);
unsigned long real_escape_string(MYSQL* mysql, char* to, const char* from, unsigned long length);
int real_query(MYSQL*, const char*, unsigned long);
my_bool rollback(MYSQL* mysql);
const char* sqlstate(MYSQL* mysql);
my_bool ssl_set(MYSQL* mysql,
const char* key,
const char* cert,
const char* ca,
const char* capath,
const char* cipher);
MYSQL_RES* store_result(MYSQL* mysql);
MYSQL_RES* use_result(MYSQL* mysql);
// Prepared Statementstmt_* functions
my_ulonglong stmt_affected_rows(MYSQL_STMT*);
my_bool stmt_attr_set(MYSQL_STMT*, enum enum_stmt_attr_type, const void*);
my_bool stmt_bind_param(MYSQL_STMT*, MYSQL_BIND*);
my_bool stmt_bind_result(MYSQL_STMT*, MYSQL_BIND*);
my_bool stmt_close(MYSQL_STMT*);
void stmt_data_seek(MYSQL_STMT*, my_ulonglong);
unsigned int stmt_errno(MYSQL_STMT*);
const char* stmt_error(MYSQL_STMT*);
int stmt_execute(MYSQL_STMT*);
int stmt_fetch(MYSQL_STMT*);
unsigned int stmt_field_count(MYSQL_STMT*);
MYSQL_STMT* stmt_init(MYSQL* mysql);
my_ulonglong stmt_num_rows(MYSQL_STMT*);
unsigned long stmt_param_count(MYSQL_STMT*);
int stmt_prepare(MYSQL_STMT*, const char*, unsigned long);
MYSQL_RES* stmt_result_metadata(MYSQL_STMT*);
my_bool stmt_send_long_data(MYSQL_STMT*, unsigned int, const char*, unsigned long);
const char* stmt_sqlstate(MYSQL_STMT*);
int stmt_store_result(MYSQL_STMT*);
void thread_init();
void thread_end();
};
} // namespace NativeAPI
} // namespace mysql
} // namespace sql
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/