(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.49 and 1.58

version 1.49, 2004/06/03 08:45:20 version 1.58, 2005/06/09 21:13:54
Line 1 
Line 1 
 //%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
Line 30 
Line 34 
 //              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)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 57 
Line 64 
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
 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.
Line 96 
Line 103 
                 &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();
   }
   
   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--)
     {     {
Line 232 
Line 244 
     set(x);     set(x);
 } }
  
   CIMValue::CIMValue(const CIMObject& x)
   {
       _rep = new CIMValueRep();
       set(x);
   }
   
 CIMValue::CIMValue(const Array<Boolean>& x) CIMValue::CIMValue(const Array<Boolean>& x)
 { {
     _rep = new CIMValueRep();     _rep = new CIMValueRep();
Line 322 
Line 340 
     set(x);     set(x);
 } }
  
   CIMValue::CIMValue(const Array<CIMObject>& x)
   {
       _rep = new CIMValueRep();
       set(x);
   }
   
 CIMValue::CIMValue(const CIMValue& x) CIMValue::CIMValue(const CIMValue& x)
 { {
     _rep = new CIMValueRep();     _rep = new CIMValueRep();
Line 430 
Line 454 
                     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:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 500 
Line 540 
                     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:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
Line 573 
Line 625 
                 delete _rep->_u._referenceArray;                 delete _rep->_u._referenceArray;
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   delete _rep->_u._objectArray;
                   break;
   
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 607 
Line 663 
                 delete _rep->_u._referenceValue;                 delete _rep->_u._referenceValue;
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   delete _rep->_u._objectValue;
                   break;
   
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 699 
Line 759 
             return _rep->_u._referenceArray->size();             return _rep->_u._referenceArray->size();
             break;             break;
  
           case CIMTYPE_OBJECT:
               return _rep->_u._objectArray->size();
               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
Line 780 
Line 844 
                 set(Array<CIMObjectPath>(arraySize));                 set(Array<CIMObjectPath>(arraySize));
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   set(Array<CIMObject>(arraySize));
                   break;
   
             default:             default:
                 throw TypeMismatchException();                 throw TypeMismatchException();
         }         }
Line 848 
Line 916 
                 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 TypeMismatchException();                 throw TypeMismatchException();
         }         }
Line 979 
Line 1055 
     _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 1114 
Line 1204 
     _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)
Line 1249 
Line 1362 
         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)
Line 1384 
Line 1506 
         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 1456 
Line 1587 
                 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:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 1511 
Line 1646 
                 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:
                 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.
Line 1614 
Line 1752 
                                _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:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 1682 
Line 1825 
                 _toString(out, *_rep->_u._referenceValue);                 _toString(out, *_rep->_u._referenceValue);
                 break;                 break;
  
               case CIMTYPE_OBJECT:
                   _toString(out, *_rep->_u._objectValue);
                   break;
   
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 1702 
Line 1849 
     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


Legend:
Removed from v.1.49  
changed lines
  Added in v.1.58

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2