AllDataType Class Reference

#include <DataType.h>


Static Public Member Functions

static long size (DataType type, int length=0)
static char * getSQLString (DataType type)
static SQLSMALLINT convertToSQLType (DataType type)
static SQLSMALLINT convertToSQL_C_Type (DataType type)
static DataType convertFromSQLType (SQLSMALLINT type)
static void copyVal (void *dest, void *src, DataType type, int length=0)
static bool compareVal (void *src1, void *src2, ComparisionOp op, DataType type, long length=0)
static bool compareIntVal (void *src1, void *src2, ComparisionOp op)
static bool compareLongVal (void *src1, void *src2, ComparisionOp op)
static bool compareLongLongVal (void *src1, void *src2, ComparisionOp op)
static bool compareShortVal (void *src1, void *src2, ComparisionOp op)
static bool compareByteIntVal (void *src1, void *src2, ComparisionOp op)
static bool compareDoubleVal (void *src1, void *src2, ComparisionOp op)
static bool compareFloatVal (void *src1, void *src2, ComparisionOp op)
static bool compareDateVal (void *src1, void *src2, ComparisionOp op)
static bool compareTimeVal (void *src1, void *src2, ComparisionOp op)
static bool compareTimeStampVal (void *src1, void *src2, ComparisionOp op)
static bool compareStringVal (void *src1, void *src2, ComparisionOp op)
static bool compareBinaryVal (void *src1, void *src2, ComparisionOp op, int length)
static void convert (DataType srcType, void *src, DataType destType, void *dest)
static void convertToInt (void *dest, void *src, DataType srcType)
static void convertToLong (void *dest, void *src, DataType srcType)
static void convertToLongLong (void *dest, void *src, DataType srcType)
static void convertToShort (void *dest, void *src, DataType srcType)
static void convertToByteInt (void *dest, void *src, DataType srcType)
static void convertToFloat (void *dest, void *src, DataType srcType)
static void convertToDouble (void *dest, void *src, DataType srcType)
static void convertToString (void *dest, void *src, DataType srcType)
static void convertToDate (void *dest, void *src, DataType srcType)
static void convertToTime (void *dest, void *src, DataType srcType)
static void convertToTimeStamp (void *dest, void *src, DataType srcType)
static ComparisionOp getComparisionOperator (char *str)
static void * alloc (DataType type, int length=0)
static void strToValue (void *dest, char *src, DataType type, int length=0)
static int printVal (void *src, DataType type, int length)


Detailed Description

Definition at line 82 of file DataType.h.


Member Function Documentation

void * AllDataType::alloc ( DataType  type,
int  length = 0 
) [static]

Definition at line 999 of file DataType.cxx.

References typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by insert(), CacheTableLoader::load(), SqlLogStatement::prepare(), SqlOdbcStatement::prepare(), SqlNetworkHandler::processPrepare(), SelStatement::resolve(), InsStatement::resolve(), UpdStatement::resolveForAssignment(), and DelStatement::resolveForCondition().

01000 {
01001     void *dest;
01002     switch(type)
01003     {
01004         case typeInt:
01005             dest = malloc(sizeof(int));
01006             break;
01007         case typeLong:
01008             dest = malloc(sizeof(long));
01009             break;
01010         case typeLongLong:
01011             dest = malloc(sizeof(long long));
01012             break;
01013         case typeShort:
01014             dest = malloc(sizeof(short));
01015             break;
01016         case typeByteInt:
01017             dest = malloc(sizeof(char));
01018             break;
01019         case typeDouble:
01020             dest = malloc(sizeof(double));
01021             break;
01022         case typeFloat:
01023             dest = malloc(sizeof(float));
01024             break;
01025         case typeDecimal:
01026             //TODO::for porting
01027             //fldDef.length_ = sizeof(long double);
01028             break;
01029         case typeString:
01030             if (length == 0 ) return NULL;
01031             dest = malloc(length);
01032             break;
01033         case typeDate:
01034             dest = malloc(sizeof(Date));
01035             break;
01036         case typeTime:
01037             dest = malloc(sizeof(Time));
01038             break;
01039         case typeTimeStamp:
01040             dest = malloc(sizeof(TimeStamp));
01041             break;
01042     }
01043     return dest;
01044 }

Here is the caller graph for this function:

bool AllDataType::compareBinaryVal ( void *  src1,
void *  src2,
ComparisionOp  op,
int  length 
) [static]

Definition at line 948 of file DataType.cxx.

References os::memcmp(), OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00950 {
00951     bool result = false;
00952     int ret = os::memcmp(src1, src2, length);
00953     switch(op)
00954     {
00955         case OpEquals:
00956             if (ret == 0 ) result= true; else result = false;
00957             break;
00958         case OpNotEquals:
00959             if (ret != 0 ) result= true; else result = false;
00960             break;
00961         case OpLessThan:
00962             if (ret < 0 ) result= true; else result = false;
00963             break;
00964         case OpLessThanEquals:
00965             printf("Illegal Operator:Not Supported for Binary\n");
00966             break;
00967         case OpGreaterThan:
00968             if (ret > 0 ) result= true; else result = false;
00969             break;
00970         case OpGreaterThanEquals:
00971             printf("Illegal Operator:Not Supported for Binary\n");
00972             break;
00973    }
00974    return result;
00975 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool AllDataType::compareByteIntVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 722 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00723 {
00724     bool result = false;
00725     switch(op)
00726     {
00727         case OpEquals:
00728             if (*(ByteInt*)src1 == *(ByteInt*)src2) result = true;
00729             else result = false;
00730             break;
00731         case OpNotEquals:
00732             if (*(ByteInt*)src1 != *(ByteInt*)src2) result = true;
00733             else result = false;
00734             break;
00735         case OpLessThan:
00736             if (*(ByteInt*)src1 < *(ByteInt*)src2) result = true;
00737             else result = false;
00738             break;
00739         case OpLessThanEquals:
00740             if (*(ByteInt*)src1 <= *(ByteInt*)src2) result = true;
00741             else result = false;
00742             break;
00743         case OpGreaterThan:
00744             if (*(ByteInt*)src1 > *(ByteInt*)src2) result = true;
00745             else result = false;
00746             break;
00747         case OpGreaterThanEquals:
00748             if (*(ByteInt*)src1 >= *(ByteInt*)src2) result = true;
00749             else result = false;
00750             break;
00751    }
00752    return result;
00753 }

Here is the caller graph for this function:

bool AllDataType::compareDateVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 821 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00822 {
00823     bool result = false;
00824     switch(op)
00825     {
00826         case OpEquals:
00827             if (*(Date*)src1 == *(Date*)src2) result = true;
00828             else result = false;
00829             break;
00830         case OpNotEquals:
00831             if (*(Date*)src1 != *(Date*)src2) result = true;
00832             else result = false;
00833             break;
00834         case OpLessThan:
00835             if (*(Date*)src1 < *(Date*)src2) result = true;
00836             else result = false;
00837             break;
00838         case OpLessThanEquals:
00839             if (*(Date*)src1 <= *(Date*)src2) result = true;
00840             else result = false;
00841             break;
00842         case OpGreaterThan:
00843             if (*(Date*)src1 > *(Date*)src2) result = true;
00844             else result = false;
00845             break;
00846         case OpGreaterThanEquals:
00847             if (*(Date*)src1 >= *(Date*)src2) result = true;
00848             else result = false;
00849             break;
00850    }
00851    return result;
00852 }

Here is the caller graph for this function:

bool AllDataType::compareDoubleVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 755 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00756 {
00757     bool result = false;
00758     switch(op)
00759     {
00760         case OpEquals:
00761             if (*(double*)src1 == *(double*)src2) result = true;
00762             else result = false;
00763             break;
00764         case OpNotEquals:
00765             if (*(double*)src1 != *(double*)src2) result = true;
00766             else result = false;
00767             break;
00768         case OpLessThan:
00769             if (*(double*)src1 < *(double*)src2) result = true;
00770             else result = false;
00771             break;
00772         case OpLessThanEquals:
00773             if (*(double*)src1 <= *(double*)src2) result = true;
00774             else result = false;
00775             break;
00776         case OpGreaterThan:
00777             if (*(double*)src1 > *(double*)src2) result = true;
00778             else result = false;
00779             break;
00780         case OpGreaterThanEquals:
00781             if (*(double*)src1 >= *(double*)src2) result = true;
00782             else result = false;
00783             break;
00784    }
00785    return result;
00786 }

Here is the caller graph for this function:

bool AllDataType::compareFloatVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 788 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00789 {
00790     bool result = false;
00791     switch(op)
00792     {
00793         case OpEquals:
00794             if (*(float*)src1 == *(float*)src2) result = true;
00795             else result = false;
00796             break;
00797         case OpNotEquals:
00798             if (*(float*)src1 != *(float*)src2) result = true;
00799             else result = false;
00800             break;
00801         case OpLessThan:
00802             if (*(float*)src1 < *(float*)src2) result = true;
00803             else result = false;
00804             break;
00805         case OpLessThanEquals:
00806             if (*(float*)src1 <= *(float*)src2) result = true;
00807             else result = false;
00808             break;
00809         case OpGreaterThan:
00810             if (*(float*)src1 > *(float*)src2) result = true;
00811             else result = false;
00812             break;
00813         case OpGreaterThanEquals:
00814             if (*(float*)src1 >= *(float*)src2) result = true;
00815             else result = false;
00816             break;
00817    }
00818    return result;
00819 }

Here is the caller graph for this function:

bool AllDataType::compareIntVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 587 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00588 {
00589     if (src1 == NULL) printf("src1 is null\n");
00590     if (src2 == NULL) printf("src2 is null\n");
00591     bool result = false;
00592     switch(op)
00593     {
00594         case OpEquals:
00595             if (*(int*)src1 == *(int*)src2) result = true;
00596             else result = false;
00597             break;
00598         case OpNotEquals:
00599             if (*(int*)src1 != *(int*)src2) result = true;
00600             else result = false;
00601             break;
00602         case OpLessThan:
00603             if (*(int*)src1 < *(int*)src2) result = true;
00604             else result = false;
00605             break;
00606         case OpLessThanEquals:
00607             if (*(int*)src1 <= *(int*)src2) result = true;
00608             else result = false;
00609             break;
00610         case OpGreaterThan:
00611             if (*(int*)src1 > *(int*)src2) result = true;
00612             else result = false;
00613             break;
00614         case OpGreaterThanEquals:
00615             if (*(int*)src1 >= *(int*)src2) result = true;
00616             else result = false;
00617             break;
00618    }
00619    return result;
00620 }

Here is the caller graph for this function:

bool AllDataType::compareLongLongVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 655 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00657 {
00658     bool result = false;
00659     switch(op)
00660     {
00661         case OpEquals:
00662             if (*(long long*)src1 == *(long long*)src2) result = true;
00663             else result = false;
00664             break;
00665         case OpNotEquals:
00666             if (*(long long*)src1 != *(long long*)src2) result = true;
00667             else result = false;
00668             break;
00669         case OpLessThan:
00670             if (*(long long*)src1 < *(long long*)src2) result = true;
00671             else result = false;
00672             break;
00673         case OpLessThanEquals:
00674             if (*(long long*)src1 <= *(long long*)src2) result = true;
00675             else result = false;
00676             break;
00677         case OpGreaterThan:
00678             if (*(long long*)src1 > *(long long*)src2) result = true;
00679             else result = false;
00680             break;
00681         case OpGreaterThanEquals:
00682             if (*(long long*)src1 >= *(long long*)src2) result = true;
00683             else result = false;
00684             break;
00685    }
00686    return result;
00687 }

Here is the caller graph for this function:

bool AllDataType::compareLongVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 622 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00623 {
00624     bool result = false;
00625     switch(op)
00626     {
00627         case OpEquals:
00628             if (*(long*)src1 == *(long*)src2) result = true;
00629             else result = false;
00630             break;
00631         case OpNotEquals:
00632             if (*(long*)src1 != *(long*)src2) result = true;
00633             else result = false;
00634             break;
00635         case OpLessThan:
00636             if (*(long*)src1 < *(long*)src2) result = true;
00637             else result = false;
00638             break;
00639         case OpLessThanEquals:
00640             if (*(long*)src1 <= *(long*)src2) result = true;
00641             else result = false;
00642             break;
00643         case OpGreaterThan:
00644             if (*(long*)src1 > *(long*)src2) result = true;
00645             else result = false;
00646             break;
00647         case OpGreaterThanEquals:
00648             if (*(long*)src1 >= *(long*)src2) result = true;
00649             else result = false;
00650             break;
00651    }
00652    return result;
00653 }

Here is the caller graph for this function:

bool AllDataType::compareShortVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 689 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00690 {
00691     bool result = false;
00692     switch(op)
00693     {
00694         case OpEquals:
00695             if (*(short*)src1 == *(short*)src2) result = true;
00696             else result = false;
00697             break;
00698         case OpNotEquals:
00699             if (*(short*)src1 != *(short*)src2) result = true;
00700             else result = false;
00701             break;
00702         case OpLessThan:
00703             if (*(short*)src1 < *(short*)src2) result = true;
00704             else result = false;
00705             break;
00706         case OpLessThanEquals:
00707             if (*(short*)src1 <= *(short*)src2) result = true;
00708             else result = false;
00709             break;
00710         case OpGreaterThan:
00711             if (*(short*)src1 > *(short*)src2) result = true;
00712             else result = false;
00713             break;
00714         case OpGreaterThanEquals:
00715             if (*(short*)src1 >= *(short*)src2) result = true;
00716             else result = false;
00717             break;
00718    }
00719    return result;
00720 }

Here is the caller graph for this function:

bool AllDataType::compareStringVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 920 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00921 {
00922     bool result = false;
00923     int ret = strcmp((char*)src1, (char*)src2);
00924     switch(op)
00925     {
00926         case OpEquals:
00927             if (ret == 0 ) result= true; else result = false;
00928             break;
00929         case OpNotEquals:
00930             if (ret != 0 ) result= true; else result = false;
00931             break;
00932         case OpLessThan:
00933             if (ret < 0 ) result= true; else result = false;
00934             break;
00935         case OpLessThanEquals:
00936             printf("Illegal Operator:Not Supported for String\n");
00937             break;
00938         case OpGreaterThan:
00939             if (ret > 0 ) result= true; else result = false;
00940             break;
00941         case OpGreaterThanEquals:
00942             printf("Illegal Operator:Not Supported for String\n");
00943             break;
00944    }
00945    return result;
00946 }

Here is the caller graph for this function:

bool AllDataType::compareTimeStampVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 887 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00888 {
00889     bool result = false;
00890     switch(op)
00891     {
00892         case OpEquals:
00893             if (*(TimeStamp*)src1 == *(TimeStamp*)src2) result = true;
00894             else result = false;
00895             break;
00896         case OpNotEquals:
00897             if (*(TimeStamp*)src1 != *(TimeStamp*)src2) result = true;
00898             else result = false;
00899             break;
00900         case OpLessThan:
00901             if (*(TimeStamp*)src1 < *(TimeStamp*)src2) result = true;
00902             else result = false;
00903             break;
00904         case OpLessThanEquals:
00905             if (*(TimeStamp*)src1 <= *(TimeStamp*)src2) result = true;
00906             else result = false;
00907             break;
00908         case OpGreaterThan:
00909             if (*(TimeStamp*)src1 > *(TimeStamp*)src2) result = true;
00910             else result = false;
00911             break;
00912         case OpGreaterThanEquals:
00913             if (*(TimeStamp*)src1 >= *(TimeStamp*)src2) result = true;
00914             else result = false;
00915             break;
00916    }
00917    return result;
00918 }

Here is the caller graph for this function:

bool AllDataType::compareTimeVal ( void *  src1,
void *  src2,
ComparisionOp  op 
) [static]

Definition at line 854 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by compareVal().

00855 {
00856     bool result = false;
00857     switch(op)
00858     {
00859         case OpEquals:
00860             if (*(Time*)src1 == *(Time*)src2) result = true;
00861             else result = false;
00862             break;
00863         case OpNotEquals:
00864             if (*(Time*)src1 != *(Time*)src2) result = true;
00865             else result = false;
00866             break;
00867         case OpLessThan:
00868             if (*(Time*)src1 < *(Time*)src2) result = true;
00869             else result = false;
00870             break;
00871         case OpLessThanEquals:
00872             if (*(Time*)src1 <= *(Time*)src2) result = true;
00873             else result = false;
00874             break;
00875         case OpGreaterThan:
00876             if (*(Time*)src1 > *(Time*)src2) result = true;
00877             else result = false;
00878             break;
00879         case OpGreaterThanEquals:
00880             if (*(Time*)src1 >= *(Time*)src2) result = true;
00881             else result = false;
00882             break;
00883    }
00884    return result;
00885 }

Here is the caller graph for this function:

bool AllDataType::compareVal ( void *  src1,
void *  src2,
ComparisionOp  op,
DataType  type,
long  length = 0 
) [static]

Definition at line 538 of file DataType.cxx.

References compareBinaryVal(), compareByteIntVal(), compareDateVal(), compareDoubleVal(), compareFloatVal(), compareIntVal(), compareLongLongVal(), compareLongVal(), compareShortVal(), compareStringVal(), compareTimeStampVal(), compareTimeVal(), typeBinary, typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by PredicateImpl::evaluate(), HashIndex::insert(), and HashIndex::update().

00540 {
00541     bool result = false;
00542         switch(type)
00543         {
00544        case typeInt:
00545            result = AllDataType::compareIntVal(val1, val2, op );
00546            break;
00547        case typeLong:
00548            result = AllDataType::compareLongVal(val1, val2, op);
00549            break;
00550        case typeLongLong:
00551            result = AllDataType::compareLongLongVal(val1, val2, op);
00552            break;
00553        case typeShort:
00554            result = AllDataType::compareShortVal(val1, val2, op);
00555            break;
00556        case typeByteInt:
00557            result = AllDataType::compareByteIntVal(val1, val2, op);
00558            break;
00559        case typeDouble:
00560            result = AllDataType::compareDoubleVal(val1, val2, op);
00561            break;
00562        case typeFloat:
00563            result = AllDataType::compareFloatVal(val1, val2, op);
00564            break;
00565        case typeDecimal:
00566            //TODO::for porting
00567            break;
00568        case typeDate:
00569            result = AllDataType::compareDateVal(val1, val2, op);
00570            break;
00571        case typeTime:
00572            result = AllDataType::compareTimeVal(val1, val2, op);
00573            break;
00574        case typeTimeStamp:
00575            result = AllDataType::compareTimeStampVal(val1, val2, op);
00576            break;
00577        case typeString:
00578            result = AllDataType::compareStringVal(val1, val2, op);
00579            break;
00580        case typeBinary:
00581            result = AllDataType::compareBinaryVal(val1, val2, op, length);
00582            break;
00583     }
00584     return result;
00585 }

Here is the call graph for this function:

Here is the caller graph for this function:

void AllDataType::convert ( DataType  srcType,
void *  src,
DataType  destType,
void *  dest 
) [static]

Definition at line 1138 of file DataType.cxx.

References convertToByteInt(), convertToDate(), convertToDouble(), convertToFloat(), convertToInt(), convertToLong(), convertToLongLong(), convertToShort(), convertToString(), convertToTime(), convertToTimeStamp(), typeBinary, typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

01140 {
01141     switch ((DataType) destType )
01142     {
01143         case typeInt:        convertToInt(dest, src, srcType); break;
01144         case typeLong:       convertToLong(dest, src, srcType); break;
01145         case typeLongLong:   convertToLongLong(dest, src, srcType); break;
01146         case typeShort:      convertToShort(dest, src, srcType); break;
01147         case typeByteInt:    convertToByteInt(dest, src, srcType); break;
01148 
01149         case typeFloat:      convertToFloat(dest, src, srcType); break;
01150         case typeDouble:     convertToDouble(dest, src, srcType); break;
01151 
01152         //TODO 
01153         case typeDecimal:    convertToDouble(dest, src, srcType); break;
01154 
01155         case typeString:     convertToString(dest, src, srcType); break;
01156 
01157         case typeBinary:
01158         case typeDate:       convertToDate(dest, src, srcType); break;
01159         case typeTime:       convertToTime(dest, src, srcType); break;
01160         case typeTimeStamp:  convertToTimeStamp(dest, src, srcType); break;
01161         default: return;
01162     }
01163 }

Here is the call graph for this function:

DataType AllDataType::convertFromSQLType ( SQLSMALLINT  type  )  [static]

Definition at line 461 of file DataType.cxx.

References SQL_CHAR, SQL_DOUBLE, SQL_FLOAT, SQL_INTEGER, SQL_REAL, SQL_SMALLINT, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP, SQL_VARCHAR, typeDate, typeDouble, typeFloat, typeInt, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by CacheTableLoader::load(), and SqlOdbcStatement::prepare().

00462 {
00463     switch(type)
00464     {
00465         case SQL_INTEGER :
00466             return typeInt;
00467         case  SQL_SMALLINT:
00468             return typeShort;
00469         case  SQL_DOUBLE:
00470             return typeDouble;
00471         case  SQL_FLOAT:
00472         case  SQL_REAL:
00473             return typeFloat;
00474         case SQL_TYPE_DATE:
00475             return typeDate;
00476         case SQL_TYPE_TIME :
00477            return typeTime;
00478         case SQL_TYPE_TIMESTAMP :
00479            return typeTimeStamp;
00480         case SQL_CHAR:
00481             return typeString;
00482         case SQL_VARCHAR:
00483             return typeString;
00484     }
00485     return typeInt;
00486 }

Here is the caller graph for this function:

void AllDataType::convertToByteInt ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1258 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01259 {
01260     switch(srcType)
01261     {
01262         case typeInt:        *(char*)dest = (char) *(int*)src; break;
01263         case typeLong:       *(char*)dest = (char) *(long*)src; break;
01264         case typeLongLong:   *(char*)dest = (char) *(long long*)src; break;
01265         case typeShort:      *(char*)dest = (char) *(short*)src; break;
01266         case typeByteInt:    *(char*)dest = *(char *)src; break;
01267 
01268         case typeFloat:      *(char*)dest = (char) *(float *)src; break;
01269         case typeDouble:     *(char*)dest =(char) *(double *)src; break;
01270 
01271         case typeString:     sscanf((const char*)src, "%c", (char*) dest); break;
01272 
01273         case typeDate:
01274         case typeTime:
01275         case typeTimeStamp:
01276         case typeBinary:
01277         default:             *(char*)dest = (char) 0;
01278     }
01279 }

Here is the caller graph for this function:

void AllDataType::convertToDate ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1398 of file DataType.cxx.

References Date::parseFrom(), typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01399 {
01400     switch(srcType)
01401     {
01402         case typeInt:
01403         case typeLong:
01404         case typeLongLong:
01405         case typeShort:
01406         case typeByteInt:
01407         case typeFloat:
01408         case typeDouble:
01409         case typeDate:
01410         case typeTime:
01411         case typeTimeStamp:
01412         case typeString:
01413         {
01414             Date *dt = (Date*) dest;
01415             dt->parseFrom((char*)src);
01416             break;
01417         }
01418         default: ((char*)dest)[0] = '\0';
01419     }
01420 }

Here is the call graph for this function:

Here is the caller graph for this function:

void AllDataType::convertToDouble ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1304 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01305 {
01306     switch(srcType)
01307     {
01308         case typeInt:        *(double *)dest =(double) *(int *)src; break;
01309         case typeLong:       *(double *)dest =(double) *(long *)src; break;
01310         case typeLongLong:   *(double *)dest =(double) *(long long *)src; break;
01311         case typeShort:      *(double *)dest =(double) *(short *)src; break;
01312         case typeByteInt:    *(double *)dest =(double) *(char *)src; break;
01313 
01314         case typeFloat:      *(double *)dest =(double) *(float *)src; break;
01315         case typeDouble:     *(double *)dest = *(double *)src; break;
01316 
01317         case typeString:     sscanf((const char*)src, "%lf", (double*) dest); break;
01318 
01319         case typeDate:
01320         case typeTime:
01321         case typeTimeStamp:
01322         case typeBinary:
01323         default:             *(double *)dest = (double) 0;
01324     }
01325 }

Here is the caller graph for this function:

void AllDataType::convertToFloat ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1281 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01282 {
01283     switch(srcType)
01284     {
01285         case typeInt:        *(float *)dest =(float) *(int *)src; break;
01286         case typeLong:       *(float *)dest =(float) *(long *)src; break;
01287         case typeLongLong:   *(float *)dest =(float) *(long long *)src; break;
01288         case typeShort:      *(float *)dest =(float) *(short *)src; break;
01289         case typeByteInt:    *(float *)dest =(float) *(char *)src; break;
01290 
01291         case typeFloat:      *(float *)dest = *(float *)src; break;
01292         case typeDouble:     *(float *)dest =(float) *(double *)src; break;
01293 
01294         case typeString:     sscanf((const char*)src, "%f", (float*) dest); break;
01295 
01296         case typeDate:
01297         case typeTime:
01298         case typeTimeStamp:
01299         case typeBinary:
01300         default:             *(float *)dest = (float) 0;
01301     }
01302 }

Here is the caller graph for this function:

void AllDataType::convertToInt ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1165 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01166 {
01167     switch(srcType)
01168     {
01169         case typeInt:        *(int *)dest = *(int *)src; break;
01170         case typeLong:       *(int *)dest =(int) *(long *)src; break;
01171         case typeLongLong:   *(int *)dest =(int) *(long long *)src; break;
01172         case typeShort:      *(int *)dest =(int) *(short *)src; break;
01173         case typeByteInt:    *(int *)dest =(int) *(char *)src; break;
01174 
01175         case typeFloat:      *(int *)dest = (int) *(float *)src; break;
01176         case typeDouble:     *(int *)dest =(int) *(double *)src; break;
01177 
01178         case typeString:     sscanf((const char*)src, "%d", (int*) dest); break;
01179 
01180         case typeDate:
01181         case typeTime:
01182         case typeTimeStamp:
01183         case typeBinary:
01184         default:             *(int *)dest = (int) 0;
01185     }
01186 }

Here is the caller graph for this function:

void AllDataType::convertToLong ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1188 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01189 {
01190     switch(srcType)
01191     {
01192         case typeInt:        *(long *)dest =(long) *(int *)src; break;
01193         case typeLong:       *(long *)dest = *(long *)src; break;
01194         case typeLongLong:   *(long *)dest =(long) *(long long *)src; break;
01195         case typeShort:      *(long *)dest =(long) *(short *)src; break;
01196         case typeByteInt:    *(long *)dest =(long) *(char *)src; break;
01197 
01198         case typeFloat:      *(long *)dest = (long) *(float *)src; break;
01199         case typeDouble:     *(long *)dest =(long) *(double *)src; break;
01200 
01201         case typeString:     sscanf((const char*)src, "%ld", (long*) dest); break;
01202 
01203         case typeDate:
01204         case typeTime:
01205         case typeTimeStamp:
01206         case typeBinary:
01207         default:             *(long *)dest = (long) 0;
01208     }
01209 }

Here is the caller graph for this function:

void AllDataType::convertToLongLong ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1212 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01213 {
01214     switch(srcType)
01215     {
01216         case typeInt:        *(long long *)dest =(long long) *(int *)src; break;
01217         case typeLong:       *(long long *)dest = (long long) *(long *)src; break;
01218         case typeLongLong:   *(long long *)dest = *(long long *)src; break;
01219         case typeShort:      *(long long *)dest =(long long) *(short *)src; break;
01220         case typeByteInt:    *(long long *)dest =(long long) *(char *)src; break;
01221 
01222         case typeFloat:      *(long long *)dest = (long long) *(float *)src; break;
01223         case typeDouble:     *(long long *)dest =(long long) *(double *)src; break;
01224 
01225         case typeString:     sscanf((const char*)src, "%lld", (long long*) dest); break;
01226 
01227         case typeDate:
01228         case typeTime:
01229         case typeTimeStamp:
01230         case typeBinary:
01231         default:             *(long long *)dest = (long long) 0;
01232     }
01233 }

Here is the caller graph for this function:

void AllDataType::convertToShort ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1235 of file DataType.cxx.

References typeBinary, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01236 {
01237     switch(srcType)
01238     {
01239         case typeInt:        *(short*)dest =(short) *(int*)src; break;
01240         case typeLong:       *(short*)dest = (short) *(long*)src; break;
01241         case typeLongLong:   *(short*)dest = (short) *(long long*)src; break;
01242         case typeShort:      *(short*)dest = *(short*)src; break;
01243         case typeByteInt:    *(short*)dest =(short) *(char *)src; break;
01244 
01245         case typeFloat:      *(short*)dest = (short) *(float *)src; break;
01246         case typeDouble:     *(short*)dest =(short) *(double *)src; break;
01247 
01248         case typeString:     sscanf((const char*)src, "%hd", (short*) dest); break;
01249 
01250         case typeDate:
01251         case typeTime:
01252         case typeTimeStamp:
01253         case typeBinary:
01254         default:             *(short*)dest = (short) 0;
01255     }
01256 }

Here is the caller graph for this function:

SQLSMALLINT AllDataType::convertToSQL_C_Type ( DataType  type  )  [static]

Definition at line 428 of file DataType.cxx.

References SQL_C_CHAR, SQL_C_DOUBLE, SQL_C_FLOAT, SQL_C_SBIGINT, SQL_C_SLONG, SQL_C_SSHORT, SQL_C_STINYINT, SQL_C_TYPE_DATE, SQL_C_TYPE_TIME, SQL_C_TYPE_TIMESTAMP, SQL_INTEGER, typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by SqlOdbcStatement::prepare().

00429 {
00430     switch(type)
00431     {
00432         case typeInt:
00433             return SQL_C_SLONG;
00434         case typeLong:
00435             return SQL_C_SLONG;
00436         case typeLongLong:
00437             return SQL_C_SBIGINT;
00438         case typeShort:
00439             return SQL_C_SSHORT;
00440         case typeByteInt:
00441             return SQL_C_STINYINT;
00442         case typeDouble:
00443             return SQL_C_DOUBLE;
00444         case typeFloat:
00445             return SQL_C_FLOAT;
00446         case typeDecimal:
00447             //TODO
00448             return SQL_INTEGER;
00449         case typeDate:
00450             return SQL_C_TYPE_DATE;
00451         case typeTime:
00452            return SQL_C_TYPE_TIME;
00453         case typeTimeStamp:
00454            return SQL_C_TYPE_TIMESTAMP;
00455         case typeString:
00456             return SQL_C_CHAR;
00457     }
00458     return SQL_C_SLONG;
00459 }

Here is the caller graph for this function:

SQLSMALLINT AllDataType::convertToSQLType ( DataType  type  )  [static]

Definition at line 394 of file DataType.cxx.

References SQL_CHAR, SQL_DOUBLE, SQL_INTEGER, SQL_REAL, SQL_SMALLINT, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP, typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by CacheTableLoader::load(), and SqlOdbcStatement::prepare().

00395 {
00396     switch(type)
00397     {
00398         case typeInt:
00399             return SQL_INTEGER;
00400         case typeLong:
00401             return SQL_INTEGER;
00402         case typeLongLong:
00403             //TODO
00404             return SQL_INTEGER;
00405         case typeShort:
00406             return SQL_SMALLINT;
00407         case typeByteInt:
00408             //TODO
00409             return SQL_INTEGER;
00410         case typeDouble:
00411             return SQL_DOUBLE;
00412         case typeFloat:
00413             return SQL_REAL;
00414         case typeDecimal:
00415             //TODO
00416             return SQL_INTEGER;
00417         case typeDate:
00418             return SQL_TYPE_DATE;
00419         case typeTime:
00420            return SQL_TYPE_TIME;
00421         case typeTimeStamp:
00422            return SQL_TYPE_TIMESTAMP;
00423         case typeString:
00424             return SQL_CHAR;
00425     }
00426     return SQL_INTEGER;
00427 }

Here is the caller graph for this function:

void AllDataType::convertToString ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1327 of file DataType.cxx.

References TimeStamp::dayOfMonth(), Date::dayOfMonth(), TimeStamp::hours(), Time::hours(), TimeStamp::minutes(), Time::minutes(), TimeStamp::month(), Date::month(), TimeStamp::seconds(), Time::seconds(), typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, typeTimeStamp, TimeStamp::year(), and Date::year().

Referenced by convert(), SqlOdbcStatement::setByteIntParam(), SqlOdbcStatement::setDateParam(), SqlOdbcStatement::setDoubleParam(), SqlOdbcStatement::setFloatParam(), SqlOdbcStatement::setIntParam(), SqlOdbcStatement::setLongLongParam(), SqlOdbcStatement::setLongParam(), SqlOdbcStatement::setTimeParam(), and SqlOdbcStatement::setTimeStampParam().

01328 {
01329     switch(srcType)
01330     {
01331         case typeInt:
01332         {
01333             sprintf ((char *)dest, "%d", *(int *)src); 
01334             break;
01335         }
01336         case typeLong:
01337         {
01338             sprintf ((char *)dest, "%ld", *(long *)src);
01339             break;
01340         }
01341         case typeLongLong:
01342         {
01343             sprintf ((char *)dest, "%lld", *(long long *)src); 
01344             break;
01345         }
01346         case typeShort:
01347         {
01348             sprintf ((char *)dest, "%hd", *(short *)src); 
01349             break;
01350         }
01351         case typeByteInt:
01352         {
01353             sprintf ((char *)dest, "%hd", *(char *)src); 
01354             break;
01355         }
01356 
01357         case typeFloat:
01358         {
01359             sprintf ((char *)dest, "%f", *(float *)src);
01360             break;
01361         }
01362         case typeDouble:
01363         {
01364             sprintf ((char *) dest, "%lf", *(double *)src); 
01365             break;
01366         }
01367 
01368         case typeString:
01369         {
01370             strcpy((char*)dest, (char*)src);
01371             break;
01372         }
01373         case typeDate:
01374         {
01375             Date* dt = (Date*)src;
01376             sprintf((char*) dest, "%d/%d/%d", dt->year(),
01377                                   dt->month(), dt->dayOfMonth());
01378             break;
01379         }
01380         case typeTime:
01381         {
01382             Time* tm = (Time*)src;
01383             sprintf((char*)dest,"%d:%d:%d.%d", tm->hours(), tm->minutes(), tm->seconds(), 0);
01384             break;
01385         }
01386         case typeTimeStamp:
01387         {
01388             TimeStamp* tm = (TimeStamp*)src;
01389             sprintf((char*)dest, "%d/%d/%d %d:%d:%d.%d", tm->year(),
01390                                 tm->month(), tm->dayOfMonth(), tm->hours(),
01391                                 tm->minutes(), tm->seconds(), 0 );
01392             break;
01393         }
01394         default: ((char*)dest)[0] = '\0';
01395     }
01396 
01397 }

Here is the call graph for this function:

Here is the caller graph for this function:

void AllDataType::convertToTime ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1422 of file DataType.cxx.

References Time::parseFrom(), typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01423 {
01424     switch(srcType)
01425     {
01426         case typeInt:
01427         case typeLong:
01428         case typeLongLong:
01429         case typeShort:
01430         case typeByteInt:
01431         case typeFloat:
01432         case typeDouble:
01433         case typeDate:
01434         case typeTime:
01435         case typeTimeStamp:
01436         case typeString:
01437         {
01438             Time *dt = (Time*) dest;
01439             dt->parseFrom((char*)src);
01440             break;
01441         }
01442         default: ((char*)dest)[0] = '\0';
01443     }
01444 }

Here is the call graph for this function:

Here is the caller graph for this function:

void AllDataType::convertToTimeStamp ( void *  dest,
void *  src,
DataType  srcType 
) [static]

Definition at line 1446 of file DataType.cxx.

References TimeStamp::parseFrom(), typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by convert().

01447 {
01448     switch(srcType)
01449     {
01450         case typeInt:
01451         case typeLong:
01452         case typeLongLong:
01453         case typeShort:
01454         case typeByteInt:
01455         case typeFloat:
01456         case typeDouble:
01457         case typeDate:
01458         case typeTime:
01459         case typeTimeStamp:
01460         case typeString:
01461         {
01462             TimeStamp *dt = (TimeStamp*) dest;
01463             dt->parseFrom((char*)src);
01464             break;
01465         }
01466         default: ((char*)dest)[0] = '\0';
01467     }
01468 }

Here is the call graph for this function:

Here is the caller graph for this function:

void AllDataType::copyVal ( void *  dest,
void *  src,
DataType  type,
int  length = 0 
) [static]

Definition at line 487 of file DataType.cxx.

References os::memcpy(), typeBinary, typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by UpdStatement::execute(), SelStatement::execute(), InsStatement::execute(), DelStatement::execute(), SqlOdbcStatement::execute(), SelStatement::fetch(), SqlOdbcStatement::fetch(), and PacketExecute::marshall().

00488 {
00489     switch(type)
00490     {
00491         case typeInt:
00492             *(int*)dest = *(int*)src;
00493             break;
00494         case typeLong:
00495             *(long*)dest = *(long*)src;
00496             break;
00497         case typeLongLong:
00498             *(long long*)dest = *(long long*)src;
00499             break;
00500         case typeShort:
00501             *(short*)dest = *(short*)src;
00502             break;
00503         case typeByteInt:
00504             *(char*)dest = *(char*)src;
00505             break;
00506         case typeDouble:
00507             *(double*)dest = *(double*)src;
00508             break;
00509         case typeFloat:
00510             *(float*)dest = *(float*)src;
00511             break;
00512         case typeDecimal:
00513             //TODO::for porting
00514         case typeDate:
00515             *(Date*)dest = *(Date*)src;
00516             break;
00517         case typeTime:
00518             *(Time*)dest = *(Time*)src;
00519             break;
00520         case typeTimeStamp:
00521             *(TimeStamp*)dest = *(TimeStamp*)src;
00522             break;
00523         case typeString: 
00524             {
00525                 strncpy((char*)dest, (char*)src, length);
00526                 char *d =(char*)dest;
00527                 d[length-1] = '\0';
00528                 break;
00529             }
00530         case typeBinary:
00531             os::memcpy((char*)dest, (char*)src, length);
00532             break;
00533         default:
00534             break;
00535         }
00536 }

Here is the call graph for this function:

Here is the caller graph for this function:

ComparisionOp AllDataType::getComparisionOperator ( char *  str  )  [static]

Definition at line 979 of file DataType.cxx.

References OpEquals, OpGreaterThan, OpGreaterThanEquals, OpInvalidComparisionOp, OpLessThan, OpLessThanEquals, and OpNotEquals.

Referenced by yyparse().

00980 {
00981     ComparisionOp op;
00982     if (strcmp(str, "<=") == 0)
00983         op = OpLessThanEquals;
00984     else if (strcmp(str, ">=") == 0)
00985         op = OpGreaterThanEquals;
00986     else if (strcmp(str, "<") == 0)
00987         op = OpLessThan;
00988     else if (strcmp(str, ">") == 0)
00989         op = OpGreaterThan;
00990     else if (strcmp(str, "=") == 0)
00991         op = OpEquals;
00992     else if (strcmp(str, "!=") == 0 || strcmp(str, "<>") == 0 )
00993         op = OpNotEquals;
00994     else
00995         op = OpInvalidComparisionOp;
00996     return op;
00997 }

Here is the caller graph for this function:

char * AllDataType::getSQLString ( DataType  type  )  [static]

Definition at line 374 of file DataType.cxx.

References typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by main().

00375 {
00376     switch(type)
00377     {
00378         case typeInt: return "INT";
00379         case typeLong: return "INT";
00380         case typeLongLong: return "BIGINT";
00381         case typeShort: return "SMALLINT";
00382         case typeByteInt: return "TINYINT";
00383         case typeDouble: return "REAL";
00384         case typeFloat: return "FLOAT";
00385         case typeDate: return "DATE";
00386         case typeTime: return "TIME";
00387         case typeTimeStamp: return "TIMESTAMP";
00388         case typeString: return "CHAR";
00389         default: return "UNKNOWN";
00390     }
00391 }

Here is the caller graph for this function:

int AllDataType::printVal ( void *  src,
DataType  type,
int  length 
) [static]

Definition at line 1470 of file DataType.cxx.

References TimeStamp::dayOfMonth(), Date::dayOfMonth(), TimeStamp::hours(), Time::hours(), TimeStamp::minutes(), Time::minutes(), TimeStamp::month(), Date::month(), TimeStamp::seconds(), Time::seconds(), typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, typeTimeStamp, TimeStamp::year(), and Date::year().

Referenced by SelStatement::fetchAndPrint(), and SqlOdbcStatement::fetchAndPrint().

01471 { 
01472     int count = 0;
01473     switch(srcType)
01474     {
01475         case typeInt:
01476         {
01477             count = printf ("%d", *(int *)src); 
01478             break;
01479         }
01480         case typeLong:
01481         {
01482             count = printf ("%ld", *(long *)src);
01483             break;
01484         }
01485         case typeLongLong:
01486         {
01487             count = printf ("%lld", *(long long *)src); 
01488             break;
01489         }
01490         case typeShort:
01491         {
01492             count = printf("%hd", *(short *)src); 
01493             break;
01494         }
01495         case typeByteInt:
01496         {
01497             count = printf("%hd", *(char *)src); 
01498             break;
01499         }
01500 
01501         case typeFloat:
01502         {
01503             count = printf("%f", *(float *)src);
01504             break;
01505         }
01506         case typeDouble:
01507         {
01508             count = printf("%lf", *(double *)src); 
01509             break;
01510         }
01511 
01512         case typeString:
01513         {
01514             count = printf("%s", (char*)src);
01515             break;
01516         }
01517         case typeDate:
01518         {
01519             Date* dt = (Date*)src;
01520             count = printf("%d/%d/%d", dt->year(),
01521                                   dt->month(), dt->dayOfMonth());
01522             break;
01523         }
01524         case typeTime:
01525         {
01526             Time* tm = (Time*)src;
01527             printf("%d:%d:%d.%d", tm->hours(), tm->minutes(), tm->seconds(), 0);
01528             break;
01529         }
01530         case typeTimeStamp:
01531         {
01532             TimeStamp* tm = (TimeStamp*)src;
01533             count = printf("%d/%d/%d %d:%d:%d.%d", tm->year(),
01534                                 tm->month(), tm->dayOfMonth(), tm->hours(),
01535                                 tm->minutes(), tm->seconds(), 0 );
01536             break;
01537         }
01538         default: { printf("DataType not supported\n"); break; }
01539     }
01540     return count;
01541 }

Here is the call graph for this function:

Here is the caller graph for this function:

long AllDataType::size ( DataType  type,
int  length = 0 
) [static]

Definition at line 326 of file DataType.cxx.

References typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by TableDef::addField(), PacketExecute::marshall(), and PacketExecute::unmarshall().

00327 {
00328     long size = 0;
00329     switch(type)
00330     {
00331         case typeInt:
00332             size = sizeof(int);
00333             break;
00334         case typeLong:
00335             size = sizeof(long);
00336             break;
00337         case typeLongLong:
00338             size = sizeof(long long);
00339             break;
00340         case typeShort:
00341             size = sizeof(short);
00342             break;
00343         case typeByteInt:
00344             size = sizeof(char);
00345             break;
00346         case typeDouble:
00347             size = sizeof(double);
00348             break;
00349         case typeFloat:
00350             size = sizeof(float);
00351             break;
00352         case typeDecimal:
00353             //TODO::for porting
00354             //fldDef.length_ = sizeof(long double);
00355             break;
00356         case typeDate:
00357             size = sizeof(Date);
00358             break;
00359         case typeTime:
00360             size = sizeof(Time);
00361             break;
00362         case typeTimeStamp:
00363             size = sizeof(TimeStamp);
00364             break;
00365         case typeString:
00366             size = length;
00367             break;
00368         default:
00369             size  = 0;
00370             break;
00371     }
00372     return size;
00373 }

Here is the caller graph for this function:

void AllDataType::strToValue ( void *  dest,
char *  src,
DataType  type,
int  length = 0 
) [static]

Definition at line 1045 of file DataType.cxx.

References typeByteInt, typeDate, typeDecimal, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, and typeTimeStamp.

Referenced by InsStatement::resolve(), UpdStatement::resolveForAssignment(), and DelStatement::resolveForCondition().

01046 {
01047     switch(type)
01048     {
01049         case typeInt: {
01050             int val;
01051             sscanf( src, "%d",  &val);
01052             *(int*)dest = val;
01053             break; }
01054         case typeLong: {
01055             long val;
01056             sscanf( src, "%ld",  &val);
01057             *(long*)dest = val;
01058             break; }
01059         case typeLongLong: {
01060             long long val;
01061             sscanf( src, "%lld",  &val);
01062             *(long long*)dest = val;
01063             break; }
01064         case typeShort: {
01065             short val;
01066             sscanf( src, "%hd",  &val);
01067             *(short*)dest = val;
01068             break; }
01069         case typeByteInt: {
01070             char val;
01071             sscanf( src, "%c",  &val);
01072             *(char*)dest = val;
01073             break; }
01074         case typeDouble: {
01075             double val;
01076             sscanf( src, "%lg",  &val);
01077             *(double*)dest = val;
01078             break; }
01079         case typeFloat: {
01080             float val;
01081             sscanf( src, "%f",  &val);
01082             *(float*)dest = val;
01083             break; }
01084         case typeDecimal:
01085             //TODO::for porting
01086         case typeString: {
01087                 strncpy((char*)dest, (char*)src, length);
01088                 char *d =(char*)dest;
01089                 d[length-1] = '\0'; 
01090                 break;}
01091         case typeDate: {
01092             int d,m,y,res=0;
01093             res = sscanf( src, "%d-%d-%d", &y, &m, &d );
01094             if( res != 3 )
01095                  res = sscanf( src, "%d/%d/%d", &y, &m, &d );
01096             if( res != 3 )
01097             {
01098            fprintf(stderr,"Error reading date. yyyy{-/}mm{-/}dd is the valid format.");
01099                 d=m=y=0;
01100             }
01101             Date dateObj(y,m,d);
01102             *(Date*)dest = dateObj;
01103             break; }
01104         case typeTime: {
01105             int h,m,s,res=0;
01106             res = sscanf( src, "%d:%d:%d", &h, &m, &s );
01107             if( res != 3 )
01108             {
01109                 fprintf(stderr, "Error reading time, hh:mm:ss is the valid format.");
01110                 h=m=s=0;
01111             }
01112             Time timeObj(h,m,s);
01113             *(Time*)dest = timeObj;
01114             break; }
01115         case typeTimeStamp: {
01116             int d,m,y, h,mn,s, res=0;
01117             res = sscanf( src, "%d-%d-%d %d:%d:%d", &y, &m, &d, &h, &mn, &s );
01118             if( res != 6 )
01119                 res = sscanf( src, "%d-%d-%d, %d:%d:%d", &y, &m, &d, &h, &mn, &s );
01120             if( res != 6 )
01121                 res = sscanf( src, "%d/%d/%d %d:%d:%d", &y, &m, &d, &h, &mn, &s );
01122             if( res != 6 )
01123                 res = sscanf( src, "%d/%d/%d, %d:%d:%d", &y, &m, &d, &h, &mn, &s );
01124             if( res != 6 )
01125             {
01126                 fprintf(stderr, "Error reading timestamp, yyyy{-/}mm{-/}dd[,] hh:mm:ss is the valid format.");
01127                 d=m=y=h=mn=s=0;
01128             }
01129             TimeStamp timeStampObj(y,m,d,h,mn,s);
01130             *(TimeStamp*)dest = timeStampObj;
01131             break; }
01132         default:
01133             break;
01134         }
01135 }

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:43:39 2008 for csql by  doxygen 1.4.7