# 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, 2000 and 2001 by
    00010  MySQL AB, and (c) 2004-2007 by Educational Technology Resources, Inc.
    00011  Others may also hold copyrights on code in this file.  See the CREDITS
    00012  file 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 "sql_string.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<SQLString>
    00049 {
    00050 public:
    00053         typedef const SQLString& ss;
    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()
    00076         {
    00077                 return parent_ != 0;
    00078         }
    00079
    00081         void clear()
    00082         {
    00083                 erase(begin(), end());
    00084         }
    00085
    00087         SQLString& operator [](size_type n)
    00088         {
    00089                 if (n >= size())
    00090                         insert(end(), (n + 1) - size(), "");
    00091                 return std::vector<SQLString>::operator [](n);
    00092         }
    00093
    00095         const SQLString& operator [](size_type n) const
    00096         {
    00097                 return std::vector<SQLString>::operator [](n);
    00098         }
    00099
    00101         SQLString& operator [](const char *str);
    00102
    00104         const SQLString& operator [](const char *str) const;
    00105
    00107         SQLQueryParms& operator <<(const SQLString& str)
    00108         {
    00109                 push_back(str);
    00110                 return *this;
    00111         }
    00112
    00114         SQLQueryParms& operator +=(const SQLString& str)
    00115         {
    00116                 push_back(str);
    00117                 return *this;
    00118         }
    00119
    00129         SQLQueryParms operator +(
    00130                         const SQLQueryParms& other) const;
    00131
    00132 #if !defined(DOXYGEN_IGNORE)
    00133 // Doxygen will not generate documentation for this section.
    00134         void set(ss a)
    00135         {
    00136                 clear();
    00137                 *this << a;
    00138         }
    00139         void set(ss a, ss b)
    00140         {
    00141                 clear();
    00142                 *this << a << b;
    00143         }
    00144         void set(ss a, ss b, ss c)
    00145         {
    00146                 clear();
    00147                 *this << a << b << c;
    00148         }
    00149         void set(ss a, ss b, ss c, ss d)
    00150         {
    00151                 clear();
    00152                 *this << a << b << c << d;
    00153         }
    00154         void set(ss a, ss b, ss c, ss d, ss e)
    00155         {
    00156                 clear();
    00157                 *this << a << b << c << d << e;
    00158         }
    00159         void set(ss a, ss b, ss c, ss d, ss e, ss f)
    00160         {
    00161                 clear();
    00162                 *this << a << b << c << d << e << f;
    00163         }
    00164         void set(ss a, ss b, ss c, ss d, ss e, ss f, ss g)
    00165         {
    00166                 clear();
    00167                 *this << a << b << c << d << e << f << g;
    00168         }
    00169         void set(ss a, ss b, ss c, ss d, ss e, ss f, ss g, ss h)
    00170         {
    00171                 clear();
    00172                 *this << a << b << c << d << e << f << g << h;
    00173         }
    00174         void set(ss a, ss b, ss c, ss d, ss e, ss f, ss g, ss h, ss i)
    00175         {
    00176                 clear();
    00177                 *this << a << b << c << d << e << f << g << h << i;
    00178         }
    00179         void set(ss a, ss b, ss c, ss d, ss e, ss f, ss g, ss h, ss i, ss j)
    00180         {
    00181                 clear();
    00182                 *this << a << b << c << d << e << f << g << h << i << j;
    00183         }
    00184         void set(ss a, ss b, ss c, ss d, ss e, ss f, ss g, ss h, ss i, ss j, ss k)
    00185         {
    00186                 clear();
    00187                 *this << a << b << c << d << e << f << g << h << i << j << k;
    00188         }
    00189 #endif // !defined(DOXYGEN_IGNORE)
    00190
    00196         void set(ss a, ss b, ss c, ss d, ss e, ss f, ss g,
    00197                         ss h, ss i, ss j, ss k, ss l)
    00198         {
    00199                 clear();
    00200                 *this << a << b << c << d << e << f << g << h << i << j << k << l;
    00201         }
    00202
    00203 private:
    00204         friend class Query;
    00205
    00206         Query* parent_;
    00207         bool processing_;
    00208 };
    00209
    00210
    00232
    00233 struct SQLParseElement
    00234 {
    00240         SQLParseElement(std::string b, char o, signed char n) :
    00241         before(b),
    00242         option(o),
    00243         num(n)
    00244         {
    00245         }
    00246
    00247         std::string before;
    00248         char option;
    00249         signed char num;
    00250 };
    00251
    00252 } // end namespace mysqlpp
    00253
    00254 #endif // !defined(MYSQLPP_QPARMS_H)
    00255