version 1.125, 2007/06/05 09:45:30
|
version 1.132, 2008/10/01 04:46:17
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/Constants.h> |
#include <errno.h> | #include <errno.h> |
#include <cctype> | #include <cctype> |
#include <cstdio> | #include <cstdio> |
|
|
#include "XmlConstants.h" | #include "XmlConstants.h" |
| |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
|
#include <Pegasus/Common/StringConversion.h> |
#include <Pegasus/Common/AutoPtr.h> | #include <Pegasus/Common/AutoPtr.h> |
#include "CIMNameUnchecked.h" | #include "CIMNameUnchecked.h" |
| |
#define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000)) |
|
#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF) |
|
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
|
// The CIMName was already checked with legal() + String() |
return name; |
return CIMNameUnchecked(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// getEmbeddedObjectAttribute() | // getEmbeddedObjectAttribute() |
// | // |
// <!ENTITY % EmbeddedObject "EMBEDDEDOBJECT (object | instance) #IMPLIED"> |
// <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED"> |
|
// |
|
// EmbeddedObjectAttributeType: |
|
// NO_EMBEDDED_OBJECT = 0, |
|
// EMBEDDED_OBJECT_ATTR = 1, |
|
// EMBEDDED_INSTANCE_ATTR = 2 |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
String XmlReader::getEmbeddedObjectAttribute( |
XmlReader::EmbeddedObjectAttributeType XmlReader::getEmbeddedObjectAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
const char* elementName) |
const char* tagName) |
{ | { |
String embeddedObject; |
const char* embeddedObject; |
| |
if (!entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject)) |
// Check for both upper case and mixed case "EmbeddedObject" |
return String(); |
// because of an error in an earlier pegasus version where we |
|
// used upper case in the generation of the attribute name |
|
// whereas the DMTF spec calls for mixed case. |
|
if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) && |
|
!entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject)) |
|
return NO_EMBEDDED_OBJECT; |
| |
// The embeddedObject attribute, if present, must have the string | // The embeddedObject attribute, if present, must have the string |
// value "object" or "instance". | // value "object" or "instance". |
if (!(String::equal(embeddedObject, "object") || |
if (strcmp(embeddedObject, "object") == 0) |
String::equal(embeddedObject, "instance"))) |
|
{ | { |
|
return EMBEDDED_OBJECT_ATTR; |
|
} |
|
|
|
if (strcmp(embeddedObject, "instance") == 0) |
|
{ |
|
return EMBEDDED_INSTANCE_ATTR; |
|
} |
|
|
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "%s.EMBEDDEDOBJECT", elementName); |
sprintf(buffer, "%s.EmbeddedObject", tagName); |
| |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", | "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
"Illegal value for $0 attribute", | "Illegal value for $0 attribute", |
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} |
|
| |
return embeddedObject; |
return NO_EMBEDDED_OBJECT; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
|
// The CIMName was already checked with legal() + String() |
return name; |
return CIMNameUnchecked(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
|
// The CIMName was already checked with legal() + String() |
return superClass; |
return CIMNameUnchecked(superClass); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!required) | if (!required) |
return defaultValue; | return defaultValue; |
| |
char buffer[62]; |
char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "%s.%s", attributeName, tagName); | sprintf(buffer, "%s.%s", attributeName, tagName); |
| |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
else if (strcmp(tmp, "false") == 0) | else if (strcmp(tmp, "false") == 0) |
return false; | return false; |
| |
char buffer[62]; |
char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "%s.%s", attributeName, tagName); | sprintf(buffer, "%s.%s", attributeName, tagName); |
| |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
return false; | return false; |
} | } |
| |
//------------------------------------------------------------------------------ |
|
// |
|
// SringToReal() |
|
// |
|
// [ "+" | "-" ] *decimalDigit "." 1*decimalDigit |
|
// [ ( "e" | "E" ) [ "+" | "-" ] 1*decimalDigit ] |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::stringToReal(const char* stringValue, Real64& x) |
|
{ |
|
// |
|
// Check the string against the DMTF-defined grammar |
|
// |
|
const char* p = stringValue; |
|
|
|
if (!*p) |
|
return false; |
|
|
|
// Skip optional sign: |
|
|
|
if (*p == '+' || *p == '-') |
|
p++; |
|
|
|
// Skip optional first set of digits: |
|
|
|
while (isdigit(*p)) |
|
p++; |
|
|
|
// Test required dot: |
|
|
|
if (*p++ != '.') |
|
return false; |
|
|
|
// One or more digits required: |
|
|
|
if (!isdigit(*p++)) |
|
return false; |
|
|
|
while (isdigit(*p)) |
|
p++; |
|
|
|
// If there is an exponent now: |
|
|
|
if (*p) |
|
{ |
|
// Test exponent: |
|
|
|
if (*p != 'e' && *p != 'E') |
|
return false; |
|
|
|
p++; |
|
|
|
// Skip optional sign: |
|
|
|
if (*p == '+' || *p == '-') |
|
p++; |
|
|
|
// One or more digits required: |
|
|
|
if (!isdigit(*p++)) |
|
return false; |
|
|
|
while (isdigit(*p)) |
|
p++; |
|
} |
|
|
|
if (*p) |
|
return false; |
|
|
|
// |
|
// Do the conversion |
|
// |
|
char* end; |
|
errno = 0; |
|
x = strtod(stringValue, &end); |
|
if (*end || (errno == ERANGE)) |
|
{ |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
inline Uint8 _xmlReader_hexCharToNumeric(const char c) |
|
{ |
|
Uint8 n; |
|
|
|
if (isdigit(c)) |
|
n = (c - '0'); |
|
else if (isupper(c)) |
|
n = (c - 'A' + 10); |
|
else // if (islower(c)) |
|
n = (c - 'a' + 10); |
|
|
|
return n; |
|
} |
|
|
|
// See http://www.ietf.org/rfc/rfc2396.txt section 2 | // See http://www.ietf.org/rfc/rfc2396.txt section 2 |
// | // |
// Also see the "CIM Operations over HTTP" spec, section 3.3.2 and | // Also see the "CIM Operations over HTTP" spec, section 3.3.2 and |
|
|
throw ParseError(MessageLoader::getMessage(mlParms)); | throw ParseError(MessageLoader::getMessage(mlParms)); |
} | } |
| |
Uint8 digit1 = _xmlReader_hexCharToNumeric(char(uriString[++i])); |
Uint8 digit1 = |
Uint8 digit2 = _xmlReader_hexCharToNumeric(char(uriString[++i])); |
StringConversion::hexCharToNumeric(char(uriString[++i])); |
|
Uint8 digit2 = |
|
StringConversion::hexCharToNumeric(char(uriString[++i])); |
if ( (digit1 > 15) || (digit2 > 15) ) | if ( (digit1 > 15) || (digit2 > 15) ) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
const char* stringValue, | const char* stringValue, |
Sint64& x) | Sint64& x) |
{ | { |
x = 0; |
return (StringConversion::stringToSint64( |
const char* p = stringValue; |
stringValue, StringConversion::decimalStringToUint64, x) || |
|
StringConversion::stringToSint64( |
if (!p || !*p) |
stringValue, StringConversion::hexStringToUint64, x)); |
return false; |
|
|
|
// Skip optional sign: |
|
|
|
Boolean negative = *p == '-'; |
|
|
|
if (negative || *p == '+') |
|
p++; |
|
|
|
if (*p == '0') |
|
{ |
|
if ( (p[1] == 'x') || (p[1] == 'X') ) |
|
{ |
|
// Convert a hexadecimal string |
|
|
|
// Skip over the "0x" |
|
p+=2; |
|
|
|
// At least one hexadecimal digit is required |
|
if (!isxdigit(*p)) |
|
return false; |
|
|
|
// Build the Sint64 as a negative number, regardless of the |
|
// eventual sign (negative numbers can be bigger than positive ones) |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isxdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 16 |
|
if (x < PEGASUS_SINT64_MIN/16) |
|
{ |
|
return false; |
|
} |
|
x = x << 4; |
|
|
|
// Make sure we don't overflow when we add the next digit |
|
Sint64 newDigit = Sint64(_xmlReader_hexCharToNumeric(*p++)); |
|
if (PEGASUS_SINT64_MIN - x > -newDigit) |
|
{ |
|
return false; |
|
} |
|
x = x - newDigit; |
|
} |
|
|
|
// If we found a non-hexadecimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
// Return the integer to positive, if necessary, checking for an |
|
// overflow error |
|
if (!negative) |
|
{ |
|
if (x == PEGASUS_SINT64_MIN) |
|
{ |
|
return false; |
|
} |
|
x = -x; |
|
} |
|
return true; |
|
} |
|
else |
|
{ |
|
// A decimal string that starts with '0' must be exactly "0". |
|
return p[1] == '\0'; |
|
} |
|
} |
|
|
|
// Expect a positive decimal digit: |
|
|
|
// At least one decimal digit is required |
|
if (!isdigit(*p)) |
|
return false; |
|
|
|
// Build the Sint64 as a negative number, regardless of the |
|
// eventual sign (negative numbers can be bigger than positive ones) |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 10 |
|
if (x < PEGASUS_SINT64_MIN/10) |
|
{ |
|
return false; |
|
} |
|
x = 10 * x; |
|
|
|
// Make sure we won't overflow when we add the next digit |
|
Sint64 newDigit = (*p++ - '0'); |
|
if (PEGASUS_SINT64_MIN - x > -newDigit) |
|
{ |
|
return false; |
|
} |
|
x = x - newDigit; |
|
} |
|
|
|
// If we found a non-decimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
// Return the integer to positive, if necessary, checking for an |
|
// overflow error |
|
if (!negative) |
|
{ |
|
if (x == PEGASUS_SINT64_MIN) |
|
{ |
|
return false; |
|
} |
|
x = -x; |
|
} |
|
return true; |
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
const char* stringValue, | const char* stringValue, |
Uint64& x) | Uint64& x) |
{ | { |
x = 0; |
return (StringConversion::decimalStringToUint64(stringValue, x) || |
const char* p = stringValue; |
StringConversion::hexStringToUint64(stringValue, x)); |
|
|
if (!p || !*p) |
|
return false; |
|
|
|
if (*p == '0') |
|
{ |
|
if ( (p[1] == 'x') || (p[1] == 'X') ) |
|
{ |
|
// Convert a hexadecimal string |
|
|
|
// Skip over the "0x" |
|
p+=2; |
|
|
|
// At least one hexadecimal digit is required |
|
if (!*p) |
|
return false; |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isxdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 16 |
|
if (x > PEGASUS_UINT64_MAX/16) |
|
{ |
|
return false; |
|
} |
|
x = x << 4; |
|
|
|
// We can't overflow when we add the next digit |
|
Uint64 newDigit = Uint64(_xmlReader_hexCharToNumeric(*p++)); |
|
if (PEGASUS_UINT64_MAX - x < newDigit) |
|
{ |
|
return false; |
|
} |
|
x = x + newDigit; |
|
} |
|
|
|
// If we found a non-hexadecimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
return true; |
|
} |
|
else |
|
{ |
|
// A decimal string that starts with '0' must be exactly "0". |
|
return p[1] == '\0'; |
|
} |
|
} |
|
|
|
// Expect a positive decimal digit: |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 10 |
|
if (x > PEGASUS_UINT64_MAX/10) |
|
{ |
|
return false; |
|
} |
|
x = 10 * x; |
|
|
|
// Make sure we won't overflow when we add the next digit |
|
Uint64 newDigit = (*p++ - '0'); |
|
if (PEGASUS_UINT64_MAX - x < newDigit) |
|
{ |
|
return false; |
|
} |
|
x = x + newDigit; |
|
} |
|
|
|
// If we found a non-decimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
return true; |
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
|
|
// remove this test, utf-8 can be up to 6 bytes per char |
|
/* |
|
if (strlen(valueString) != 1) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_CHAR16_VALUE", |
|
"Invalid char16 value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
|
*/ |
|
// Converts UTF-8 to UTF-16 | // Converts UTF-8 to UTF-16 |
String tmp(valueString); | String tmp(valueString); |
if (tmp.size() != 1) | if (tmp.size() != 1) |
|
|
{ | { |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
if (x >= (Uint64(1)<<8)) |
if (!StringConversion::checkUintBounds(x, type)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.U8_VALUE_OUT_OF_RANGE", | "Common.XmlReader.U8_VALUE_OUT_OF_RANGE", |
|
|
} | } |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
if (x >= (Uint64(1)<<16)) |
if (!StringConversion::checkUintBounds(x, type)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.U16_VALUE_OUT_OF_RANGE", | "Common.XmlReader.U16_VALUE_OUT_OF_RANGE", |
|
|
} | } |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
if (x >= (Uint64(1)<<32)) |
if (!StringConversion::checkUintBounds(x, type)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.U32_VALUE_OUT_OF_RANGE", | "Common.XmlReader.U32_VALUE_OUT_OF_RANGE", |
|
|
{ | { |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
if ((x >= (Sint64(1)<<7)) || (x < (-(Sint64(1)<<7)))) |
if (!StringConversion::checkSintBounds(x, type)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.S8_VALUE_OUT_OF_RANGE", | "Common.XmlReader.S8_VALUE_OUT_OF_RANGE", |
|
|
} | } |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
if ((x >= (Sint64(1)<<15)) || (x < (-(Sint64(1)<<15)))) |
if (!StringConversion::checkSintBounds(x, type)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.S16_VALUE_OUT_OF_RANGE", | "Common.XmlReader.S16_VALUE_OUT_OF_RANGE", |
|
|
} | } |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
if ((x >= (Sint64(1)<<31)) || (x < (-(Sint64(1)<<31)))) |
if (!StringConversion::checkSintBounds(x, type)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.S32_VALUE_OUT_OF_RANGE", | "Common.XmlReader.S32_VALUE_OUT_OF_RANGE", |
|
|
{ | { |
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) |
if (!StringConversion::stringToReal64(valueString, x)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.INVALID_RN_VALUE", | "Common.XmlReader.INVALID_RN_VALUE", |
|
|
{ | { |
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) |
if (!StringConversion::stringToReal64(valueString, x)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.INVALID_RN_VALUE", | "Common.XmlReader.INVALID_RN_VALUE", |
|
|
// just a Pegasus internal representation of an embedded object. However, | // just a Pegasus internal representation of an embedded object. However, |
// this case is used when decoding string representations of embedded objects. | // this case is used when decoding string representations of embedded objects. |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
{ | { |
CIMObject x; | CIMObject x; |
| |
|
|
| |
if (XmlReader::getInstanceElement(tmp_parser, cimInstance)) | if (XmlReader::getInstanceElement(tmp_parser, cimInstance)) |
{ | { |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
if (type == CIMTYPE_INSTANCE) | if (type == CIMTYPE_INSTANCE) |
return CIMValue(cimInstance); | return CIMValue(cimInstance); |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
x = CIMObject(cimInstance); | x = CIMObject(cimInstance); |
} | } |
else if (XmlReader::getClassElement(tmp_parser, cimClass)) | else if (XmlReader::getClassElement(tmp_parser, cimClass)) |
|
|
} | } |
else | else |
{ | { |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
if (type == CIMTYPE_OBJECT) | if (type == CIMTYPE_OBJECT) |
{ | { |
// change "element" to "embedded object" | // change "element" to "embedded object" |
|
|
"Expected INSTANCE element"); | "Expected INSTANCE element"); |
throw XmlValidationError(lineNumber, mlParms); | throw XmlValidationError(lineNumber, mlParms); |
} | } |
#else |
|
// change "element" to "embedded object" |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); |
|
throw XmlValidationError(lineNumber, mlParms); |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
} | } |
// Ok, now we can delete the storage for the temporary | // Ok, now we can delete the storage for the temporary |
// XmlParser. | // XmlParser. |
|
|
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
return StringArrayToValueAux( | return StringArrayToValueAux( |
lineNumber, array, type, (CIMObject*)0); | lineNumber, array, type, (CIMObject*)0); |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
return StringArrayToValueAux( | return StringArrayToValueAux( |
lineNumber, array, type, (CIMInstance*)0); | lineNumber, array, type, (CIMInstance*)0); |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
|
|
default: | default: |
break; | break; |
} | } |
|
|
Boolean propagated = getCimBooleanAttribute( | Boolean propagated = getCimBooleanAttribute( |
parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); | parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); |
| |
// Get PROPERTY.EMBEDDEDOBJECT attribute: |
// Get PROPERTY.EmbeddedObject attribute: |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = |
parser.getLine(), entry, "PROPERTY"); |
getEmbeddedObjectAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
|
|
} | } |
| |
Boolean embeddedObjectQualifierValue = false; | Boolean embeddedObjectQualifierValue = false; |
Uint32 ix = property.findQualifier(CIMName("EmbeddedObject")); |
Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); | property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
String embeddedInstanceQualifierValue; | String embeddedInstanceQualifierValue; |
ix = property.findQualifier(CIMName("EmbeddedInstance")); |
ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get( | property.getQualifier(ix).getValue().get( |
embeddedInstanceQualifierValue); | embeddedInstanceQualifierValue); |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
// If the EmbeddedObject attribute is present with value "object" |
// If the EMBEDDEDOBJECT attribute is present with value "object" |
|
// or the EmbeddedObject qualifier exists on this property with value "true" | // or the EmbeddedObject qualifier exists on this property with value "true" |
// then |
// then convert the EmbeddedObject-encoded string into a CIMObject |
// Convert the EmbeddedObject-encoded string into a CIMObject |
Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) || |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
Boolean isEmbeddedObject = String::equal(embeddedObject, "object") || |
|
embeddedObjectQualifierValue; | embeddedObjectQualifierValue; |
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") || |
Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) || |
embeddedInstanceQualifierValue.size() > 0; | embeddedInstanceQualifierValue.size() > 0; |
if (isEmbeddedObject || isEmbeddedInstance) | if (isEmbeddedObject || isEmbeddedInstance) |
{ | { |
// The EMBEDDEDOBJECT attribute is only valid on Properties of type |
// The EmbeddedObject attribute is only valid on Properties of type |
// string | // string |
if (type == CIMTYPE_STRING) | if (type == CIMTYPE_STRING) |
{ | { |
|
|
| |
// Copy the qualifiers from the String property to the CIMObject | // Copy the qualifiers from the String property to the CIMObject |
// property. | // property. |
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
for (Uint32 i = 0; i < property.getQualifierCount(); ++i) |
{ | { |
// All properties are copied, including the EmbeddedObject | // All properties are copied, including the EmbeddedObject |
// qualifier. This way we don't have to keep track to know | // qualifier. This way we don't have to keep track to know |
// that the EmbeddedObject qualifier needs to be added back | // that the EmbeddedObject qualifier needs to be added back |
// during the encode step. | // during the encode step. |
new_property.addQualifier(property.getQualifier(ix)); |
new_property.addQualifier(property.getQualifier(i)); |
} | } |
| |
value = new_value; | value = new_value; |
|
|
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", | "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
"The EmbeddedObject attribute is only valid on string types."); |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
#else |
|
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Properties of type |
|
// string |
|
if (type == CIMTYPE_STRING) |
|
{ |
|
type = CIMTYPE_OBJECT; |
|
CIMValue new_value(type, false); |
|
CIMProperty new_property = CIMProperty( |
|
name, new_value, 0, CIMName(), classOrigin, propagated); |
|
|
|
// Copy the qualifiers from the String property to the CIMObject |
|
// property. |
|
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
|
{ |
|
// All properties are copied, including the EmbeddedObject |
|
// qualifier. This way we don't have to keep track to know |
|
// that the EmbeddedObject qualifier needs to be added back |
|
// during the encode step. |
|
new_property.addQualifier(property.getQualifier(ix)); |
|
} |
|
|
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// Continue on to get property value, if not empty. | // Continue on to get property value, if not empty. |
if (!empty) | if (!empty) |
{ | { |
|
|
| |
Uint64 arraySize; | Uint64 arraySize; |
| |
if (!stringToUnsignedInteger(tmp, arraySize) || arraySize == 0) |
if (!stringToUnsignedInteger(tmp, arraySize) || (arraySize == 0) || |
|
!StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32)) |
{ | { |
char message[128]; | char message[128]; |
sprintf(message, "%s.%s", tagName, "ARRAYSIZE"); | sprintf(message, "%s.%s", tagName, "ARRAYSIZE"); |
|
|
false, | false, |
false); | false); |
| |
// Get PROPERTY.EMBEDDEDOBJECT attribute: |
// Get PROPERTY.EmbeddedObject attribute: |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
parser.getLine(), entry, "PROPERTY.ARRAY"); | parser.getLine(), entry, "PROPERTY.ARRAY"); |
| |
// Create property: | // Create property: |
|
|
} | } |
| |
Boolean embeddedObjectQualifierValue = false; | Boolean embeddedObjectQualifierValue = false; |
Uint32 ix = property.findQualifier(CIMName("EmbeddedObject")); |
Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); | property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
String embeddedInstanceQualifierValue; | String embeddedInstanceQualifierValue; |
ix = property.findQualifier(CIMName("EmbeddedInstance")); |
ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get( | property.getQualifier(ix).getValue().get( |
embeddedInstanceQualifierValue); | embeddedInstanceQualifierValue); |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
// If the EmbeddedObject attribute is present with value "object" |
// If the EMBEDDEDOBJECT attribute is present with value "object" |
|
// or the EmbeddedObject qualifier exists on this property with value "true" | // or the EmbeddedObject qualifier exists on this property with value "true" |
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // Convert the EmbeddedObject-encoded string into a CIMObject |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) || |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object") || |
|
embeddedObjectQualifierValue; | embeddedObjectQualifierValue; |
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") || |
Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) || |
embeddedInstanceQualifierValue.size() > 0; | embeddedInstanceQualifierValue.size() > 0; |
if (isEmbeddedObject || isEmbeddedInstance) | if (isEmbeddedObject || isEmbeddedInstance) |
{ | { |
// The EMBEDDEDOBJECT attribute is only valid on Properties of type |
// The EmbeddedObject attribute is only valid on Properties of type |
// string | // string |
if (type == CIMTYPE_STRING) | if (type == CIMTYPE_STRING) |
{ | { |
|
|
| |
// Copy the qualifiers from the String property to the CIMObject | // Copy the qualifiers from the String property to the CIMObject |
// property. | // property. |
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
for (Uint32 i = 0; i < property.getQualifierCount(); ++i) |
{ |
|
// All properties are copied, including the EmbeddedObject |
|
// qualifier. This way we don't have to keep track to know |
|
// that the EmbeddedObject qualifier needs to be added back |
|
// during the encode step. |
|
new_property.addQualifier(property.getQualifier(ix)); |
|
} |
|
|
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#else |
|
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Properties of type |
|
// string |
|
if (type == CIMTYPE_STRING) |
|
{ |
|
type = CIMTYPE_OBJECT; |
|
CIMValue new_value(type, true, arraySize); |
|
CIMProperty new_property = CIMProperty( |
|
name, new_value, arraySize, CIMName(), classOrigin, propagated); |
|
|
|
// Copy the qualifiers from the String property to the CIMObject |
|
// property. |
|
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
|
{ | { |
// All properties are copied, including the EmbeddedObject | // All properties are copied, including the EmbeddedObject |
// qualifier. This way we don't have to keep track to know | // qualifier. This way we don't have to keep track to know |
// that the EmbeddedObject qualifier needs to be added back | // that the EmbeddedObject qualifier needs to be added back |
// during the encode step. | // during the encode step. |
new_property.addQualifier(property.getQualifier(ix)); |
new_property.addQualifier(property.getQualifier(i)); |
} | } |
| |
value = new_value; | value = new_value; |
|
|
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", | "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
"The EmbeddedObject attribute is only valid on string types."); |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// Continue on to get property array value, if not empty. | // Continue on to get property array value, if not empty. |
// Else not an embedded object, if not empty, get the property array value. | // Else not an embedded object, if not empty, get the property array value. |
if (!empty) | if (!empty) |
|
|
const XmlEntry& entry, | const XmlEntry& entry, |
const char* elementName) | const char* elementName) |
{ | { |
String tmp; |
const char* tmp; |
| |
if (!entry.getAttributeValue("VALUETYPE", tmp)) | if (!entry.getAttributeValue("VALUETYPE", tmp)) |
return CIMKeyBinding::STRING; | return CIMKeyBinding::STRING; |
| |
if (String::equal(tmp, "string")) |
if (strcmp(tmp, "string") == 0) |
return CIMKeyBinding::STRING; | return CIMKeyBinding::STRING; |
else if (String::equal(tmp, "boolean")) |
else if (strcmp(tmp, "boolean") == 0) |
return CIMKeyBinding::BOOLEAN; | return CIMKeyBinding::BOOLEAN; |
else if (String::equal(tmp, "numeric")) |
else if (strcmp(tmp, "numeric") == 0) |
return CIMKeyBinding::NUMERIC; | return CIMKeyBinding::NUMERIC; |
| |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
|
|
objectName.set(String(), CIMNamespaceName(), className); | objectName.set(String(), CIMNamespaceName(), className); |
return true; | return true; |
} | } |
else if (getInstanceNameElement(parser, objectName)) |
|
return true; |
if (!getInstanceNameElement(parser, objectName)) |
else |
|
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.EXPECTED_CLASSNAME_OR_INSTANCENAME_ELEMENT", | "Common.XmlReader.EXPECTED_CLASSNAME_OR_INSTANCENAME_ELEMENT", |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
PEGASUS_UNREACHABLE( return false; ) |
return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!testStartTag(parser, entry, "OBJECTPATH")) | if (!testStartTag(parser, entry, "OBJECTPATH")) |
return false; | return false; |
| |
if (getClassPathElement(parser, objectPath)) |
if (!getClassPathElement(parser, objectPath) && |
{ |
!getInstancePathElement(parser, objectPath)) |
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
|
} |
|
else if (getInstancePathElement(parser, objectPath)) |
|
{ |
|
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
|
} |
|
else |
|
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", | "Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
PEGASUS_UNREACHABLE(return false;) |
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
// Get PROPERTY.EMBEDDEDOBJECT |
// Get PROPERTY.EmbeddedObject |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
parser.getLine(), entry, "PARAMVALUE"); | parser.getLine(), entry, "PARAMVALUE"); |
| |
// Get PARAMVALUE.PARAMTYPE attribute: | // Get PARAMVALUE.PARAMTYPE attribute: |
|
|
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
gotType = true; | gotType = true; |
} | } |
// If type==reference but no VALUE.REFERENCE found, use null value |
else |
|
{ |
|
gotType = false; // Can't distinguish array and non-array types |
|
} |
} | } |
| |
// Parse non-reference value | // Parse non-reference value |
|
|
effectiveType = type; | effectiveType = type; |
} | } |
| |
// If the EMBEDDEDOBJECT attribute is present with value "object" |
// If the EmbeddedObject attribute is present with value "object" |
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // Convert the EmbeddedObject-encoded string into a CIMObject |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
if (embeddedObject != NO_EMBEDDED_OBJECT) |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object"); |
|
Boolean isEmbeddedInstance = |
|
String::equal(embeddedObject, "instance"); |
|
if (isEmbeddedObject || isEmbeddedInstance) |
|
{ | { |
// The EMBEDDEDOBJECT attribute is only valid on Parameters |
// The EmbeddedObject attribute is only valid on Parameters |
// of type string | // of type string |
// The type must have been specified. | // The type must have been specified. |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
{ | { |
if (isEmbeddedObject) |
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
// Used below by getValueElement() or | // Used below by getValueElement() or |
// getValueArrayElement() | // getValueArrayElement() |
effectiveType = CIMTYPE_OBJECT; | effectiveType = CIMTYPE_OBJECT; |
|
|
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", | "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
"The EMBEDDEDOBJECT attribute is only valid on " |
"The EmbeddedObject attribute is only valid on " |
"string types."); | "string types."); |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
#else |
|
if (String::equal(embeddedObject, "object")) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Parameters |
|
// of type string |
|
// The type must have been specified. |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
// Used below by getValueElement() or getValueArrayElement() |
|
effectiveType = CIMTYPE_OBJECT; |
|
} |
|
else |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on " |
|
"string types."); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
| |
if (!XmlReader::getValueArrayElement(parser, effectiveType, value) | if (!XmlReader::getValueArrayElement(parser, effectiveType, value) |
&& !XmlReader::getValueElement(parser, effectiveType, value)) | && !XmlReader::getValueElement(parser, effectiveType, value)) |
|
|
if (!testStartTag(parser, entry, "RETURNVALUE")) | if (!testStartTag(parser, entry, "RETURNVALUE")) |
return false; | return false; |
| |
// Get PROPERTY.EMBEDDEDOBJECT |
// Get PROPERTY.EmbeddedObject |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
parser.getLine(), entry, "RETURNVALUE"); | parser.getLine(), entry, "RETURNVALUE"); |
| |
// Get RETURNVALUE.PARAMTYPE attribute: | // Get RETURNVALUE.PARAMTYPE attribute: |
|
|
// If we don't know what type the value is, read it as a String | // If we don't know what type the value is, read it as a String |
type = CIMTYPE_STRING; | type = CIMTYPE_STRING; |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
if (embeddedObject != NO_EMBEDDED_OBJECT) |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object"); |
|
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance"); |
|
if (isEmbeddedObject || isEmbeddedInstance) |
|
{ | { |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
{ | { |
if (isEmbeddedObject) |
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
// Used below by getValueElement() or getValueArrayElement() | // Used below by getValueElement() or getValueArrayElement() |
type = CIMTYPE_OBJECT; | type = CIMTYPE_OBJECT; |
else | else |
|
|
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", | "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
"The EMBEDDEDOBJECT attribute is only valid on string " |
"The EmbeddedObject attribute is only valid on string " |
"types."); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#else |
|
if (String::equal(embeddedObject, "object")) |
|
{ |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
type = CIMTYPE_OBJECT; // Used below by getValueElement() |
|
} |
|
else |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string " |
|
"types."); | "types."); |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
if ( !XmlReader::getValueElement(parser, type, returnValue) ) | if ( !XmlReader::getValueElement(parser, type, returnValue) ) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |