version 1.149, 2007/03/05 20:02:06
|
version 1.156, 2008/03/05 21:31:45
|
|
|
#include "StrLit.h" | #include "StrLit.h" |
#include "LanguageParser.h" | #include "LanguageParser.h" |
#include "IDFactory.h" | #include "IDFactory.h" |
|
#include "StringConversion.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
return out; | return out; |
} | } |
| |
Buffer& operator<<(Buffer& out, const Indentor& x) |
|
{ |
|
XmlWriter::append(out, x); |
|
return out; |
|
} |
|
|
|
Buffer& operator<<(Buffer& out, const Buffer& x) | Buffer& operator<<(Buffer& out, const Buffer& x) |
{ | { |
out.append(x.getData(), x.size()); | out.append(x.getData(), x.size()); |
|
|
{ | { |
if ( ((c < 0x20) && (c >= 0)) || (c == 0x7f) ) | if ( ((c < 0x20) && (c >= 0)) || (c == 0x7f) ) |
{ | { |
char charref[7]; |
char scratchBuffer[22]; |
sprintf(charref, "&#%u;", static_cast<Uint8>(c)); |
Uint32 outputLength; |
os << charref; |
const char * output = Uint8ToString(scratchBuffer, |
|
static_cast<Uint8>(c), |
|
outputLength); |
|
os << "&#" << output << ";"; |
} | } |
else | else |
{ | { |
|
|
| |
void XmlWriter::append(Buffer& out, Boolean x) | void XmlWriter::append(Buffer& out, Boolean x) |
{ | { |
append(out, (x ? "TRUE" : "FALSE")); |
if (x) |
|
out.append(STRLIT_ARGS("TRUE")); |
|
else |
|
out.append(STRLIT_ARGS("FALSE")); |
} | } |
| |
void XmlWriter::append(Buffer& out, Uint32 x) | void XmlWriter::append(Buffer& out, Uint32 x) |
{ | { |
char buffer[32]; |
Uint32 outputLength=0; |
sprintf(buffer, "%u", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Uint32ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Sint32 x) | void XmlWriter::append(Buffer& out, Sint32 x) |
{ | { |
char buffer[32]; |
Uint32 outputLength=0; |
sprintf(buffer, "%d", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Sint32ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Uint64 x) | void XmlWriter::append(Buffer& out, Uint64 x) |
{ | { |
char buffer[32]; // Should need 21 chars max |
Uint32 outputLength=0; |
sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Uint64ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Sint64 x) | void XmlWriter::append(Buffer& out, Sint64 x) |
{ | { |
char buffer[32]; // Should need 21 chars max |
Uint32 outputLength=0; |
sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Sint64ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Real32 x) | void XmlWriter::append(Buffer& out, Real32 x) |
|
|
} | } |
} | } |
| |
void XmlWriter::append(Buffer& out, const Indentor& x) |
|
{ |
|
for (Uint32 i = 0; i < 4 * x.getLevel(); i++) |
|
out.append(' '); |
|
} |
|
|
|
void XmlWriter::appendSpecial(Buffer& out, const Char16& x) | void XmlWriter::appendSpecial(Buffer& out, const Char16& x) |
{ | { |
_xmlWritter_appendSpecialChar(out, x); | _xmlWritter_appendSpecialChar(out, x); |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendValueElement(tmp, value); | appendValueElement(tmp, value); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendValueReferenceElement(tmp, reference, true); | appendValueReferenceElement(tmp, reference, true); |
tmp.append('\0'); |
|
indentedPrint(os, tmp.getData()); | indentedPrint(os, tmp.getData()); |
} | } |
| |
|
|
| |
void XmlWriter::appendClassElement( | void XmlWriter::appendClassElement( |
Buffer& out, | Buffer& out, |
const CIMConstClass& cimclass) |
const CIMConstClass& cimClass) |
|
{ |
|
CheckRep(cimClass._rep); |
|
const CIMClassRep* rep = cimClass._rep; |
|
|
|
// Class opening element: |
|
|
|
out << STRLIT("<CLASS NAME=\"") |
|
<< rep->getClassName() |
|
<< STRLIT("\" "); |
|
|
|
if (!rep->getSuperClassName().isNull()) |
{ | { |
cimclass._checkRep(); |
out << STRLIT(" SUPERCLASS=\"") |
cimclass._rep->toXml(out); |
<< rep->getSuperClassName() |
|
<< STRLIT("\" "); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
// Append Class Qualifiers: |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
// Append Property definitions: |
|
|
|
for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++) |
|
XmlWriter::appendPropertyElement(out, rep->getProperty(i)); |
|
|
|
// Append Method definitions: |
|
|
|
for (Uint32 i = 0, n = rep->getMethodCount(); i < n; i++) |
|
XmlWriter::appendMethodElement(out, rep->getMethod(i)); |
|
|
|
// Class closing element: |
|
|
|
out << STRLIT("</CLASS>\n"); |
} | } |
| |
void XmlWriter::printClassElement( | void XmlWriter::printClassElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendClassElement(tmp, cimclass); | appendClassElement(tmp, cimclass); |
tmp.append('\0'); |
|
indentedPrint(os, tmp.getData(), 4); | indentedPrint(os, tmp.getData(), 4); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstInstance& instance) | const CIMConstInstance& instance) |
{ | { |
instance._checkRep(); |
CheckRep(instance._rep); |
instance._rep->toXml(out); |
const CIMInstanceRep* rep = instance._rep; |
|
|
|
// Class opening element: |
|
|
|
out << STRLIT("<INSTANCE CLASSNAME=\"") |
|
<< rep->getClassName() |
|
<< STRLIT("\" >\n"); |
|
|
|
// Append Instance Qualifiers: |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
// Append Properties: |
|
|
|
for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++) |
|
XmlWriter::appendPropertyElement(out, rep->getProperty(i)); |
|
|
|
// Instance closing element: |
|
|
|
out << STRLIT("</INSTANCE>\n"); |
} | } |
| |
void XmlWriter::printInstanceElement( | void XmlWriter::printInstanceElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendInstanceElement(tmp, instance); | appendInstanceElement(tmp, instance); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstProperty& property) | const CIMConstProperty& property) |
{ | { |
property._checkRep(); |
CheckRep(property._rep); |
property._rep->toXml(out); |
const CIMPropertyRep* rep = property._rep; |
|
|
|
if (rep->getValue().isArray()) |
|
{ |
|
out << STRLIT("<PROPERTY.ARRAY NAME=\"") |
|
<< rep->getName() |
|
<< STRLIT("\" "); |
|
|
|
if (rep->getValue().getType() == CIMTYPE_OBJECT) |
|
{ |
|
// If the property array type is CIMObject, then |
|
// encode the property in CIM-XML as a string array with the |
|
// EmbeddedObject attribute (there is not currently a CIM-XML |
|
// "object" datatype) |
|
|
|
Array<CIMObject> a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); |
|
// If the Embedded Object is an instance, always add the |
|
// EmbeddedObject attribute. |
|
if (a.size() > 0 && a[0].isInstance()) |
|
{ |
|
out << STRLIT(" EmbeddedObject=\"object\""); |
|
out << STRLIT(" 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(CIMName("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(CIMName("EmbeddedObject"), true)); |
|
} |
|
} |
|
} |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else if (rep->getValue().getType() == CIMTYPE_INSTANCE) |
|
{ |
|
// If the property array type is CIMInstance, then |
|
// encode the property in CIM-XML as a string array with the |
|
// EmbeddedObject attribute (there is not currently a CIM-XML |
|
// "instance" datatype) |
|
|
|
Array<CIMInstance> a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); |
|
|
|
// add the EmbeddedObject attribute |
|
if (a.size() > 0) |
|
{ |
|
out << STRLIT(" EmbeddedObject=\"instance\""); |
|
out << STRLIT(" 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(CIMName("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( |
|
CIMName("EmbeddedInstance"), |
|
a[0].getClassName().getString())); |
|
} |
|
# endif |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else |
|
{ |
|
out << STRLIT(" TYPE=\"") |
|
<< cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PROPERTY.ARRAY>\n"); |
|
} |
|
else if (rep->getValue().getType() == CIMTYPE_REFERENCE) |
|
{ |
|
out << STRLIT("<PROPERTY.REFERENCE"); |
|
|
|
out << STRLIT(" NAME=\"") << rep->getName() << STRLIT("\" "); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName(); |
|
out.append('"'); |
|
} |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PROPERTY.REFERENCE>\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("<PROPERTY NAME=\"") << rep->getName() << STRLIT("\" "); |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
if (rep->getValue().getType() == CIMTYPE_OBJECT) |
|
{ |
|
// If the property type is CIMObject, then |
|
// encode the property in CIM-XML as a string with the |
|
// EmbeddedObject attribute (there is not currently a CIM-XML |
|
// "object" datatype) |
|
|
|
CIMObject a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); |
|
|
|
// If the Embedded Object is an instance, always add the |
|
// EmbeddedObject attribute. |
|
if (a.isInstance()) |
|
{ |
|
out << STRLIT(" EmbeddedObject=\"object\""); |
|
out << STRLIT(" 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(CIMName("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(CIMName("EmbeddedObject"), true)); |
|
} |
|
} |
|
} |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else if (rep->getValue().getType() == CIMTYPE_INSTANCE) |
|
{ |
|
CIMInstance a; |
|
rep->getValue().get(a); |
|
out << " TYPE=\"string\""; |
|
out << " EmbeddedObject=\"instance\""; |
|
out << " EMBEDDEDOBJECT=\"instance\""; |
|
|
|
# ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
if (rep->findQualifier(CIMName("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( |
|
CIMName("EmbeddedInstance"), |
|
a.getClassName().getString())); |
|
} |
|
# endif |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else |
|
{ |
|
out << STRLIT(" TYPE=\"") |
|
<< cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PROPERTY>\n"); |
|
} |
} | } |
| |
void XmlWriter::printPropertyElement( | void XmlWriter::printPropertyElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendPropertyElement(tmp, property); | appendPropertyElement(tmp, property); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstMethod& method) | const CIMConstMethod& method) |
{ | { |
method._checkRep(); |
CheckRep(method._rep); |
method._rep->toXml(out); |
const CIMMethodRep* rep = method._rep; |
|
|
|
out << STRLIT("<METHOD NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
|
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType()); |
|
out.append('"'); |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
for (Uint32 i = 0, n = rep->getParameterCount(); i < n; i++) |
|
XmlWriter::appendParameterElement(out, rep->getParameter(i)); |
|
|
|
out << STRLIT("</METHOD>\n"); |
} | } |
| |
void XmlWriter::printMethodElement( | void XmlWriter::printMethodElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendMethodElement(tmp, method); | appendMethodElement(tmp, method); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstParameter& parameter) | const CIMConstParameter& parameter) |
{ | { |
parameter._checkRep(); |
CheckRep(parameter._rep); |
parameter._rep->toXml(out); |
const CIMParameterRep* rep = parameter._rep; |
|
|
|
if (rep->isArray()) |
|
{ |
|
if (rep->getType() == CIMTYPE_REFERENCE) |
|
{ |
|
out << STRLIT("<PARAMETER.REFARRAY NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\""); |
|
out << rep->getReferenceClassName().getString(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
int n = sprintf(buffer, "%d", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\""); |
|
out.append(buffer, n); |
|
out.append('"'); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER.REFARRAY>\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("<PARAMETER.ARRAY"); |
|
out << STRLIT(" NAME=\"") << rep->getName(); |
|
out << STRLIT("\" "); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType()); |
|
out.append('"'); |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER.ARRAY>\n"); |
|
} |
|
} |
|
else if (rep->getType() == CIMTYPE_REFERENCE) |
|
{ |
|
out << STRLIT("<PARAMETER.REFERENCE"); |
|
out << STRLIT(" NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\""); |
|
out << rep->getReferenceClassName().getString(); |
|
out.append('"'); |
|
} |
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER.REFERENCE>\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("<PARAMETER"); |
|
out << STRLIT(" NAME=\"") << rep->getName(); |
|
out << STRLIT("\" "); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType()); |
|
out << STRLIT("\">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER>\n"); |
|
} |
} | } |
| |
void XmlWriter::printParameterElement( | void XmlWriter::printParameterElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendParameterElement(tmp, parameter); | appendParameterElement(tmp, parameter); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
// | // |
// <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?> | // <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?> |
// <!ATTLIST PARAMVALUE | // <!ATTLIST PARAMVALUE |
// %CIMName;> |
// %CIMName; |
|
// %EmbeddedObject; #IMPLIED |
|
// %ParamType;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMParamValue& paramValue) | const CIMParamValue& paramValue) |
{ | { |
paramValue._checkRep(); |
CheckRep(paramValue._rep); |
paramValue._rep->toXml(out); |
const CIMParamValueRep* rep = paramValue._rep; |
|
|
|
out << STRLIT("<PARAMVALUE NAME=\"") << rep->getParameterName(); |
|
out.append('"'); |
|
|
|
CIMType type = rep->getValue().getType(); |
|
|
|
if (rep->isTyped()) |
|
{ |
|
XmlWriter::appendParamTypeAndEmbeddedObjAttrib(out, type); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PARAMVALUE>\n"); |
} | } |
| |
void XmlWriter::printParamValueElement( | void XmlWriter::printParamValueElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendParamValueElement(tmp, paramValue); | appendParamValueElement(tmp, paramValue); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstQualifier& qualifier) | const CIMConstQualifier& qualifier) |
{ | { |
qualifier._checkRep(); |
CheckRep(qualifier._rep); |
qualifier._rep->toXml(out); |
const CIMQualifierRep* rep = qualifier._rep; |
|
|
|
out << STRLIT("<QUALIFIER NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor()); |
|
|
|
out << STRLIT(">\n"); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</QUALIFIER>\n"); |
} | } |
| |
void XmlWriter::printQualifierElement( | void XmlWriter::printQualifierElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendQualifierElement(tmp, qualifier); | appendQualifierElement(tmp, qualifier); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstQualifierDecl& qualifierDecl) | const CIMConstQualifierDecl& qualifierDecl) |
{ | { |
qualifierDecl._checkRep(); |
CheckRep(qualifierDecl._rep); |
qualifierDecl._rep->toXml(out); |
const CIMQualifierDeclRep* rep = qualifierDecl._rep; |
|
|
|
out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
|
|
if (rep->getValue().isArray()) |
|
{ |
|
out << STRLIT(" ISARRAY=\"true\""); |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[64]; |
|
int n = sprintf(buffer, " ARRAYSIZE=\"%d\"", rep->getArraySize()); |
|
out.append(buffer, n); |
|
} |
|
} |
|
|
|
XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor()); |
|
|
|
out << STRLIT(">\n"); |
|
|
|
XmlWriter::appendScopeElement(out, rep->getScope()); |
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</QUALIFIER.DECLARATION>\n"); |
} | } |
| |
void XmlWriter::printQualifierDeclElement( | void XmlWriter::printQualifierDeclElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendQualifierDeclElement(tmp, qualifierDecl); | appendQualifierDeclElement(tmp, qualifierDecl); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
const String& content) | const String& content) |
{ | { |
out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n"); | out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n"); |
|
Uint32 contentLength = 0; |
|
OUTPUT_CONTENTLENGTH; |
out << content << STRLIT("\r\n"); | out << content << STRLIT("\r\n"); |
out << STRLIT("\r\n"); | out << STRLIT("\r\n"); |
| |
|
|
out << STRLIT("/>"); | out << STRLIT("/>"); |
} | } |
| |
//------------------------------------------------------------------------------ |
//---------------------------------------------------------------------- |
// | // |
// appendReturnValueElement() |
// appendParmType |
// |
// Appends the Param type and EmbeddedObject Info |
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
// to the buffer |
// <!ATTLIST RETURNVALUE |
|
// %EmbeddedObject; #IMPLIED | // %EmbeddedObject; #IMPLIED |
// %ParamType;> | // %ParamType;> |
// | // |
//------------------------------------------------------------------------------ |
//--------------------------------------------------------------------- |
|
void XmlWriter::appendParamTypeAndEmbeddedObjAttrib( |
void XmlWriter::appendReturnValueElement( |
|
Buffer& out, | Buffer& out, |
const CIMValue& value) |
const CIMType& type) |
{ | { |
out << STRLIT("<RETURNVALUE"); |
|
| |
CIMType type = value.getType(); |
|
// 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 EMBEDDEDOBJECT |
// encode the property in CIM-XML as a string with the EmbeddedObject |
// attribute (there is not currently a CIM-XML "object" datatype) |
// attribute (there is not currently a CIM-XML "object" |
|
// datatype). |
|
// Because of an error in Pegasus we were earlier outputting |
|
// upper case "EMBEDDEDOBJECT" as the attribute name. The |
|
// spec calls for mixed case "EmbeddedObject. Fixed in |
|
// bug 7131 to output EmbeddedObject attribute in upper |
|
// case and mixed case. Receiver will ignore one or the |
|
// other. |
// else | // else |
// output the real type | // output the real type |
if (type == CIMTYPE_OBJECT) | if (type == CIMTYPE_OBJECT) |
{ | { |
|
|
out << STRLIT(" PARAMTYPE=\"string\""); | out << STRLIT(" PARAMTYPE=\"string\""); |
|
out << STRLIT(" EmbeddedObject=\"object\""); |
out << STRLIT(" EMBEDDEDOBJECT=\"object\""); | out << STRLIT(" EMBEDDEDOBJECT=\"object\""); |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
else if (type == CIMTYPE_INSTANCE) | else if (type == CIMTYPE_INSTANCE) |
{ | { |
out << STRLIT(" PARAMTYPE=\"string\""); | out << STRLIT(" PARAMTYPE=\"string\""); |
|
out << STRLIT(" EmbeddedObject=\"instance\""); |
out << STRLIT(" EMBEDDEDOBJECT=\"instance\""); | out << STRLIT(" EMBEDDEDOBJECT=\"instance\""); |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
|
out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type); | out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type); |
out.append('"'); | out.append('"'); |
} | } |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// appendReturnValueElement() |
|
// |
|
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
|
// <!ATTLIST RETURNVALUE |
|
// %EmbeddedObject; #IMPLIED |
|
// %ParamType;> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
|
|
void XmlWriter::appendReturnValueElement( |
|
Buffer& out, |
|
const CIMValue& value) |
|
{ |
|
out << STRLIT("<RETURNVALUE"); |
|
|
|
CIMType type = value.getType(); |
|
|
|
appendParamTypeAndEmbeddedObjAttrib(out, type); |
| |
out << STRLIT(">\n"); | out << STRLIT(">\n"); |
| |
|
|
| |
String XmlWriter::getNextMessageId() | String XmlWriter::getNextMessageId() |
{ | { |
char buffer[16]; |
char scratchBuffer[22]; |
sprintf(buffer, "%u", _messageIDFactory.getID()); |
Uint32 n; |
return buffer; |
const char * startP = Uint32ToString(scratchBuffer, |
|
_messageIDFactory.getID(), |
|
n); |
|
return String(startP, n); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |