IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7468


Ignore:
Timestamp:
Jun 9, 2006, 3:27:52 PM (20 years ago)
Author:
magnier
Message:

added support in ConfigParse for U8,U16,U32,S8,S16; replaced parseValue with parseDouble,parseSignedInt,parseUnsignedInt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r7451 r7468  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-06-09 02:35:17 $
     12*  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-06-10 01:27:52 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    218218// Returns single parsed value as a double precision number. The input string must be cleaned and null
    219219// terminated.
    220 static double parseValue(char *inString,
    221                          psS32 *status)
     220static double parseDouble(char *inString,
     221                          psS32 *status)
    222222{
    223223    char *end = NULL;
     
    225225
    226226    value = strtod(inString, &end);
     227    if(*end != '\0') {
     228        *status = 1;
     229    } else if(inString==end) {
     230        *status = 1;
     231    }
     232
     233    return value;
     234}
     235
     236// Returns single parsed value as a long signed int. The input string must be cleaned and null
     237// terminated.
     238static long int parseSignedInt(char *inString,
     239                               psS32 *status)
     240{
     241    char *end = NULL;
     242    psS32 value = 0;
     243
     244    value = strtol(inString, &end, 0);
     245    if(*end != '\0') {
     246        *status = 1;
     247    } else if(inString==end) {
     248        *status = 1;
     249    }
     250
     251    return value;
     252}
     253
     254// Returns single parsed value as a double precision number. The input string must be cleaned and null
     255// terminated.
     256static unsigned long int parseUnsignedInt(char *inString,
     257        psS32 *status)
     258{
     259    char *end = NULL;
     260    psU32 value = 0;
     261
     262    value = strtoul(inString, &end, 0);
    227263    if(*end != '\0') {
    228264        *status = 1;
     
    649685    psBool               tempBool      = false;
    650686    psS32                tempInt       = 0;
     687    psU32                tempUint       = 0;
    651688    psVector*            tempVec       = NULL;
    652689    char*                tempStr       = NULL;
     
    706743        } else if(!strncmp(strType, "BOOL", 4)) {
    707744            mdType = PS_DATA_BOOL;
     745        } else if(!strncmp(strType, "S8", 2)) {
     746            mdType = PS_DATA_S8;
     747        } else if(!strncmp(strType, "S16", 3)) {
     748            mdType = PS_DATA_S16;
    708749        } else if(!strncmp(strType, "S32", 3)) {
    709750            mdType = PS_DATA_S32;
     751        } else if(!strncmp(strType, "U8", 2)) {
     752            mdType = PS_DATA_U8;
     753        } else if(!strncmp(strType, "U16", 3)) {
     754            mdType = PS_DATA_U16;
     755        } else if(!strncmp(strType, "U32", 3)) {
     756            mdType = PS_DATA_U32;
    710757        } else if(!strncmp(strType, "F32", 3)) {
    711758            mdType = PS_DATA_F32;
     
    817864    case PS_DATA_F32:
    818865    case PS_DATA_F64:
    819         tempDbl = parseValue(strValue, &status);
     866        tempDbl = parseDouble(strValue, &status);
    820867        if(!status) {
    821868            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName,
     
    829876        }
    830877        break;
     878    case PS_DATA_S8:
     879        tempInt = (psS8) parseSignedInt(strValue, &status);
     880        if(!status) {
     881            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt);
     882        } else {
     883            psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
     884                    strType, lineCount, fileName);
     885            returnValue = false;
     886        }
     887        break;
     888    case PS_DATA_S16:
     889        tempInt = (psS16) parseSignedInt(strValue, &status);
     890        if(!status) {
     891            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt);
     892        } else {
     893            psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
     894                    strType, lineCount, fileName);
     895            returnValue = false;
     896        }
     897        break;
    831898    case PS_DATA_S32:
    832         tempInt = (psS32)parseValue(strValue, &status);
     899        tempInt = (psS32) parseSignedInt(strValue, &status);
    833900        if(!status) {
    834             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName,
    835                                       mdType | flags,
    836                                       strComment, tempInt);
     901            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt);
     902        } else {
     903            psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
     904                    strType, lineCount, fileName);
     905            returnValue = false;
     906        }
     907        break;
     908    case PS_DATA_U8:
     909        tempUint = (psU8)parseUnsignedInt(strValue, &status);
     910        if(!status) {
     911            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint);
     912        } else {
     913            psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
     914                    strType, lineCount, fileName);
     915            returnValue = false;
     916        }
     917        break;
     918    case PS_DATA_U16:
     919        tempUint = (psU16)parseUnsignedInt(strValue, &status);
     920        if(!status) {
     921            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint);
     922        } else {
     923            psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
     924                    strType, lineCount, fileName);
     925            returnValue = false;
     926        }
     927        break;
     928    case PS_DATA_U32:
     929        tempUint = (psU32)parseUnsignedInt(strValue, &status);
     930        if(!status) {
     931            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint);
    837932        } else {
    838933            psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
Note: See TracChangeset for help on using the changeset viewer.