column description More...
#include <mysqlpl.h>

Public Member Functions | |
| ColumnType () | |
| std::string | get_type_str (bool show_null=false) const |
| void | init (const MYSQL_FIELD *) |
Public Attributes | |
| std::string | _table_name |
| std::string | _name |
| enum_field_types | _data_type |
| int | _width |
| int | _decimals |
| int | _flags |
column description
Definition at line 314 of file mysqlpl.h.
| MySqlPL::ColumnType::ColumnType | ( | ) | [inline] |
Definition at line 323 of file mysqlpl.h.
References _data_type, _decimals, _flags, and _width.
{
_data_type = (enum_field_types)-1;
_width = 0;
_decimals = 0;
_flags = 0;
}
| std::string MySqlPL::ColumnType::get_type_str | ( | bool | show_null = false ) |
const |
Definition at line 366 of file mysqlpl.cpp.
References _data_type, _decimals, _flags, _width, MYSQL_TYPE_BLOB, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TIME, MYSQL_TYPE_TINY, MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_VAR_STRING, and MYSQL_TYPE_YEAR.
Referenced by MySqlPL::SqlRecord::print_columns().
{
std::ostringstream str;
switch(_data_type) {
case MYSQL_TYPE_STRING:
str << "char(" << _width << ")";
break;
case MYSQL_TYPE_VAR_STRING:
str << "varchar(" << _width << ")";
break;
case MYSQL_TYPE_DECIMAL:
if (_width == 0)
str << "decimal";
else
str << "decimal(" << (_width-1) << "," << _decimals << ")";
break;
#if MYSQL_VERSION_ID>=50000
case MYSQL_TYPE_NEWDECIMAL:
if (_width == 0)
str << "newdecimal";
else
str << "newdecimal(" << (_width-1) << "," << _decimals << ")";
break;
#endif
case MYSQL_TYPE_TINY:
str << "tinyint(" << _width << ")";
break;
case MYSQL_TYPE_SHORT:
str << "shortint(" << _width << ")";
break;
case MYSQL_TYPE_LONG:
str << "int(" << _width << ")";
break;
case MYSQL_TYPE_LONGLONG:
str << "bigint(" << _width << ")";
break;
#ifdef FIELD_TYPE_ENUM
case FIELD_TYPE_ENUM:
str << "enum";
break;
#endif
case MYSQL_TYPE_FLOAT:
if (_width == 12)
str << "float";
else
str << "float(" << _width << "," << _decimals << ")";
break;
case MYSQL_TYPE_DOUBLE:
if (_width == 22)
str << "double";
else
str << "double(" << _width << "," << _decimals << ")";
break;
case MYSQL_TYPE_DATE:
str << "date";
break;
#if MYSQL_VERSION_ID>=50000
case MYSQL_TYPE_NEWDATE:
str << "newdate";
break;
#endif
case MYSQL_TYPE_DATETIME:
str << "datetime";
break;
case MYSQL_TYPE_TIME:
str << "time";
break;
case MYSQL_TYPE_YEAR:
str << "year(" << _width << ")";
break;
case MYSQL_TYPE_TINY_BLOB:
if (_flags & BINARY_FLAG)
str << "tinyblob";
else
str << "tinytext";
break;
case MYSQL_TYPE_MEDIUM_BLOB:
if (_flags & BINARY_FLAG)
str << "mediumblob";
else
str << "mediumtext";
break;
case MYSQL_TYPE_LONG_BLOB:
if (_flags & BINARY_FLAG)
str << "longblob";
else
str << "longtext";
break;
case MYSQL_TYPE_BLOB:
if (_flags & BINARY_FLAG)
str << "blob";
else
str << "text";
break;
default:
str << "unknown";
}
if (show_null)
if (IS_NOT_NULL(_flags))
str << " not null";
else
str << " null";
return str.str();
}

| void MySqlPL::ColumnType::init | ( | const MYSQL_FIELD * | field ) |
Definition at line 795 of file mysqlpl.cpp.
References _data_type, _decimals, _flags, _name, _table_name, and _width.
Referenced by MySqlPL::SqlStatement::get_column_type().
{
// get column name
_table_name = field->table;
_name = field->name;
// get column data type
_data_type = field->type;
_width = field->length;
_decimals = field->decimals;
// get NULL-ability, binary, ... flags
_flags = field->flags;
}

| enum_field_types MySqlPL::ColumnType::_data_type |
Definition at line 318 of file mysqlpl.h.
Referenced by ColumnType(), get_type_str(), and init().
Definition at line 320 of file mysqlpl.h.
Referenced by ColumnType(), get_type_str(), and init().
Definition at line 321 of file mysqlpl.h.
Referenced by ColumnType(), get_type_str(), and init().
| std::string MySqlPL::ColumnType::_name |
Definition at line 317 of file mysqlpl.h.
Referenced by init(), MySqlPL::SqlRecord::print_columns(), and MySqlPL::SqlRecord::print_values().
| std::string MySqlPL::ColumnType::_table_name |
Definition at line 316 of file mysqlpl.h.
Referenced by init(), and MySqlPL::SqlRecord::print_columns().
Definition at line 319 of file mysqlpl.h.
Referenced by ColumnType(), get_type_str(), and init().
1.7.2