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 #ifndef MYSQLPP_ROW_H
00029 #define MYSQLPP_ROW_H
00030
00031 #include "coldata.h"
00032 #include "exceptions.h"
00033 #include "noexceptions.h"
00034 #include "resiter.h"
00035 #include "vallist.h"
00036
00037 #include <vector>
00038 #include <string>
00039
00040 #include <string.h>
00041
00042 namespace mysqlpp {
00043
00044 class FieldNames;
00045 class ResUse;
00046
00048 class Row :
00049 public const_subscript_container<Row, ColData, const ColData>,
00050 public OptionalExceptions
00051 {
00052 public:
00054 Row() :
00055 res_(0),
00056 initialized_(false)
00057 {
00058 }
00059
00066 MYSQLPP_EXPORT Row(const MYSQL_ROW& d, const ResUse* r,
00067 unsigned long* jj, bool te = true);
00068
00070 MYSQLPP_EXPORT ~Row();
00071
00073 const ResUse& parent() const
00074 {
00075 return *res_;
00076 }
00077
00079 MYSQLPP_EXPORT size_type size() const;
00080
00114 MYSQLPP_EXPORT const ColData operator [](const char* field) const;
00115
00126 const ColData operator [](size_type i) const
00127 {
00128 return at(i);
00129 }
00130
00138 MYSQLPP_EXPORT const ColData at(size_type i) const;
00139
00145 const char* raw_data(int i) const
00146 {
00147 return data_[i].data();
00148 }
00149
00151 operator bool() const
00152 {
00153 return data_.size();
00154 }
00155
00164 template <class Manip>
00165 value_list_ba<Row, Manip> value_list(const char* d = ",",
00166 Manip m = quote) const
00167 {
00168 return value_list_ba<Row, Manip>(*this, d, m);
00169 }
00170
00177 template <class Manip>
00178 value_list_b<Row, Manip> value_list(const char *d,
00179 const std::vector<bool>& vb, Manip m = quote) const
00180 {
00181 return value_list_b<Row, Manip>(*this, vb, d, m);
00182 }
00183
00191 value_list_b<Row, quote_type0> value_list(
00192 const std::vector<bool> &vb) const
00193 {
00194 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00195 }
00196
00203 template <class Manip>
00204 value_list_b<Row, Manip> value_list(const char *d, Manip m,
00205 bool t0, bool t1 = false, bool t2 = false, bool t3 = false,
00206 bool t4 = false, bool t5 = false, bool t6 = false,
00207 bool t7 = false, bool t8 = false, bool t9 = false,
00208 bool ta = false, bool tb = false, bool tc = false) const
00209 {
00210 std::vector<bool> vb;
00211 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00212 t7, t8, t9, ta, tb, tc);
00213 return value_list_b<Row, Manip>(*this, vb, d, m);
00214 }
00215
00222 value_list_b <Row, quote_type0>
00223 value_list(const char *d, bool t0, bool t1 = false, bool t2 = false,
00224 bool t3 = false, bool t4 = false, bool t5 = false,
00225 bool t6 = false, bool t7 = false, bool t8 = false,
00226 bool t9 = false, bool ta = false, bool tb = false,
00227 bool tc = false) const
00228 {
00229 std::vector<bool> vb;
00230 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00231 t7, t8, t9, ta, tb, tc);
00232 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00233 }
00234
00241 value_list_b<Row, quote_type0> value_list(bool t0,
00242 bool t1 = false, bool t2 = false, bool t3 = false,
00243 bool t4 = false, bool t5 = false, bool t6 = false,
00244 bool t7 = false, bool t8 = false, bool t9 = false,
00245 bool ta = false, bool tb = false, bool tc = false) const
00246 {
00247 std::vector<bool> vb;
00248 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00249 t7, t8, t9, ta, tb, tc);
00250 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00251 }
00252
00259 template <class Manip>
00260 value_list_b<Row, Manip> value_list(const char *d, Manip m,
00261 std::string s0, std::string s1 = "", std::string s2 = "",
00262 std::string s3 = "", std::string s4 = "",
00263 std::string s5 = "", std::string s6 = "",
00264 std::string s7 = "", std::string s8 = "",
00265 std::string s9 = "", std::string sa = "",
00266 std::string sb = "", std::string sc = "") const
00267 {
00268 std::vector<bool> vb;
00269 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00270 s9, sa, sb, sc);
00271 return value_list_b<Row, Manip>(*this, vb, d, m);
00272 }
00273
00280 value_list_b<Row, quote_type0> value_list(
00281 const char *d,
00282 std::string s0, std::string s1 = "", std::string s2 = "",
00283 std::string s3 = "", std::string s4 = "",
00284 std::string s5 = "", std::string s6 = "",
00285 std::string s7 = "", std::string s8 = "",
00286 std::string s9 = "", std::string sa = "",
00287 std::string sb = "", std::string sc = "") const
00288 {
00289 std::vector<bool> vb;
00290 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00291 s9, sa, sb, sc);
00292 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00293 }
00294
00301 value_list_b<Row, quote_type0> value_list(
00302 std::string s0,
00303 std::string s1 = "", std::string s2 = "",
00304 std::string s3 = "", std::string s4 = "",
00305 std::string s5 = "", std::string s6 = "",
00306 std::string s7 = "", std::string s8 = "",
00307 std::string s9 = "", std::string sa = "",
00308 std::string sb = "", std::string sc = "") const
00309 {
00310 std::vector<bool> vb;
00311 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00312 s9, sa, sb, sc);
00313 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00314 }
00315
00320 MYSQLPP_EXPORT value_list_ba<FieldNames, do_nothing_type0>
00321 field_list(const char* d = ",") const;
00322
00329 template <class Manip>
00330 value_list_ba<FieldNames, Manip> field_list(const char* d,
00331 Manip m) const;
00332
00341 template <class Manip>
00342 value_list_b<FieldNames, Manip> field_list(const char* d, Manip m,
00343 const std::vector<bool>& vb) const;
00344
00354 MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00355 const char* d, const std::vector<bool>& vb) const;
00356
00364 MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00365 const std::vector<bool>& vb) const;
00366
00374 template <class Manip>
00375 value_list_b<FieldNames, Manip> field_list(const char *d, Manip m,
00376 bool t0,
00377 bool t1 = false, bool t2 = false, bool t3 = false,
00378 bool t4 = false, bool t5 = false, bool t6 = false,
00379 bool t7 = false, bool t8 = false, bool t9 = false,
00380 bool ta = false, bool tb = false, bool tc = false) const;
00381
00389 MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00390 const char *d, bool t0,
00391 bool t1 = false, bool t2 = false, bool t3 = false,
00392 bool t4 = false, bool t5 = false, bool t6 = false,
00393 bool t7 = false, bool t8 = false, bool t9 = false,
00394 bool ta = false, bool tb = false, bool tc = false) const;
00395
00402 MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00403 bool t0,
00404 bool t1 = false, bool t2 = false, bool t3 = false,
00405 bool t4 = false, bool t5 = false, bool t6 = false,
00406 bool t7 = false, bool t8 = false, bool t9 = false,
00407 bool ta = false, bool tb = false, bool tc = false) const;
00408
00414 MYSQLPP_EXPORT equal_list_ba<FieldNames, Row, quote_type0>
00415 equal_list(const char* d = ",", const char* e = " = ") const;
00416
00437 template <class Manip>
00438 equal_list_ba<FieldNames, Row, Manip> equal_list(const char* d,
00439 const char* e, Manip m) const;
00440
00441 private:
00442 std::vector<std::string> data_;
00443 std::vector<bool> is_nulls_;
00444 const ResUse* res_;
00445 bool initialized_;
00446 };
00447
00448 }
00449
00450 #endif