#include <stadapter.h>
Collaboration diagram for mysqlpp::SQLTypeAdapter:
Public Types | |
typedef size_t | size_type |
size of length values | |
Public Member Functions | |
SQLTypeAdapter () | |
Default constructor; empty string. | |
SQLTypeAdapter (const SQLTypeAdapter &other) | |
Copy ctor. | |
SQLTypeAdapter (const String &str, bool processed=false) | |
Create a copy of a MySQL++ string. | |
SQLTypeAdapter (const std::string &str, bool processed=false) | |
Create a copy of a C++ string. | |
SQLTypeAdapter (const char *str, bool processed=false) | |
Create a copy of a null-terminated C string. | |
SQLTypeAdapter (const char *str, int len, bool processed=false) | |
Create a copy of an arbitrary block of data. | |
SQLTypeAdapter (char c) | |
Create a single-character string. | |
SQLTypeAdapter (sql_tinyint i) | |
Create a string representation of SQL TINYINT . | |
SQLTypeAdapter (sql_tinyint_unsigned i) | |
Create a string representation of SQL TINYINT UNSIGNED . | |
SQLTypeAdapter (short i) | |
Create a string representation of a short int value. | |
SQLTypeAdapter (unsigned short i) | |
Create a string representation of an unsigned short int value. | |
SQLTypeAdapter (int i) | |
Create a string representation of an int value. | |
SQLTypeAdapter (unsigned i) | |
Create a string representation of an unsigned int value. | |
SQLTypeAdapter (long i) | |
Create a string representation of a long int value. | |
SQLTypeAdapter (unsigned long i) | |
Create a string representation of an unsigned long int value. | |
SQLTypeAdapter (longlong i) | |
Create a string representation of a longlong value. | |
SQLTypeAdapter (ulonglong i) | |
Create a string representation of an unsigned longlong value. | |
SQLTypeAdapter (float i) | |
Create a string representation of a float value. | |
SQLTypeAdapter (double i) | |
Create a string representation of a double value. | |
SQLTypeAdapter (const Date &d) | |
Create a SQL string representation of a date. | |
SQLTypeAdapter (const DateTime &dt) | |
Create a SQL string representation of a date and time. | |
SQLTypeAdapter (const Time &t) | |
Create a SQL string representation of a time. | |
SQLTypeAdapter (const null_type &i) | |
Create object representing SQL NULL. | |
SQLTypeAdapter & | operator= (const SQLTypeAdapter &rhs) |
Standard assignment operator. | |
SQLTypeAdapter & | operator= (const null_type &n) |
Replace contents of object with a SQL null. | |
operator const char * () const | |
Returns a const char pointer to the object's raw data. | |
SQLTypeAdapter & | assign (const SQLTypeAdapter &sta) |
Copies another SQLTypeAdapter's data buffer into this object. | |
SQLTypeAdapter & | assign (const char *pc, int len=-1) |
Copies a C string or a raw buffer into this object. | |
SQLTypeAdapter & | assign (const null_type &n) |
Replaces contents of object with a SQL null. | |
char | at (size_type i) const throw (std::out_of_range) |
Returns the character at a given position within the string buffer. | |
int | compare (const SQLTypeAdapter &other) const |
Compare the internal buffer to the given string. | |
int | compare (const std::string &other) const |
Compare the internal buffer to the given string. | |
int | compare (size_type pos, size_type num, std::string &other) const |
Compare the internal buffer to the given string. | |
int | compare (const char *other) const |
Compare the internal buffer to the given string. | |
int | compare (size_type pos, size_type num, const char *other) const |
Compare the internal buffer to the given string. | |
const char * | data () const |
Return pointer to raw data buffer. | |
bool | escape_q () const |
Returns true if we were initialized with a data type that must be escaped when used in a SQL query. | |
bool | is_processed () const |
Returns true if the internal 'processed' flag is set. | |
size_type | length () const |
Return number of bytes in data buffer. | |
size_type | size () const |
alias for length() | |
bool | quote_q () const |
Returns true if we were initialized with a data type that must be quoted when used in a SQL query. | |
int | type_id () const |
Returns the type ID of the buffer's data. | |
void | set_processed () |
Turns on the internal 'is_processed_' flag. |
This class provides implicit conversion between many C++ types and SQL-formatted string representations of that data without losing important type information. This class is not for direct use outside MySQL++ itself. It exists for those interfaces in MySQL++ that need to accept a value of any reasonable data type which it will use in building a query string.
One major use for this is in the Query class interfaces for building template queries: they have to be generic with respect to argument type, but because we know we want the data in some kind of string form eventually, we don't need to templatize it. The interface can just use SQLTypeAdapter, which lets callers pass any reasonable data type. The adapter converts the passed value implicitly.
The other major use for this type is the quoting and escaping logic in Query's stream interface: rather than overload the << operators and the manipulators for every single type we know the rules for a priori, we just specialize the manipulators for SQLTypeAdapter. The conversion to SQLTypeAdapter stringizes the data, which we needed anyway for stream insertion, and holds enough type information so that the manipulator can decide whether to do automatic quoting and/or escaping.
|
Copy ctor.
|
|
Create a copy of a MySQL++ string. This does reference-counted buffer sharing with the other object. If you need a deep copy, pass the result of either String::c_str() or String::conv() instead, which will call one of the other string ctors. |
|
Create a single-character string.
If you mean for |
|
Replaces contents of object with a SQL null.
|
|
Copies a C string or a raw buffer into this object.
|
|
Copies another SQLTypeAdapter's data buffer into this object.
|
|
Returns the character at a given position within the string buffer.
|
|
Compare the internal buffer to the given string. Works just like string::compare(size_type, size_type, const char*). |
|
Compare the internal buffer to the given string. Works just like string::compare(const char*). |
|
Compare the internal buffer to the given string. Works just like string::compare(size_type, size_type, std::string&). |
|
Compare the internal buffer to the given string. Works just like string::compare(const std::string&). |
|
Compare the internal buffer to the given string. Works just like string::compare(const std::string&). |
|
Returns true if the internal 'processed' flag is set. This is an implementation detail of template queries, used to prevent repeated processing of values. |
|
Replace contents of object with a SQL null.
|
|
Standard assignment operator.
|
|
Turns on the internal 'is_processed_' flag. This is an implementation detail of template queries, used to prevent repeated processing of values. |
|
Returns the type ID of the buffer's data. Values from type_info.h. At the moment, these are the same as the underlying MySQL C API type IDs, but it's not a good idea to count on this remaining the case. |