version 1.66, 2002/08/20 17:39:37
|
version 1.70, 2002/08/25 06:43:56
|
|
|
#include "CIMObject.h" | #include "CIMObject.h" |
#include "CIMParamValue.h" | #include "CIMParamValue.h" |
| |
|
//#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL(9223372036854775808)) |
|
//#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(18446744073709551615) |
|
#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL((Sint64) 0x8000000000000000)) |
|
#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL((Uint64) 0xFFFFFFFFFFFFFFFF) |
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
CIMType XmlReader::getCimTypeAttribute( |
Boolean XmlReader::getCimTypeAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
|
CIMType& cimType, // Output parameter |
const char* tagName, | const char* tagName, |
const char* attributeName, | const char* attributeName, |
Boolean required) | Boolean required) |
|
|
} | } |
else | else |
{ | { |
return CIMTYPE_NONE; |
return false; |
} | } |
} | } |
| |
CIMType type = CIMTYPE_NONE; |
CIMType type = CIMTYPE_BOOLEAN; |
|
Boolean unrecognizedType = false; |
| |
if (strcmp(typeName, "boolean") == 0) | if (strcmp(typeName, "boolean") == 0) |
type = CIMTYPE_BOOLEAN; | type = CIMTYPE_BOOLEAN; |
|
|
type = CIMTYPE_REAL64; | type = CIMTYPE_REAL64; |
else if (strcmp(typeName, "reference") == 0) | else if (strcmp(typeName, "reference") == 0) |
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
|
else unrecognizedType = true; |
| |
if ((type == CIMTYPE_NONE) || |
if (unrecognizedType || |
((type == CIMTYPE_REFERENCE) && | ((type == CIMTYPE_REFERENCE) && |
(strcmp(attributeName, "PARAMTYPE") != 0))) | (strcmp(attributeName, "PARAMTYPE") != 0))) |
{ | { |
|
|
throw XmlSemanticError(lineNumber, message); | throw XmlSemanticError(lineNumber, message); |
} | } |
| |
return type; |
cimType = type; |
|
return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
while (isxdigit(*p)) | while (isxdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 16 | // Make sure we won't overflow when we multiply by 16 |
if (x < PEGASUS_LLONG_MIN/16) |
if (x < PEGASUS_SINT64_MIN/16) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Make sure we don't overflow when we add the next digit | // Make sure we don't overflow when we add the next digit |
Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); | Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); |
if (PEGASUS_LLONG_MIN - x > -newDigit) |
if (PEGASUS_SINT64_MIN - x > -newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
// overflow error | // overflow error |
if (!negative) | if (!negative) |
{ | { |
if (x == PEGASUS_LLONG_MIN) |
if (x == PEGASUS_SINT64_MIN) |
{ | { |
return false; | return false; |
} | } |
|
|
while (isdigit(*p)) | while (isdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 10 | // Make sure we won't overflow when we multiply by 10 |
if (x < PEGASUS_LLONG_MIN/10) |
if (x < PEGASUS_SINT64_MIN/10) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Make sure we won't overflow when we add the next digit | // Make sure we won't overflow when we add the next digit |
Sint64 newDigit = (*p++ - '0'); | Sint64 newDigit = (*p++ - '0'); |
if (PEGASUS_LLONG_MIN - x > -newDigit) |
if (PEGASUS_SINT64_MIN - x > -newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
// overflow error | // overflow error |
if (!negative) | if (!negative) |
{ | { |
if (x == PEGASUS_LLONG_MIN) |
if (x == PEGASUS_SINT64_MIN) |
{ | { |
return false; | return false; |
} | } |
|
|
while (isxdigit(*p)) | while (isxdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 16 | // Make sure we won't overflow when we multiply by 16 |
if (x > PEGASUS_ULLONG_MAX/16) |
if (x > PEGASUS_UINT64_MAX/16) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// We can't overflow when we add the next digit | // We can't overflow when we add the next digit |
Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); | Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); |
if (PEGASUS_ULLONG_MAX - x < newDigit) |
if (PEGASUS_UINT64_MAX - x < newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
while (isdigit(*p)) | while (isdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 10 | // Make sure we won't overflow when we multiply by 10 |
if (x > PEGASUS_ULLONG_MAX/10) |
if (x > PEGASUS_UINT64_MAX/10) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Make sure we won't overflow when we add the next digit | // Make sure we won't overflow when we add the next digit |
Uint64 newDigit = (*p++ - '0'); | Uint64 newDigit = (*p++ - '0'); |
if (PEGASUS_ULLONG_MAX - x < newDigit) |
if (PEGASUS_UINT64_MAX - x < newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Get QUALIFIER.TYPE attribute: | // Get QUALIFIER.TYPE attribute: |
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "QUALIFIER"); |
CIMType type; |
|
getCimTypeAttribute(parser.getLine(), entry, type, "QUALIFIER"); |
| |
// Get QUALIFIER.PROPAGATED | // Get QUALIFIER.PROPAGATED |
| |
|
|
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
CIMType type; |
|
getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY"); |
| |
// Create property: Sets type and !isarray | // Create property: Sets type and !isarray |
| |
|
|
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); |
CIMType type; |
|
getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY.ARRAY"); |
| |
// Get PROPERTY.ARRAYSIZE attribute: | // Get PROPERTY.ARRAYSIZE attribute: |
| |
|
|
| |
// Get PARAMETER.TYPE attribute: | // Get PARAMETER.TYPE attribute: |
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER"); |
CIMType type; |
|
getCimTypeAttribute(parser.getLine(), entry, type, "PARAMETER"); |
| |
// Create parameter: | // Create parameter: |
| |
|
|
| |
// Get PARAMETER.ARRAY.TYPE attribute: | // Get PARAMETER.ARRAY.TYPE attribute: |
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER.ARRAY"); |
CIMType type; |
|
getCimTypeAttribute(parser.getLine(), entry, type, "PARAMETER.ARRAY"); |
| |
// Get PARAMETER.ARRAYSIZE attribute: | // Get PARAMETER.ARRAYSIZE attribute: |
| |
|
|
| |
// Get TYPE attribute: | // Get TYPE attribute: |
| |
CIMType type = getCimTypeAttribute( |
CIMType type; |
parser.getLine(), entry, "QUALIFIER.DECLARATION"); |
getCimTypeAttribute(parser.getLine(), entry, type, "QUALIFIER.DECLARATION"); |
| |
// Get ISARRAY attribute: | // Get ISARRAY attribute: |
| |
|
|
| |
CIMScope scope = CIMScope (); | CIMScope scope = CIMScope (); |
CIMValue value; | CIMValue value; |
|
Boolean gotValue = false; |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
"VALUE.ARRAY size is not the same as " | "VALUE.ARRAY size is not the same as " |
"ARRAYSIZE attribute"); | "ARRAYSIZE attribute"); |
} | } |
|
|
|
gotValue = true; |
} | } |
else if (getValueElement(parser, type, value)) | else if (getValueElement(parser, type, value)) |
{ | { |
|
|
throw XmlSemanticError(parser.getLine(), | throw XmlSemanticError(parser.getLine(), |
"ISARRAY attribute used but VALUE element encountered"); | "ISARRAY attribute used but VALUE element encountered"); |
} | } |
|
|
|
gotValue = true; |
} | } |
| |
// Now get the closing tag: | // Now get the closing tag: |
|
|
expectEndTag(parser, "QUALIFIER.DECLARATION"); | expectEndTag(parser, "QUALIFIER.DECLARATION"); |
} | } |
| |
if (value.getType() == CIMTYPE_NONE) |
if (!gotValue) |
{ | { |
if (isArray) | if (isArray) |
value.setNullValue(type, true, arraySize); | value.setNullValue(type, true, arraySize); |
|
|
| |
String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); | String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
CIMType type; |
|
getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY"); |
| |
CIMName classOrigin = | CIMName classOrigin = |
getClassOriginAttribute(parser.getLine(), entry, "PROPERTY"); | getClassOriginAttribute(parser.getLine(), entry, "PROPERTY"); |
|
|
| |
// Get PARAMVALUE.PARAMTYPE attribute: | // Get PARAMVALUE.PARAMTYPE attribute: |
| |
type = getCimTypeAttribute(parser.getLine(), entry, "PARAMVALUE", |
Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type, |
"PARAMTYPE", false); |
"PARAMVALUE", "PARAMTYPE", false); |
| |
if (!empty) | if (!empty) |
{ | { |
// Parse VALUE.REFERENCE and VALUE.REFARRAY type | // Parse VALUE.REFERENCE and VALUE.REFARRAY type |
if ( (type == CIMTYPE_REFERENCE) || (type == CIMTYPE_NONE) ) |
if ( (type == CIMTYPE_REFERENCE) || !gotType ) |
{ | { |
CIMObjectPath reference; | CIMObjectPath reference; |
if (XmlReader::getValueReferenceElement(parser, reference)) | if (XmlReader::getValueReferenceElement(parser, reference)) |
{ | { |
value.set(reference); | value.set(reference); |
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
|
gotType = true; |
} | } |
else if (XmlReader::getValueReferenceArrayElement(parser, value)) | else if (XmlReader::getValueReferenceArrayElement(parser, value)) |
{ | { |
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
|
gotType = true; |
} | } |
// If type==reference but no VALUE.REFERENCE found, use null value | // If type==reference but no VALUE.REFERENCE found, use null value |
} | } |
|
|
// Parse non-reference value | // Parse non-reference value |
if ( type != CIMTYPE_REFERENCE ) | if ( type != CIMTYPE_REFERENCE ) |
{ | { |
// If we don't know what type the value is, read it as a String |
CIMType effectiveType; |
CIMType effectiveType = type; |
if (!gotType) |
if ( effectiveType == CIMTYPE_NONE) |
|
{ | { |
|
// If we don't know what type the value is, read it as a String |
effectiveType = CIMTYPE_STRING; | effectiveType = CIMTYPE_STRING; |
} | } |
|
else |
|
{ |
|
effectiveType = type; |
|
} |
| |
if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && | if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && |
!XmlReader::getValueElement(parser, effectiveType, value) ) | !XmlReader::getValueElement(parser, effectiveType, value) ) |
|
|
expectEndTag(parser, "PARAMVALUE"); | expectEndTag(parser, "PARAMVALUE"); |
} | } |
| |
paramValue = CIMParamValue(name, value, Boolean(type!=CIMTYPE_NONE)); |
paramValue = CIMParamValue(name, value, gotType); |
| |
return true; | return true; |
} | } |
|
|
// Get RETURNVALUE.PARAMTYPE attribute: | // Get RETURNVALUE.PARAMTYPE attribute: |
// NOTE: Array type return values are not allowed (2/20/02) | // NOTE: Array type return values are not allowed (2/20/02) |
| |
type = getCimTypeAttribute(parser.getLine(), entry, "RETURNVALUE", |
Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type, |
"PARAMTYPE", false); |
"RETURNVALUE", "PARAMTYPE", false); |
| |
// Parse VALUE.REFERENCE type | // Parse VALUE.REFERENCE type |
if ( (type == CIMTYPE_REFERENCE) || (type == CIMTYPE_NONE) ) |
if ( (type == CIMTYPE_REFERENCE) || !gotType ) |
{ | { |
CIMObjectPath reference; | CIMObjectPath reference; |
if (XmlReader::getValueReferenceElement(parser, reference)) | if (XmlReader::getValueReferenceElement(parser, reference)) |
{ | { |
returnValue.set(reference); | returnValue.set(reference); |
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
|
gotType = true; |
} | } |
else if (type == CIMTYPE_REFERENCE) | else if (type == CIMTYPE_REFERENCE) |
{ | { |
|
|
// Parse non-reference return value | // Parse non-reference return value |
if ( type != CIMTYPE_REFERENCE ) | if ( type != CIMTYPE_REFERENCE ) |
{ | { |
// If we don't know what type the value is, read it as a String |
if (!gotType) |
if ( type == CIMTYPE_NONE) |
|
{ | { |
|
// If we don't know what type the value is, read it as a String |
type = CIMTYPE_STRING; | type = CIMTYPE_STRING; |
} | } |
| |