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 "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
00297
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 }
00337
00338 #endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)