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 david 1.1.2.12 throw(Exception(String("CQLValueRep::CQLValueRep")));
|
224 david 1.1.2.1 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
237
238 CQLValueRep::CQLValueRep(String inString)
239 {
240 _theValue._S = new String(inString);
241 _valueType = String_type;
242 _isResolved = true;
243 }
244
245 david 1.1.2.1 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 }
258
259 CQLValueRep::CQLValueRep(CIMObjectPath inObjPath)
260 {
261 _theValue._OP = new CIMObjectPath(inObjPath);
262 _valueType = CIMReference_type;
263 _isResolved = true;
264 }
265
266 david 1.1.2.1 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 }
279
280 CQLValueRep::CQLValueRep(Boolean inBool)
281 {
282 _theValue._B = inBool;
283 _valueType = Boolean_type;
284 _isResolved = true;
285 }
286
287 david 1.1.2.1 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 }
300
301 void CQLValueRep::resolve(CIMInstance CI, QueryContext& inQueryCtx)
302 {
303 if(_isResolved)
304 {
305 return;
306 }
307
308 david 1.1.2.1 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
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 david 1.1.2.1 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 {
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 david 1.1.2.1 if(classList.size() != 1)
351 {
|
352 david 1.1.2.12 throw(Exception(String("CQLValueRep::resolve")));
|
353 david 1.1.2.1 }
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 _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 david 1.1.2.12 throw(Exception(String("CQLValueRep::resolve -- Property not Found")));
|
442 david 1.1.2.1 }
443
444 // We will check the property type to determine what processing
445 // needs to be done.
446 queryPropObj = QueryClass.getProperty(propertyIndex);
447
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 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator==")));
|
524 david 1.1.2.6 }
525
526 if(x._valueType == Null_type ||
527 _valueType == Null_type)
528 {
|
529 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator==")));
|
530 david 1.1.2.6 }
|
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 lucier 1.1.2.13 Real64 temp;
588 memcpy(&temp, &_theValue._U64, sizeof(temp));
589 if(temp == x._theValue._R64)
|
590 david 1.1.2.1 {
591 return true;
592 }
593 }
594 break;
595 case Real_type:
596 if(x._valueType == Sint64_type)
597 {
598 if(_theValue._R64 == x._theValue._S64)
599 {
600 return true;
601 }
602 }
603 else if(x._valueType == Uint64_type)
604 {
|
605 lucier 1.1.2.13 Real64 temp;
606 memcpy(&temp, &x._theValue._U64, sizeof(temp));
607 if(_theValue._R64 == temp)
|
608 david 1.1.2.1 {
609 return true;
610 }
611 }
612 else if(x._valueType == Real_type)
613 {
614 if(_theValue._R64 == x._theValue._R64)
615 {
616 return true;
617 }
618 }
619 break;
620 case String_type:
621 if(*_theValue._S == *x._theValue._S)
622 {
623 return true;
624 }
625 break;
626 case CIMDateTime_type:
627 if(*_theValue._DT == *x._theValue._DT)
628 {
629 david 1.1.2.1 return true;
630 }
631 break;
632 case CIMReference_type:
633 if(*_theValue._OP == *x._theValue._OP)
634 {
635 return true;
636 }
637 break;
638 case CIMInstance_type:
639 if((*_theValue._IN).getPath() == (*x._theValue._IN).getPath())
640 {
641 return true;
642 }
643 break;
644 case CQLIdentifier_type:
|
645 david 1.1.2.11 throw(Exception(String("")));
|
646 david 1.1.2.1 break;
647
648 default:
|
649 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator==")));
|
650 david 1.1.2.1 break;
651 }
652 return false;
653 }
654
655 //##ModelId=40FBFF9502BB
656 Boolean CQLValueRep::operator!=(const CQLValueRep& x)
657 {
658 if(!_validate(x))
659 {
|
660 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator!=")));
|
661 david 1.1.2.1 }
662
663 return !(this->operator==(x));
664 }
665
666
667 Boolean CQLValueRep::operator<=(const CQLValueRep& x)
668 {
|
669 david 1.1.2.6 if(!_validate(x))
|
670 david 1.1.2.1 {
|
671 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<=")));
|
672 david 1.1.2.1 }
|
673 lucier 1.1.2.13
674 if (this->operator<(x) || this->operator==(x))
675 return true;
|
676 david 1.1.2.1 return false;
677 }
678
679
680 Boolean CQLValueRep::operator>=(const CQLValueRep& x)
681 {
|
682 david 1.1.2.6 if(!_validate(x))
|
683 david 1.1.2.1 {
|
684 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator>=")));
|
685 david 1.1.2.6 }
|
686 lucier 1.1.2.13 return !(this->operator<(x));
|
687 david 1.1.2.1 }
688
689
690 Boolean CQLValueRep::operator<(const CQLValueRep& x)
691 {
692 if(!_validate(x))
693 {
|
694 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
695 david 1.1.2.1 }
696
|
697 david 1.1.2.6 if(x._valueType == Null_type ||
698 _valueType == Null_type)
699 {
|
700 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
701 david 1.1.2.6 }
702
|
703 david 1.1.2.1 switch(_valueType)
704 {
705 case Boolean_type:
706 {
707 if(x._valueType == Boolean_type)
708 {
709 if(_theValue._B < x._theValue._B)
710 {
711 return true;
712 }
713 }
714 break;
715 }
716 case Sint64_type:
717 if(x._valueType == Sint64_type)
718 {
719 if(_theValue._S64 < x._theValue._S64)
720 {
721 return true;
722 }
723 }
724 david 1.1.2.1 else if(x._valueType == Uint64_type)
725 {
726 if(_theValue._S64 < (Sint64)x._theValue._U64)
727 {
728 return true;
729 }
730 }
731 else if(x._valueType == Real_type)
732 {
733 if(_theValue._S64 < x._theValue._R64)
734 {
735 return true;
736 }
737 }
738 break;
739 case Uint64_type:
740 if(x._valueType == Sint64_type)
741 {
742 if((Sint64)_theValue._U64 < x._theValue._S64)
743 {
744 return true;
745 david 1.1.2.1 }
746 }
747 else if(x._valueType == Uint64_type)
748 {
749 if(_theValue._U64 < x._theValue._U64)
750 {
751 return true;
752 }
753 }
754 else if(x._valueType == Real_type)
755 {
|
756 lucier 1.1.2.13 Real64 temp;
757 memcpy(&temp, &_theValue._U64, sizeof(temp));
758 if(temp < x._theValue._R64)
|
759 david 1.1.2.1 {
760 return true;
761 }
762 }
763 break;
764 case Real_type:
765 if(x._valueType == Sint64_type)
766 {
767 if(_theValue._R64 < x._theValue._S64)
768 {
769 return true;
770 }
771 }
772 else if(x._valueType == Uint64_type)
773 {
|
774 lucier 1.1.2.13 Real64 temp;
775 memcpy(&temp, &x._theValue._U64, sizeof(temp));
776 if(_theValue._R64 < temp)
|
777 david 1.1.2.1 {
778 return true;
779 }
780 }
781 else if(x._valueType == Real_type)
782 {
783 if(_theValue._R64 < x._theValue._R64)
784 {
785 return true;
786 }
787 }
788 break;
789 case String_type:
790 if(*_theValue._S < *x._theValue._S)
791 {
792 return true;
793 }
794 break;
795 case CIMDateTime_type:
|
796 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
797 david 1.1.2.1 break;
798 case CIMReference_type:
|
799 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
800 david 1.1.2.1 break;
801 case CIMInstance_type:
|
802 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
803 david 1.1.2.1 break;
804 case CQLIdentifier_type:
|
805 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
806 david 1.1.2.1 break;
807
808 default:
|
809 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator<")));
|
810 david 1.1.2.1 break;
811 }
812 return false;
813 }
814
815
816 Boolean CQLValueRep::operator>(const CQLValueRep& x)
817 {
818 if(!_validate(x))
819 {
|
820 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator>")));
|
821 david 1.1.2.1 }
|
822 lucier 1.1.2.13 if (this->operator<(x) || this->operator==(x))
823 return false;
824 return true;
|
825 david 1.1.2.1 }
826
827
828 CQLValueRep CQLValueRep::operator+(const CQLValueRep x)
829 {
830
831 if(!_validate(x))
832 {
|
833 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
834 david 1.1.2.1 }
835
|
836 david 1.1.2.6 if(x._valueType == Null_type ||
837 _valueType == Null_type)
838 {
839 return CQLValueRep();
840 }
841
|
842 david 1.1.2.1 switch(_valueType)
843 {
844 case Boolean_type:
|
845 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
846 david 1.1.2.1 break;
847 case Sint64_type:
848 if(x._valueType == Sint64_type)
849 {
850 return CQLValueRep(_theValue._S64 + x._theValue._S64);
851 }
852 else if(x._valueType == Uint64_type)
853 {
854 return CQLValueRep(_theValue._S64 + x._theValue._U64);
855 }
856 else if(x._valueType == Real_type)
857 {
858 return CQLValueRep(_theValue._S64 + x._theValue._R64);
859 }
860 break;
861 case Uint64_type:
862 if(x._valueType == Sint64_type)
863 {
864 return CQLValueRep(_theValue._U64 + x._theValue._S64);
865 }
866 else if(x._valueType == Uint64_type)
867 david 1.1.2.1 {
868 return CQLValueRep(_theValue._U64 + x._theValue._U64);
869 }
870 else if(x._valueType == Real_type)
871 {
|
872 lucier 1.1.2.13 Real64 temp;
873 memcpy(&temp, &_theValue._U64, sizeof(temp));
874 return CQLValueRep(temp + x._theValue._R64);
|
875 david 1.1.2.1 }
876 break;
877 case Real_type:
878 if(x._valueType == Sint64_type)
879 {
880 return CQLValueRep(_theValue._R64 + x._theValue._S64);
881 }
882 else if(x._valueType == Uint64_type)
883 {
|
884 lucier 1.1.2.13 Real64 temp;
885 memcpy(&temp, &x._theValue._U64, sizeof(temp));
886 return CQLValueRep(_theValue._R64 + temp);
|
887 david 1.1.2.1 }
888 else if(x._valueType == Real_type)
889 {
890 return CQLValueRep(_theValue._R64 + x._theValue._R64);
891 }
892 break;
893 case String_type:
894 return CQLValueRep(*_theValue._S + *x._theValue._S);
895 break;
896 case CIMDateTime_type:
|
897 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
898 david 1.1.2.1 break;
899 case CIMReference_type:
|
900 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
901 david 1.1.2.1 break;
902 case CIMInstance_type:
|
903 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
904 david 1.1.2.1 break;
905 case CQLIdentifier_type:
|
906 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
907 david 1.1.2.1 break;
908
909 default:
|
910 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator+")));
|
911 david 1.1.2.1 break;
912 }
913
914 // control should never reach here
915 return x;
916 }
917
918
919 CQLValueRep CQLValueRep::operator-(const CQLValueRep& x)
920 {
921 if(!_validate(x))
922 {
|
923 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
924 david 1.1.2.1 }
|
925 david 1.1.2.6 if(x._valueType == Null_type ||
926 _valueType == Null_type)
927 {
928 return CQLValueRep();
929 }
|
930 david 1.1.2.1
931 switch(_valueType)
932 {
933 case Boolean_type:
|
934 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
935 david 1.1.2.1 break;
936 case Sint64_type:
937 if(x._valueType == Sint64_type)
938 {
939 return CQLValueRep(_theValue._S64 - x._theValue._S64);
940 }
941 else if(x._valueType == Uint64_type)
942 {
943 return CQLValueRep(_theValue._S64 - x._theValue._U64);
944 }
945 else if(x._valueType == Real_type)
946 {
947 return CQLValueRep(_theValue._S64 - x._theValue._R64);
948 }
949 break;
950 case Uint64_type:
951 if(x._valueType == Sint64_type)
952 {
953 return CQLValueRep(_theValue._U64 - x._theValue._S64);
954 }
955 else if(x._valueType == Uint64_type)
956 david 1.1.2.1 {
957 return CQLValueRep(_theValue._U64 - x._theValue._U64);
958 }
959 else if(x._valueType == Real_type)
960 {
|
961 lucier 1.1.2.13 Real64 temp;
962 memcpy(&temp, &_theValue._U64, sizeof(temp));
963 return CQLValueRep(temp - x._theValue._R64);
|
964 david 1.1.2.1 }
965 break;
966 case Real_type:
967 if(x._valueType == Sint64_type)
968 {
969 return CQLValueRep(_theValue._R64 - x._theValue._S64);
970 }
971 else if(x._valueType == Uint64_type)
972 {
|
973 lucier 1.1.2.13 Real64 temp;
974 memcpy(&temp, &x._theValue._U64, sizeof(temp));
975 return CQLValueRep(_theValue._R64 - temp);
|
976 david 1.1.2.1 }
977 else if(x._valueType == Real_type)
978 {
979 return CQLValueRep(_theValue._R64 - x._theValue._R64);
980 }
981 break;
982 case String_type:
|
983 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
984 david 1.1.2.1 break;
985 case CIMDateTime_type:
|
986 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
987 david 1.1.2.1 break;
988 case CIMReference_type:
|
989 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
990 david 1.1.2.1 break;
991 case CIMInstance_type:
|
992 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
993 david 1.1.2.1 break;
994 case CQLIdentifier_type:
|
995 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
996 david 1.1.2.1 break;
997
998 default:
|
999 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator-")));
|
1000 david 1.1.2.1 break;
1001 }
1002 // control should never reach here
1003 return x;
1004 }
1005
1006
1007 CQLValueRep CQLValueRep::operator*(const CQLValueRep& x)
1008 {
1009
1010 if(!_validate(x))
1011 {
|
1012 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1013 david 1.1.2.1 }
1014
|
1015 david 1.1.2.6 if(x._valueType == Null_type ||
1016 _valueType == Null_type)
1017 {
1018 return CQLValueRep();
1019 }
|
1020 david 1.1.2.1
1021 switch(_valueType)
1022 {
1023 case Boolean_type:
|
1024 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1025 david 1.1.2.1 break;
1026 case Sint64_type:
1027 if(x._valueType == Sint64_type)
1028 {
1029 return CQLValueRep(_theValue._S64 * x._theValue._S64);
1030 }
1031 else if(x._valueType == Uint64_type)
1032 {
1033 return CQLValueRep(_theValue._S64 * x._theValue._U64);
1034 }
1035 else if(x._valueType == Real_type)
1036 {
1037 return CQLValueRep(_theValue._S64 * x._theValue._R64);
1038 }
1039 break;
1040 case Uint64_type:
1041 if(x._valueType == Sint64_type)
1042 {
1043 return CQLValueRep(_theValue._U64 * x._theValue._S64);
1044 }
1045 else if(x._valueType == Uint64_type)
1046 david 1.1.2.1 {
1047 return CQLValueRep(_theValue._U64 * x._theValue._U64);
1048 }
1049 else if(x._valueType == Real_type)
1050 {
|
1051 lucier 1.1.2.13 Real64 temp;
1052 memcpy(&temp, &_theValue._U64, sizeof(temp));
1053 return CQLValueRep(temp * x._theValue._R64);
|
1054 david 1.1.2.1 }
1055 break;
1056 case Real_type:
1057 if(x._valueType == Sint64_type)
1058 {
1059 return CQLValueRep(_theValue._R64 * x._theValue._S64);
1060 }
1061 else if(x._valueType == Uint64_type)
1062 {
|
1063 lucier 1.1.2.13 Real64 temp;
1064 memcpy(&temp, &x._theValue._U64, sizeof(temp));
1065 return CQLValueRep(_theValue._R64 * temp);
|
1066 david 1.1.2.1 }
1067 else if(x._valueType == Real_type)
1068 {
1069 return CQLValueRep(_theValue._R64 * x._theValue._R64);
1070 }
1071 break;
1072 case String_type:
|
1073 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1074 david 1.1.2.1 break;
1075 case CIMDateTime_type:
|
1076 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1077 david 1.1.2.1 break;
1078 case CIMReference_type:
|
1079 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1080 david 1.1.2.1 break;
1081 case CIMInstance_type:
|
1082 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1083 david 1.1.2.1 break;
1084 case CQLIdentifier_type:
|
1085 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1086 david 1.1.2.1 break;
1087
1088 default:
|
1089 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator*")));
|
1090 david 1.1.2.1 break;
1091 }
1092 // control should never reach here
1093 return x;
1094 }
1095
1096
1097 CQLValueRep CQLValueRep::operator/(const CQLValueRep& x)
1098 {
1099 if(!_validate(x) ||
1100 x._theValue._U64 == 0)
1101 {
|
1102 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1103 david 1.1.2.1 }
|
1104 david 1.1.2.6
1105 if(x._valueType == Null_type ||
1106 _valueType == Null_type)
1107 {
1108 return CQLValueRep();
1109 }
1110
|
1111 david 1.1.2.1 switch(_valueType)
1112 {
1113 case Boolean_type:
|
1114 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1115 david 1.1.2.1 break;
1116 case Sint64_type:
1117 if(x._valueType == Sint64_type)
1118 {
1119 return CQLValueRep(_theValue._S64 / x._theValue._S64);
1120 }
1121 else if(x._valueType == Uint64_type)
1122 {
1123 return CQLValueRep(_theValue._S64 / x._theValue._U64);
1124 }
1125 else if(x._valueType == Real_type)
1126 {
1127 return CQLValueRep(_theValue._S64 / x._theValue._R64);
1128 }
1129 break;
1130 case Uint64_type:
1131 if(x._valueType == Sint64_type)
1132 {
1133 return CQLValueRep(_theValue._U64 / x._theValue._S64);
1134 }
1135 else if(x._valueType == Uint64_type)
1136 david 1.1.2.1 {
1137 return CQLValueRep(_theValue._U64 / x._theValue._U64);
1138 }
1139 else if(x._valueType == Real_type)
1140 {
|
1141 lucier 1.1.2.13 Real64 temp;
1142 memcpy(&temp, &_theValue._U64, sizeof(temp));
1143 return CQLValueRep(temp / x._theValue._R64);
|
1144 david 1.1.2.1 }
1145 break;
1146 case Real_type:
1147 if(x._valueType == Sint64_type)
1148 {
1149 return CQLValueRep(_theValue._R64 / x._theValue._S64);
1150 }
1151 else if(x._valueType == Uint64_type)
1152 {
|
1153 lucier 1.1.2.13 Real64 temp;
1154 memcpy(&temp, &x._theValue._U64, sizeof(temp));
1155 return CQLValueRep(_theValue._R64 / temp);
|
1156 david 1.1.2.1 }
1157 else if(x._valueType == Real_type)
1158 {
1159 return CQLValueRep(_theValue._R64 / x._theValue._R64);
1160 }
1161 break;
1162 case String_type:
|
1163 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1164 david 1.1.2.1 break;
1165 case CIMDateTime_type:
|
1166 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1167 david 1.1.2.1 break;
1168 case CIMReference_type:
|
1169 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1170 david 1.1.2.1 break;
1171 case CIMInstance_type:
|
1172 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1173 david 1.1.2.1 break;
1174 case CQLIdentifier_type:
|
1175 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1176 david 1.1.2.1 break;
1177
1178 default:
|
1179 david 1.1.2.12 throw(Exception(String("CQLValueRep::operator/")));
|
1180 david 1.1.2.1 break;
1181 }
1182 // control should never reach here
1183 return x;
1184 }
1185
1186 //##ModelId=40FC3F6F0302
1187 CQLValueType CQLValueRep::getValueType()
1188 {
1189 return _valueType;
1190 }
1191
1192
1193 void CQLValueRep::setNull()
1194 {
1195 _valueType = Null_type;
1196 _isResolved = true;
1197 }
1198
1199
1200 Boolean CQLValueRep::isResolved()
1201 david 1.1.2.1 {
1202 return _isResolved;
1203 }
1204
1205
1206 Boolean CQLValueRep::isNull()
1207 {
1208 if(_valueType == Null_type)
1209 {
1210 return true;
1211 }
1212 return false;
1213 }
1214
1215
1216 Boolean CQLValueRep::isa(const CQLValueRep& inVal, QueryContext& QueryCtx)
1217 {
1218 if(!_isResolved ||
1219 !inVal._isResolved ||
1220 _valueType != CIMInstance_type ||
1221 inVal._valueType != String_type)
1222 david 1.1.2.1 {
|
1223 david 1.1.2.12 throw(Exception(String("CQLValueRep::isa")));
|
1224 david 1.1.2.1 }
1225
1226 CIMName className;
1227 CIMClass classObj;
1228
1229 className = this->_theValue._IN->getClassName();
1230
1231 while(!className.isNull())
1232 {
1233 if(className == CIMName(*inVal._theValue._S))
1234 {
1235 return true;
1236 }
1237
1238 classObj = QueryCtx.getClass(className);
1239 className = classObj.getSuperClassName();
1240 }
1241
1242 return false;
1243 }
1244
1245 david 1.1.2.1
1246 Boolean CQLValueRep::like(const CQLValueRep& inVal)
1247 {
1248 if( _valueType != String_type ||
1249 inVal._valueType != String_type)
1250 {
|
1251 david 1.1.2.12 throw(Exception(String("CQLValueRep::like")));
|
1252 david 1.1.2.1 }
1253
1254 // Poughkepsie is doing this, Dan Gorey.
1255 return false;
1256 }
1257
1258 void CQLValueRep::invert()
1259 {
1260 switch(_valueType)
1261 {
1262 case Sint64_type:
1263 _theValue._S64 = -1 * _theValue._S64;
1264 break;
1265 case Real_type:
1266 _theValue._R64 = -1 * _theValue._R64;
1267 break;
1268 case Boolean_type:
1269 _theValue._B = !_theValue._B;
1270 break;
1271 default:
1272 break;
1273 david 1.1.2.1 }
1274 }
1275
1276 CQLChainedIdentifier CQLValueRep::getChainedIdentifier()const
1277 {
1278 return _CQLChainId;
1279 }
1280
1281 Uint64 CQLValueRep::getUint()const
1282 {
1283 if(_valueType != Uint64_type)
1284 {
|
1285 david 1.1.2.12 throw(Exception(String("CQLValueRep::getUint")));
|
1286 david 1.1.2.1 }
1287 return _theValue._U64;
1288 }
1289
1290 Boolean CQLValueRep::getBool()const
1291 {
1292 if(_valueType != Boolean_type)
1293 {
|
1294 david 1.1.2.12 throw(Exception(String("CQLValueRep::getBool")));
|
1295 david 1.1.2.1 }
1296 return _theValue._B;
1297 }
1298
1299 Sint64 CQLValueRep::getSint()const
1300 {
1301 if(_valueType != Sint64_type)
1302 {
|
1303 david 1.1.2.12 throw(Exception(String("CQLValueRep::getSint")));
|
1304 david 1.1.2.1 }
1305 return _theValue._S64;
1306 }
1307
1308 Real64 CQLValueRep::getReal()const
1309 {
1310 if(_valueType != Real_type)
1311 {
|
1312 david 1.1.2.12 throw(Exception(String("CQLValueRep::getReal")));
|
1313 david 1.1.2.1 }
1314 return _theValue._R64;
1315 }
1316
1317 String CQLValueRep::getString()const
1318 {
1319 if(_valueType != String_type)
1320 {
|
1321 david 1.1.2.12 throw(Exception(String("CQLValueRep::getString")));
|
1322 david 1.1.2.1 }
1323 return *_theValue._S;
1324 }
1325
1326 CIMDateTime CQLValueRep::getDateTime()const
1327 {
1328 if(_valueType != CIMDateTime_type)
1329 {
|
1330 david 1.1.2.12 throw(Exception(String("CQLValueRep::getDateTime")));
|
1331 david 1.1.2.1 }
1332
1333 return *_theValue._DT;
1334 }
1335
1336 CIMObjectPath CQLValueRep::getReference()const
1337 {
1338 if(_valueType != CIMReference_type)
1339 {
|
1340 david 1.1.2.12 throw(Exception(String("CQLValueRep::getReference")));
|
1341 david 1.1.2.1 }
1342 return *_theValue._OP;
1343 }
1344
1345 CIMInstance CQLValueRep::getInstance()const
1346 {
1347 if(_valueType != CIMInstance_type)
1348 {
|
1349 david 1.1.2.12 throw(Exception(String("CQLValueRep::getInstance")));
|
1350 david 1.1.2.1 }
1351 return *_theValue._IN;
1352 }
1353
1354 CIMClass CQLValueRep::getClass()const
1355 {
1356 if(_valueType != CIMClass_type)
1357 {
|
1358 david 1.1.2.12 throw(Exception(String("CQLValueRep::getClass")));
|
1359 david 1.1.2.1 }
1360
1361 return *_theValue._CL;
1362 }
1363
1364 String CQLValueRep::toString()const
1365 {
1366 switch(_valueType)
1367 {
1368 case Boolean_type:
1369 {
1370 return (_theValue._B ? String("TRUE") : String("FALSE"));
1371 break;
1372 }
1373 case Sint64_type:
1374 {
1375 char buffer[32]; // Should need 21 chars max
1376 sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", _theValue._S64);
1377 return String(buffer);
1378 break;
1379 }
1380 david 1.1.2.1 case Uint64_type:
1381 {
1382 char buffer[32]; // Should need 21 chars max
1383 sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", _theValue._U64);
1384 return String(buffer);
1385 break;
1386 }
1387 case Real_type:
1388 {
1389 char buffer[128];
1390 sprintf(buffer, "%.6e", _theValue._R64);
1391 return String(buffer);
1392 break;
1393 }
1394 case String_type:
1395 return *_theValue._S;
1396 break;
1397 case CIMDateTime_type:
1398 return _theValue._DT->toString();
1399 break;
1400 case CIMReference_type:
1401 david 1.1.2.1 return _theValue._OP->toString();
1402 break;
1403 case CIMInstance_type:
1404 return _theValue._IN->getPath().toString();
1405 break;
1406 case CIMClass_type:
1407 return _theValue._CL->getPath().toString();
1408 break;
1409 case CQLIdentifier_type:
1410 return _CQLChainId.toString();
1411 break;
1412 default:
1413 break;
1414 }
1415 return String();
1416 }
1417
1418
1419
1420 Boolean CQLValueRep::_validate(const CQLValueRep& x)
1421 {
1422 david 1.1.2.1 switch(_valueType)
1423 {
1424 case Boolean_type:
1425 if(x._valueType != Boolean_type)
1426 {
1427 return false;
1428 }
1429 break;
1430 case Sint64_type:
1431 case Uint64_type:
1432 case Real_type:
1433 if(x._valueType != Sint64_type &&
1434 x._valueType != Uint64_type &&
1435 x._valueType != Real_type)
1436 {
1437 return false;
1438 }
1439 break;
1440 case String_type:
1441 if(x._valueType != String_type)
1442 {
1443 david 1.1.2.1 return false;
1444 }
1445 break;
1446 case CIMDateTime_type:
1447 if(x._valueType != CIMDateTime_type)
1448 {
1449 return false;
1450 }
1451 break;
1452 case CIMReference_type:
1453 if(x._valueType != CIMReference_type)
1454 {
1455 return false;
1456 }
1457 break;
1458 case CIMInstance_type:
1459 if(x._valueType != CIMInstance_type)
1460 {
1461 return false;
1462 }
1463 break;
1464 david 1.1.2.1 case CQLIdentifier_type:
1465 if(x._valueType != CQLIdentifier_type)
1466 {
1467 return false;
1468 }
1469 break;
1470
1471 default:
|
1472 david 1.1.2.12 throw(Exception(String("CQLValueRep::_validate")));
|
1473 david 1.1.2.1 break;
1474 }
1475 return true;
1476 }
1477
1478 Boolean CQLValueRep::_areClassesInline(CIMClass c1,CIMClass c2,QueryContext& QC)
1479 {
1480 CIMName superClass;
1481 CIMName prevClass;
1482
1483 superClass = c1.getClassName();
1484 while(!(superClass == prevClass))
1485 {
1486 prevClass = superClass;
1487 if(superClass == c2.getClassName())
1488 {
1489 return true;
1490 }
1491 superClass = c1.getSuperClassName();
1492 }
1493 prevClass = CIMName();
1494 david 1.1.2.1 superClass = c2.getClassName();
1495 while(!(superClass == prevClass))
1496 {
1497 prevClass = superClass;
1498 if(superClass == c1.getClassName())
1499 {
1500 return true;
1501 }
1502 superClass = c2.getSuperClassName();
1503 }
1504
1505 return false;
1506 }
1507
1508 void CQLValueRep::_setValue(CIMValue cv,Uint64 index)
1509 {
1510 CIMValue tmp;
1511 if(cv.isArray())
1512 {
1513 switch(cv.getType())
1514 {
1515 david 1.1.2.1 case CIMTYPE_BOOLEAN:
1516 {
1517 Array<Boolean> _bool;
1518 cv.get(_bool);
1519 _theValue._B = _bool[index];
1520 _valueType = Boolean_type;
1521 break;
1522 }
1523 case CIMTYPE_UINT8:
1524 {
1525 Array<Uint8> _uint;
1526 cv.get(_uint);
1527 _theValue._U64 = _uint[index];
1528 _valueType = Uint64_type;
1529 break;
1530 }
1531 case CIMTYPE_UINT16:
1532 {
1533 Array<Uint16> _uint;
1534 cv.get(_uint);
1535 _theValue._U64 = _uint[index];
1536 david 1.1.2.1 _valueType = Uint64_type;
1537 break;
1538 }
1539 case CIMTYPE_UINT32:
1540 {
1541 Array<Uint32> _uint;
1542 cv.get(_uint);
1543 _theValue._U64 = _uint[index];
1544 _valueType = Uint64_type;
1545 break;
1546 }
1547 case CIMTYPE_UINT64:
1548 {
1549 Array<Uint64> _uint;
1550 cv.get(_uint);
1551 _theValue._U64 = _uint[index];
1552 _valueType = Uint64_type;
1553 break;
1554 }
1555 case CIMTYPE_SINT8:
1556 {
1557 david 1.1.2.1 Array<Sint8> _sint;
1558 cv.get(_sint);
1559 _theValue._S64 = _sint[index];
1560 _valueType = Sint64_type;
1561 break;
1562 }
1563 case CIMTYPE_SINT16:
1564 {
1565 Array<Sint16> _sint;
1566 cv.get(_sint);
1567 _theValue._S64 = _sint[index];
1568 _valueType = Sint64_type;
1569 break;
1570 }
1571 case CIMTYPE_SINT32:
1572 {
1573 Array<Sint32> _sint;
1574 cv.get(_sint);
1575 _theValue._S64 = _sint[index];
1576 _valueType = Sint64_type;
1577 break;
1578 david 1.1.2.1 }
1579 case CIMTYPE_SINT64:
1580 {
1581 Array<Sint64> _sint;
1582 cv.get(_sint);
1583 _theValue._S64 = _sint[index];
1584 _valueType = Sint64_type;
1585 break;
1586 }
1587
1588 case CIMTYPE_REAL32:
1589 {
1590 Array<Real32> _real;
1591 cv.get(_real);
1592 _theValue._R64 = _real[index];
1593 _valueType = Real_type;
1594 break;
1595 }
1596 case CIMTYPE_REAL64:
1597 {
1598 Array<Real64> _real;
1599 david 1.1.2.1 cv.get(_real);
1600 _theValue._R64 = _real[index];
1601 _valueType = Real_type;
1602 break;
1603 }
1604 case CIMTYPE_CHAR16:
1605 {
1606 Array<Char16> _str;
1607 cv.get(_str);
1608 _theValue._S = new String(&_str[index]);
1609 _valueType = String_type;
1610 break;
1611 }
1612 case CIMTYPE_STRING:
1613 {
1614 Array<String> _str;
1615 cv.get(_str);
1616 _theValue._S = new String(_str[index]);
1617 _valueType = String_type;
1618 break;
1619 }
1620 david 1.1.2.1 case CIMTYPE_DATETIME:
1621 {
1622 Array<CIMDateTime> _date;
1623 cv.get(_date);
1624 _theValue._DT = new CIMDateTime(_date[index]);
1625 _valueType = CIMDateTime_type;
1626 break;
1627 }
1628 case CIMTYPE_REFERENCE:
1629 {
1630 Array<CIMObjectPath> _path;
1631 cv.get(_path);
1632 _theValue._OP = new CIMObjectPath(_path[index]);
1633 _valueType = CIMReference_type;
1634 break;
1635 }
1636 default:
|
1637 david 1.1.2.12 throw(Exception(String("CQLValueRep::_setValue")));
|
1638 david 1.1.2.1 } // switch statement
1639
1640 }
1641 else
1642 {
1643 switch(cv.getType())
1644 {
1645 case CIMTYPE_BOOLEAN:
1646 {
1647 Boolean _bool;
1648 cv.get(_bool);
1649 _theValue._B = _bool;
1650 _valueType = Boolean_type;
1651 break;
1652 }
1653 case CIMTYPE_UINT8:
1654 {
1655 Uint8 _uint;
1656 cv.get(_uint);
1657 _theValue._U64 = _uint;
1658 _valueType = Uint64_type;
1659 david 1.1.2.1 break;
1660 }
1661 case CIMTYPE_UINT16:
1662 {
1663 Uint16 _uint;
1664 cv.get(_uint);
1665 _theValue._U64 = _uint;
1666 _valueType = Uint64_type;
1667 break;
1668 }
1669 case CIMTYPE_UINT32:
1670 {
1671 Uint32 _uint;
1672 cv.get(_uint);
1673 _theValue._U64 = _uint;
1674 _valueType = Uint64_type;
1675 break;
1676 }
1677 case CIMTYPE_UINT64:
1678 {
1679 Uint64 _uint;
1680 david 1.1.2.1 cv.get(_uint);
1681 _theValue._U64 = _uint;
1682 _valueType = Uint64_type;
1683 break;
1684 }
1685 case CIMTYPE_SINT8:
1686 {
1687 Sint8 _sint;
1688 cv.get(_sint);
1689 _theValue._S64 = _sint;
1690 _valueType = Sint64_type;
1691 break;
1692 }
1693 case CIMTYPE_SINT16:
1694 {
1695 Sint16 _sint;
1696 cv.get(_sint);
1697 _theValue._S64 = _sint;
1698 _valueType = Sint64_type;
1699 break;
1700 }
1701 david 1.1.2.1 case CIMTYPE_SINT32:
1702
1703 {
1704 Sint32 _sint;
1705 cv.get(_sint);
1706 _theValue._S64 = _sint;
1707 _valueType = Sint64_type;
1708 break;
1709 }
1710 case CIMTYPE_SINT64:
1711 {
1712 Sint64 _sint;
1713 cv.get(_sint);
1714 _theValue._S64 = _sint;
1715 _valueType = Sint64_type;
1716 break;
1717 }
1718 case CIMTYPE_REAL32:
1719 {
1720 Real32 _real;
1721 cv.get(_real);
1722 david 1.1.2.1 _theValue._R64 = _real;
1723 _valueType = Real_type;
1724 break;
1725 }
1726 case CIMTYPE_REAL64:
1727 {
1728 Real64 _real;
1729 cv.get(_real);
1730 _theValue._R64 = _real;
1731 _valueType = Real_type;
1732 break;
1733 }
1734 case CIMTYPE_CHAR16:
1735 {
1736 Char16 _str;
1737 cv.get(_str);
1738 _theValue._S = new String(&_str);
1739 _valueType = String_type;
1740 break;
1741 }
1742 case CIMTYPE_STRING:
1743 david 1.1.2.1 {
1744 String _str;
1745 cv.get(_str);
1746 _theValue._S = new String(_str);
1747 _valueType = String_type;
1748 break;
1749 }
1750 case CIMTYPE_DATETIME:
1751 {
1752 CIMDateTime _date;
1753 cv.get(_date);
1754 _theValue._DT = new CIMDateTime(_date);
1755 _valueType = CIMDateTime_type;
1756 break;
1757 }
1758 case CIMTYPE_REFERENCE:
1759 {
1760 CIMObjectPath _path;
1761 cv.get(_path);
1762 _theValue._OP = new CIMObjectPath(_path);
1763 _valueType = CIMReference_type;
1764 david 1.1.2.1 break;
1765 }
1766 default:
|
1767 david 1.1.2.12 throw(Exception(String("CQLValueRep::setValue")));
|
1768 david 1.1.2.1 } // switch statement
1769 }
1770 _isResolved = true;
1771 return;
1772 }
1773
|
1774 david 1.1.2.8 void CQLValueRep::applyContext(QueryContext& _ctx,
1775 CQLChainedIdentifier& inCid)
|
1776 lucier 1.1.2.13 {
|
1777 david 1.1.2.8 if(inCid.size() != 0 && _CQLChainId.size() == 1)
1778 {
|
1779 david 1.1.2.12
|
1780 david 1.1.2.8 _CQLChainId[0].setName(inCid[inCid.size()-1].getName());
|
1781 david 1.1.2.12 _CQLChainId[0].applyScope(inCid[inCid.size()-1].getScope());
1782
|
1783 david 1.1.2.8 for(Sint32 i = inCid.size()-2; i >= 0; --i)
1784 {
1785 _CQLChainId.prepend(inCid[i]);
1786 }
|
1787 david 1.1.2.12
|
1788 david 1.1.2.8 resolve(CIMInstance(),_ctx);
1789 }
1790 else
1791 {
|
1792 david 1.1.2.12 _CQLChainId.applyContext(_ctx);
|
1793 david 1.1.2.8 }
|
1794 humberto 1.1.2.2 }
1795
|
1796 david 1.1.2.9 void CQLValueRep::_resolveSymbolicConstant(QueryContext& inQueryCtx)
1797 {
1798 Array<String> valueMapArray; // Value Map Qualifier for property
1799 Array<String> valuesArray; // Values Qualifier for property
1800 CIMName className;
1801 CQLIdentifier lid = _CQLChainId.getLastIdentifier();
1802 CIMClass QueryClass;
1803 CIMValue valueMap; // CIMValue for Value Map Qualifiers
1804 CIMValue values; // CIMValue for Values Qualifiers
1805 Boolean matchFound = false; // Indicator for match Qualifier
1806 Uint32 matchIndex; // Placeholder for matched Qualifier
1807
1808 if(lid.isScoped())
1809 {
1810 className = lid.getScope();
1811 }
1812 else
1813 {
1814 className = _CQLChainId[0].getName();
1815 }
1816
1817 david 1.1.2.9 QueryClass = inQueryCtx.getClass(className);
1818
1819 Uint32 propertyIndex =
1820 QueryClass.findProperty(lid.getName());
1821
1822 if(propertyIndex == PEG_NOT_FOUND)
1823 {
|
1824 david 1.1.2.12 throw(Exception(String("CQLValueRep::_resolveSymbolicConstant")));
|
1825 david 1.1.2.9 }
1826
1827 CIMProperty queryPropObj = QueryClass.getProperty(propertyIndex);
1828
1829 // We have a symbolic constant (ex. propName#OK)
1830 // We need to retrieve the ValueMap and Values Qualifiers for
1831 // the property if the exist.
1832 Uint32 qualIndex = queryPropObj.findQualifier(CIMName("ValueMap"));
1833
1834 if(qualIndex == PEG_NOT_FOUND)
1835 {
1836 // This property can not be processed with a symbolic constant.
|
1837 david 1.1.2.12 throw(Exception(String("CQLValueRep::_resolveSymbolicConstant")));
|
1838 david 1.1.2.9 }
1839
1840 valueMap = queryPropObj.getQualifier(qualIndex).getValue();
1841 qualIndex = queryPropObj.findQualifier(CIMName("Values"));
1842
1843 if(qualIndex == PEG_NOT_FOUND)
1844 {
1845 // This property does not have a Values Qualifier,
1846 // therefore the valueMap must be the list of symbolic constants.
1847
1848 valueMap.get(valueMapArray);
1849
1850 // We will loop through the list of Symbolic constants to
1851 // determine if we have a match with the Symbolic constant
1852 // defined in the CQLIdentifier.
1853 for(Uint32 i = 0; i < valueMapArray.size(); ++i)
1854 {
1855 if(valueMapArray[i] ==
1856 lid.getSymbolicConstantName())
1857 {
1858 matchFound = true;
1859 david 1.1.2.9 matchIndex = i;
1860 break;
1861 }
1862 }
1863 if(matchFound == false)
1864 {
1865 // The symbolic constant provided is not valid
1866 // for this property.
|
1867 david 1.1.2.12 throw(Exception(String("CQLValueRep::_resolveSymbolicConstant")));
|
1868 david 1.1.2.9 }
1869
1870 // The symbolic constant defined in the CQLIdentifier is
1871 // valid for this property. Now we need to set the value.
1872 // Set primitive
1873 _setValue(CIMValue(lid.getSymbolicConstantName()));
1874 return;
1875 }
1876 else
1877 {
1878 // The qualifier Values is defined for the property.
1879 // valueMap must be a list of #'s.
1880
1881 values = queryPropObj.getQualifier(qualIndex).getValue();
1882
1883 valueMap.get(valueMapArray);
1884 values.get(valuesArray);
1885
1886 // We will loop through the list of Symbolic constants to
1887 // determine if we have a match with the Symbolic constant
1888 // defined in the CQLIdentifier.
1889 david 1.1.2.9 for(Uint32 i = 0; i < valuesArray.size(); ++i)
1890 {
1891 if(valuesArray[i] == lid.getSymbolicConstantName())
1892 {
1893 matchFound = true;
1894 matchIndex = i;
1895 break;
1896 }
1897 }
1898 if(matchFound == false)
1899 {
1900 // The symbolic constant provided is not valid
1901 // for this property.
|
1902 david 1.1.2.12 throw(Exception(String("CQLValueRep::_resolveSymbolicConstant")));
|
1903 david 1.1.2.9 }
1904
1905 CString cStr = valueMapArray[matchIndex].getCString();
1906 char *endP;
1907
1908 // Set Primitive
1909 _setValue(CIMValue(Uint64(strtoul((const char*)cStr,&endP,10))));
1910 return;
1911 }
1912 }
1913
|
1914 david 1.1.2.1 PEGASUS_NAMESPACE_END
|