MySQL++  3.3.0
Public Member Functions | Static Public Attributes | List of all members
mysqlpp::mysql_type_info Class Reference

SQL field type information. More...

#include <type_info.h>

Public Member Functions

 mysql_type_info ()
 Default constructor. More...
 
 mysql_type_info (enum_field_types t, bool _unsigned=false, bool _null=false)
 Create object from MySQL C API type info. More...
 
 mysql_type_info (const mysql_type_info &t)
 Create object as a copy of another.
 
 mysql_type_info (const std::type_info &t)
 Create object from a C++ type_info object. More...
 
mysql_type_infooperator= (const mysql_type_info &t)
 Assign another mysql_type_info object to this object.
 
mysql_type_infooperator= (const std::type_info &t)
 Assign a C++ type_info object to this object. More...
 
const char * name () const
 Returns an implementation-defined name of the C++ type. More...
 
const char * sql_name () const
 Returns the name of the SQL type. More...
 
const std::type_info & c_type () const
 Returns the type_info for the C++ type associated with the SQL type. More...
 
const mysql_type_info base_type () const
 Returns the type_info for the C++ type inside of the mysqlpp::Null type. More...
 
int id () const
 Returns the ID of the SQL type. More...
 
bool quote_q () const
 Returns true if the SQL type is of a type that needs to be quoted. More...
 
bool escape_q () const
 Returns true if the SQL type is of a type that needs to be escaped. More...
 
bool before (mysql_type_info &b)
 Provides a way to compare two types for sorting. More...
 

Static Public Attributes

static const enum_field_types string_type
 The internal constant we use for our string type. More...
 

Detailed Description

SQL field type information.

Constructor & Destructor Documentation

◆ mysql_type_info() [1/3]

mysqlpp::mysql_type_info::mysql_type_info ( )
inline

Default constructor.

This only exists because FieldTypes keeps a vector of these objects. You are expected to copy real values into it before using it via the copy ctor or one of the assignment operators. If you don't, we have arranged a pretty spectacular crash for your program. So there.

◆ mysql_type_info() [2/3]

mysqlpp::mysql_type_info::mysql_type_info ( enum_field_types  t,
bool  _unsigned = false,
bool  _null = false 
)
inline

Create object from MySQL C API type info.

Parameters
tthe underlying C API type ID for this type
_unsignedif true, this is the unsigned version of the type
_nullif true, this type can hold a SQL null

◆ mysql_type_info() [3/3]

mysqlpp::mysql_type_info::mysql_type_info ( const std::type_info &  t)
inline

Create object from a C++ type_info object.

This tries to map a C++ type to the closest MySQL data type. It is necessarily somewhat approximate.

Member Function Documentation

◆ base_type()

const mysql_type_info mysqlpp::mysql_type_info::base_type ( ) const
inline

Returns the type_info for the C++ type inside of the mysqlpp::Null type.

Returns the type_info for the C++ type inside the mysqlpp::Null type. If the type is not Null then this is the same as c_type().

Referenced by mysqlpp::SQLBuffer::quote_q().

◆ before()

bool mysqlpp::mysql_type_info::before ( mysql_type_info b)
inline

Provides a way to compare two types for sorting.

Returns true if the SQL ID of this type is lower than that of another. Used by mysqlpp::type_info_cmp when comparing types.

◆ c_type()

const std::type_info& mysqlpp::mysql_type_info::c_type ( ) const
inline

Returns the type_info for the C++ type associated with the SQL type.

Returns the C++ type_info record corresponding to the SQL type.

Referenced by mysqlpp::operator!=(), mysqlpp::operator==(), and mysqlpp::SQLBuffer::quote_q().

◆ escape_q()

bool mysqlpp::mysql_type_info::escape_q ( ) const

Returns true if the SQL type is of a type that needs to be escaped.

Returns
true if the type needs to be escaped for syntactically correct SQL.

Referenced by mysqlpp::String::escape_q(), and mysqlpp::SQLBuffer::escape_q().

◆ id()

int mysqlpp::mysql_type_info::id ( ) const
inline

Returns the ID of the SQL type.

Returns the ID number MySQL uses for this type. Note: Do not depend on the value of this ID as it may change between MySQL versions.

Referenced by mysqlpp::operator!=(), mysqlpp::operator==(), and mysqlpp::SQLTypeAdapter::type_id().

◆ name()

const char* mysqlpp::mysql_type_info::name ( ) const
inline

Returns an implementation-defined name of the C++ type.

Returns the name that would be returned by typeid().name() for the C++ type associated with the SQL type.

◆ operator=()

mysql_type_info& mysqlpp::mysql_type_info::operator= ( const std::type_info &  t)
inline

Assign a C++ type_info object to this object.

This tries to map a C++ type to the closest MySQL data type. It is necessarily somewhat approximate.

◆ quote_q()

bool mysqlpp::mysql_type_info::quote_q ( ) const

Returns true if the SQL type is of a type that needs to be quoted.

Returns
true if the type needs to be quoted for syntactically correct SQL.

Referenced by mysqlpp::String::quote_q(), and mysqlpp::SQLBuffer::quote_q().

◆ sql_name()

const char* mysqlpp::mysql_type_info::sql_name ( ) const
inline

Returns the name of the SQL type.

Returns the SQL name for the type.

Member Data Documentation

◆ string_type

const enum_field_types mysqlpp::mysql_type_info::string_type
static
Initial value:
=
FIELD_TYPE_STRING

The internal constant we use for our string type.

We expose this because other parts of MySQL++ need to know what the string constant is at the moment.

Referenced by mysqlpp::SQLTypeAdapter::assign(), mysqlpp::SQLBuffer::is_string(), mysqlpp::String::it_is_null(), mysqlpp::String::operator=(), and mysqlpp::String::type().


The documentation for this class was generated from the following files: