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