(file) Return to CIMValue.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/CIMValue.cpp between version 1.37 and 1.61

version 1.37, 2002/08/16 01:28:06 version 1.61, 2005/10/31 18:19:27
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // 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.;
   // 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
Line 27 
Line 33 
 //              Karl Schopmeyer, (k.schopmeyer@opengroup.org) //              Karl Schopmeyer, (k.schopmeyer@opengroup.org)
 //              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
   //              Dave Sudlik, IBM (dsudlik@us.ibm.com)
   //              David Dillard, VERITAS Software Corp.
   //                  (david.dillard@veritas.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 37 
Line 47 
 #include "Union.h" #include "Union.h"
 #include "Indentor.h" #include "Indentor.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
   #include "CommonUTF.h"
   #include "Buffer.h"
   #include "CIMValueRep.h"
   #include "Buffer.h"
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 #define PEGASUS_ARRAY_T CIMValue #define PEGASUS_ARRAY_T CIMValue
Line 45 
Line 58 
 #undef PEGASUS_ARRAY_T #undef PEGASUS_ARRAY_T
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
   
 // //
 // _toString routines: // _toString routines:
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
 inline void _toString(Array<Sint8>& out, Boolean x)  inline void _toString(Buffer& 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(Buffer& out, Uint8 x) { XmlWriter::append(out, Uint32(x)); }
 inline void _toString(Array<Sint8>& out, Sint8 x) { XmlWriter::append(out, Sint32(x)); }  inline void _toString(Buffer& out, Sint8 x) { XmlWriter::append(out, Sint32(x)); }
 inline void _toString(Array<Sint8>& out, Uint16 x) { XmlWriter::append(out, Uint32(x)); }  inline void _toString(Buffer& out, Uint16 x) { XmlWriter::append(out, Uint32(x)); }
 inline void _toString(Array<Sint8>& out, Sint16 x) { XmlWriter::append(out, Sint32(x)); }  inline void _toString(Buffer& out, Sint16 x) { XmlWriter::append(out, Sint32(x)); }
 inline void _toString(Array<Sint8>& out, Uint32 x) { XmlWriter::append(out, x); }  inline void _toString(Buffer& out, Uint32 x) { XmlWriter::append(out, x); }
 inline void _toString(Array<Sint8>& out, Sint32 x) { XmlWriter::append(out, x); }  inline void _toString(Buffer& out, Sint32 x) { XmlWriter::append(out, x); }
 inline void _toString(Array<Sint8>& out, Uint64 x) { XmlWriter::append(out, x); }  inline void _toString(Buffer& out, Uint64 x) { XmlWriter::append(out, x); }
 inline void _toString(Array<Sint8>& out, Sint64 x) { XmlWriter::append(out, x); }  inline void _toString(Buffer& out, Sint64 x) { XmlWriter::append(out, x); }
 inline void _toString(Array<Sint8>& out, Real32 x) { XmlWriter::append(out, Real64(x)); }  inline void _toString(Buffer& out, Real32 x) { XmlWriter::append(out, Real64(x)); }
 inline void _toString(Array<Sint8>& out, Real64 x) { XmlWriter::append(out, x); }  inline void _toString(Buffer& out, Real64 x) { XmlWriter::append(out, x); }
   
   inline void _toString(Buffer& out, Char16 x)
   {
       // We need to convert the Char16 to UTF8 then append the UTF8
       // 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);
  
 inline void _toString(Array<Sint8>& out, Char16 x)      out.append(str, UTF_8_COUNT_TRAIL_BYTES(str[0]) +1);
 {  
     // ATTN: How to convert 16-bit characters to printable form?  
     out.append(Sint8(x));  
 } }
  
 inline void _toString(Array<Sint8>& out, const String& x)  inline void _toString(Buffer& out, const String& x)
 { {
     out << x;     out << x;
 } }
  
 inline void _toString(Array<Sint8>& out, const CIMDateTime& x)  inline void _toString(Buffer& out, const CIMDateTime& x)
 { {
     out << x.getString();      out << x.toString();
 } }
  
 inline void _toString(Array<Sint8>& out, const CIMObjectPath& x)  inline void _toString(Buffer& out, const CIMObjectPath& x)
 { {
     out << x.toString();     out << x.toString();
 } }
  
 template<class T>  inline void _toString(Buffer& out, const CIMObject& x)
 void _toString(Array<Sint8>& out, const T* p, Uint32 size)  
 {  
     while (size--)  
     {     {
         _toString(out, *p++);      out << x.toString();
         out << " ";  
     }  
 } }
  
   template<class T>
 ////////////////////////////////////////////////////////////////////////////////  void _toString(Buffer& out, const T* p, Uint32 size)
 //  
 // CIMValueRep  
 //  
 ////////////////////////////////////////////////////////////////////////////////  
   
 class CIMValueRep  
 {  
 public:  
     CIMValueRep()  
     {     {
         reset();      while (size--)
     }  
   
     ~CIMValueRep()  
     {     {
           _toString(out, *p++);
           out.append(' ');
     }     }
   
     void reset()  
     {  
         _type = CIMTYPE_NONE;  
         _isArray = false;  
         _isNull = true;  
         _u._voidPtr = 0;  
     }     }
  
     CIMType _type;  
     Boolean _isArray;  
     Boolean _isNull;  
     Union _u;  
 };  
   
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // //
Line 238 
Line 244 
     set(x);     set(x);
 } }
  
   CIMValue::CIMValue(const CIMObject& x)
   {
       _rep = new CIMValueRep();
       AutoPtr<CIMValueRep> rep(_rep);
   
       set(x);
   
       rep.release();
   }
   
 CIMValue::CIMValue(const Array<Boolean>& x) CIMValue::CIMValue(const Array<Boolean>& x)
 { {
     _rep = new CIMValueRep();     _rep = new CIMValueRep();
Line 328 
Line 344 
     set(x);     set(x);
 } }
  
   CIMValue::CIMValue(const Array<CIMObject>& x)
   {
       _rep = new CIMValueRep();
       AutoPtr<CIMValueRep> rep(_rep);
   
       set(x);
   
       rep.release();
   }
   
 CIMValue::CIMValue(const CIMValue& x) CIMValue::CIMValue(const CIMValue& x)
 { {
     _rep = new CIMValueRep();     _rep = new CIMValueRep();
Line 356 
Line 382 
     _rep->_type = x._rep->_type;     _rep->_type = x._rep->_type;
     _rep->_isArray = x._rep->_isArray;     _rep->_isArray = x._rep->_isArray;
     _rep->_isNull = x._rep->_isNull;     _rep->_isNull = x._rep->_isNull;
     _rep->_u._voidPtr = 0;  
  
     if (_rep->_isArray)     if (_rep->_isArray)
     {     {
Line 423 
Line 448 
                 break;                 break;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 _rep->_u._stringArray =                  new(_rep->_u._stringArray) Array<String>(x._rep->stringArray());
                     new Array<String>(*(x._rep->_u._stringArray));  
                 break;                 break;
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
Line 436 
Line 460 
                 _rep->_u._referenceArray =                 _rep->_u._referenceArray =
                     new Array<CIMObjectPath>(*(x._rep->_u._referenceArray));                     new Array<CIMObjectPath>(*(x._rep->_u._referenceArray));
                 break;                 break;
   
               case CIMTYPE_OBJECT:
                   // Clone the object array
                   _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;
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
     {     {
         switch (_rep->_type)         switch (_rep->_type)
         {         {
             case CIMTYPE_NONE:  
                 break;  
   
             case CIMTYPE_BOOLEAN:             case CIMTYPE_BOOLEAN:
                 _rep->_u._booleanValue = x._rep->_u._booleanValue;                 _rep->_u._booleanValue = x._rep->_u._booleanValue;
                 break;                 break;
Line 496 
Line 534 
                 break;                 break;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 _rep->_u._stringValue = new String(*(x._rep->_u._stringValue));                  new(_rep->_u._stringValue) String(
                       *((String*)x._rep->_u._stringValue));
                 break;                 break;
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
Line 509 
Line 548 
                     new CIMObjectPath(*(x._rep->_u._referenceValue));                     new CIMObjectPath(*(x._rep->_u._referenceValue));
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   if (x._rep->_u._objectValue->isUninitialized())
                   {
                       _rep->_u._objectValue = new CIMObject();
                   }
                   else
                   {
                       _rep->_u._objectValue =
                           new CIMObject(x._rep->_u._objectValue->clone());
                   }
                   break;
   
             // Should never get here. testing complete enum             // Should never get here. testing complete enum
             default:             default:
                 throw CIMValueInvalidType();                  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)
Line 574 
Line 622 
                 break;                 break;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 delete _rep->_u._stringArray;                  _rep->stringArray().~Array<String>();
                 break;                 break;
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
Line 585 
Line 633 
                 delete _rep->_u._referenceArray;                 delete _rep->_u._referenceArray;
                 break;                 break;
  
             //default:              case CIMTYPE_OBJECT:
                 //throw CIMValueInvalidType();                  delete _rep->_u._objectArray;
                   break;
   
               default:
                   PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
Line 608 
Line 660 
                 break;                 break;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 delete _rep->_u._stringValue;                  ((String*)_rep->_u._stringValue)->~String();
                 break;                 break;
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
Line 618 
Line 670 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 delete _rep->_u._referenceValue;                 delete _rep->_u._referenceValue;
                 break;                 break;
             //default:  
                 //throw CIMValueInvalidType();              case CIMTYPE_OBJECT:
                   delete _rep->_u._objectValue;
                   break;
   
               default:
                   PEGASUS_ASSERT(false);
         }         }
     }     }
  
Line 650 
Line 707 
  
     switch (_rep->_type)     switch (_rep->_type)
     {     {
         case CIMTYPE_NONE:  
             return 0;  
             break;  
   
         case CIMTYPE_BOOLEAN:         case CIMTYPE_BOOLEAN:
             return _rep->_u._booleanArray->size();             return _rep->_u._booleanArray->size();
             break;             break;
Line 703 
Line 756 
             break;             break;
  
         case CIMTYPE_STRING:         case CIMTYPE_STRING:
             return _rep->_u._stringArray->size();              return _rep->stringArray().size();
             break;             break;
  
         case CIMTYPE_DATETIME:         case CIMTYPE_DATETIME:
Line 713 
Line 766 
         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:          case CIMTYPE_OBJECT:
             throw CIMValueInvalidType();              return _rep->_u._objectArray->size();
               break;
   
           //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
Line 730 
Line 786 
  
 void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize)
 { {
   
     clear();     clear();
  
     if (isArray)     if (isArray)
Line 796 
Line 851 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 set(Array<CIMObjectPath>(arraySize));                 set(Array<CIMObjectPath>(arraySize));
                 break;                 break;
   
               case CIMTYPE_OBJECT:
                   set(Array<CIMObject>(arraySize));
                   break;
   
             default:             default:
                 throw CIMValueInvalidType();                  throw TypeMismatchException();
         }         }
     }     }
     else     else
Line 863 
Line 923 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 set(CIMObjectPath());                 set(CIMObjectPath());
                 break;                 break;
   
               case CIMTYPE_OBJECT:
                   // 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;
   
             default:             default:
                 throw CIMValueInvalidType();                  throw TypeMismatchException();
         }         }
     }     }
  
Line 973 
Line 1042 
 void CIMValue::set(const String& x) void CIMValue::set(const String& x)
 { {
     clear();     clear();
     _rep->_u._stringValue = new String(x);      new(_rep->_u._stringValue) String(x);
     _rep->_type = CIMTYPE_STRING;     _rep->_type = CIMTYPE_STRING;
     _rep->_isNull = false;     _rep->_isNull = false;
 } }
Line 994 
Line 1063 
     _rep->_isNull = false;     _rep->_isNull = false;
 } }
  
   void CIMValue::set(const CIMObject& x)
   {
       clear();
       if (x.isUninitialized()) {
           // Bug 3373, throw exception if uninitialized object is passed to set().
           throw UninitializedObjectException();
       }
       else {
           _rep->_u._objectValue = new CIMObject(x.clone());
       }
       _rep->_type = CIMTYPE_OBJECT;
       _rep->_isNull = false;
   }
   
 void CIMValue::set(const Array<Boolean>& x) void CIMValue::set(const Array<Boolean>& x)
 { {
     clear();     clear();
Line 1105 
Line 1188 
 void CIMValue::set(const Array<String>& x) void CIMValue::set(const Array<String>& x)
 { {
     clear();     clear();
     _rep->_u._stringArray = new Array<String>(x);      new(_rep->_u._stringArray) Array<String>(x);
     _rep->_type = CIMTYPE_STRING;     _rep->_type = CIMTYPE_STRING;
     _rep->_isArray = true;     _rep->_isArray = true;
     _rep->_isNull = false;     _rep->_isNull = false;
Line 1129 
Line 1212 
     _rep->_isNull = false;     _rep->_isNull = false;
 } }
  
   void CIMValue::set(const Array<CIMObject>& x)
   {
       clear();
   
       // 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->_isArray = true;
       _rep->_isNull = false;
   }
   
 void CIMValue::get(Boolean& x) const void CIMValue::get(Boolean& x) const
 { {
     if (_rep->_type != CIMTYPE_BOOLEAN || _rep->_isArray)     if (_rep->_type != CIMTYPE_BOOLEAN || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._booleanValue != 0;     x = _rep->_u._booleanValue != 0;
 } }
  
 void CIMValue::get(Uint8& x) const void CIMValue::get(Uint8& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT8 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT8 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint8Value;     x = _rep->_u._uint8Value;
 } }
  
 void CIMValue::get(Sint8& x) const void CIMValue::get(Sint8& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT8 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT8 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint8Value;     x = _rep->_u._sint8Value;
 } }
  
 void CIMValue::get(Uint16& x) const void CIMValue::get(Uint16& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT16 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT16 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint16Value;     x = _rep->_u._uint16Value;
 } }
  
 void CIMValue::get(Sint16& x) const void CIMValue::get(Sint16& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT16 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT16 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint16Value;     x = _rep->_u._sint16Value;
 } }
  
 void CIMValue::get(Uint32& x) const void CIMValue::get(Uint32& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT32 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT32 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint32Value;     x = _rep->_u._uint32Value;
 } }
  
 void CIMValue::get(Sint32& x) const void CIMValue::get(Sint32& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT32 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT32 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint32Value;     x = _rep->_u._sint32Value;
 } }
  
 void CIMValue::get(Uint64& x) const void CIMValue::get(Uint64& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT64 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT64 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint64Value;     x = _rep->_u._uint64Value;
 } }
  
 void CIMValue::get(Sint64& x) const void CIMValue::get(Sint64& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT64 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT64 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint64Value;     x = _rep->_u._sint64Value;
 } }
  
 void CIMValue::get(Real32& x) const void CIMValue::get(Real32& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL32 || _rep->_isArray)     if (_rep->_type != CIMTYPE_REAL32 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._real32Value;     x = _rep->_u._real32Value;
 } }
  
 void CIMValue::get(Real64& x) const void CIMValue::get(Real64& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL64 || _rep->_isArray)     if (_rep->_type != CIMTYPE_REAL64 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._real64Value;     x = _rep->_u._real64Value;
 } }
  
 void CIMValue::get(Char16& x) const void CIMValue::get(Char16& x) const
 { {
     if (_rep->_type != CIMTYPE_CHAR16 || _rep->_isArray)     if (_rep->_type != CIMTYPE_CHAR16 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._char16Value;     x = _rep->_u._char16Value;
 } }
  
 void CIMValue::get(String& x) const void CIMValue::get(String& x) const
 { {
     if (_rep->_type != CIMTYPE_STRING || _rep->_isArray)     if (_rep->_type != CIMTYPE_STRING || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
     x = *_rep->_u._stringValue;      if (!_rep->_isNull)
           x = *((String*)_rep->_u._stringValue);
 } }
  
 void CIMValue::get(CIMDateTime& x) const void CIMValue::get(CIMDateTime& x) const
 { {
     if (_rep->_type != CIMTYPE_DATETIME || _rep->_isArray)     if (_rep->_type != CIMTYPE_DATETIME || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._dateTimeValue;     x = *_rep->_u._dateTimeValue;
 } }
  
 void CIMValue::get(CIMObjectPath& x) const void CIMValue::get(CIMObjectPath& x) const
 { {
     if (_rep->_type != CIMTYPE_REFERENCE || _rep->_isArray)     if (_rep->_type != CIMTYPE_REFERENCE || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._referenceValue;     x = *_rep->_u._referenceValue;
 } }
  
   void CIMValue::get(CIMObject& x) const
   {
       if (_rep->_type != CIMTYPE_OBJECT || _rep->_isArray)
           throw TypeMismatchException();
   
       if (!_rep->_isNull)
           x = *_rep->_u._objectValue;
   }
   
 void CIMValue::get(Array<Boolean>& x) const void CIMValue::get(Array<Boolean>& x) const
 { {
     if (_rep->_type != CIMTYPE_BOOLEAN || !_rep->_isArray)     if (_rep->_type != CIMTYPE_BOOLEAN || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._booleanArray;     x = *_rep->_u._booleanArray;
 } }
  
 void CIMValue::get(Array<Uint8>& x) const void CIMValue::get(Array<Uint8>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT8 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT8 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint8Array;     x = *_rep->_u._uint8Array;
 } }
  
 void CIMValue::get(Array<Sint8>& x) const void CIMValue::get(Array<Sint8>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT8 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT8 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint8Array;     x = *_rep->_u._sint8Array;
 } }
  
 void CIMValue::get(Array<Uint16>& x) const void CIMValue::get(Array<Uint16>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT16 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT16 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint16Array;     x = *_rep->_u._uint16Array;
 } }
  
 void CIMValue::get(Array<Sint16>& x) const void CIMValue::get(Array<Sint16>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT16 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT16 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint16Array;     x = *_rep->_u._sint16Array;
 } }
  
 void CIMValue::get(Array<Uint32>& x) const void CIMValue::get(Array<Uint32>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT32 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT32 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint32Array;     x = *_rep->_u._uint32Array;
 } }
  
 void CIMValue::get(Array<Sint32>& x) const void CIMValue::get(Array<Sint32>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT32 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT32 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint32Array;     x = *_rep->_u._sint32Array;
 } }
  
 void CIMValue::get(Array<Uint64>& x) const void CIMValue::get(Array<Uint64>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT64 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT64 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint64Array;     x = *_rep->_u._uint64Array;
 } }
  
 void CIMValue::get(Array<Sint64>& x) const void CIMValue::get(Array<Sint64>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT64 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT64 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint64Array;     x = *_rep->_u._sint64Array;
 } }
  
 void CIMValue::get(Array<Real32>& x) const void CIMValue::get(Array<Real32>& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL32 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_REAL32 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._real32Array;     x = *_rep->_u._real32Array;
 } }
  
 void CIMValue::get(Array<Real64>& x) const void CIMValue::get(Array<Real64>& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL64 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_REAL64 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._real64Array;     x = *_rep->_u._real64Array;
 } }
  
 void CIMValue::get(Array<Char16>& x) const void CIMValue::get(Array<Char16>& x) const
 { {
     if (_rep->_type != CIMTYPE_CHAR16 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_CHAR16 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._char16Array;     x = *_rep->_u._char16Array;
 } }
  
 void CIMValue::get(Array<String>& x) const void CIMValue::get(Array<String>& x) const
 { {
     if (_rep->_type != CIMTYPE_STRING || !_rep->_isArray)     if (_rep->_type != CIMTYPE_STRING || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
     x = *_rep->_u._stringArray;      if (!_rep->_isNull)
           x = _rep->stringArray();
 } }
  
 void CIMValue::get(Array<CIMDateTime>& x) const void CIMValue::get(Array<CIMDateTime>& x) const
 { {
 // ATTN-RK-20020815: Use UninitializedObject exception here if CIMValue is null?  
   
     if (_rep->_type != CIMTYPE_DATETIME || !_rep->_isArray)     if (_rep->_type != CIMTYPE_DATETIME || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._dateTimeArray;     x = *_rep->_u._dateTimeArray;
 } }
  
 void CIMValue::get(Array<CIMObjectPath>& x) const void CIMValue::get(Array<CIMObjectPath>& x) const
 { {
     if (_rep->_type != CIMTYPE_REFERENCE || !_rep->_isArray)     if (_rep->_type != CIMTYPE_REFERENCE || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._referenceArray;     x = *_rep->_u._referenceArray;
 } }
  
   void CIMValue::get(Array<CIMObject>& x) const
   {
       if (_rep->_type != CIMTYPE_OBJECT || !_rep->_isArray)
           throw TypeMismatchException();
   
       if (!_rep->_isNull)
           x = *_rep->_u._objectArray;
   }
   
 Boolean CIMValue::equal(const CIMValue& x) const Boolean CIMValue::equal(const CIMValue& x) const
 { {
     if (!typeCompatible(x))     if (!typeCompatible(x))
Line 1432 
Line 1584 
                     (*x._rep->_u._char16Array);                     (*x._rep->_u._char16Array);
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 return (*_rep->_u._stringArray) ==                  return _rep->stringArray() == x._rep->stringArray();
                     (*x._rep->_u._stringArray);  
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
                 return (*_rep->_u._dateTimeArray) ==                 return (*_rep->_u._dateTimeArray) ==
Line 1442 
Line 1593 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 return (*_rep->_u._referenceArray) ==                 return (*_rep->_u._referenceArray) ==
                     (*x._rep->_u._referenceArray);                     (*x._rep->_u._referenceArray);
   
               case CIMTYPE_OBJECT:
                   return (*_rep->_u._objectArray) ==
                       (*x._rep->_u._objectArray);
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
Line 1487 
Line 1643 
                 return _rep->_u._char16Value == x._rep->_u._char16Value;                 return _rep->_u._char16Value == x._rep->_u._char16Value;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 return String::equal(*_rep->_u._stringValue,                  return String::equal(
                                      *x._rep->_u._stringValue);                      *((String*)_rep->_u._stringValue),
                       *((String*)x._rep->_u._stringValue));
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
                 return *_rep->_u._dateTimeValue == *x._rep->_u._dateTimeValue;                 return *_rep->_u._dateTimeValue == *x._rep->_u._dateTimeValue;
Line 1497 
Line 1654 
                 return *_rep->_u._referenceValue ==                 return *_rep->_u._referenceValue ==
                     *x._rep->_u._referenceValue;                     *x._rep->_u._referenceValue;
  
               case CIMTYPE_OBJECT:
                   return (*_rep->_u._objectValue).identical((*x._rep->_u._objectValue));
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
  
     // Unreachable!     // Unreachable!
     return false;      PEGASUS_UNREACHABLE( return false; )
 } }
  
 String CIMValue::toString() const String CIMValue::toString() const
 { {
     Array<Sint8> out;      Buffer 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.
Line 1525 
Line 1685 
                 for (Uint32 i = 0; i < size; i++)                 for (Uint32 i = 0; i < size; i++)
                 {                 {
                     _toString(out, Boolean(_rep->_u._booleanArray->getData()[i]));                     _toString(out, Boolean(_rep->_u._booleanArray->getData()[i]));
                     out << " ";                      out.append(' ');
                 }                 }
                 break;                 break;
             }             }
Line 1586 
Line 1746 
                 break;                 break;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 _toString(out, _rep->_u._stringArray->getData(),                  _toString(out, _rep->stringArray().getData(),
                                _rep->_u._stringArray->size());                                 _rep->stringArray().size());
                 break;                 break;
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
Line 1600 
Line 1760 
                                _rep->_u._referenceArray->size());                                _rep->_u._referenceArray->size());
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   _toString(out, _rep->_u._objectArray->getData(),
                                  _rep->_u._objectArray->size());
                   break;
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
Line 1657 
Line 1822 
                 break;                 break;
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
                 _toString(out, *_rep->_u._stringValue);                  _toString(out, *((String*)_rep->_u._stringValue));
                 break;                 break;
  
             case CIMTYPE_DATETIME:             case CIMTYPE_DATETIME:
Line 1668 
Line 1833 
                 _toString(out, *_rep->_u._referenceValue);                 _toString(out, *_rep->_u._referenceValue);
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   _toString(out, *_rep->_u._objectValue);
                   break;
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
  
Line 1688 
Line 1857 
     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
   
   void CIMValue::_get(const String*& data, Uint32& size) const
   {
       data = _rep->stringArray().getData();
       size = _rep->stringArray().size();
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.37  
changed lines
  Added in v.1.61

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2