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