Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File 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 
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 
00136         MYSQLPP_EXPORT const ColData at(size_type i) const;
00137 
00143         const char* raw_data(int i) const
00144         {
00145                 return data_[i].data();
00146         }
00147 
00149         operator bool() const
00150         {
00151                 return data_.size();
00152         }
00153 
00162         template <class Manip>
00163         value_list_ba<Row, Manip> value_list(const char* d = ",",
00164                         Manip m = quote) const
00165         {
00166                 return value_list_ba<Row, Manip>(*this, d, m);
00167         }
00168         
00175         template <class Manip>
00176         value_list_b<Row, Manip> value_list(const char *d,
00177                         const std::vector<bool>& vb, Manip m = quote) const
00178         {
00179                 return value_list_b<Row, Manip>(*this, vb, d, m);
00180         }
00181         
00189         value_list_b<Row, quote_type0> value_list(
00190                         const std::vector<bool> &vb) const
00191         {
00192                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00193         }
00194         
00201         template <class Manip>
00202         value_list_b<Row, Manip> value_list(const char *d, Manip m,
00203                         bool t0, bool t1 = false, bool t2 = false, bool t3 = false,
00204                         bool t4 = false, bool t5 = false, bool t6 = false,
00205                         bool t7 = false, bool t8 = false, bool t9 = false,
00206                         bool ta = false, bool tb = false, bool tc = false) const
00207         {
00208                 std::vector<bool> vb;
00209                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00210                                 t7, t8, t9, ta, tb, tc);
00211                 return value_list_b<Row, Manip>(*this, vb, d, m);
00212         }
00213         
00220         value_list_b <Row, quote_type0>
00221         value_list(const char *d, bool t0, bool t1 = false, bool t2 = false,
00222                         bool t3 = false, bool t4 = false, bool t5 = false,
00223                         bool t6 = false, bool t7 = false, bool t8 = false,
00224                         bool t9 = false, bool ta = false, bool tb = false,
00225                         bool tc = false) const
00226         {
00227                 std::vector<bool> vb;
00228                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00229                                 t7, t8, t9, ta, tb, tc);
00230                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00231         }
00232         
00239         value_list_b<Row, quote_type0> value_list(bool t0,
00240                         bool t1 = false, bool t2 = false, bool t3 = false,
00241                         bool t4 = false, bool t5 = false, bool t6 = false,
00242                         bool t7 = false, bool t8 = false, bool t9 = false,
00243                         bool ta = false, bool tb = false, bool tc = false) const
00244         {
00245                 std::vector<bool> vb;
00246                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00247                                 t7, t8, t9, ta, tb, tc);
00248                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00249         }
00250         
00257         template <class Manip>
00258         value_list_b<Row, Manip> value_list(const char *d, Manip m,
00259                         std::string s0, std::string s1 = "", std::string s2 = "",
00260                         std::string s3 = "", std::string s4 = "",
00261                         std::string s5 = "", std::string s6 = "",
00262                         std::string s7 = "", std::string s8 = "",
00263                         std::string s9 = "", std::string sa = "",
00264                         std::string sb = "", std::string sc = "") const
00265         {
00266                 std::vector<bool> vb;
00267                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00268                                 s9, sa, sb, sc);
00269                 return value_list_b<Row, Manip>(*this, vb, d, m);
00270         }
00271         
00278         value_list_b<Row, quote_type0> value_list(
00279                         const char *d,
00280                         std::string s0, std::string s1 = "", std::string s2 = "",
00281                         std::string s3 = "", std::string s4 = "",
00282                         std::string s5 = "", std::string s6 = "",
00283                         std::string s7 = "", std::string s8 = "",
00284                         std::string s9 = "", std::string sa = "",
00285                         std::string sb = "", std::string sc = "") const
00286         {
00287                 std::vector<bool> vb;
00288                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00289                                 s9, sa, sb, sc);
00290                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00291         }
00292         
00299         value_list_b<Row, quote_type0> value_list(
00300                         std::string s0,
00301                         std::string s1 = "", std::string s2 = "",
00302                         std::string s3 = "", std::string s4 = "",
00303                         std::string s5 = "", std::string s6 = "",
00304                         std::string s7 = "", std::string s8 = "",
00305                         std::string s9 = "", std::string sa = "",
00306                         std::string sb = "", std::string sc = "") const
00307         {
00308                 std::vector<bool> vb;
00309                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00310                                 s9, sa, sb, sc);
00311                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00312         }
00313 
00318         MYSQLPP_EXPORT value_list_ba<FieldNames, do_nothing_type0>
00319                         field_list(const char* d = ",") const;
00320 
00327         template <class Manip>
00328         value_list_ba<FieldNames, Manip> field_list(const char* d,
00329                         Manip m) const;
00330 
00339         template <class Manip>
00340         value_list_b<FieldNames, Manip> field_list(const char* d, Manip m,
00341                         const std::vector<bool>& vb) const;
00342 
00352         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00353                         const char* d, const std::vector<bool>& vb) const;
00354 
00362         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00363                         const std::vector<bool>& vb) const;
00364 
00372         template <class Manip>
00373         value_list_b<FieldNames, Manip> field_list(const char *d, Manip m,
00374                         bool t0,
00375                         bool t1 = false, bool t2 = false, bool t3 = false,
00376                         bool t4 = false, bool t5 = false, bool t6 = false,
00377                         bool t7 = false, bool t8 = false, bool t9 = false,
00378                         bool ta = false, bool tb = false, bool tc = false) const;
00379 
00387         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00388                         const char *d, bool t0,
00389                         bool t1 = false, bool t2 = false, bool t3 = false,
00390                         bool t4 = false, bool t5 = false, bool t6 = false,
00391                         bool t7 = false, bool t8 = false, bool t9 = false,
00392                         bool ta = false, bool tb = false, bool tc = false) const;
00393 
00400         MYSQLPP_EXPORT value_list_b<FieldNames, quote_type0> field_list(
00401                         bool t0,
00402                         bool t1 = false, bool t2 = false, bool t3 = false,
00403                         bool t4 = false, bool t5 = false, bool t6 = false,
00404                         bool t7 = false, bool t8 = false, bool t9 = false,
00405                         bool ta = false, bool tb = false, bool tc = false) const;
00406 
00412         MYSQLPP_EXPORT equal_list_ba<FieldNames, Row, quote_type0>
00413                         equal_list(const char* d = ",", const char* e = " = ") const;
00414 
00435         template <class Manip>
00436         equal_list_ba<FieldNames, Row, Manip> equal_list(const char* d,
00437                         const char* e, Manip m) const;
00438 
00439 private:
00440         std::vector<std::string> data_;
00441         std::vector<bool> is_nulls_;
00442         const ResUse* res_;
00443         bool initialized_;
00444 };
00445 
00446 } // end namespace mysqlpp
00447 
00448 #endif

Generated on Tue Aug 16 12:53:42 2005 for MySQL++ by  doxygen 1.3.9.1