version 1.49.4.1, 2004/11/12 17:48:28
|
version 1.58, 2005/06/09 21:13:54
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// Carol Ann Krug Graves, Hewlett-Packard Company | // Carol Ann Krug Graves, Hewlett-Packard Company |
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
// Adriann Schuur (schuur@de.ibm.com) PEP 164 | // Adriann Schuur (schuur@de.ibm.com) PEP 164 |
|
// Dave Sudlik, IBM (dsudlik@us.ibm.com) |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
inline void _toString(Array<Sint8>& out, Boolean x) |
inline void _toString(Array<char>& out, Boolean x) |
{ | { |
XmlWriter::append(out, x); | XmlWriter::append(out, x); |
} | } |
| |
inline void _toString(Array<Sint8>& out, Uint8 x) { XmlWriter::append(out, Uint32(x)); } |
inline void _toString(Array<char>& out, Uint8 x) { XmlWriter::append(out, Uint32(x)); } |
inline void _toString(Array<Sint8>& out, Sint8 x) { XmlWriter::append(out, Sint32(x)); } |
inline void _toString(Array<char>& out, Sint8 x) { XmlWriter::append(out, Sint32(x)); } |
inline void _toString(Array<Sint8>& out, Uint16 x) { XmlWriter::append(out, Uint32(x)); } |
inline void _toString(Array<char>& out, Uint16 x) { XmlWriter::append(out, Uint32(x)); } |
inline void _toString(Array<Sint8>& out, Sint16 x) { XmlWriter::append(out, Sint32(x)); } |
inline void _toString(Array<char>& out, Sint16 x) { XmlWriter::append(out, Sint32(x)); } |
inline void _toString(Array<Sint8>& out, Uint32 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<char>& out, Uint32 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<Sint8>& out, Sint32 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<char>& out, Sint32 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<Sint8>& out, Uint64 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<char>& out, Uint64 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<Sint8>& out, Sint64 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<char>& out, Sint64 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<Sint8>& out, Real32 x) { XmlWriter::append(out, Real64(x)); } |
inline void _toString(Array<char>& out, Real32 x) { XmlWriter::append(out, Real64(x)); } |
inline void _toString(Array<Sint8>& out, Real64 x) { XmlWriter::append(out, x); } |
inline void _toString(Array<char>& out, Real64 x) { XmlWriter::append(out, x); } |
| |
inline void _toString(Array<Sint8>& out, Char16 x) |
inline void _toString(Array<char>& out, Char16 x) |
{ | { |
// We need to convert the Char16 to UTF8 then append the UTF8 | // We need to convert the Char16 to UTF8 then append the UTF8 |
// character into the array. | // character into the array. |
|
|
&strtgt, | &strtgt, |
endtgt); | endtgt); |
| |
out.append((Sint8 *)str, UTF_8_COUNT_TRAIL_BYTES(str[0]) +1); |
out.append(str, UTF_8_COUNT_TRAIL_BYTES(str[0]) +1); |
} | } |
| |
inline void _toString(Array<Sint8>& out, const String& x) |
inline void _toString(Array<char>& out, const String& x) |
{ | { |
out << x; | out << x; |
} | } |
| |
inline void _toString(Array<Sint8>& out, const CIMDateTime& x) |
inline void _toString(Array<char>& out, const CIMDateTime& x) |
{ | { |
out << x.toString(); | out << x.toString(); |
} | } |
| |
inline void _toString(Array<Sint8>& out, const CIMObjectPath& x) |
inline void _toString(Array<char>& out, const CIMObjectPath& x) |
{ | { |
out << x.toString(); | out << x.toString(); |
} | } |
| |
inline void _toString(Array<Sint8>& out, const CIMObject& x) |
inline void _toString(Array<char>& out, const CIMObject& x) |
{ | { |
out << x.toString(); | out << x.toString(); |
} | } |
| |
template<class T> | template<class T> |
void _toString(Array<Sint8>& out, const T* p, Uint32 size) |
void _toString(Array<char>& out, const T* p, Uint32 size) |
{ | { |
while (size--) | while (size--) |
{ | { |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
_rep->_u._cimobjectArray = |
// Clone the object array |
new Array<CIMObject>(*(x._rep->_u._cimobjectArray)); |
_rep->_u._objectArray = new Array<CIMObject>(); |
|
for (Uint32 i = 0, n = x._rep->_u._objectArray->size(); |
|
i < n; i++) |
|
{ |
|
// Encountering an uninitialized CIMObject here would |
|
// indicate a Pegasus bug rather than improper use of the |
|
// CIMValue class |
|
PEGASUS_ASSERT( |
|
!(*(x._rep->_u._objectArray))[i].isUninitialized()); |
|
_rep->_u._objectArray->append( |
|
(*(x._rep->_u._objectArray))[i].clone()); |
|
} |
break; | break; |
| |
default: | default: |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
_rep->_u._cimobjectValue = |
if (x._rep->_u._objectValue->isUninitialized()) |
new CIMObject(x._rep->_u._cimobjectValue->clone()); |
{ |
|
_rep->_u._objectValue = new CIMObject(); |
|
} |
|
else |
|
{ |
|
_rep->_u._objectValue = |
|
new CIMObject(x._rep->_u._objectValue->clone()); |
|
} |
break; | break; |
| |
// Should never get here. testing complete enum | // Should never get here. testing complete enum |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
delete _rep->_u._cimobjectArray; |
delete _rep->_u._objectArray; |
break; | break; |
| |
default: | default: |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
delete _rep->_u._cimobjectValue; |
delete _rep->_u._objectValue; |
break; | break; |
| |
default: | default: |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
return _rep->_u._cimobjectArray->size(); |
return _rep->_u._objectArray->size(); |
break; | break; |
| |
//default: // Handled below | //default: // Handled below |
|
|
| |
// Unreachable! | // Unreachable! |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
return 0; |
PEGASUS_UNREACHABLE( return 0; ) |
} | } |
| |
CIMType CIMValue::getType() const | CIMType CIMValue::getType() const |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
set(CIMObject()); |
// Since we can't use set() with an uninitialized CIMObject(), and |
|
// nothing else really makes sense, we duplicate the set() function |
|
// here for an uninitialized object. |
|
_rep->_u._objectValue = new CIMObject(); |
|
_rep->_type = CIMTYPE_OBJECT; |
break; | break; |
| |
default: | default: |
|
|
{ | { |
clear(); | clear(); |
if (x.isUninitialized()) { | if (x.isUninitialized()) { |
// Don't need to clone since null CIMObjects aren't shared when created. |
// Bug 3373, throw exception if uninitialized object is passed to set(). |
// Doesn't work anyway, clone() throws an exception if null. |
throw UninitializedObjectException(); |
_rep->_u._cimobjectValue = new CIMObject(x); |
|
} | } |
else { | else { |
_rep->_u._cimobjectValue = new CIMObject(x.clone()); |
_rep->_u._objectValue = new CIMObject(x.clone()); |
} | } |
_rep->_type = CIMTYPE_OBJECT; | _rep->_type = CIMTYPE_OBJECT; |
_rep->_isNull = false; | _rep->_isNull = false; |
|
|
void CIMValue::set(const Array<CIMObject>& x) | void CIMValue::set(const Array<CIMObject>& x) |
{ | { |
clear(); | clear(); |
_rep->_u._cimobjectArray = new Array<CIMObject>(x); |
|
|
// Copy the input value |
|
AutoPtr<Array<CIMObject> > objectArray(new Array<CIMObject>()); |
|
for (Uint32 i = 0, n = x.size(); i < n; i++) |
|
{ |
|
// Do not allow the value to contain an uninitialized CIMObject |
|
if (x[i].isUninitialized()) |
|
{ |
|
throw UninitializedObjectException(); |
|
} |
|
|
|
objectArray->append(x[i].clone()); |
|
} |
|
_rep->_u._objectArray = objectArray.release(); |
|
|
_rep->_type = CIMTYPE_OBJECT; | _rep->_type = CIMTYPE_OBJECT; |
_rep->_isArray = true; | _rep->_isArray = true; |
_rep->_isNull = false; | _rep->_isNull = false; |
|
|
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
if (!_rep->_isNull) | if (!_rep->_isNull) |
x = *_rep->_u._cimobjectValue; |
x = *_rep->_u._objectValue; |
} | } |
| |
void CIMValue::get(Array<Boolean>& x) const | void CIMValue::get(Array<Boolean>& x) const |
|
|
throw TypeMismatchException(); | throw TypeMismatchException(); |
| |
if (!_rep->_isNull) | if (!_rep->_isNull) |
x = *_rep->_u._cimobjectArray; |
x = *_rep->_u._objectArray; |
} | } |
| |
Boolean CIMValue::equal(const CIMValue& x) const | Boolean CIMValue::equal(const CIMValue& x) const |
|
|
(*x._rep->_u._referenceArray); | (*x._rep->_u._referenceArray); |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
return (*_rep->_u._cimobjectArray) == |
return (*_rep->_u._objectArray) == |
(*x._rep->_u._cimobjectArray); |
(*x._rep->_u._objectArray); |
| |
default: | default: |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
|
|
*x._rep->_u._referenceValue; | *x._rep->_u._referenceValue; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
return (*_rep->_u._cimobjectValue).identical((*x._rep->_u._cimobjectValue)); |
return (*_rep->_u._objectValue).identical((*x._rep->_u._objectValue)); |
| |
default: | default: |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
|
|
} | } |
| |
// Unreachable! | // Unreachable! |
return false; |
PEGASUS_UNREACHABLE( return false; ) |
} | } |
| |
String CIMValue::toString() const | String CIMValue::toString() const |
{ | { |
Array<Sint8> out; |
Array<char> out; |
| |
//ATTN: Not sure what we should do with getstring for Null CIMValues | //ATTN: Not sure what we should do with getstring for Null CIMValues |
//Choice return empty string or exception out. | //Choice return empty string or exception out. |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
_toString(out, _rep->_u._cimobjectArray->getData(), |
_toString(out, _rep->_u._objectArray->getData(), |
_rep->_u._cimobjectArray->size()); |
_rep->_u._objectArray->size()); |
break; | break; |
| |
default: | default: |
|
|
break; | break; |
| |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
_toString(out, *_rep->_u._cimobjectValue); |
_toString(out, *_rep->_u._objectValue); |
break; | break; |
| |
default: | default: |
|
|
return !x.equal(y); | return !x.equal(y); |
} | } |
| |
|
|
|
#ifdef PEGASUS_USE_DEPRECATED_INTERFACES |
|
|
|
CIMValue::CIMValue(char x) |
|
{ |
|
_rep = new CIMValueRep(); |
|
set(x); |
|
} |
|
|
|
CIMValue::CIMValue(const Array<char>& x) |
|
{ |
|
_rep = new CIMValueRep(); |
|
set(x); |
|
} |
|
|
|
void CIMValue::set(char x) |
|
{ |
|
set(static_cast<Sint8>(x)); |
|
} |
|
|
|
void CIMValue::set(const Array<char>& x) |
|
{ |
|
set(*reinterpret_cast<const Array<Sint8> *>(&x)); |
|
} |
|
|
|
void CIMValue::get(char& x) const |
|
{ |
|
get(*reinterpret_cast<Sint8 *>(&x)); |
|
} |
|
|
|
void CIMValue::get(Array<char>& x) const |
|
{ |
|
get(*reinterpret_cast<Array<Sint8> *>(&x)); |
|
} |
|
|
|
#endif |
|
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |