31 #if !defined(MYSQLPP_TYPE_INFO_H)
32 #define MYSQLPP_TYPE_INFO_H
44 #if !defined(DOXYGEN_IGNORE)
47 class MYSQLPP_EXPORT mysql_type_info;
48 class MYSQLPP_EXPORT mysql_ti_sql_type_info_lookup;
50 class MYSQLPP_EXPORT mysql_ti_sql_type_info
53 #if __cplusplus >= 201103L
55 mysql_ti_sql_type_info& operator=(
const mysql_ti_sql_type_info&) =
67 friend class mysql_type_info;
68 friend class mysql_ti_sql_type_info_lookup;
70 #if __cplusplus < 201103L
72 mysql_ti_sql_type_info& operator=(
73 const mysql_ti_sql_type_info& b);
78 mysql_ti_sql_type_info() :
82 #if MYSQL_VERSION_ID > 40000
92 mysql_ti_sql_type_info(
const char* s,
93 const std::type_info& t,
const enum_field_types bt,
94 const unsigned int flags = 0) :
102 bool is_default()
const {
return flags_ & tf_default; }
103 bool is_null()
const {
return flags_ & tf_null; }
104 bool is_unsigned()
const {
return flags_ & tf_unsigned; }
106 const char* sql_name_;
107 const std::type_info* c_type_;
108 const enum_field_types base_type_;
109 const unsigned int flags_;
115 bool operator() (
const std::type_info* lhs,
116 const std::type_info* rhs)
const
118 return lhs->before(*rhs) != 0;
122 class MYSQLPP_EXPORT mysql_ti_sql_type_info_lookup
125 friend class mysql_type_info;
127 typedef mysql_ti_sql_type_info sql_type_info;
128 typedef std::map<const std::type_info*, unsigned char, type_info_cmp>
131 mysql_ti_sql_type_info_lookup(
const sql_type_info types[],
134 const unsigned char& operator [](
135 const std::type_info& ti)
const
137 map_type::const_iterator it = map_.find(&ti);
138 if (it != map_.end()) {
142 std::ostringstream outs;
143 outs <<
"Failed to find MySQL C API type ID for " << ti.name();
144 throw TypeLookupFailed(outs.str());
169 num_(static_cast<unsigned char>(-1))
179 bool _null =
false) :
180 num_(type(t, _unsigned, _null))
220 const char*
name()
const {
return deref().c_type_->name(); }
225 const char*
sql_name()
const {
return deref().sql_name_; }
231 const std::type_info&
c_type()
const {
return *deref().c_type_; }
258 bool quote_q()
const;
265 bool escape_q()
const;
273 return num_ < b.num_;
280 static const enum_field_types string_type =
281 #if MYSQL_VERSION_ID > 40000
288 typedef mysql_ti_sql_type_info sql_type_info;
289 typedef mysql_ti_sql_type_info_lookup sql_type_info_lookup;
291 static const sql_type_info types[];
292 static const int num_types;
294 static const sql_type_info_lookup lookups;
314 static unsigned char type(enum_field_types t,
315 bool _unsigned,
bool _null =
false);
317 const sql_type_info& deref()
const
328 return a.
id() == b.
id();
334 return a.
id() != b.
id();
SQL field type information.
Definition: type_info.h:159
mysql_type_info(const mysql_type_info &t)
Create object as a copy of another.
Definition: type_info.h:185
int id() const
Returns the ID of the SQL type.
Definition: type_info.h:248
const mysql_type_info base_type() const
Returns the type_info for the C++ type inside of the mysqlpp::Null type.
Definition: type_info.h:238
mysql_type_info(enum_field_types t, bool _unsigned=false, bool _null=false)
Create object from MySQL C API type info.
Definition: type_info.h:178
mysql_type_info()
Default constructor.
Definition: type_info.h:168
const std::type_info & c_type() const
Returns the type_info for the C++ type associated with the SQL type.
Definition: type_info.h:231
mysql_type_info(const std::type_info &t)
Create object from a C++ type_info object.
Definition: type_info.h:194
bool before(mysql_type_info &b)
Provides a way to compare two types for sorting.
Definition: type_info.h:271
const char * name() const
Returns an implementation-defined name of the C++ type.
Definition: type_info.h:220
const char * sql_name() const
Returns the name of the SQL type.
Definition: type_info.h:225
This file includes top-level definitions for use both internal to the library, and outside it....
Declares the MySQL++-specific exception classes.