MySQL++ Reference Manual

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

stadapter.h
Go to the documentation of this file.
1
4 /***********************************************************************
5 Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
6 (c) 2004-2009 by Educational Technology Resources, Inc. Others may
7 also hold copyrights on code in this file. See the CREDITS.txt file
8 in the top directory of the distribution for details.
9
10 This file is part of MySQL++.
11
12 MySQL++ is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published
14 by the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with MySQL++; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 USA
26 ***********************************************************************/
27
28 #if !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)
29 #define MYSQLPP_SQL_TYPE_ADAPTER_H
30
31 #include "common.h"
32
33 #include "datetime.h"
34 #include "null.h"
35 #include "sql_buffer.h"
36 #include "tiny_int.h"
37
38 #include <stdexcept>
39 #include <string>
40
41 namespace mysqlpp {
42
43 #if !defined(DOXYGEN_IGNORE)
44 class MYSQLPP_EXPORT String;
45 #endif
46
72
73 class MYSQLPP_EXPORT SQLTypeAdapter
74 {
75 public:
76 typedef size_t size_type;
77
79 SQLTypeAdapter();
80
88 SQLTypeAdapter(const SQLTypeAdapter& other);
89
96 SQLTypeAdapter(const String& str, bool processed = false);
97
99 SQLTypeAdapter(const std::string& str, bool processed = false);
100
102 SQLTypeAdapter(const char* str, bool processed = false);
103
105 SQLTypeAdapter(const char* str, int len, bool processed = false);
106
113 SQLTypeAdapter(char c);
114
116 SQLTypeAdapter(tiny_int<signed char> i);
117
120 SQLTypeAdapter(tiny_int<unsigned char> i);
121
123 SQLTypeAdapter(short i);
124
127 SQLTypeAdapter(unsigned short i);
128
130 SQLTypeAdapter(int i);
131
134 SQLTypeAdapter(unsigned i);
135
137 SQLTypeAdapter(long i);
138
141 SQLTypeAdapter(unsigned long i);
142
144 SQLTypeAdapter(longlong i);
145
148 SQLTypeAdapter(ulonglong i);
149
151 SQLTypeAdapter(float i);
152
154 SQLTypeAdapter(double i);
155
157 SQLTypeAdapter(const Date& d);
158
160 SQLTypeAdapter(const DateTime& dt);
161
163 SQLTypeAdapter(const Time& t);
164
166 SQLTypeAdapter(const null_type& i);
167
171 SQLTypeAdapter& operator =(const SQLTypeAdapter& rhs);
172
176 SQLTypeAdapter& operator =(const null_type& n);
177
179 operator const char*() const { return data(); }
180
192 SQLTypeAdapter& assign(const SQLTypeAdapter& sta);
193
205 SQLTypeAdapter& assign(const char* pc, int len = -1);
206
212 SQLTypeAdapter& assign(const null_type& n);
213
224 char at(size_type i) const throw(std::out_of_range);
225
229 int compare(const SQLTypeAdapter& other) const;
230
234 int compare(const std::string& other) const;
235
240 int compare(size_type pos, size_type num, std::string& other) const;
241
245 int compare(const char* other) const;
246
251 int compare(size_type pos, size_type num, const char* other) const;
252
254 const char* data() const;
255
258 bool escape_q() const;
259
266 bool is_null() const { return buffer_->is_null(); }
267
272 bool is_processed() const { return is_processed_; }
273
275 size_type length() const;
276 size_type size() const { return length(); }
277
280 bool quote_q() const;
281
287 int type_id() const;
288
293 void set_processed() { is_processed_ = true; }
294
295 #if !defined(DOXYGEN_IGNORE)
296 // Parallel interface for Null<>-wrapped versions of types we
297 // support above. No need for parallel documentation.
298 SQLTypeAdapter(const Null<std::string>& str, bool processed = false);
299 SQLTypeAdapter(const Null<String>& str, bool processed = false);
300 SQLTypeAdapter(Null<char> c);
301 SQLTypeAdapter(Null< tiny_int<signed char> > i);
302 SQLTypeAdapter(Null< tiny_int<unsigned char> > i);
303 SQLTypeAdapter(Null<short> i);
304 SQLTypeAdapter(Null<unsigned short> i);
305 SQLTypeAdapter(Null<int> i);
306 SQLTypeAdapter(Null<unsigned> i);
307 SQLTypeAdapter(Null<long> i);
308 SQLTypeAdapter(Null<unsigned long> i);
309 SQLTypeAdapter(Null<longlong> i);
310 SQLTypeAdapter(Null<ulonglong> i);
311 SQLTypeAdapter(Null<float> i);
312 SQLTypeAdapter(Null<double> i);
313 SQLTypeAdapter(const Null<Date>& d);
314 SQLTypeAdapter(const Null<DateTime>& dt);
315 SQLTypeAdapter(const Null<Time>& t);
316 SQLTypeAdapter& operator =(const Null<std::string>& str);
317 #endif // !defined(DOXYGEN_IGNORE)
318
319 private:
321 RefCountedBuffer buffer_;
322
333 bool is_processed_;
334 };
335
336 } // end namespace mysqlpp
337
338 #endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)
null.h
Declares classes that implement SQL &quot;null&quot; semantics within C++&#39;s type system.
mysqlpp::SQLTypeAdapter::size
size_type size() const
alias for length()
Definition: stadapter.h:276
mysqlpp::SQLTypeAdapter::size_type
size_t size_type
size of length values
Definition: stadapter.h:76
mysqlpp::SQLTypeAdapter::is_null
bool is_null() const
Return true if buffer&#39;s contents represent a SQL null.
Definition: stadapter.h:266
mysqlpp::Time
C++ form of SQL&#39;s TIME type.
Definition: datetime.h:347
mysqlpp::DateTime
C++ form of SQL&#39;s DATETIME type.
Definition: datetime.h:48
datetime.h
Declares classes to add SQL-compatible date and time types to C++&#39;s type system.
mysqlpp::SQLTypeAdapter::is_processed
bool is_processed() const
Returns true if the internal &#39;processed&#39; flag is set.
Definition: stadapter.h:272
mysqlpp::tiny_int
Class for holding an SQL TINYINT value.
Definition: tiny_int.h:55
mysqlpp::null_type
The type of the global mysqlpp::null object.
Definition: null.h:49
mysqlpp::SQLTypeAdapter::set_processed
void set_processed()
Turns on the internal &#39;is_processed_&#39; flag.
Definition: stadapter.h:293
mysqlpp::Date
C++ form of SQL&#39;s DATE type.
Definition: datetime.h:225
mysqlpp::RefCountedPointer< SQLBuffer >
common.h
This file includes top-level definitions for use both internal to the library, and outside it...
sql_buffer.h
Declares the SQLBuffer class.
mysqlpp::SQLTypeAdapter
Converts many different data types to strings suitable for use in SQL queries.
Definition: stadapter.h:73
tiny_int.h
Declares class for holding a SQL TINYINT.
mysqlpp::Null
Class for holding data from a SQL column with the NULL attribute.
Definition: null.h:170
mysqlpp::String
A std::string work-alike that can convert itself from SQL text data formats to C++ data types...
Definition: mystring.h:139