#include <SQLField.h>
Inheritance diagram for clawsoft::SQLField:
The purpose of SQLField is to provide a multitype container, because we need to translate the data that is coming from the ResultSet on a select statement we need to provide a way to ensure a safe translation of the data provided.
Public Types | |
enum | SQLtypes { TINYINT = 1, INTEGER = 2, BIGINT = 3, FLOAT = 4, DOUBLE = 5, CHAR = 6, VARCHAR = 7, STRING = 8, BLOB = 9, TEXT = 10, DATE = 11, TIME = 12, TIMESTAMP = 13, BIT = 14, BYTE = 15 } |
This enumeration holds all SQL compatible datatypes, this compatible datatypes must also coincide with C/C++ and/or clawlib's previously defined datatypes. More... | |
Public Methods | |
SQLField (const void *data, const Uint32 size) | |
This will instatiate an SQLResultSet attempting to guess the datatype based on the size in bytes, data is pointer to the buffer containing the the value returned in the current cell from the selected row in the ResultSet. | |
SQLField (const int type, const void *data, const Uint32 size) | |
This constructor will instatiate a new object of this class followed by an specified type, data pointer and a given pointer size. | |
~SQLField () | |
This destructor will release any used buffeasr and reset all internal stored data. | |
Sint16 | toTinyInt () |
This will convert the data stored on this object to an Sint16 which is a signed integer of 16 bits (2 bytes) length. | |
Uint16 | toUTinyInt () |
Is the same as toTinyInt but instead of returning a signed quantity this method returns an unsigned one. | |
Sint32 | toInteger () |
Returns the data as a 32 bit (4 bytes) signed integer. | |
Uint32 | toUInteger () |
Is the same as toInteger but instead of returning a signed quantity this method returns an unsigned one. | |
Sint64 | toBigInt () |
Returns the data as a 64 bit (8 bytes) signed integer. | |
Uint64 | toUBigInt () |
Is the same as clawsoft::SQLResultSet::toBigInt but instead of returning a signed quantity this method returns an unsigned one. | |
float | toFloat () |
Returns the data as a 32 bit (4 bytes) floating number conforming to the IEEE 754 standard. | |
double | toDouble () |
Returns the data as a 64 bit (8 bytes) floating number conforming to the IEEE 754 standard. | |
const char * | toChar () |
Returns the data as a null-terminated string of char, len is the length of the string. | |
const String * | toString () |
Returns the data as a String if the data is numeric then it will be translated also if it is a Date, Time Byte, Bit or Timestamp. | |
const String * | toText () |
Returns the data as a String if the data is numeric then it will be translated also if it is a Date, Time Byte, Bit or Timestamp. | |
const void * | toBLOB () |
This will return a void data pointer, please take special care with BLOBs and try not to pass their addressing limits, please use allways the size(); method in order know the size of the current BLOB. | |
const Date * | toDate () |
This method will convert and return the data as a Date pointer. | |
const Time * | toTime () |
This method will convert and return the data as a Time pointer. | |
const Timestamp * | toTimestamp () |
This method will convert and return the data as a Timestamp pointer. | |
bool | toBit () |
This method will return 0 or 1, a boolean value according to the stored data pointer. | |
const Byte * | toByte () |
With this method ou will get the first byte of the stored data pointer. | |
const int | getDatatype () |
Returns a constant like SQLtypes describing the datatype currently stored. | |
const Uint32 | size () |
Returns the size in bytes of the currently stored object. | |
const Uint32 | dataSize () |
Returns the size in bytes of the currently stored object. | |
void | setFieldName (const String &nam) |
This will set the column name to nam. | |
const String & | getFieldName () |
This will the name for this field as configured during the table creation. | |
const char * | getClassName () |
Returns the name of the current class. | |
Protected Methods | |
void | setClassName (const char *n) |
Call this method when you need to set the name of the class you're creating, typically in it's constructor, remember that you must set the classname for every class you create, that way you can have more information while debugging. |
|
This enumeration holds all SQL compatible datatypes, this compatible datatypes must also coincide with C/C++ and/or clawlib's previously defined datatypes.
|
|
This will instatiate an SQLResultSet attempting to guess the datatype based on the size in bytes, data is pointer to the buffer containing the the value returned in the current cell from the selected row in the ResultSet.
|
|
This constructor will instatiate a new object of this class followed by an specified type, data pointer and a given pointer size. type must be one of the above SQLtypes |
|
This destructor will release any used buffeasr and reset all internal stored data.
|
|
Returns the size in bytes of the currently stored object.
|
|
Returns the name of the current class.
|
|
Returns a constant like SQLtypes describing the datatype currently stored.
|
|
This will the name for this field as configured during the table creation.
|
|
Call this method when you need to set the name of the class you're creating, typically in it's constructor, remember that you must set the classname for every class you create, that way you can have more information while debugging.
|
|
This will set the column name to nam.
|
|
Returns the size in bytes of the currently stored object.
|
|
Returns the data as a 64 bit (8 bytes) signed integer. If the data on this cell is coming from a TEXT or VARCHAR column type then be prepared to receive the NumberException exception if there is a non numeric character contained in there. Also the BufferTooSmallException may be thrown if the number of digits is bigger than 20. |
|
This method will return 0 or 1, a boolean value according to the stored data pointer.
|
|
This will return a void data pointer, please take special care with BLOBs and try not to pass their addressing limits, please use allways the size(); method in order know the size of the current BLOB.
|
|
With this method ou will get the first byte of the stored data pointer.
|
|
Returns the data as a null-terminated string of char, len is the length of the string.
|
|
This method will convert and return the data as a Date pointer.
|
|
Returns the data as a 64 bit (8 bytes) floating number conforming to the IEEE 754 standard. If the data on this cell is coming from a TEXT or VARCHAR column type then be prepared to receive the NumberException exception if there is a non numeric character different from + - or E. Also the BufferTooSmallException may be thrown if the number of digits is bigger than 20 plus 3 for the exponent and 2 more for signs. |
|
Returns the data as a 32 bit (4 bytes) floating number conforming to the IEEE 754 standard. If the data on this cell is coming from a TEXT or VARCHAR column type then be prepared to receive the NumberException exception if there is a non numeric character different from + - or E. Also the BufferTooSmallException may be thrown if the number of digits is bigger than 10 plus 3 for the exponent and 2 more for signs. |
|
Returns the data as a 32 bit (4 bytes) signed integer. If the data on this cell is coming from a TEXT or VARCHAR column type then be prepared to receive the NumberException exception if there is a non numeric character contained in there. Also the BufferTooSmallException may be thrown if the number of digits is bigger than 10. |
|
Returns the data as a String if the data is numeric then it will be translated also if it is a Date, Time Byte, Bit or Timestamp.
|
|
Returns the data as a String if the data is numeric then it will be translated also if it is a Date, Time Byte, Bit or Timestamp.
|
|
This method will convert and return the data as a Time pointer.
|
|
This method will convert and return the data as a Timestamp pointer.
|
|
This will convert the data stored on this object to an Sint16 which is a signed integer of 16 bits (2 bytes) length. Be aware that if you try to convert the incorrect data you may be having an overflow of your current storage space, as an example imagine that the SQLField is storing a 32 char VARCHAR, as an Sint16 your limits are set between -32768 and 32767 so even if the VARCHAR is composed of numeric values you wont have enough space to store the result translation, in this case the BufferTooSmallException is thrown, be carefull with this and try allways to convert the correct datatype. A NumberException is thrown only if the source datatype is of the type VARCHAR, TEXT or STRING and one or more of its characters is NOT a digit |
|
Is the same as clawsoft::SQLResultSet::toBigInt but instead of returning a signed quantity this method returns an unsigned one.
|
|
Is the same as toInteger but instead of returning a signed quantity this method returns an unsigned one.
|
|
Is the same as toTinyInt but instead of returning a signed quantity this method returns an unsigned one.
|
Authors:
Juan V. Guerrero
Jannette C. Mejia
Juan C. Guevara
Powered by: