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

Diff for /pegasus/src/Pegasus/Common/CIMObjectPath.cpp between version 1.32 and 1.33

version 1.32, 2003/11/11 22:22:41 version 1.33, 2003/11/11 22:53:31
Line 315 
Line 315 
  
 Boolean operator==(const CIMKeyBinding& x, const CIMKeyBinding& y) Boolean operator==(const CIMKeyBinding& x, const CIMKeyBinding& y)
 { {
     return      // Check that the names and types match
         x.getName().equal(y.getName()) &&      if (!(x.getName().equal(y.getName())) ||
         String::equal(x.getValue(), y.getValue()) &&          !(x.getType() == y.getType()))
         x.getType() == y.getType();      {
           return false;
       }
   
       switch (x.getType())
       {
       case CIMKeyBinding::REFERENCE:
           try
           {
               // References should be compared as CIMObjectPaths
               return (CIMObjectPath(x.getValue()) == CIMObjectPath(y.getValue()));
           }
           catch (Exception&)
           {
               // If CIMObjectPath parsing fails, just compare strings
               return (String::equal(x.getValue(), y.getValue()));
           }
           break;
       case CIMKeyBinding::BOOLEAN:
           // Case-insensitive comparison is sufficient for booleans
           return (String::equalNoCase(x.getValue(), y.getValue()));
           break;
       case CIMKeyBinding::NUMERIC:
           // Note: This comparison assumes XML syntax for integers
           // First try comparing as unsigned integers
           {
               Uint64 xValue;
               Uint64 yValue;
               if (XmlReader::stringToUnsignedInteger(
                       x.getValue().getCString(), xValue) &&
                   XmlReader::stringToUnsignedInteger(
                       y.getValue().getCString(), yValue))
               {
                   return (xValue == yValue);
               }
           }
           // Next try comparing as signed integers
           {
               Sint64 xValue;
               Sint64 yValue;
               if (XmlReader::stringToSignedInteger(
                       x.getValue().getCString(), xValue) &&
                   XmlReader::stringToSignedInteger(
                       y.getValue().getCString(), yValue))
               {
                   return (xValue == yValue);
               }
           }
           // Note: Keys may not be real values, so don't try comparing as reals
           // We couldn't parse the numbers, so just compare the strings
           return (String::equal(x.getValue(), y.getValue()));
           break;
       default:  // CIMKeyBinding::STRING
           return (String::equal(x.getValue(), y.getValue()));
           break;
       }
   
       PEGASUS_UNREACHABLE(return false;)
 } }
  
  
Line 901 
Line 958 
 { {
     CIMObjectPath ref = *this;     CIMObjectPath ref = *this;
  
     // ATTN-RK-P2-20020510: Need to make hostname and namespace lower case?      // Normalize hostname by changing to lower case
       ref._rep->_host.toLower(); // ICU_TODO:
  
       // Normalize namespace by changing to lower case
       if (!ref._rep->_nameSpace.isNull())
       {
           String nameSpaceLower = ref._rep->_nameSpace.getString();
           nameSpaceLower.toLower(); // ICU_TODO:
           ref._rep->_nameSpace = nameSpaceLower;
       }
   
       // Normalize class name by changing to lower case
       if (!ref._rep->_className.isNull())
       {
     String classNameLower = ref._rep->_className.getString ();     String classNameLower = ref._rep->_className.getString ();
     classNameLower.toLower(); // ICU_TODO:     classNameLower.toLower(); // ICU_TODO:
     ref._rep->_className = classNameLower;     ref._rep->_className = classNameLower;
       }
  
     for (Uint32 i = 0, n = ref._rep->_keyBindings.size(); i < n; i++)     for (Uint32 i = 0, n = ref._rep->_keyBindings.size(); i < n; i++)
     {     {
           // Normalize key binding name by changing to lower case
           if (!ref._rep->_keyBindings[i]._rep->_name.isNull())
           {
         String keyBindingNameLower =         String keyBindingNameLower =
             ref._rep->_keyBindings[i]._rep->_name.getString ();             ref._rep->_keyBindings[i]._rep->_name.getString ();
         keyBindingNameLower.toLower();              keyBindingNameLower.toLower(); // ICU_TODO:
         ref._rep->_keyBindings[i]._rep->_name = keyBindingNameLower;         ref._rep->_keyBindings[i]._rep->_name = keyBindingNameLower;
     }     }
  
     // ATTN-RK-20020826: Need to sort keys?          // Normalize the key value
           switch (ref._rep->_keyBindings[i]._rep->_type)
           {
           case CIMKeyBinding::REFERENCE:
               try
               {
                   // Convert reference to CIMObjectPath and recurse
                   ref._rep->_keyBindings[i]._rep->_value =
                       CIMObjectPath(ref._rep->_keyBindings[i]._rep->_value).
                           _toStringCanonical();
               }
               catch (Exception&)
               {
                   // Leave value unchanged if the CIMObjectPath parsing fails
               }
               break;
           case CIMKeyBinding::BOOLEAN:
               // Normalize the boolean string by changing to lower case
               ref._rep->_keyBindings[i]._rep->_value.toLower(); // ICU_TODO:
               break;
           case CIMKeyBinding::NUMERIC:
               // Normalize the numeric string by converting to integer and back
               Uint64 uValue;
               Sint64 sValue;
               // First try converting to unsigned integer
               if (XmlReader::stringToUnsignedInteger(
                       ref._rep->_keyBindings[i]._rep->_value.getCString(),
                           uValue))
               {
                   char buffer[32];  // Should need 21 chars max
                   sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", uValue);
                   ref._rep->_keyBindings[i]._rep->_value = String(buffer);
               }
               // Next try converting to signed integer
               else if (XmlReader::stringToSignedInteger(
                            ref._rep->_keyBindings[i]._rep->_value.getCString(),
                                sValue))
               {
                   char buffer[32];  // Should need 21 chars max
                   sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", sValue);
                   ref._rep->_keyBindings[i]._rep->_value = String(buffer);
               }
               // Leave value unchanged if it cannot be converted to an integer
               break;
           default:  // CIMKeyBinding::STRING
               // No normalization required for STRING
               break;
           }
       }
   
       // Note: key bindings are sorted when set in the CIMObjectPath
  
     return ref.toString();     return ref.toString();
 } }
Line 923 
Line 1046 
 Boolean CIMObjectPath::identical(const CIMObjectPath& x) const Boolean CIMObjectPath::identical(const CIMObjectPath& x) const
 { {
     return     return
         String::equal(_rep->_host, x._rep->_host) &&          String::equalNoCase(_rep->_host, x._rep->_host) &&
         _rep->_nameSpace.equal(x._rep->_nameSpace) &&         _rep->_nameSpace.equal(x._rep->_nameSpace) &&
         _rep->_className.equal(x._rep->_className) &&         _rep->_className.equal(x._rep->_className) &&
         _rep->_keyBindings == x._rep->_keyBindings;         _rep->_keyBindings == x._rep->_keyBindings;


Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2