void CIMtoXML(CIMValue const& cv, ostream& out) { if (!cv) { OW_THROWCIMMSG(CIMException::FAILED, "CIM value is NULL"); } if (cv.isArray()) { switch (cv.getType()) { case CIMDataType::BOOLEAN: { BoolArray a; cv.get(a); raToXml(out, a); break; } case CIMDataType::UINT8: { UInt8Array a; cv.get(a); raToXmlNumeric(out, a); break; } case CIMDataType::SINT8: { Int8Array a; cv.get(a); raToXmlNumeric(out, a); break; } // ATTN: UTF8 case CIMDataType::CHAR16: { Char16Array a; cv.get(a); raToXmlChar16(out, a); break; } case CIMDataType::UINT16: { UInt16Array a; cv.get(a); raToXml(out, a); break; } case CIMDataType::SINT16: { Int16Array a; cv.get(a); raToXml(out, a); break; } case CIMDataType::UINT32: { UInt32Array a; cv.get(a); raToXml(out, a); break; } case CIMDataType::SINT32: { Int32Array a; cv.get(a); raToXml(out, a); break; } case CIMDataType::UINT64: { UInt64Array a; cv.get(a); raToXml(out, a); break; } case CIMDataType::SINT64: { Int64Array a; cv.get(a); raToXml(out, a); break; } case CIMDataType::REAL32: { Real32Array a; cv.get(a); realArrayToXml(out, a); break; } case CIMDataType::REAL64: { Real64Array a; cv.get(a); realArrayToXml(out, a); break; } case CIMDataType::STRING: { StringArray a; cv.get(a); raToXmlSA(out, a); break; } case CIMDataType::DATETIME: { CIMDateTimeArray a; cv.get(a); raToXml(out, a); break; } case CIMDataType::REFERENCE: { CIMObjectPathArray a; cv.get(a); raToXmlCOP(out, a); break; } case CIMDataType::EMBEDDEDCLASS: { CIMClassArray ca; cv.get(ca); StringArray sa; for (size_t i = 0; i < ca.size(); ++i) { OStringStream ss; CIMtoXML(ca[i], ss); sa.push_back(ss.toString()); } raToXmlSA(out, sa); break; } case CIMDataType::EMBEDDEDINSTANCE: { CIMInstanceArray ia; cv.get(ia); StringArray sa; for (size_t i = 0; i < ia.size(); ++i) { OStringStream ss; CIMInstancetoXML(ia[i],ss); sa.push_back(ss.toString()); } raToXmlSA(out, sa); break; } default: OW_ASSERT(0); } } else if (cv.getType() == CIMDataType::REFERENCE) { out << "<VALUE.REFERENCE>"; CIMObjectPath a(CIMNULL); cv.get(a); if (a.getFullNameSpace().isLocal()) { if (a.getNameSpace().empty()) { CIMInstanceNametoXML(a, out); } else { CIMLocalInstancePathtoXML(a, out); } } else { CIMInstancePathtoXML(a, out); } out << "</VALUE.REFERENCE>"; } else { out << "<VALUE>"; switch (cv.getType()) { case CIMDataType::BOOLEAN: case CIMDataType::UINT8: case CIMDataType::SINT8: case CIMDataType::UINT16: case CIMDataType::SINT16: case CIMDataType::UINT32: case CIMDataType::SINT32: case CIMDataType::UINT64: case CIMDataType::SINT64: case CIMDataType::DATETIME: { out << cv.toString(); break; } case CIMDataType::REAL32: { char tmpbuf[128]; #if FLT_RADIX == 2 #if defined(OW_REAL32_IS_FLOAT) ::SNPRINTF(tmpbuf, sizeof(tmpbuf), "%.*e", FLT_MANT_DIG * 3 / 10 + 1, static_cast<double>(cv.toReal32())); #elif defined(OW_REAL32_IS_DOUBLE) ::SNPRINTF(tmpbuf, sizeof(tmpbuf), "%.*e", DBL_MANT_DIG * 3 / 10 + 1, cv.toReal32()); #endif #else #error "The formula for computing the number of digits of precision for a floating point needs to be implmented. It's ceiling(bits * log(FLT_RADIX) / log(10))" #endif out << tmpbuf; break; } case CIMDataType::REAL64: { char tmpbuf[128]; #if FLT_RADIX == 2 #if defined(OW_REAL64_IS_DOUBLE) ::SNPRINTF(tmpbuf, sizeof(tmpbuf), "%.*e", DBL_MANT_DIG * 3 / 10 + 1, cv.toReal64()); #elif defined(OW_REAL64_IS_LONG_DOUBLE) ::SNPRINTF(tmpbuf, sizeof(tmpbuf), "%.*Le", LDBL_MANT_DIG * 3 / 10 + 1, cv.toReal64()); #endif #else #error "The formula for computing the number of digits of precision for a floating point needs to be implmented. It's ceiling(bits * log(FLT_RADIX) / log(10))" #endif out << tmpbuf; break; } case CIMDataType::CHAR16: case CIMDataType::STRING: { out << XMLEscape(cv.toString()); break; } case CIMDataType::EMBEDDEDCLASS: { CIMClass cc(CIMNULL); cv.get(cc); String s; OStringStream ss; CIMtoXML(cc, ss); out << XMLEscape(ss.toString()); break; } case CIMDataType::EMBEDDEDINSTANCE: { CIMInstance i(CIMNULL); cv.get(i); String s; OStringStream ss; CIMInstancetoXML(i,ss); out << XMLEscape(ss.toString()); break; } default: OW_ASSERT(0); } out << "</VALUE>"; } }