- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

options.h
Go to the documentation of this file.
1
11 /***********************************************************************
12 Copyright (c) 2007-2009 by Educational Technology Resources, Inc.
13 Others may also hold copyrights on code in this file. See the
14 CREDITS file in the top directory of the distribution for details.
15
16 This file is part of MySQL++.
17
18 MySQL++ is free software; you can redistribute it and/or modify it
19 under the terms of the GNU Lesser General Public License as published
20 by the Free Software Foundation; either version 2.1 of the License, or
21 (at your option) any later version.
22
23 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
24 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
26 License for more details.
27
28 You should have received a copy of the GNU Lesser General Public
29 License along with MySQL++; if not, write to the Free Software
30 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
31 USA
32 ***********************************************************************/
33
34 #if !defined(MYSQLPP_OPTIONS_H)
35 #define MYSQLPP_OPTIONS_H
36
37 #include "common.h"
38
39 #include <deque>
40 #include <string>
41
42
43 namespace mysqlpp {
44
45 #if !defined(DOXYGEN_IGNORE)
46 class DBDriver;
47 #endif
48
49
51 // Classes
52
57 class MYSQLPP_EXPORT Option
58 {
59 public:
61 enum Error {
62 err_NONE,
63 err_api_limit,
64 err_api_reject,
65 err_connected,
66 err_disconnected
67 };
68
69 virtual ~Option() { }
70 virtual Error set(DBDriver* dbd) = 0;
71 };
72
73
76 template <typename T>
77 class MYSQLPP_EXPORT DataOption : public Option
78 {
79 public:
80 typedef T ArgType;
81
82 protected:
83 DataOption(const T& arg) : arg_(arg) { }
84 T arg_;
85 };
86
87 typedef DataOption<unsigned> IntegerOption;
88 typedef DataOption<bool> BooleanOption;
89 typedef DataOption<std::string> StringOption;
90
91
93 class MYSQLPP_EXPORT CompressOption : public Option
94 {
95 #if !defined(DOXYGEN_IGNORE)
96 public:
97 CompressOption() : Option() { }
98
99 private:
100 Error set(DBDriver* dbd);
101 #endif
102 };
103
104
106 class MYSQLPP_EXPORT ConnectTimeoutOption : public IntegerOption
107 {
108 #if !defined(DOXYGEN_IGNORE)
109 public:
110 ConnectTimeoutOption(ArgType arg) : IntegerOption(arg) { }
111
112 private:
113 Error set(DBDriver* dbd);
114 #endif
115 };
116
117
121 class MYSQLPP_EXPORT FoundRowsOption : public BooleanOption
122 {
123 #if !defined(DOXYGEN_IGNORE)
124 public:
125 FoundRowsOption(ArgType arg) : BooleanOption(arg) { }
126
127 private:
128 Error set(DBDriver* dbd);
129 #endif
130 };
131
132
137 class MYSQLPP_EXPORT GuessConnectionOption : public Option
138 {
139 #if !defined(DOXYGEN_IGNORE)
140 public:
141 GuessConnectionOption() : Option() { }
142
143 private:
144 Error set(DBDriver* dbd);
145 #endif
146 };
147
148
150 class MYSQLPP_EXPORT IgnoreSpaceOption : public BooleanOption
151 {
152 #if !defined(DOXYGEN_IGNORE)
153 public:
154 IgnoreSpaceOption(ArgType arg) : BooleanOption(arg) { }
155
156 private:
157 Error set(DBDriver* dbd);
158 #endif
159 };
160
161
163 class MYSQLPP_EXPORT InitCommandOption : public StringOption
164 {
165 #if !defined(DOXYGEN_IGNORE)
166 public:
167 InitCommandOption(ArgType arg) : StringOption(arg) { }
168
169 private:
170 Error set(DBDriver* dbd);
171 #endif
172 };
173
174
178 class MYSQLPP_EXPORT InteractiveOption : public BooleanOption
179 {
180 #if !defined(DOXYGEN_IGNORE)
181 public:
182 InteractiveOption(ArgType arg) : BooleanOption(arg) { }
183
184 private:
185 Error set(DBDriver* dbd);
186 #endif
187 };
188
189
191 class MYSQLPP_EXPORT LocalFilesOption : public BooleanOption
192 {
193 #if !defined(DOXYGEN_IGNORE)
194 public:
195 LocalFilesOption(ArgType arg) : BooleanOption(arg) { }
196
197 private:
198 Error set(DBDriver* dbd);
199 #endif
200 };
201
202
204 class MYSQLPP_EXPORT LocalInfileOption : public IntegerOption
205 {
206 #if !defined(DOXYGEN_IGNORE)
207 public:
208 LocalInfileOption(ArgType arg) : IntegerOption(arg) { }
209
210 private:
211 Error set(DBDriver* dbd);
212 #endif
213 };
214
215
217 class MYSQLPP_EXPORT MultiResultsOption : public BooleanOption
218 {
219 #if !defined(DOXYGEN_IGNORE)
220 public:
221 MultiResultsOption(ArgType arg) : BooleanOption(arg) { }
222
223 private:
224 Error set(DBDriver* dbd);
225 #endif
226 };
227
228
230 class MYSQLPP_EXPORT MultiStatementsOption : public BooleanOption
231 {
232 #if !defined(DOXYGEN_IGNORE)
233 public:
234 MultiStatementsOption(ArgType arg) : BooleanOption(arg) { }
235
236 private:
237 Error set(DBDriver* dbd);
238 #endif
239 };
240
241
243 class MYSQLPP_EXPORT NamedPipeOption : public Option
244 {
245 #if !defined(DOXYGEN_IGNORE)
246 public:
247 NamedPipeOption() : Option() { }
248
249 private:
250 Error set(DBDriver* dbd);
251 #endif
252 };
253
254
256 class MYSQLPP_EXPORT NoSchemaOption : public BooleanOption
257 {
258 #if !defined(DOXYGEN_IGNORE)
259 public:
260 NoSchemaOption(ArgType arg) : BooleanOption(arg) { }
261
262 private:
263 Error set(DBDriver* dbd);
264 #endif
265 };
266
267
268 #if MYSQL_VERSION_ID > 40000 // only in 4.0 +
269 class MYSQLPP_EXPORT ProtocolOption : public IntegerOption
271 {
272 #if !defined(DOXYGEN_IGNORE)
273 public:
274 ProtocolOption(ArgType arg) : IntegerOption(arg) { }
275
276 private:
277 Error set(DBDriver* dbd);
278 #endif
279 };
280 #endif
281
282
284 class MYSQLPP_EXPORT ReadDefaultFileOption : public StringOption
285 {
286 #if !defined(DOXYGEN_IGNORE)
287 public:
288 ReadDefaultFileOption(ArgType arg) : StringOption(arg) { }
289
290 private:
291 Error set(DBDriver* dbd);
292 #endif
293 };
294
295
297 class MYSQLPP_EXPORT ReadDefaultGroupOption : public StringOption
298 {
299 #if !defined(DOXYGEN_IGNORE)
300 public:
301 ReadDefaultGroupOption(ArgType arg) : StringOption(arg) { }
302
303 private:
304 Error set(DBDriver* dbd);
305 #endif
306 };
307
308
310 class MYSQLPP_EXPORT ReadTimeoutOption : public IntegerOption
311 {
312 #if !defined(DOXYGEN_IGNORE)
313 public:
314 ReadTimeoutOption(ArgType arg) : IntegerOption(arg) { }
315
316 private:
317 Error set(DBDriver* dbd);
318 #endif
319 };
320
321
323 class MYSQLPP_EXPORT ReconnectOption : public BooleanOption
324 {
325 #if !defined(DOXYGEN_IGNORE)
326 public:
327 ReconnectOption(ArgType arg) : BooleanOption(arg) { }
328
329 private:
330 Error set(DBDriver* dbd);
331 #endif
332 };
333
334
336 class MYSQLPP_EXPORT ReportDataTruncationOption : public BooleanOption
337 {
338 #if !defined(DOXYGEN_IGNORE)
339 public:
340 ReportDataTruncationOption(ArgType arg) : BooleanOption(arg) { }
341
342 private:
343 Error set(DBDriver* dbd);
344 #endif
345 };
346
347
350 class MYSQLPP_EXPORT SecureAuthOption : public BooleanOption
351 {
352 #if !defined(DOXYGEN_IGNORE)
353 public:
354 SecureAuthOption(ArgType arg) : BooleanOption(arg) { }
355
356 private:
357 Error set(DBDriver* dbd);
358 #endif
359 };
360
361
363 class MYSQLPP_EXPORT SetCharsetDirOption : public StringOption
364 {
365 #if !defined(DOXYGEN_IGNORE)
366 public:
367 SetCharsetDirOption(ArgType arg) : StringOption(arg) { }
368
369 private:
370 Error set(DBDriver* dbd);
371 #endif
372 };
373
374
376 class MYSQLPP_EXPORT SetCharsetNameOption : public StringOption
377 {
378 #if !defined(DOXYGEN_IGNORE)
379 public:
380 SetCharsetNameOption(ArgType arg) : StringOption(arg) { }
381
382 private:
383 Error set(DBDriver* dbd);
384 #endif
385 };
386
387
389 class MYSQLPP_EXPORT SetClientIpOption : public StringOption
390 {
391 #if !defined(DOXYGEN_IGNORE)
392 public:
393 SetClientIpOption(ArgType arg) : StringOption(arg) { }
394
395 private:
396 Error set(DBDriver* dbd);
397 #endif
398 };
399
400
402 class MYSQLPP_EXPORT SharedMemoryBaseNameOption : public StringOption
403 {
404 #if !defined(DOXYGEN_IGNORE)
405 public:
406 SharedMemoryBaseNameOption(ArgType arg) : StringOption(arg) { }
407
408 private:
409 Error set(DBDriver* dbd);
410 #endif
411 };
412
413
415 class MYSQLPP_EXPORT SslOption : public Option
416 {
417 public:
430 SslOption(const char* key = 0, const char* cert = 0,
431 const char* ca = 0, const char* capath = 0,
432 const char* cipher = 0)
433 {
434 if (key) key_.assign(key);
435 if (cert) cert_.assign(cert);
436 if (ca) ca_.assign(ca);
437 if (capath) capath_.assign(capath);
438 if (cipher) cipher_.assign(cipher);
439 }
440
441 private:
442 std::string key_, cert_, ca_, capath_, cipher_;
443 Error set(DBDriver* dbd);
444 };
445
446
448 class MYSQLPP_EXPORT UseEmbeddedConnectionOption : public Option
449 {
450 #if !defined(DOXYGEN_IGNORE)
451 public:
452 UseEmbeddedConnectionOption() : Option() { }
453
454 private:
455 Error set(DBDriver* dbd);
456 #endif
457 };
458
459
461 class MYSQLPP_EXPORT UseRemoteConnectionOption : public Option
462 {
463 #if !defined(DOXYGEN_IGNORE)
464 public:
465 UseRemoteConnectionOption() : Option() { }
466
467 private:
468 Error set(DBDriver* dbd);
469 #endif
470 };
471
472
474 class MYSQLPP_EXPORT WriteTimeoutOption : public IntegerOption
475 {
476 #if !defined(DOXYGEN_IGNORE)
477 public:
478 WriteTimeoutOption(ArgType arg) : IntegerOption(arg) { }
479
480 private:
481 Error set(DBDriver* dbd);
482 #endif
483 };
484
485
487 // Typedefs
488
490 typedef std::deque<Option*> OptionList;
491
493 typedef OptionList::const_iterator OptionListIt;
494
495 } // end namespace mysqlpp
496
497 #endif // !defined(MYSQLPP_OPTIONS_H)
mysqlpp::UseRemoteConnectionOption
Connect to remote server in preference to embedded server.
Definition: options.h:461
mysqlpp::SslOption
Specialized option for handling SSL parameters.
Definition: options.h:415
mysqlpp::UseEmbeddedConnectionOption
Connect to embedded server in preference to remote server.
Definition: options.h:448
mysqlpp::SetCharsetNameOption
Give name of default charset.
Definition: options.h:376
mysqlpp::LocalFilesOption
Enable LOAD DATA LOCAL statement.
Definition: options.h:191
mysqlpp::Option::Error
Error
Types of option setting errors we can diagnose.
Definition: options.h:61
mysqlpp::Option::err_connected
can&#39;t set the given option while connected
Definition: options.h:65
mysqlpp::Option::~Option
virtual ~Option()
Destroy object.
Definition: options.h:69
mysqlpp::ReconnectOption
Enable automatic reconnection to server.
Definition: options.h:323
mysqlpp::DataOption::arg_
T arg_
The argument value.
Definition: options.h:84
mysqlpp::SslOption::SslOption
SslOption(const char *key=0, const char *cert=0, const char *ca=0, const char *capath=0, const char *cipher=0)
Create a set of SSL connection option parameters.
Definition: options.h:430
mysqlpp::SetClientIpOption
Fake client IP address when connecting to embedded server.
Definition: options.h:389
mysqlpp::LocalInfileOption
Enable LOAD LOCAL INFILE statement.
Definition: options.h:204
mysqlpp::SharedMemoryBaseNameOption
Set name of shmem segment for IPC.
Definition: options.h:402
mysqlpp::Option
Define abstract interface for all *Option subclasses.
Definition: options.h:57
mysqlpp::IgnoreSpaceOption
Allow spaces after function names in queries.
Definition: options.h:150
mysqlpp::NoSchemaOption
Disable db.tbl.col syntax in queries.
Definition: options.h:256
mysqlpp::DataOption::ArgType
T ArgType
Alias for template param.
Definition: options.h:80
mysqlpp::Option::err_NONE
option was set successfully
Definition: options.h:62
mysqlpp::GuessConnectionOption
Allow C API to guess what kind of connection to use.
Definition: options.h:137
mysqlpp::SecureAuthOption
Enforce use of secure authentication, refusing connection if not available.
Definition: options.h:350
mysqlpp::ConnectTimeoutOption
Change Connection::connect() default timeout.
Definition: options.h:106
mysqlpp::Option::err_api_reject
underlying C API returned error when setting option
Definition: options.h:64
mysqlpp::InteractiveOption
Assert that this is an interactive program.
Definition: options.h:178
mysqlpp::CompressOption
Enable data compression on the connection.
Definition: options.h:93
mysqlpp::Option::err_api_limit
option not supported by underlying C API
Definition: options.h:63
mysqlpp::ReadDefaultFileOption
Override use of my.cnf.
Definition: options.h:284
mysqlpp::FoundRowsOption
Make Query::affected_rows() return number of matched rows.
Definition: options.h:121
mysqlpp::MultiStatementsOption
Enable multiple queries in a request to the server.
Definition: options.h:230
mysqlpp::InitCommandOption
Give SQL executed on connect.
Definition: options.h:163
common.h
This file includes top-level definitions for use both internal to the library, and outside it...
mysqlpp::ReportDataTruncationOption
Set reporting of data truncation errors.
Definition: options.h:336
mysqlpp::SetCharsetDirOption
Give path to charset definition files.
Definition: options.h:363
mysqlpp::NamedPipeOption
Suggest use of named pipes.
Definition: options.h:243
mysqlpp::ReadDefaultGroupOption
Override use of my.cnf.
Definition: options.h:297
mysqlpp::WriteTimeoutOption
Set timeout for IPC data reads.
Definition: options.h:474
mysqlpp::DataOption
Define abstract interface for all *Options that take a lone scalar as an argument.
Definition: options.h:77
mysqlpp::MultiResultsOption
Enable multiple result sets in a reply.
Definition: options.h:217
mysqlpp::DBDriver
Provides a thin abstraction layer over the underlying database client library.
Definition: dbdriver.h:57
mysqlpp::ReadTimeoutOption
Set timeout for IPC data reads.
Definition: options.h:310
mysqlpp::DataOption::DataOption
DataOption(const T &arg)
Construct object.
Definition: options.h:83