version 1.8, 2001/06/16 17:30:37
|
version 1.11.2.2, 2001/08/01 11:17:36
|
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// _toXml() routines: |
// _toXml() and _toMof routines: |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
{ | { |
out << (x ? "TRUE" : "FALSE"); | out << (x ? "TRUE" : "FALSE"); |
} | } |
|
inline void _toMof(Array<Sint8>& out, Boolean x) |
|
{ |
|
out << (x ? "TRUE" : "FALSE"); |
|
} |
| |
template<class T> | template<class T> |
inline void _integerToXml(Array<Sint8>& out, const T& x) | inline void _integerToXml(Array<Sint8>& out, const T& x) |
|
|
sprintf(buffer, "%d", x); | sprintf(buffer, "%d", x); |
out << (char*)buffer; | out << (char*)buffer; |
} | } |
|
/* ATTNKS template<class T> |
|
inline void _integerToMof(Array<Sint8>& out, const T& x) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", x); |
|
out << (char*)buffer; |
|
} |
|
*/ |
inline void _toXml(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); } | inline void _toXml(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); } |
| |
inline void _toXml(Array<Sint8>& out, Sint8 x) { _integerToXml(out, x); } | inline void _toXml(Array<Sint8>& out, Sint8 x) { _integerToXml(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Sint8 x) { _integerToXml(out, x); } |
| |
inline void _toXml(Array<Sint8>& out, Uint16 x) { _integerToXml(out, x); } | inline void _toXml(Array<Sint8>& out, Uint16 x) { _integerToXml(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Uint16 x) { _integerToXml(out, x); } |
| |
inline void _toXml(Array<Sint8>& out, Sint16 x) { _integerToXml(out, x); } | inline void _toXml(Array<Sint8>& out, Sint16 x) { _integerToXml(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Sint16 x) { _integerToXml(out, x); } |
| |
inline void _toXml(Array<Sint8>& out, Uint32 x) { _integerToXml(out, x); } | inline void _toXml(Array<Sint8>& out, Uint32 x) { _integerToXml(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Uint32 x) { _integerToXml(out, x); } |
| |
inline void _toXml(Array<Sint8>& out, Sint32 x) { _integerToXml(out, x); } | inline void _toXml(Array<Sint8>& out, Sint32 x) { _integerToXml(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Sint32 x) { _integerToXml(out, x); } |
| |
inline void _toXml(Array<Sint8>& out, Uint64 x) | inline void _toXml(Array<Sint8>& out, Uint64 x) |
{ | { |
|
|
_UnsignedIntToStr(x, buffer); | _UnsignedIntToStr(x, buffer); |
out << buffer; | out << buffer; |
} | } |
|
inline void _toMof(Array<Sint8>& out, Uint64 x) |
|
{ |
|
char buffer[128]; |
|
_UnsignedIntToStr(x, buffer); |
|
out << buffer; |
|
} |
| |
inline void _toXml(Array<Sint8>& out, Sint64 x) | inline void _toXml(Array<Sint8>& out, Sint64 x) |
{ | { |
|
|
_SignedIntToStr(x, buffer); | _SignedIntToStr(x, buffer); |
out << buffer; | out << buffer; |
} | } |
|
inline void _toMof(Array<Sint8>& out, Sint64 x) |
|
{ |
|
char buffer[128]; |
|
_SignedIntToStr(x, buffer); |
|
out << buffer; |
|
} |
| |
void _toXml(Array<Sint8>& out, Real32 x) | void _toXml(Array<Sint8>& out, Real32 x) |
{ | { |
|
|
sprintf(buffer, "%f", x); | sprintf(buffer, "%f", x); |
out << buffer; | out << buffer; |
} | } |
|
void _toMof(Array<Sint8>& out, Real32 x) |
|
{ |
|
// ATTN: Does this format match the CIM/XML format? |
|
char buffer[128]; |
|
sprintf(buffer, "%f", x); |
|
out << buffer; |
|
} |
| |
void _toXml(Array<Sint8>& out, Real64 x) | void _toXml(Array<Sint8>& out, Real64 x) |
{ | { |
|
|
sprintf(buffer, "%f", x); | sprintf(buffer, "%f", x); |
out << buffer; | out << buffer; |
} | } |
|
void _toMof(Array<Sint8>& out, Real64 x) |
|
{ |
|
char buffer[128]; |
|
sprintf(buffer, "%f", x); |
|
out << buffer; |
|
} |
| |
inline void _toXml(Array<Sint8>& out, Char16 x) | inline void _toXml(Array<Sint8>& out, Char16 x) |
{ | { |
XmlWriter::appendSpecial(out, x); | XmlWriter::appendSpecial(out, x); |
} | } |
|
inline void _toMof(Array<Sint8>& out, Char16 x) |
|
{ |
|
XmlWriter::appendSpecial(out, x); |
|
} |
| |
inline void _toXml(Array<Sint8>& out, const String& x) | inline void _toXml(Array<Sint8>& out, const String& x) |
{ | { |
XmlWriter::appendSpecial(out, x); | XmlWriter::appendSpecial(out, x); |
} | } |
|
inline void _toMof(Array<Sint8>& out, const String& x) |
|
{ |
|
out << "\""; |
|
const Char16* tmp = x.getData(); |
|
char c; |
|
while (c = *tmp++) |
|
{ |
|
switch (c) |
|
{ |
|
case '"': |
|
out.append("'", 1); |
|
break; |
|
|
|
case ' ': |
|
out.append(Sint8(c)); |
|
break; |
|
|
|
default: |
|
out.append(Sint8(c)); |
|
} |
|
|
|
} |
|
out << "\""; |
|
} |
| |
inline void _toXml(Array<Sint8>& out, const CIMDateTime& x) | inline void _toXml(Array<Sint8>& out, const CIMDateTime& x) |
{ | { |
out << x.getString(); | out << x.getString(); |
} | } |
|
inline void _toMof(Array<Sint8>& out, const CIMDateTime& x) |
|
{ |
|
out << x.getString(); |
|
} |
| |
template<class T> | template<class T> |
void _toXml(Array<Sint8>& out, const T* p, Uint32 size) | void _toXml(Array<Sint8>& out, const T* p, Uint32 size) |
|
|
out << "</VALUE>\n"; | out << "</VALUE>\n"; |
} | } |
} | } |
|
template<class T> |
|
void _toMof(Array<Sint8>& out, const T* p, Uint32 size) |
|
{ |
|
Boolean isFirstEntry = true; |
|
out << "{"; |
|
while (size--) |
|
{ |
|
// Put comma on all but first entry. |
|
if (!isFirstEntry) |
|
{ |
|
out << ", "; |
|
} |
|
isFirstEntry = false; |
|
_toMof(out, *p++); |
|
} |
|
out << "}"; |
|
} |
| |
template<class T> | template<class T> |
void _toStr(Array<Sint8>& out, const T* p, Uint32 size) | void _toStr(Array<Sint8>& out, const T* p, Uint32 size) |
|
|
| |
_type = x._type; | _type = x._type; |
_isArray = x._isArray; | _isArray = x._isArray; |
|
_isNull = x._isNull; |
_u._voidPtr = 0; | _u._voidPtr = 0; |
| |
if (_isArray) | if (_isArray) |
|
|
out << "</VALUE>\n"; | out << "</VALUE>\n"; |
} | } |
} | } |
|
void CIMValue::toMof(Array<Sint8>& out) const //ATTNKS: |
|
{ |
|
if (_isArray) |
|
{ |
|
switch (_type) |
|
{ |
|
case CIMType::BOOLEAN: |
|
{ |
|
for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++) |
|
{ |
|
_toMof(out, Boolean(_u._booleanArray->data()[i])); |
|
} |
|
break; |
|
} |
|
case CIMType::UINT8: |
|
_toMof(out, _u._uint8Array->data(), _u._uint8Array->size); |
|
break; |
|
|
|
case CIMType::SINT8: |
|
_toMof(out, _u._sint8Array->data(), _u._sint8Array->size); |
|
break; |
|
|
|
case CIMType::UINT16: |
|
_toMof(out, _u._uint16Array->data(), _u._uint16Array->size); |
|
break; |
|
|
|
case CIMType::SINT16: |
|
_toMof(out, _u._sint16Array->data(), _u._sint16Array->size); |
|
break; |
|
|
|
case CIMType::UINT32: |
|
_toMof(out, _u._uint32Array->data(), _u._uint32Array->size); |
|
break; |
|
|
|
case CIMType::SINT32: |
|
_toMof(out, _u._sint32Array->data(), _u._sint32Array->size); |
|
break; |
|
|
|
case CIMType::UINT64: |
|
_toMof(out, _u._uint64Array->data(), _u._uint64Array->size); |
|
break; |
|
|
|
case CIMType::SINT64: |
|
_toMof(out, _u._sint64Array->data(), _u._sint64Array->size); |
|
break; |
|
|
|
case CIMType::REAL32: |
|
_toMof(out, _u._real32Array->data(), _u._real32Array->size); |
|
break; |
|
|
|
case CIMType::REAL64: |
|
_toMof(out, _u._real64Array->data(), _u._real64Array->size); |
|
break; |
|
|
|
case CIMType::CHAR16: |
|
_toMof(out, _u._char16Array->data(), _u._char16Array->size); |
|
break; |
|
|
|
case CIMType::STRING: |
|
_toMof(out, _u._stringArray->data(), _u._stringArray->size); |
|
break; |
|
|
|
case CIMType::DATETIME: |
|
_toMof(out, _u._dateTimeArray->data(), |
|
_u._dateTimeArray->size); break; |
|
} |
|
} |
|
else if (_type == CIMType::REFERENCE) |
|
{ |
|
_u._referenceValue->toMof(out); |
|
} |
|
else |
|
{ |
|
switch (_type) |
|
{ |
|
case CIMType::BOOLEAN: |
|
_toMof(out, Boolean(_u._booleanValue != 0)); |
|
break; |
|
|
|
case CIMType::UINT8: |
|
_toMof(out, _u._uint8Value); |
|
break; |
|
|
|
case CIMType::SINT8: |
|
_toMof(out, _u._sint8Value); |
|
break; |
|
|
|
case CIMType::UINT16: |
|
_toMof(out, _u._uint16Value); |
|
break; |
|
|
|
case CIMType::SINT16: |
|
_toMof(out, _u._sint16Value); |
|
break; |
|
|
|
case CIMType::UINT32: |
|
_toMof(out, _u._uint32Value); |
|
break; |
|
|
|
case CIMType::SINT32: |
|
_toMof(out, _u._sint32Value); |
|
break; |
|
|
|
case CIMType::UINT64: |
|
_toMof(out, _u._uint64Value); |
|
break; |
|
|
|
case CIMType::SINT64: |
|
_toMof(out, _u._sint64Value); |
|
break; |
|
|
|
case CIMType::REAL32: |
|
_toMof(out, _u._real32Value); |
|
break; |
|
|
|
case CIMType::REAL64: |
|
_toMof(out, _u._real64Value); |
|
break; |
|
|
|
case CIMType::CHAR16: |
|
_toMof(out, Char16(_u._char16Value)); |
|
break; |
|
|
|
case CIMType::STRING: |
|
_toMof(out, *_u._stringValue); |
|
break; |
|
|
|
case CIMType::DATETIME: |
|
_toMof(out, *_u._dateTimeValue); |
|
break; |
|
} |
|
} |
|
} |
|
|
| |
void CIMValue::print(PEGASUS_STD(ostream) &os) const | void CIMValue::print(PEGASUS_STD(ostream) &os) const |
{ | { |
|
|
_Inc(_u._booleanArray = x._rep); | _Inc(_u._booleanArray = x._rep); |
_type = CIMType::BOOLEAN; | _type = CIMType::BOOLEAN; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Uint8>& x) | void CIMValue::set(const Array<Uint8>& x) |
|
|
_Inc(_u._uint8Array = x._rep); | _Inc(_u._uint8Array = x._rep); |
_type = CIMType::UINT8; | _type = CIMType::UINT8; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Sint8>& x) | void CIMValue::set(const Array<Sint8>& x) |
|
|
_Inc(_u._sint8Array = x._rep); | _Inc(_u._sint8Array = x._rep); |
_type = CIMType::SINT8; | _type = CIMType::SINT8; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Uint16>& x) | void CIMValue::set(const Array<Uint16>& x) |
|
|
_Inc(_u._uint16Array = x._rep); | _Inc(_u._uint16Array = x._rep); |
_type = CIMType::UINT16; | _type = CIMType::UINT16; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Sint16>& x) | void CIMValue::set(const Array<Sint16>& x) |
|
|
_Inc(_u._sint16Array = x._rep); | _Inc(_u._sint16Array = x._rep); |
_type = CIMType::SINT16; | _type = CIMType::SINT16; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Uint32>& x) | void CIMValue::set(const Array<Uint32>& x) |
|
|
_Inc(_u._uint32Array = x._rep); | _Inc(_u._uint32Array = x._rep); |
_type = CIMType::UINT32; | _type = CIMType::UINT32; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Sint32>& x) | void CIMValue::set(const Array<Sint32>& x) |
|
|
_Inc(_u._sint32Array = x._rep); | _Inc(_u._sint32Array = x._rep); |
_type = CIMType::SINT32; | _type = CIMType::SINT32; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Uint64>& x) | void CIMValue::set(const Array<Uint64>& x) |
|
|
_Inc(_u._uint64Array = x._rep); | _Inc(_u._uint64Array = x._rep); |
_type = CIMType::UINT64; | _type = CIMType::UINT64; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Sint64>& x) | void CIMValue::set(const Array<Sint64>& x) |
|
|
_Inc(_u._sint64Array = x._rep); | _Inc(_u._sint64Array = x._rep); |
_type = CIMType::SINT64; | _type = CIMType::SINT64; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Real32>& x) | void CIMValue::set(const Array<Real32>& x) |
|
|
_Inc(_u._real32Array = x._rep); | _Inc(_u._real32Array = x._rep); |
_type = CIMType::REAL32; | _type = CIMType::REAL32; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Real64>& x) | void CIMValue::set(const Array<Real64>& x) |
|
|
_Inc(_u._real64Array = x._rep); | _Inc(_u._real64Array = x._rep); |
_type = CIMType::REAL64; | _type = CIMType::REAL64; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Char16>& x) | void CIMValue::set(const Array<Char16>& x) |
|
|
_Inc(_u._char16Array = x._rep); | _Inc(_u._char16Array = x._rep); |
_type = CIMType::CHAR16; | _type = CIMType::CHAR16; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<String>& x) | void CIMValue::set(const Array<String>& x) |
|
|
_Inc(_u._stringArray = x._rep); | _Inc(_u._stringArray = x._rep); |
_type = CIMType::STRING; | _type = CIMType::STRING; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<CIMDateTime>& x) | void CIMValue::set(const Array<CIMDateTime>& x) |
|
|
_Inc(_u._dateTimeArray = x._rep); | _Inc(_u._dateTimeArray = x._rep); |
_type = CIMType::DATETIME; | _type = CIMType::DATETIME; |
_isArray = true; | _isArray = true; |
|
_isNull = false; |
} | } |
| |
void CIMValue::get(Boolean& x) const | void CIMValue::get(Boolean& x) const |
|
|
{ | { |
_type = CIMType::NONE; | _type = CIMType::NONE; |
_isArray = false; | _isArray = false; |
|
_isNull = true; |
_u._voidPtr = 0; | _u._voidPtr = 0; |
} | } |
| |
|
|
| |
void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) | void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) |
{ | { |
|
_isNull = true; |
|
|
clear(); | clear(); |
| |
if (isArray) | if (isArray) |