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
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef MYSQLPP_MANIP_H
00043 #define MYSQLPP_MANIP_H
00044
00045 #include "defs.h"
00046
00047 #include "datetime.h"
00048 #include "myset.h"
00049 #include "sql_string.h"
00050
00051 #include <mysql.h>
00052
00053 #include <iostream>
00054
00058 namespace mysqlpp {
00059
00060 class Query;
00061
00062 extern bool dont_quote_auto;
00063
00064
00073
00074
00075 enum quote_type0
00076 {
00077 quote
00078 };
00079
00080
00081 #if !defined(DOXYGEN_IGNORE)
00082
00083
00084 struct quote_type1
00085 {
00086 std::ostream * ostr;
00087 quote_type1(std::ostream * o) :
00088 ostr(o)
00089 {
00090 }
00091 };
00092
00093
00094 MYSQLPP_EXPORT inline quote_type1 operator <<(std::ostream& o,
00095 quote_type0 )
00096 {
00097 return quote_type1(&o);
00098 }
00099
00100
00101 class SQLQueryParms;
00102 struct quote_type2
00103 {
00104 SQLQueryParms *qparms;
00105 quote_type2(SQLQueryParms* p) :
00106 qparms(p)
00107 {
00108 }
00109 };
00110
00111
00112 MYSQLPP_EXPORT inline quote_type2 operator <<(SQLQueryParms& p,
00113 quote_type0 )
00114 {
00115 return quote_type2(&p);
00116 }
00117
00118
00119 MYSQLPP_EXPORT SQLQueryParms& operator <<(quote_type2 p,
00120 SQLString& in);
00121
00122
00123 template <class T>
00124 inline std::ostream& operator <<(quote_type1 o, const T & in)
00125 {
00126 return *o.ostr << in;
00127 }
00128
00129
00130 MYSQLPP_EXPORT std::ostream& operator <<(std::ostream& o,
00131 const ColData_Tmpl<std::string>& in);
00132
00133
00134 MYSQLPP_EXPORT std::ostream& operator <<(std::ostream& o,
00135 const ColData_Tmpl<const_string>& in);
00136
00137
00138 MYSQLPP_EXPORT Query& operator <<(Query& o,
00139 const ColData_Tmpl<std::string>& in);
00140
00141
00142 MYSQLPP_EXPORT Query& operator <<(Query& o,
00143 const ColData_Tmpl<const_string>& in);
00144
00145
00146 template <>
00147 MYSQLPP_EXPORT std::ostream& operator <<(quote_type1 o,
00148 const std::string& in);
00149
00150
00151 template <>
00152 MYSQLPP_EXPORT std::ostream& operator <<(quote_type1 o,
00153 const char* const& in);
00154
00155
00156 template <>
00157 MYSQLPP_EXPORT std::ostream& operator <<(quote_type1 o,
00158 const ColData_Tmpl<std::string>& in);
00159
00160
00161 template <>
00162 MYSQLPP_EXPORT std::ostream& operator <<(quote_type1 o,
00163 const ColData_Tmpl<const_string>& in);
00164
00165
00166 template <>
00167 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_type1 o,
00168 char* const& in)
00169 {
00170 return operator <<(o, const_cast<const char* const&>(in));
00171 }
00172
00173
00174 template <>
00175 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_type1 o,
00176 const Date& in)
00177 {
00178 return *o.ostr << '\'' << in << '\'';
00179 }
00180
00181
00182 template <>
00183 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_type1 o,
00184 const Time& in)
00185 {
00186 return *o.ostr << '\'' << in << '\'';
00187 }
00188
00189
00190 template <>
00191 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_type1 o,
00192 const DateTime& in)
00193 {
00194 return *o.ostr << '\'' << in << '\'';
00195 }
00196
00197
00198 template <class ST>
00199 inline std::ostream& operator <<(quote_type1 o, const Set<ST>& in)
00200 {
00201 return *o.ostr << '\'' << in << '\'';
00202 }
00203
00204 #endif // !defined(DOXYGEN_IGNORE)
00205
00206
00214
00215 enum quote_only_type0
00216 {
00217 quote_only
00218 };
00219
00220
00221 #if !defined(DOXYGEN_IGNORE)
00222
00223
00224 struct quote_only_type1
00225 {
00226 std::ostream* ostr;
00227 quote_only_type1(std::ostream* o) :
00228 ostr(o)
00229 {
00230 }
00231 };
00232
00233
00234 MYSQLPP_EXPORT inline quote_only_type1 operator <<(std::ostream& o,
00235 quote_only_type0 )
00236 {
00237 return quote_only_type1(&o);
00238 }
00239
00240
00241 struct quote_only_type2
00242 {
00243 SQLQueryParms* qparms;
00244 quote_only_type2(SQLQueryParms* p) :
00245 qparms(p)
00246 {
00247 }
00248 };
00249
00250
00251 MYSQLPP_EXPORT inline quote_only_type2 operator <<(SQLQueryParms& p,
00252 quote_only_type0 )
00253 {
00254 return quote_only_type2(&p);
00255 }
00256
00257 MYSQLPP_EXPORT SQLQueryParms& operator <<(quote_only_type2 p,
00258 SQLString& in);
00259
00260
00261 template <class T>
00262 inline std::ostream& operator <<(quote_only_type1 o, const T& in)
00263 {
00264 return *o.ostr << in;
00265 }
00266
00267
00268 template <>
00269 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_only_type1 o,
00270 const std::string& in)
00271 {
00272 return *o.ostr << '\'' << in << '\'';
00273 }
00274
00275
00276 template <>
00277 MYSQLPP_EXPORT std::ostream& operator <<(quote_only_type1 o,
00278 const ColData_Tmpl<std::string>& in);
00279
00280
00281 template <>
00282 MYSQLPP_EXPORT std::ostream& operator <<(quote_only_type1 o,
00283 const ColData_Tmpl<const_string>& in);
00284
00285
00286 template <>
00287 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_only_type1 o,
00288 const Date& in)
00289 {
00290 return *o.ostr << '\'' << in << '\'';
00291 }
00292
00293
00294 template <>
00295 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_only_type1 o,
00296 const Time& in)
00297 {
00298 return *o.ostr << '\'' << in << '\'';
00299 }
00300
00301
00302 template <>
00303 MYSQLPP_EXPORT inline std::ostream& operator <<(quote_only_type1 o,
00304 const DateTime& in)
00305 {
00306 return *o.ostr << '\'' << in << '\'';
00307 }
00308
00309
00310 template <class ST>
00311 inline std::ostream& operator <<(quote_only_type1 o, const Set<ST>& in)
00312 {
00313 return *o.ostr << '\'' << in << '\'';
00314 }
00315
00316 #endif // !defined(DOXYGEN_IGNORE)
00317
00318
00326
00327 enum quote_double_only_type0
00328 {
00329 quote_double_only
00330 };
00331
00332
00333 #if !defined(DOXYGEN_IGNORE)
00334
00335
00336 struct quote_double_only_type1
00337 {
00338 std::ostream* ostr;
00339 quote_double_only_type1(std::ostream* o) :
00340 ostr(o)
00341 {
00342 }
00343 };
00344
00345
00346 MYSQLPP_EXPORT inline quote_double_only_type1 operator <<(
00347 std::ostream& o, quote_double_only_type0 )
00348 {
00349 return quote_double_only_type1(&o);
00350 }
00351
00352
00353 struct quote_double_only_type2
00354 {
00355 SQLQueryParms *qparms;
00356 quote_double_only_type2(SQLQueryParms* p) :
00357 qparms(p)
00358 {
00359 }
00360 };
00361
00362
00363 MYSQLPP_EXPORT inline quote_double_only_type2 operator <<(
00364 SQLQueryParms& p, quote_double_only_type0 )
00365 {
00366 return quote_double_only_type2(&p);
00367 }
00368
00369
00370 MYSQLPP_EXPORT SQLQueryParms& operator <<(quote_double_only_type2 p,
00371 SQLString& in);
00372
00373
00374 template <class T>
00375 inline std::ostream& operator <<(quote_double_only_type1 o, const T& in)
00376 {
00377 return *o.ostr << in;
00378 }
00379
00380
00381 template <>
00382 MYSQLPP_EXPORT inline std::ostream& operator <<(
00383 quote_double_only_type1 o, const std::string& in)
00384 {
00385 return *o.ostr << '"' << in << '"';
00386 }
00387
00388
00389 template <>
00390 MYSQLPP_EXPORT std::ostream& operator <<(quote_double_only_type1 o,
00391 const ColData_Tmpl<std::string>& in);
00392
00393
00394 template <>
00395 MYSQLPP_EXPORT std::ostream & operator <<(quote_double_only_type1 o,
00396 const ColData_Tmpl<const_string>& in);
00397
00398
00399 template <>
00400 MYSQLPP_EXPORT inline std::ostream& operator <<(
00401 quote_double_only_type1 o, const Date& in)
00402 {
00403 return *o.ostr << '"' << in << '"';
00404 }
00405
00406
00407 template <>
00408 MYSQLPP_EXPORT inline std::ostream& operator <<(
00409 quote_double_only_type1 o, const Time& in)
00410 {
00411 return *o.ostr << '"' << in << '"';
00412 }
00413
00414
00415 template <>
00416 MYSQLPP_EXPORT inline std::ostream& operator <<(
00417 quote_double_only_type1 o, const DateTime& in)
00418 {
00419 return *o.ostr << '"' << in << '"';
00420 }
00421
00422
00423 template <class ST>
00424 inline std::ostream& operator <<(quote_double_only_type1 o,
00425 const Set<ST>& in)
00426 {
00427 return *o.ostr << '"' << in << '"';
00428 }
00429
00430 #endif // !defined(DOXYGEN_IGNORE)
00431
00432
00439
00440 enum escape_type0 { escape };
00441
00442
00443 #if !defined(DOXYGEN_IGNORE)
00444
00445
00446 struct escape_type1
00447 {
00448 std::ostream* ostr;
00449 escape_type1(std::ostream* o) :
00450 ostr(o)
00451 {
00452 }
00453 };
00454
00455
00456 MYSQLPP_EXPORT inline escape_type1 operator <<(std::ostream& o,
00457 escape_type0 )
00458 {
00459 return escape_type1(&o);
00460 }
00461
00462
00463 struct escape_type2
00464 {
00465 SQLQueryParms *qparms;
00466 escape_type2(SQLQueryParms* p) :
00467 qparms(p)
00468 {
00469 }
00470 };
00471
00472
00473 MYSQLPP_EXPORT inline escape_type2 operator <<(SQLQueryParms& p,
00474 escape_type0 )
00475 {
00476 return escape_type2(&p);
00477 }
00478
00479 #endif // !defined(DOXYGEN_IGNORE)
00480
00481
00488
00489 MYSQLPP_EXPORT SQLQueryParms& operator <<(escape_type2 p,
00490 SQLString& in);
00491
00492
00501
00502 template <class T>
00503 inline std::ostream& operator <<(escape_type1 o, const T& in)
00504 {
00505 return *o.ostr << in;
00506 }
00507
00508
00509 template <>
00510 MYSQLPP_EXPORT std::ostream& operator <<(escape_type1 o,
00511 const std::string& in);
00512
00513
00514 template <>
00515 MYSQLPP_EXPORT std::ostream& operator <<(escape_type1 o,
00516 const char* const& in);
00517
00518
00519 template <>
00520 MYSQLPP_EXPORT std::ostream& operator <<(escape_type1 o,
00521 const ColData_Tmpl<std::string>& in);
00522
00523
00524 template <>
00525 MYSQLPP_EXPORT std::ostream& operator <<(escape_type1 o,
00526 const ColData_Tmpl<const_string>& in);
00527
00528
00535
00536 template <>
00537 MYSQLPP_EXPORT inline std::ostream& operator <<(escape_type1 o,
00538 char* const& in)
00539 {
00540 return operator <<(o, const_cast<const char* const&>(in));
00541 }
00542
00543
00554
00555 enum do_nothing_type0
00556 {
00557 do_nothing
00558 };
00559
00560
00561 #if !defined(DOXYGEN_IGNORE)
00562
00563
00564 struct do_nothing_type1
00565 {
00566 std::ostream* ostr;
00567 do_nothing_type1(std::ostream* o) :
00568 ostr(o)
00569 {
00570 }
00571 };
00572
00573
00574 MYSQLPP_EXPORT inline do_nothing_type1 operator <<(std::ostream& o,
00575 do_nothing_type0 )
00576 {
00577 return do_nothing_type1(&o);
00578 }
00579
00580
00581 template <class T>
00582 inline std::ostream& operator <<(do_nothing_type1 o, const T& in)
00583 {
00584 return *o.ostr << in;
00585 }
00586
00587
00588 struct do_nothing_type2
00589 {
00590 SQLQueryParms *qparms;
00591 do_nothing_type2(SQLQueryParms* p) :
00592 qparms(p)
00593 {
00594 }
00595 };
00596
00597
00598 MYSQLPP_EXPORT inline do_nothing_type2 operator <<(SQLQueryParms& p,
00599 do_nothing_type0 )
00600 {
00601 return do_nothing_type2(&p);
00602 }
00603
00604
00605 MYSQLPP_EXPORT SQLQueryParms& operator <<(do_nothing_type2 p,
00606 SQLString& in);
00607
00608 #endif // !defined(DOXYGEN_IGNORE)
00609
00610
00620
00621 enum ignore_type0
00622 {
00623 ignore
00624 };
00625
00626
00627 #if !defined(DOXYGEN_IGNORE)
00628
00629
00630 struct ignore_type2
00631 {
00632 SQLQueryParms* qparms;
00633 ignore_type2(SQLQueryParms* p) :
00634 qparms(p)
00635 {
00636 }
00637 };
00638
00639
00640 MYSQLPP_EXPORT inline ignore_type2 operator <<(SQLQueryParms& p,
00641 ignore_type0 )
00642 {
00643 return ignore_type2(&p);
00644 }
00645
00646
00647 MYSQLPP_EXPORT SQLQueryParms& operator <<(ignore_type2 p,
00648 SQLString& in);
00649
00650 #endif // !defined(DOXYGEN_IGNORE)
00651
00652 }
00653
00654 #endif