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
60 friend class mysql_type_info;
61 friend class mysql_ti_sql_type_info_lookup;
63 mysql_ti_sql_type_info& operator=(
64 const mysql_ti_sql_type_info& b);
68 mysql_ti_sql_type_info() :
72 #if MYSQL_VERSION_ID > 40000
82 mysql_ti_sql_type_info(
const char* s,
83 const std::type_info& t,
const enum_field_types bt,
84 const unsigned int flags = 0) :
92 bool is_default()
const {
return flags_ & tf_default; }
93 bool is_null()
const {
return flags_ & tf_null; }
94 bool is_unsigned()
const {
return flags_ & tf_unsigned; }
96 const char* sql_name_;
97 const std::type_info* c_type_;
98 const enum_field_types base_type_;
99 const unsigned int flags_;
105 bool operator() (
const std::type_info* lhs,
106 const std::type_info* rhs)
const 108 return lhs->before(*rhs) != 0;
112 class MYSQLPP_EXPORT mysql_ti_sql_type_info_lookup
115 friend class mysql_type_info;
117 typedef mysql_ti_sql_type_info sql_type_info;
118 typedef std::map<const std::type_info*, unsigned char, type_info_cmp>
121 mysql_ti_sql_type_info_lookup(
const sql_type_info types[],
124 const unsigned char& operator [](
125 const std::type_info& ti)
const 127 map_type::const_iterator it = map_.find(&ti);
128 if (it != map_.end()) {
132 std::ostringstream outs;
133 outs <<
"Failed to find MySQL C API type ID for " << ti.name();
134 throw TypeLookupFailed(outs.str());
141 #endif // !defined(DOXYGEN_IGNORE) 159 num_(static_cast<unsigned char>(-1))
169 bool _null =
false) :
170 num_(type(t, _unsigned, _null))
210 const char*
name()
const {
return deref().c_type_->name(); }
215 const char*
sql_name()
const {
return deref().sql_name_; }
221 const std::type_info&
c_type()
const {
return *deref().c_type_; }
248 bool quote_q()
const;
255 bool escape_q()
const;
263 return num_ < b.num_;
270 static const enum_field_types string_type =
271 #if MYSQL_VERSION_ID > 40000 278 typedef mysql_ti_sql_type_info sql_type_info;
279 typedef mysql_ti_sql_type_info_lookup sql_type_info_lookup;
281 static const sql_type_info types[];
282 static const int num_types;
284 static const sql_type_info_lookup lookups;
304 static unsigned char type(enum_field_types t,
305 bool _unsigned,
bool _null =
false);
307 const sql_type_info& deref()
const 318 return a.
id() == b.
id();
324 return a.
id() != b.
id();
357 #endif // !defined(MYSQLPP_TYPE_INFO_H) const char * sql_name() const
Returns the name of the SQL type.
Definition: type_info.h:215
bool operator !=(const mysql_type_info &a, const mysql_type_info &b)
Returns true if two mysql_type_info objects are not equal.
Definition: type_info.h:322
SQL field type information.
Definition: type_info.h:148
int id() const
Returns the ID of the SQL type.
Definition: type_info.h:238
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:228
Declares the MySQL++-specific exception classes.
const char * name() const
Returns an implementation-defined name of the C++ type.
Definition: type_info.h:210
mysql_type_info(const std::type_info &t)
Create object from a C++ type_info object.
Definition: type_info.h:184
This file includes top-level definitions for use both internal to the library, and outside it....
mysql_type_info()
Default constructor.
Definition: type_info.h:158
const std::type_info & c_type() const
Returns the type_info for the C++ type associated with the SQL type.
Definition: type_info.h:221
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:168
mysql_type_info(const mysql_type_info &t)
Create object as a copy of another.
Definition: type_info.h:175
bool before(mysql_type_info &b)
Provides a way to compare two types for sorting.
Definition: type_info.h:261