version 1.40, 2002/08/21 00:15:44
|
version 1.43.14.1, 2003/08/13 19:39:50
|
|
|
#include "Union.h" | #include "Union.h" |
#include "Indentor.h" | #include "Indentor.h" |
#include "XmlWriter.h" | #include "XmlWriter.h" |
|
#include "CommonUTF.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
| |
inline void _toString(Array<Sint8>& out, Char16 x) | inline void _toString(Array<Sint8>& out, Char16 x) |
{ | { |
// ATTN: How to convert 16-bit characters to printable form? |
// We need to convert the Char16 to UTF8 then append the UTF8 |
out.append(Sint8(x)); |
// character into the array. |
|
// NOTE: The UTF8 character could be several bytes long. |
|
// WARNING: This function will put in replacement character for |
|
// all characters that have surogate pairs. |
|
|
|
char str[6]; |
|
memset(str,0x00,sizeof(str)); |
|
char* charIN = (char *)&x; |
|
|
|
const Uint16 *strsrc = (Uint16 *)charIN; |
|
Uint16 *endsrc = (Uint16 *)&charIN[1]; |
|
|
|
Uint8 *strtgt = (Uint8 *)str; |
|
Uint8 *endtgt = (Uint8 *)&str[5]; |
|
|
|
UTF16toUTF8(&strsrc, |
|
endsrc, |
|
&strtgt, |
|
endtgt); |
|
|
|
out.append((Sint8 *)str,trailingBytesForUTF8[Uint32(str[0])]+1); |
} | } |
| |
inline void _toString(Array<Sint8>& out, const String& x) | inline void _toString(Array<Sint8>& out, const String& x) |
|
|
_rep->_u._referenceArray = | _rep->_u._referenceArray = |
new Array<CIMObjectPath>(*(x._rep->_u._referenceArray)); | new Array<CIMObjectPath>(*(x._rep->_u._referenceArray)); |
break; | break; |
|
|
default: | default: |
throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
else | else |
|
|
| |
// Should never get here. testing complete enum | // Should never get here. testing complete enum |
default: | default: |
throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
} | } |
| |
//ATTN: P1 KS Problem with Compiler when I added the defaults to clear, the compiler |
|
// gets an exception very early. Disabled the exceptions to keep compiler running for |
|
// the minute. Note that the case statement is not complete. None missing. |
|
void CIMValue::clear() | void CIMValue::clear() |
{ | { |
if (_rep->_isArray) | if (_rep->_isArray) |
|
|
delete _rep->_u._referenceArray; | delete _rep->_u._referenceArray; |
break; | break; |
| |
//default: |
default: |
//throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
else | else |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
delete _rep->_u._referenceValue; | delete _rep->_u._referenceValue; |
break; | break; |
//default: |
|
//throw CIMValueInvalidTypeException(); |
default: |
|
PEGASUS_ASSERT(false); |
} | } |
} | } |
| |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
return _rep->_u._referenceArray->size(); | return _rep->_u._referenceArray->size(); |
break; | break; |
// Should never get here. switch on complete enum |
|
default: |
//default: // Handled below |
throw CIMValueInvalidTypeException(); |
|
} | } |
| |
// Unreachable! | // Unreachable! |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
set(Array<CIMObjectPath>(arraySize)); | set(Array<CIMObjectPath>(arraySize)); |
break; | break; |
|
|
default: | default: |
throw CIMValueInvalidTypeException(); |
throw TypeMismatchException(); |
} | } |
} | } |
else | else |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
set(CIMObjectPath()); | set(CIMObjectPath()); |
break; | break; |
|
|
default: | default: |
throw CIMValueInvalidTypeException(); |
throw TypeMismatchException(); |
} | } |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_BOOLEAN || _rep->_isArray) | if (_rep->_type != CIMTYPE_BOOLEAN || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._booleanValue != 0; | x = _rep->_u._booleanValue != 0; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT8 || _rep->_isArray) | if (_rep->_type != CIMTYPE_UINT8 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._uint8Value; | x = _rep->_u._uint8Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT8 || _rep->_isArray) | if (_rep->_type != CIMTYPE_SINT8 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._sint8Value; | x = _rep->_u._sint8Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT16 || _rep->_isArray) | if (_rep->_type != CIMTYPE_UINT16 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._uint16Value; | x = _rep->_u._uint16Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT16 || _rep->_isArray) | if (_rep->_type != CIMTYPE_SINT16 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._sint16Value; | x = _rep->_u._sint16Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT32 || _rep->_isArray) | if (_rep->_type != CIMTYPE_UINT32 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._uint32Value; | x = _rep->_u._uint32Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT32 || _rep->_isArray) | if (_rep->_type != CIMTYPE_SINT32 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._sint32Value; | x = _rep->_u._sint32Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT64 || _rep->_isArray) | if (_rep->_type != CIMTYPE_UINT64 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._uint64Value; | x = _rep->_u._uint64Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT64 || _rep->_isArray) | if (_rep->_type != CIMTYPE_SINT64 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._sint64Value; | x = _rep->_u._sint64Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_REAL32 || _rep->_isArray) | if (_rep->_type != CIMTYPE_REAL32 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._real32Value; | x = _rep->_u._real32Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_REAL64 || _rep->_isArray) | if (_rep->_type != CIMTYPE_REAL64 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._real64Value; | x = _rep->_u._real64Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_CHAR16 || _rep->_isArray) | if (_rep->_type != CIMTYPE_CHAR16 || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = _rep->_u._char16Value; | x = _rep->_u._char16Value; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_STRING || _rep->_isArray) | if (_rep->_type != CIMTYPE_STRING || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._stringValue; | x = *_rep->_u._stringValue; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_DATETIME || _rep->_isArray) | if (_rep->_type != CIMTYPE_DATETIME || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._dateTimeValue; | x = *_rep->_u._dateTimeValue; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_REFERENCE || _rep->_isArray) | if (_rep->_type != CIMTYPE_REFERENCE || _rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._referenceValue; | x = *_rep->_u._referenceValue; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_BOOLEAN || !_rep->_isArray) | if (_rep->_type != CIMTYPE_BOOLEAN || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._booleanArray; | x = *_rep->_u._booleanArray; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT8 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_UINT8 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._uint8Array; | x = *_rep->_u._uint8Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT8 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_SINT8 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._sint8Array; | x = *_rep->_u._sint8Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT16 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_UINT16 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._uint16Array; | x = *_rep->_u._uint16Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT16 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_SINT16 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._sint16Array; | x = *_rep->_u._sint16Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT32 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_UINT32 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._uint32Array; | x = *_rep->_u._uint32Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT32 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_SINT32 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._sint32Array; | x = *_rep->_u._sint32Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_UINT64 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_UINT64 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._uint64Array; | x = *_rep->_u._uint64Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_SINT64 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_SINT64 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._sint64Array; | x = *_rep->_u._sint64Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_REAL32 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_REAL32 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._real32Array; | x = *_rep->_u._real32Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_REAL64 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_REAL64 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._real64Array; | x = *_rep->_u._real64Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_CHAR16 || !_rep->_isArray) | if (_rep->_type != CIMTYPE_CHAR16 || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._char16Array; | x = *_rep->_u._char16Array; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_STRING || !_rep->_isArray) | if (_rep->_type != CIMTYPE_STRING || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._stringArray; | x = *_rep->_u._stringArray; |
} | } |
| |
void CIMValue::get(Array<CIMDateTime>& x) const | void CIMValue::get(Array<CIMDateTime>& x) const |
{ | { |
// ATTN-RK-20020815: Use UninitializedObjectException here if CIMValue is null? |
|
|
|
if (_rep->_type != CIMTYPE_DATETIME || !_rep->_isArray) | if (_rep->_type != CIMTYPE_DATETIME || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._dateTimeArray; | x = *_rep->_u._dateTimeArray; |
} | } |
| |
|
|
if (_rep->_type != CIMTYPE_REFERENCE || !_rep->_isArray) | if (_rep->_type != CIMTYPE_REFERENCE || !_rep->_isArray) |
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
|
if (!_rep->_isNull) |
x = *_rep->_u._referenceArray; | x = *_rep->_u._referenceArray; |
} | } |
| |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
return (*_rep->_u._referenceArray) == | return (*_rep->_u._referenceArray) == |
(*x._rep->_u._referenceArray); | (*x._rep->_u._referenceArray); |
|
|
default: | default: |
throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
else | else |
|
|
*x._rep->_u._referenceValue; | *x._rep->_u._referenceValue; |
| |
default: | default: |
throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
| |
|
|
break; | break; |
| |
default: | default: |
throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
else | else |
|
|
break; | break; |
| |
default: | default: |
throw CIMValueInvalidTypeException(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
| |