IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3137


Ignore:
Timestamp:
Feb 4, 2005, 2:57:49 PM (21 years ago)
Author:
jhoblitt
Message:

minor cleanup in psDBSelectColumnNum()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/psdb/psDB.c

    r3135 r3137  
    88 *  @author Joshua Hoblitt
    99 *
    10  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-02-05 00:49:51 $
     10 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-02-05 00:57:49 $
    1212 *
    1313 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    228228}
    229229
    230 // a = assign too, b = source psArray, c = conversion function, d = type to cast to
    231 #define STRINGARRAYTOPTYPE(a, b, c, d)  for (i = 0; i < b->n; i++) { \
    232                                             a = (d)(strlen(b->data[i]) \
    233                                               ? atoi(b->data[i]) \
    234                                               : *(d *)p_psDBGetPTypeNull(pType)); \
    235                                         }
     230// a = assign too, b = source psArray, c = conversion function, d = type to cast to, e = psElemType
     231#define STRINGARRAYTOPTYPE(a, b, c, d, e)   for (i = 0; i < b->n; i++) { \
     232                                                a = (d)(strlen(b->data[i]) \
     233                                                  ? atoi(b->data[i]) \
     234                                                  : *(d *)p_psDBGetPTypeNull(e)); \
     235                                            }
    236236
    237237psVector *psDBSelectColumnNum(psDB *dbh, const char *tableName, const char *col, psElemType pType, const psU64 limit)
     
    253253    switch (pType) {
    254254        case PS_TYPE_S8:
    255             STRINGARRAYTOPTYPE(column->data.S8[i], stringColumn, atoi, psS8);
     255            STRINGARRAYTOPTYPE(column->data.S8[i], stringColumn, atoi, psS8, PS_TYPE_S8);
    256256            break;
    257257        case PS_TYPE_S16:
    258             STRINGARRAYTOPTYPE(column->data.S16[i], stringColumn, atoi, psS16);
     258            STRINGARRAYTOPTYPE(column->data.S16[i], stringColumn, atoi, psS16, PS_TYPE_S16);
    259259            break;
    260260        case PS_TYPE_S32:
    261             STRINGARRAYTOPTYPE(column->data.S32[i], stringColumn, atoi, psS32);
     261            STRINGARRAYTOPTYPE(column->data.S32[i], stringColumn, atoi, psS32, PS_TYPE_S32);
    262262            break;
    263263        case PS_TYPE_S64:
    264             STRINGARRAYTOPTYPE(column->data.S64[i], stringColumn, atoll, psS64);
     264            STRINGARRAYTOPTYPE(column->data.S64[i], stringColumn, atoll, psS64, PS_TYPE_S64);
    265265            break;
    266266        case PS_TYPE_U8:
    267267            // missing from psVector in SDRS
    268             STRINGARRAYTOPTYPE(column->data.U8[i], stringColumn, atoi, psU8);
     268            STRINGARRAYTOPTYPE(column->data.U8[i], stringColumn, atoi, psU8, PS_TYPE_U8);
    269269            break;
    270270        case PS_TYPE_U16:
    271             STRINGARRAYTOPTYPE(column->data.U16[i], stringColumn, atoi, psU16);
     271            STRINGARRAYTOPTYPE(column->data.U16[i], stringColumn, atoi, psU16, PS_TYPE_U16);
    272272            break;
    273273        case PS_TYPE_U32:
    274             STRINGARRAYTOPTYPE(column->data.U32[i], stringColumn, atoi, psU32);
     274            STRINGARRAYTOPTYPE(column->data.U32[i], stringColumn, atoi, psU32, PS_TYPE_U32);
    275275            break;
    276276        case PS_TYPE_U64:
    277             STRINGARRAYTOPTYPE(column->data.U64[i], stringColumn, atoll, psU64);
     277            STRINGARRAYTOPTYPE(column->data.U64[i], stringColumn, atoll, psU64, PS_TYPE_U64);
    278278            break;
    279279        case PS_TYPE_F32:
    280             STRINGARRAYTOPTYPE(column->data.F32[i], stringColumn, atof, psF32);
     280            STRINGARRAYTOPTYPE(column->data.F32[i], stringColumn, atof, psF32, PS_TYPE_F32);
    281281            break;
    282282        case PS_TYPE_F64:
    283             STRINGARRAYTOPTYPE(column->data.F64[i], stringColumn, atof, psF64);
     283            STRINGARRAYTOPTYPE(column->data.F64[i], stringColumn, atof, psF64, PS_TYPE_F64);
    284284            break;
    285285        case PS_TYPE_C32:
    286286            // this is a bogus SQL type
    287             STRINGARRAYTOPTYPE(column->data.C32[i], stringColumn, atof, psC32);
     287            STRINGARRAYTOPTYPE(column->data.C32[i], stringColumn, atof, psC32, PS_TYPE_C32);
    288288            break;
    289289        case PS_TYPE_C64:
    290290            // this is a bogus SQL type
    291             STRINGARRAYTOPTYPE(column->data.C64[i], stringColumn, atof, psC64);
     291            STRINGARRAYTOPTYPE(column->data.C64[i], stringColumn, atof, psC64, PS_TYPE_C64);
    292292            break;
    293293        case PS_TYPE_BOOL:
Note: See TracChangeset for help on using the changeset viewer.