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 #if !defined(DOXYGEN_IGNORE)
00045
00046 class MYSQLPP_EXPORT FieldNames;
00047 class MYSQLPP_EXPORT ResUse;
00048 #endif
00049
00051 class MYSQLPP_EXPORT Row :
00052 public const_subscript_container<Row, ColData, const ColData>,
00053 public OptionalExceptions
00054 {
00055 public:
00057 Row() :
00058 res_(0),
00059 initialized_(false)
00060 {
00061 }
00062
00069 Row(const MYSQL_ROW& d, const ResUse* r,
00070 unsigned long* jj, bool te = true);
00071
00073 ~Row();
00074
00076 const ResUse& parent() const
00077 {
00078 return *res_;
00079 }
00080
00082 size_type size() const;
00083
00122 const ColData operator [](const char* field) const;
00123
00134 const ColData operator [](size_type i) const
00135 {
00136 return at(i);
00137 }
00138
00150 const ColData at(size_type i) const;
00151
00158 const char* raw_data(int i) const
00159 {
00160 return data_[i].data();
00161 }
00162
00168 const std::string& raw_string(int i) const
00169 {
00170 return data_.at(i);
00171 }
00172
00174 operator bool() const
00175 {
00176 return data_.size();
00177 }
00178
00187 template <class Manip>
00188 value_list_ba<Row, Manip> value_list(const char* d = ",",
00189 Manip m = quote) const
00190 {
00191 return value_list_ba<Row, Manip>(*this, d, m);
00192 }
00193
00200 template <class Manip>
00201 value_list_b<Row, Manip> value_list(const char *d,
00202 const std::vector<bool>& vb, Manip m = quote) const
00203 {
00204 return value_list_b<Row, Manip>(*this, vb, d, m);
00205 }
00206
00214 value_list_b<Row, quote_type0> value_list(
00215 const std::vector<bool> &vb) const
00216 {
00217 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00218 }
00219
00226 template <class Manip>
00227 value_list_b<Row, Manip> value_list(const char *d, Manip m,
00228 bool t0, bool t1 = false, bool t2 = false, bool t3 = false,
00229 bool t4 = false, bool t5 = false, bool t6 = false,
00230 bool t7 = false, bool t8 = false, bool t9 = false,
00231 bool ta = false, bool tb = false, bool tc = false) const
00232 {
00233 std::vector<bool> vb;
00234 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00235 t7, t8, t9, ta, tb, tc);
00236 return value_list_b<Row, Manip>(*this, vb, d, m);
00237 }
00238
00245 value_list_b <Row, quote_type0>
00246 value_list(const char *d, bool t0, bool t1 = false, bool t2 = false,
00247 bool t3 = false, bool t4 = false, bool t5 = false,
00248 bool t6 = false, bool t7 = false, bool t8 = false,
00249 bool t9 = false, bool ta = false, bool tb = false,
00250 bool tc = false) const
00251 {
00252 std::vector<bool> vb;
00253 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00254 t7, t8, t9, ta, tb, tc);
00255 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00256 }
00257
00264 value_list_b<Row, quote_type0> value_list(bool t0,
00265 bool t1 = false, bool t2 = false, bool t3 = false,
00266 bool t4 = false, bool t5 = false, bool t6 = false,
00267 bool t7 = false, bool t8 = false, bool t9 = false,
00268 bool ta = false, bool tb = false, bool tc = false) const
00269 {
00270 std::vector<bool> vb;
00271 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00272 t7, t8, t9, ta, tb, tc);
00273 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00274 }
00275
00282 template <class Manip>
00283 value_list_b<Row, Manip> value_list(const char *d, Manip m,
00284 std::string s0, std::string s1 = "", std::string s2 = "",
00285 std::string s3 = "", std::string s4 = "",
00286 std::string s5 = "", std::string s6 = "",
00287 std::string s7 = "", std::string s8 = "",
00288 std::string s9 = "", std::string sa = "",
00289 std::string sb = "", std::string sc = "") const
00290 {
00291 std::vector<bool> vb;
00292 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00293 s9, sa, sb, sc);
00294 return value_list_b<Row, Manip>(*this, vb, d, m);
00295 }
00296
00303 value_list_b<Row, quote_type0> value_list(
00304 const char *d,
00305 std::string s0, std::string s1 = "", std::string s2 = "",
00306 std::string s3 = "", std::string s4 = "",
00307 std::string s5 = "", std::string s6 = "",
00308 std::string s7 = "", std::string s8 = "",
00309 std::string s9 = "", std::string sa = "",
00310 std::string sb = "", std::string sc = "") const
00311 {
00312 std::vector<bool> vb;
00313 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00314 s9, sa, sb, sc);
00315 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00316 }
00317
00324 value_list_b<Row, quote_type0> value_list(
00325 std::string s0,
00326 std::string s1 = "", std::string s2 = "",
00327 std::string s3 = "", std::string s4 = "",
00328 std::string s5 = "", std::string s6 = "",
00329 std::string s7 = "", std::string s8 = "",
00330 std::string s9 = "", std::string sa = "",
00331 std::string sb = "", std::string sc = "") const
00332 {
00333 std::vector<bool> vb;
00334 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00335 s9, sa, sb, sc);
00336 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00337 }
00338
00343 value_list_ba<FieldNames, do_nothing_type0>
00344 field_list(const char* d = ",") const;
00345
00352 template <class Manip>
00353 value_list_ba<FieldNames, Manip> field_list(const char* d,
00354 Manip m) const;
00355
00364 template <class Manip>
00365 value_list_b<FieldNames, Manip> field_list(const char* d, Manip m,
00366 const std::vector<bool>& vb) const;
00367
00377 value_list_b<FieldNames, quote_type0> field_list(
00378 const char* d, const std::vector<bool>& vb) const;
00379
00387 value_list_b<FieldNames, quote_type0> field_list(
00388 const std::vector<bool>& vb) const;
00389
00397 template <class Manip>
00398 value_list_b<FieldNames, Manip> field_list(const char *d, Manip m,
00399 bool t0,
00400 bool t1 = false, bool t2 = false, bool t3 = false,
00401 bool t4 = false, bool t5 = false, bool t6 = false,
00402 bool t7 = false, bool t8 = false, bool t9 = false,
00403 bool ta = false, bool tb = false, bool tc = false) const;
00404
00412 value_list_b<FieldNames, quote_type0> field_list(
00413 const char *d, bool t0,
00414 bool t1 = false, bool t2 = false, bool t3 = false,
00415 bool t4 = false, bool t5 = false, bool t6 = false,
00416 bool t7 = false, bool t8 = false, bool t9 = false,
00417 bool ta = false, bool tb = false, bool tc = false) const;
00418
00425 value_list_b<FieldNames, quote_type0> field_list(
00426 bool t0,
00427 bool t1 = false, bool t2 = false, bool t3 = false,
00428 bool t4 = false, bool t5 = false, bool t6 = false,
00429 bool t7 = false, bool t8 = false, bool t9 = false,
00430 bool ta = false, bool tb = false, bool tc = false) const;
00431
00437 equal_list_ba<FieldNames, Row, quote_type0>
00438 equal_list(const char* d = ",", const char* e = " = ") const;
00439
00460 template <class Manip>
00461 equal_list_ba<FieldNames, Row, Manip> equal_list(const char* d,
00462 const char* e, Manip m) const;
00463
00464 private:
00465 std::vector<std::string> data_;
00466 std::vector<bool> is_nulls_;
00467 const ResUse* res_;
00468 bool initialized_;
00469 };
00470
00471 }
00472
00473 #endif