From bad7bd373e2a3ed9318b2a76e0a17656c65d93ad Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 23 Sep 2002 23:59:29 +0000 Subject: [PATCH] fixed string to enum conversion so that it allows strings with integers --- src/gdd/aitConvert.cc | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/gdd/aitConvert.cc b/src/gdd/aitConvert.cc index 84fa0025d..ea6f6fd12 100644 --- a/src/gdd/aitConvert.cc +++ b/src/gdd/aitConvert.cc @@ -206,7 +206,7 @@ static int aitConvertEnum16FixedString (void* d,const void* s,aitIndex c, for (i=0;igetString(choice), in[i].fixed_string)==0) { @@ -216,10 +216,25 @@ static int aitConvertEnum16FixedString (void* d,const void* s,aitIndex c, } } // - // if none found that match then abort and return an error + // if no string matches then look for a numeric match // if (choice>=nChoices) { - return -1; + int temp; + if ( sscanf ( in[i].fixed_string,"%i", &temp ) == 1 ) { + if ( temp >= 0 && temp < nChoices ) { + out[i] = (aitUint16) temp; + status += sizeof(out[i]); + } + else { + // + // no match, return an error + // + return -1; + } + } + else { + return -1; + } } } return status; @@ -269,10 +284,25 @@ static int aitConvertEnum16String (void* d,const void* s, } } // - // if none found that match then abort and return an error + // if no string matches then look for a numeric match // if (choice>=nChoices) { - return -1; + int temp; + if ( sscanf ( in[i].string(),"%i", &temp ) == 1 ) { + if ( temp >= 0 && temp < nChoices ) { + out[i] = (aitUint16) temp; + status += sizeof(out[i]); + } + else { + // + // no match, return an error + // + return -1; + } + } + else { + return -1; + } } } return status;