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

Diff for /pegasus/src/Pegasus/Common/SCMO.cpp between version 1.2.2.13 and 1.2.2.38

version 1.2.2.13, 2009/08/05 14:08:34 version 1.2.2.38, 2009/10/13 09:36:35
Line 33 
Line 33 
 #include <Pegasus/Common/SCMOClass.h> #include <Pegasus/Common/SCMOClass.h>
 #include <Pegasus/Common/SCMOInstance.h> #include <Pegasus/Common/SCMOInstance.h>
 #include <Pegasus/Common/SCMODump.h> #include <Pegasus/Common/SCMODump.h>
   #include <Pegasus/Common/SCMOClassCache.h>
 #include <Pegasus/Common/CharSet.h> #include <Pegasus/Common/CharSet.h>
 #include <Pegasus/Common/CIMDateTimeRep.h> #include <Pegasus/Common/CIMDateTimeRep.h>
 #include <Pegasus/Common/CIMPropertyRep.h> #include <Pegasus/Common/CIMPropertyRep.h>
 #include <Pegasus/Common/CIMInstanceRep.h> #include <Pegasus/Common/CIMInstanceRep.h>
 #include <Pegasus/Common/CIMObjectPathRep.h> #include <Pegasus/Common/CIMObjectPathRep.h>
   #include <Pegasus/Common/CIMNameCast.h>
 #include <Pegasus/Common/CommonUTF.h> #include <Pegasus/Common/CommonUTF.h>
 #include <Pegasus/Common/StrLit.h> #include <Pegasus/Common/StrLit.h>
 #include <Pegasus/Common/XmlWriter.h> #include <Pegasus/Common/XmlWriter.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/StringConversion.h> #include <Pegasus/Common/StringConversion.h>
   #include <Pegasus/Common/ArrayIterator.h>
   #include <Pegasus/Common/PegasusAssert.h>
   #include <strings.h>
  
 #ifdef PEGASUS_OS_ZOS #ifdef PEGASUS_OS_ZOS
   #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>   #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
 #endif #endif
  
   #ifdef PEGASUS_HAS_ICU
   # include <unicode/platform.h>
   # include <unicode/urename.h>
   # include <unicode/ures.h>
   # include <unicode/ustring.h>
   # include <unicode/uchar.h>
   # include <unicode/ucnv.h>
   #endif
   
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096
Line 60 
Line 74 
  * for a string format specification, the string "(null)" is  * for a string format specification, the string "(null)" is
  * substituted. On other platforms no string "" is substituded.  * substituted. On other platforms no string "" is substituded.
  */  */
 #define NULLSTR(x) ((x) == NULL ? "" : (x))  #define NULLSTR(x) ((x) == 0 ? "" : (x))
   
   #define NEWCIMSTR(ptr,base) \
         ((ptr).length == 0 ?  \
         (String()) :           \
         (String(&(base)[(ptr).start],((ptr).length)-1)))
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static StrLit _qualifierNameStrLit[] =  #define PEGASUS_ARRAY_T SCMOInstance
   # include "ArrayImpl.h"
   #undef PEGASUS_ARRAY_T
   
   
   const StrLit SCMOClass::_qualifierNameStrLit[72] =
 { {
     STRLIT(""),     STRLIT(""),
     STRLIT("ABSTRACT"),     STRLIT("ABSTRACT"),
Line 144 
Line 168 
            (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))            (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))
  
 /***************************************************************************** /*****************************************************************************
    * Internal inline functions.
    *****************************************************************************/
   
   inline SCMOClass* _getSCMOClass(
       const CIMObjectPath& theCIMObj,
       const char* altNS,
       Uint64 altNSlength)
   {
       SCMOClass* theClass=0;
   
       if (theCIMObj.getClassName().isNull())
       {
           return 0;
       }
   
       if (theCIMObj.getNameSpace().isNull())
       {
           // the name space of the object path is empty,
           // use alternative name space.
           CString clsName = theCIMObj.getClassName().getString().getCString();
   
           SCMOClassCache* theCache = SCMOClassCache::getInstance();
           theClass = theCache->getSCMOClass(
               altNS,
               altNSlength,
               (const char*)clsName,
               strlen(clsName));
   
       }
       else
       {
           CString nameSpace = theCIMObj.getNameSpace().getString().getCString();
           CString clsName = theCIMObj.getClassName().getString().getCString();
   
           SCMOClassCache* theCache = SCMOClassCache::getInstance();
           theClass = theCache->getSCMOClass(
               (const char*)nameSpace,
               strlen(nameSpace),
               (const char*)clsName,
               strlen(clsName));
       }
   
       return theClass;
   }
   
   inline void _deleteArrayExtReference(
       SCMBDataPtr& theArray,
       SCMBMgmt_Header** pmem )
   {
       SCMBUnion* ptr;
       // if the array was already set,
       // the previous references has to be deleted
       if(theArray.length != 0)
       {
           Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion));
   
           ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]);
           for (Uint32 i = 0 ; i < oldArraySize ; i++)
           {
               delete ptr[i].extRefPtr;
           }
       }
   }
   
   inline void _copyArrayExtReference(
       SCMBDataPtr& theArray,
       SCMBMgmt_Header** pmem )
   {
       SCMBUnion* ptr;
       // if the array was already set,
       // the previous references has to be deleted
       if(theArray.length != 0)
       {
           Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion));
   
           ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]);
           for (Uint32 i = 0 ; i < oldArraySize ; i++)
           {
               if (ptr[i].extRefPtr != 0)
               {
                   ptr[i].extRefPtr = new SCMOInstance(*ptr[i].extRefPtr);
               }
           }
       }
   }
   
   /*****************************************************************************
  * The SCMOClass methods  * The SCMOClass methods
  *****************************************************************************/  *****************************************************************************/
 SCMOClass::SCMOClass() SCMOClass::SCMOClass()
 { {
     cls.mem = NULL;      cls.mem = 0;
   }
   
   void SCMOClass::_destroyExternalReferences()
   {
       // TODO: Has to be optimized not to loop through all props.
       // Address the property array
       SCMBClassPropertyNode* nodeArray =
           (SCMBClassPropertyNode*)
               &(cls.base[cls.hdr->propertySet.nodeArray.start]);
   
       SCMBValue* theValue;
   
       for (Uint32 i = 0; i < cls.hdr->propertySet.number; i++)
       {
           theValue = &(nodeArray[i].theProperty.defaultValue);
   
           // if not an NULL value !
           if(!theValue->flags.isNull)
           {
               if (theValue->valueType == CIMTYPE_REFERENCE ||
                   theValue->valueType == CIMTYPE_OBJECT ||
                   theValue->valueType == CIMTYPE_INSTANCE )
               {
                   if (theValue->flags.isArray)
                   {
                       _deleteArrayExtReference(
                           theValue->value.arrayValue,
                           &cls.mem);
                   }
                   else
                   {
                       delete theValue->value.extRefPtr;
                   }  // end is Array
               } // end is ext. reference.
           }// end is not null
       }// loop throug all properties
 } }
  
 SCMOClass::SCMOClass(CIMClass& theCIMClass)  inline void SCMOClass::_initSCMOClass()
 { {
     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
         - sizeof(SCMBClass_Main)>0);         - sizeof(SCMBClass_Main)>0);
  
     cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);     cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
     if (cls.base == NULL)      if (cls.base == 0)
     {     {
         // Not enough memory!         // Not enough memory!
         throw PEGASUS_STD(bad_alloc)();         throw PEGASUS_STD(bad_alloc)();
     }     }
  
       memset(cls.base,0,sizeof(SCMBClass_Main));
   
     // initalize eye catcher     // initalize eye catcher
     cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC;     cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC;
     cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;     cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
Line 175 
Line 324 
  
     cls.hdr->refCount=1;     cls.hdr->refCount=1;
  
   }
   
   SCMOClass::SCMOClass(const char* className, const char* nameSpaceName )
   {
       if (0 == className)
       {
           String message("SCMOClass: Class name not set (null pointer)!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       if (0 == nameSpaceName)
       {
           String message("SCMOClass: Name Space not set (null pointer)!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       _initSCMOClass();
   
       _setBinary(className,
                  strlen(className)+1,
                  cls.hdr->className,
                  &cls.mem );
   
       _setBinary(nameSpaceName,
                  strlen(nameSpaceName)+1,
                  cls.hdr->nameSpace,
                  &cls.mem );
   
   }
   
   SCMOClass::SCMOClass(
       const CIMClass& theCIMClass,
       const char* nameSpaceName)
   {
   
       _initSCMOClass();
   
     try     try
     {     {
         _setString(theCIMClass.getSuperClassName().getString(),         _setString(theCIMClass.getSuperClassName().getString(),
Line 191 
Line 377 
     CIMObjectPath theObjectPath=theCIMClass.getPath();     CIMObjectPath theObjectPath=theCIMClass.getPath();
  
     //set name space     //set name space
       if (nameSpaceName)
       {
           _setBinary(nameSpaceName,
                      strlen(nameSpaceName)+1,
                      cls.hdr->nameSpace,
                      &cls.mem );
       }
       else
       {
    _setString(theObjectPath.getNameSpace().getString(),    _setString(theObjectPath.getNameSpace().getString(),
               cls.hdr->nameSpace,               cls.hdr->nameSpace,
               &cls.mem );               &cls.mem );
       }
   
  
     //set class name     //set class name
     _setString(theObjectPath.getClassName().getString(),     _setString(theObjectPath.getClassName().getString(),
                cls.hdr->className,                cls.hdr->className,
                &cls.mem );                &cls.mem );
  
   
     //set class Qualifiers     //set class Qualifiers
     _setClassQualifers(theCIMClass);      _setClassQualifers(theCIMClass._rep->_qualifiers);
  
     //set properties     //set properties
     _setClassProperties(theCIMClass);      _setClassProperties(theCIMClass._rep->_properties);
   
   }
   
   void  SCMOClass::getCIMClass(CIMClass& cimClass) const
   {
       CIMClass newCimClass(
           CIMNameCast(NEWCIMSTR(cls.hdr->className,cls.base)),
           CIMNameCast(NEWCIMSTR(cls.hdr->superClassName,cls.base)));
   
       // set the name space
       newCimClass._rep->_reference._rep->_nameSpace=
           CIMNamespaceNameCast(NEWCIMSTR(cls.hdr->nameSpace,cls.base));
   
       // Add class qualifier if exist
       if (0 != cls.hdr->numberOfQualifiers)
       {
           SCMBQualifier* qualiArray =
               (SCMBQualifier*)&(cls.base[cls.hdr->qualifierArray.start]);
   
           CIMQualifier theCimQualifier;
   
           Uint32 i, k = cls.hdr->numberOfQualifiers;
           for ( i = 0 ; i < k ; i++)
           {
               _getCIMQualifierFromSCMBQualifier(
                   theCimQualifier,
                   qualiArray[i],
                   cls.base);
   
               newCimClass._rep->_qualifiers.addUnchecked(theCimQualifier);
           }
       }
   
       // If properties are in that class
       if (0 != cls.hdr->propertySet.number)
       {
           Uint32 i, k = cls.hdr->propertySet.number;
           for ( i = 0 ; i < k ; i++)
           {
              newCimClass._rep->_properties.append(
                  _getCIMPropertyAtNodeIndex(i));
           }
       }
   
       cimClass = newCimClass;
   }
   
   CIMProperty SCMOClass::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
   {
       CIMValue theCimValue;
       CIMProperty retCimProperty;
   
       SCMBClassPropertyNode& clsProp =
           ((SCMBClassPropertyNode*)
            &(cls.base[cls.hdr->propertySet.nodeArray.start]))[nodeIdx];
   
       // get the default value
       SCMOInstance::_getCIMValueFromSCMBValue(
           theCimValue,
           clsProp.theProperty.defaultValue,
           cls.base);
   
       // have to check if there is the origin class name set.
       // An empty origin class name is differnt then a NULL class name
       if (0 != clsProp.theProperty.originClassName.start)
       {
           retCimProperty = CIMProperty(
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)),
               theCimValue,
               theCimValue.getArraySize(),
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)),
               CIMNameCast(NEWCIMSTR(
                   clsProp.theProperty.originClassName,cls.base)),
               clsProp.theProperty.flags.propagated);
       }
       else
       {
            retCimProperty = CIMProperty(
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)),
               theCimValue,
               theCimValue.getArraySize(),
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)),
               CIMName(),
               clsProp.theProperty.flags.propagated);
       }
  
       SCMBQualifier* qualiArray =
           (SCMBQualifier*)
                &(cls.base[clsProp.theProperty.qualifierArray.start]);
   
       CIMQualifier theCimQualifier;
       Uint32 i, k = clsProp.theProperty.numberOfQualifiers;
       for ( i = 0 ; i < k ; i++)
       {
           _getCIMQualifierFromSCMBQualifier(
               theCimQualifier,
               qualiArray[i],
               cls.base);
   
           retCimProperty._rep->_qualifiers.addUnchecked(theCimQualifier);
       }
   
       return retCimProperty;
   
   }
   
   void SCMOClass::_getCIMQualifierFromSCMBQualifier(
       CIMQualifier& theCimQualifier,
       const SCMBQualifier& scmbQualifier,
       const char* base)
   
   {
   
       CIMName theCimQualiName;
       CIMValue theCimValue;
   
       SCMOInstance::_getCIMValueFromSCMBValue(
           theCimValue,
           scmbQualifier.value,
           base);
   
       if (scmbQualifier.name == QUALNAME_USERDEFINED)
       {
           theCimQualiName = NEWCIMSTR(scmbQualifier.userDefName,base);
       }
       else
       {
           theCimQualiName = String(
               SCMOClass::qualifierNameStrLit(scmbQualifier.name).str,
               SCMOClass::qualifierNameStrLit(scmbQualifier.name).size);
       }
   
       theCimQualifier = CIMQualifier(
           theCimQualiName,
           theCimValue,
           scmbQualifier.flavor,
           scmbQualifier.propagated);
 } }
  
 void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const
Line 294 
Line 623 
  
 } }
  
   
 SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const
 { {
  
Line 351 
Line 679 
  
 } }
  
 void SCMOClass::_setClassProperties(CIMClass& theCIMClass)  void SCMOClass::_setClassProperties(PropertySet& theCIMProperties)
 { {
     Uint32 noProps = theCIMClass.getPropertyCount();      Uint32 noProps = theCIMProperties.size();
     Uint64 start, startKeyIndexList;     Uint64 start, startKeyIndexList;
     Uint32 noKeys = 0;     Uint32 noKeys = 0;
     Boolean isKey = false;     Boolean isKey = false;
Line 381 
Line 709 
         // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values.         // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values.
         _getFreeSpace(cls.hdr->keyPropertyMask,         _getFreeSpace(cls.hdr->keyPropertyMask,
               sizeof(Uint64)*(((noProps-1)/64)+1),               sizeof(Uint64)*(((noProps-1)/64)+1),
               &cls.mem);                &cls.mem,true);
  
         // allocate property array and save the start index of the array.         // allocate property array and save the start index of the array.
         start = _getFreeSpace(cls.hdr->propertySet.nodeArray,         start = _getFreeSpace(cls.hdr->propertySet.nodeArray,
                       sizeof(SCMBClassPropertyNode)*noProps,                       sizeof(SCMBClassPropertyNode)*noProps,
                       &cls.mem);                        &cls.mem,true);
  
         // clear the hash table         // clear the hash table
         memset(cls.hdr->propertySet.hashTable,         memset(cls.hdr->propertySet.hashTable,
                0,                0,
                PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32));                PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32));
  
         _clearKeyPropertyMask();  
  
         for (Uint32 i = 0; i < noProps; i++)         for (Uint32 i = 0; i < noProps; i++)
         {         {
  
             _setProperty(start,&isKey ,theCIMClass.getProperty(i));              _setProperty(start,&isKey ,theCIMProperties[i]);
             if(isKey)             if(isKey)
             {             {
                 // if the property is a key                 // if the property is a key
Line 436 
Line 763 
             for (Uint32 i = 0 ; i < noKeys; i++)             for (Uint32 i = 0 ; i < noKeys; i++)
             {             {
  
                 _setClassKeyBinding(start,theCIMClass.getProperty(keyIndex[i]));                  _setClassKeyBinding(start,theCIMProperties[keyIndex[i]]);
                 // Adjust ordered set management structures.                 // Adjust ordered set management structures.
                 _insertKeyBindingIntoOrderedSet(start,i);                 _insertKeyBindingIntoOrderedSet(start,i);
  
Line 592 
Line 919 
     // calculate the new hash tag     // calculate the new hash tag
     scmoKeyBindNode->nameHashTag =     scmoKeyBindNode->nameHashTag =
         _generateSCMOStringTag(scmoKeyBindNode->name,cls.base);         _generateSCMOStringTag(scmoKeyBindNode->name,cls.base);
     scmoKeyBindNode->type = _cimTypeToKeyBindType(propRep->_value.getType());      scmoKeyBindNode->type = propRep->_value.getType();
     scmoKeyBindNode->hasNext=false;     scmoKeyBindNode->hasNext=false;
     scmoKeyBindNode->nextNode=0;     scmoKeyBindNode->nextNode=0;
  
 } }
  
 void SCMOClass::_clearKeyPropertyMask()  
 {  
   
     Uint64 *keyMask;  
   
     // Calculate the real pointer to the Uint64 array  
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];  
   
     // the number of Uint64 in the key mask is :  
     // Decrease the number of properties by 1  
     // since the array is starting at index 0!  
     // Divide with the number of bits in a Uint64.  
     // e.g. number of Properties = 68  
     // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64  
   
     memset(keyMask,0, sizeof(Uint64)*(((cls.hdr->propertySet.number-1)/64)+1));  
   
 }  
   
 void SCMOClass::_setPropertyAsKeyInMask(Uint32 i) void SCMOClass::_setPropertyAsKeyInMask(Uint32 i)
 { {
     Uint64 *keyMask;     Uint64 *keyMask;
Line 631 
Line 939 
     Uint64 filter = ( (Uint64)1 << (i%64));     Uint64 filter = ( (Uint64)1 << (i%64));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];      keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
  
     keyMask[idx] = keyMask[idx] | filter ;     keyMask[idx] = keyMask[idx] | filter ;
 } }
Line 651 
Line 959 
     Uint64 filter = ( (Uint64)1 << (i%64));     Uint64 filter = ( (Uint64)1 << (i%64));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];      keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
  
     return keyMask[idx] & filter ;     return keyMask[idx] & filter ;
  
Line 752 
Line 1060 
  
     return isKey;     return isKey;
 } }
 void SCMOClass::_setClassQualifers(CIMClass& theCIMClass)  
   void SCMOClass::_setClassQualifers(const CIMQualifierList& theQualifierList)
 { {
  
     Uint32 noQuali = theCIMClass.getQualifierCount();      Uint32 noQuali = theQualifierList.getCount();
     Uint64 start;     Uint64 start;
  
     cls.hdr->numberOfQualifiers = noQuali;     cls.hdr->numberOfQualifiers = noQuali;
Line 768 
Line 1077 
                       &cls.mem);                       &cls.mem);
         for (Uint32 i = 0; i < noQuali; i++)         for (Uint32 i = 0; i < noQuali; i++)
         {         {
             _setQualifier(start,theCIMClass.getQualifier(i));              _setQualifier(start,theQualifierList.getQualifier(i));
             start = start + sizeof(SCMBQualifier);             start = start + sizeof(SCMBQualifier);
  
         }         }
Line 779 
Line 1088 
         cls.hdr->qualifierArray.start=0;         cls.hdr->qualifierArray.start=0;
         cls.hdr->qualifierArray.length=0;         cls.hdr->qualifierArray.length=0;
     }     }
   
   
 } }
  
 QualifierNameEnum SCMOClass::_setQualifier( QualifierNameEnum SCMOClass::_setQualifier(
Line 812 
Line 1119 
     return name;     return name;
 } }
  
 void SCMOClass::_setValue(Uint64 start, const CIMValue& theCIMValue)  void SCMOClass::_setValue(
       Uint64 start,
       const CIMValue& theCIMValue)
 { {
     Uint64 valueStart;     Uint64 valueStart;
  
Line 823 
Line 1132 
     scmoValue->valueArraySize = 0;     scmoValue->valueArraySize = 0;
     scmoValue->flags.isNull = rep->isNull;     scmoValue->flags.isNull = rep->isNull;
     scmoValue->flags.isArray = rep->isArray;     scmoValue->flags.isArray = rep->isArray;
     // Only initalized by for completeness.  
     scmoValue->flags.isSet = false;     scmoValue->flags.isSet = false;
  
     if (rep->isNull)     if (rep->isNull)
Line 835 
Line 1143 
  
     if (scmoValue->flags.isArray)     if (scmoValue->flags.isArray)
     {     {
         SCMOInstance::_setArrayValue(          SCMOInstance::_setUnionArrayValue(
             valueStart,             valueStart,
             &cls.mem,             &cls.mem,
             rep->type,             rep->type,
             // Is set to the number of array members by the function.             // Is set to the number of array members by the function.
             scmoValue->valueArraySize,             scmoValue->valueArraySize,
               cls.hdr->nameSpace.start,
               cls.hdr->nameSpace.length,
             rep->u);             rep->u);
     }     }
     else     else
Line 849 
Line 1159 
             valueStart,             valueStart,
             &cls.mem,             &cls.mem,
             rep->type,             rep->type,
               cls.hdr->nameSpace.start,
               cls.hdr->nameSpace.length,
             rep->u);             rep->u);
     }     }
 } }
Line 867 
Line 1179 
     // list.     // list.
     for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++)     for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++)
     {     {
         if (_qualifierNameStrLit[i].size == length)          if (qualifierNameStrLit(i).size == length)
         {         {
             // TBD: Make it more efficent...             // TBD: Make it more efficent...
             if(String::equalNoCase(             if(String::equalNoCase(
                 theCIMName.getString(),                 theCIMName.getString(),
                 _qualifierNameStrLit[i].str))                  qualifierNameStrLit(i).str))
             {             {
                 return (QualifierNameEnum)i;                 return (QualifierNameEnum)i;
             }             }
Line 897 
Line 1209 
        len));        len));
 } }
  
 inline SCMO_RC SCMOClass::_isNodeSameType(  SCMO_RC SCMOClass::_isNodeSameType(
     Uint32 node,     Uint32 node,
     CIMType type,     CIMType type,
     Boolean isArray) const      Boolean isArray,
       CIMType& realType) const
 { {
   
     SCMBClassPropertyNode* nodeArray =     SCMBClassPropertyNode* nodeArray =
         (SCMBClassPropertyNode*)         (SCMBClassPropertyNode*)
             &(cls.base[cls.hdr->propertySet.nodeArray.start]);             &(cls.base[cls.hdr->propertySet.nodeArray.start]);
  
       // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       realType = nodeArray[node].theProperty.defaultValue.valueType;
  
     if(nodeArray[node].theProperty.defaultValue.valueType != type)     if(nodeArray[node].theProperty.defaultValue.valueType != type)
     {     {
           // Accept an property of type instance also
           // for an CIMTYPE_OBJECT property.
           if (!(type == CIMTYPE_INSTANCE &&
                 nodeArray[node].theProperty.defaultValue.valueType
                 == CIMTYPE_OBJECT))
           {
         return SCMO_WRONG_TYPE;         return SCMO_WRONG_TYPE;
     }     }
       }
  
     if (isArray)     if (isArray)
     {     {
Line 933 
Line 1257 
     return SCMO_OK;     return SCMO_OK;
  
 } }
   
 /***************************************************************************** /*****************************************************************************
  * The SCMOInstance methods  * The SCMOInstance methods
  *****************************************************************************/  *****************************************************************************/
  
 SCMOInstance::SCMOInstance() SCMOInstance::SCMOInstance()
 { {
     inst.base = NULL;      inst.base = 0;
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass) SCMOInstance::SCMOInstance(SCMOClass baseClass)
 { {
     _initSCMOInstance(new SCMOClass(baseClass),false,false);      _initSCMOInstance(new SCMOClass(baseClass));
 } }
  
 SCMOInstance::SCMOInstance( SCMOInstance::SCMOInstance(
Line 954 
Line 1279 
     const char** propertyList)     const char** propertyList)
 { {
  
     _initSCMOInstance(      _initSCMOInstance(new SCMOClass(baseClass));
         new SCMOClass(baseClass),  
         includeQualifiers,      inst.hdr->flags.includeQualifiers=includeQualifiers;
         includeClassOrigin);      inst.hdr->flags.includeClassOrigin=includeClassOrigin;
  
     setPropertyFilter(propertyList);     setPropertyFilter(propertyList);
  
Line 965 
Line 1290 
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj) SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj)
 { {
     _initSCMOInstance(new SCMOClass(baseClass),false,false);      _initSCMOInstance(new SCMOClass(baseClass));
  
     _setCIMObjectPath(cimObj);     _setCIMObjectPath(cimObj);
   
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance) SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance)
 { {
  
     CIMPropertyRep* propRep;      _initSCMOInstance(new SCMOClass(baseClass));
     Uint32 propNode;  
     Uint64 valueStart;  
     SCMO_RC rc;  
  
     CIMInstanceRep* instRep = cimInstance._rep;      _setCIMInstance(cimInstance);
     Boolean hasQualifiers = (instRep->_qualifiers.getCount()>0);  
     Boolean hasClassOrigin = false;  
  
     _initSCMOInstance(new SCMOClass(baseClass),hasQualifiers,hasClassOrigin);  }
  
     _setCIMObjectPath(instRep->_reference);  
  
     // Copy all properties  void SCMOInstance::_copyExternalReferences()
     for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++)  
     {     {
         propRep = instRep->_properties[i]._rep;      // TODO: Has to be optimized not to loop through all props.
         // if not already detected that qualifiers are specified and      // create a pointer to keybinding node array of the class.
         // there are qualifers at that property.      Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
         if (!hasQualifiers && propRep->getQualifierCount() > 0)      SCMBKeyBindingNode* theClassKeyBindNodeArray =
           (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
   
       // create a pointer to instanc key binding array.
       SCMBKeyBindingValue* theInstanceKeyBindingNodeArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
       for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++)
         {         {
             includeQualifiers();          if (theInstanceKeyBindingNodeArray[i].isSet)
         }  
         // if not already detected that class origins are specified and  
         // there is a class origin specified at that property.  
         if (!hasClassOrigin && !propRep->_classOrigin.isNull())  
         {         {
             includeClassOrigins();              // only references can be a key binding.
               if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)
               {
                   // Use the copy constructro to ref. count the reference.
                   // These objects are handeld by the SCMOInstance it sef.
                   // No one can modify these instances.
                   theInstanceKeyBindingNodeArray[i].data.extRefPtr =
                       new SCMOInstance(
                           *theInstanceKeyBindingNodeArray[i].data.extRefPtr);
               }
         }         }
       }// for all key bindings defined in the class
  
         // get the property node index for the property      // Are there user defined key bindings ?
         rc = inst.hdr->theClass->_getProperyNodeIndex(      if (0 != inst.hdr->numberUserKeyBindindigs)
             propNode,      {
             (const char*)propRep->_name.getString().getCString());          SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
  
         if (rc != SCMO_OK)          for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++)
         {         {
             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY,              if (theUserDefKBElement->value.isSet)
                propRep->_name.getString());  
         }  
         rc = inst.hdr->theClass->_isNodeSameType(  
                  propNode,  
                  propRep->_value._rep->type,  
                  propRep->_value._rep->isArray);  
         if (rc == SCMO_OK)  
         {         {
             _setCIMValueAtNodeIndex(propNode, propRep->_value._rep);                  // only references can be a key binding.
         }                  if (theUserDefKBElement->type == CIMTYPE_REFERENCE)
         else  
         {         {
             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH,                      // Use the copy constructro to ref. count the reference.
                propRep->_name.getString());                      // These objects are handeld by the SCMOInstance it sef.
                       // No one can modify these instances.
                       theUserDefKBElement->value.data.extRefPtr =
                           new SCMOInstance(
                               *theUserDefKBElement->value.data.extRefPtr);
         }         }
     }     }
  
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
 } }
  
 void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj)      SCMBValue* theInstPropArray =
 {          (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
     CIMObjectPathRep* objRep = cimObj._rep;  
     SCMO_RC rc;  
   
     // For better usability define pointers to SCMO Class data structures.  
     SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;  
     char* clsbase = inst.hdr->theClass->cls.base;  
   
     CString className = objRep->_className.getString().getCString();  
     CString nameSpace = objRep->_nameSpace.getString().getCString();  
  
     // Is the instance from the same class and name space ?      for (Uint32 i = 0; i < inst.hdr->numberProperties; i++)
     if (!(_equalNoCaseUTF8Strings(  
              clshdr->className,  
              clsbase,  
              (const char*)className,  
              strlen(className)) &&  
           _equalNoCaseUTF8Strings(  
              clshdr->nameSpace,  
              clsbase,  
              (const char*)nameSpace,  
              strlen(nameSpace)))  
         )  
     {     {
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,          // was the property set by the provider ?
            objRep->_className.getString());          if(theInstPropArray[i].flags.isSet)
           {
               // is the property type reference,instance or object?
               if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE ||
                   theInstPropArray[i].valueType == CIMTYPE_OBJECT ||
                   theInstPropArray[i].valueType == CIMTYPE_INSTANCE )
               {
                   if (theInstPropArray[i].flags.isArray)
                   {
                       _copyArrayExtReference(
                           theInstPropArray[i].value.arrayValue,
                           &inst.mem);
     }     }
                   else
     //set host name  
     _setString(objRep->_host,inst.hdr->hostName,&inst.mem );  
   
     if (inst.hdr->numberKeyBindings < objRep->_keyBindings.size())  
     {     {
         String message("CIMObjectPath has more keybindings "                      theInstPropArray[i].value.extRefPtr =
                        "than the associatied class key propertties.");                          new SCMOInstance(*theInstPropArray[i].value.extRefPtr);
         throw CIMException(CIM_ERR_FAILED, message);                  } // end is arry
               } // end is reference
           }// end is set
       } // for all properties.
     }     }
  
     for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++)  void SCMOInstance::_destroyExternalReferences()
     {     {
       // TODO: Has to be optimized not to loop through all props.
       // create a pointer to keybinding node array of the class.
       Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
       SCMBKeyBindingNode* theClassKeyBindNodeArray =
           (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
  
         rc = setKeyBinding(      // create a pointer to instanc key binding array.
             (const char*)      SCMBKeyBindingValue* theInstanceKeyBindingNodeArray =
                     objRep->_keyBindings[i].getName().getString().getCString(),          (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
             objRep->_keyBindings[i].getType(),  
             (const char*) objRep->_keyBindings[i].getValue().getCString());  
  
         if (rc != SCMO_OK)      for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++)
         {         {
             switch (rc)          if (theInstanceKeyBindingNodeArray[i].isSet)
             {             {
             case SCMO_NOT_FOUND:              // only references can be a key binding
               if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)
                 {                 {
                     String message("CIMObjectPath key binding ");                 delete theInstanceKeyBindingNodeArray[i].data.extRefPtr;
                     message.append(  
                         objRep->_keyBindings[i].getName().getString());  
                     message.append(" not found.");  
                     throw CIMException(CIM_ERR_FAILED, message);  
                 }                 }
             default:  
                 {  
                     String message("CIMObjectPath key binding ");  
                     message.append(  
                         objRep->_keyBindings[i].getName().getString());  
                     message.append(" does not match class definition!");  
                     throw CIMException(CIM_ERR_FAILED, message);  
                 }                 }
       }// for all key bindings
   
       // Are there user defined key bindings ?
       if (0 != inst.hdr->numberUserKeyBindindigs)
       {
           SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
           for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++)
           {
               if (theUserDefKBElement->value.isSet)
               {
                   // only references can be a key binding.
                   if (theUserDefKBElement->type == CIMTYPE_REFERENCE)
                   {
                       delete theUserDefKBElement->value.data.extRefPtr;
             }             }
         }         }
   
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
     }     }
  
       SCMBValue* theInstPropArray =
           (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
       for (Uint32 i = 0; i < inst.hdr->numberProperties; i++)
       {
           // was the property set by the provider ?
           if(theInstPropArray[i].flags.isSet)
           {
               // is the property type reference,instance or object?
               if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE ||
                   theInstPropArray[i].valueType == CIMTYPE_OBJECT ||
                   theInstPropArray[i].valueType == CIMTYPE_INSTANCE )
               {
                   if (theInstPropArray[i].flags.isArray)
                   {
                       _deleteArrayExtReference(
                           theInstPropArray[i].value.arrayValue,
                           &inst.mem);
 } }
 void SCMOInstance::_setCIMValueAtNodeIndex(Uint32 node, CIMValueRep* valRep)                  else
 { {
     SCMBValue* theInstPropNodeArray =                      delete theInstPropArray[i].value.extRefPtr;
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];                  } // end is arry
               } // end is reference
           }// end is set
       } // for all properties.
   }
  
   SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const
   {
  
     SCMBValue& theInstProp = theInstPropNodeArray[node];      SCMO_RC rc = SCMO_OK;
       Uint32 noProps;
       CIMObjectPath objPath;
  
     theInstProp.valueType=valRep->type;      // For better usability define pointers to SCMO Class data structures.
     theInstProp.flags.isNull=valRep->isNull;      SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
     theInstProp.flags.isArray=valRep->isArray;      char* clsbase = inst.hdr->theClass->cls.base;
     theInstProp.flags.isSet=true;  
     theInstProp.valueArraySize=0;  
  
     if (valRep->isNull)      getCIMObjectPath(objPath);
   
       CIMInstance newInstance;
       newInstance._rep = new CIMInstanceRep(objPath);
   
       if (inst.hdr->flags.includeQualifiers)
     {     {
         return;          SCMBQualifier* qualiArray =
               (SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]);
   
   
           CIMQualifier theCimQualifier;
           Uint32 i, k = clshdr->numberOfQualifiers;
   
           for ( i = 0 ; i < k ; i++)
           {
               SCMOClass::_getCIMQualifierFromSCMBQualifier(
                   theCimQualifier,
                   qualiArray[i],
                   clsbase);
   
               newInstance._rep->_qualifiers.addUnchecked(theCimQualifier);
           }
     }     }
  
     Uint64 start = ((const char*)&(theInstProp.value))-inst.base;      if (inst.hdr->flags.isFiltered)
       {
           // Get absolut pointer to property filter index map of the instance
           Uint32* propertyFilterIndexMap =
               (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
  
     if (valRep->isArray)          for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++)
     {     {
         _setArrayValue(              // Get absolut pointer to property filter index map
             start,              // of the instance get the real node index of the property.
             &inst.mem,              CIMProperty theProperty=_getCIMPropertyAtNodeIndex(
             valRep->type,                  propertyFilterIndexMap[i]);
             // Is set to the number of array members by the function.  
             theInstProp.valueArraySize,              newInstance._rep->_properties.append(theProperty);
             valRep->u);          }
   
     }     }
     else     else
     {     {
         _setUnionValue(start,&inst.mem,valRep->type,valRep->u);          for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
           {
               SCMBValue* theInstPropArray =
                   (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
               // was the property set by the provider ?
               if(theInstPropArray[i].flags.isSet)
               {
                   // no filtering. Counter is node index
                   CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);
   
                   newInstance._rep->_properties.append(theProperty);
     }     }
 } }
  
       }
  
 Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const      cimInstance = newInstance;
 {  
     return inst.base == theInstance.inst.base;      return rc;
 } }
  
 const char* SCMOInstance::getHostName() const  void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const
 { {
   return _getCharString(inst.hdr->hostName,inst.base);  
       CIMObjectPath newObjectPath;
   
       // For better usability define pointers to SCMO Class data structures.
       SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
       char* clsbase = inst.hdr->theClass->cls.base;
   
       // Address the class keybinding information
       SCMBKeyBindingNode* scmoClassArray =
           (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
   
       // Address the instance keybinding information
       SCMBKeyBindingValue* scmoInstArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
       Uint32 numberKeyBindings = inst.hdr->numberKeyBindings;
   
       CIMValue theKeyBindingValue;
   
       for (Uint32 i = 0; i < numberKeyBindings; i ++)
       {
           if (scmoInstArray[i].isSet)
           {
               _getCIMValueFromSCMBUnion(
                   theKeyBindingValue,
                   scmoClassArray[i].type,
                   false, // can never be a null value
                   false, // can never be an array
                   0,
                   scmoInstArray[i].data,
                   inst.base);
               newObjectPath._rep->_keyBindings.append(
                   CIMKeyBinding(
                       CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)),
                       theKeyBindingValue
                       ));
           }
 } }
  
 void SCMOInstance::buildKeyBindingsFromProperties()      // Are there user defined key bindings ?
       if (0 != inst.hdr->numberUserKeyBindindigs)
 { {
           SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
  
     Uint32* theClassKeyPropList =          for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++)
         (Uint32*) &((inst.hdr->theClass->cls.base)          {
                           [(inst.hdr->theClass->cls.hdr->keyIndexList.start)]);              if (theUserDefKBElement->value.isSet)
               {
                   _getCIMValueFromSCMBUnion(
                       theKeyBindingValue,
                       theUserDefKBElement->type,
                       false, // can never be a null value
                       false, // can never be an array
                       0,
                       theUserDefKBElement->value.data,
                       inst.base);
  
     SCMBDataPtr* theInstKeyBindNodeArray;                  newObjectPath._rep->_keyBindings.append(
     SCMBValue* theInstPropNodeArray;                      CIMKeyBinding(
                           CIMNameCast(
                               NEWCIMSTR(theUserDefKBElement->name,inst.base)),
                       theKeyBindingValue));
               }
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
       }
  
     Uint32 propNode;      newObjectPath._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base);
       // Use name space and class name of the instance
       newObjectPath._rep->_nameSpace =
           CIMNamespaceNameCast(NEWCIMSTR(inst.hdr->instNameSpace,inst.base));
       newObjectPath._rep->_className=
           CIMNameCast(NEWCIMSTR(inst.hdr->instClassName,inst.base));
  
     for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)      cimObj = newObjectPath;
   }
   
   CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
     {     {
         // the instance pointers has to be reinitialized eache time,      CIMValue theValue;
         // because in _setKeyBindingFromSCMBUnion()      CIMProperty retProperty;
         // a reallocation can take place.  
         theInstKeyBindNodeArray =  
             (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];  
  
         theInstPropNodeArray =      // For better usability define pointers to SCMO Class data structures.
             (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];      SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
       char* clsbase = inst.hdr->theClass->cls.base;
  
         // If the keybinding is not set.  
         if (theInstKeyBindNodeArray[i].start == 0)  
         {  
             // get the node index for this key binding form class  
             propNode = theClassKeyPropList[i];  
  
             // if property was not set by the provider or it is null.      SCMBClassPropertyNode& clsProp =
             if (!theInstPropNodeArray[propNode].flags.isSet ||          ((SCMBClassPropertyNode*)
                  theInstPropNodeArray[propNode].flags.isNull)           &(clsbase[clshdr->propertySet.nodeArray.start]))[nodeIdx];
   
       SCMBValue& instValue =
           ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx];
   
       _getCIMValueFromSCMBValue(theValue,instValue,inst.base);
   
   
       if (inst.hdr->flags.includeClassOrigin)
             {             {
                 const char * propName =          retProperty = CIMProperty(
                     inst.hdr->theClass->_getPropertyNameAtNode(propNode);              CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)),
                 throw NoSuchProperty(String(propName));              theValue,
               theValue.getArraySize(),
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)),
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.originClassName,clsbase)),
               clsProp.theProperty.flags.propagated);
       }
       else
       {
            retProperty = CIMProperty(
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)),
               theValue,
               theValue.getArraySize(),
               CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)),
               CIMName(),
               clsProp.theProperty.flags.propagated);
             }             }
  
             _setKeyBindingFromSCMBUnion(      if (inst.hdr->flags.includeQualifiers)
                 theInstPropNodeArray[propNode].valueType,      {
                 theInstPropNodeArray[propNode].value,          SCMBQualifier* qualiArray =
                 theInstKeyBindNodeArray[i]);              (SCMBQualifier*)
                    &(clsbase[clsProp.theProperty.qualifierArray.start]);
   
           CIMQualifier theCimQualifier;
   
           Uint32 i, k = clsProp.theProperty.numberOfQualifiers;
           for ( i = 0 ; i < k ; i++)
           {
               SCMOClass::_getCIMQualifierFromSCMBQualifier(
                   theCimQualifier,
                   qualiArray[i],
                   clsbase);
   
               retProperty._rep->_qualifiers.addUnchecked(theCimQualifier);
         }         }
     }     }
   
       return retProperty;
 } }
  
 void SCMOInstance::_setKeyBindingFromSCMBUnion(  void SCMOInstance::_getCIMValueFromSCMBUnion(
     CIMType type,      CIMValue& cimV,
     SCMBUnion& u,      const CIMType type,
     SCMBDataPtr& keyNode)      const Boolean isNull,
       const Boolean isArray,
       const Uint32 arraySize,
       const SCMBUnion& scmbUn,
       const char * base)
   {
   
       const SCMBUnion* pscmbArrayUn = 0;
   
       if (isNull)
       {
           cimV.setNullValue(type,isArray,arraySize);
           return;
       }
   
       if (isArray)
 { {
     Uint32 outputLength=0;          pscmbArrayUn =(SCMBUnion*)&(base[scmbUn.arrayValue.start]);
     const char * output;      }
  
     switch (type)     switch (type)
     {     {
   
     case CIMTYPE_UINT8:     case CIMTYPE_UINT8:
         {         {
             char buffer[22];              if (isArray)
             output = Uint8ToString(buffer, u._uint8Value, outputLength);              {
             // including trailing '\0' !                  Array<Uint8> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.u8);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.u8);
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:     case CIMTYPE_UINT16:
         {         {
             char buffer[22];              if (isArray)
             output = Uint16ToString(buffer, u._uint16Value, outputLength);              {
             // including trailing '\0' !                  Array<Uint16> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.u16);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.u16);
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
         {         {
             char buffer[22];              if (isArray)
             output = Uint32ToString(buffer, u._uint32Value, outputLength);              {
             // including trailing '\0' !                  Array<Uint32> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.u32);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.u32);
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:     case CIMTYPE_UINT64:
         {         {
             char buffer[22];              if (isArray)
             output = Uint64ToString(buffer, u._uint64Value, outputLength);              {
             // including trailing '\0' !                  Array<Uint64> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.u64);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.u64);
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             char buffer[22];              if (isArray)
             output = Sint8ToString(buffer, u._sint8Value, outputLength);              {
             // including trailing '\0' !                  Array<Sint8> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.s8);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.s8);
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:     case CIMTYPE_SINT16:
         {         {
             char buffer[22];              if (isArray)
             output = Sint16ToString(buffer, u._sint16Value, outputLength);              {
             // including trailing '\0' !                  Array<Sint16> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.s16);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.s16);
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:     case CIMTYPE_SINT32:
         {         {
             char buffer[22];              if (isArray)
             output = Sint32ToString(buffer, u._sint32Value, outputLength);              {
             // including trailing '\0' !                  Array<Sint32> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.s32);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.s32);
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:     case CIMTYPE_SINT64:
         {         {
             char buffer[22];              if (isArray)
             output = Sint64ToString(buffer, u._sint64Value, outputLength);              {
             // including trailing '\0' !                  Array<Sint64> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.s64);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.s64);
               }
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             char buffer[128];              if (isArray)
             output = Real32ToString(buffer, u._real32Value, outputLength);              {
             // including trailing '\0' !                  Array<Real32> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.r32);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.r32);
               }
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             char buffer[128];              if (isArray)
             output = Real64ToString(buffer, u._real64Value, outputLength);              {
             // including trailing '\0' !                  Array<Real64> x;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
             break;                  {
                       x.append(pscmbArrayUn[i].simple.val.r64);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.r64);
               }
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             Buffer out;              if (isArray)
             _toString(out,u._char16Value);              {
             // including trailing '\0' !                  Array<Char16> x;
             _setBinary(out.getData(),out.size()+1,keyNode,&inst.mem);                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.c16);
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(scmbUn.simple.val.c16);
               }
             break;             break;
         }         }
  
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
         {         {
             if (u._booleanValue)              if (isArray)
               {
                   Array<Boolean> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
             {             {
                 _setBinary("TRUE",strlen("TRUE")+1,keyNode,&inst.mem);                      x.append(pscmbArrayUn[i].simple.val.bin);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 _setBinary("FALSE",strlen("FLASE")+1,keyNode,&inst.mem);                  cimV.set(scmbUn.simple.val.bin);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             _setBinary(              if (isArray)
                 &inst.base[u._stringValue.start],              {
                 u._stringValue.length,  
                 keyNode,  
                 &inst.mem);  
             break;  
         }  
  
     case CIMTYPE_DATETIME:                  Array<String> x;
   
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
         {         {
             _setString(                      x.append(NEWCIMSTR(pscmbArrayUn[i].stringValue,base));
                 CIMDateTime(&u._dateTimeValue).toString(),                  }
                 keyNode,                  cimV.set(x);
                 &inst.mem);              }
               else
               {
                   cimV.set(NEWCIMSTR(scmbUn.stringValue,base));
               }
             break;             break;
         }         }
  
         case CIMTYPE_REFERENCE:      case CIMTYPE_DATETIME:
           {
               if (isArray)
               {
                   Array<CIMDateTime> x;
   
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(CIMDateTime(&(pscmbArrayUn[i].dateTimeValue)));
                   }
                   cimV.set(x);
               }
               else
               {
                   cimV.set(CIMDateTime(&scmbUn.dateTimeValue));
               }
               break;
   
           }
   
       case CIMTYPE_REFERENCE:
           {
               CIMObjectPath theObjPath;
   
               if(isArray)
               {
                   Array<CIMObjectPath> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       if (0 != pscmbArrayUn[i].extRefPtr)
                       {
                           pscmbArrayUn[i].extRefPtr->getCIMObjectPath(theObjPath);
                           x.append(theObjPath);
                       }
                       else
                       {
                           // set an empty object
                           x.append(CIMObjectPath());
                       }
                   }
                   cimV.set(x);
               }
               else
               {
   
                   if (0 != scmbUn.extRefPtr)
                   {
                       scmbUn.extRefPtr->getCIMObjectPath(theObjPath);
                       cimV.set(theObjPath);
                   }
                   else
                   {
                       cimV.set(CIMObjectPath());
                   }
               }
               break;
           }
       case CIMTYPE_OBJECT:
           {
               CIMInstance theInstance;
               CIMClass theClass;
   
               if(isArray)
               {
                   Array<CIMObject> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       if (0 != pscmbArrayUn[i].extRefPtr)
                       {
                           // check if the Object is an emedded instance or class
                           if(pscmbArrayUn[i].extRefPtr->
                                  inst.hdr->flags.isClassOnly)
                           {
                               pscmbArrayUn[i].extRefPtr->
                                   inst.hdr->theClass->getCIMClass(theClass);
                               x.append(CIMObject(theClass));
                           }
                           else
                           {
                               pscmbArrayUn[i].extRefPtr->
                                   getCIMInstance(theInstance);
                               x.append(CIMObject(theInstance));
                           }
                       }
                       else
                       {
                           // set an empty object
                           x.append(CIMObject());
                       }
                   }
                   cimV.set(x);
               }
               else
               {
   
                   if (0 != scmbUn.extRefPtr)
                   {
                       // check if the Object is an emedded instance or class
                       if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly)
                       {
                           scmbUn.extRefPtr->
                               inst.hdr->theClass->getCIMClass(theClass);
                           cimV.set(CIMObject(theClass));
                       }
                       else
                       {
                           scmbUn.extRefPtr->getCIMInstance(theInstance);
                           cimV.set(CIMObject(theInstance));
                       }
                   }
                   else
                   {
                       cimV.set(CIMObject());
                   }
               }
               break;
           }
   
       case CIMTYPE_INSTANCE:
           {
               CIMInstance theInstance;
   
               if(isArray)
               {
                   Array<CIMInstance> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       if (0 != pscmbArrayUn[i].extRefPtr)
                       {
                           pscmbArrayUn[i].extRefPtr->
                               getCIMInstance(theInstance);
                           x.append(theInstance);
                       }
                       else
                       {
                           // set an empty object
                           x.append(CIMInstance());
                       }
                   }
                   cimV.set(x);
               }
               else
               {
   
                   if (0 != scmbUn.extRefPtr)
                   {
                       scmbUn.extRefPtr->getCIMInstance(theInstance);
                       cimV.set(theInstance);
                   }
                   else
                   {
                       cimV.set(CIMInstance());
                   }
               }
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
   }
   
   void SCMOInstance::_getCIMValueFromSCMBValue(
       CIMValue& cimV,
       const SCMBValue& scmbV,
       const char * base)
   {
       SCMOInstance::_getCIMValueFromSCMBUnion(
           cimV,
           scmbV.valueType,
           scmbV.flags.isNull,
           scmbV.flags.isArray,
           scmbV.valueArraySize,
           scmbV.value,
           base);
   }
   
   
   void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj)
   {
       CIMObjectPathRep* objRep = cimObj._rep;
       SCMO_RC rc;
   
       CString className = objRep->_className.getString().getCString();
   
       // Is the instance from the same class ?
       if (!(_equalNoCaseUTF8Strings(
                inst.hdr->instClassName,
                inst.base,
                (const char*)className,
                strlen(className))))
       {
           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,
              objRep->_className.getString());
       }
   
       //set host name
       _setString(objRep->_host,inst.hdr->hostName,&inst.mem );
   
       for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++)
       {
           String key = objRep->_keyBindings[i].getValue();
           rc = _setKeyBindingFromString(
               (const char*)
                   objRep->_keyBindings[i].getName().getString().getCString(),
               _CIMTypeFromKeyBindingType(
                   (const char*)key.getCString(),
                   objRep->_keyBindings[i].getType()),
               key);
   
           if (rc != SCMO_OK)
           {
                  String message("Can not set CIMObjectPath key binding:'");
                  message.append(
                      objRep->_keyBindings[i].getName().getString());
                  message.append("'");
                  throw CIMException(CIM_ERR_FAILED, message);
           }
       }
   
   }
   void SCMOInstance::_setCIMValueAtNodeIndex(
       Uint32 node,
       CIMValueRep* valRep,
       CIMType realType)
   {
       SCMBValue* theInstPropNodeArray =
           (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
   
       SCMBValue& theInstProp = theInstPropNodeArray[node];
   
       theInstProp.valueType=realType;
       theInstProp.flags.isNull=valRep->isNull;
       theInstProp.flags.isArray=valRep->isArray;
       theInstProp.flags.isSet=true;
       theInstProp.valueArraySize=0;
   
       if (valRep->isNull)
       {
           return;
       }
   
       Uint64 start = ((const char*)&(theInstProp.value))-inst.base;
   
       if (valRep->isArray)
       {
           _setUnionArrayValue(
               start,
               &inst.mem,
               realType,
               // Is set to the number of array members by the function.
               theInstProp.valueArraySize,
               inst.hdr->instNameSpace.start,
               inst.hdr->instNameSpace.length,
               valRep->u);
       }
       else
       {
           _setUnionValue(
               start,
               &inst.mem,
               realType,
               inst.hdr->instNameSpace.start,
               inst.hdr->instNameSpace.length,
               valRep->u);
       }
   }
   
   
   Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const
   {
       return inst.base == theInstance.inst.base;
   }
   
   void SCMOInstance::setHostName(const char* hostName)
   {
       Uint32 len;
   
       if (hostName!=0)
       {
   
           len = strlen((const char*)hostName);
           if(len != 0)
           {
   
               // copy including trailing '\0'
               _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
               return;
           }
   
       }
       inst.hdr->hostName.start=0;
       inst.hdr->hostName.length=0;
   }
   
   const char* SCMOInstance::getHostName() const
   {
       return _getCharString(inst.hdr->hostName,inst.base);
   }
   
   const char* SCMOInstance::getHostName_l(Uint64& length) const
   {
       length = inst.hdr->hostName.length;
       return _getCharString(inst.hdr->hostName,inst.base);
   }
   
   void SCMOInstance::setClassName(const char* className)
   {
       Uint32 len;
   
       if (className!=0)
       {
   
           len = strlen((const char*)className);
           if(len != 0)
           {
   
               // copy including trailing '\0'
               _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
               return;
           }
   
       }
   
       inst.hdr->instClassName.start=0;
       inst.hdr->instClassName.length=0;
   
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
   
   }
   
   const char* SCMOInstance::getClassName() const
   {
       return _getCharString(inst.hdr->instClassName,inst.base);
   }
   
   const char* SCMOInstance::getClassName_l(Uint64 & length) const
   {
       length = inst.hdr->instClassName.length;
       return _getCharString(inst.hdr->instClassName,inst.base);
   }
   
   void SCMOInstance::setNameSpace(const char* nameSpace)
   {
       Uint32 len;
   
       if (nameSpace!=0)
       {
   
           len = strlen((const char*)nameSpace);
           if(len != 0)
           {
   
               // copy including trailing '\0'
               _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
               return;
           }
   
       }
   
       inst.hdr->instNameSpace.start=0;
       inst.hdr->instNameSpace.length=0;
   
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
   
   }
   
   const char* SCMOInstance::getNameSpace() const
   {
       return _getCharString(inst.hdr->instNameSpace,inst.base);
   }
   
   const char* SCMOInstance::getNameSpace_l(Uint64 & length) const
   {
       length = inst.hdr->instNameSpace.length;
       return _getCharString(inst.hdr->instNameSpace,inst.base);
   }
   
   void SCMOInstance::buildKeyBindingsFromProperties()
   {
   
       Uint32* theClassKeyPropList =
           (Uint32*) &((inst.hdr->theClass->cls.base)
                             [(inst.hdr->theClass->cls.hdr->keyIndexList.start)]);
   
       SCMBKeyBindingValue* theKeyBindValueArray;
       SCMBValue* theInstPropNodeArray;
   
       Uint32 propNode;
   
       for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)
       {
           // the instance pointers has to be reinitialized each time,
           // because in _setKeyBindingFromSCMBUnion()
           // a reallocation can take place.
           theKeyBindValueArray =
              (SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start];
   
           theInstPropNodeArray =
               (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
           // If the keybinding is not set.
           if (!theKeyBindValueArray[i].isSet)
           {
               // get the node index for this key binding form class
               propNode = theClassKeyPropList[i];
   
               // if property was not set by the provider or it is null.
               if (!theInstPropNodeArray[propNode].flags.isSet ||
                    theInstPropNodeArray[propNode].flags.isNull)
               {
                   const char * propName =
                       inst.hdr->theClass->_getPropertyNameAtNode(propNode);
                   throw NoSuchProperty(String(propName));
               }
   
               _setKeyBindingFromSCMBUnion(
                   theInstPropNodeArray[propNode].valueType,
                   theInstPropNodeArray[propNode].value,
                   inst.base,
                   theKeyBindValueArray[i]);
           }
       }
   }
   
   void SCMOInstance::_setKeyBindingFromSCMBUnion(
       CIMType type,
       const SCMBUnion& u,
       const char * uBase,
       SCMBKeyBindingValue& keyData)
   {
       switch (type)
       {
       case CIMTYPE_UINT8:
       case CIMTYPE_UINT16:
       case CIMTYPE_UINT32:
       case CIMTYPE_UINT64:
       case CIMTYPE_SINT8:
       case CIMTYPE_SINT16:
       case CIMTYPE_SINT32:
       case CIMTYPE_SINT64:
       case CIMTYPE_REAL32:
       case CIMTYPE_REAL64:
       case CIMTYPE_CHAR16:
       case CIMTYPE_BOOLEAN:
       case CIMTYPE_DATETIME:
           {
               memcpy(&keyData.data,&u,sizeof(SCMBUnion));
               keyData.isSet=true;
               break;
           }
       case CIMTYPE_STRING:
           {
               keyData.isSet=true;
               _setBinary(
                   &uBase[u.stringValue.start],
                   u.stringValue.length,
                   keyData.data.stringValue,
                   &inst.mem);
               break;
           }
       case CIMTYPE_REFERENCE:
           {
               if(0 != keyData.data.extRefPtr)
               {
                   delete keyData.data.extRefPtr;
               }
   
               if(u.extRefPtr)
               {
                   keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr);
               }
               else
               {
                   keyData.data.extRefPtr=0;
               }
               keyData.isSet=true;
               break;
           }
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
           {
               // From PEP 194: EmbeddedObjects cannot be keys.
               throw TypeMismatchException();
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
   }
   
   void SCMOInstance::_initSCMOInstance(SCMOClass* pClass)
   {
       PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
           - sizeof(SCMBInstance_Main)>0);
   
   
       inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
       if (inst.base == 0)
       {
           // Not enough memory!
           throw PEGASUS_STD(bad_alloc)();
       }
   
       memset(inst.base,0,sizeof(SCMBInstance_Main));
   
       // initalize eye catcher
       inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;
       inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
       // The # of bytes free
       inst.hdr->header.freeBytes=
           SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);
       // Index to the start of the free space in this instance
       inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);
   
       inst.hdr->refCount=1;
   
       //Assign the SCMBClass structure this instance based on.
       inst.hdr->theClass = pClass;
   
       // Copy name space name and class name of the class
       _setBinary(
           _getCharString(inst.hdr->theClass->cls.hdr->className,
                          inst.hdr->theClass->cls.base),
           inst.hdr->theClass->cls.hdr->className.length,
           inst.hdr->instClassName,
           &inst.mem);
   
       _setBinary(
           _getCharString(inst.hdr->theClass->cls.hdr->nameSpace,
                          inst.hdr->theClass->cls.base),
           inst.hdr->theClass->cls.hdr->nameSpace.length,
           inst.hdr->instNameSpace,
           &inst.mem);
   
       // Number of key bindings
       inst.hdr->numberKeyBindings =
           inst.hdr->theClass->cls.hdr->keyBindingSet.number;
   
       // Number of properties
       inst.hdr->numberProperties =
           inst.hdr->theClass->cls.hdr->propertySet.number;
   
       // Allocate the SCMOInstanceKeyBindingArray
       _getFreeSpace(
             inst.hdr->keyBindingArray,
             sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
             &inst.mem,
             true);
   
       // Allocate the SCMBInstancePropertyArray
       _getFreeSpace(
           inst.hdr->propertyArray,
           sizeof(SCMBValue)*inst.hdr->numberProperties,
           &inst.mem,
           true);
   
   }
   
   void SCMOInstance::_setCIMInstance(const CIMInstance& cimInstance)
   {
       CIMPropertyRep* propRep;
       Uint32 propNode;
       Uint64 valueStart;
       SCMO_RC rc;
       CIMType realType;
   
       CIMInstanceRep* instRep = cimInstance._rep;
   
       // Test if the instance has qualifiers.
       // The instance level qualifiers are stored on the associated SCMOClass.
       inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0);
   
       _setCIMObjectPath(instRep->_reference);
   
       // Copy all properties
       for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++)
       {
           propRep = instRep->_properties[i]._rep;
           // if not already detected that qualifiers are specified and
           // there are qualifers at that property.
           if (!inst.hdr->flags.includeQualifiers &&
               propRep->getQualifierCount() > 0)
           {
               includeQualifiers();
           }
           // if not already detected that class origins are specified and
           // there is a class origin specified at that property.
           if (!inst.hdr->flags.includeClassOrigin &&
               !propRep->_classOrigin.isNull())
           {
               includeClassOrigins();
           }
   
           // get the property node index for the property
           rc = inst.hdr->theClass->_getProperyNodeIndex(
               propNode,
               (const char*)propRep->_name.getString().getCString());
   
           if (rc != SCMO_OK)
           {
               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY,
                  propRep->_name.getString());
           }
           // The type stored in the class information is set on realType.
           // It must be used in further calls to guaranty consistence.
           rc = inst.hdr->theClass->_isNodeSameType(
                    propNode,
                    propRep->_value._rep->type,
                    propRep->_value._rep->isArray,
                    realType);
           if (rc == SCMO_OK)
           {
               _setCIMValueAtNodeIndex(propNode, propRep->_value._rep,realType);
           }
           else
           {
               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH,
                  propRep->_name.getString());
           }
       }
   }
   
   SCMO_RC SCMOInstance::getProperty(
       const char* name,
       CIMType& type,
       const SCMBUnion** pOutVal,
       Boolean& isArray,
       Uint32& size ) const
   {
       Uint32 node;
       const char* pname;
       SCMO_RC rc = SCMO_OK;
   
       *pOutVal = 0;
       isArray = false;
       size = 0;
   
       rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       // is filtering on ?
       if (inst.hdr->flags.isFiltered)
       {
           // Is the property NOT in the property filter ?
           if(!_isPropertyInFilter(node))
           {
               // The named propery is not part of this instance
               // due to filtering.
               return SCMO_NOT_FOUND;
           }
       }
   
       return  _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);
   }
   
   SCMO_RC SCMOInstance::getPropertyAt(
           Uint32 idx,
           const char** pname,
           CIMType& type,
           const SCMBUnion** pOutVal,
           Boolean& isArray,
           Uint32& size ) const
   {
       *pname = 0;
       *pOutVal = 0;
       isArray = false;
       size = 0;
       Uint32 node;
   
       // is filtering on ?
       if (inst.hdr->flags.isFiltered)
       {
           // check the number of properties part of the filter
           if (idx >= inst.hdr->filterProperties)
           {
               return SCMO_INDEX_OUT_OF_BOUND;
           }
   
           // Get absolut pointer to property filter index map of the instance
           Uint32* propertyFilterIndexMap =
           (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
   
           // get the real node index of the property.
           node = propertyFilterIndexMap[idx];
       }
       else
       {
           // the index is used as node index.
           node = idx;
           if (node >= inst.hdr->numberProperties)
           {
               return SCMO_INDEX_OUT_OF_BOUND;
           }
       }
   
       return  _getPropertyAtNodeIndex(node,pname,type,pOutVal,isArray,size);
   }
   
   SCMO_RC SCMOInstance::getPropertyAt(
       Uint32 pos,
       SCMBValue** value,
       const char ** valueBase,
       SCMBClassProperty ** propDef) const
   {
       Uint32 node;
       // is filtering on ?
       if (inst.hdr->flags.isFiltered)
       {
           // check the number of properties part of the filter
           if (pos >= inst.hdr->filterProperties)
           {
               return SCMO_INDEX_OUT_OF_BOUND;
           }
   
           // Get absolut pointer to property filter index map of the instance
           Uint32* propertyFilterIndexMap =
           (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
   
           // get the real node index of the property.
           node = propertyFilterIndexMap[pos];
       }
       else
       {
           // the index is used as node index.
           node = pos;
           if (node >= inst.hdr->numberProperties)
           {
               return SCMO_INDEX_OUT_OF_BOUND;
           }
       }
   
       SCMBValue* theInstPropNodeArray =
           (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
       // create a pointer to property node array of the class.
       Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;
       SCMBClassPropertyNode* theClassPropNodeArray =
           (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];
   
       // return the absolute pointer to the property definition
       *propDef= &(theClassPropNodeArray[node].theProperty);
   
       // need check if property set or not, if not set use the default value
       if (theInstPropNodeArray[node].flags.isSet)
       {
           // return the absolute pointer to the property value in the instance
           *value = &(theInstPropNodeArray[node]);
           *valueBase = inst.base;
       }
       else
       {
           // return the absolute pointer to
           *value = &(theClassPropNodeArray[node].theProperty.defaultValue);
           *valueBase = inst.hdr->theClass->cls.base;
       }
   
       return SCMO_OK;
   }
   
   
   SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
   {
       SCMO_RC rc;
       if(name==0)
       {
           return SCMO_INVALID_PARAMETER;
       }
   
       rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
   
       return rc;
   
   }
   
   SCMO_RC SCMOInstance::setPropertyWithOrigin(
       const char* name,
       CIMType type,
       const SCMBUnion* pInVal,
       Boolean isArray,
       Uint32 size,
       const char* origin)
   {
       Uint32 node;
       SCMO_RC rc;
       CIMType realType;
   
       rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       // Is the traget type OK ?
       // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray,realType);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       // is filtering on ?
       if (inst.hdr->flags.isFiltered)
       {
           // Is the property NOT in the property filter ?
           if(!_isPropertyInFilter(node))
           {
               // The named propery is not part of this instance
               // due to filtering.
               return SCMO_NOT_FOUND;
           }
       }
   
       // check class origin if set.
       if (origin!= 0)
       {
           if(!inst.hdr->theClass->_isSamePropOrigin(node,origin))
           {
               return SCMO_NOT_SAME_ORIGIN;
           }
       }
   
   
       _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
   
       return SCMO_OK;
   }
   
    SCMO_RC SCMOInstance::setPropertyWithNodeIndex(
        Uint32 node,
        CIMType type,
        const SCMBUnion* pInVal,
        Boolean isArray,
        Uint32 size)
    {
        SCMO_RC rc;
        CIMType realType;
   
        if (node >= inst.hdr->numberProperties)
        {
            return SCMO_INDEX_OUT_OF_BOUND;
        }
   
        // is filtering on ?
        if (inst.hdr->flags.isFiltered)
        {
            // Is the property NOT in the property filter ?
            if(!_isPropertyInFilter(node))
            {
                // The proptery of the is not set due to filtering.
                return SCMO_OK;
            }
        }
   
        // Is the traget type OK ?
        // The type stored in the class information is set on realType.
        // It must be used in further calls to guaranty consistence.
        rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray,realType);
        if (rc != SCMO_OK)
        {
            return rc;
        }
   
        _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
   
        return SCMO_OK;
    }
   
   void SCMOInstance::_setPropertyAtNodeIndex(
       Uint32 node,
       CIMType type,
       const SCMBUnion* pInVal,
       Boolean isArray,
       Uint32 size)
   {
       SCMBValue* theInstPropNodeArray =
           (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
   
       theInstPropNodeArray[node].flags.isSet=true;
       theInstPropNodeArray[node].valueType=type;
       theInstPropNodeArray[node].flags.isArray=isArray;
       if (isArray)
       {
           theInstPropNodeArray[node].valueArraySize=size;
       }
   
       if (pInVal==0)
       {
           theInstPropNodeArray[node].flags.isNull=true;
       }
       else
       {
           _setSCMBUnion(
               pInVal,
               type,
               isArray,
               size,
               theInstPropNodeArray[node].value);
       }
   }
   
   void SCMOInstance::_setSCMBUnion(
       const SCMBUnion* pInVal,
       CIMType type,
       Boolean isArray,
       Uint32 size,
       SCMBUnion & u)
   {
   
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
       case CIMTYPE_UINT8:
       case CIMTYPE_SINT8:
       case CIMTYPE_UINT16:
       case CIMTYPE_SINT16:
       case CIMTYPE_UINT32:
       case CIMTYPE_SINT32:
       case CIMTYPE_UINT64:
       case CIMTYPE_SINT64:
       case CIMTYPE_REAL32:
       case CIMTYPE_REAL64:
       case CIMTYPE_CHAR16:
       case CIMTYPE_DATETIME:
           {
               if (isArray)
               {
                   _setBinary(pInVal,size*sizeof(SCMBUnion),
                              u.arrayValue,
                              &inst.mem );
               }
               else
               {
                   memcpy(&u,pInVal,sizeof(SCMBUnion));
               }
               break;
           }
       case CIMTYPE_STRING:
           {
               if (isArray)
               {
                   SCMBUnion* ptr;
                   Uint64 startPtr;
   
                   startPtr = _getFreeSpace(
                       u.arrayValue,
                       size*sizeof(SCMBUnion),
                       &inst.mem,true);
   
                   for (Uint32 i = 0; i < size; i++)
                   {
                       ptr = (SCMBUnion*)&(inst.base[startPtr]);
                       // Copy the sting including the trailing '\0'
                       _setBinary(
                           pInVal[i].extString.pchar,
                           pInVal[i].extString.length+1,
                           ptr[i].stringValue,
                           &inst.mem );
                   }
               }
               else
               {
                   // Copy the sting including the trailing '\0'
                   _setBinary(
                       pInVal->extString.pchar,
                       pInVal->extString.length+1,
                       u.stringValue,
                       &inst.mem );
               }
               break;
           }
   
       case CIMTYPE_REFERENCE:
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
           {
               if(isArray)
               {
                   SCMBUnion* ptr;
                   Uint64 startPtr;
   
                   // if the array was previously set, delete the references !
                   _deleteArrayExtReference(u.arrayValue,&inst.mem);
   
                   // get new array
                   startPtr = _getFreeSpace(
                       u.arrayValue,
                       size*sizeof(SCMBUnion),
                       &inst.mem,false);
   
                   ptr = (SCMBUnion*)&(inst.base[startPtr]);
   
                   for (Uint32 i = 0 ; i < size ; i++)
                   {
                       if(pInVal[i].extRefPtr)
                       {
                           ptr[i].extRefPtr=
                               new SCMOInstance(*(pInVal[i].extRefPtr));
                       }
                       else
                       {
                           ptr[i].extRefPtr = 0;
                       }
                   }
   
               }
               else
               {
                   if(0 != u.extRefPtr)
                   {
                       delete u.extRefPtr;
                   }
   
                   if(pInVal->extRefPtr)
                   {
                       u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr));
                   }
                   else
                   {
                       u.extRefPtr = 0;
                   }
               }
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
   }
   
   void SCMOInstance::_setUnionArrayValue(
       Uint64 start,
       SCMBMgmt_Header** pmem,
       CIMType type,
       Uint32& n,
       Uint64 startNS,
       Uint64 lenNS,
       Union& u)
   {
       SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
       SCMBUnion* ptargetUnion;
       Uint64 arrayStart;
       Uint32 loop;
   
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
           {
               Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Boolean> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.bin  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT8:
           {
               Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Uint8> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u8  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT8:
           {
               Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Sint8> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s8  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT16:
           {
               Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Uint16> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u16  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT16:
           {
               Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Sint16> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s16  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT32:
           {
               Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Uint32> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u32  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT32:
           {
               Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Sint32> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s32  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT64:
           {
               Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Uint64> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u64  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT64:
           {
               Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Sint64> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s64  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_REAL32:
           {
               Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Real32> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.r32  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_REAL64:
           {
               Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Real64> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.r64  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_CHAR16:
           {
               Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem,
                   true);
   
               ConstArrayIterator<Char16> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.c16  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_STRING:
           {
               Array<String> *x = reinterpret_cast<Array<String>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<String> iterator(*x);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   // the pointer has to be set eache loop,
                   // because a reallocation may take place.
                   ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
                   _setString( iterator[i],ptargetUnion[i].stringValue, pmem );
               }
   
               break;
           }
   
       case CIMTYPE_DATETIME:
           {
               Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMDateTime> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   memcpy(
                       &(ptargetUnion[i].dateTimeValue),
                       iterator[i]._rep,
                       sizeof(SCMBDateTime));
               }
               break;
           }
   
       case CIMTYPE_REFERENCE:
           {
               Array<CIMObjectPath> *x =
                   reinterpret_cast<Array<CIMObjectPath>*>(&u);
   
               // if the array was previously set, delete the references !
               _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
   
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMObjectPath> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               SCMOClass* theRefClass;
   
               for (Uint32 i = 0; i < loop ; i++)
               {
   
                   theRefClass = _getSCMOClass(
                       iterator[i],
                       &(((const char*)*pmem)[startNS]),
                       lenNS);
   
                   if (theRefClass != 0)
                   {
                       ptargetUnion[i].extRefPtr =
                           new SCMOInstance(*theRefClass,iterator[i]);
                   } else
                   {
                       //There is no reference class for the object path
                       ptargetUnion[i].extRefPtr = 0;
                   }
               }
   
               break;
           }
       case CIMTYPE_OBJECT:
           {
               Array<CIMObject> *x =
                   reinterpret_cast<Array<CIMObject>*>(&u);
   
               // if the array was previously set, delete the references !
               _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
   
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMObject> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               SCMOClass* theRefClass;
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   if (iterator[i].isUninitialized())
                   {
                       // the Object was empty.
                       ptargetUnion[i].extRefPtr = 0;
                   }
                   else
                   {
                       if (iterator[i].isClass())
                       {
                           CIMClass theClass(iterator[i]);
                           ptargetUnion[i].extRefPtr = new SCMOInstance(theClass);
                           // marke as class only !
                           ptargetUnion[i].extRefPtr->
                               inst.hdr->flags.isClassOnly=true;
                       }
                       else
                       {
                           CIMInstance theInst(iterator[i]);
                           theRefClass = _getSCMOClass(
                               theInst.getPath(),
                               &(((const char*)*pmem)[startNS]),
                               lenNS);
   
                           if (theRefClass != 0)
                           {
                               ptargetUnion[i].extRefPtr =
                                   new SCMOInstance(*theRefClass,theInst);
                           } else
                           {
                               //There is no reference class for the object path
                               ptargetUnion[i].extRefPtr = 0;
                           }
   
                       }
                   }
               }
  
             break;             break;
           }
       case CIMTYPE_INSTANCE:
           {
               Array<CIMInstance> *x =
                   reinterpret_cast<Array<CIMInstance>*>(&u);
   
               // if the array was previously set, delete the references !
               _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
   
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMInstance> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               SCMOClass* theRefClass;
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   if (iterator[i].isUninitialized())
                   {
                       // the Instance was empty.
                       ptargetUnion[i].extRefPtr = 0;
                   }
                   else
                   {
                       theRefClass = _getSCMOClass(
                           iterator[i].getPath(),
                           &(((const char*)*pmem)[startNS]),
                           lenNS);
   
  
         case CIMTYPE_OBJECT:                      if (theRefClass != 0)
                       {
                           ptargetUnion[i].extRefPtr =
                               new SCMOInstance(*theRefClass,iterator[i]);
                       } else
                       {
                           //There is no reference class for the object path
                           ptargetUnion[i].extRefPtr = 0;
                       }
                   }
               }
  
             break;             break;
         case CIMTYPE_INSTANCE:          }
       default:
           {
               PEGASUS_ASSERT(false);
             break;             break;
     }     }
       }
   }
  
  
   void SCMOInstance::_setUnionValue(
       Uint64 start,
       SCMBMgmt_Header** pmem,
       CIMType type,
       Uint64 startNS,
       Uint64 lenNS,
       Union& u)
   {
       SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
  
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
           {
               scmoUnion->simple.val.bin = u._booleanValue;
               scmoUnion->simple.hasValue=true;
               break;
 } }
  
 void SCMOInstance::setHostName(const char* hostName)      case CIMTYPE_UINT8:
 { {
     Uint32 len;              scmoUnion->simple.val.u8 = u._uint8Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
  
     if (hostName!=NULL)      case CIMTYPE_SINT8:
     {     {
               scmoUnion->simple.val.s8 = u._sint8Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
  
         len = strlen((const char*)hostName);      case CIMTYPE_UINT16:
         if(len != 0)  
         {         {
               scmoUnion->simple.val.u16 = u._uint16Value;
             // copy including trailing '\0'              scmoUnion->simple.hasValue=true;
             _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);              break;
             return;  
         }         }
  
     }      case CIMTYPE_SINT16:
     inst.hdr->hostName.start=0;          {
     inst.hdr->hostName.length=0;              scmoUnion->simple.val.s16 = u._sint16Value;
               scmoUnion->simple.hasValue=true;
               break;
 } }
  
 const char* SCMOInstance::getClassName() const      case CIMTYPE_UINT32:
 { {
     return _getCharString(              scmoUnion->simple.val.u32 = u._uint32Value;
         inst.hdr->theClass->cls.hdr->className,              scmoUnion->simple.hasValue=true;
         inst.hdr->theClass->cls.base);              break;
 } }
  
 const char* SCMOInstance::getNameSpace() const      case CIMTYPE_SINT32:
 { {
     return _getCharString(              scmoUnion->simple.val.s32 = u._sint32Value;
         inst.hdr->theClass->cls.hdr->nameSpace,              scmoUnion->simple.hasValue=true;
         inst.hdr->theClass->cls.base);              break;
 } }
  
 void SCMOInstance::_initSCMOInstance(      case CIMTYPE_UINT64:
     SCMOClass* pClass,  
     Boolean inclQual,  
     Boolean inclOrigin)  
 { {
     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE              scmoUnion->simple.val.u64 = u._uint64Value;
         - sizeof(SCMBInstance_Main)>0);              scmoUnion->simple.hasValue=true;
               break;
           }
  
     inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);      case CIMTYPE_SINT64:
     if (inst.base == NULL)  
     {     {
         // Not enough memory!              scmoUnion->simple.val.s64 = u._sint64Value;
         throw PEGASUS_STD(bad_alloc)();              scmoUnion->simple.hasValue=true;
               break;
     }     }
  
     // initalize eye catcher      case CIMTYPE_REAL32:
     inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;          {
     inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;              scmoUnion->simple.val.r32 = u._real32Value;
     // The # of bytes free              scmoUnion->simple.hasValue=true;
     inst.hdr->header.freeBytes=              break;
         SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);          }
     // Index to the start of the free space in this instance  
     inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);  
   
     inst.hdr->refCount=1;  
   
     //Assign the SCMBClass structure this instance based on.  
     inst.hdr->theClass = pClass;  
  
     // Init flags      case CIMTYPE_REAL64:
     inst.hdr->flags.includeQualifiers=inclQual;          {
     inst.hdr->flags.includeClassOrigin=inclOrigin;              scmoUnion->simple.val.r64 = u._real64Value;
     inst.hdr->flags.isFiltered=false;              scmoUnion->simple.hasValue=true;
               break;
           }
  
     inst.hdr->hostName.start=0;      case CIMTYPE_CHAR16:
     inst.hdr->hostName.length=0;          {
               scmoUnion->simple.val.c16 = u._char16Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
  
     // Number of key bindings      case CIMTYPE_STRING:
     inst.hdr->numberKeyBindings =          {
         inst.hdr->theClass->cls.hdr->keyBindingSet.number;              _setString(*((String*)((void*)&u)),
                          scmoUnion->stringValue,
                          pmem );
               break;
           }
  
     // Number of properties      case CIMTYPE_DATETIME:
     inst.hdr->numberProperties =          {
         inst.hdr->theClass->cls.hdr->propertySet.number;              memcpy(
                   &scmoUnion->dateTimeValue,
                   (*((CIMDateTime*)((void*)&u)))._rep,
                   sizeof(SCMBDateTime));
               break;
           }
  
     // Allocate the SCMOInstanceKeyBindingArray      case CIMTYPE_REFERENCE:
     _getFreeSpace(          {
           inst.hdr->keyBindingArray,              if (0 != scmoUnion->extRefPtr)
           sizeof(SCMBDataPtr)*inst.hdr->numberKeyBindings,              {
           &inst.mem,                  delete scmoUnion->extRefPtr;
           true);                  scmoUnion->extRefPtr = 0;
               }
  
     // Allocate the SCMBInstancePropertyArray              if (0 == u._referenceValue)
     _getFreeSpace(              {
         inst.hdr->propertyArray,                scmoUnion->extRefPtr=0;
         sizeof(SCMBValue)*inst.hdr->numberProperties,                return;
         &inst.mem,              }
         true);  
  
     inst.hdr->propertyFilter.start=0;              CIMObjectPath* theCIMObj =
     inst.hdr->propertyFilter.length=0;                  (CIMObjectPath*)((void*)&u._referenceValue);
     inst.hdr->propertyFilterIndexMap.start=0;  
     inst.hdr->propertyFilterIndexMap.length=0;  
  
               SCMOClass* theRefClass = _getSCMOClass(
                   *theCIMObj,
                   &(((const char*)*pmem)[startNS]),
                   lenNS);
  
               if (theRefClass != 0)
               {
                   scmoUnion->extRefPtr =
                       new SCMOInstance(*theRefClass,*theCIMObj);
               } else
               {
                   //There is no reference class for the object path
                   scmoUnion->extRefPtr = 0;
               }
               break;
           }
       case CIMTYPE_OBJECT:
           {
               if (0 != scmoUnion->extRefPtr)
               {
                   delete scmoUnion->extRefPtr;
                   scmoUnion->extRefPtr = 0;
 } }
  
 SCMO_RC SCMOInstance::getProperty(              if (0 == u._referenceValue)
     const char* name,  
     CIMType& type,  
     const void** pvalue,  
     Boolean& isArray,  
     Uint32& size ) const  
 { {
     Uint32 node;                scmoUnion->extRefPtr=0;
     const char* pname;                return;
     SCMO_RC rc = SCMO_OK;              }
  
     *pvalue = NULL;              CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue);
     isArray = false;              SCMOClass* theRefClass;
     size = 0;  
  
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);              if (theCIMObject->isUninitialized())
     if (rc != SCMO_OK)  
     {     {
         return rc;                  // the Object was empty.
                   scmoUnion->extRefPtr = 0;
     }     }
               else
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {     {
         // Is the property NOT in the property filter ?                  if (theCIMObject->isClass())
         if(!_isPropertyInFilter(node))  
         {         {
             // The named propery is not part of this instance                      CIMClass theClass(*theCIMObject);
             // due to filtering.                      scmoUnion->extRefPtr = new SCMOInstance(theClass);
             return SCMO_NOT_FOUND;                      // marke as class only !
         }                      scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true;
     }     }
                   else
                   {
                       CIMInstance theInst(*theCIMObject);
                       theRefClass = _getSCMOClass(
                           theInst.getPath(),
                           &(((const char*)*pmem)[startNS]),
                           lenNS);
  
     return  _getPropertyAtNodeIndex(node,&pname,type,pvalue,isArray,size);                      if (theRefClass != 0)
                       {
                           scmoUnion->extRefPtr =
                               new SCMOInstance(*theRefClass,theInst);
                       } else
                       {
                           //There is no reference class for the object path
                           scmoUnion->extRefPtr = 0;
 } }
  
 SCMO_RC SCMOInstance::getPropertyAt(                  }
         Uint32 idx,              }
         const char** pname,              break;
         CIMType& type,          }
         const void** pvalue,      case CIMTYPE_INSTANCE:
         Boolean& isArray,  
         Uint32& size ) const  
 { {
     *pname = NULL;              if (0 != scmoUnion->extRefPtr)
     *pvalue = NULL;  
     isArray = false;  
     size = 0;  
     Uint32 node;  
   
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {     {
         // check the number of properties part of the filter                  delete scmoUnion->extRefPtr;
         if (idx >= inst.hdr->filterProperties)                  scmoUnion->extRefPtr = 0;
               }
   
               if (0 == u._referenceValue)
         {         {
             return SCMO_INDEX_OUT_OF_BOUND;                scmoUnion->extRefPtr=0;
                 return;
         }         }
  
         // Get absolut pointer to property filter index map of the instance              CIMInstance* theCIMInst =
         Uint32* propertyFilterIndexMap =                  (CIMInstance*)((void*)&u._instanceValue);
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
  
         // get the real node index of the property.              if (theCIMInst->isUninitialized())
         node = propertyFilterIndexMap[idx];              {
                   // the Instance was empty.
                   scmoUnion->extRefPtr = 0;
     }     }
     else     else
     {     {
         // the index is used as node index.                  SCMOClass* theRefClass = _getSCMOClass(
         node = idx;                      theCIMInst->getPath(),
         if (node >= inst.hdr->numberProperties)                      &(((const char*)*pmem)[startNS]),
                       lenNS);
                   if (theRefClass != 0)
         {         {
             return SCMO_INDEX_OUT_OF_BOUND;                      scmoUnion->extRefPtr =
                           new SCMOInstance(*theRefClass,*theCIMInst);
                   } else
                   {
                       //There is no reference class for the object path
                       scmoUnion->extRefPtr = 0;
         }         }
     }     }
               break;
     return  _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size);  
 } }
       default:
 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const  
 {  
     SCMO_RC rc;  
     if(name==NULL)  
     {     {
         return SCMO_INVALID_PARAMETER;              PEGASUS_ASSERT(false);
               break;
           }
     }     }
   
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);  
   
     return rc;  
   
 } }
 SCMO_RC SCMOInstance::setPropertyWithOrigin(  
     const char* name,  
     CIMType type,  
     void* value,  
     Boolean isArray,  
     Uint32 size,  
     const char* origin)  
 {  
     Uint32 node;  
     SCMO_RC rc;  
  
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);  SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(
     if (rc != SCMO_OK)          Uint32 node,
           const char** pname,
           CIMType& type,
           const SCMBUnion** pvalue,
           Boolean& isArray,
           Uint32& size ) const
     {     {
         return rc;      SCMBValue* theInstPropNodeArray =
     }          (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
       // create a pointer to property node array of the class.
       Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;
       SCMBClassPropertyNode* theClassPropNodeArray =
           (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];
   
       // the property name is always from the class.
       // return the absolut pointer to the property name,
       // the caller has to copy the name!
       *pname=_getCharString(
           theClassPropNodeArray[node].theProperty.name,
           inst.hdr->theClass->cls.base);
  
     // Is the traget type OK ?      // the property was set by the provider.
     rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);      if (theInstPropNodeArray[node].flags.isSet)
     if (rc != SCMO_OK)  
     {     {
         return rc;  
     }  
  
     // is filtering on ?          type = theInstPropNodeArray[node].valueType;
     if (inst.hdr->flags.isFiltered)          isArray = theInstPropNodeArray[node].flags.isArray;
     {          if (isArray)
         // Is the property NOT in the property filter ?  
         if(!_isPropertyInFilter(node))  
         {         {
             // The named propery is not part of this instance              size = theInstPropNodeArray[node].valueArraySize;
             // due to filtering.  
             return SCMO_NOT_FOUND;  
         }  
     }     }
  
     // check class origin if set.          if (theInstPropNodeArray[node].flags.isNull)
     if (origin!= NULL)  
     {  
         if(!inst.hdr->theClass->_isSamePropOrigin(node,origin))  
         {         {
             return SCMO_NOT_SAME_ORIGIN;              return SCMO_NULL_VALUE;
         }  
     }     }
  
           // calculate the relative index for the value.
           Uint64 start =
               (const char*)&(theInstPropNodeArray[node].value) -
               inst.base;
  
     _setPropertyAtNodeIndex(node,type,value,isArray,size);          // the caller has to copy the value !
           *pvalue = _resolveSCMBUnion(type,isArray,size,start,inst.base);
  
     return SCMO_OK;     return SCMO_OK;
 } }
  
  SCMO_RC SCMOInstance::setPropertyWithNodeIndex(      // the get the defaults out of the class.
      Uint32 node,      type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;
      CIMType type,      isArray =
      void* value,          theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;
      Boolean isArray,      if (isArray)
      Uint32 size)  
  {  {
      SCMO_RC rc;          size = theClassPropNodeArray[node].
                      theProperty.defaultValue.valueArraySize;
       }
  
      if (node >= inst.hdr->numberProperties)      if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)
      {      {
          return SCMO_INDEX_OUT_OF_BOUND;          return SCMO_NULL_VALUE;
      }      }
  
      // is filtering on ?      // calcutate the relativ start address of the value
      if (inst.hdr->flags.isFiltered)      Uint64 start =
      {          (const char*)
          // Is the property NOT in the property filter ?                 &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
          if(!_isPropertyInFilter(node))          (inst.hdr->theClass->cls.base);
          {  
              // The proptery of the is not set due to filtering.      *pvalue = _resolveSCMBUnion(
           type,
           isArray,
           size,
           start,
           (inst.hdr->theClass->cls.base)
           );
   
              return SCMO_OK;              return SCMO_OK;
   
          }          }
   
   SCMOInstance SCMOInstance::clone(Boolean objectPathOnly) const
   {
       if (objectPathOnly)
       {
           // Create a new, empty SCMOInstance
           SCMOInstance newInst(*(this->inst.hdr->theClass));
   
           // Copy the host name to tha new instance-
           _setBinary(
               _resolveDataPtr(this->inst.hdr->hostName,this->inst.base),
               this->inst.hdr->hostName.length,
               newInst.inst.hdr->hostName,
               &newInst.inst.mem);
   
           // Copy the key bindings to that new instance.
           this->_copyKeyBindings(newInst);
   
           return newInst;
      }      }
  
      // Is the traget type OK ?      SCMOInstance newInst;
      rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);      newInst.inst.base = (char*)malloc(this->inst.mem->totalSize);
      if (rc != SCMO_OK)      if (newInst.inst.base == 0 )
      {      {
          return rc;          throw PEGASUS_STD(bad_alloc)();
      }      }
  
      _setPropertyAtNodeIndex(node,type,value,isArray,size);      memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize);
       // reset the refcounter of this new instance
       newInst.inst.hdr->refCount = 1;
       // keep the ref counter of the class correct !
       newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass));
       // keep the ref count for external references
       newInst._copyExternalReferences();
  
      return SCMO_OK;      return newInst;
  }  }
  
 void SCMOInstance::_setPropertyAtNodeIndex(  void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const
     Uint32 node,  
     CIMType type,  
     void* value,  
     Boolean isArray,  
     Uint32 size)  
 { {
     SCMBValue* theInstPropNodeArray =      Uint32 noBindings = inst.hdr->numberKeyBindings;
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];  
  
       SCMBKeyBindingValue* sourceArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
  
     theInstPropNodeArray[node].flags.isSet=true;      // Address the class keybinding information
     theInstPropNodeArray[node].valueType=type;      const SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
     theInstPropNodeArray[node].flags.isArray=isArray;      const char * clsbase = inst.hdr->theClass->cls.base;
     if (isArray)      SCMBKeyBindingNode* scmoClassArray =
     {          (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
         theInstPropNodeArray[node].valueArraySize=size;  
     }  
  
     if (value==NULL)      SCMBKeyBindingValue* targetArray;
   
       for (Uint32 i = 0; i < noBindings; i++)
     {     {
         theInstPropNodeArray[node].flags.isNull=true;          // hast to be set every time, because of reallocation.
     }          targetArray=(SCMBKeyBindingValue*)&(targetInst.inst.base)
     else                               [targetInst.inst.hdr->keyBindingArray.start];
           if(sourceArray[i].isSet)
     {     {
         Uint64 start =              // this has to be done on the target instance to keep constantness.
             (const char*)&(theInstPropNodeArray[node].value)-inst.base;              targetInst._setKeyBindingFromSCMBUnion(
                   scmoClassArray[i].type,
         _setSCMBUnion(value,type,isArray,size,start);                  sourceArray[i].data,
                   inst.base,
                   targetArray[i]);
     }     }
 } }
  
 void SCMOInstance::_setSCMBUnion(      // Are there user defined key bindings ?
     void* value,      if (0 != inst.hdr->numberUserKeyBindindigs)
     CIMType type,  
     Boolean isArray,  
     Uint32 size,  
     Uint64 start)  
 { {
     SCMBUnion* u = (SCMBUnion*)&(inst.base[start]);          SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
  
     switch (type)          for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++)
     {  
     case CIMTYPE_BOOLEAN:  
         {         {
             if (isArray)              if (theUserDefKBElement->value.isSet)
             {             {
                 _setBinary(value,size*sizeof(Boolean),                  targetInst._setUserDefinedKeyBinding(*theUserDefKBElement,
                            u->_arrayValue,                                                          inst.base);
                            &inst.mem );  
             }             }
             else  
             {              theUserDefKBElement =
                 u->_booleanValue = *((Boolean*)value);                  (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
             }             }
             break;  
         }         }
  
     case CIMTYPE_UINT8:  
         {  void SCMOInstance::_setUserDefinedKeyBinding(
             if (isArray)          SCMBUserKeyBindingElement& theInsertElement,
           char* elementBase)
             {             {
                 _setBinary(value,size*sizeof(Uint8),  
                            u->_arrayValue,      SCMBUserKeyBindingElement* ptrNewElement;
                            &inst.mem );  
       // get an exsiting or new user defined key binding
       ptrNewElement = _getUserDefinedKeyBinding(
           _getCharString(theInsertElement.name,elementBase),
           // lenght is without the trailing '\0'
           theInsertElement.name.length-1,
           theInsertElement.type);
   
       // Copy the data
       _setKeyBindingFromSCMBUnion(
                   theInsertElement.type,
                   theInsertElement.value.data,
                   elementBase,
                   ptrNewElement->value);
   
             }             }
             else  
   
   SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt(
       Uint32 index ) const
             {             {
                 u->_uint8Value = *((Uint8*)value);  
       // Get the start element
       SCMBUserKeyBindingElement *ptrNewElement =
           (SCMBUserKeyBindingElement*)
                &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
       // calculate the index within the user defined key bindings
       index = index - inst.hdr->numberKeyBindings;
   
       // traverse trough the user defindes key binding nodes.
       for (Uint32 i = 0; i < index; i ++)
       {
           PEGASUS_ASSERT(ptrNewElement->nextElement.start != 0);
           ptrNewElement = (SCMBUserKeyBindingElement*)
                 &(inst.base[ptrNewElement->nextElement.start]);
             }             }
             break;  
       return ptrNewElement;
         }         }
  
     case CIMTYPE_SINT8:  SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBinding(
       const char* name,
       Uint32 nameLen,
       CIMType type)
         {         {
             if (isArray)      SCMBDataPtr newElement;
       SCMBUserKeyBindingElement* ptrNewElement;
       Uint32 node;
   
       // is the key binding already stored as user defind in the instance ?
       if (SCMO_OK == _getUserKeyBindingNodeIndex(node,name))
             {             {
                 _setBinary(value,size*sizeof(Sint8),         ptrNewElement = _getUserDefinedKeyBindingAt(node);
                            u->_arrayValue,  
                            &inst.mem );  
             }             }
             else      else // Not found, create a new user defined key binding.
             {             {
                 u->_sint8Value = *((Sint8*)value);  
           _getFreeSpace(newElement,
                         sizeof(SCMBUserKeyBindingElement),
                         &inst.mem);
   
           ptrNewElement =
               (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
   
           // link new first user defined key binding element into chain:
           // - Assing the start point of user key binding element chain
           //   to the next element of the new element.
           ptrNewElement->nextElement.start =
               inst.hdr->userKeyBindingElement.start;
           ptrNewElement->nextElement.length =
               inst.hdr->userKeyBindingElement.length;
           // - Assing the the new element
           //   to the  start point of user key binding element chain
           inst.hdr->userKeyBindingElement.start = newElement.start;
           inst.hdr->userKeyBindingElement.length = newElement.length;
           // Adjust the couter of user defined key bindings.
           inst.hdr->numberUserKeyBindindigs++;
   
   
           // Copy the type
           ptrNewElement->type = type;
           ptrNewElement->value.isSet=false;
   
           // Copy the key binding name including the trailing '\0'
           _setBinary(name,nameLen+1,ptrNewElement->name,&inst.mem);
   
           // reset the pointer. May the instance was reallocated.
           ptrNewElement =
               (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
   
             }             }
             break;  
   
       return ptrNewElement;
   
         }         }
  
     case CIMTYPE_UINT16:  Uint32 SCMOInstance::getPropertyCount() const
         {  
             if (isArray)  
             {             {
                 _setBinary(value,size*sizeof(Uint16),      if (inst.hdr->flags.isFiltered)
                            u->_arrayValue,  
                            &inst.mem );  
             }  
             else  
             {             {
                 u->_uint16Value = *((Uint16*)value);          return(inst.hdr->filterProperties);
             }             }
             break;  
       return(inst.hdr->numberProperties);
         }         }
  
     case CIMTYPE_SINT16:  SCMBUnion * SCMOInstance::_resolveSCMBUnion(
       CIMType type,
       Boolean isArray,
       Uint32 size,
       Uint64 start,
       char* base) const
         {         {
   
       SCMBUnion* u = (SCMBUnion*)&(base[start]);
   
       SCMBUnion* av = 0;
   
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Sint16),          if (size == 0)
                            u->_arrayValue,  
                            &inst.mem );  
             }  
             else  
             {             {
                 u->_sint16Value = *((Sint16*)value);              return 0;
             }             }
             break;          av = (SCMBUnion*)&(base[u->arrayValue.start]);
         }         }
  
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
       case CIMTYPE_UINT8:
       case CIMTYPE_SINT8:
       case CIMTYPE_UINT16:
       case CIMTYPE_SINT16:
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
       case CIMTYPE_SINT32:
       case CIMTYPE_UINT64:
       case CIMTYPE_SINT64:
       case CIMTYPE_REAL32:
       case CIMTYPE_REAL64:
       case CIMTYPE_CHAR16:
       case CIMTYPE_DATETIME:
       case CIMTYPE_REFERENCE:
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Uint32),                  return (av);
                            u->_arrayValue,  
                            &inst.mem );  
             }             }
             else             else
             {             {
                 u->_uint32Value = *((Uint32*)value);                  return(u);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:      case CIMTYPE_STRING:
         {         {
               SCMBUnion *ptr;
   
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Sint32),  
                            u->_arrayValue,                  ptr = (SCMBUnion*)malloc(size*sizeof(SCMBUnion));
                            &inst.mem );                  if (ptr == 0 )
             }  
             else  
             {             {
                 u->_sint32Value = *((Sint32*)value);                      throw PEGASUS_STD(bad_alloc)();
             }  
             break;  
         }         }
  
     case CIMTYPE_UINT64:                  for(Uint32 i = 0; i < size; i++)
         {  
             if (isArray)  
             {             {
                 _setBinary(value,size*sizeof(Uint64),                      // resolv relative pointer to absolute pointer
                            u->_arrayValue,                      ptr[i].extString.pchar =
                            &inst.mem );                          (char*)_getCharString(av[i].stringValue,base);
                       // lenght with out the trailing /0 !
                       ptr[i].extString.length = av[i].stringValue.length-1;
                   }
             }             }
             else             else
             {             {
                 u->_uint64Value = *((Uint64*)value);                  ptr = (SCMBUnion*)malloc(sizeof(SCMBUnion));
                   ptr->extString.pchar =
                       (char*)_getCharString(u->stringValue,base);
                   // lenght with out the trailing /0 !
                   ptr->extString.length = u->stringValue.length-1;
             }             }
   
                return(ptr);
             break;             break;
         }         }
       default:
     case CIMTYPE_SINT64:  
         {  
             if (isArray)  
             {             {
                 _setBinary(value,size*sizeof(Sint64),              PEGASUS_ASSERT(false);
                            u->_arrayValue,              break;
                            &inst.mem );  
             }             }
             else  
             {  
                 u->_sint64Value = *((Sint64*)value);  
             }             }
             break;      return 0;
         }         }
  
     case CIMTYPE_REAL32:  Uint32 SCMOInstance::getKeyBindingCount() const
         {  
             if (isArray)  
             {  
                 _setBinary(value,size*sizeof(Real32),  
                            u->_arrayValue,  
                            &inst.mem );  
             }  
             else  
             {             {
                 u->_real32Value = *((Real32*)value);      // count of class keys + user definded keys
             }      return(inst.hdr->numberKeyBindings+
             break;             inst.hdr->numberUserKeyBindindigs);
         }         }
  
     case CIMTYPE_REAL64:  
   SCMO_RC SCMOInstance::getKeyBindingAt(
           Uint32 node,
           const char** pname,
           CIMType& type,
           const SCMBUnion** pvalue) const
         {         {
             if (isArray)      SCMO_RC rc;
       const SCMBUnion* pdata=0;
       Uint32 pnameLen=0;
   
       *pname = 0;
       *pvalue = 0;
   
       // count of class keys + user definded keys
       if (node >= (inst.hdr->numberKeyBindings+
                    inst.hdr->numberUserKeyBindindigs))
             {             {
                 _setBinary(value,size*sizeof(Real64),          return SCMO_INDEX_OUT_OF_BOUND;
                            u->_arrayValue,  
                            &inst.mem );  
             }             }
             else  
       rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,&pdata);
       if (rc != SCMO_OK)
             {             {
                 u->_real64Value = *((Real64*)value);          return rc;
             }             }
             break;  
       *pvalue = _resolveSCMBUnion(
           type,
           false,  // A key binding can never be an array.
           0,
           (char*)pdata-inst.base,
           inst.base);
   
       return SCMO_OK;
   
         }         }
  
     case CIMTYPE_CHAR16:  SCMO_RC SCMOInstance::getKeyBinding(
       const char* name,
       CIMType& type,
       const SCMBUnion** pvalue) const
         {         {
             if (isArray)      SCMO_RC rc;
       Uint32 node;
       const char* pname=0;
       const SCMBUnion* pdata=0;
       Uint32 pnameLen=0;
   
       *pvalue = 0;
   
       rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
       if (rc != SCMO_OK)
             {             {
                 _setBinary(value,size*sizeof(Char16),          // look at the user defined key bindings.
                            u->_arrayValue,          rc = _getUserKeyBindingNodeIndex(node,name);
                            &inst.mem );          if (rc != SCMO_OK)
             }  
             else  
             {             {
                 u->_char16Value = *((Char16*)value);              return rc;
             }             }
             break;  
         }         }
  
     case CIMTYPE_DATETIME:      rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata);
         {  
             if (isArray)      if (rc != SCMO_OK)
             {  
                 _setBinary(value,size*sizeof(SCMBDateTime),  
                            u->_arrayValue,  
                            &inst.mem );  
             }  
             else  
             {             {
                 u->_dateTimeValue = *((SCMBDateTime*)value);          return rc;
             }             }
             break;  
       *pvalue = _resolveSCMBUnion(
           type,
           false,  // A key binding can never be an array.
           0,
           (char*)pdata-inst.base,
           inst.base);
   
       return SCMO_OK;
         }         }
  
     case CIMTYPE_STRING:  
   SCMO_RC SCMOInstance::_getKeyBindingDataAtNodeIndex(
       Uint32 node,
       const char** pname,
       Uint32 & pnameLen,
       CIMType & type,
       const SCMBUnion** pdata) const
         {         {
             if (isArray)      if (node < inst.hdr->numberKeyBindings)
             {             {
                 SCMBDataPtr* ptr;          SCMBKeyBindingValue* theInstKeyBindValueArray =
                 char** tmp;              (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
                 Uint64 startPtr;  
  
                 startPtr = _getFreeSpace(          // create a pointer to key binding node array of the class.
                     u->_arrayValue,          Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
                     size*sizeof(SCMBDataPtr),          SCMBKeyBindingNode* theClassKeyBindNodeArray =
                     &inst.mem,false);              (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
                 // the value is pointer to an array of char*  
                 tmp = (char**)value;  
  
                 for (Uint32 i = 0; i < size; i++)          type = theClassKeyBindNodeArray[node].type;
   
           // First resolve pointer to the key binding name
           pnameLen = theClassKeyBindNodeArray[node].name.length;
           *pname = _getCharString(
               theClassKeyBindNodeArray[node].name,
               inst.hdr->theClass->cls.base);
   
           // There is no value set in the instance
           if (!theInstKeyBindValueArray[node].isSet)
                 {                 {
                     ptr = (SCMBDataPtr*)&(inst.base[startPtr]);              return SCMO_NULL_VALUE;
                     // Copy the sting including the trailing '\0'  
                     _setBinary(tmp[i],strlen(tmp[i])+1,ptr[i],&inst.mem );  
                 }                 }
   
           *pdata = &(theInstKeyBindValueArray[node].data);
             }             }
             else      else // look at the user defined key bindings
             {             {
                 // Copy the sting including the trailing '\0'  
                 _setBinary(  
                     value,  
                     strlen((char*)value)+1,  
                     u->_stringValue,  
                     &inst.mem );  
             }  
             break;  
         }  
  
         case CIMTYPE_REFERENCE:          SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node);
  
             break;          type = theElem->type;
  
         case CIMTYPE_OBJECT:          pnameLen = theElem->name.length;
           *pname = _getCharString(theElem->name,inst.base);
  
             break;          // There is no value set in the instance
         case CIMTYPE_INSTANCE:          if (!theElem->value.isSet)
           {
               return SCMO_NULL_VALUE;
           }
   
           *pdata = &(theElem->value.data);
  
             break;  
     }     }
   
       return SCMO_OK;
 } }
  
 void SCMOInstance::_setArrayValue(  SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex(
     Uint64 start,      Uint32& node,
     SCMBMgmt_Header** pmem,      const char* name) const
     CIMType type,  
     Uint32& n,  
     Union& u)  
 { {
     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);  
     Uint64 arrayStart;  
  
     switch (type)      Uint32 len = strlen(name);
     {      node = 0;
     case CIMTYPE_BOOLEAN:      SCMBUserKeyBindingElement* theUserDefKBElement;
         {  
             Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);  
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Boolean),  
                 pmem);  
             memcpy(  
                 &((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Boolean));  
             break;  
         }  
  
     case CIMTYPE_UINT8:      Uint64 elementStart = inst.hdr->userKeyBindingElement.start;
   
       while (elementStart != 0)
         {         {
             Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);          SCMBUserKeyBindingElement* theUserDefKBElement =
             n = x->size();              (SCMBUserKeyBindingElement*)&(inst.base[elementStart]);
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint8),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint8));  
             break;  
         }  
  
     case CIMTYPE_SINT8:          if (_equalUTF8Strings(theUserDefKBElement->name,inst.base,name,len))
         {         {
             Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);              // the node index of a user defined key binding has an offset
             n = x->size();              // by the number of key bindings defined in the class
             arrayStart = _getFreeSpace(              node = node + inst.hdr->numberKeyBindings;
                 scmoUnion->_arrayValue,              return SCMO_OK;
                 n*sizeof(Sint8),          }
                 pmem);          node = node + 1;
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint8));          elementStart = theUserDefKBElement->nextElement.start;
             break;  
         }         }
  
     case CIMTYPE_UINT16:      return SCMO_NOT_FOUND;
         {  
             Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);  
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint16),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint16));  
  
             break;  
         }         }
  
     case CIMTYPE_SINT16:  CIMType SCMOInstance::_CIMTypeFromKeyBindingType(
       const char* key,
       CIMKeyBinding::Type t)
         {         {
             Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);      switch( t )
             n = x->size();      {
             arrayStart = _getFreeSpace(          case CIMKeyBinding::NUMERIC:
                 scmoUnion->_arrayValue,              {
                 n*sizeof(Sint16),                  if( *(key)=='-' )
                 pmem);                  {
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint16));                     Sint64 x;
             break;                     // check if it is realy an integer
                      if (StringConversion::stringToSignedInteger(key, x))
                      {
                          return CIMTYPE_SINT64;
         }         }
                      else
     case CIMTYPE_UINT32:  
         {         {
             Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);                         return CIMTYPE_REAL64;
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint32),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint32));  
             break;  
         }         }
                   }
     case CIMTYPE_SINT32:                  else
         {         {
             Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);                      Uint64 x;
             n = x->size();                      // check if it is realy an integer
             arrayStart = _getFreeSpace(                      if (StringConversion::stringToUnsignedInteger(key, x))
                 scmoUnion->_arrayValue,                      {
                 n*sizeof(Sint32),                          return CIMTYPE_UINT64;
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint32));  
             break;  
         }         }
                       else
     case CIMTYPE_UINT64:  
         {         {
             Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);                          return CIMTYPE_REAL64;
             n = x->size();                      }
             arrayStart = _getFreeSpace(                  }
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint64),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint64));  
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:  
           case CIMKeyBinding::STRING:
         {         {
             Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);              return CIMTYPE_STRING;
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Sint64),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint64));  
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:          case CIMKeyBinding::BOOLEAN:
         {         {
             Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);              return CIMTYPE_BOOLEAN;
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Real32),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real32));  
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:          case CIMKeyBinding::REFERENCE:
         {         {
             Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);              return CIMTYPE_REFERENCE;
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Real64),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real64));  
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:          default:
         {              return CIMTYPE_UINT64;
             Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);      }
             n = x->size();      return CIMTYPE_UINT64;
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Char16),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Char16));  
             break;  
         }         }
  
     case CIMTYPE_STRING:  Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue(
       const String& kbs,
       CIMType type,
       SCMBKeyBindingValue& scmoKBV
       )
         {         {
             SCMBDataPtr *ptr;      scmoKBV.isSet=false;
   
             Array<String> *x = reinterpret_cast<Array<String>*>(&u);  
   
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(SCMBDataPtr),  
                 pmem);  
  
             for (Uint32 i = 0; i < n ; i++)      if ( kbs.size() == 0 && type != CIMTYPE_STRING)
             {             {
                 // the pointer has to be set eache loop,          // The string is empty ! Do nothing.
                 // because a reallocation may take place.          return false;
                 ptr = (SCMBDataPtr*)(&((char*)*pmem)[arrayStart]);  
                 _setString( (*x)[i],ptr[i], pmem );  
             }             }
  
             break;      CString a = kbs.getCString();
         }      const char* v = a;
  
     case CIMTYPE_DATETIME:      switch (type)
         {         {
             SCMBDateTime *ptr;      case CIMTYPE_UINT8:
             Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);          {
             n = x->size();              Uint64 x;
             arrayStart = _getFreeSpace(              if (StringConversion::stringToUnsignedInteger(v, x) &&
                 scmoUnion->_arrayValue,                  StringConversion::checkUintBounds(x, type))
                 n*sizeof(SCMBDateTime),  
                 pmem);  
   
             ptr=(SCMBDateTime*)(&((char*)*pmem)[arrayStart]);  
   
             for (Uint32 i = 0; i < n ; i++)  
             {             {
                 memcpy(&(ptr[i]),(*x)[i]._rep,sizeof(SCMBDateTime));                scmoKBV.data.simple.val.u8 = Uint8(x);
                 scmoKBV.isSet=true;
             }             }
             break;             break;
         }         }
       case CIMTYPE_UINT16:
         case CIMTYPE_REFERENCE:          {
               Uint64 x;
             break;              if (StringConversion::stringToUnsignedInteger(v, x) &&
                   StringConversion::checkUintBounds(x, type))
         case CIMTYPE_OBJECT:              {
                 scmoKBV.data.simple.val.u16 = Uint16(x);
             break;                scmoKBV.isSet=true;
   
         case CIMTYPE_INSTANCE:  
   
             break;  
     }     }
               break;
 } }
  
       case CIMTYPE_UINT32:
 void SCMOInstance::_setUnionValue(  
     Uint64 start,  
     SCMBMgmt_Header** pmem,  
     CIMType type,  
     Union& u)  
 {  
     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);  
   
     switch (type)  
     {     {
     case CIMTYPE_BOOLEAN:              Uint64 x;
               if (StringConversion::stringToUnsignedInteger(v, x) &&
                   StringConversion::checkUintBounds(x, type))
         {         {
             scmoUnion->_booleanValue = u._booleanValue;                scmoKBV.data.simple.val.u32 = Uint32(x);
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:      case CIMTYPE_UINT64:
           {
               Uint64 x;
               if (StringConversion::stringToUnsignedInteger(v, x))
         {         {
             scmoUnion->_uint8Value = u._uint8Value;                scmoKBV.data.simple.val.u64 = x;
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             scmoUnion->_sint8Value = u._sint8Value;              Sint64 x;
               if (StringConversion::stringToSignedInteger(v, x) &&
                   StringConversion::checkSintBounds(x, type))
               {
                 scmoKBV.data.simple.val.s8 = Sint8(x);
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:      case CIMTYPE_SINT16:
           {
               Sint64 x;
               if (StringConversion::stringToSignedInteger(v, x) &&
                   StringConversion::checkSintBounds(x, type))
         {         {
             scmoUnion->_uint16Value = u._uint16Value;                scmoKBV.data.simple.val.s16 = Sint16(x);
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:      case CIMTYPE_SINT32:
           {
               Sint64 x;
               if (StringConversion::stringToSignedInteger(v, x) &&
                   StringConversion::checkSintBounds(x, type))
         {         {
             scmoUnion->_sint16Value = u._sint16Value;                scmoKBV.data.simple.val.s32 = Sint32(x);
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:      case CIMTYPE_SINT64:
           {
               Sint64 x;
               if (StringConversion::stringToSignedInteger(v, x))
         {         {
             scmoUnion->_uint32Value = u._uint32Value;                scmoKBV.data.simple.val.s64 = x;
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:      case CIMTYPE_DATETIME:
           {
               CIMDateTime tmp;
   
               try
         {         {
             scmoUnion->_sint32Value = u._sint32Value;                  tmp.set(v);
             break;  
         }         }
               catch (InvalidDateTimeFormatException&)
     case CIMTYPE_UINT64:  
         {         {
             scmoUnion->_uint64Value = u._uint64Value;                  return false;
             break;  
         }         }
  
     case CIMTYPE_SINT64:              memcpy(
         {                  &(scmoKBV.data.dateTimeValue),
             scmoUnion->_sint64Value = u._sint64Value;                  tmp._rep,
                   sizeof(SCMBDateTime));
               scmoKBV.isSet=true;
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             scmoUnion->_real32Value = u._real32Value;              Real64 x;
   
               if (StringConversion::stringToReal64(v, x))
               {
                 scmoKBV.data.simple.val.r32 = Real32(x);
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             scmoUnion->_real64Value = u._real64Value;              Real64 x;
   
               if (StringConversion::stringToReal64(v, x))
               {
                 scmoKBV.data.simple.val.r64 = x;
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             scmoUnion->_char16Value = u._char16Value;              if (kbs.size() == 1)
               {
                   scmoKBV.data.simple.val.c16 = kbs[0];
                   scmoKBV.isSet=true;
               }
             break;             break;
         }         }
       case CIMTYPE_BOOLEAN:
     case CIMTYPE_STRING:  
         {         {
             _setString(*((String*)((void*)&u)),              if (String::equalNoCase(kbs,"TRUE"))
                        scmoUnion->_stringValue,              {
                        pmem );                  scmoKBV.data.simple.val.bin = true;
                   scmoKBV.isSet=true;
               }
               else if (String::equalNoCase(kbs,"FALSE"))
                    {
                        scmoKBV.data.simple.val.bin = false;
                        scmoKBV.isSet=true;
                    }
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:      case CIMTYPE_STRING:
         {         {
               scmoKBV.isSet=true;
             memcpy(              // Can cause reallocation !
                 &scmoUnion->_dateTimeValue,              _setString(kbs,scmoKBV.data.stringValue,&inst.mem);
                 (*((CIMDateTime*)((void*)&u)))._rep,              return true;
                 sizeof(SCMBDateTime));  
             break;             break;
         }         }
   
         case CIMTYPE_REFERENCE:         case CIMTYPE_REFERENCE:
           {
               if (0 != scmoKBV.data.extRefPtr)
               {
                   delete scmoKBV.data.extRefPtr;
                   scmoKBV.data.extRefPtr = 0;
                   scmoKBV.isSet=false;
               }
               // TBD: Optimize parsing and SCMOInstance creation.
               CIMObjectPath theCIMObj(kbs);
               SCMOClass* theRefClass = _getSCMOClass(
                   theCIMObj,
                   _getCharString(inst.hdr->instNameSpace,inst.base),
                   inst.hdr->instNameSpace.length);
  
               if (theRefClass != 0)
               {
                   scmoKBV.data.extRefPtr =
                       new SCMOInstance(*theRefClass,theCIMObj);
               } else
               {
                   scmoKBV.data.extRefPtr = 0;
               }
               scmoKBV.isSet=true;
             break;             break;
           }
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
   
             break;  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
           {
               // From PEP 194: EmbeddedObjects cannot be keys.
               throw TypeMismatchException();
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
             break;             break;
     }     }
       }
  
       return scmoKBV.isSet;
 } }
  
 SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(  SCMO_RC SCMOInstance::_setKeyBindingFromString(
         Uint32 node,      const char* name,
         const char** pname,      CIMType type,
         CIMType& type,      String cimKeyBinding)
         const void** pvalue,  
         Boolean& isArray,  
         Uint32& size ) const  
 { {
     SCMBValue* theInstPropNodeArray =      SCMO_RC rc;
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];      Uint32 node;
   
     // create a pointer to property node array of the class.  
     Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;  
     SCMBClassPropertyNode* theClassPropNodeArray =  
         (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];  
  
     // the property name is always from the class.      if (0 == name)
     // return the absolut pointer to the property name,      {
     // the caller has to copy the name!          return SCMO_INVALID_PARAMETER;
     *pname=_getCharString(      }
         theClassPropNodeArray[node].theProperty.name,  
         inst.hdr->theClass->cls.base);  
  
     // the property was set by the provider.      if (SCMO_OK == inst.hdr->theClass->_getKeyBindingNodeIndex(node,name))
     if (theInstPropNodeArray[node].flags.isSet)  
     {     {
           // create a pointer to keybinding node array of the class.
           Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
           SCMBKeyBindingNode* theClassKeyBindNodeArray =
               (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
  
         type = theInstPropNodeArray[node].valueType;          // create a pointer to instance keybinding values
         isArray = theInstPropNodeArray[node].flags.isArray;          SCMBKeyBindingValue* theInstKeyBindValueArray =
         if (isArray)              (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
           // If the set was not successful, the conversion was not successful
           if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
                   cimKeyBinding,
                   theClassKeyBindNodeArray[node].type,
                   theInstKeyBindValueArray[node]))
         {         {
             size = theInstPropNodeArray[node].valueArraySize;              return SCMO_TYPE_MISSMATCH;
         }         }
  
         if (theInstPropNodeArray[node].flags.isNull)          return SCMO_OK;
       }
   
       // the key binig does not belong to the associated class
       // add/set it as user defined key binding.
       SCMBUserKeyBindingElement* ptrNewElement;
   
       ptrNewElement = _getUserDefinedKeyBinding( name,strlen(name),type);
   
       // Copy the data.
       // If the set was not successful, the conversion was not successful
       if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
               cimKeyBinding,
               type,
               ptrNewElement->value))
         {         {
             return SCMO_NULL_VALUE;          return SCMO_TYPE_MISSMATCH;
         }         }
  
         // calculate the relative index for the value.      return SCMO_OK;
         Uint64 start =  }
             (const char*)&(theInstPropNodeArray[node].value) -  
             inst.base;  
  
         // the caller has to copy the value !  SCMO_RC SCMOInstance::setKeyBinding(
         *pvalue = _getSCMBUnion(type,isArray,size,start,inst.base);      const char* name,
       CIMType type,
       const SCMBUnion* keyvalue)
   {
       SCMO_RC rc;
       Uint32 node;
  
         return SCMO_OK;      if (0 == name)
       {
           return SCMO_INVALID_PARAMETER;
     }     }
  
     // the get the defaults out of the class.      if (0 == keyvalue)
     type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;  
     isArray =  
         theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;  
     if (isArray)  
     {     {
         size = theClassPropNodeArray[node].          return SCMO_INVALID_PARAMETER;
                    theProperty.defaultValue.valueArraySize;  
     }     }
  
     if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)      rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
       if (rc != SCMO_OK)
     {     {
         return SCMO_NULL_VALUE;          // the key bindig does not belong to the associated class
           // add/set it as user defined key binding.
           SCMBUserKeyBindingElement *theNode;
   
           theNode = _getUserDefinedKeyBinding( name,strlen(name),type);
   
           // Is this a new node or an existing user key binding?
           if (theNode->value.isSet && (theNode->type != type))
           {
               return SCMO_TYPE_MISSMATCH;
   
     }     }
  
     // calcutate the relativ start address of the value          theNode->value.isSet=true;
     Uint64 start =  
         (const char*)  
                &(theClassPropNodeArray[node].theProperty.defaultValue.value) -  
         (inst.hdr->theClass->cls.base);  
  
     *pvalue = _getSCMBUnion(          _setSCMBUnion(
               keyvalue,
         type,         type,
         isArray,              false, // a key binding can never be an array.
         size,              0,
         start,              theNode->value.data);
         (inst.hdr->theClass->cls.base)  
         );  
  
     return SCMO_OK;     return SCMO_OK;
       }
  
       return setKeyBindingAt(node, type, keyvalue);
 } }
  
 SCMOInstance SCMOInstance::clone() const  SCMO_RC SCMOInstance::setKeyBindingAt(
           Uint32 node,
           CIMType type,
           const SCMBUnion* keyvalue)
 { {
     SCMOInstance newInst;      SCMO_RC rc;
     newInst.inst.base = (char*)malloc(this->inst.mem->totalSize);  
     if (newInst.inst.base == NULL )     // create a pointer to keybinding node array of the class.
       Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
       SCMBKeyBindingNode* theClassKeyBindNodeArray =
           (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
   
       if (0 == keyvalue)
     {     {
         throw PEGASUS_STD(bad_alloc)();          return SCMO_INVALID_PARAMETER;
     }     }
  
     memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize);      // count of class keys + user definded keys
     // reset the refcounter of this new instance      if (node >= (inst.hdr->numberKeyBindings+
     newInst.inst.hdr->refCount = 1;                   inst.hdr->numberUserKeyBindindigs))
     // kepp the ref counter of the class correct !      {
     newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass));          return SCMO_INDEX_OUT_OF_BOUND;
   
     return newInst;  
 } }
  
 Uint32 SCMOInstance::getPropertyCount() const      // is the node a user defined key binding ?
       if (node >= inst.hdr->numberKeyBindings)
 { {
     if (inst.hdr->flags.isFiltered)          SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node);
   
           // Does the new value for the user defined keybinding match?
           if (theNode->type != type)
     {     {
         return(inst.hdr->filterProperties);              return SCMO_TYPE_MISSMATCH;
     }     }
  
     return(inst.hdr->numberProperties);          _setSCMBUnion(
               keyvalue,
               type,
               false, // a key binding can never be an array.
               0,
               theNode->value.data);
   
            return SCMO_OK;
   
 } }
  
 void* SCMOInstance::_getSCMBUnion(      SCMBKeyBindingValue* theInstKeyBindValueArray =
     CIMType type,          (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
     Boolean isArray,  
     Uint32 size,  
     Uint64 start,      if (theClassKeyBindNodeArray[node].type == type)
     char* base) const  
 { {
  
     SCMBUnion* u = (SCMBUnion*)&(base[start]);          // Has to be set first,
           // because reallocaton can take place in _setSCMBUnion()
           theInstKeyBindValueArray[node].isSet=true;
  
     void* av = NULL;          _setSCMBUnion(
               keyvalue,
               type,
               false, // a key binding can never be an array.
               0,
               theInstKeyBindValueArray[node].data);
   
           return SCMO_OK;
  
     if (isArray)  
     {  
         if (size == 0)  
         {  
             return NULL;  
         }  
         av = (void*)&base[u->_arrayValue.start];  
     }     }
  
       // The type does not match.
       return _setKeyBindingTypeTolerate(
           theClassKeyBindNodeArray[node].type,
           type,
           keyvalue,
           theInstKeyBindValueArray[node]);
  
     switch (type)  
     {  
     case CIMTYPE_BOOLEAN:  
     case CIMTYPE_UINT8:  
     case CIMTYPE_SINT8:  
     case CIMTYPE_UINT16:  
     case CIMTYPE_SINT16:  
     case CIMTYPE_UINT32:  
     case CIMTYPE_SINT32:  
     case CIMTYPE_UINT64:  
     case CIMTYPE_SINT64:  
     case CIMTYPE_REAL32:  
     case CIMTYPE_REAL64:  
     case CIMTYPE_CHAR16:  
     case CIMTYPE_DATETIME:  
         {  
             if(isArray)  
             {  
                 return ((void*)av);  
             }  
             else  
             {  
                 return((void*)u);  
             }  
             break;  
         }         }
  
     case CIMTYPE_STRING:  /**
    * Set a SCMO user defined key binding using the class CIM type tolerating
    * CIM key binding types converted to CIM types by fuction
    *  _CIMTypeFromKeyBindingType().
    *
    * @parm classType The type of the key binding in the class definition
    * @parm setType The type of the key binding to be set.
    * @param keyValue A pointer to the key binding to be set.
    * @param kbValue Out parameter, the SCMO keybinding to be set.
    *
    **/
   SCMO_RC SCMOInstance::_setKeyBindingTypeTolerate(
       CIMType classType,
       CIMType setType,
       const SCMBUnion* keyValue,
       SCMBKeyBindingValue& kbValue)
         {         {
             SCMBDataPtr *ptr;      if (setType == CIMTYPE_UINT64 )
             char** tmp=NULL;  
   
             if (isArray)  
             {             {
                 // allocate an array of char* pointers.          switch (classType)
                 tmp = (char**)malloc(size*sizeof(char*));  
                 if (tmp == NULL )  
                 {                 {
                     throw PEGASUS_STD(bad_alloc)();  
                 }  
  
                 // use temporary variables to avoid casting          case CIMTYPE_UINT8:
                 ptr = (SCMBDataPtr*)av;  
   
                 for(Uint32 i = 0; i < size; i++)  
                 {                 {
                     // resolv relative pointer to absolute pointer                  kbValue.isSet=true;
                     tmp[i] = (char*)_getCharString(ptr[i],base);                  kbValue.data.simple.hasValue=true;
                 }                  kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);
                   return SCMO_OK;
                 return((void*)tmp);                  break;
             }             }
             else          case CIMTYPE_UINT16:
             {             {
                 return((void*)_getCharString(u->_stringValue,base));                  kbValue.isSet=true;
             }                  kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);
                   return SCMO_OK;
             break;             break;
         }         }
           case CIMTYPE_UINT32:
     case CIMTYPE_REFERENCE:              {
                   kbValue.isSet=true;
         break;                  kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);
     case CIMTYPE_OBJECT:                  return SCMO_OK;
   
         break;         break;
               }
     case CIMTYPE_INSTANCE:          case CIMTYPE_UINT64:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u64=keyValue->simple.val.u64;
                   return SCMO_OK;
         break;         break;
               }
     default:     default:
         PEGASUS_ASSERT(false);              {
                   return SCMO_TYPE_MISSMATCH;
         break;         break;
     }     }
     return NULL;  
 } }
   
 Uint32 SCMOInstance::getKeyBindingCount()  
 {  
     return(inst.hdr->numberKeyBindings);  
 } }
  
       if (setType == CIMTYPE_SINT64)
 SCMO_RC SCMOInstance::getKeyBindingAt(      {
         Uint32 node,          switch (classType)
         const char** pname,  
         CIMKeyBinding::Type& type,  
         const char** pvalue) const  
 { {
     *pname = NULL;  
     *pvalue = NULL;  
  
     if (node >= inst.hdr->numberKeyBindings)          case CIMTYPE_SINT8:
     {     {
         return SCMO_INDEX_OUT_OF_BOUND;                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);
                   return SCMO_OK;
                   break;
     }     }
           case CIMTYPE_SINT16:
     return _getKeyBindingAtNodeIndex(node,pname,type,pvalue);              {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);
                   return SCMO_OK;
                   break;
 } }
           case CIMTYPE_SINT32:
 SCMO_RC SCMOInstance::getKeyBinding(  
     const char* name,  
     CIMKeyBinding::Type& type,  
     const char** pvalue) const  
 { {
     SCMO_RC rc;                  kbValue.isSet=true;
     Uint32 node;                  kbValue.data.simple.hasValue=true;
     const char* pname=NULL;                  kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);
                   return SCMO_OK;
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);                  break;
     if (rc != SCMO_OK)              }
           case CIMTYPE_SINT64:
     {     {
         return rc;                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.s64=keyValue->simple.val.s64;
                   return SCMO_OK;
                   break;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
                   break;
               }
     }     }
   
     return _getKeyBindingAtNodeIndex(node,&pname,type,pvalue);  
   
 } }
  
 SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex(      if (setType == CIMTYPE_REAL64)
     Uint32 node,  
     const char** pname,  
     CIMKeyBinding::Type& type,  
     const char** pvalue) const  
 { {
           switch (classType)
     SCMBDataPtr* theInstKeyBindNodeArray =  
         (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];  
   
     // create a pointer to keybinding node array of the class.  
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;  
     SCMBKeyBindingNode* theClassKeyBindNodeArray =  
         (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];  
   
     type = theClassKeyBindNodeArray[node].type;  
   
     *pname = _getCharString(  
         theClassKeyBindNodeArray[node].name,  
         inst.hdr->theClass->cls.base);  
   
     // There is no value set in the instance  
     // if the relative pointer has no start value.  
     if (theInstKeyBindNodeArray[node].start==0)  
     {     {
         *pvalue = NULL;          case CIMTYPE_REAL32:
         return SCMO_NULL_VALUE;              {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);
                   return SCMO_OK;
                   break;
     }     }
           case CIMTYPE_REAL64:
     // Set the absolut pointer to the key binding value              {
     *pvalue = _getCharString(theInstKeyBindNodeArray[node],inst.base);                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.r64=keyValue->simple.val.r64;
     return SCMO_OK;     return SCMO_OK;
                   break;
 } }
           default:
 SCMO_RC SCMOInstance::setKeyBinding(  
     const char* name,  
     CIMKeyBinding::Type type,  
     const char* pvalue)  
 { {
     SCMO_RC rc;                  return SCMO_TYPE_MISSMATCH;
     Uint32 node;                  break;
               }
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);          }
     if (rc != SCMO_OK)      }
       else
     {     {
         return rc;          switch (classType)
           {
           case CIMTYPE_BOOLEAN:
           case CIMTYPE_UINT64:
           case CIMTYPE_SINT64:
           case CIMTYPE_REAL64:
           case CIMTYPE_STRING:
           case CIMTYPE_REFERENCE:
               {
                   kbValue.isSet=true;
                   _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);
                   return SCMO_OK;
                   break;
     }     }
           default:
    // create a pointer to keybinding node array of the class.  
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;  
     SCMBKeyBindingNode* theClassKeyBindNodeArray =  
         (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];  
   
     if (theClassKeyBindNodeArray[node].type != type)  
     {     {
         return SCMO_TYPE_MISSMATCH;         return SCMO_TYPE_MISSMATCH;
                   break;
               }
           }
     }     }
  
     SCMBDataPtr* theInstKeyBindNodeArray =      return SCMO_TYPE_MISSMATCH;
         (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];  
   
     // copy the value including trailing '\0'  
     _setBinary(pvalue,strlen(pvalue)+1,theInstKeyBindNodeArray[node],&inst.mem);  
   
     return SCMO_OK;  
  
 } }
  
   
 void SCMOInstance::setPropertyFilter(const char **propertyList) void SCMOInstance::setPropertyFilter(const char **propertyList)
 { {
     SCMO_RC rc;     SCMO_RC rc;
Line 2604 
Line 4962 
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
  
     // All properties are accepted     // All properties are accepted
     if (propertyList == NULL)      if (propertyList == 0)
     {     {
         // Clear filtering:         // Clear filtering:
         // Switch filtering off.         // Switch filtering off.
Line 2614 
Line 4972 
         memset(         memset(
             propertyFilterIndexMap,             propertyFilterIndexMap,
             0,             0,
             sizeof(Uint32)*inst.hdr->filterProperties);              sizeof(Uint32)*inst.hdr->numberProperties);
  
         //reset number filter properties to all         //reset number filter properties to all
         inst.hdr->filterProperties = inst.hdr->numberProperties;         inst.hdr->filterProperties = inst.hdr->numberProperties;
Line 2629 
Line 4987 
     inst.hdr->filterProperties=_initPropFilterWithKeys();     inst.hdr->filterProperties=_initPropFilterWithKeys();
  
     // add the properties to the filter.     // add the properties to the filter.
     while (propertyList[i] != NULL)      while (propertyList[i] != 0)
     {     {
         // the hash index of the property if the property name is found         // the hash index of the property if the property name is found
         rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]);         rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]);
  
         if (rc == SCMO_OK)          // if property is already in the filter
           // ( eg. key properties ) do not add them !
           if (rc == SCMO_OK && !_isPropertyInFilter(node))
         {         {
             // The property name was found. Otherwise ignore this property name.             // The property name was found. Otherwise ignore this property name.
             // insert the hash index into the filter index map             // insert the hash index into the filter index map
Line 2689 
Line 5049 
     Uint64 *propertyFilter;     Uint64 *propertyFilter;
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];      propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
  
     // the number of Uint64 in the key mask is :     // the number of Uint64 in the key mask is :
     // Decrease the number of properties by 1     // Decrease the number of properties by 1
Line 2737 
Line 5097 
     Uint64 filter = ( (Uint64)1 << (i%64));     Uint64 filter = ( (Uint64)1 << (i%64));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];      propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
  
     // If the bit is set the property is NOT filtered.     // If the bit is set the property is NOT filtered.
     // So the result has to be negated!     // So the result has to be negated!
Line 2759 
Line 5119 
  
 } }
  
 SCMODump::SCMODump(char* filename)  SCMODump::SCMODump(const char* filename)
 { {
     openFile(filename);     openFile(filename);
 } }
  
 void SCMODump::openFile(char* filename)  void SCMODump::openFile(const char* filename)
 { {
     const char* pegasusHomeDir = getenv("PEGASUS_HOME");     const char* pegasusHomeDir = getenv("PEGASUS_HOME");
  
     if (pegasusHomeDir == NULL)      if (pegasusHomeDir == 0)
     {     {
         pegasusHomeDir = ".";         pegasusHomeDir = ".";
     }     }
Line 2849 
Line 5209 
            (insthdr->flags.includeClassOrigin ? "True" : "False"));            (insthdr->flags.includeClassOrigin ? "True" : "False"));
     fprintf(_out,"\n   isFiltered: %s",     fprintf(_out,"\n   isFiltered: %s",
            (insthdr->flags.isFiltered ? "True" : "False"));            (insthdr->flags.isFiltered ? "True" : "False"));
       fprintf(_out,"\n   isClassOnly: %s",
              (insthdr->flags.isClassOnly ? "True" : "False"));
       fprintf(_out,"\n   isCompromised: %s",
              (insthdr->flags.isCompromised ? "True" : "False"));
       fprintf(_out,"\n\ninstNameSpace: \'%s\'",
              NULLSTR(_getCharString(insthdr->instNameSpace,instbase)));
       fprintf(_out,"\n\ninstClassName: \'%s\'",
              NULLSTR(_getCharString(insthdr->instClassName,instbase)));
     fprintf(_out,"\n\nhostName: \'%s\'",     fprintf(_out,"\n\nhostName: \'%s\'",
            NULLSTR(_getCharString(insthdr->hostName,instbase)));            NULLSTR(_getCharString(insthdr->hostName,instbase)));
  
Line 3022 
Line 5390 
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
  
     SCMBDataPtr* ptr =      // create a pointer to keybinding node array of the class.
         (SCMBDataPtr*)_resolveDataPtr(insthdr->keyBindingArray,instbase);      Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
       SCMBKeyBindingNode* theClassKeyBindNodeArray =
           (SCMBKeyBindingNode*)&((insthdr->theClass->cls.base)[idx]);
   
       SCMBKeyBindingValue* ptr =
           (SCMBKeyBindingValue*)
                _resolveDataPtr(insthdr->keyBindingArray,instbase);
  
     fprintf(_out,"\n\nInstance Key Bindings :");     fprintf(_out,"\n\nInstance Key Bindings :");
     fprintf(_out,"\n=======================");     fprintf(_out,"\n=======================");
Line 3031 
Line 5405 
  
     for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)     for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)
     {     {
           if (ptr[i].isSet)
           {
         fprintf(_out,"\n\nNo %u : '%s'",i,         fprintf(_out,"\n\nNo %u : '%s'",i,
                 NULLSTR(_getCharString(ptr[i],instbase)));                  (const char*)printUnionValue(
                       theClassKeyBindNodeArray[i].type,
                       ptr[i].data,
                       instbase).getCString());
           }
           else
           {
               fprintf(_out,"\n\nNo %u : Not Set",i);
   
           }
     }     }
     fprintf(_out,"\n");     fprintf(_out,"\n");
 } }
Line 3193 
Line 5578 
                nodeArray[i].nameHashTag,                nodeArray[i].nameHashTag,
                nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);                nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
  
         fprintf(_out,"\nKey binding type: %s",          fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));
                XmlWriter::keyBindingTypeToString(nodeArray[i].type).str);  
  
     }     }
  
Line 3338 
Line 5722 
      else      else
      {      {
          fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",          fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",
                 _qualifierNameStrLit[theQualifier.name].str);                  SCMOClass::qualifierNameStrLit(theQualifier.name).str);
      }      }
  
      fprintf(_out,"\nPropagated : %s",      fprintf(_out,"\nPropagated : %s",
Line 3355 
Line 5739 
     char* base) const     char* base) const
 { {
    fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));    fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));
    fprintf(_out,"\nValue was set by the provider: %s",     fprintf(_out,"\nValue was set: %s",
        (theValue.flags.isSet ? "True" : "False"));        (theValue.flags.isSet ? "True" : "False"));
    if (theValue.flags.isNull)    if (theValue.flags.isNull)
    {    {
Line 3367 
Line 5751 
        fprintf(_out,        fprintf(_out,
                "\nThe value is an Array of size: %u",                "\nThe value is an Array of size: %u",
                theValue.valueArraySize);                theValue.valueArraySize);
        fprintf(_out,"\nThe values are: '%s'",         fprintf(_out,"\nThe values are: %s",
               (const char*)printArrayValue(               (const char*)printArrayValue(
                   theValue.valueType,                   theValue.valueType,
                   theValue.valueArraySize,                   theValue.valueArraySize,
Line 3497 
Line 5881 
 { {
     Buffer out;     Buffer out;
  
       SCMBUnion* p;
       p = (SCMBUnion*)&(base[u.arrayValue.start]);
   
     switch (type)     switch (type)
     {     {
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
         {         {
             Boolean* p=(Boolean*)&(base[u._arrayValue.start]);  
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                 _toString(out,p[i]);                  out.append('\'');
                 out.append(' ');                  _toString(out,p[i].simple.val.bin);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:     case CIMTYPE_UINT8:
         {         {
             Uint8* p=(Uint8*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u8);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             Sint8* p=(Sint8*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
               {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s8);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:     case CIMTYPE_UINT16:
         {         {
             Uint16* p=(Uint16*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u16);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:     case CIMTYPE_SINT16:
         {         {
             Sint16* p=(Sint16*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s16);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
         {         {
             Uint32* p=(Uint32*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u32);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:     case CIMTYPE_SINT32:
         {         {
             Sint32* p=(Sint32*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s32);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:     case CIMTYPE_UINT64:
         {         {
             Uint64* p=(Uint64*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u64);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:     case CIMTYPE_SINT64:
         {         {
             Sint64* p=(Sint64*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s64);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             Real32* p=(Real32*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.r32);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             Real64* p=(Real64*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.r64);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             Char16* p=(Char16*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.c16);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             SCMBDataPtr* p = (SCMBDataPtr*)&(base[u._arrayValue.start]);              SCMBDataPtr* p = (SCMBDataPtr*)&(base[u.arrayValue.start]);
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                   if ( 0 != p[i].length)
                   {
                       out.append('\'');
                 out.append((const char*)_getCharString(p[i],base),                 out.append((const char*)_getCharString(p[i],base),
                            p[i].length-1);                            p[i].length-1);
                 out.append(' ');                      out.append('\'');
                   }
                   else
                   {
                     out << STRLIT("NULL;");
                   }
                   out.append(';');
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             SCMBDateTime* p = (SCMBDateTime*)&(base[u._arrayValue.start]);              SCMBDateTime* p = (SCMBDateTime*)&(base[u.arrayValue.start]);
             CIMDateTime x;             CIMDateTime x;
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
Line 3613 
Line 6101 
         }         }
  
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
         {  
             break;  
         }  
   
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
         {  
             break;  
         }  
   
     case CIMTYPE_INSTANCE:     case CIMTYPE_INSTANCE:
         {         {
               // TODO: has to dump SCMOInstance ...
             break;             break;
         }         }
     default:     default:
         {         {
             PEGASUS_ASSERT(0);              PEGASUS_ASSERT(false);
               break;
         }         }
     }     }
  
Line 3647 
Line 6129 
     {     {
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
         {         {
             _toString(out,u._booleanValue);              _toString(out,u.simple.val.bin);
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:     case CIMTYPE_UINT8:
         {         {
             _toString(out,u._uint8Value);              _toString(out,u.simple.val.u8);
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             _toString(out,u._sint8Value);              _toString(out,u.simple.val.s8);
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:     case CIMTYPE_UINT16:
         {         {
             _toString(out,(Uint32)u._uint16Value);              _toString(out,(Uint32)u.simple.val.u16);
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:     case CIMTYPE_SINT16:
         {         {
             _toString(out,u._sint16Value);              _toString(out,u.simple.val.s16);
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
         {         {
             _toString(out,u._uint32Value);              _toString(out,u.simple.val.u32);
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:     case CIMTYPE_SINT32:
         {         {
             _toString(out,u._sint32Value);              _toString(out,u.simple.val.s32);
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:     case CIMTYPE_UINT64:
         {         {
             _toString(out,u._uint64Value);              _toString(out,u.simple.val.u64);
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:     case CIMTYPE_SINT64:
         {         {
             _toString(out,u._sint64Value);              _toString(out,u.simple.val.s64);
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             _toString(out,u._real32Value);              _toString(out,u.simple.val.r32);
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             _toString(out,u._real32Value);              _toString(out,u.simple.val.r32);
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             _toString(out,u._char16Value);              _toString(out,u.simple.val.c16);
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             out.append((const char*)_getCharString(u._stringValue,base),              if ( 0 != u.stringValue.length)
                        u._stringValue.length-1);              {
                   out.append((const char*)_getCharString(u.stringValue,base),
                              u.stringValue.length-1);
               }
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             CIMDateTime x;             CIMDateTime x;
             memcpy(x._rep,&(u._dateTimeValue),sizeof(SCMBDateTime));              memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime));
             _toString(out,x);             _toString(out,x);
             break;             break;
         }         }
  
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
         {  
             break;  
         }  
   
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
         {  
             break;  
         }  
   
     case CIMTYPE_INSTANCE:     case CIMTYPE_INSTANCE:
         {         {
               // TODO: Has to dump SCMOInstance.
             break;             break;
         }         }
     default:     default:
         {         {
             PEGASUS_ASSERT(0);              PEGASUS_ASSERT(false);
               break;
         }         }
     }     }
  
Line 3760 
Line 6239 
  * The constant functions  * The constant functions
  *****************************************************************************/  *****************************************************************************/
  
 static const void* _resolveDataPtr(  static Boolean _equalUTF8Strings(
     const SCMBDataPtr& ptr,      const SCMBDataPtr& ptr_a,
     char* base)      char* base,
 {      const char* name,
     return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start])));      Uint32 len)
 }  
  
 PEGASUS_COMMON_LINKAGE const char* _getCharString(  
     const SCMBDataPtr& ptr,  
     char* base)  
 { {
     return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start])));      // size without trailing '\0' !!
       if (ptr_a.length-1 != len)
       {
           return false;
 } }
       const char* a = (const char*)_getCharString(ptr_a,base);
  
       // lets do a loop-unrolling optimized compare here
 static Uint32 _generateSCMOStringTag(      while (len >= 8)
     const SCMBDataPtr& ptr,  
     char* base)  
 { {
     // The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'.          if ((a[0] - name[0]) || (a[1] - name[1]) ||
     return _generateStringTag(_getCharString(ptr,base),ptr.length-1);              (a[2] - name[2]) || (a[3] - name[3]) ||
               (a[4] - name[4]) || (a[5] - name[5]) ||
               (a[6] - name[6]) || (a[7] - name[7]))
           {
               return false;
 } }
           len -= 8;
 static Uint32 _generateStringTag(const char* str, Uint32 len)          a += 8;
           name += 8;
       }
       while (len >= 4)
 { {
     if (len == 0)          if ((a[0] - name[0]) || (a[1] - name[1]) ||
               (a[2] - name[2]) || (a[3] - name[3]))
     {     {
         return 0;              return false;
     }     }
     return          len -= 4;
         (Uint32(CharSet::toUpperHash(str[0]) << 1) |          a += 4;
         Uint32(CharSet::toUpperHash(str[len-1])));          name += 4;
 } }
       while (len--)
 static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType)  
 { {
     switch (cimType)          if (a[0] - name[0])
     {     {
     case CIMTYPE_BOOLEAN:              return false;
         return(CIMKeyBinding::BOOLEAN);          }
         break;          a++;
     case CIMTYPE_CHAR16:          name++;
     case CIMTYPE_STRING:  
     case CIMTYPE_DATETIME:  
         return(CIMKeyBinding::STRING);  
         break;  
     case CIMTYPE_REFERENCE:  
         return(CIMKeyBinding::REFERENCE);  
         break;  
     case CIMTYPE_OBJECT:  
     case CIMTYPE_INSTANCE:  
         // From PEP 194: EmbeddedObjects cannot be keys.  
         throw TypeMismatchException();  
         break;  
     default:  
         return(CIMKeyBinding::NUMERIC);  
         break;  
     }     }
       return true;
 } }
  
 static Boolean _equalUTF8Strings(  
   static Boolean _equalNoCaseUTF8Strings(
     const SCMBDataPtr& ptr_a,     const SCMBDataPtr& ptr_a,
     char* base,     char* base,
     const char* name,     const char* name,
     Uint32 len)     Uint32 len)
  
 { {
   
       //both are empty strings, so they are equal.
       if (ptr_a.length == 0 && len == 0)
       {
           return true;
       }
   
     // size without trailing '\0' !!     // size without trailing '\0' !!
     if (ptr_a.length-1 != len)     if (ptr_a.length-1 != len)
     {     {
Line 3835 
Line 6313 
  
     const char* a = (const char*)_getCharString(ptr_a,base);     const char* a = (const char*)_getCharString(ptr_a,base);
  
     // ToDo: Here an UTF8 complinet comparison should take place  #ifdef PEGASUS_HAS_ICU
     return ( strncmp(a,name,len )== 0 );      return ( _utf8ICUncasecmp(a,name,len)== 0);
   #else
       return ( strncasecmp(a,name,len )== 0 );
   #endif
 } }
  
 static Boolean _equalNoCaseUTF8Strings(  #ifdef PEGASUS_HAS_ICU
     const SCMBDataPtr& ptr_a,  static Uint32 _utf8ICUncasecmp(
     char* base,      const char* a,
     const char* name,      const char* b,
     Uint32 len)     Uint32 len)
   
 { {
     // size without trailing '\0' !!      UErrorCode errorCode=U_ZERO_ERROR;
     if (ptr_a.length-1 != len)  
       Uint32 rc, a16len,b16len,utf16BufLen;
       utf16BufLen = (len*sizeof(UChar))+2;
   
       UChar* a_UTF16 = (UChar*)malloc(utf16BufLen);
       UChar* b_UTF16 = (UChar*)malloc(utf16BufLen);
   
       UConverter *conv = ucnv_open(0, &errorCode);
       if(U_FAILURE(errorCode))
       {
           free(a_UTF16);
           free(b_UTF16);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not open ICU default converter!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&errorCode);
   
       if(U_FAILURE(errorCode))
     {     {
         return false;          free(a_UTF16);
           free(b_UTF16);
           ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not convert string a:'");
           message.append(String(a,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
     }     }
  
     const char* a = (const char*)_getCharString(ptr_a,base);      b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&errorCode);
  
     // ToDo: Here an UTF8 complinet comparison should take place      if(U_FAILURE(errorCode))
     return ( strncasecmp(a,name,len )== 0 );      {
           free(a_UTF16);
           free(b_UTF16);
           ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not convert string b:'");
           message.append(String(b,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
       }
  
       rc = u_strCaseCompare(
           a_UTF16,a16len,
           b_UTF16,b16len,
           U_FOLD_CASE_DEFAULT,
           &errorCode);
   
       if(U_FAILURE(errorCode))
       {
           free(a_UTF16);
           free(b_UTF16);
           ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not compare string a:'");
           message.append(String(a,len));
           message.append("' with b: '");
           message.append(String(b,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
 } }
  
       free(a_UTF16);
       free(b_UTF16);
       ucnv_close(conv);
   
       return(rc);
   }
   #endif
  
 /** /**
  * This function calcutates a free memory slot in the single chunk memory block.  * This function calcutates a free memory slot in the single chunk memory block.
Line 3902 
Line 6445 
         // reallocate the buffer, double the space !         // reallocate the buffer, double the space !
         // This is a working approach until a better algorithm is found.         // This is a working approach until a better algorithm is found.
         (*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2);         (*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2);
         if ((*pmem) == NULL)          if ((*pmem) == 0)
         {         {
             // Not enough memory!             // Not enough memory!
             throw PEGASUS_STD(bad_alloc)();             throw PEGASUS_STD(bad_alloc)();
         }         }
         // increase the total size and free space         // increase the total size and free space
         (*pmem)->freeBytes= (*pmem)->freeBytes + oldSize;          (*pmem)->freeBytes+=oldSize;
         (*pmem)->totalSize= (*pmem)->totalSize + oldSize;          (*pmem)->totalSize+=oldSize;
     }     }
  
     (*pmem)->freeBytes = (*pmem)->freeBytes - size;      (*pmem)->freeBytes -= size;
     (*pmem)->startOfFreeSpace = (*pmem)->startOfFreeSpace + size;      (*pmem)->startOfFreeSpace += size;
  
     if (clear)     if (clear)
     {     {
Line 3962 
Line 6505 
 { {
  
     // If buffer is not empty.     // If buffer is not empty.
     if (bufferSize != 1)      if (bufferSize != 1 && theBuffer != 0)
     {     {
  
         Uint64 start;         Uint64 start;
Line 3983 
Line 6526 
     }     }
 } }
  
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2.2.13  
changed lines
  Added in v.1.2.2.38

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2