# stadapter.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_SQL_TYPE_ADAPTER_H)
    00029 #define MYSQLPP_SQL_TYPE_ADAPTER_H
    00030
    00031 #include "common.h"
    00032
    00033 #include "datetime.h"
    00034 #include "null.h"
    00035 #include "sql_buffer.h"
    00036 #include "sql_types.h"
    00037
    00038 #include <stdexcept>
    00039 #include <string>
    00040
    00041 namespace mysqlpp {
    00042
    00043 #if !defined(DOXYGEN_IGNORE)
    00044 class MYSQLPP_EXPORT String;
    00045 #endif
    00046
    00072
    00073 class MYSQLPP_EXPORT SQLTypeAdapter
    00074 {
    00075 public:
    00076         typedef size_t size_type;
    00077
    00079         SQLTypeAdapter();
    00080
    00088         SQLTypeAdapter(const SQLTypeAdapter& other);
    00089
    00096         SQLTypeAdapter(const String& str, bool processed = false);
    00097
    00099         SQLTypeAdapter(const std::string& str, bool processed = false);
    00100
    00102         SQLTypeAdapter(const char* str, bool processed = false);
    00103
    00105         SQLTypeAdapter(const char* str, int len, bool processed = false);
    00106
    00113         SQLTypeAdapter(char c);
    00114
    00116         SQLTypeAdapter(sql_tinyint i);
    00117
    00120         SQLTypeAdapter(sql_tinyint_unsigned i);
    00121
    00123         SQLTypeAdapter(short i);
    00124
    00127         SQLTypeAdapter(unsigned short i);
    00128
    00130         SQLTypeAdapter(int i);
    00131
    00134         SQLTypeAdapter(unsigned i);
    00135
    00137         SQLTypeAdapter(long i);
    00138
    00141         SQLTypeAdapter(unsigned long i);
    00142
    00144         SQLTypeAdapter(longlong i);
    00145
    00148         SQLTypeAdapter(ulonglong i);
    00149
    00151         SQLTypeAdapter(float i);
    00152
    00154         SQLTypeAdapter(double i);
    00155
    00157         SQLTypeAdapter(const Date& d);
    00158
    00160         SQLTypeAdapter(const DateTime& dt);
    00161
    00163         SQLTypeAdapter(const Time& t);
    00164
    00166         SQLTypeAdapter(const null_type& i);
    00167
    00171         SQLTypeAdapter& operator =(const SQLTypeAdapter& rhs);
    00172
    00176         SQLTypeAdapter& operator =(const null_type& n);
    00177
    00179         operator const char*() const { return data(); }
    00180
    00192         SQLTypeAdapter& assign(const SQLTypeAdapter& sta);
    00193
    00205         SQLTypeAdapter& assign(const char* pc, int len = -1);
    00206
    00212         SQLTypeAdapter& assign(const null_type& n);
    00213
    00224         char at(size_type i) const throw(std::out_of_range);
    00225
    00229         int compare(const SQLTypeAdapter& other) const;
    00230
    00234         int compare(const std::string& other) const;
    00235
    00240         int compare(size_type pos, size_type num, std::string& other) const;
    00241
    00245         int compare(const char* other) const;
    00246
    00251         int compare(size_type pos, size_type num, const char* other) const;
    00252
    00254         const char* data() const;
    00255
    00258         bool escape_q() const;
    00259
    00264         bool is_processed() const { return is_processed_; }
    00265
    00267         size_type length() const;
    00268         size_type size() const { return length(); }
    00269
    00272         bool quote_q() const;
    00273
    00279         int type_id() const;
    00280
    00285         void set_processed() { is_processed_ = true; }
    00286
    00287 #if !defined(DOXYGEN_IGNORE)
    00288         // Parallel interface for Null<>-wrapped versions of types we
    00289         // support above.  No need for parallel documentation.
    00290         SQLTypeAdapter(const Null<std::string>& str, bool processed = false);
    00291         SQLTypeAdapter(const Null<String>& str, bool processed = false);
    00292         SQLTypeAdapter(Null<char> c);
    00293         SQLTypeAdapter(Null<sql_tinyint> i);
    00294         SQLTypeAdapter(Null<sql_tinyint_unsigned> i);
    00295         SQLTypeAdapter(Null<short> i);
    00296         SQLTypeAdapter(Null<unsigned short> i);
    00297         SQLTypeAdapter(Null<int> i);
    00298         SQLTypeAdapter(Null<unsigned> i);
    00299         SQLTypeAdapter(Null<long> i);
    00300         SQLTypeAdapter(Null<unsigned long> i);
    00301         SQLTypeAdapter(Null<longlong> i);
    00302         SQLTypeAdapter(Null<ulonglong> i);
    00303         SQLTypeAdapter(Null<float> i);
    00304         SQLTypeAdapter(Null<double> i);
    00305         SQLTypeAdapter(const Null<Date>& d);
    00306         SQLTypeAdapter(const Null<DateTime>& dt);
    00307         SQLTypeAdapter(const Null<Time>& t);
    00308         SQLTypeAdapter& operator =(const Null<std::string>& str);
    00309 #endif // !defined(DOXYGEN_IGNORE)
    00310
    00311 private:
    00313         RefCountedBuffer buffer_;
    00314
    00325         bool is_processed_;
    00326 };
    00327
    00328 } // end namespace mysqlpp
    00329
    00330 #endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)