00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #if !defined(MYSQLPP_OPTIONS_H)
00035 #define MYSQLPP_OPTIONS_H
00036
00037 #include "common.h"
00038
00039 #include <deque>
00040 #include <string>
00041
00042
00043 namespace mysqlpp {
00044
00045 #if !defined(DOXYGEN_IGNORE)
00046 class DBDriver;
00047 #endif
00048
00049
00051
00052
00057 class MYSQLPP_EXPORT Option
00058 {
00059 public:
00061 enum Error {
00062 err_NONE,
00063 err_api_limit,
00064 err_api_reject,
00065 err_connected
00066 };
00067
00068 virtual ~Option() { }
00069 virtual Error set(DBDriver* dbd) = 0;
00070 };
00071
00072
00075 template <typename T>
00076 class MYSQLPP_EXPORT DataOption : public Option
00077 {
00078 public:
00079 typedef T ArgType;
00080
00081 protected:
00082 DataOption(const T& arg) : arg_(arg) { }
00083 T arg_;
00084 };
00085
00086 typedef DataOption<unsigned> IntegerOption;
00087 typedef DataOption<bool> BooleanOption;
00088 typedef DataOption<std::string> StringOption;
00089
00090
00092 class MYSQLPP_EXPORT CompressOption : public Option
00093 {
00094 #if !defined(DOXYGEN_IGNORE)
00095 public:
00096 CompressOption() : Option() { }
00097
00098 private:
00099 Error set(DBDriver* dbd);
00100 #endif
00101 };
00102
00103
00105 class MYSQLPP_EXPORT ConnectTimeoutOption : public IntegerOption
00106 {
00107 #if !defined(DOXYGEN_IGNORE)
00108 public:
00109 ConnectTimeoutOption(ArgType arg) : IntegerOption(arg) { }
00110
00111 private:
00112 Error set(DBDriver* dbd);
00113 #endif
00114 };
00115
00116
00120 class MYSQLPP_EXPORT FoundRowsOption : public BooleanOption
00121 {
00122 #if !defined(DOXYGEN_IGNORE)
00123 public:
00124 FoundRowsOption(ArgType arg) : BooleanOption(arg) { }
00125
00126 private:
00127 Error set(DBDriver* dbd);
00128 #endif
00129 };
00130
00131
00136 class MYSQLPP_EXPORT GuessConnectionOption : public Option
00137 {
00138 #if !defined(DOXYGEN_IGNORE)
00139 public:
00140 GuessConnectionOption() : Option() { }
00141
00142 private:
00143 Error set(DBDriver* dbd);
00144 #endif
00145 };
00146
00147
00149 class MYSQLPP_EXPORT IgnoreSpaceOption : public BooleanOption
00150 {
00151 #if !defined(DOXYGEN_IGNORE)
00152 public:
00153 IgnoreSpaceOption(ArgType arg) : BooleanOption(arg) { }
00154
00155 private:
00156 Error set(DBDriver* dbd);
00157 #endif
00158 };
00159
00160
00162 class MYSQLPP_EXPORT InitCommandOption : public StringOption
00163 {
00164 #if !defined(DOXYGEN_IGNORE)
00165 public:
00166 InitCommandOption(ArgType arg) : StringOption(arg) { }
00167
00168 private:
00169 Error set(DBDriver* dbd);
00170 #endif
00171 };
00172
00173
00177 class MYSQLPP_EXPORT InteractiveOption : public BooleanOption
00178 {
00179 #if !defined(DOXYGEN_IGNORE)
00180 public:
00181 InteractiveOption(ArgType arg) : BooleanOption(arg) { }
00182
00183 private:
00184 Error set(DBDriver* dbd);
00185 #endif
00186 };
00187
00188
00190 class MYSQLPP_EXPORT LocalFilesOption : public BooleanOption
00191 {
00192 #if !defined(DOXYGEN_IGNORE)
00193 public:
00194 LocalFilesOption(ArgType arg) : BooleanOption(arg) { }
00195
00196 private:
00197 Error set(DBDriver* dbd);
00198 #endif
00199 };
00200
00201
00203 class MYSQLPP_EXPORT LocalInfileOption : public IntegerOption
00204 {
00205 #if !defined(DOXYGEN_IGNORE)
00206 public:
00207 LocalInfileOption(ArgType arg) : IntegerOption(arg) { }
00208
00209 private:
00210 Error set(DBDriver* dbd);
00211 #endif
00212 };
00213
00214
00216 class MYSQLPP_EXPORT MultiResultsOption : public BooleanOption
00217 {
00218 #if !defined(DOXYGEN_IGNORE)
00219 public:
00220 MultiResultsOption(ArgType arg) : BooleanOption(arg) { }
00221
00222 private:
00223 Error set(DBDriver* dbd);
00224 #endif
00225 };
00226
00227
00229 class MYSQLPP_EXPORT MultiStatementsOption : public BooleanOption
00230 {
00231 #if !defined(DOXYGEN_IGNORE)
00232 public:
00233 MultiStatementsOption(ArgType arg) : BooleanOption(arg) { }
00234
00235 private:
00236 Error set(DBDriver* dbd);
00237 #endif
00238 };
00239
00240
00242 class MYSQLPP_EXPORT NamedPipeOption : public Option
00243 {
00244 #if !defined(DOXYGEN_IGNORE)
00245 public:
00246 NamedPipeOption() : Option() { }
00247
00248 private:
00249 Error set(DBDriver* dbd);
00250 #endif
00251 };
00252
00253
00255 class MYSQLPP_EXPORT NoSchemaOption : public BooleanOption
00256 {
00257 #if !defined(DOXYGEN_IGNORE)
00258 public:
00259 NoSchemaOption(ArgType arg) : BooleanOption(arg) { }
00260
00261 private:
00262 Error set(DBDriver* dbd);
00263 #endif
00264 };
00265
00266
00268 class MYSQLPP_EXPORT ProtocolOption : public IntegerOption
00269 {
00270 #if !defined(DOXYGEN_IGNORE)
00271 public:
00272 ProtocolOption(ArgType arg) : IntegerOption(arg) { }
00273
00274 private:
00275 Error set(DBDriver* dbd);
00276 #endif
00277 };
00278
00279
00281 class MYSQLPP_EXPORT ReadDefaultFileOption : public StringOption
00282 {
00283 #if !defined(DOXYGEN_IGNORE)
00284 public:
00285 ReadDefaultFileOption(ArgType arg) : StringOption(arg) { }
00286
00287 private:
00288 Error set(DBDriver* dbd);
00289 #endif
00290 };
00291
00292
00294 class MYSQLPP_EXPORT ReadDefaultGroupOption : public StringOption
00295 {
00296 #if !defined(DOXYGEN_IGNORE)
00297 public:
00298 ReadDefaultGroupOption(ArgType arg) : StringOption(arg) { }
00299
00300 private:
00301 Error set(DBDriver* dbd);
00302 #endif
00303 };
00304
00305
00307 class MYSQLPP_EXPORT ReadTimeoutOption : public IntegerOption
00308 {
00309 #if !defined(DOXYGEN_IGNORE)
00310 public:
00311 ReadTimeoutOption(ArgType arg) : IntegerOption(arg) { }
00312
00313 private:
00314 Error set(DBDriver* dbd);
00315 #endif
00316 };
00317
00318
00320 class MYSQLPP_EXPORT ReconnectOption : public BooleanOption
00321 {
00322 #if !defined(DOXYGEN_IGNORE)
00323 public:
00324 ReconnectOption(ArgType arg) : BooleanOption(arg) { }
00325
00326 private:
00327 Error set(DBDriver* dbd);
00328 #endif
00329 };
00330
00331
00333 class MYSQLPP_EXPORT ReportDataTruncationOption : public BooleanOption
00334 {
00335 #if !defined(DOXYGEN_IGNORE)
00336 public:
00337 ReportDataTruncationOption(ArgType arg) : BooleanOption(arg) { }
00338
00339 private:
00340 Error set(DBDriver* dbd);
00341 #endif
00342 };
00343
00344
00347 class MYSQLPP_EXPORT SecureAuthOption : public BooleanOption
00348 {
00349 #if !defined(DOXYGEN_IGNORE)
00350 public:
00351 SecureAuthOption(ArgType arg) : BooleanOption(arg) { }
00352
00353 private:
00354 Error set(DBDriver* dbd);
00355 #endif
00356 };
00357
00358
00360 class MYSQLPP_EXPORT SetCharsetDirOption : public StringOption
00361 {
00362 #if !defined(DOXYGEN_IGNORE)
00363 public:
00364 SetCharsetDirOption(ArgType arg) : StringOption(arg) { }
00365
00366 private:
00367 Error set(DBDriver* dbd);
00368 #endif
00369 };
00370
00371
00373 class MYSQLPP_EXPORT SetCharsetNameOption : public StringOption
00374 {
00375 #if !defined(DOXYGEN_IGNORE)
00376 public:
00377 SetCharsetNameOption(ArgType arg) : StringOption(arg) { }
00378
00379 private:
00380 Error set(DBDriver* dbd);
00381 #endif
00382 };
00383
00384
00386 class MYSQLPP_EXPORT SetClientIpOption : public StringOption
00387 {
00388 #if !defined(DOXYGEN_IGNORE)
00389 public:
00390 SetClientIpOption(ArgType arg) : StringOption(arg) { }
00391
00392 private:
00393 Error set(DBDriver* dbd);
00394 #endif
00395 };
00396
00397
00399 class MYSQLPP_EXPORT SharedMemoryBaseNameOption : public StringOption
00400 {
00401 #if !defined(DOXYGEN_IGNORE)
00402 public:
00403 SharedMemoryBaseNameOption(ArgType arg) : StringOption(arg) { }
00404
00405 private:
00406 Error set(DBDriver* dbd);
00407 #endif
00408 };
00409
00410
00412 class MYSQLPP_EXPORT SslOption : public Option
00413 {
00414 public:
00427 SslOption(const char* key = 0, const char* cert = 0,
00428 const char* ca = 0, const char* capath = 0,
00429 const char* cipher = 0)
00430 {
00431 if (key) key_.assign(key);
00432 if (cert) cert_.assign(key);
00433 if (ca) ca_.assign(key);
00434 if (capath) capath_.assign(key);
00435 if (cipher) cipher_.assign(key);
00436 }
00437
00438 private:
00439 std::string key_, cert_, ca_, capath_, cipher_;
00440 Error set(DBDriver* dbd);
00441 };
00442
00443
00445 class MYSQLPP_EXPORT UseEmbeddedConnectionOption : public Option
00446 {
00447 #if !defined(DOXYGEN_IGNORE)
00448 public:
00449 UseEmbeddedConnectionOption() : Option() { }
00450
00451 private:
00452 Error set(DBDriver* dbd);
00453 #endif
00454 };
00455
00456
00458 class MYSQLPP_EXPORT UseRemoteConnectionOption : public Option
00459 {
00460 #if !defined(DOXYGEN_IGNORE)
00461 public:
00462 UseRemoteConnectionOption() : Option() { }
00463
00464 private:
00465 Error set(DBDriver* dbd);
00466 #endif
00467 };
00468
00469
00471 class MYSQLPP_EXPORT WriteTimeoutOption : public IntegerOption
00472 {
00473 #if !defined(DOXYGEN_IGNORE)
00474 public:
00475 WriteTimeoutOption(ArgType arg) : IntegerOption(arg) { }
00476
00477 private:
00478 Error set(DBDriver* dbd);
00479 #endif
00480 };
00481
00482
00484
00485
00487 typedef std::deque<Option*> OptionList;
00488
00490 typedef OptionList::const_iterator OptionListIt;
00491
00492 }
00493
00494 #endif // !defined(MYSQLPP_OPTIONS_H)