- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# 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-2009 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 "tiny_int.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(tiny_int<signed char> i);
    00117
    00120         SQLTypeAdapter(tiny_int<unsigned char> 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
    00266         bool is_null() const { return buffer_->is_null(); }
    00267
    00272         bool is_processed() const { return is_processed_; }
    00273
    00275         size_type length() const;
    00276         size_type size() const { return length(); }
    00277
    00280         bool quote_q() const;
    00281
    00287         int type_id() const;
    00288
    00293         void set_processed() { is_processed_ = true; }
    00294
    00295 #if !defined(DOXYGEN_IGNORE)
    00296         // Parallel interface for Null<>-wrapped versions of types we
    00297         // support above.  No need for parallel documentation.
    00298         SQLTypeAdapter(const Null<std::string>& str, bool processed = false);
    00299         SQLTypeAdapter(const Null<String>& str, bool processed = false);
    00300         SQLTypeAdapter(Null<char> c);
    00301         SQLTypeAdapter(Null< tiny_int<signed char> > i);
    00302         SQLTypeAdapter(Null< tiny_int<unsigned char> > i);
    00303         SQLTypeAdapter(Null<short> i);
    00304         SQLTypeAdapter(Null<unsigned short> i);
    00305         SQLTypeAdapter(Null<int> i);
    00306         SQLTypeAdapter(Null<unsigned> i);
    00307         SQLTypeAdapter(Null<long> i);
    00308         SQLTypeAdapter(Null<unsigned long> i);
    00309         SQLTypeAdapter(Null<longlong> i);
    00310         SQLTypeAdapter(Null<ulonglong> i);
    00311         SQLTypeAdapter(Null<float> i);
    00312         SQLTypeAdapter(Null<double> i);
    00313         SQLTypeAdapter(const Null<Date>& d);
    00314         SQLTypeAdapter(const Null<DateTime>& dt);
    00315         SQLTypeAdapter(const Null<Time>& t);
    00316         SQLTypeAdapter& operator =(const Null<std::string>& str);
    00317 #endif // !defined(DOXYGEN_IGNORE)
    00318
    00319 private:
    00321         RefCountedBuffer buffer_;
    00322
    00333         bool is_processed_;
    00334 };
    00335
    00336 } // end namespace mysqlpp
    00337
    00338 #endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)