Field.h

Go to the documentation of this file.
00001 /*
00002  * $Id:Field.h 540 2007-08-20 07:51:56Z mindstorm2600 $
00003  *
00004  * X-VR2 
00005  * 
00006  * Copyright (C) Juan V. Guerrero 2007
00007  * 
00008  * Juan V. Guerrero <mindstorm2600@users.sourceforge.net>
00009  * 
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License Version 2. See the LICENSE file
00012  * at the top of the source tree.
00013  */
00014 #ifndef __XVR2_SQL_FIELD_H__
00015 #define __XVR2_SQL_FIELD_H__
00016 
00017 #include<xvr2/xvr2config.h>
00018 #include<xvr2/Date.h>
00019 #include<xvr2/Time.h>
00020 #include<xvr2/Timestamp.h>
00021 #include<xvr2/Byte.h>
00022 #include<xvr2/String.h>
00023 #include<xvr2/CoreExceptions.h>
00024 #include<xvr2/SQL/Driver.h>
00025 
00026 namespace xvr2{
00027         namespace SQL {
00036                 class Field:public Object{
00037                         private:
00038                                 void            *dataPtr;
00039                                 UInt32          dataLen;
00040                                 int             dataType;
00041                                 //Temporary char pointers for datatypes
00042                                 char            *tmpStrTINYINT;
00043                                 char            *tmpStrINTEGER;
00044                                 char            *tmpStrBIGINT;
00045                                 char            *tmpStrFLOAT;
00046                                 char            *tmpStrDOUBLE;
00047                                 char            *tmpStrBIT;
00048                                 char            *tmpStrBYTE;
00049 
00050                                 String          tmpString;
00051                                 /*String                tmpStringTINYINT;
00052                                 String          tmpStringINTEGER;
00053                                 String          tmpStringBIGINT;
00054                                 String          tmpStringFLOAT;
00055                                 String          tmpStringDOUBLE;
00056                                 String          tmpStringBIT;
00057                                 String          tmpStringBYTE;*/
00058 
00059                                 Date            *tmpDate;
00060                                 Time            *tmpTime;
00061                                 Timestamp       *tmpTimestamp;
00062                                 Byte            *tmpByte;
00063                                 bool            *tmpBool;
00064                                 Int16           *tmpInt16;
00065                                 Int32           *tmpInt32;
00066                                 Int64           *tmpInt64;
00067                                 float           *tmpFloat;
00068                                 double          *tmpDouble;
00069                                 String          colname;
00070                         public:
00071                                 Driver *drv;
00075                                 enum SQLtypes{
00077                                         TINYINT   = 1, 
00079                                         INTEGER   = 2,
00082                                         BIGINT    = 3,
00084                                         FLOAT     = 4,
00086                                         DOUBLE    = 5,
00089                                         CHAR      = 6,
00092                                         VARCHAR   = 7,
00095                                         STRING    = 8,
00103                                         BLOB      = 9,
00108                                         TEXT      = 10,
00111                                         DATE      = 11,
00114                                         TIME      = 12,
00117                                         TIMESTAMP = 13,
00121                                         BIT       = 14,
00123                                         BYTE      = 15
00124                                 };
00126                                 Field();
00132                                 Field(const void *data, const UInt32 size);
00137                                 Field(const int type, const void *data, const UInt32 size);
00142                                 void init(const int type, const void *data, const UInt32 size);
00143                                 /*void init(const int type, const bool data, const UInt32 size);
00144                                 void init(const int type, const int data, const UInt32 size);
00145                                 void init(const int type, const int data, const UInt32 size);*/
00148                                 ~Field();
00164                                 Int16           toTinyInt() const;
00167                                 UInt16          toUTinyInt() const;
00176                                 Int32           toInteger() const;
00179                                 UInt32          toUInteger() const;
00188                                 Int64           toBigInt() const;
00192                                 UInt64          toUBigInt() const;
00203                                 float           toFloat() const;
00214                                 double          toDouble() const;
00217                                 char    *toChar() const;
00221                                 std::string toString() const;
00225                                 const String    &toText() const;
00230                                 const void      *toBLOB();
00233                                 const Date      *toDate();
00236                                 const Time      *toTime();
00239                                 Timestamp       toTimestamp();
00240                                 Timestamp       toTimestamp() const;
00243                                 bool            toBit() const;
00246                                 bool            toBool() const;
00249                                 const Byte      *toByte();
00252                                 const int       getDatatype();
00255                                 const int       getDatatype() const;
00258                                 const UInt32    size();
00261                                 const UInt32    size() const;
00264                                 const UInt32    dataSize();
00267                                 const UInt32    dataSize() const;
00269                                 void setFieldName(const String &nam);
00272                                 const String &getFieldName() const;
00273                                 bool isNull() const;
00274                 };
00275         };
00276 };
00277 
00278 #endif

Generated on Fri Jun 20 22:55:48 2008 for X-VR2 SDK by  doxygen 1.5.5