Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members

# row.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004 /***********************************************************************
    00005  Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
    00006  MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
    00007  Others may also hold copyrights on code in this file.  See the CREDITS
    00008  file in the top directory of the distribution for details.
    00009
    00010  This file is part of MySQL++.
    00011
    00012  MySQL++ is free software; you can redistribute it and/or modify it
    00013  under the terms of the GNU Lesser General Public License as published
    00014  by the Free Software Foundation; either version 2.1 of the License, or
    00015  (at your option) any later version.
    00016
    00017  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00018  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00019  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00020  License for more details.
    00021
    00022  You should have received a copy of the GNU Lesser General Public
    00023  License along with MySQL++; if not, write to the Free Software
    00024  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00025  USA
    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
    00119         MYSQLPP_EXPORT const ColData operator [](const char* field) const;
    00120
    00131         const ColData operator [](size_type i) const
    00132         {
    00133                 return at(i);
    00134         }
    00135
    00147         MYSQLPP_EXPORT const ColData at(size_type i) const;
    00148
    00154         const char* raw_data(int i) const
    00155         {
    00156                 return data_[i].data();
    00157         }
    00158
    00160         operator bool() const
    00161         {
    00162                 return data_.size();
    00163         }
    00164
    00173         template <class Manip>
    00174         value_list_ba<Row, Manip> value_list(const char* d = ",",
    00175                         Manip m = quote) const
    00176         {
    00177                 return value_list_ba<Row, Manip>(*this, d, m);
    00178         }
    00179
    00186         template <class Manip>
    00187         value_list_b<Row, Manip> value_list(const char *d,
    00188                         const std::vector<bool>& vb, Manip m = quote) const
    00189         {
    00190                 return value_list_b<Row, Manip>(*this, vb, d, m);
    00191         }
    00192
    00200         value_list_b<Row, quote_type0> value_list(
    00201                         const std::vector<bool> &vb) const
    00202         {
    00203                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
    00204         }
    00205
    00212         template <class Manip>
    00213         value_list_b<Row, Manip> value_list(const char *d, Manip m,
    00214                         bool t0, bool t1 = false, bool t2 = false, bool t3 = false,
    00215                         bool t4 = false, bool t5 = false, bool t6 = false,
    00216                         bool t7 = false, bool t8 = false, bool t9 = false,
    00217                         bool ta = false, bool tb = false, bool tc = false) const
    00218         {
    00219                 std::vector<bool> vb;
    00220                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
    00221                                 t7, t8, t9, ta, tb, tc);
    00222                 return value_list_b<Row, Manip>(*this, vb, d, m);
    00223         }
    00224
    00231         value_list_b <Row, quote_type0>
    00232         value_list(const char *d, bool t0, bool t1 = false, bool t2 = false,
    00233                         bool t3 = false, bool t4 = false, bool t5 = false,
    00234                         bool t6 = false, bool t7 = false, bool t8 = false,
    00235                         bool t9 = false, bool ta = false, bool tb = false,
    00236                         bool tc = false) const
    00237         {
    00238                 std::vector<bool> vb;
    00239                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
    00240                                 t7, t8, t9, ta, tb, tc);
    00241                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
    00242         }
    00243
    00250         value_list_b<Row, quote_type0> value_list(bool t0,
    00251                         bool t1 = false, bool t2 = false, bool t3 = false,
    00252                         bool t4 = false, bool t5 = false, bool t6 = false,
    00253                         bool t7 = false, bool t8 = false, bool t9 = false,
    00254                         bool ta = false, bool tb = false, bool tc = false) const
    00255         {
    00256                 std::vector<bool> vb;
    00257                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
    00258                                 t7, t8, t9, ta, tb, tc);
    00259                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
    00260         }
    00261
    00268         template <class Manip>
    00269         value_list_b<Row, Manip> value_list(const char *d, Manip m,
    00270                         std::string s0, std::string s1 = "", std::string s2 = "",
    00271                         std::string s3 = "", std::string s4 = "",
    00272                         std::string s5 = "", std::string s6 = "",
    00273                         std::string s7 = "", std::string s8 = "",
    00274                         std::string s9 = "", std::string sa = "",
    00275                         std::string sb = "", std::string sc = "") const
    00276         {
    00277                 std::vector<bool> vb;
    00278                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
    00279                                 s9, sa, sb, sc);
    00280                 return value_list_b<Row, Manip>(*this, vb, d, m);
    00281         }
    00282
    00289         value_list_b<Row, quote_type0> value_list(
    00290                         const char *d,
    00291                         std::string s0, std::string s1 = "", std::string s2 = "",
    00292                         std::string s3 = "", std::string s4 = "",
    00293                         std::string s5 = "", std::string s6 = "",
    00294                         std::string s7 = "", std::string s8 = "",
    00295                         std::string s9 = "", std::string sa = "",
    00296                         std::string sb = "", std::string sc = "") const
    00297         {
    00298                 std::vector<bool> vb;
    00299                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
    00300                                 s9, sa, sb, sc);
    00301                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
    00302         }
    00303
    00310         value_list_b<Row, quote_type0> value_list(
    00311                         std::string s0,
    00312                         std::string s1 = "", std::string s2 = "",
    00313                         std::string s3 = "", std::string s4 = "",
    00314                         std::string s5 = "", std::string s6 = "",
    00315                         std::string s7 = "", std::string s8 = "",
    00316                         std::string s9 = "", std::string sa = "",
    00317                         std::string sb = "", std::string sc = "") const
    00318         {
    00319                 std::vector<bool> vb;
    00320                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
    00321                                 s9, sa, sb, sc);
    00322                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
    00323         }
    00324
    00329         MYSQLPP_EXPORT value_list_ba<FieldNames, do_nothing_type0>
    00330                         field_list(const char* d = ",") const;
    00331
    00338         template <class Manip>
    00339         value_list_ba<FieldNames, Manip> field_list(const char* d,
    00340                         Manip m) const;
    00341
    00350         template <class Manip>
    00351         value_list_b<FieldNames, Manip> field_list(const char* d, Manip m,
    00352                         const std::vector<bool>& vb) const;
    00353
    00363         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
    00364                         const char* d, const std::vector<bool>& vb) const;
    00365
    00373         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
    00374                         const std::vector<bool>& vb) const;
    00375
    00383         template <class Manip>
    00384         value_list_b<FieldNames, Manip> field_list(const char *d, Manip m,
    00385                         bool t0,
    00386                         bool t1 = false, bool t2 = false, bool t3 = false,
    00387                         bool t4 = false, bool t5 = false, bool t6 = false,
    00388                         bool t7 = false, bool t8 = false, bool t9 = false,
    00389                         bool ta = false, bool tb = false, bool tc = false) const;
    00390
    00398         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
    00399                         const char *d, 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
    00411         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
    00412                         bool t0,
    00413                         bool t1 = false, bool t2 = false, bool t3 = false,
    00414                         bool t4 = false, bool t5 = false, bool t6 = false,
    00415                         bool t7 = false, bool t8 = false, bool t9 = false,
    00416                         bool ta = false, bool tb = false, bool tc = false) const;
    00417
    00423         MYSQLPP_EXPORT equal_list_ba<FieldNames, Row, quote_type0>
    00424                         equal_list(const char* d = ",", const char* e = " = ") const;
    00425
    00446         template <class Manip>
    00447         equal_list_ba<FieldNames, Row, Manip> equal_list(const char* d,
    00448                         const char* e, Manip m) const;
    00449
    00450 private:
    00451         std::vector<std::string> data_;
    00452         std::vector<bool> is_nulls_;
    00453         const ResUse* res_;
    00454         bool initialized_;
    00455 };
    00456
    00457 } // end namespace mysqlpp
    00458
    00459 #endif