Changeset 7468
- Timestamp:
- Jun 9, 2006, 3:27:52 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/types/psMetadataConfig.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadataConfig.c
r7451 r7468 10 10 * @author Eric Van Alst, MHPCC 11 11 * 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 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 218 218 // Returns single parsed value as a double precision number. The input string must be cleaned and null 219 219 // terminated. 220 static double parse Value(char *inString,221 psS32 *status)220 static double parseDouble(char *inString, 221 psS32 *status) 222 222 { 223 223 char *end = NULL; … … 225 225 226 226 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. 238 static 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. 256 static 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); 227 263 if(*end != '\0') { 228 264 *status = 1; … … 649 685 psBool tempBool = false; 650 686 psS32 tempInt = 0; 687 psU32 tempUint = 0; 651 688 psVector* tempVec = NULL; 652 689 char* tempStr = NULL; … … 706 743 } else if(!strncmp(strType, "BOOL", 4)) { 707 744 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; 708 749 } else if(!strncmp(strType, "S32", 3)) { 709 750 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; 710 757 } else if(!strncmp(strType, "F32", 3)) { 711 758 mdType = PS_DATA_F32; … … 817 864 case PS_DATA_F32: 818 865 case PS_DATA_F64: 819 tempDbl = parse Value(strValue, &status);866 tempDbl = parseDouble(strValue, &status); 820 867 if(!status) { 821 868 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, … … 829 876 } 830 877 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; 831 898 case PS_DATA_S32: 832 tempInt = (psS32) parseValue(strValue, &status);899 tempInt = (psS32) parseSignedInt(strValue, &status); 833 900 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); 837 932 } else { 838 933 psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
Note:
See TracChangeset
for help on using the changeset viewer.
