00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00220 char at(size_type i) const throw(std::out_of_range);
00221
00225 int compare(const SQLTypeAdapter& other) const;
00226
00230 int compare(const std::string& other) const;
00231
00236 int compare(size_type pos, size_type num, std::string& other) const;
00237
00241 int compare(const char* other) const;
00242
00247 int compare(size_type pos, size_type num, const char* other) const;
00248
00250 const char* data() const;
00251
00254 bool escape_q() const;
00255
00260 bool is_processed() const { return is_processed_; }
00261
00263 size_type length() const;
00264 size_type size() const { return length(); }
00265
00268 bool quote_q() const;
00269
00275 int type_id() const;
00276
00281 void set_processed() { is_processed_ = true; }
00282
00283 #if !defined(DOXYGEN_IGNORE)
00284
00285
00286 SQLTypeAdapter(const Null<std::string>& str, bool processed = false);
00287 SQLTypeAdapter(Null<char> c);
00288 SQLTypeAdapter(Null<sql_tinyint> i);
00289 SQLTypeAdapter(Null<sql_tinyint_unsigned> i);
00290 SQLTypeAdapter(Null<short> i);
00291 SQLTypeAdapter(Null<unsigned short> i);
00292 SQLTypeAdapter(Null<int> i);
00293 SQLTypeAdapter(Null<unsigned> i);
00294 SQLTypeAdapter(Null<long> i);
00295 SQLTypeAdapter(Null<unsigned long> i);
00296 SQLTypeAdapter(Null<longlong> i);
00297 SQLTypeAdapter(Null<ulonglong> i);
00298 SQLTypeAdapter(Null<float> i);
00299 SQLTypeAdapter(Null<double> i);
00300 SQLTypeAdapter(const Null<Date>& d);
00301 SQLTypeAdapter(const Null<DateTime>& dt);
00302 SQLTypeAdapter(const Null<Time>& t);
00303 SQLTypeAdapter& operator =(const Null<std::string>& str);
00304 #endif // !defined(DOXYGEN_IGNORE)
00305
00306 private:
00308 RefCountedBuffer buffer_;
00309
00320 bool is_processed_;
00321 };
00322
00323 }
00324
00325 #endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)