#include <coldata.h>
Collaboration diagram for mysqlpp::ColData_Tmpl< Str >:
Public Methods | |
ColData_Tmpl () | |
Default constructor. | |
mysql_type_info | type () const |
Get this object's current MySQL type. | |
bool | quote_q () const |
Returns true if data of this type should be quoted, false otherwise. | |
bool | escape_q () const |
Returns true if data of this type should be escaped, false otherwise. | |
template<class Type> Type | conv (Type dummy) const |
Template for converting data from one type to another. | |
void | it_is_null () |
Set a flag indicating that this object is a SQL null. | |
const bool | is_null () const |
Returns true if this object is a SQL null. | |
const std::string & | get_string () const |
Returns the string form of this object's data. | |
operator cchar * () const | |
Returns a const char pointer to the string form of this object's data. | |
operator signed char () const | |
Converts this object's string data to a signed char. | |
operator unsigned char () const | |
Converts this object's string data to an unsigned char. | |
operator int () const | |
Converts this object's string data to an int. | |
operator unsigned int () const | |
Converts this object's string data to an unsigned int. | |
operator short int () const | |
Converts this object's string data to a short int. | |
operator unsigned short int () const | |
Converts this object's string data to an unsigned short int. | |
operator long int () const | |
Converts this object's string data to a long int. | |
operator unsigned long int () const | |
Converts this object's string data to an unsigned long int. | |
operator longlong () const | |
Converts this object's string data to the platform- specific 'longlong' type, usually a 64-bit integer. | |
operator ulonglong () const | |
Converts this object's string data to the platform- specific 'ulonglong' type, usually a 64-bit unsigned integer. | |
operator float () const | |
Converts this object's string data to a float. | |
operator double () const | |
Converts this object's string data to a double. |
This template is used to construct std::string-like classes with additional MySQL-related smarts. It is for taking data from the MySQL database, which is always in string form, and converting it to any of the basic C types.
These conversions are implicit, so you can do things like this:
ColData("12.86") + 2.0
But be careful. If you had said this instead:
ColData("12.86") + 2
the result would be 14 because 2 is an integer, so the string data is converted to that same type before the binary operator is applied.
If these automatic conversions scare you, define the micro NO_BINARY_OPERS to disable this behavior.
This class also has some basic information about the type of data stored in it, to allow it to do the conversions more intelligently than a trivial implementation would allow.
Do not use this class directly. Use the typedef ColData or MutableColData instead.