version 1.12, 2001/12/13 14:53:55
|
version 1.13, 2002/02/18 13:59:48
|
|
|
// Author: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Karl Schopmeyer, (k.schopmeyer@opengroup.org) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
template<class T> | template<class T> |
void _toMof(Array<Sint8>& out, const T* p, Uint32 size) | void _toMof(Array<Sint8>& out, const T* p, Uint32 size) |
{ | { |
|
//ATTNKS: Account for the Null value here |
Boolean isFirstEntry = true; | Boolean isFirstEntry = true; |
// if there are any entries in the array output them | // if there are any entries in the array output them |
if (size) | if (size) |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_Inc(_u._dateTimeArray = x._u._dateTimeArray); | _Inc(_u._dateTimeArray = x._u._dateTimeArray); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
else | else |
|
|
_u._referenceValue | _u._referenceValue |
= new CIMReference(*(x._u._referenceValue)); | = new CIMReference(*(x._u._referenceValue)); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
} | } |
|
|
| |
case CIMType::REFERENCE: | case CIMType::REFERENCE: |
return 0; | return 0; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
| |
// Unreachable! | // Unreachable! |
|
|
return 0; | return 0; |
} | } |
| |
|
//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. |
void CIMValue::clear() | void CIMValue::clear() |
{ | { |
|
// ATTN: KS P1 should we be setting NULL=true here????. Right now it only |
|
// clears the value component. Note that the last thing we do is init |
|
// and that does the isNull=false. |
|
// |
if (_isArray) | if (_isArray) |
{ | { |
switch (_type) | switch (_type) |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_Dec(_u._dateTimeArray); | _Dec(_u._dateTimeArray); |
break; | break; |
|
//default: |
|
//throw CIMValueInvalidType(); |
} | } |
} | } |
else | else |
|
|
case CIMType::REFERENCE: | case CIMType::REFERENCE: |
delete _u._referenceValue; | delete _u._referenceValue; |
break; | break; |
|
//default: |
|
//throw CIMValueInvalidType(); |
} | } |
} | } |
| |
|
|
| |
void CIMValue::toXml(Array<Sint8>& out) const | void CIMValue::toXml(Array<Sint8>& out) const |
{ | { |
|
// If the CIMValue is Null, no element is returned. |
|
//ATTNCH: Feb 12 added the isNull test KS |
|
// Note that I ouptut absolutly nothing |
|
|
|
if (_isNull) |
|
{ |
|
// out << "\n"; |
|
return; |
|
} |
if (_isArray) | if (_isArray) |
{ | { |
out << "<VALUE.ARRAY>\n"; | out << "<VALUE.ARRAY>\n"; |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_toXml(out, _u._dateTimeArray->data(), _u._dateTimeArray->size); | _toXml(out, _u._dateTimeArray->data(), _u._dateTimeArray->size); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
| |
out << "</VALUE.ARRAY>\n"; | out << "</VALUE.ARRAY>\n"; |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_toXml(out, *_u._dateTimeValue); | _toXml(out, *_u._dateTimeValue); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
| |
out << "</VALUE>\n"; | out << "</VALUE>\n"; |
|
|
return String(out.getData()); | return String(out.getData()); |
} | } |
| |
void CIMValue::toMof(Array<Sint8>& out) const //ATTNKS: |
void CIMValue::toMof(Array<Sint8>& out) const |
{ | { |
|
// if the CIMValue is Null we return nothing. |
|
if (_isNull) |
|
return; |
|
|
if (_isArray) | if (_isArray) |
{ | { |
switch (_type) | switch (_type) |
|
|
case CIMType::BOOLEAN: | case CIMType::BOOLEAN: |
{ | { |
for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++) | for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++) |
{ |
|
_toMof(out, Boolean(_u._booleanArray->data()[i])); | _toMof(out, Boolean(_u._booleanArray->data()[i])); |
} |
|
break; | break; |
} | } |
case CIMType::UINT8: | case CIMType::UINT8: |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_toMof(out, _u._dateTimeArray->data(), | _toMof(out, _u._dateTimeArray->data(), |
_u._dateTimeArray->size); break; | _u._dateTimeArray->size); break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
else if (_type == CIMType::REFERENCE) | else if (_type == CIMType::REFERENCE) |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_toMof(out, *_u._dateTimeValue); | _toMof(out, *_u._dateTimeValue); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
} | } |
|
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
void CIMValue::set(Boolean x) | void CIMValue::set(Boolean x) |
{ | { |
clear(); | clear(); |
_u._booleanValue = (Uint8)x; | _u._booleanValue = (Uint8)x; |
_type = CIMType::BOOLEAN; | _type = CIMType::BOOLEAN; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Uint8 x) | void CIMValue::set(Uint8 x) |
|
|
clear(); | clear(); |
_u._uint8Value = x; | _u._uint8Value = x; |
_type = CIMType::UINT8; | _type = CIMType::UINT8; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Sint8 x) | void CIMValue::set(Sint8 x) |
|
|
clear(); | clear(); |
_u._sint8Value = x; | _u._sint8Value = x; |
_type = CIMType::SINT8; | _type = CIMType::SINT8; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Uint16 x) | void CIMValue::set(Uint16 x) |
|
|
clear(); | clear(); |
_u._uint16Value = x; | _u._uint16Value = x; |
_type = CIMType::UINT16; | _type = CIMType::UINT16; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Sint16 x) | void CIMValue::set(Sint16 x) |
|
|
clear(); | clear(); |
_u._sint16Value = x; | _u._sint16Value = x; |
_type = CIMType::SINT16; | _type = CIMType::SINT16; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Uint32 x) | void CIMValue::set(Uint32 x) |
|
|
clear(); | clear(); |
_u._uint32Value = x; | _u._uint32Value = x; |
_type = CIMType::UINT32; | _type = CIMType::UINT32; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Sint32 x) | void CIMValue::set(Sint32 x) |
|
|
clear(); | clear(); |
_u._sint32Value = x; | _u._sint32Value = x; |
_type = CIMType::SINT32; | _type = CIMType::SINT32; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Uint64 x) | void CIMValue::set(Uint64 x) |
|
|
clear(); | clear(); |
_u._uint64Value = x; | _u._uint64Value = x; |
_type = CIMType::UINT64; | _type = CIMType::UINT64; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Sint64 x) | void CIMValue::set(Sint64 x) |
|
|
clear(); | clear(); |
_u._sint64Value = x; | _u._sint64Value = x; |
_type = CIMType::SINT64; | _type = CIMType::SINT64; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Real32 x) | void CIMValue::set(Real32 x) |
|
|
clear(); | clear(); |
_u._real32Value = x; | _u._real32Value = x; |
_type = CIMType::REAL32; | _type = CIMType::REAL32; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(Real64 x) | void CIMValue::set(Real64 x) |
|
|
clear(); | clear(); |
_u._real64Value = x; | _u._real64Value = x; |
_type = CIMType::REAL64; | _type = CIMType::REAL64; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Char16& x) | void CIMValue::set(const Char16& x) |
|
|
clear(); | clear(); |
_u._char16Value = x; | _u._char16Value = x; |
_type = CIMType::CHAR16; | _type = CIMType::CHAR16; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const String& x) | void CIMValue::set(const String& x) |
|
|
clear(); | clear(); |
new(_u._stringValue) String(x); | new(_u._stringValue) String(x); |
_type = CIMType::STRING; | _type = CIMType::STRING; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const char* x) | void CIMValue::set(const char* x) |
{ | { |
set(String(x)); | set(String(x)); |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const CIMDateTime& x) | void CIMValue::set(const CIMDateTime& x) |
|
|
clear(); | clear(); |
_u._dateTimeValue = new CIMDateTime(x); | _u._dateTimeValue = new CIMDateTime(x); |
_type = CIMType::DATETIME; | _type = CIMType::DATETIME; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const CIMReference& x) | void CIMValue::set(const CIMReference& x) |
|
|
clear(); | clear(); |
_u._referenceValue = new CIMReference(x); | _u._referenceValue = new CIMReference(x); |
_type = CIMType::REFERENCE; | _type = CIMType::REFERENCE; |
|
_isNull = false; |
} | } |
| |
void CIMValue::set(const Array<Boolean>& x) | void CIMValue::set(const Array<Boolean>& x) |
|
|
| |
void CIMValue::get(Array<CIMDateTime>& x) const | void CIMValue::get(Array<CIMDateTime>& x) const |
{ | { |
|
#ifdef CIMValueisNullexception |
|
if (_isNull) |
|
throw CIMValueIsNull(); |
|
#endif |
|
|
if (_type != CIMType::DATETIME || !_isArray) | if (_type != CIMType::DATETIME || !_isArray) |
throw TypeMismatch(); | throw TypeMismatch(); |
| |
|
|
if (!x.typeCompatible(y)) | if (!x.typeCompatible(y)) |
return false; | return false; |
| |
|
if (x.isNull != y.isNull) |
|
return false; |
|
|
if (x._isArray) | if (x._isArray) |
{ | { |
switch (x._type) | switch (x._type) |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
return Array<CIMDateTime>(x._u._dateTimeArray) == | return Array<CIMDateTime>(x._u._dateTimeArray) == |
Array<CIMDateTime>(y._u._dateTimeArray); | Array<CIMDateTime>(y._u._dateTimeArray); |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
else | else |
|
|
| |
case CIMType::REFERENCE: | case CIMType::REFERENCE: |
return *x._u._referenceValue == *y._u._referenceValue; | return *x._u._referenceValue == *y._u._referenceValue; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
| |
|
|
| |
void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) | void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) |
{ | { |
_isNull = true; |
|
| |
clear(); | clear(); |
| |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
set(Array<CIMDateTime>(arraySize)); | set(Array<CIMDateTime>(arraySize)); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
else | else |
|
|
case CIMType::REFERENCE: | case CIMType::REFERENCE: |
set(CIMReference()); | set(CIMReference()); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
|
|
|
// Set the Null attribute. Note that this must be after the set |
|
// because the set functions sets the _isNull. |
|
|
|
_isNull = true; |
} | } |
| |
String CIMValue::toString() const | String CIMValue::toString() const |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
| |
|
//ATTN: Not sure what we should do with getstring for Null CIMValues |
|
//Choice return empty string or exception out. |
|
|
if (_isArray) | if (_isArray) |
{ | { |
switch (_type) | switch (_type) |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_toString(out, _u._dateTimeArray->data(), _u._dateTimeArray->size); | _toString(out, _u._dateTimeArray->data(), _u._dateTimeArray->size); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
else if (_type == CIMType::REFERENCE) | else if (_type == CIMType::REFERENCE) |
|
|
case CIMType::DATETIME: | case CIMType::DATETIME: |
_toString(out, *_u._dateTimeValue); | _toString(out, *_u._dateTimeValue); |
break; | break; |
|
default: |
|
throw CIMValueInvalidType(); |
} | } |
} | } |
| |