version 1.110, 2005/03/09 21:02:26
|
version 1.116, 2006/01/30 16:17:08
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) | // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) | // Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) |
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3103 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
#endif | #endif |
// l10n | // l10n |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
|
#include <Pegasus/Common/AutoPtr.h> |
|
#include "CIMNameUnchecked.h" |
| |
#define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000)) | #define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000)) |
#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF) | #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF) |
|
|
| |
#endif | #endif |
} | } |
return CIMName (name); |
return CIMNameUnchecked(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
// Convert the non-NULL string to a CIMObject (containing either a | // Convert the non-NULL string to a CIMObject (containing either a |
// CIMInstance or a CIMClass). | // CIMInstance or a CIMClass). |
| |
// First we need to create a new "temporary" XMLParser that is |
// First we need to create a new "temporary" XmlParser that is |
// just the value of the Embedded Object in String representation. | // just the value of the Embedded Object in String representation. |
char* tmp_buffer = new char[strlen(valueString) + 1]; |
AutoArrayPtr<char> tmp_buffer(new char[strlen(valueString) + 1]); |
strcpy(tmp_buffer, valueString); |
strcpy(tmp_buffer.get(), valueString); |
XmlParser tmp_parser(tmp_buffer); |
XmlParser tmp_parser(tmp_buffer.get()); |
delete [] tmp_buffer; |
|
| |
// The next bit of logic constructs a CIMObject from the Embedded Object String. | // The next bit of logic constructs a CIMObject from the Embedded Object String. |
// It is similar to the method XmlReader::getValueObjectElement(). | // It is similar to the method XmlReader::getValueObjectElement(). |
|
|
throw XmlValidationError(lineNumber, mlParms); | throw XmlValidationError(lineNumber, mlParms); |
| |
} | } |
|
// Ok, now we can delete the storage for the temporary XmlParser. |
|
tmp_buffer.reset(); |
} | } |
return CIMValue(x); | return CIMValue(x); |
} | } |
|
|
| |
XmlEntry entry; | XmlEntry entry; |
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
return false; |
|
|
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
|
// Since stringToValue() takes a char* as input, we handle CIMTYPE_OBJECT separately. |
|
if (type == CIMTYPE_OBJECT) |
|
{ |
|
CIMObject cimObject; |
|
|
|
if (empty) |
|
{ | { |
cimObject = CIMObject(); |
return false; |
} | } |
else |
|
{ |
|
// Convert the non-empty value to a CIMObject (containing either a |
|
// CIMInstance or a CIMClass). |
|
|
|
// The next bit of logic constructs a CIMObject from the Embedded Object String. |
|
// It is similar to the method XmlReader::getValueObjectElement(). |
|
CIMInstance cimInstance; |
|
CIMClass cimClass; |
|
| |
if (XmlReader::getInstanceElement(parser, cimInstance)) |
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
{ |
|
cimObject = CIMObject(cimInstance); |
|
} |
|
else if (XmlReader::getClassElement(parser, cimClass)) |
|
{ |
|
cimObject = CIMObject(cimClass); |
|
} |
|
else |
|
{ |
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "Expected INSTANCE or CLASS element"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); // change "element" to "embedded object" |
|
| |
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
expectEndTag(parser, "VALUE"); |
|
} |
|
value = CIMValue(cimObject); |
|
} |
|
else |
|
{ |
|
const char* valueString = ""; | const char* valueString = ""; |
| |
if (!empty) | if (!empty) |
{ | { |
if (testContentOrCData(parser, entry)) | if (testContentOrCData(parser, entry)) |
|
{ |
valueString = entry.text; | valueString = entry.text; |
|
} |
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
|
|
if (!empty) | if (!empty) |
#endif | #endif |
value = stringToValue(parser.getLine(), valueString,type); | value = stringToValue(parser.getLine(), valueString,type); |
} |
|
| |
return true; | return true; |
} | } |
|
|
// Get VALUE.ARRAY open tag: | // Get VALUE.ARRAY open tag: |
| |
XmlEntry entry; | XmlEntry entry; |
|
Array<const char*> stringArray; |
| |
// If no VALUE.ARRAY start tag, return false | // If no VALUE.ARRAY start tag, return false |
if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY")) |
|
|
| |
if (entry.type != XmlEntry::EMPTY_TAG) | if (entry.type != XmlEntry::EMPTY_TAG) |
{ | { |
if (type == CIMTYPE_OBJECT) |
|
{ |
|
Array<CIMObject> objectArray; |
|
|
|
// For each VALUE element: | // For each VALUE element: |
while (testStartTagOrEmptyTag(parser, entry, "VALUE")) |
|
{ |
|
CIMObject cimObject; |
|
| |
if (entry.type == XmlEntry::EMPTY_TAG) |
|
{ |
|
cimObject = CIMObject(); |
|
} |
|
else |
|
{ |
|
// Convert the non-empty value to a CIMObject (containing either a |
|
// CIMInstance or a CIMClass). |
|
|
|
// The next bit of logic constructs a CIMObject from the Embedded Object String. |
|
// It is similar to the method XmlReader::getValueObjectElement(). |
|
CIMInstance cimInstance; |
|
CIMClass cimClass; |
|
|
|
if (XmlReader::getInstanceElement(parser, cimInstance)) |
|
{ |
|
cimObject = CIMObject(cimInstance); |
|
} |
|
else if (XmlReader::getClassElement(parser, cimClass)) |
|
{ |
|
cimObject = CIMObject(cimClass); |
|
} |
|
else |
|
{ |
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "Expected INSTANCE or CLASS element"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); // change "element" to "embedded object" |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
expectEndTag(parser, "VALUE"); |
|
} |
|
objectArray.append(cimObject); |
|
} |
|
value = CIMValue(objectArray); |
|
} |
|
else |
|
{ |
|
Array<const char*> stringArray; |
|
|
|
// For each VALUE element: |
|
while (testStartTagOrEmptyTag(parser, entry, "VALUE")) | while (testStartTagOrEmptyTag(parser, entry, "VALUE")) |
{ | { |
if (entry.type == XmlEntry::EMPTY_TAG) | if (entry.type == XmlEntry::EMPTY_TAG) |
|
|
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
value = stringArrayToValue(parser.getLine(), stringArray, type); |
|
} |
|
| |
expectEndTag(parser, "VALUE.ARRAY"); | expectEndTag(parser, "VALUE.ARRAY"); |
} | } |
| |
|
value = stringArrayToValue(parser.getLine(), stringArray, type); |
return true; | return true; |
} | } |
| |
|
|
new_property.addQualifier(property.getQualifier(ix)); | new_property.addQualifier(property.getQualifier(ix)); |
} | } |
| |
value = new_value; // does this leak? |
value = new_value; |
property = new_property; // does this leak? |
property = new_property; |
} | } |
else | else |
{ | { |
|
|
new_property.addQualifier(property.getQualifier(ix)); | new_property.addQualifier(property.getQualifier(ix)); |
} | } |
| |
value = new_value; // does this leak? |
value = new_value; |
property = new_property; // does this leak? |
property = new_property; |
} | } |
else | else |
{ | { |
|
|
Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type, | Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type, |
"PARAMVALUE", "PARAMTYPE", false); | "PARAMVALUE", "PARAMTYPE", false); |
| |
if (!empty) |
if (empty) |
|
{ |
|
gotType = false; // Can't distinguish array and non-array types |
|
} |
|
else |
{ | { |
// Parse VALUE.REFERENCE and VALUE.REFARRAY type | // Parse VALUE.REFERENCE and VALUE.REFARRAY type |
if ( (type == CIMTYPE_REFERENCE) || !gotType ) | if ( (type == CIMTYPE_REFERENCE) || !gotType ) |
|
|
// The type must have been specified. | // The type must have been specified. |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
{ | { |
type = CIMTYPE_OBJECT; // Used below by getValueElement() or getValueArrayElement() |
// Used below by getValueElement() or getValueArrayElement() |
|
effectiveType = CIMTYPE_OBJECT; |
} | } |
else | else |
{ | { |
|
|
if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && | if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && |
!XmlReader::getValueElement(parser, effectiveType, value) ) | !XmlReader::getValueElement(parser, effectiveType, value) ) |
{ | { |
|
gotType = false; // Can't distinguish array and non-array types |
value.clear(); // Isn't necessary; should already be cleared | value.clear(); // Isn't necessary; should already be cleared |
} | } |
| |