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

   1 martin 1.34 //%LICENSE////////////////////////////////////////////////////////////////
   2 martin 1.35 //
   3 martin 1.34 // Licensed to The Open Group (TOG) under one or more contributor license
   4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   5             // this work for additional information regarding copyright ownership.
   6             // Each contributor licenses this file to you under the OpenPegasus Open
   7             // Source License; you may not use this file except in compliance with the
   8             // License.
   9 martin 1.35 //
  10 martin 1.34 // Permission is hereby granted, free of charge, to any person obtaining a
  11             // copy of this software and associated documentation files (the "Software"),
  12             // to deal in the Software without restriction, including without limitation
  13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14             // and/or sell copies of the Software, and to permit persons to whom the
  15             // Software is furnished to do so, subject to the following conditions:
  16 martin 1.35 //
  17 martin 1.34 // The above copyright notice and this permission notice shall be included
  18             // in all copies or substantial portions of the Software.
  19 martin 1.35 //
  20 martin 1.34 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21 martin 1.35 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22 martin 1.34 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27 martin 1.35 //
  28 martin 1.34 //////////////////////////////////////////////////////////////////////////
  29 chuck  1.2  //
  30             //%/////////////////////////////////////////////////////////////////////////////
  31             #include <Pegasus/CQL/CQLValue.h>
  32             #include <Pegasus/CQL/CQLValueRep.h>
  33             #include <Pegasus/Repository/NameSpaceManager.h>
  34             #include <Pegasus/Common/CIMClass.h>
  35             #include <Pegasus/Common/Tracer.h>
  36             #include <Pegasus/CQL/CQLIdentifier.h>
  37             #include <Pegasus/CQL/CQLRegularExpression.h>
  38             #include <Pegasus/CQL/CQLFactory.h>
  39             #include <Pegasus/Query/QueryCommon/QueryException.h>
  40 david  1.4  #include <Pegasus/CQL/CQLUtilities.h>
  41 chuck  1.2  
  42             
  43             PEGASUS_NAMESPACE_BEGIN
  44             PEGASUS_USING_STD;
  45             
  46             /*
  47             #define PEGASUS_ARRAY_T CQLValueRep
  48             #include <Pegasus/Common/ArrayImpl.h>
  49             #undef PEGASUS_ARRAY_T
  50             */
  51             
  52             #define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000))
  53             #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF)
  54 david  1.8  
  55 chuck  1.2  
  56             CQLValueRep::CQLValueRep()
  57 venkat.puvvada 1.32   :_theValue(),
  58                        _CQLChainId(),
  59                        _isResolved(false),
  60                        _valueType(CQLValue::Boolean_type)
  61 chuck          1.2  {
  62                     }
  63                     
  64                     CQLValueRep::~CQLValueRep()
  65                     {
  66                     
  67                     }
  68                     
  69                     
  70 humberto       1.16 CQLValueRep::CQLValueRep(const CQLValueRep& val):
  71                      _theValue(val._theValue),
  72                      _CQLChainId(val._CQLChainId),
  73                      _isResolved(val._isResolved),
  74                      _valueType(val._valueType),
  75                      _ArrayType(val._ArrayType)
  76 chuck          1.2  {
  77 kumpf          1.36 
  78 chuck          1.2  }
  79                     
  80 humberto       1.16 CQLValueRep::CQLValueRep(const CQLValueRep* val):
  81                      _theValue(val->_theValue),
  82                      _CQLChainId(val->_CQLChainId),
  83                      _isResolved(val->_isResolved),
  84                      _valueType(val->_valueType),
  85                      _ArrayType(val->_ArrayType)
  86 chuck          1.2  {
  87                     }
  88                     
  89 kumpf          1.36 CQLValueRep::CQLValueRep(const String& inString,
  90 karl           1.26                          CQLValue::NumericType inValueType, Boolean inSign)
  91 chuck          1.2  {
  92                        PEG_METHOD_ENTER(TRC_CQL, "CQLValueRep::CQLValueRep()");
  93                     
  94                        switch(inValueType)
  95                        {
  96 david          1.4     case CQLValue::Hex:
  97                          {
  98 david          1.7         String tmp(inString);
  99 david          1.4         if(inSign)
 100 karl           1.26      {
 101                            _theValue.set(CQLUtilities::stringToUint64(tmp));
 102                            _valueType = CQLValue::Uint64_type;
 103                          }
 104 david          1.4         else
 105 karl           1.26      {
 106                            _theValue.set(CQLUtilities::stringToSint64(inString));
 107                            _valueType = CQLValue::Sint64_type;
 108                          }
 109 david          1.4       }
 110                          break;
 111                        case CQLValue::Binary:
 112                          {
 113 david          1.7         String tmp(inString);;
 114 david          1.4         if(inSign)
 115 karl           1.26      {
 116                            _theValue.set(CQLUtilities::stringToUint64(tmp));
 117                            _valueType = CQLValue::Uint64_type;
 118                          }
 119 david          1.4         else
 120 karl           1.26      {
 121                            _theValue.set(CQLUtilities::stringToSint64(tmp));
 122                            _valueType = CQLValue::Sint64_type;
 123                          }
 124 david          1.4         break;
 125                          }
 126                        case CQLValue::Decimal:
 127                          {
 128 david          1.7         String tmp(inString);
 129 david          1.4         if(inSign)
 130 karl           1.26      {
 131                            _theValue.set(CQLUtilities::stringToUint64(tmp));
 132                            _valueType = CQLValue::Uint64_type;
 133                          }
 134 david          1.4         else
 135 karl           1.26      {
 136                            _theValue.set(CQLUtilities::stringToSint64(tmp));
 137                            _valueType = CQLValue::Sint64_type;
 138                          }
 139 david          1.4       }
 140                          break;
 141                        case CQLValue::Real:
 142                          {
 143 david          1.7         String tmp(inString);
 144 humberto       1.16 
 145                            _theValue.set(CQLUtilities::stringToReal64(tmp));
 146                            _valueType = CQLValue::Real_type;
 147 david          1.4       }
 148                          break;
 149                        default:
 150 kumpf          1.29      MessageLoaderParms mload(
 151                              "CQL.CQLValueRep.CONSTRUCTOR_FAILURE",
 152                              "Undefined case:$0 in constructor.",
 153                              inValueType);
 154 david          1.4       throw CQLRuntimeException(mload);
 155 kumpf          1.36 
 156 david          1.4       break;
 157 chuck          1.2     }
 158 kumpf          1.36 
 159 chuck          1.2     _isResolved = true;
 160 kumpf          1.36 
 161 chuck          1.2     PEG_METHOD_EXIT();
 162                     }
 163                     
 164                     
 165                     CQLValueRep::CQLValueRep(const CQLChainedIdentifier& inCQLIdent)
 166 kumpf          1.36   : _CQLChainId(inCQLIdent),
 167 chuck          1.2      _isResolved(false),
 168                         _valueType(CQLValue::CQLIdentifier_type)
 169                     {
 170 kumpf          1.36 
 171 chuck          1.2  }
 172                     
 173                     
 174                     CQLValueRep::CQLValueRep(const String& inString)
 175 kumpf          1.36   : _isResolved(true),
 176 chuck          1.2      _valueType(CQLValue::String_type)
 177                     {
 178                        _theValue.set(inString);
 179                     }
 180                     
 181                     CQLValueRep::CQLValueRep(const CIMInstance& inInstance)
 182                       : _isResolved(true),
 183                         _valueType(CQLValue::CIMObject_type)
 184                     {
 185 david          1.5    _theValue.set((CIMObject)inInstance);
 186 chuck          1.2  }
 187                     
 188                     CQLValueRep::CQLValueRep(const CIMClass& inClass)
 189                       : _isResolved(true),
 190                         _valueType(CQLValue::CIMObject_type)
 191                     {
 192 david          1.5    _theValue.set((CIMObject)inClass);
 193 chuck          1.2  }
 194                     
 195                     CQLValueRep::CQLValueRep(const CIMObject& inObject)
 196                       : _isResolved(true),
 197                         _valueType(CQLValue::CIMObject_type)
 198                     {
 199 david          1.6    _theValue.set((CIMObject)inObject);
 200 chuck          1.2  }
 201                     
 202                     CQLValueRep::CQLValueRep(const CIMObjectPath& inObjPath)
 203                       : _isResolved(true),
 204                         _valueType(CQLValue::CIMReference_type)
 205                     {
 206                        _theValue.set(inObjPath);
 207                     }
 208                     
 209                     CQLValueRep::CQLValueRep(const CIMDateTime& inDateTime)
 210                       : _isResolved(true),
 211                         _valueType(CQLValue::CIMDateTime_type)
 212                     {
 213                        _theValue.set(inDateTime);
 214                     }
 215                     
 216                     CQLValueRep::CQLValueRep(Uint64 inUint)
 217                       : _isResolved(true),
 218                         _valueType(CQLValue::Uint64_type)
 219                     {
 220                        _theValue.set(inUint);
 221 chuck          1.2  }
 222                     
 223                     CQLValueRep::CQLValueRep(Boolean inBool)
 224                       : _isResolved(true),
 225                         _valueType(CQLValue::Boolean_type)
 226                     {
 227                        _theValue.set(inBool);
 228                     }
 229                     
 230                     CQLValueRep::CQLValueRep(Sint64 inSint)
 231                       : _isResolved(true),
 232                         _valueType(CQLValue::Sint64_type)
 233                     {
 234                        _theValue.set(inSint);
 235                     }
 236                     
 237                     CQLValueRep::CQLValueRep(Real64 inReal)
 238                       : _isResolved(true),
 239                         _valueType(CQLValue::Real_type)
 240                     {
 241                        _theValue.set(inReal);
 242 chuck          1.2  }
 243                     
 244                     CQLValueRep::CQLValueRep(const CIMValue& inVal)
 245 humberto       1.16   : _isResolved(true)
 246 chuck          1.2  {
 247 humberto       1.16   // _valueType is set by _setValue
 248 chuck          1.2    _setValue(inVal);
 249                     }
 250                     
 251 kumpf          1.36 void CQLValueRep::resolve(const CIMInstance& CI,
 252 karl           1.26                           const  QueryContext& inQueryCtx)
 253 kumpf          1.36 {
 254 chuck          1.2    if(_CQLChainId.size() == 0)
 255                         {
 256                           return;
 257                         }
 258                     
 259 kumpf          1.36 
 260                       Array<CQLIdentifier> Idstrings =
 261 chuck          1.2      _CQLChainId.getSubIdentifiers(); // Array of Identifiers to process
 262 humberto       1.16   Uint32 IdSize = Idstrings.size();
 263 chuck          1.2    Uint32 index = 0;                // Counter for looping through Identifiers
 264 kumpf          1.36   CIMProperty propObj;
 265                     
 266 humberto       1.16   if(IdSize == 1)
 267 chuck          1.2      {
 268                           // A class was passed in with no property indicated.
 269                           // Set the instance passed in, as a primitive.
 270 david          1.5         _theValue.set((CIMObject)CI);
 271 chuck          1.2        _valueType = CQLValue::CIMObject_type;
 272                           _isResolved = true;
 273                           return; // Done.
 274                         }
 275                       else
 276                         {
 277                           // Symbolic Constant processing
 278                           if(_CQLChainId.getLastIdentifier().isSymbolicConstant() &&
 279 karl           1.26      IdSize == 2)
 280                         {
 281                           _resolveSymbolicConstant(inQueryCtx);
 282                           return;
 283                         }
 284 kumpf          1.36 
 285 chuck          1.2        // Need to increment index since the first Identifier is a class,
 286                           // and additional identifiers need processing.
 287                           ++index;
 288                          }
 289 kumpf          1.36 
 290 chuck          1.2    CIMName classContext = Idstrings[0].getName();
 291                       CIMObject objectContext = CI;
 292 kumpf          1.36 
 293 venkat.puvvada 1.32   _theValue = CIMValue();
 294                     
 295 humberto       1.16   for(;index < IdSize; ++index)
 296 chuck          1.2      {
 297                           // Now we need to verify that the property is in the class.
 298 karl           1.26       Uint32 propertyIndex = objectContext.findProperty(
 299                                   Idstrings[index].getName());
 300 kumpf          1.36 
 301 chuck          1.2        if(propertyIndex == PEG_NOT_FOUND)
 302 karl           1.26     {
 303                           _isResolved = true;
 304                           return;
 305                         }
 306 kumpf          1.36 
 307                           // We will check the property type to determine what processing
 308 chuck          1.2        // needs to be done.
 309                           propObj = objectContext.getProperty(propertyIndex);
 310                     
 311 david          1.12       try
 312 karl           1.26     {
 313 kumpf          1.36       if((Idstrings[index].isScoped() &&
 314 karl           1.26         inQueryCtx.getClassRelation(Idstrings[index].getScope(),
 315                                 objectContext.getClassName())
 316 kumpf          1.36             == QueryContext::NOTRELATED) ||
 317 karl           1.26          (Idstrings[index].isScoped() && inQueryCtx.getClassRelation(
 318                                 Idstrings[index].getScope(),objectContext.getClassName())
 319 kumpf          1.36             == QueryContext::SUPERCLASS))
 320 karl           1.26         {
 321                               // The chain is not inline with scope.
 322 venkat.puvvada 1.32           _isResolved = true;
 323 karl           1.26           return;
 324                             }
 325                         }
 326 david.dillard  1.21       catch(const CIMException &)
 327 karl           1.26     {
 328                           // The chain is not inline with scope.
 329 venkat.puvvada 1.32       _isResolved = true;
 330 karl           1.26       return;
 331                         }
 332 kumpf          1.36     CIMType propObjType = propObj.getType();
 333 a.dunfey       1.25     if(index == IdSize-1)
 334                         {
 335                             _process_value(propObj,Idstrings[index],inQueryCtx);
 336                             return;
 337                         }
 338                         else if((propObjType != CIMTYPE_OBJECT &&
 339                             propObjType != CIMTYPE_INSTANCE) ||
 340                             (propObj.getValue().isNull()))
 341                         {
 342                             // Object is not embedded.
 343                             _isResolved = true;
 344                             return;
 345                         }
 346                         CIMValue propValue = propObj.getValue();
 347                         // If the property is an embeddedInstance, convert to an object
 348                         if(propObjType == CIMTYPE_INSTANCE)
 349                         {
 350                             CIMInstance tmpInst;
 351                             propValue.get(tmpInst);
 352                             propValue = CIMValue((CIMObject)tmpInst);
 353                         }
 354 a.dunfey       1.25     propValue.get(objectContext);
 355 karl           1.26         if(!objectContext.isInstance())
 356                             {
 357                                 MessageLoaderParms mparms(
 358                                     "CQL.CQLValueRep.OBJECT_CONTEXT_NOT_INSTANCE",
 359                                     "The object context $0 is not an instance.",
 360                                     objectContext.getClassName().getString());
 361                                 throw CQLRuntimeException(mparms);
 362                             }
 363 david          1.5        classContext = objectContext.getClassName();
 364 kumpf          1.36     }
 365 chuck          1.2  } // end of function
 366                     
 367                     void CQLValueRep::_process_value(CIMProperty& propObj,
 368 karl           1.26                  CQLIdentifier& _id,
 369                                      const QueryContext& inQueryCtx)
 370 chuck          1.2  {
 371 kumpf          1.36   if(propObj.getType() == CIMTYPE_OBJECT)
 372 chuck          1.2      {
 373                           CIMObject cimObj;
 374                           propObj.getValue().get(cimObj);
 375                     
 376 humberto       1.16       _theValue.set(cimObj.clone());
 377 chuck          1.2        _valueType = CQLValue::CIMObject_type;
 378 david          1.20       _isResolved = true;
 379 chuck          1.2      }
 380 kumpf          1.36   else if(propObj.getType() == CIMTYPE_INSTANCE)
 381 a.dunfey       1.25   {
 382                           CIMInstance cimInstance;
 383                           propObj.getValue().get(cimInstance);
 384                     
 385                           _theValue.set((CIMObject)cimInstance.clone());
 386                           _valueType = CQLValue::CIMObject_type;
 387                           _isResolved = true;
 388                       }
 389 chuck          1.2    else // Primitive
 390                         {
 391                           if(_id.isArray())
 392 karl           1.26     {
 393                           // We have an array property.  All we need to do
 394                           // Is get the index defined by CQLIdentifier.
 395                           // NOTE: Basic CQL support only allows one index.
 396                           _setValue(propObj.getValue(),
 397                                 _id.getSubRanges()[0].start);
 398                           return;
 399                         }
 400 chuck          1.2        else if(_id.isSymbolicConstant())
 401 karl           1.26     {
 402                           // Symbolic Constant processing
 403                           _resolveSymbolicConstant(inQueryCtx);
 404                           return;
 405                         }
 406 chuck          1.2        else
 407 karl           1.26     {
 408                           // The property has no special charactors.
 409                           if(propObj.isArray())
 410                             {
 411                               Uint32 qualIndex = propObj.findQualifier(
 412                                       CIMName(String("ArrayType")));
 413                               if(qualIndex == PEG_NOT_FOUND)
 414                             {
 415                               // Default Array type
 416                               _ArrayType = String("Indexed");
 417                             }
 418                               else
 419                             {
 420                               propObj.getQualifier(qualIndex).getValue().get(_ArrayType);
 421                             }
 422                             }
 423                           _setValue(propObj.getValue());
 424                           return;
 425                         }
 426 chuck          1.2      }
 427                     }
 428                     
 429                     CQLValueRep& CQLValueRep::operator=(const CQLValueRep& rhs)
 430                     {
 431                     
 432                       if(&rhs != this)
 433                         {
 434                           _valueType = rhs._valueType;
 435                           _theValue = rhs._theValue;
 436                           _CQLChainId = rhs._CQLChainId;
 437                           _isResolved = rhs._isResolved;
 438 humberto       1.16       _ArrayType = rhs._ArrayType;
 439 chuck          1.2      }
 440                       return *this;
 441                     }
 442                     Boolean CQLValueRep::operator==(const CQLValueRep& x)
 443                     {
 444                       PEG_METHOD_ENTER(TRC_CQL, "CQLValueRep::operator==");
 445 kumpf          1.36 
 446 chuck          1.2    _validate(x);
 447                     
 448 dave.sudlik    1.28   if(isNull() && x.isNull())
 449 humberto       1.16     {
 450                           return true;
 451                         }
 452 dave.sudlik    1.28   if(isNull() || x.isNull())
 453 humberto       1.16     {
 454                           return false;
 455                         }
 456 chuck          1.2    if(_theValue.isArray())
 457                         {
 458                           return _compareArray(x);
 459                         }
 460                       else if((_theValue.getType() == x._theValue.getType()) &&
 461                          (_valueType != CQLValue::CIMObject_type) &&
 462                          (_valueType != CQLValue::CQLIdentifier_type))
 463                         {
 464                           return _theValue == x._theValue;
 465                         }
 466                       else
 467                         {
 468                           Uint64 tmpU64;
 469                           Sint64 tmpS64;
 470                           Real64 tmpR64;
 471 kumpf          1.36 
 472 chuck          1.2        switch(_valueType)
 473 karl           1.26     {
 474                         case CQLValue::Sint64_type:
 475                           {
 476                             _theValue.get(tmpS64);
 477                             if(x._valueType == CQLValue::Uint64_type)
 478                               {
 479                             x._theValue.get(tmpU64);
 480 kumpf          1.36 
 481 karl           1.26         if(tmpU64 >= (Uint64)PEGASUS_SINT64_MIN)
 482                               {
 483                                 return false;
 484                               }
 485                             else
 486                               {
 487                                 return (Sint64)tmpU64 == tmpS64;
 488                               }
 489                               }
 490 kumpf          1.36         else
 491 karl           1.26           {
 492                             x._theValue.get(tmpR64);
 493 kumpf          1.36 
 494 karl           1.26         return tmpR64 == tmpS64;
 495                               }
 496                             break;
 497                           }
 498                         case CQLValue::Uint64_type:
 499                           {
 500                             _theValue.get(tmpU64);
 501                             if(x._valueType == CQLValue::Sint64_type)
 502                               {
 503                             x._theValue.get(tmpS64);
 504 kumpf          1.36 
 505 karl           1.26         if(tmpU64 >= (Uint64)PEGASUS_SINT64_MIN)
 506                               {
 507                                 return false;
 508                               }
 509                             else
 510                               {
 511                                 return (Sint64)tmpU64 == tmpS64;
 512                               }
 513                               }
 514 kumpf          1.36         else
 515 karl           1.26           {
 516                             x._theValue.get(tmpR64);
 517                             if(tmpU64 >= (Uint64)PEGASUS_SINT64_MIN)
 518                               {
 519                                 return false;
 520                               }
 521                             else
 522                               {
 523                                 return tmpR64 == (Sint64)tmpU64;
 524                               }
 525                               }
 526                             break;
 527                           }
 528                         case CQLValue::Real_type:
 529                           {
 530                             _theValue.get(tmpR64);
 531                             if(x._valueType == CQLValue::Uint64_type)
 532                               {
 533                             x._theValue.get(tmpU64);
 534 kumpf          1.36 
 535 karl           1.26         if(tmpU64 >= (Uint64)PEGASUS_SINT64_MIN)
 536                               {
 537                                 return false;
 538                               }
 539                             else
 540                               {
 541                                 return (Sint64)tmpU64 == tmpR64;
 542                               }
 543                               }
 544 kumpf          1.36         else
 545 karl           1.26           {
 546                             x._theValue.get(tmpS64);
 547 kumpf          1.36 
 548 karl           1.26         return tmpR64 == tmpS64;
 549                               }
 550                             break;
 551                           }
 552 kumpf          1.36     case CQLValue::CIMObject_type:
 553                           {
 554 karl           1.26         CIMObject objBase;
 555                             CIMObject objParm;
 556                             _theValue.get(objBase);
 557                             x._theValue.get(objParm);
 558 kumpf          1.36 
 559 karl           1.26         return _compareObjects(objBase,objParm);
 560 kumpf          1.36 
 561 karl           1.26       }
 562                           break;
 563 kumpf          1.36 
 564 karl           1.26     default:
 565 kumpf          1.29       MessageLoaderParms mload(
 566                               "CQL.CQLValueRep.CONSTRUCTOR_FAILURE",
 567                               "Undefined case:$0 in constructor.",
 568                               _valueType);
 569                           throw CQLRuntimeException(mload);
 570 karl           1.26       break;
 571                         }
 572 chuck          1.2        return false;
 573                         }
 574                     }
 575 kumpf          1.36 
 576 chuck          1.2  Boolean CQLValueRep::operator!=(const CQLValueRep& x)
 577                     {
 578                       return !(this->operator==(x));
 579                     }
 580                     
 581                     
 582                     Boolean CQLValueRep::operator<=(const CQLValueRep& x)
 583 kumpf          1.36 {
 584 chuck          1.2    if (this->operator<(x) || this->operator==(x))
 585                         {
 586                           return true;
 587                         }
 588 kumpf          1.36 
 589 chuck          1.2    return false;
 590                     }
 591                     
 592                     
 593                     Boolean CQLValueRep::operator>=(const CQLValueRep& x)
 594                     {
 595 kumpf          1.36    return !(this->operator<(x));
 596 chuck          1.2  }
 597                     
 598                     
 599                     Boolean CQLValueRep::operator<(const CQLValueRep& x)
 600                     {
 601                       PEG_METHOD_ENTER(TRC_CQL, "CQLValueRep::operator<");
 602                     
 603                       Uint64 tmpU64;
 604                       Sint64 tmpS64;
 605                       Real64 tmpR64;
 606 humberto       1.16 
 607                       _validate(x);
 608                     
 609                       if(_theValue.isNull() && x._theValue.isNull())
 610                         {
 611                           return true;
 612                         }
 613                       if(_theValue.isNull() || x._theValue.isNull())
 614                         {
 615                           return false;
 616                         }
 617                       if(_theValue.isArray() || x._theValue.isArray())
 618                         {
 619                           return false;
 620                         }
 621 kumpf          1.36 
 622 chuck          1.2    switch(_valueType)
 623                         {
 624                         case CQLValue::Sint64_type:
 625                           {
 626 karl           1.26     _theValue.get(tmpS64);
 627                         if(x._valueType == CQLValue::Sint64_type)
 628                           {
 629                             Sint64 right;
 630                             x._theValue.get(right);
 631 kumpf          1.36 
 632 karl           1.26         return tmpS64 < right;
 633                           }
 634                         else if(x._valueType == CQLValue::Uint64_type)
 635                           {
 636                             x._theValue.get(tmpU64);
 637 kumpf          1.36 
 638 karl           1.26         if(tmpU64 > (Uint64)PEGASUS_SINT64_MIN)
 639                               {
 640                             return true;
 641                               }
 642                             else
 643                               {
 644                             return tmpS64 < (Sint64)tmpU64;
 645                               }
 646                           }
 647 kumpf          1.36     else
 648 karl           1.26       {
 649                             x._theValue.get(tmpR64);
 650 kumpf          1.36 
 651 karl           1.26         return tmpS64 < tmpR64;
 652                           }
 653                         break;
 654 chuck          1.2        }
 655                         case CQLValue::Uint64_type:
 656                           {
 657 karl           1.26     _theValue.get(tmpU64);
 658                         if(x._valueType == CQLValue::Uint64_type)
 659                           {
 660                             Uint64 right;
 661                             x._theValue.get(right);
 662 kumpf          1.36 
 663 karl           1.26         return tmpU64 < right;
 664                           }
 665                         else if(x._valueType == CQLValue::Sint64_type)
 666                           {
 667                             x._theValue.get(tmpS64);
 668 kumpf          1.36 
 669 karl           1.26         if(tmpU64 > (Uint64)PEGASUS_SINT64_MIN)
 670                               {
 671                             return false;
 672                               }
 673                             else
 674                               {
 675                             return (Sint64)tmpU64 < tmpS64;
 676                               }
 677                           }
 678 kumpf          1.36     else
 679 karl           1.26       {
 680                             x._theValue.get(tmpR64);
 681                             if(tmpU64 > (Uint64)PEGASUS_SINT64_MIN)
 682                               {
 683                             return false;
 684                               }
 685                            else
 686                              {
 687                                return (Sint64)tmpU64 < tmpR64;
 688                              }
 689                           }
 690                         break;
 691 chuck          1.2        }
 692                         case CQLValue::Real_type:
 693                           {
 694 karl           1.26     _theValue.get(tmpR64);
 695                         if(x._valueType == CQLValue::Real_type)
 696                           {
 697                             Real64 right;
 698                             x._theValue.get(right);
 699 kumpf          1.36 
 700 karl           1.26         return tmpR64 < right;
 701                           }
 702                         else if(x._valueType == CQLValue::Uint64_type)
 703                           {
 704                             x._theValue.get(tmpU64);
 705 kumpf          1.36 
 706 karl           1.26         if(tmpU64 > (Uint64)PEGASUS_SINT64_MIN)
 707                               {
 708                             return true;
 709                               }
 710                             else
 711                               {
 712                             return tmpR64 < (Sint64)tmpU64;
 713                               }
 714                           }
 715 kumpf          1.36     else
 716 karl           1.26       {
 717                             x._theValue.get(tmpS64);
 718 kumpf          1.36 
 719 karl           1.26         return tmpR64 < tmpS64;
 720                           }
 721                         break;
 722 chuck          1.2        }
 723                         case CQLValue::String_type:
 724                           {
 725 karl           1.26     String tmpS1;
 726                         String tmpS2;
 727                         _theValue.get(tmpS1);
 728                         x._theValue.get(tmpS2);
 729                         return tmpS1 < tmpS2;
 730 chuck          1.2        }
 731                           break;
 732 kumpf          1.36     case CQLValue::CIMDateTime_type:
 733 chuck          1.2        {
 734 karl           1.26     CIMDateTime tmpS1;
 735                         CIMDateTime tmpS2;
 736                         _theValue.get(tmpS1);
 737                         x._theValue.get(tmpS2);
 738                         return tmpS1 < tmpS2;
 739 chuck          1.2        }
 740                           break;
 741                     
 742                         default:
 743 kumpf          1.29       MessageLoaderParms mload(
 744                               "CQL.CQLValueRep.CONSTRUCTOR_FAILURE",
 745                               "Undefined case: $0 in constructor.");
 746                           throw CQLRuntimeException(mload);
 747 chuck          1.2        break;
 748                         }
 749                       PEG_METHOD_EXIT();
 750                       return false;
 751                     }
 752                     
 753                     
 754                     Boolean CQLValueRep::operator>(const CQLValueRep& x)
 755                     {
 756                        _validate(x);
 757 kumpf          1.36 
 758 chuck          1.2     if (this->operator<(x) || this->operator==(x))
 759                          {
 760                            return false;
 761 kumpf          1.36      }
 762 chuck          1.2     return true;
 763                     }
 764                     
 765                     
 766                     CQLValueRep CQLValueRep::operator+(const CQLValueRep x)
 767                     {
 768                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::operator+");
 769 kumpf          1.36    _validate(x);
 770 chuck          1.2  
 771                        switch(_valueType)
 772                          {
 773                          case CQLValue::String_type:
 774                            {
 775 karl           1.26      String tmpS1;
 776                          String tmpS2;
 777                          _theValue.get(tmpS1);
 778                          x._theValue.get(tmpS2);
 779                          return CQLValueRep(tmpS1 + tmpS2);
 780 chuck          1.2         }
 781                            break;
 782 kumpf          1.36 
 783 chuck          1.2       default:
 784 kumpf          1.29        MessageLoaderParms mload(
 785                                "CQL.CQLValueRep.CONSTRUCTOR_FAILURE",
 786                                "Undefined case:$0 in constructor.",
 787 karl           1.26            _valueType);
 788 chuck          1.2         throw CQLRuntimeException(mload);
 789                            break;
 790                          }
 791                     
 792                        PEG_METHOD_EXIT();
 793                        return x;
 794                     }
 795                     
 796                     CQLValue::CQLValueType CQLValueRep::getValueType()
 797                     {
 798 dave.sudlik    1.28     return _valueType;
 799 chuck          1.2  }
 800                     
 801 venkat.puvvada 1.32 CQLValue::CQLValueType CQLValueRep::_getCQLType(const CIMType &type) const
 802 dave.sudlik    1.28 {
 803                         switch (type)
 804                         {
 805                             case CIMTYPE_BOOLEAN:
 806                                 return CQLValue::Boolean_type;
 807                     
 808                             case CIMTYPE_UINT8:
 809                             case CIMTYPE_UINT16:
 810                             case CIMTYPE_UINT32:
 811                             case CIMTYPE_UINT64:
 812                                 return CQLValue::Uint64_type;
 813                     
 814                             case CIMTYPE_SINT8:
 815                             case CIMTYPE_SINT16:
 816                             case CIMTYPE_SINT32:
 817                             case CIMTYPE_SINT64:
 818                                 return CQLValue::Sint64_type;
 819                     
 820                             case CIMTYPE_REAL32:
 821                             case CIMTYPE_REAL64:
 822                                 return CQLValue::Real_type;
 823 dave.sudlik    1.28 
 824                             case CIMTYPE_CHAR16:
 825                             case CIMTYPE_STRING:
 826                                 return CQLValue::String_type;
 827 chuck          1.2  
 828 dave.sudlik    1.28         case CIMTYPE_DATETIME:
 829                                return CQLValue::CIMDateTime_type;
 830                     
 831                             case CIMTYPE_REFERENCE:
 832                                 return CQLValue::CIMReference_type;
 833                     
 834                             case CIMTYPE_OBJECT:
 835                             case CIMTYPE_INSTANCE:
 836                                 return CQLValue::CIMObject_type;
 837 kumpf          1.36 
 838 dave.sudlik    1.28         default:
 839 venkat.puvvada 1.32             PEGASUS_ASSERT(0);
 840                                 return CQLValue::Boolean_type; // Never reach here
 841 dave.sudlik    1.28     }
 842 chuck          1.2  }
 843                     
 844                     Boolean CQLValueRep::isResolved()
 845                     {
 846                        return _isResolved;
 847                     }
 848                     
 849                     
 850 dave.sudlik    1.28 Boolean CQLValueRep::isNull() const
 851 chuck          1.2  {
 852 venkat.puvvada 1.32    return _theValue.isNull();
 853 chuck          1.2  }
 854                     
 855                     
 856 karl           1.26 Boolean CQLValueRep::isa(const CQLChainedIdentifier& inID,
 857                                              QueryContext& QueryCtx)
 858 kumpf          1.36 {
 859 chuck          1.2    PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::isa()");
 860 kumpf          1.36   if(!_isResolved ||
 861 david          1.11      (_valueType != CQLValue::CIMObject_type))
 862                         {
 863 kumpf          1.29       MessageLoaderParms mload(
 864                             "CQL.CQLValueRep.ISA_TYPE_MISMATCH",
 865                             "The type: $0 is not an object, or the object is not resolved",
 866 karl           1.26         _valueType);
 867 david          1.11       throw CQLRuntimeException(mload);
 868                         }
 869 kumpf          1.36 
 870 david          1.11   CIMName className;
 871                       CIMName isaName;
 872                       CIMObject obj;
 873 kumpf          1.36 
 874 david          1.11   _theValue.get(obj);
 875 kumpf          1.36 
 876 david          1.11   className = obj.getClassName();
 877                       isaName = inID[0].getName();
 878 kumpf          1.36 
 879 humberto       1.16   // Short circuit if the Object name and the isa name are the same.
 880                       // This will prevent an unneeded repository call.
 881                       if(className == isaName)
 882                         {
 883                           return true;
 884                         }
 885 david          1.11   Array<CIMName> cimNames = QueryCtx.enumerateClassNames(isaName);
 886                       cimNames.append(isaName);
 887 chuck          1.2  
 888 david          1.11   for(Uint32 i = 0; i < cimNames.size() ; ++i)
 889                         {
 890 kumpf          1.36 
 891 david          1.11       if(cimNames[i] == className)
 892 karl           1.26     {
 893                           PEG_METHOD_EXIT();
 894                           return true;
 895                         }
 896 david          1.11     }
 897                       PEG_METHOD_EXIT();
 898                       return false;
 899 chuck          1.2  }
 900                     
 901                     
 902                     Boolean CQLValueRep::like(const CQLValueRep& inVal)
 903                     {
 904                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::like()");
 905                        if( _valueType != CQLValue::String_type ||
 906                           inVal._valueType != CQLValue::String_type)
 907                        {
 908 kumpf          1.29        MessageLoaderParms mload(
 909                                "CQL.CQLValueRep.LIKE_TYPE_MISMATCH",
 910                                "The following types may not be strings: $0, $1.",
 911                                _valueType, inVal._valueType);
 912 chuck          1.2         throw CQLRuntimeException(mload);
 913                        }
 914 kumpf          1.36 
 915 chuck          1.2     String leftside;
 916                        _theValue.get(leftside);
 917                     
 918                        String rightside;
 919                        inVal._theValue.get(rightside);
 920 kumpf          1.36 
 921 s.kodali       1.31    CQLRegularExpression re(rightside);
 922 chuck          1.2  
 923                        PEG_METHOD_EXIT();
 924 s.kodali       1.31    return re.match(leftside);
 925 chuck          1.2  
 926                     }
 927                     
 928                     CQLChainedIdentifier CQLValueRep::getChainedIdentifier()const
 929                     {
 930                        return _CQLChainId;
 931                     }
 932                     
 933                     Uint64 CQLValueRep::getUint()const
 934                     {
 935                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getUint()");
 936                        if(_valueType != CQLValue::Uint64_type)
 937                        {
 938 karl           1.26         String str;
 939                              if(_theValue.isArray())
 940                                 str = "array";
 941                              else str = valueTypeToString(_valueType);
 942 kumpf          1.29        MessageLoaderParms mload(
 943                                "CQL.CQLValueRep.TYPE_MISMATCH",
 944                                "The type: $0 is not correct for $1 operation.",
 945                                str,
 946                                "getUint");
 947 chuck          1.2         throw CQLRuntimeException(mload);
 948                        }
 949                        Uint64 tmp;
 950                        _theValue.get(tmp);
 951                     
 952                        PEG_METHOD_EXIT();
 953                        return tmp;
 954                     }
 955                     
 956                     Boolean CQLValueRep::getBool()const
 957                     {
 958                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getBool()");
 959                        if(_valueType != CQLValue::Boolean_type)
 960                        {
 961 humberto       1.16        String str;
 962                            if(_theValue.isArray())
 963                               str = "array";
 964                            else str = valueTypeToString(_valueType);
 965 kumpf          1.29        MessageLoaderParms mload(
 966                                "CQL.CQLValueRep.TYPE_MISMATCH",
 967                                "The type: $0 is not correct for $1 operation.",
 968                                str,
 969                                "getBool");
 970 chuck          1.2         throw CQLRuntimeException(mload);
 971                        }
 972                        Boolean tmp;
 973                        _theValue.get(tmp);
 974                     
 975                        PEG_METHOD_EXIT();
 976                        return tmp;
 977                     }
 978                     
 979                     Sint64 CQLValueRep::getSint()const
 980                     {
 981                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getSint()");
 982                     
 983                        if(_valueType != CQLValue::Sint64_type)
 984                        {
 985 humberto       1.16        String str;
 986                            if(_theValue.isArray())
 987                               str = "array";
 988                            else str = valueTypeToString(_valueType);
 989 kumpf          1.29        MessageLoaderParms mload(
 990                                "CQL.CQLValueRep.TYPE_MISMATCH",
 991                                "The type: $0 is not correct for $1 operation.",
 992                                str,
 993                                "getSint");
 994 chuck          1.2         throw CQLRuntimeException(mload);
 995                        }
 996                        Sint64 tmp;
 997                        _theValue.get(tmp);
 998                     
 999                        PEG_METHOD_EXIT();
1000                        return tmp;
1001                     }
1002                     
1003                     Real64 CQLValueRep::getReal()const
1004                     {
1005                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getReal()");
1006                        if(_valueType != CQLValue::Real_type)
1007                        {
1008 humberto       1.16        String str;
1009                            if(_theValue.isArray())
1010                               str = "array";
1011                            else str = valueTypeToString(_valueType);
1012 kumpf          1.29        MessageLoaderParms mload(
1013                                "CQL.CQLValueRep.TYPE_MISMATCH",
1014                                "The type: $0 is not correct for $1 operation.",
1015                                str,
1016                                "getReal");
1017 chuck          1.2         throw CQLRuntimeException(mload);
1018                        }
1019                        Real64 tmp;
1020                        _theValue.get(tmp);
1021                        PEG_METHOD_EXIT();
1022                        return tmp;
1023                     }
1024                     
1025                     String CQLValueRep::getString()const
1026                     {
1027                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getString()");
1028                        if(_valueType != CQLValue::String_type)
1029                        {
1030 humberto       1.16        String str;
1031                            if(_theValue.isArray())
1032                               str = "array";
1033                            else str = valueTypeToString(_valueType);
1034 kumpf          1.29        MessageLoaderParms mload(
1035                                "CQL.CQLValueRep.TYPE_MISMATCH",
1036                                "The type: $0 is not correct for $1 operation.",
1037                                str,
1038                                "getString");
1039 chuck          1.2         throw CQLRuntimeException(mload);
1040                        }
1041                        String tmp;
1042                        _theValue.get(tmp);
1043                        PEG_METHOD_EXIT();
1044                        return tmp;
1045                     }
1046                     
1047                     CIMDateTime CQLValueRep::getDateTime()const
1048                     {
1049                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getDateTime()");
1050                        if(_valueType != CQLValue::CIMDateTime_type)
1051                        {
1052 humberto       1.16        String str;
1053                            if(_theValue.isArray())
1054                               str = "array";
1055                            else str = valueTypeToString(_valueType);
1056 kumpf          1.29        MessageLoaderParms mload(
1057                                "CQL.CQLValueRep.TYPE_MISMATCH",
1058                                "The type: $0 is not correct for $1 operation.",
1059                                str,
1060                                "getDateTime");
1061 chuck          1.2         throw CQLRuntimeException(mload);
1062                        }
1063                        CIMDateTime tmp;
1064                        _theValue.get(tmp);
1065                        PEG_METHOD_EXIT();
1066                        return tmp;
1067                     }
1068                     
1069                     CIMObjectPath CQLValueRep::getReference()const
1070                     {
1071                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getReference()");
1072                     
1073                        if(_valueType != CQLValue::CIMReference_type)
1074                        {
1075 humberto       1.16        String str;
1076                            if(_theValue.isArray())
1077                               str = "array";
1078                            else str = valueTypeToString(_valueType);
1079 kumpf          1.29        MessageLoaderParms mload(
1080                                "CQL.CQLValueRep.TYPE_MISMATCH",
1081                                "The type: $0 is not correct for $1 operation.",
1082                                str,
1083                                "getReference");
1084 chuck          1.2         throw CQLRuntimeException(mload);
1085                        }
1086                        CIMObjectPath tmp;
1087                        _theValue.get(tmp);
1088                     
1089                        PEG_METHOD_EXIT();
1090                        return tmp;
1091                     }
1092                     
1093                     CIMObject CQLValueRep::getObject()const
1094                     {
1095                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::getObject()");
1096                        if(_valueType != CQLValue::CIMObject_type)
1097                        {
1098 humberto       1.16        String str;
1099                            if(_theValue.isArray())
1100                               str = "array";
1101                            else str = valueTypeToString(_valueType);
1102 kumpf          1.29        MessageLoaderParms mload(
1103                                "CQL.CQLValueRep.TYPE_MISMATCH",
1104                                "The type: $0 is not correct for $1 operation.",
1105                                str,
1106                                "getObject");
1107 chuck          1.2         throw CQLRuntimeException(mload);
1108                        }
1109                        CIMObject tmp;
1110 david          1.5     _theValue.get(tmp);
1111 chuck          1.2     PEG_METHOD_EXIT();
1112                        return tmp.clone();
1113                     }
1114                     
1115                     String CQLValueRep::toString()const
1116                     {
1117                       if(_valueType == CQLValue::CQLIdentifier_type)
1118                         {
1119                           return _CQLChainId.toString();
1120                         }
1121                       else
1122 lucier         1.10   {
1123                         String returnStr;
1124                         if (_valueType == CQLValue::String_type)
1125 chuck          1.2      {
1126 lucier         1.10       returnStr.append("'");
1127 chuck          1.2      }
1128 lucier         1.15 
1129                         String temp(_theValue.toString());
1130 kumpf          1.36 
1131 lucier         1.15     // If the string is a real string, then strip padding off the exponent
1132                         if (_valueType == CQLValue::Real_type)
1133                           temp = CQLUtilities::formatRealStringExponent(temp);
1134 kumpf          1.36 
1135 lucier         1.15     returnStr.append(temp);
1136 kumpf          1.36 
1137 lucier         1.10     if (_valueType == CQLValue::String_type)
1138                         {
1139                           returnStr.append("'");
1140                         }
1141                         return returnStr;
1142                       }
1143 chuck          1.2  }
1144                     
1145                     
1146                     
1147                     void CQLValueRep::_validate(const CQLValueRep& x)
1148                     {
1149                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::_validate()");
1150 kumpf          1.36 
1151 venkat.puvvada 1.32   // Check for null and identifier can not be resolved
1152                       if ((isNull() && _valueType == CQLValue::CQLIdentifier_type) ||
1153                           (x.isNull() && x._valueType == CQLValue::CQLIdentifier_type))
1154 dave.sudlik    1.28   {
1155                           PEG_METHOD_EXIT();
1156                           return;
1157                       }
1158 venkat.puvvada 1.32 
1159 humberto       1.16   // Do not allow an array value be compared to a non array value.
1160                       if(x._theValue.isArray() != _theValue.isArray())
1161                         {
1162 kumpf          1.29         MessageLoaderParms mload(
1163                                 "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1164                                 "Validation type mismatch error for type: $0",
1165                                 "ARRAY");
1166                             throw CQLRuntimeException(mload);
1167 humberto       1.16     }
1168 chuck          1.2  
1169 humberto       1.16   switch(_valueType)
1170                         {
1171                         case CQLValue::Boolean_type:
1172                           if(x._valueType != CQLValue::Boolean_type)
1173 karl           1.26     {
1174 kumpf          1.29         MessageLoaderParms mload(
1175                                 "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1176                                 "Validation type mismatch error for type: $0",
1177                                 "BOOLEAN");
1178 karl           1.26       throw CQLRuntimeException(mload);
1179                         }
1180 humberto       1.16       break;
1181                         case CQLValue::Sint64_type:
1182                         case CQLValue::Uint64_type:
1183                         case CQLValue::Real_type:
1184                           if(x._valueType != CQLValue::Sint64_type &&
1185 karl           1.26      x._valueType != CQLValue::Uint64_type &&
1186                          x._valueType != CQLValue::Real_type)
1187                         {
1188 kumpf          1.29       MessageLoaderParms mload(
1189                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1190                               "Validation type mismatch error for type: $0",
1191                               "SINT64, UINT64, REAL64");
1192 karl           1.26       throw CQLRuntimeException(mload);
1193                         }
1194 humberto       1.16       break;
1195                         case CQLValue::String_type:
1196                           if(x._valueType != CQLValue::String_type)
1197 karl           1.26     {
1198 kumpf          1.29       MessageLoaderParms mload(
1199                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1200                               "Validation type mismatch error for type: $0",
1201                               "STRING");
1202 karl           1.26       throw CQLRuntimeException(mload);
1203                         }
1204 humberto       1.16       break;
1205                         case CQLValue::CIMDateTime_type:
1206                           if(x._valueType != CQLValue::CIMDateTime_type)
1207 karl           1.26     {
1208 kumpf          1.29       MessageLoaderParms mload(
1209                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1210                               "Validation type mismatch error for type: $0",
1211                               "CIMDATETIME");
1212 karl           1.26       throw CQLRuntimeException(mload);
1213                         }
1214 humberto       1.16       break;
1215                         case CQLValue::CIMReference_type:
1216                           if(x._valueType != CQLValue::CIMReference_type)
1217 karl           1.26     {
1218 kumpf          1.29       MessageLoaderParms mload(
1219                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1220                               "Validation type mismatch error for type: $0",
1221                               "CIMREFERENCE");
1222 karl           1.26       throw CQLRuntimeException(mload);
1223                         }
1224 humberto       1.16       break;
1225                         case CQLValue::CIMObject_type:
1226                           if(x._valueType != CQLValue::CIMObject_type)
1227 karl           1.26     {
1228 kumpf          1.29       MessageLoaderParms mload(
1229                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1230                               "Validation type mismatch error for type: $0",
1231                               "CIMOBJECT");
1232 karl           1.26       throw CQLRuntimeException(mload);
1233                         }
1234 humberto       1.16       break;
1235                         case CQLValue::CQLIdentifier_type:
1236                           if(x._valueType != CQLValue::CQLIdentifier_type)
1237 karl           1.26     {
1238 kumpf          1.29       MessageLoaderParms mload(
1239                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1240                               "Validation type mismatch error for type: $0",
1241                               "CQLIDENTIFIER");
1242 karl           1.26       throw CQLRuntimeException(mload);
1243                         }
1244 humberto       1.16       break;
1245 kumpf          1.36 
1246 humberto       1.16     default:
1247 kumpf          1.29       MessageLoaderParms mload(
1248                               "CQL.CQLValueRep.OP_TYPE_MISMATCH",
1249                               "Validation type mismatch error for type: $0",
1250                               "UNKNOWN");
1251 humberto       1.16       throw CQLRuntimeException(mload);
1252                           break;
1253                         }
1254                       PEG_METHOD_EXIT();
1255                       return;
1256 chuck          1.2  }
1257                     
1258 david          1.3  void CQLValueRep::_setValue(CIMValue cv,Sint64 key)
1259 chuck          1.2  {
1260                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::_setValue()");
1261                       CIMValue tmp;
1262 kumpf          1.23   Uint32 index = 0;
1263 david          1.3  
1264 humberto       1.16   if(cv.isNull())
1265                         {
1266 dave.sudlik    1.28       _theValue = cv;
1267                           // Get actual value type.
1268                           _valueType = _getCQLType(cv.getType());
1269 kumpf          1.27       _isResolved = true;
1270                           PEG_METHOD_EXIT();
1271                           return;
1272 humberto       1.16     }
1273 david          1.3    if(key != -1)
1274                         {
1275                           index = (Uint32)key;
1276                         }
1277 chuck          1.2    if(cv.isArray())
1278                         {
1279                           switch(cv.getType())
1280 karl           1.26     {
1281                         case CIMTYPE_BOOLEAN:
1282                           {
1283                             if(key == -1)
1284                               {
1285                             _theValue = cv;
1286                               }
1287                             else
1288                               {
1289                             Array<Boolean> _bool;
1290                             cv.get(_bool);
1291                             _theValue.set(_bool[index]);
1292                               }
1293 chuck          1.2  
1294 karl           1.26         _valueType = CQLValue::Boolean_type;
1295 chuck          1.2              break;
1296 karl           1.26       }
1297                         case CIMTYPE_UINT8:
1298                           {
1299                             Array<Uint8> _uint;
1300                             cv.get(_uint);
1301                     
1302                             if(key == -1)
1303                               {
1304                             Array<Uint64> _uint64;
1305                             for(Uint32 i = 0; i < _uint.size(); ++i)
1306                               {
1307                                 _uint64.append((Uint64)_uint[i]);
1308                               }
1309                             _theValue = CIMValue(_uint64);
1310                               }
1311                             else
1312                               {
1313                             _theValue.set((Uint64)_uint[index]);
1314                               }
1315 chuck          1.2              _valueType = CQLValue::Uint64_type;
1316                                 break;
1317 karl           1.26       }
1318                         case CIMTYPE_UINT16:
1319                           {
1320                             Array<Uint16> _uint;
1321                             cv.get(_uint);
1322                     
1323                             if(key == -1)
1324                               {
1325                             Array<Uint64> _uint64;
1326                             for(Uint32 i = 0; i < _uint.size(); ++i)
1327                               {
1328                                 _uint64.append((Uint64)_uint[i]);
1329                               }
1330                             _theValue = CIMValue(_uint64);
1331                               }
1332                             else
1333                               {
1334                             _theValue.set((Uint64)_uint[index]);
1335                               }
1336 chuck          1.2              _valueType = CQLValue::Uint64_type;
1337                                 break;
1338 karl           1.26       }
1339                         case CIMTYPE_UINT32:
1340                           {
1341                             Array<Uint32> _uint;
1342                             cv.get(_uint);
1343                     
1344                             if(key == -1)
1345                               {
1346                             Array<Uint64> _uint64;
1347                             for(Uint32 i = 0; i < _uint.size(); ++i)
1348                               {
1349                                 _uint64.append((Uint64)_uint[i]);
1350                               }
1351                             _theValue = CIMValue(_uint64);
1352                               }
1353                             else
1354                               {
1355                             _theValue.set((Uint64)_uint[index]);
1356                               }
1357 chuck          1.2              _valueType = CQLValue::Uint64_type;
1358                                 break;
1359 karl           1.26       }
1360                         case CIMTYPE_UINT64:
1361                           {
1362                             if(key == -1)
1363                               {
1364                             _theValue = cv;
1365                               }
1366                             else
1367                               {
1368                             Array<Uint64> _uint;
1369                             cv.get(_uint);
1370                             _theValue.set((Uint64)_uint[index]);
1371                               }
1372 chuck          1.2              _valueType = CQLValue::Uint64_type;
1373                                 break;
1374 karl           1.26       }
1375                         case CIMTYPE_SINT8:
1376                           {
1377                             Array<Sint8> _sint;
1378                             cv.get(_sint);
1379                     
1380                             if(key == -1)
1381                               {
1382                             Array<Sint64> _sint64;
1383                             for(Uint32 i = 0; i < _sint.size(); ++i)
1384                               {
1385                                 _sint64.append((Sint64)_sint[i]);
1386                               }
1387                             _theValue = CIMValue(_sint64);
1388                               }
1389                             else
1390                               {
1391                             _theValue.set((Sint64)_sint[index]);
1392                               }
1393                             _valueType = CQLValue::Sint64_type;
1394                             break;
1395 karl           1.26       }
1396                         case CIMTYPE_SINT16:
1397                           {
1398                             Array<Sint16> _sint;
1399                             cv.get(_sint);
1400                     
1401                             if(key == -1)
1402                               {
1403                             Array<Sint64> _sint64;
1404                             for(Uint32 i = 0; i < _sint.size(); ++i)
1405                               {
1406                                 _sint64.append((Sint64)_sint[i]);
1407                               }
1408                             _theValue = CIMValue(_sint64);
1409                               }
1410                             else
1411                               {
1412                             _theValue.set((Sint64)_sint[index]);
1413                               }
1414                             _valueType = CQLValue::Sint64_type;
1415                             break;
1416 karl           1.26       }
1417                         case CIMTYPE_SINT32:
1418                           {
1419                             Array<Sint32> _sint;
1420                             cv.get(_sint);
1421                     
1422                             if(key == -1)
1423                               {
1424                             Array<Sint64> _sint64;
1425                             for(Uint32 i = 0; i < _sint.size(); ++i)
1426                               {
1427                                 _sint64.append((Sint64)_sint[i]);
1428                               }
1429                             _theValue = CIMValue(_sint64);
1430                               }
1431                             else
1432                               {
1433                             _theValue.set((Sint64)_sint[index]);
1434                               }
1435 chuck          1.2              _valueType = CQLValue::Sint64_type;
1436                                 break;
1437 karl           1.26       }
1438                         case CIMTYPE_SINT64:
1439                           {
1440                             if(key == -1)
1441                               {
1442                             _theValue = cv;
1443                               }
1444                             else
1445                               {
1446                             Array<Sint64> _sint;
1447                             cv.get(_sint);
1448                             _theValue.set((Sint64)_sint[index]);
1449                               }
1450 chuck          1.2              _valueType = CQLValue::Sint64_type;
1451                                 break;
1452 karl           1.26       }
1453 kumpf          1.36 
1454 karl           1.26     case CIMTYPE_REAL32:
1455                           {
1456                             Array<Real32> _real;
1457                             cv.get(_real);
1458                     
1459                             if(key == -1)
1460                               {
1461                             Array<Real64> _real64;
1462                             for(Uint32 i = 0; i < _real.size(); ++i)
1463                               {
1464                                 _real64.append((Real64)_real[i]);
1465                               }
1466                             _theValue = CIMValue(_real64);
1467                               }
1468                             else
1469                               {
1470                             _theValue.set((Real64)_real[index]);
1471                               }
1472 chuck          1.2              _valueType = CQLValue::Real_type;
1473                                 break;
1474 karl           1.26       }
1475                         case CIMTYPE_REAL64:
1476                           {
1477                             if(key == -1)
1478                               {
1479                             _theValue = cv;
1480                               }
1481                             else
1482                               {
1483                             Array<Real64> _real;
1484                             cv.get(_real);
1485                             _theValue.set((Real64)_real[index]);
1486                               }
1487 chuck          1.2              _valueType = CQLValue::Real_type;
1488                                 break;
1489 kumpf          1.36       }
1490 karl           1.26     case CIMTYPE_CHAR16:
1491                           {
1492                             Array<Char16> _str16;
1493                             cv.get(_str16);
1494 chuck          1.2  
1495 chuck          1.13        Char16 _tmp[2];
1496                     
1497 karl           1.26         if(key == -1)
1498 chuck          1.13        {
1499                              Array<String> _str;
1500                              for(Uint32 i = 0; i < _str16.size(); ++i)
1501                              {
1502 kumpf          1.36            _tmp[0] = _str16[i];
1503 chuck          1.13            _tmp[1] = '\0';
1504                                _str.append(String(_tmp));
1505                              }
1506                              _theValue = CIMValue(_str);
1507                            }
1508 karl           1.26         else
1509 chuck          1.13        {
1510 kumpf          1.36          _tmp[0] = _str16[index];
1511 chuck          1.13          _tmp[1] = '\0';
1512                              _theValue.set(String(_tmp));
1513                            }
1514 karl           1.26         _valueType = CQLValue::String_type;
1515 chuck          1.13        break;
1516 karl           1.26       }
1517                         case CIMTYPE_STRING:
1518                           {
1519                             if(key == -1)
1520                               {
1521                             _theValue = cv;
1522                               }
1523                             else
1524                               {
1525                             Array<String> _str;
1526                             cv.get(_str);
1527                             _theValue.set(_str[index]);
1528                               }
1529 chuck          1.2              _valueType = CQLValue::String_type;
1530                                 break;
1531 kumpf          1.36       }
1532 karl           1.26     case CIMTYPE_DATETIME:
1533                           {
1534                             if(key == -1)
1535                               {
1536                             _theValue = cv;
1537                               }
1538                             else
1539                               {
1540                             Array<CIMDateTime> _date;
1541                             cv.get(_date);
1542                             _theValue.set(_date[index]);
1543                               }
1544 chuck          1.2              _valueType = CQLValue::CIMDateTime_type;
1545                                 break;
1546 karl           1.26       }
1547                         case CIMTYPE_REFERENCE:
1548                           {
1549                             if(key == -1)
1550                               {
1551                             _theValue = cv;
1552                               }
1553                             else
1554                               {
1555                             Array<CIMObjectPath> _path;
1556                             cv.get(_path);
1557                             _theValue.set(_path[index]);
1558                               }
1559 chuck          1.2              _valueType = CQLValue::CIMReference_type;
1560                                 break;
1561 karl           1.26       }
1562                         case CIMTYPE_OBJECT:
1563 a.dunfey       1.25     case CIMTYPE_INSTANCE:
1564                         {
1565                             Boolean isInstance = cv.getType() == CIMTYPE_INSTANCE;
1566                             if(key == -1)
1567                             {
1568                                 _theValue = cv;
1569                             }
1570                             else
1571                             {
1572                                 if(isInstance)
1573                                 {
1574                                   Array<CIMInstance> _inst;
1575                                   cv.get(_inst);
1576                                   _theValue.set((CIMObject)(_inst[index]));
1577                                 }
1578                                 else
1579                                 {
1580                                     Array<CIMObject> _obj;
1581                                     cv.get(_obj);
1582                                     _theValue.set(_obj[index]);
1583                                 }
1584 a.dunfey       1.25         }
1585                     
1586                             _valueType = CQLValue::CIMObject_type;
1587                             break;
1588 kumpf          1.36     }
1589 karl           1.26     default:
1590 kumpf          1.29        MessageLoaderParms mload(
1591                                "CQL.CQLValueRep.SET_VALUE",
1592                                "Unable to set internal object type: $0.",
1593                                cv.getType());
1594 karl           1.26        throw CQLRuntimeException(mload);
1595 kumpf          1.36     } // switch statement
1596 chuck          1.2      }
1597                       else
1598                         {
1599                           switch(cv.getType())
1600 karl           1.26     {
1601                         case CIMTYPE_BOOLEAN:
1602                           {
1603                             _theValue = cv;
1604 chuck          1.2              _valueType = CQLValue::Boolean_type;
1605                                 break;
1606 karl           1.26       }
1607                         case CIMTYPE_UINT8:
1608                           {
1609                             Uint8 _tmp;
1610                             cv.get(_tmp);
1611                             _theValue = CIMValue((Uint64)_tmp);
1612                             _valueType = CQLValue::Uint64_type;
1613                             break;
1614                           }
1615                         case CIMTYPE_UINT16:
1616                           {
1617                             Uint16 _tmp;
1618                             cv.get(_tmp);
1619                             _theValue = CIMValue((Uint64)_tmp);
1620                             _valueType = CQLValue::Uint64_type;
1621                             break;
1622                           }
1623                         case CIMTYPE_UINT32:
1624                           {
1625                             Uint32 _tmp;
1626                             cv.get(_tmp);
1627 karl           1.26         _theValue = CIMValue((Uint64)_tmp);
1628                             _valueType = CQLValue::Uint64_type;
1629                             break;
1630                           }
1631                         case CIMTYPE_UINT64:
1632                           {
1633                             Uint64 _tmp;
1634                             cv.get(_tmp);
1635                             _theValue = CIMValue((Uint64)_tmp);
1636                             _valueType = CQLValue::Uint64_type;
1637                             break;
1638                           }
1639                         case CIMTYPE_SINT8:
1640                           {
1641                             Sint8 _tmp;
1642                             cv.get(_tmp);
1643                             _theValue = CIMValue((Sint64)_tmp);
1644                             _valueType = CQLValue::Sint64_type;
1645                             break;
1646                           }
1647                         case CIMTYPE_SINT16:
1648 karl           1.26       {
1649                             Sint16 _tmp;
1650                             cv.get(_tmp);
1651                             _theValue = CIMValue((Sint64)_tmp);
1652                             _valueType = CQLValue::Sint64_type;
1653                             break;
1654                           }
1655                         case CIMTYPE_SINT32:
1656                           {
1657                             Sint32 _tmp;
1658                             cv.get(_tmp);
1659                             _theValue = CIMValue((Sint64)_tmp);
1660                             _valueType = CQLValue::Sint64_type;
1661                             break;
1662                           }
1663                         case CIMTYPE_SINT64:
1664                           {
1665                             Sint64 _tmp;
1666                             cv.get(_tmp);
1667                             _theValue = CIMValue((Sint64)_tmp);
1668                             _valueType = CQLValue::Sint64_type;
1669 karl           1.26         break;
1670                           }
1671                         case CIMTYPE_REAL32:
1672                           {
1673                             Real32 _tmp;
1674                             cv.get(_tmp);
1675                             _theValue = CIMValue((Real64)_tmp);
1676                             _valueType = CQLValue::Real_type;
1677                             break;
1678                           }
1679                         case CIMTYPE_REAL64:
1680                           {
1681                             Real64 _tmp;
1682                             cv.get(_tmp);
1683                             _theValue = CIMValue((Real64)_tmp);
1684                             _valueType = CQLValue::Real_type;
1685                             break;
1686 kumpf          1.36       }
1687 karl           1.26     case CIMTYPE_CHAR16:
1688                           {
1689                             Char16 _tmp[2];
1690                             cv.get(_tmp[0]);
1691 chuck          1.13        _tmp[1] = '\0';
1692 karl           1.26         _theValue = CIMValue(String(_tmp));
1693                             _valueType = CQLValue::String_type;
1694                             break;
1695 kumpf          1.36       }
1696 karl           1.26     case CIMTYPE_STRING:
1697                           {
1698                             _theValue = cv;
1699                             _valueType = CQLValue::String_type;
1700                             break;
1701 kumpf          1.36       }
1702 karl           1.26     case CIMTYPE_DATETIME:
1703                           {
1704                             _theValue = cv;
1705                             _valueType = CQLValue::CIMDateTime_type;
1706                             break;
1707 kumpf          1.36       }
1708 karl           1.26     case CIMTYPE_REFERENCE:
1709                           {
1710                             _theValue = cv;
1711 chuck          1.2              _valueType = CQLValue::CIMReference_type;
1712                                 break;
1713 kumpf          1.36       }
1714 karl           1.26     case CIMTYPE_OBJECT:
1715                           {
1716                             _theValue = cv;
1717 chuck          1.2              _valueType = CQLValue::CIMObject_type;
1718                                 break;
1719 karl           1.26       }
1720 a.dunfey       1.25     case CIMTYPE_INSTANCE:
1721                         {
1722                             // Convert the value into an Object value
1723                             CIMValue convertedValue(CIMTYPE_OBJECT, false);
1724                             CIMInstance tmpInst;
1725                             cv.get(tmpInst);
1726                             convertedValue.set((CIMObject)tmpInst);
1727                             _theValue = convertedValue;
1728                             _valueType = CQLValue::CIMObject_type;
1729                             break;
1730 kumpf          1.36     }
1731 karl           1.26     default:
1732 kumpf          1.29        MessageLoaderParms mload(
1733                                "CQL.CQLValueRep.SET_VALUE",
1734                                "Unable to set internal object type: $0.",
1735                                cv.getType());
1736 karl           1.26        throw CQLRuntimeException(mload);
1737                         }
1738 chuck          1.2  
1739                         }
1740                     
1741                       _isResolved = true;
1742                     
1743                       PEG_METHOD_EXIT();
1744                       return;
1745                     }
1746                     
1747 vijay.eli      1.22 void CQLValueRep::applyContext(const QueryContext& _ctx,
1748                                                   const CQLChainedIdentifier& inCid)
1749 chuck          1.2  {
1750                        if(inCid.size() != 0 && _CQLChainId.size() == 1)
1751 kumpf          1.36      {
1752 chuck          1.2         // If we get here we have a stand alone Symbolic constant.
1753                            // We need to take the chain and create a complete context
1754                            // for the symbolic constant.  We will use the context from
1755                            // inCid to populate the context for chain.
1756                            /*
1757                             _CQLChainId[0].setName(inCid[inCid.size()-1].getName());
1758                             _CQLChainId[0].applyScope(inCid[inCid.size()-1].getScope());
1759                            */
1760 kumpf          1.36 
1761 chuck          1.2         CQLIdentifier id = _CQLChainId[0];
1762                            id.setName(inCid[inCid.size()-1].getName());
1763                            id.applyScope(inCid[inCid.size()-1].getScope());
1764                     
1765                            CQLChainedIdentifier chainId(id);
1766                     
1767                            for(Sint32 i = inCid.size()-2; i >= 0; --i)
1768                            {
1769 kumpf          1.36          chainId.prepend(inCid[i]);
1770 chuck          1.2         }
1771                     
1772                            _CQLChainId = chainId;
1773                     
1774                     
1775 karl           1.26     CIMInstance temp;
1776                         resolve(temp,_ctx);
1777 chuck          1.2       }
1778                        else
1779                          {
1780 kumpf          1.36        _CQLChainId.applyContext(_ctx);
1781 chuck          1.2       }
1782                     
1783                        // Add the chained identifier to the WHERE identifier list.
1784                        // Note: CQLValue's are only used in WHERE processing.
1785                        if (_CQLChainId.size() > 0)
1786                        {
1787 s.kodali       1.33      _ctx.addWhereIdentifier(_CQLChainId);
1788 chuck          1.2     }
1789                     }
1790                     
1791                     void CQLValueRep::_resolveSymbolicConstant(const QueryContext& inQueryCtx)
1792                     {
1793                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::_resolveSymbolicConstant()");
1794                     
1795                        Array<String> valueMapArray;     // Value Map Qualifier for property
1796                        Array<String> valuesArray;       // Values Qualifier for property
1797                        CIMName className;
1798                        CQLIdentifier lid = _CQLChainId.getLastIdentifier();
1799                        CIMClass QueryClass;
1800                        CIMValue valueMap;               // CIMValue for Value Map Qualifiers
1801                        CIMValue values;                 // CIMValue for Values Qualifiers
1802                        Boolean matchFound = false;      // Indicator for match Qualifier
1803 kumpf          1.23    Uint32 matchIndex = 0;           // Placeholder for matched Qualifier
1804 chuck          1.2  
1805                        if(lid.isScoped())
1806                        {
1807                          className = lid.getScope();
1808                        }
1809                        else
1810                        {
1811                          className = _CQLChainId[0].getName();
1812                        }
1813                     
1814                        QueryClass = inQueryCtx.getClass(className);
1815                     
1816 kumpf          1.36    Uint32 propertyIndex =
1817 chuck          1.2           QueryClass.findProperty(lid.getName());
1818                     
1819                        if(propertyIndex == PEG_NOT_FOUND)
1820                        {
1821 kumpf          1.29      MessageLoaderParms mload(
1822                              "CQL.CQLValueRep.PROP_NOT_FOUND",
1823                              "Property $0 not found on class $1.",
1824                              lid.getName().getString(),
1825                              className.getString());
1826 chuck          1.2       throw CQLRuntimeException(mload);
1827                        }
1828                     
1829                        CIMProperty queryPropObj = QueryClass.getProperty(propertyIndex);
1830                     
1831                        // We have a symbolic constant (ex. propName#OK)
1832 kumpf          1.36    // We need to retrieve the ValueMap and Values Qualifiers for
1833 chuck          1.2     // the property if the exist.
1834 humberto       1.16    Uint32 qualIndex = queryPropObj.findQualifier(CIMName("Values"));
1835 chuck          1.2  
1836                        if(qualIndex == PEG_NOT_FOUND)
1837                        {
1838                           // This property can not be processed with a symbolic constant.
1839 kumpf          1.29      MessageLoaderParms mload(
1840                              "CQL.CQLValueRep.QUALIFIER_NOT_FOUND",
1841                              "Qualifier $0 not found on Property $1 in class $2.",
1842                              "Values",
1843                              lid.getName().getString(),
1844                              className.getString());
1845 chuck          1.2       throw CQLRuntimeException(mload);
1846                        }
1847                     
1848 humberto       1.16    values = queryPropObj.getQualifier(qualIndex).getValue();
1849 david          1.11 
1850 humberto       1.16    qualIndex = queryPropObj.findQualifier(CIMName("ValueMap"));
1851 chuck          1.2  
1852                        if(qualIndex == PEG_NOT_FOUND)
1853                          {
1854 humberto       1.16        // This property does not have a ValueMap Qualifier,
1855                            // therefore the values must be the list of symbolic constants.
1856 kumpf          1.36 
1857 humberto       1.16        values.get(valuesArray);
1858 kumpf          1.36 
1859                            // We will loop through the list of Symbolic constants to
1860 chuck          1.2         // determine if we have a match with the Symbolic constant
1861                            // defined in the CQLIdentifier.
1862 humberto       1.16        for(Uint32 i = 0; i < valuesArray.size(); ++i)
1863 karl           1.26      {
1864                            if(String::equalNoCase(valuesArray[i],lid.getSymbolicConstantName()))
1865                              {
1866                                matchFound = true;
1867                                matchIndex = i;
1868                                break;
1869                              }
1870                          }
1871 chuck          1.2         if(matchFound == false)
1872 karl           1.26      {
1873                            // The symbolic constant provided is not valid
1874                            // for this property.
1875                            MessageLoaderParms mload(
1876 kumpf          1.29             "CQL.CQLValueRep.INVALID_SYMBOLIC_CONSTANT",
1877                                 "Provided symbolic constant $0 is not valid for"
1878                                     " property $1 in class $2.",
1879 karl           1.26             lid.getSymbolicConstantName(),
1880                                 lid.getName().getString(),
1881                                 className.getString());
1882                            throw CQLRuntimeException(mload);
1883                          }
1884 kumpf          1.36 
1885                            // The symbolic constant defined in the CQLIdentifier is
1886 chuck          1.2         // valid for this property. Now we need to set the value.
1887                            // Set primitive
1888 humberto       1.16        _setValue(Uint64(matchIndex));
1889 chuck          1.2  
1890                            PEG_METHOD_EXIT();
1891                            return;
1892                          }
1893                        else
1894                          {
1895                            // The qualifier Values is defined for the property.
1896                            // valueMap must be a list of #'s.
1897 kumpf          1.36 
1898 humberto       1.16        valueMap = queryPropObj.getQualifier(qualIndex).getValue();
1899 kumpf          1.36 
1900 chuck          1.2         valueMap.get(valueMapArray);
1901                            values.get(valuesArray);
1902 kumpf          1.36 
1903                            // We will loop through the list of Symbolic constants to
1904 chuck          1.2         // determine if we have a match with the Symbolic constant
1905                            // defined in the CQLIdentifier.
1906                            for(Uint32 i = 0; i < valuesArray.size(); ++i)
1907 karl           1.26      {
1908                            if(String::equalNoCase(valuesArray[i],lid.getSymbolicConstantName()))
1909                              {
1910                                matchFound = true;
1911                                matchIndex = i;
1912                                break;
1913                              }
1914                          }
1915 chuck          1.2         if(matchFound == false)
1916 karl           1.26      {
1917                            // The symbolic constant provided is not valid
1918                            // for this property.
1919                            MessageLoaderParms mload(
1920 kumpf          1.29             "CQL.CQLValueRep.INVALID_SYMBOLIC_CONSTANT",
1921                                 "Provided symbolic constant $0 is not valid for property"
1922                                     " $1 in class $2.",
1923 karl           1.26             lid.getSymbolicConstantName(),
1924                                 lid.getName().getString(),
1925                                 className.getString());
1926 kumpf          1.36        throw CQLRuntimeException(mload);
1927 karl           1.26      }
1928 kumpf          1.36 
1929 humberto       1.16        // Set Primitive
1930 kumpf          1.36 
1931 humberto       1.16        if(valueMapArray[matchIndex].find(String("..")) != PEG_NOT_FOUND)
1932 karl           1.26      {
1933                            // The symbolic constant provided is not valid
1934                            // for this property.
1935                            MessageLoaderParms mload(
1936 kumpf          1.29             "CQL.CQLValueRep.INVALID_SYMBOLIC_CONSTANT",
1937                                 "Provided symbolic constant $0 is not valid for property"
1938                                     " $1 in class $2.",
1939 karl           1.26             lid.getSymbolicConstantName(),
1940                                 lid.getName().getString(),
1941                                 className.getString());
1942                            throw CQLRuntimeException(mload);
1943 kumpf          1.36      }
1944 karl           1.26        _setValue(CIMValue(Sint64(CQLUtilities::stringToSint64(
1945                                                valueMapArray[matchIndex]))));
1946 kumpf          1.36 
1947 chuck          1.2         PEG_METHOD_EXIT();
1948                            return;
1949                          }
1950 kumpf          1.36 
1951 chuck          1.2  }
1952                     
1953                     Boolean CQLValueRep::_compareObjects(CIMObject& _in1, CIMObject& _in2)
1954                     {
1955                       if(_in1.isClass() != _in2.isClass())
1956                         {
1957                           return false;
1958                         }
1959                       else if(_in1.isClass())
1960 kumpf          1.36     { // objects are classes
1961                           return ((_in1.getClassName() == _in2.getClassName())
1962 karl           1.26               && _in1.identical(_in2));
1963 chuck          1.2      }
1964                       else
1965                         { // objects are instances
1966                     
1967 humberto       1.16       if(!(_in1.getClassName() ==
1968 karl           1.26       _in2.getClassName()))
1969                         {
1970                           return false;
1971                         }
1972 humberto       1.16 
1973 chuck          1.2        if(_in1.getPropertyCount() !=
1974 karl           1.26      _in2.getPropertyCount())
1975                         {
1976                           return false;
1977                         }
1978 chuck          1.2  
1979                           Array<CIMProperty> prop1;
1980                           Array<CIMProperty> prop2;
1981                           Boolean result;
1982                     
1983                           for(Uint32 i = 0; i < _in1.getPropertyCount(); ++i)
1984 karl           1.26     {
1985                           prop1.append(_in1.getProperty(i));
1986                           prop2.append(_in2.getProperty(i));
1987                         }
1988 chuck          1.2  
1989                           for(Uint32 i = 0; i < _in1.getPropertyCount(); ++i)
1990 karl           1.26     {
1991                           result = false;
1992 chuck          1.2  
1993 karl           1.26       for(Uint32 j = 0; j < _in2.getPropertyCount(); ++j)
1994                             {
1995                               if(prop1[i].getName() == prop2[j].getName())
1996                             {
1997                               if(prop1[i].isArray() != prop2[j].isArray())
1998                                 {
1999                                   break;
2000                                 }
2001                               if(prop1[i].isArray())
2002                                 {
2003                                   CQLValueRep left;
2004                                   CQLValueRep right;
2005                                   left._setValue(prop1[i].getValue());
2006                                   right._setValue(prop2[j].getValue());
2007                                   result = left._compareArray(right);
2008                                 }
2009                               else
2010                                 {
2011                                   if(CQLValue(prop1[i].getValue()) == CQLValue(prop2[j].getValue()))
2012                                 {
2013                                   result = true;
2014 karl           1.26               break;
2015                                 }
2016                                   else
2017                                 {
2018                                   result = false;
2019                                   break;
2020                                 }
2021                                 }
2022                             }
2023                             }
2024                           if(result == false)
2025                             {
2026                               return false;
2027                             }
2028                         }
2029 chuck          1.2      }
2030                       return true;
2031                     }
2032                     
2033                     Boolean CQLValueRep::_compareArray(const CQLValueRep& _in)
2034                     {
2035                       PEG_METHOD_ENTER(TRC_CQL,"CQLValueRep::_compareArray()");
2036 humberto       1.16 
2037 dave.sudlik    1.28   if (isNull() && _in.isNull())
2038 kumpf          1.27   {
2039                           PEG_METHOD_EXIT();
2040                           return true;
2041                       }
2042 kumpf          1.36 
2043 dave.sudlik    1.28   if (isNull() ||_in.isNull())
2044 kumpf          1.27   {
2045                           PEG_METHOD_EXIT();
2046                           return false;
2047                       }
2048 kumpf          1.36 
2049 chuck          1.2    Boolean result;
2050                       Array<Boolean>       _bool1;
2051                       Array<Boolean>       _bool2;
2052                       Array<Uint64>        _uint1;
2053                       Array<Uint64>        _uint2;
2054                       Array<Sint64>        _sint1;
2055                       Array<Sint64>        _sint2;
2056                       Array<Real64>        _real1;
2057                       Array<Real64>        _real2;
2058                       Array<String>        _str1;
2059                       Array<String>        _str2;
2060                       Array<CIMDateTime>   _date1;
2061                       Array<CIMDateTime>   _date2;
2062                       Array<CIMObjectPath> _path1;
2063                       Array<CIMObjectPath> _path2;
2064                       Array<CIMObject>     _obj1;
2065                       Array<CIMObject>     _obj2;
2066                     
2067                       Array<CQLValue>      _cqlVal1;
2068                       Array<CQLValue>      _cqlVal2;
2069                     
2070 chuck          1.2    CIMValue _in1 = _theValue;
2071                       CIMValue _in2 = _in._theValue;
2072                     
2073                       String _arrayType1 = _ArrayType;
2074                       String _arrayType2 = _in._ArrayType;
2075                     
2076                       switch(_in1.getType())
2077                         {
2078                         case CIMTYPE_BOOLEAN:
2079                           {
2080 karl           1.26     _in1.get(_bool1);
2081                         for(Uint32 i = 0; i < _bool1.size(); ++i)
2082                           {
2083                             _cqlVal1.append(CQLValue(_bool1[i]));
2084                           }
2085                         break;
2086 chuck          1.2        }
2087                         case CIMTYPE_UINT64:
2088                           {
2089 karl           1.26     _in1.get(_uint1);
2090                         for(Uint32 i = 0; i < _uint1.size(); ++i)
2091                           {
2092                             _cqlVal1.append(CQLValue(_uint1[i]));
2093                           }
2094                         break;
2095 chuck          1.2        }
2096                         case CIMTYPE_SINT64:
2097                           {
2098 karl           1.26     _in1.get(_sint1);
2099                         for(Uint32 i = 0; i < _sint1.size(); ++i)
2100                           {
2101                             _cqlVal1.append(CQLValue(_sint1[i]));
2102                           }
2103                         break;
2104 chuck          1.2        }
2105                         case CIMTYPE_REAL64:
2106                           {
2107 karl           1.26     _in1.get(_real1);
2108                         for(Uint32 i = 0; i < _real1.size(); ++i)
2109                           {
2110                             _cqlVal1.append(CQLValue(_real1[i]));
2111                           }
2112                         break;
2113 kumpf          1.36       }
2114 chuck          1.2      case CIMTYPE_STRING:
2115                           {
2116 karl           1.26     _in1.get(_str1);
2117                         for(Uint32 i = 0; i < _str1.size(); ++i)
2118                           {
2119                             _cqlVal1.append(CQLValue(_str1[i]));
2120                           }
2121                         break;
2122 kumpf          1.36       }
2123 chuck          1.2      case CIMTYPE_DATETIME:
2124                           {
2125 karl           1.26     _in1.get(_date1);
2126                         for(Uint32 i = 0; i < _date1.size(); ++i)
2127                           {
2128                             _cqlVal1.append(CQLValue(_date1[i]));
2129                           }
2130                         break;
2131 chuck          1.2        }
2132                         case CIMTYPE_REFERENCE:
2133                           {
2134 karl           1.26     _in1.get(_path1);
2135                         for(Uint32 i = 0; i < _path1.size(); ++i)
2136                           {
2137                             _cqlVal1.append(CQLValue(_path1[i]));
2138                           }
2139                         break;
2140 kumpf          1.36       }
2141 david          1.8      case CIMTYPE_OBJECT:
2142 chuck          1.2        {
2143 karl           1.26     _in1.get(_obj1);
2144                         for(Uint32 i = 0; i < _obj1.size(); ++i)
2145                           {
2146                             _cqlVal1.append(CQLValue(_obj1[i]));
2147                           }
2148                         break;
2149 a.dunfey       1.25       }
2150                         case CIMTYPE_INSTANCE:
2151                         {
2152                             Array<CIMInstance> tmpInst;
2153                             _in1.get(tmpInst);
2154                             for(Uint32 i = 0; i < tmpInst.size(); ++i)
2155                             {
2156                                 _cqlVal1.append(CQLValue((CIMObject)tmpInst[i]));
2157                             }
2158                             break;
2159 kumpf          1.36     }
2160 chuck          1.2      default:
2161 karl           1.26       MessageLoaderParms mload(
2162 kumpf          1.29           "CQL.CQLValueRep.INVALID_ARRAY_COMPARISON",
2163                               "Invalid array comparison type: $0.",
2164                               _in1.getType());
2165 kumpf          1.36       throw CQLRuntimeException(mload);
2166                         } // switch statement
2167                     
2168 thilo.boehm    1.37     switch (_in2.getType())
2169 chuck          1.2      {
2170 thilo.boehm    1.37         case CIMTYPE_BOOLEAN:
2171 a.dunfey       1.25         {
2172 thilo.boehm    1.37             _in2.get(_bool2);
2173                                 for (Uint32 i = 0; i < _bool2.size(); ++i)
2174                                 {
2175                                     _cqlVal2.append(CQLValue(_bool2[i]));
2176                                 }
2177                                 break;
2178                             }
2179                             case CIMTYPE_UINT64:
2180                             {
2181                                 _in2.get(_uint2);
2182                                 for (Uint32 i = 0; i < _uint2.size(); ++i)
2183                                 {
2184                                     _cqlVal2.append(CQLValue(_uint2[i]));
2185                                 }
2186                                 break;
2187                             }
2188                             case CIMTYPE_SINT64:
2189                             {
2190                                 _in2.get(_sint2);
2191                                 for (Uint32 i = 0; i < _sint2.size(); ++i)
2192                                 {
2193 thilo.boehm    1.37                 _cqlVal2.append(CQLValue(_sint2[i]));
2194                                 }
2195                                 break;
2196                             }
2197                             case CIMTYPE_REAL64:
2198                             {
2199                                 _in2.get(_real2);
2200                                 for (Uint32 i = 0; i < _real2.size(); ++i)
2201                                 {
2202                                     _cqlVal2.append(CQLValue(_real2[i]));
2203                                 }
2204                                 break;
2205                             }
2206                             case CIMTYPE_STRING:
2207                             {
2208                                 _in2.get(_str2);
2209                                 for (Uint32 i = 0; i < _str2.size(); ++i)
2210                                 {
2211                                     _cqlVal2.append(CQLValue(_str2[i]));
2212                                 }
2213                                 break;
2214 thilo.boehm    1.37         }
2215                             case CIMTYPE_DATETIME:
2216                             {
2217                                 _in2.get(_date2);
2218                                 for (Uint32 i = 0; i < _date2.size(); ++i)
2219                                 {
2220                                     _cqlVal2.append(CQLValue(_date2[i]));
2221                                 }
2222                                 break;
2223                             }
2224                             case CIMTYPE_REFERENCE:
2225                             {
2226                                 _in2.get(_path2);
2227                                 for (Uint32 i = 0; i < _path2.size(); ++i)
2228                                 {
2229                                     _cqlVal2.append(CQLValue(_path2[i]));
2230                                 }
2231                                 break;
2232                             }
2233                             case CIMTYPE_OBJECT:
2234                             {
2235 thilo.boehm    1.37             _in2.get(_obj2);
2236                                 for (Uint32 i = 0; i < _obj2.size(); ++i)
2237                                 {
2238                                     _cqlVal2.append(CQLValue(_obj2[i]));
2239                                 }
2240                                 break;
2241                             }
2242                             case CIMTYPE_INSTANCE:
2243                             {
2244                                 Array<CIMObject> tmpInst;
2245                                 _in2.get(tmpInst);
2246                                 for (Uint32 i = 0; i < tmpInst.size(); ++i)
2247                                 {
2248                                     _cqlVal2.append(CQLValue((CIMObject)tmpInst[i]));
2249                                 }
2250                                 break;
2251                             }    
2252                             default:
2253                                 MessageLoaderParms mload(
2254                                      "CQL.CQLValueRep.INVALID_ARRAY_COMPARISON",
2255                                      "Invalid array comparison type: $0.",
2256 thilo.boehm    1.37                  _in2.getType());
2257                                 throw CQLRuntimeException(mload);
2258 kumpf          1.36     } // switch statement
2259 chuck          1.2  
2260                       if((_arrayType1 == String("Indexed") ||
2261                           _arrayType1 == String("Ordered")) &&
2262                          (_arrayType2 == String("Indexed") ||
2263                           _arrayType2 == String("Ordered")))
2264                         { // Handle the indexed or ordered case.
2265                           for(Uint32 i = 0; i < _cqlVal1.size(); ++i)
2266 kumpf          1.36     {
2267 karl           1.26       if(_cqlVal1[i] != _cqlVal2[i])
2268                             {
2269                               PEG_METHOD_EXIT();
2270                               return false;
2271                             }
2272                         }
2273 kumpf          1.36     }
2274 humberto       1.16   else // We are doing a bag comparison
2275 chuck          1.2      {
2276                           for(Uint32 i = 0; i < _cqlVal1.size(); ++i)
2277 karl           1.26     {
2278                           result = false;
2279 kumpf          1.36 
2280 karl           1.26       for(Uint32 j = 0; j < _cqlVal2.size(); ++j)
2281                             {
2282                               if(_cqlVal1[i] == _cqlVal2[j])
2283                             {
2284                               result = true;
2285                               break;
2286                             }
2287                             }
2288                           if(result == false)
2289                             {
2290                               PEG_METHOD_EXIT();
2291                               return false;
2292                             }
2293                         }
2294 kumpf          1.36 
2295 chuck          1.2        for(Uint32 i = 0; i < _cqlVal2.size(); ++i)
2296 karl           1.26     {
2297                           result = false;
2298 kumpf          1.36 
2299 karl           1.26       for(Uint32 j = 0; j < _cqlVal1.size(); ++j)
2300                             {
2301                               if(_cqlVal2[i] == _cqlVal1[j])
2302                             {
2303                               result = true;
2304                               break;
2305                             }
2306                             }
2307                           if(result == false)
2308                             {
2309                               PEG_METHOD_EXIT();
2310                               return false;
2311                             }
2312                         }
2313 chuck          1.2      }
2314                       PEG_METHOD_EXIT();
2315                       return true;
2316                     }
2317                     
2318 kumpf          1.36 String CQLValueRep::valueTypeToString(const CQLValue::CQLValueType parmType)
2319 humberto       1.16 {
2320                       String returnStr;
2321                     
2322                       switch (parmType)
2323                       {
2324                           case CQLValue::Sint64_type:
2325                               returnStr.append("Sint64");
2326                               break;
2327                           case CQLValue::Uint64_type:
2328                               returnStr.append("Uint64");
2329                               break;
2330                           case CQLValue::Real_type:
2331                               returnStr.append("Real");
2332                               break;
2333                           case CQLValue::String_type:
2334                               returnStr.append("String");
2335                               break;
2336                           case CQLValue::CIMDateTime_type:
2337                               returnStr.append("DateTime");
2338                               break;
2339                           case CQLValue::CIMReference_type:
2340 humberto       1.16           returnStr.append("CIM Ref");
2341                               break;
2342                           case CQLValue::CQLIdentifier_type:
2343                               returnStr.append("Identifier");
2344                               break;
2345                           case CQLValue::CIMObject_type:
2346                               returnStr.append("CIM Object");
2347                               break;
2348                           case CQLValue::Boolean_type:
2349                               returnStr.append("Boolean");
2350                               break;
2351                           default:
2352                               returnStr.append("Unknown");
2353                       }
2354                       return returnStr;
2355                     }
2356 chuck          1.2  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2