MySQL++ Reference Manual

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# row.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004 /***********************************************************************
    00005  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
    00006  (c) 2004-2008 by Educational Technology Resources, Inc.  Others may
    00007  also hold copyrights on code in this file.  See the CREDITS.txt file
    00008  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 #if !defined(MYSQLPP_ROW_H)
    00029 #define MYSQLPP_ROW_H
    00030
    00031 #include "common.h"
    00032
    00033 #include "mystring.h"
    00034 #include "noexceptions.h"
    00035 #include "refcounted.h"
    00036 #include "vallist.h"
    00037
    00038 #include <vector>
    00039 #include <string>
    00040
    00041 namespace mysqlpp {
    00042
    00043 #if !defined(DOXYGEN_IGNORE)
    00044 // Make Doxygen ignore this
    00045 class FieldNames;
    00046 class MYSQLPP_EXPORT ResultBase;
    00047 #endif
    00048
    00062
    00063 class MYSQLPP_EXPORT Row : public OptionalExceptions
    00064 {
    00065 private:
    00070         typedef bool Row::*private_bool_type;
    00071
    00072 public:
    00077         typedef std::vector<String> list_type;
    00078
    00080         typedef list_type::const_iterator const_iterator;
    00081
    00083         typedef list_type::const_reference const_reference;
    00084
    00086         typedef list_type::const_reverse_iterator const_reverse_iterator;
    00087
    00089         typedef list_type::difference_type difference_type;
    00090
    00097         typedef const_iterator iterator;
    00098
    00102         typedef const_reference reference;
    00103
    00108         typedef const_reverse_iterator reverse_iterator;
    00109
    00111         typedef list_type::size_type size_type;
    00112
    00114         typedef list_type::value_type value_type;
    00115
    00117         Row() :
    00118         initialized_(false)
    00119         {
    00120         }
    00121
    00123         Row(const Row& r) :
    00124         OptionalExceptions(),
    00125         data_(r.data_.begin(), r.data_.end()),
    00126         field_names_(r.field_names_),
    00127         initialized_(r.initialized_)
    00128         {
    00129         }
    00130
    00137         Row(MYSQL_ROW row, const ResultBase* res,
    00138                         const unsigned long* lengths, bool te = true);
    00139
    00141         ~Row() { }
    00142
    00147         const_reference at(size_type i) const;
    00148
    00150         const_reference back() const { return data_.back(); }
    00151
    00154         const_iterator begin() const { return data_.begin(); }
    00155
    00157         bool empty() const { return data_.empty(); }
    00158
    00161         const_iterator end() const { return data_.end(); }
    00162
    00168         equal_list_ba<FieldNames, Row, quote_type0>
    00169                         equal_list(const char* d = ",", const char* e = " = ") const;
    00170
    00191         template <class Manip>
    00192         equal_list_ba<FieldNames, Row, Manip> equal_list(const char* d,
    00193                         const char* e, Manip m) const;
    00194
    00199         value_list_ba<FieldNames, do_nothing_type0>
    00200                         field_list(const char* d = ",") const;
    00201
    00208         template <class Manip>
    00209         value_list_ba<FieldNames, Manip> field_list(const char* d,
    00210                         Manip m) const;
    00211
    00220         template <class Manip>
    00221         value_list_b<FieldNames, Manip> field_list(const char* d, Manip m,
    00222                         const std::vector<bool>& vb) const;
    00223
    00233         value_list_b<FieldNames, quote_type0> field_list(
    00234                         const char* d, const std::vector<bool>& vb) const;
    00235
    00243         value_list_b<FieldNames, quote_type0> field_list(
    00244                         const std::vector<bool>& vb) const;
    00245
    00253         template <class Manip>
    00254         value_list_b<FieldNames, Manip> field_list(const char *d, Manip m,
    00255                         bool t0,
    00256                         bool t1 = false, bool t2 = false, bool t3 = false,
    00257                         bool t4 = false, bool t5 = false, bool t6 = false,
    00258                         bool t7 = false, bool t8 = false, bool t9 = false,
    00259                         bool ta = false, bool tb = false, bool tc = false) const;
    00260
    00268         value_list_b<FieldNames, quote_type0> field_list(
    00269                         const char *d, bool t0,
    00270                         bool t1 = false, bool t2 = false, bool t3 = false,
    00271                         bool t4 = false, bool t5 = false, bool t6 = false,
    00272                         bool t7 = false, bool t8 = false, bool t9 = false,
    00273                         bool ta = false, bool tb = false, bool tc = false) const;
    00274
    00281         value_list_b<FieldNames, quote_type0> field_list(
    00282                         bool t0,
    00283                         bool t1 = false, bool t2 = false, bool t3 = false,
    00284                         bool t4 = false, bool t5 = false, bool t6 = false,
    00285                         bool t7 = false, bool t8 = false, bool t9 = false,
    00286                         bool ta = false, bool tb = false, bool tc = false) const;
    00287
    00289         size_type field_num(const char* name) const;
    00290
    00292         const_reference front() const { return data_.front(); }
    00293
    00296         size_type max_size() const { return data_.max_size(); }
    00297
    00299         Row& operator =(const Row& rhs)
    00300         {
    00301                 data_.assign(rhs.data_.begin(), rhs.data_.end());
    00302                 field_names_.assign(rhs.field_names_);
    00303                 initialized_ = rhs.initialized_;
    00304                 return *this;
    00305         }
    00306
    00314         const_reference operator [](const char* field) const;
    00315
    00327         const_reference operator [](int i) const
    00328                         { return at(static_cast<size_type>(i)); }
    00329
    00347         operator private_bool_type() const
    00348         {
    00349                 return data_.size() && initialized_ ? &Row::initialized_ : 0;
    00350         }
    00351
    00354         const_reverse_iterator rbegin() const { return data_.rbegin(); }
    00355
    00358         const_reverse_iterator rend() const { return data_.rend(); }
    00359
    00361         size_type size() const { return data_.size(); }
    00362
    00371         template <class Manip>
    00372         value_list_ba<Row, Manip> value_list(const char* d = ",",
    00373                         Manip m = quote) const
    00374         {
    00375                 return value_list_ba<Row, Manip>(*this, d, m);
    00376         }
    00377
    00384         template <class Manip>
    00385         value_list_b<Row, Manip> value_list(const char *d,
    00386                         const std::vector<bool>& vb, Manip m = quote) const
    00387         {
    00388                 return value_list_b<Row, Manip>(*this, vb, d, m);
    00389         }
    00390
    00398         value_list_b<Row, quote_type0> value_list(
    00399                         const std::vector<bool> &vb) const
    00400         {
    00401                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
    00402         }
    00403
    00410         template <class Manip>
    00411         value_list_b<Row, Manip> value_list(const char *d, Manip m,
    00412                         bool t0, bool t1 = false, bool t2 = false, bool t3 = false,
    00413                         bool t4 = false, bool t5 = false, bool t6 = false,
    00414                         bool t7 = false, bool t8 = false, bool t9 = false,
    00415                         bool ta = false, bool tb = false, bool tc = false) const
    00416         {
    00417                 std::vector<bool> vb;
    00418                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
    00419                                 t7, t8, t9, ta, tb, tc);
    00420                 return value_list_b<Row, Manip>(*this, vb, d, m);
    00421         }
    00422
    00429         value_list_b <Row, quote_type0>
    00430         value_list(const char *d, bool t0, bool t1 = false, bool t2 = false,
    00431                         bool t3 = false, bool t4 = false, bool t5 = false,
    00432                         bool t6 = false, bool t7 = false, bool t8 = false,
    00433                         bool t9 = false, bool ta = false, bool tb = false,
    00434                         bool tc = false) const
    00435         {
    00436                 std::vector<bool> vb;
    00437                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
    00438                                 t7, t8, t9, ta, tb, tc);
    00439                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
    00440         }
    00441
    00448         value_list_b<Row, quote_type0> value_list(bool t0,
    00449                         bool t1 = false, bool t2 = false, bool t3 = false,
    00450                         bool t4 = false, bool t5 = false, bool t6 = false,
    00451                         bool t7 = false, bool t8 = false, bool t9 = false,
    00452                         bool ta = false, bool tb = false, bool tc = false) const
    00453         {
    00454                 std::vector<bool> vb;
    00455                 create_vector(size(), vb, t0, t1, t2, t3, t4, t5, t6,
    00456                                 t7, t8, t9, ta, tb, tc);
    00457                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
    00458         }
    00459
    00466         template <class Manip>
    00467         value_list_b<Row, Manip> value_list(const char *d, Manip m,
    00468                         std::string s0, std::string s1 = "", std::string s2 = "",
    00469                         std::string s3 = "", std::string s4 = "",
    00470                         std::string s5 = "", std::string s6 = "",
    00471                         std::string s7 = "", std::string s8 = "",
    00472                         std::string s9 = "", std::string sa = "",
    00473                         std::string sb = "", std::string sc = "") const
    00474         {
    00475                 std::vector<bool> vb;
    00476                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
    00477                                 s9, sa, sb, sc);
    00478                 return value_list_b<Row, Manip>(*this, vb, d, m);
    00479         }
    00480
    00487         value_list_b<Row, quote_type0> value_list(
    00488                         const char *d,
    00489                         std::string s0, std::string s1 = "", std::string s2 = "",
    00490                         std::string s3 = "", std::string s4 = "",
    00491                         std::string s5 = "", std::string s6 = "",
    00492                         std::string s7 = "", std::string s8 = "",
    00493                         std::string s9 = "", std::string sa = "",
    00494                         std::string sb = "", std::string sc = "") const
    00495         {
    00496                 std::vector<bool> vb;
    00497                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
    00498                                 s9, sa, sb, sc);
    00499                 return value_list_b<Row, quote_type0>(*this, vb, d, quote);
    00500         }
    00501
    00508         value_list_b<Row, quote_type0> value_list(
    00509                         std::string s0,
    00510                         std::string s1 = "", std::string s2 = "",
    00511                         std::string s3 = "", std::string s4 = "",
    00512                         std::string s5 = "", std::string s6 = "",
    00513                         std::string s7 = "", std::string s8 = "",
    00514                         std::string s9 = "", std::string sa = "",
    00515                         std::string sb = "", std::string sc = "") const
    00516         {
    00517                 std::vector<bool> vb;
    00518                 create_vector(*this, vb, s0, s1, s2, s3, s4, s5, s6, s7, s8,
    00519                                 s9, sa, sb, sc);
    00520                 return value_list_b<Row, quote_type0>(*this, vb, ",", quote);
    00521         }
    00522
    00523 private:
    00524         list_type data_;
    00525         RefCountedPointer<FieldNames> field_names_;
    00526         bool initialized_;
    00527 };
    00528
    00529 } // end namespace mysqlpp
    00530
    00531 #endif // !defined(MYSQLPP_ROW_H)