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