Go to the documentation of this file.
28 #if !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)
29 #define MYSQLPP_SQL_TYPE_ADAPTER_H
43 #if !defined(DOXYGEN_IGNORE)
44 class MYSQLPP_EXPORT String;
73 class MYSQLPP_EXPORT SQLTypeAdapter
76 typedef size_t size_type;
88 SQLTypeAdapter(
const SQLTypeAdapter& other);
96 SQLTypeAdapter(
const String& str,
bool processed =
false);
99 SQLTypeAdapter(
const std::string& str,
bool processed =
false);
102 SQLTypeAdapter(
const char* str,
bool processed =
false);
105 SQLTypeAdapter(
const char* str,
int len,
bool processed =
false);
113 SQLTypeAdapter(
char c);
116 SQLTypeAdapter(tiny_int<signed char> i);
179 operator const char*()
const {
return data(); }
225 #if !defined(DOXYGEN_IGNORE) && __cplusplus >= 201103L
227 char at(size_type i)
const noexcept(
false);
229 char at(size_type i)
const throw(std::out_of_range);
240 int compare(
const std::string& other)
const;
246 int compare(size_type pos, size_type num, std::string& other)
const;
251 int compare(
const char* other)
const;
257 int compare(size_type pos, size_type num,
const char* other)
const;
260 const char* data()
const;
264 bool escape_q()
const;
272 bool is_null()
const {
return buffer_->is_null(); }
278 bool is_processed()
const {
return is_processed_; }
281 size_type length()
const;
282 size_type size()
const {
return length(); }
286 bool quote_q()
const;
299 void set_processed() { is_processed_ =
true; }
301 #if !defined(DOXYGEN_IGNORE)
304 SQLTypeAdapter(
const Null<std::string>& str,
bool processed =
false);
305 SQLTypeAdapter(
const Null<String>& str,
bool processed =
false);
306 SQLTypeAdapter(Null<char> c);
307 SQLTypeAdapter(Null< tiny_int<signed char> > i);
308 SQLTypeAdapter(Null< tiny_int<unsigned char> > i);
309 SQLTypeAdapter(Null<short> i);
310 SQLTypeAdapter(Null<unsigned short> i);
311 SQLTypeAdapter(Null<int> i);
312 SQLTypeAdapter(Null<unsigned> i);
313 SQLTypeAdapter(Null<long> i);
314 SQLTypeAdapter(Null<unsigned long> i);
315 SQLTypeAdapter(Null<longlong> i);
323 #endif // !defined(DOXYGEN_IGNORE)
344 #endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)
SQLTypeAdapter & operator=(const SQLTypeAdapter &rhs)
Standard assignment operator.
Definition: stadapter.cpp:499
Exception thrown when an object with operator [] or an at() method gets called with a bad index.
Definition: exceptions.h:202
const mysql_type_info & type() const
Return the SQL type of the data held in the buffer.
Definition: sql_buffer.h:157
Declares an adapter that converts something that can be inserted into a C++ stream into a std::string...
bool quote_q() const
Returns true if we were initialized with a data type that must be quoted when used in a SQL query.
Definition: stadapter.cpp:511
const char * data() const
Return pointer to raw data buffer.
Definition: sql_buffer.h:124
bool escape_q() const
Returns true if we were initialized with a data type that must be escaped when used in a SQL query.
Definition: stadapter.cpp:493
size_type length() const
Return number of bytes in data buffer.
Definition: sql_buffer.h:136
char at(size_type i) const
Returns the character at a given position within the string buffer.
Definition: stadapter.cpp:419
Declares the SQLTypeAdapter class.
Declares the RefCountedPointer template.
C++ form of SQL's DATE type.
Definition: datetime.h:247
Type data
The object's value, when it is not SQL null.
Definition: null.h:196
size_type length() const
Return number of bytes in data buffer.
Definition: stadapter.cpp:487
Declares class for holding a SQL TINYINT.
int id() const
Returns the ID of the SQL type.
Definition: type_info.h:282
Holds SQL data in string form plus type information for use in converting the string to compatible C+...
Definition: sql_buffer.h:63
Converts many different data types to strings suitable for use in SQL queries.
Definition: stadapter.h:95
SQLTypeAdapter()
Default constructor; empty string.
Definition: stadapter.cpp:41
bool quote_q() const
Returns true if we were initialized with a data type that must be quoted when used in a SQL query.
Definition: sql_buffer.cpp:79
The type of the global mysqlpp::null object.
Definition: null.h:71
bool escape_q() const
Returns true if we were initialized with a data type that must be escaped when used in a SQL query.
Definition: sql_buffer.h:128
Declares classes that implement SQL "null" semantics within C++'s type system.
SQLTypeAdapter & assign(const SQLTypeAdapter &sta)
Copies another SQLTypeAdapter's data buffer into this object.
Definition: stadapter.cpp:391
int compare(const SQLTypeAdapter &other) const
Compare the internal buffer to the given string.
Definition: stadapter.cpp:436
C++ form of SQL's TIME type.
Definition: datetime.h:369
const std::string null_str
"NULL" string constant
Class for holding data from a SQL column with the NULL attribute.
Definition: null.h:192
int type_id() const
Returns the type ID of the buffer's data.
Definition: stadapter.cpp:519
This file includes top-level definitions for use both internal to the library, and outside it....
A std::string work-alike that can convert itself from SQL text data formats to C++ data types.
Definition: mystring.h:161
SQL field type information.
Definition: type_info.h:170
C++ form of SQL's DATETIME type.
Definition: datetime.h:70
static const enum_field_types string_type
The internal constant we use for our string type.
Definition: type_info.h:314
Class for holding an SQL TINYINT value.
Definition: tiny_int.h:77
const char * data() const
Return pointer to raw data buffer.
Definition: stadapter.cpp:481
size_t size_type
size of length values
Definition: stadapter.h:120
bool is_null
If set, this object is considered equal to SQL null.
Definition: null.h:201
Declares String class, MySQL++'s generic std::string-like class, used for holding data received from ...
Declares the SQLBuffer class.
Declares classes to add SQL-compatible date and time types to C++'s type system.
std::string stream2string(const T &object)
Converts anything you can insert into a C++ stream to a std::string via std::ostringstream.
Definition: stream2string.h:63