version 1.42, 2002/03/21 02:50:31
|
version 1.43, 2002/03/21 21:11:19
|
|
|
| |
Boolean XmlReader::stringToReal(const char* stringValue, Real64& x) | Boolean XmlReader::stringToReal(const char* stringValue, Real64& x) |
{ | { |
|
// |
|
// Check the string against the DMTF-defined grammar |
|
// |
const char* p = stringValue; | const char* p = stringValue; |
| |
if (!*p) | if (!*p) |
|
|
if (*p) | if (*p) |
return false; | return false; |
| |
|
// |
|
// Do the conversion |
|
// |
char* end; | char* end; |
|
errno = 0; |
x = strtod(stringValue, &end); | x = strtod(stringValue, &end); |
|
if (*end || (errno == ERANGE)) |
|
{ |
|
return false; |
|
} |
|
|
return true; | return true; |
} | } |
| |
|
|
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) | if (!stringToReal(valueString, x)) |
throw XmlSemanticError(lineNumber, "Bad real value"); |
throw XmlSemanticError(lineNumber, "Bad real number value"); |
| |
// ATTN-RK-P3-20010319: This value gets truncated. |
|
return CIMValue(Real32(x)); | return CIMValue(Real32(x)); |
} | } |
| |
|
|
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) | if (!stringToReal(valueString, x)) |
throw XmlSemanticError(lineNumber, "Bad real value"); |
throw XmlSemanticError(lineNumber, "Bad real number value"); |
| |
return CIMValue(x); | return CIMValue(x); |
} | } |