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 #if !defined(DOXYGEN_IGNORE)
00045 // Make Doxygen ignore this
00046 class 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 
00164         std::string::size_type raw_size(int i) const
00165         {
00166                 return data_[i].length();
00167         }
00168 
00174         const std::string& raw_string(int i) const
00175         {
00176                 return data_.at(i);
00177         }
00178 
00180         operator bool() const
00181         {
00182                 return data_.size();
00183         }
00184 
00193         template <class Manip>
00194         value_list_ba<Row, Manip> value_list(const char* d = ",",
00195                         Manip m = quote) const
00196         {
00197                 return value_list_ba<Row, Manip>(*this, d, m);
00198         }
00199         
00206         template <class Manip>
00207         value_list_b<Row, Manip> value_list(const char *d,
00208                         const std::vector<bool>& vb, Manip m = quote) const
00209         {
00210                 return value_list_b<Row, Manip>(*this, vb, d, m);
00211         }
00212         
00220         value_list_b<Row, quote_type0> value_list(
00221                         const std::vector<bool> &vb) const
00222         {
00223                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00224         }
00225         
00232         template <class Manip>
00233         value_list_b<Row, Manip> value_list(const char *d, Manip m,
00234                         bool t0, bool t1 = false, bool t2 = false, bool t3 = false,
00235                         bool t4 = false, bool t5 = false, bool t6 = false,
00236                         bool t7 = false, bool t8 = false, bool t9 = false,
00237                         bool ta = false, bool tb = false, bool tc = false) const
00238         {
00239                 std::vector<bool> vb;
00240                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00241                                 t7, t8, t9, ta, tb, tc);
00242                 return value_list_b<Row, Manip>(*this, vb, d, m);
00243         }
00244         
00251         value_list_b <Row, quote_type0>
00252         value_list(const char *d, bool t0, bool t1 = false, bool t2 = false,
00253                         bool t3 = false, bool t4 = false, bool t5 = false,
00254                         bool t6 = false, bool t7 = false, bool t8 = false,
00255                         bool t9 = false, bool ta = false, bool tb = false,
00256                         bool tc = false) const
00257         {
00258                 std::vector<bool> vb;
00259                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00260                                 t7, t8, t9, ta, tb, tc);
00261                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00262         }
00263         
00270         value_list_b<Row, quote_type0> value_list(bool t0,
00271                         bool t1 = false, bool t2 = false, bool t3 = false,
00272                         bool t4 = false, bool t5 = false, bool t6 = false,
00273                         bool t7 = false, bool t8 = false, bool t9 = false,
00274                         bool ta = false, bool tb = false, bool tc = false) const
00275         {
00276                 std::vector<bool> vb;
00277                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
00278                                 t7, t8, t9, ta, tb, tc);
00279                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00280         }
00281         
00288         template <class Manip>
00289         value_list_b<Row, Manip> value_list(const char *d, Manip m,
00290                         std::string s0, std::string s1 = "", std::string s2 = "",
00291                         std::string s3 = "", std::string s4 = "",
00292                         std::string s5 = "", std::string s6 = "",
00293                         std::string s7 = "", std::string s8 = "",
00294                         std::string s9 = "", std::string sa = "",
00295                         std::string sb = "", std::string sc = "") const
00296         {
00297                 std::vector<bool> vb;
00298                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00299                                 s9, sa, sb, sc);
00300                 return value_list_b<Row, Manip>(*this, vb, d, m);
00301         }
00302         
00309         value_list_b<Row, quote_type0> value_list(
00310                         const char *d,
00311                         std::string s0, std::string s1 = "", std::string s2 = "",
00312                         std::string s3 = "", std::string s4 = "",
00313                         std::string s5 = "", std::string s6 = "",
00314                         std::string s7 = "", std::string s8 = "",
00315                         std::string s9 = "", std::string sa = "",
00316                         std::string sb = "", std::string sc = "") const
00317         {
00318                 std::vector<bool> vb;
00319                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00320                                 s9, sa, sb, sc);
00321                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
00322         }
00323         
00330         value_list_b<Row, quote_type0> value_list(
00331                         std::string s0,
00332                         std::string s1 = "", std::string s2 = "",
00333                         std::string s3 = "", std::string s4 = "",
00334                         std::string s5 = "", std::string s6 = "",
00335                         std::string s7 = "", std::string s8 = "",
00336                         std::string s9 = "", std::string sa = "",
00337                         std::string sb = "", std::string sc = "") const
00338         {
00339                 std::vector<bool> vb;
00340                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
00341                                 s9, sa, sb, sc);
00342                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
00343         }
00344 
00349         value_list_ba<FieldNames, do_nothing_type0>
00350                         field_list(const char* d = ",") const;
00351 
00358         template <class Manip>
00359         value_list_ba<FieldNames, Manip> field_list(const char* d,
00360                         Manip m) const;
00361 
00370         template <class Manip>
00371         value_list_b<FieldNames, Manip> field_list(const char* d, Manip m,
00372                         const std::vector<bool>& vb) const;
00373 
00383         value_list_b<FieldNames, quote_type0> field_list(
00384                         const char* d, const std::vector<bool>& vb) const;
00385 
00393         value_list_b<FieldNames, quote_type0> field_list(
00394                         const std::vector<bool>& vb) const;
00395 
00403         template <class Manip>
00404         value_list_b<FieldNames, Manip> field_list(const char *d, Manip m,
00405                         bool t0,
00406                         bool t1 = false, bool t2 = false, bool t3 = false,
00407                         bool t4 = false, bool t5 = false, bool t6 = false,
00408                         bool t7 = false, bool t8 = false, bool t9 = false,
00409                         bool ta = false, bool tb = false, bool tc = false) const;
00410 
00418         value_list_b<FieldNames, quote_type0> field_list(
00419                         const char *d, bool t0,
00420                         bool t1 = false, bool t2 = false, bool t3 = false,
00421                         bool t4 = false, bool t5 = false, bool t6 = false,
00422                         bool t7 = false, bool t8 = false, bool t9 = false,
00423                         bool ta = false, bool tb = false, bool tc = false) const;
00424 
00431         value_list_b<FieldNames, quote_type0> field_list(
00432                         bool t0,
00433                         bool t1 = false, bool t2 = false, bool t3 = false,
00434                         bool t4 = false, bool t5 = false, bool t6 = false,
00435                         bool t7 = false, bool t8 = false, bool t9 = false,
00436                         bool ta = false, bool tb = false, bool tc = false) const;
00437 
00443         equal_list_ba<FieldNames, Row, quote_type0>
00444                         equal_list(const char* d = ",", const char* e = " = ") const;
00445 
00466         template <class Manip>
00467         equal_list_ba<FieldNames, Row, Manip> equal_list(const char* d,
00468                         const char* e, Manip m) const;
00469 
00470 private:
00471         std::vector<std::string> data_;
00472         std::vector<bool> is_nulls_;
00473         const ResUse* res_;
00474         bool initialized_;
00475 };
00476 
00477 } // end namespace mysqlpp
00478 
00479 #endif

Generated on Wed Jul 11 15:34:34 2007 for MySQL++ by doxygen 1.3.5