MySQL++ Reference Manual

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# qparms.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008 /***********************************************************************
    00009  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
    00010  (c) 2004-2007 by Educational Technology Resources, Inc.  Others may
    00011  also hold copyrights on code in this file.  See the CREDITS.txt file
    00012  in the top directory of the distribution for details.
    00013
    00014  This file is part of MySQL++.
    00015
    00016  MySQL++ is free software; you can redistribute it and/or modify it
    00017  under the terms of the GNU Lesser General Public License as published
    00018  by the Free Software Foundation; either version 2.1 of the License, or
    00019  (at your option) any later version.
    00020
    00021  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00022  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00023  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00024  License for more details.
    00025
    00026  You should have received a copy of the GNU Lesser General Public
    00027  License along with MySQL++; if not, write to the Free Software
    00028  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00029  USA
    00030 ***********************************************************************/
    00031
    00032 #ifndef MYSQLPP_QPARMS_H
    00033 #define MYSQLPP_QPARMS_H
    00034
    00035 #include "stadapter.h"
    00036
    00037 #include <vector>
    00038
    00039 namespace mysqlpp {
    00040
    00041 #if !defined(DOXYGEN_IGNORE)
    00042 // Make Doxygen ignore this
    00043 class MYSQLPP_EXPORT Query;
    00044 #endif
    00045
    00048 class MYSQLPP_EXPORT SQLQueryParms : public std::vector<SQLTypeAdapter>
    00049 {
    00050 public:
    00053         typedef const SQLTypeAdapter& sta;
    00054
    00056         SQLQueryParms() :
    00057         parent_(0),
    00058         processing_(false)
    00059         {
    00060         }
    00061
    00066         SQLQueryParms(Query* p) :
    00067         parent_(p),
    00068         processing_(false)
    00069         {
    00070         }
    00071
    00075         bool bound() { return parent_ != 0; }
    00076
    00078         void clear() { erase(begin(), end()); }
    00079
    00088         size_t escape_string(std::string* ps, const char* original = 0,
    00089                         size_t length = 0) const;
    00090
    00095         size_t escape_string(char* escaped, const char* original,
    00096                         size_t length) const;
    00097
    00099         SQLTypeAdapter& operator [](size_type n)
    00100         {
    00101                 if (n >= size()) {
    00102                         insert(end(), (n + 1) - size(), "");
    00103                 }
    00104                 return std::vector<SQLTypeAdapter>::operator [](n);
    00105         }
    00106
    00108         const SQLTypeAdapter& operator [](size_type n) const
    00109                         { return std::vector<SQLTypeAdapter>::operator [](n); }
    00110
    00112         SQLTypeAdapter& operator [](const char *str);
    00113
    00115         const SQLTypeAdapter& operator [](const char *str) const;
    00116
    00118         SQLQueryParms& operator <<(const SQLTypeAdapter& str)
    00119         {
    00120                 push_back(str);
    00121                 return *this;
    00122         }
    00123
    00125         SQLQueryParms& operator +=(const SQLTypeAdapter& str)
    00126         {
    00127                 push_back(str);
    00128                 return *this;
    00129         }
    00130
    00140         SQLQueryParms operator +(
    00141                         const SQLQueryParms& other) const;
    00142
    00143 #if !defined(DOXYGEN_IGNORE)
    00144 // Doxygen will not generate documentation for this section.
    00145         void set(sta a)
    00146         {
    00147                 clear();
    00148                 *this << a;
    00149         }
    00150         void set(sta a, sta b)
    00151         {
    00152                 clear();
    00153                 *this << a << b;
    00154         }
    00155         void set(sta a, sta b, sta c)
    00156         {
    00157                 clear();
    00158                 *this << a << b << c;
    00159         }
    00160         void set(sta a, sta b, sta c, sta d)
    00161         {
    00162                 clear();
    00163                 *this << a << b << c << d;
    00164         }
    00165         void set(sta a, sta b, sta c, sta d, sta e)
    00166         {
    00167                 clear();
    00168                 *this << a << b << c << d << e;
    00169         }
    00170         void set(sta a, sta b, sta c, sta d, sta e, sta f)
    00171         {
    00172                 clear();
    00173                 *this << a << b << c << d << e << f;
    00174         }
    00175         void set(sta a, sta b, sta c, sta d, sta e, sta f, sta g)
    00176         {
    00177                 clear();
    00178                 *this << a << b << c << d << e << f << g;
    00179         }
    00180         void set(sta a, sta b, sta c, sta d, sta e, sta f, sta g, sta h)
    00181         {
    00182                 clear();
    00183                 *this << a << b << c << d << e << f << g << h;
    00184         }
    00185         void set(sta a, sta b, sta c, sta d, sta e, sta f, sta g, sta h, sta i)
    00186         {
    00187                 clear();
    00188                 *this << a << b << c << d << e << f << g << h << i;
    00189         }
    00190         void set(sta a, sta b, sta c, sta d, sta e, sta f, sta g, sta h, sta i, sta j)
    00191         {
    00192                 clear();
    00193                 *this << a << b << c << d << e << f << g << h << i << j;
    00194         }
    00195         void set(sta a, sta b, sta c, sta d, sta e, sta f, sta g, sta h, sta i, sta j, sta k)
    00196         {
    00197                 clear();
    00198                 *this << a << b << c << d << e << f << g << h << i << j << k;
    00199         }
    00200 #endif // !defined(DOXYGEN_IGNORE)
    00201
    00207         void set(sta a, sta b, sta c, sta d, sta e, sta f, sta g,
    00208                         sta h, sta i, sta j, sta k, sta l)
    00209         {
    00210                 clear();
    00211                 *this << a << b << c << d << e << f << g << h << i << j << k << l;
    00212         }
    00213
    00214 private:
    00215         friend class Query;
    00216
    00217         Query* parent_;
    00218         bool processing_;
    00219 };
    00220
    00221
    00243
    00244 struct SQLParseElement
    00245 {
    00251         SQLParseElement(std::string b, char o, signed char n) :
    00252         before(b),
    00253         option(o),
    00254         num(n)
    00255         {
    00256         }
    00257
    00258         std::string before;
    00259         char option;
    00260         signed char num;
    00261 };
    00262
    00263 } // end namespace mysqlpp
    00264
    00265 #endif // !defined(MYSQLPP_QPARMS_H)
    00266