version 1.1.2.7, 2009/10/14 12:47:15
|
version 1.1.2.8, 2009/10/20 13:21:19
|
|
|
if (kbType == CIMTYPE_REFERENCE) | if (kbType == CIMTYPE_REFERENCE) |
{ | { |
SCMOInstance * ref = kbValue->extRefPtr; | SCMOInstance * ref = kbValue->extRefPtr; |
|
if (ref) |
|
{ |
appendValueReferenceElement(out, *ref, true); | appendValueReferenceElement(out, *ref, true); |
} | } |
|
} |
else | else |
{ | { |
out << STRLIT("<KEYVALUE VALUETYPE=\""); | out << STRLIT("<KEYVALUE VALUETYPE=\""); |
|
|
// %Propagated;> | // %Propagated;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
void SCMOXmlWriter::appendPropertyElement( | void SCMOXmlWriter::appendPropertyElement( |
Buffer& out, | Buffer& out, |
const SCMOInstance& scmoInstance, | const SCMOInstance& scmoInstance, |
Uint32 pos) | Uint32 pos) |
{ | { |
// Get most of the property data from the instance |
|
const char* propertyName; |
|
Uint32 propertyNameLen; |
|
CIMType propertyType; | CIMType propertyType; |
|
Buffer embeddedQualifierOutput; |
| |
// This is an absolute pointer at a SCMBValue | // This is an absolute pointer at a SCMBValue |
SCMBValue * propertyValue; | SCMBValue * propertyValue; |
|
|
| |
if (propertyValue->flags.isArray) | if (propertyValue->flags.isArray) |
{ | { |
|
Uint32 arraySize=propertyValue->valueArraySize; |
|
|
out << STRLIT("<PROPERTY.ARRAY NAME=\""); | out << STRLIT("<PROPERTY.ARRAY NAME=\""); |
| |
out.append( | out.append( |
|
|
out << STRLIT("\" "); | out << STRLIT("\" "); |
if (propertyType == CIMTYPE_OBJECT) | if (propertyType == CIMTYPE_OBJECT) |
{ | { |
/* TODO: Implement writing CIM_OBJECT |
|
// If the property array type is CIMObject, then | // If the property array type is CIMObject, then |
// encode the property in CIM-XML as a string array with the | // encode the property in CIM-XML as a string array with the |
// EmbeddedObject attribute (there is not currently a CIM-XML | // EmbeddedObject attribute (there is not currently a CIM-XML |
// "object" datatype) | // "object" datatype) |
| |
Array<CIMObject> a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); | out << STRLIT(" TYPE=\"string\""); |
// If the Embedded Object is an instance, always add the | // If the Embedded Object is an instance, always add the |
// EmbeddedObject attribute. | // EmbeddedObject attribute. |
if (a.size() > 0 && a[0].isInstance()) |
SCMOInstance * instPtr = propertyValue->value.extRefPtr; |
|
if ((0 != instPtr) && |
|
(arraySize > 0) && |
|
!(instPtr->inst.hdr->flags.isClassOnly)) |
{ | { |
out << STRLIT(" EmbeddedObject=\"object\"" | out << STRLIT(" EmbeddedObject=\"object\"" |
" EMBEDDEDOBJECT=\"object\""); | " EMBEDDEDOBJECT=\"object\""); |
} | } |
#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
else |
|
#endif |
|
{ |
|
// Else the Embedded Object is a class, always add the |
|
// EmbeddedObject qualifier. Note that if the macro |
|
// PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then |
|
// the EmbeddedObject qualifier will always be added, |
|
// whether it's a class or an instance. |
|
if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) |
|
== PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep.In this case we really do want to add |
|
// the EmbeddedObject qualifier, so we cast away the |
|
// constness. |
|
CIMPropertyRep* tmpRep=const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier( |
|
CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT, |
|
true)); |
|
} |
|
} |
|
*/ |
|
} | } |
else if (propertyType == CIMTYPE_INSTANCE) | else if (propertyType == CIMTYPE_INSTANCE) |
{ | { |
/* TODO: Implement writing embedded instance |
|
// If the property array type is CIMInstance, then | // If the property array type is CIMInstance, then |
// encode the property in CIM-XML as a string array with the | // encode the property in CIM-XML as a string array with the |
// EmbeddedObject attribute (there is not currently a CIM-XML | // EmbeddedObject attribute (there is not currently a CIM-XML |
// "instance" datatype) | // "instance" datatype) |
|
|
Array<CIMInstance> a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); | out << STRLIT(" TYPE=\"string\""); |
|
|
// add the EmbeddedObject attribute | // add the EmbeddedObject attribute |
if (a.size() > 0) |
if (arraySize > 0) |
{ | { |
out << STRLIT(" EmbeddedObject=\"instance\"" | out << STRLIT(" EmbeddedObject=\"instance\"" |
" EMBEDDEDOBJECT=\"instance\""); | " EMBEDDEDOBJECT=\"instance\""); |
|
|
// Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
// is defined, then the EmbeddedInstance qualifier will be |
|
// added |
|
# ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
if (rep->findQualifier( |
|
PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE == |
|
PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep.In this case we really do want to add |
|
// the EmbeddedInstance qualifier, so we cast away the |
|
// constness. |
|
|
|
// For now, we assume that all the embedded instances in |
|
// the array are of the same type |
|
CIMPropertyRep* tmpRep=const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier(CIMQualifier( |
|
PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE, |
|
a[0].getClassName().getString())); |
|
} |
|
# endif |
|
} | } |
*/ |
|
} | } |
else | else |
{ | { |
|
|
out << xmlWriterTypeStrings(propertyType); | out << xmlWriterTypeStrings(propertyType); |
} | } |
| |
Uint32 arraySize=propertyValue->valueArraySize; |
|
|
|
if (0 != arraySize) | if (0 != arraySize) |
{ | { |
out << STRLIT(" ARRAYSIZE=\""); | out << STRLIT(" ARRAYSIZE=\""); |
|
|
| |
if (propertyType == CIMTYPE_OBJECT) | if (propertyType == CIMTYPE_OBJECT) |
{ | { |
/* TODO: Implement writing Embedded Object |
|
// If the property type is CIMObject, then | // If the property type is CIMObject, then |
// encode the property in CIM-XML as a string with the | // encode the property in CIM-XML as a string with the |
// EmbeddedObject attribute (there is not currently a CIM-XML | // EmbeddedObject attribute (there is not currently a CIM-XML |
// "object" datatype) | // "object" datatype) |
|
|
CIMObject a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); | out << STRLIT(" TYPE=\"string\""); |
|
|
// If the Embedded Object is an instance, always add the | // If the Embedded Object is an instance, always add the |
// EmbeddedObject attribute. | // EmbeddedObject attribute. |
if (a.isInstance()) |
SCMOInstance * a = propertyValue->value.extRefPtr; |
|
if (a && !(a->inst.hdr->flags.isClassOnly)) |
{ | { |
out << STRLIT(" EmbeddedObject=\"object\"" | out << STRLIT(" EmbeddedObject=\"object\"" |
" EMBEDDEDOBJECT=\"object\""); | " EMBEDDEDOBJECT=\"object\""); |
} | } |
// Else the Embedded Object is a class, always add the |
|
// EmbeddedObject qualifier. |
|
#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
else |
|
#endif |
|
{ |
|
// Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
// is defined, then the EmbeddedObject qualifier will always |
|
// be added, whether it's a class or an instance. |
|
if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) |
|
== PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep. In this case we really do want to |
|
// add the EmbeddedObject qualifier, so we cast away the |
|
// constness. |
|
CIMPropertyRep* tmpRep=const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier( |
|
CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT, |
|
true)); |
|
} |
|
} |
|
*/ |
|
} |
|
else if (propertyType == CIMTYPE_INSTANCE) | else if (propertyType == CIMTYPE_INSTANCE) |
{ | { |
/* TODO: Implement writing Embedded Instance |
|
CIMInstance a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\"" | out << STRLIT(" TYPE=\"string\"" |
" EmbeddedObject=\"instance\"" | " EmbeddedObject=\"instance\"" |
" EMBEDDEDOBJECT=\"instance\""); | " EMBEDDEDOBJECT=\"instance\""); |
|
|
# ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) |
|
== PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep. In this case we really do want to add |
|
// the EmbeddedInstance qualifier, so we cast away the |
|
// constness. |
|
CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier(CIMQualifier( |
|
PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE, |
|
a.getClassName().getString())); |
|
} | } |
# endif |
|
*/ |
|
} | } |
else | else |
{ | { |
|
|
else if (value.valueType == CIMTYPE_REFERENCE) | else if (value.valueType == CIMTYPE_REFERENCE) |
{ | { |
SCMOInstance * ref = value.value.extRefPtr; | SCMOInstance * ref = value.value.extRefPtr; |
|
if (ref) |
|
{ |
appendValueReferenceElement(out, *ref, true); | appendValueReferenceElement(out, *ref, true); |
} | } |
|
} |
else | else |
{ | { |
out << STRLIT("<VALUE>"); | out << STRLIT("<VALUE>"); |
|
|
SCMOXmlWriter::appendPropertyElement(out,cimClass,i); | SCMOXmlWriter::appendPropertyElement(out,cimClass,i); |
} | } |
| |
// TODO: What do with Method definitions ? |
// ATTN: No method definitions with SCMO today, so do nothing with them |
// for (Uint32 i = 0, n = rep->getMethodCount(); i < n; i++) |
// Actually this code does not serve a purpose, but is kept here |
// XmlWriter::appendMethodElement(out, rep->getMethod(i)); |
// for completeness. |
| |
// Class closing element: | // Class closing element: |
out << STRLIT("</CLASS>\n"); | out << STRLIT("</CLASS>\n"); |
|
|
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.bin); | SCMOXmlWriter::append(out, u.simple.val.bin); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.u8); | SCMOXmlWriter::append(out, u.simple.val.u8); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.s8); | SCMOXmlWriter::append(out, u.simple.val.s8); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.u16); | SCMOXmlWriter::append(out, u.simple.val.u16); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.s16); | SCMOXmlWriter::append(out, u.simple.val.s16); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.u32); | SCMOXmlWriter::append(out, u.simple.val.u32); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.s32); | SCMOXmlWriter::append(out, u.simple.val.s32); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.u64); | SCMOXmlWriter::append(out, u.simple.val.u64); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.s64); | SCMOXmlWriter::append(out, u.simple.val.s64); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.r32); | SCMOXmlWriter::append(out, u.simple.val.r32); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::append(out, u.simple.val.r64); | SCMOXmlWriter::append(out, u.simple.val.r64); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
|
if (u.simple.hasValue) |
|
{ |
SCMOXmlWriter::appendSpecial( | SCMOXmlWriter::appendSpecial( |
out, | out, |
u.simple.val.c16); | u.simple.val.c16); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
|
if (u.stringValue.start) |
|
{ |
SCMOXmlWriter::appendSpecial( | SCMOXmlWriter::appendSpecial( |
out, | out, |
&(base[u.stringValue.start]), | &(base[u.stringValue.start]), |
u.stringValue.length-1); | u.stringValue.length-1); |
|
} |
break; | break; |
} | } |
| |
|
|
out.append(buffer,sizeof(buffer)-1); | out.append(buffer,sizeof(buffer)-1); |
break; | break; |
} | } |
/* |
// Object and Instance are both written the same way, namely as |
|
// object element which then is encoded using appendSpecial |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
{ |
|
CIMObject v; |
|
value.get(v); |
|
_xmlWritter_appendValue(out, v); |
|
break; |
|
} |
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
CIMInstance v; |
Buffer toEncodeObject(4000); |
value.get(v); |
SCMOInstance * obj = u.extRefPtr; |
_xmlWritter_appendValue(out, v); |
if (obj) |
|
{ |
|
appendObjectElement(toEncodeObject, *obj); |
|
SCMOXmlWriter::appendSpecial( |
|
out, |
|
toEncodeObject.getData(), |
|
toEncodeObject.size()); |
|
} |
break; | break; |
} | } |
default: | default: |
PEGASUS_ASSERT(false); |
// CIMTYPE_REFERENCE has been handled upfront, do nothing here |
*/ |
break; |
} | } |
} | } |
| |
|
|
out << STRLIT("</VALUE.ARRAY>\n"); | out << STRLIT("</VALUE.ARRAY>\n"); |
break; | break; |
} | } |
/* |
case CIMTYPE_REFERENCE: |
case CIMTYPE_OBJECT: |
|
{ | { |
CIMObject v; |
out << STRLIT("<VALUE.REFARRAY>\n"); |
value.get(v); |
while (numElements--) |
_xmlWritter_appendValue(out, v); |
{ |
break; |
SCMOInstance * ref = arr->extRefPtr; |
|
if (ref) |
|
{ |
|
appendValueReferenceElement(out, *ref, true); |
|
} |
|
arr++; |
|
} |
|
out << STRLIT("</VALUE.REFARRAY>\n"); |
} | } |
|
case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
CIMInstance v; |
out << STRLIT("<VALUE.ARRAY>\n"); |
value.get(v); |
Buffer toEncodeObject(4000); |
_xmlWritter_appendValue(out, v); |
while (numElements--) |
|
{ |
|
toEncodeObject.clear(); |
|
out << STRLIT("<VALUE>"); |
|
SCMOInstance * obj = arr->extRefPtr; |
|
if (obj) |
|
{ |
|
appendObjectElement(toEncodeObject, *obj); |
|
SCMOXmlWriter::appendSpecial( |
|
out, |
|
toEncodeObject.getData(), |
|
toEncodeObject.size()); |
|
} |
|
arr++; |
|
out << STRLIT("</VALUE>\n"); |
|
} |
|
out << STRLIT("</VALUE.ARRAY>\n"); |
break; | break; |
} | } |
default: | default: |
PEGASUS_ASSERT(false); |
PEGASUS_DEBUG_ASSERT(false); |
*/ |
|
} | } |
| |
} | } |