6 inline bool value::assign(value& aThis,const value& aV,std::string& aError){
7 if(aThis.m_type==aV.m_type) {
9 if(aV.m_type==value::STRING) {
10 aThis.u.m_string = new std::string(*aV.u.m_string);
12 //} else if(aV.m_type==value::ARRAY_UNSIGNED_CHAR) {
13 // aThis.u.m_array_unsigned_char =
14 // new array<unsigned char>(*aV.u.m_array_unsigned_char);
15 //} else if(aV.m_type==value::ARRAY_CHAR) {
16 // aThis.u.m_array_char = new array<char>(*aV.u.m_array_char);
18 } else if(aV.m_type==value::ARRAY_UNSIGNED_SHORT) {
19 aThis.u.m_array_unsigned_short =
20 new array<unsigned short>(*aV.u.m_array_unsigned_short);
21 } else if(aV.m_type==value::ARRAY_SHORT) {
22 aThis.u.m_array_short = new array<short>(*aV.u.m_array_short);
24 } else if(aV.m_type==value::ARRAY_UNSIGNED_INT) {
25 aThis.u.m_array_unsigned_int =
26 new array<unsigned int>(*aV.u.m_array_unsigned_int);
27 } else if(aV.m_type==value::ARRAY_INT) {
28 aThis.u.m_array_int = new array<int>(*aV.u.m_array_int);
30 } else if(aV.m_type==value::ARRAY_UNSIGNED_INT64) {
31 aThis.u.m_array_unsigned_int64 =
32 new array<uint64>(*aV.u.m_array_unsigned_int64);
33 } else if(aV.m_type==value::ARRAY_INT64) {
34 aThis.u.m_array_int64 =
35 new array<int64>(*aV.u.m_array_int64);
37 } else if(aV.m_type==value::ARRAY_FLOAT) {
38 aThis.u.m_array_float = new array<float>(*aV.u.m_array_float);
39 } else if(aV.m_type==value::ARRAY_DOUBLE) {
40 aThis.u.m_array_double = new array<double>(*aV.u.m_array_double);
41 } else if(aV.m_type==value::ARRAY_BOOL) {
42 aThis.u.m_array_bool = new array<bool>(*aV.u.m_array_bool);
44 } else if(aV.m_type==value::ARRAY_STRING) {
45 aThis.u.m_array_string =
46 new array<std::string>(*aV.u.m_array_string);
53 switch(aThis.m_type) {
59 aThis.u.m_double = aV.u.m_int;
61 case value::UNSIGNED_SHORT :
62 aThis.u.m_double = aV.u.m_unsigned_short;
64 case value::UNSIGNED_INT:
65 aThis.u.m_double = aV.u.m_unsigned_int;
69 case value::VOID_STAR:
74 //case value::UNSIGNED_CHAR:
76 case value::UNSIGNED_INT64 :
77 case value::DOUBLE_STAR:
78 case value::FLOAT_STAR:
81 //case value::ARRAY_UNSIGNED_CHAR:
82 //case value::ARRAY_CHAR:
83 case value::ARRAY_UNSIGNED_SHORT:
84 case value::ARRAY_SHORT:
85 case value::ARRAY_UNSIGNED_INT:
86 case value::ARRAY_INT:
87 case value::ARRAY_UNSIGNED_INT64:
88 case value::ARRAY_INT64:
89 case value::ARRAY_FLOAT:
90 case value::ARRAY_DOUBLE:
91 case value::ARRAY_BOOL:
92 case value::ARRAY_STRING:
98 case value::VOID_STAR:
100 case value::UNSIGNED_INT:
107 aThis.u.m_short = (short)aV.u.m_int;
111 case value::VOID_STAR:
116 //case value::UNSIGNED_CHAR:
118 case value::UNSIGNED_SHORT :
119 case value::UNSIGNED_INT:
120 case value::UNSIGNED_INT64 :
121 case value::DOUBLE_STAR:
122 case value::FLOAT_STAR:
123 case value::INT_STAR:
125 //case value::ARRAY_UNSIGNED_CHAR:
126 //case value::ARRAY_CHAR:
127 case value::ARRAY_UNSIGNED_SHORT:
128 case value::ARRAY_SHORT:
129 case value::ARRAY_UNSIGNED_INT:
130 case value::ARRAY_INT:
131 case value::ARRAY_UNSIGNED_INT64:
132 case value::ARRAY_INT64:
133 case value::ARRAY_FLOAT:
134 case value::ARRAY_DOUBLE:
135 case value::ARRAY_BOOL:
136 case value::ARRAY_STRING:
143 aThis.u.m_float = (float)aV.u.m_int;
146 aThis.u.m_float = (float)aV.u.m_double;
149 case value::VOID_STAR:
154 //case value::UNSIGNED_CHAR:
156 case value::UNSIGNED_SHORT :
157 case value::UNSIGNED_INT:
158 case value::UNSIGNED_INT64 :
159 case value::DOUBLE_STAR:
160 case value::FLOAT_STAR:
161 case value::INT_STAR:
163 //case value::ARRAY_UNSIGNED_CHAR:
164 //case value::ARRAY_CHAR:
165 case value::ARRAY_UNSIGNED_SHORT:
166 case value::ARRAY_SHORT:
167 case value::ARRAY_UNSIGNED_INT:
168 case value::ARRAY_INT:
169 case value::ARRAY_UNSIGNED_INT64:
170 case value::ARRAY_INT64:
171 case value::ARRAY_FLOAT:
172 case value::ARRAY_DOUBLE:
173 case value::ARRAY_BOOL:
174 case value::ARRAY_STRING:
179 case value::UNSIGNED_CHAR:
182 aThis.u.m_unsigned_char = (unsigned char)aV.u.m_int;
186 case value::VOID_STAR:
191 case value::UNSIGNED_CHAR:
193 case value::UNSIGNED_SHORT :
194 case value::UNSIGNED_INT:
195 case value::UNSIGNED_INT64 :
196 case value::DOUBLE_STAR:
197 case value::FLOAT_STAR:
198 case value::INT_STAR:
200 case value::ARRAY_UNSIGNED_CHAR:
201 case value::ARRAY_CHAR:
202 case value::ARRAY_UNSIGNED_SHORT:
203 case value::ARRAY_SHORT:
204 case value::ARRAY_UNSIGNED_INT:
205 case value::ARRAY_INT:
206 case value::ARRAY_UNSIGNED_INT64:
207 case value::ARRAY_INT64:
208 case value::ARRAY_FLOAT:
209 case value::ARRAY_DOUBLE:
210 case value::ARRAY_BOOL:
211 case value::ARRAY_STRING:
218 aThis.u.m_char = (char)aV.u.m_int;
221 if(aV.u.m_string->size()!=1) break;
222 aThis.u.m_char = (*aV.u.m_string)[0];
226 case value::VOID_STAR:
231 case value::UNSIGNED_CHAR:
233 case value::UNSIGNED_SHORT :
234 case value::UNSIGNED_INT:
235 case value::UNSIGNED_INT64 :
236 case value::DOUBLE_STAR:
237 case value::FLOAT_STAR:
238 case value::INT_STAR:
239 case value::ARRAY_UNSIGNED_CHAR:
240 case value::ARRAY_CHAR:
241 case value::ARRAY_UNSIGNED_SHORT:
242 case value::ARRAY_SHORT:
243 case value::ARRAY_UNSIGNED_INT:
244 case value::ARRAY_INT:
245 case value::ARRAY_UNSIGNED_INT64:
246 case value::ARRAY_INT64:
247 case value::ARRAY_FLOAT:
248 case value::ARRAY_DOUBLE:
249 case value::ARRAY_BOOL:
250 case value::ARRAY_STRING:
257 case value::UNSIGNED_SHORT :
258 case value::UNSIGNED_INT64 :
261 aThis.u.m_int64 = aV.u.m_int;
263 case value::UNSIGNED_SHORT :
264 aThis.u.m_int64 = aV.u.m_unsigned_short;
266 case value::UNSIGNED_INT:
267 aThis.u.m_int64 = aV.u.m_unsigned_int;
271 case value::VOID_STAR:
276 //case value::UNSIGNED_CHAR:
278 case value::UNSIGNED_INT64 :
279 case value::DOUBLE_STAR:
280 case value::FLOAT_STAR:
281 case value::INT_STAR:
283 //case value::ARRAY_UNSIGNED_CHAR:
284 //case value::ARRAY_CHAR:
285 case value::ARRAY_UNSIGNED_SHORT:
286 case value::ARRAY_SHORT:
287 case value::ARRAY_UNSIGNED_INT:
288 case value::ARRAY_INT:
289 case value::ARRAY_UNSIGNED_INT64:
290 case value::ARRAY_INT64:
291 case value::ARRAY_FLOAT:
292 case value::ARRAY_DOUBLE:
293 case value::ARRAY_BOOL:
294 case value::ARRAY_STRING:
298 case value::DOUBLE_STAR:
299 case value::FLOAT_STAR:
300 case value::INT_STAR:
301 //case value::ARRAY_UNSIGNED_CHAR:
302 //case value::ARRAY_CHAR:
303 case value::ARRAY_UNSIGNED_SHORT:
304 case value::ARRAY_SHORT:
305 case value::ARRAY_UNSIGNED_INT:
306 case value::ARRAY_INT:
307 case value::ARRAY_UNSIGNED_INT64:
308 case value::ARRAY_INT64:
309 case value::ARRAY_FLOAT:
310 case value::ARRAY_DOUBLE:
311 case value::ARRAY_BOOL:
312 case value::ARRAY_STRING:
315 aError = std::string("value::assign :")
316 + " unable to assign " + aV.stype()
317 + " to " + aThis.stype();
323 inline bool value::minus(value& aThis,std::string& aError){
324 value::e_type oType = aThis.m_type;
325 switch(aThis.m_type) {
327 aThis.u.m_int = -aThis.u.m_int;
330 aThis.u.m_double = -aThis.u.m_double;
333 aThis.u.m_short = -aThis.u.m_short;
336 aThis.u.m_int64 = -aThis.u.m_int64;
339 aThis.u.m_float = -1.0F * aThis.u.m_float;
341 case value::ARRAY_DOUBLE:{
342 std::vector<double>& stdv = aThis.u.m_array_double->vector();
343 size_t number = stdv.size();
344 for(size_t index=0;index<number;index++) stdv[index] = -stdv[index];
347 // aThis.u.m_char = -aThis.u.m_char;
349 //case value::UNSIGNED_CHAR:{
350 // char tmp = -1*aThis.u.m_unsigned_char;
351 // aThis.set(tmp); //this becomes a value::CHAR.
353 case value::UNSIGNED_SHORT:{
354 short tmp = -1*aThis.u.m_unsigned_short;
355 aThis.set(tmp); //this becomes a value::SHORT.
357 case value::UNSIGNED_INT:{
358 int tmp = -1*aThis.u.m_unsigned_int;
359 aThis.set(tmp); //this becomes a value::INT.
361 case value::UNSIGNED_INT64 :{
362 int64 tmp = -1*aThis.u.m_unsigned_int64;
363 aThis.set(tmp); //this becomes a value::INT64.
368 case value::VOID_STAR:
369 case value::DOUBLE_STAR:
370 case value::FLOAT_STAR:
371 case value::INT_STAR:
372 //case value::ARRAY_UNSIGNED_CHAR:
373 //case value::ARRAY_CHAR:
374 case value::ARRAY_UNSIGNED_SHORT:
375 case value::ARRAY_SHORT:
376 case value::ARRAY_UNSIGNED_INT:
377 case value::ARRAY_INT:
378 case value::ARRAY_UNSIGNED_INT64:
379 case value::ARRAY_INT64:
380 case value::ARRAY_FLOAT:
381 //case value::ARRAY_DOUBLE:
382 case value::ARRAY_BOOL:
383 case value::ARRAY_STRING:
386 aError = std::string("value::minus :")
387 + " can't apply on type " + value::stype(oType);
392 inline bool value::do_not(value& aThis,std::string& aError){
393 value::e_type oType = aThis.m_type;
394 switch(aThis.m_type) {
396 aThis.u.m_bool = aThis.u.m_bool?false:true;
401 case value::VOID_STAR:
402 case value::UNSIGNED_SHORT :
403 case value::UNSIGNED_INT:
406 //case value::UNSIGNED_CHAR:
410 case value::UNSIGNED_INT64 :
411 case value::DOUBLE_STAR:
412 case value::FLOAT_STAR:
413 case value::INT_STAR:
414 //case value::ARRAY_UNSIGNED_CHAR:
415 //case value::ARRAY_CHAR:
416 case value::ARRAY_UNSIGNED_SHORT:
417 case value::ARRAY_SHORT:
418 case value::ARRAY_UNSIGNED_INT:
419 case value::ARRAY_INT:
420 case value::ARRAY_UNSIGNED_INT64:
421 case value::ARRAY_INT64:
422 case value::ARRAY_FLOAT:
423 case value::ARRAY_DOUBLE:
424 case value::ARRAY_BOOL:
425 case value::ARRAY_STRING:
428 aError = std::string("value::do_not :")
429 + " can't apply on type " + value::stype(oType);
434 //////////////////////////////////////////////////////////////////////////////
435 //////////////////////////////////////////////////////////////////////////////
436 //////////////////////////////////////////////////////////////////////////////
438 inline bool value::add(value& aThis,const value& aV,std::string& aError){
439 value::e_type oType = aThis.m_type;
440 switch(aThis.m_type) {
444 aThis.u.m_int += aV.u.m_int;
447 float tmp = aThis.u.m_int + aV.u.m_float;
451 double tmp = aThis.u.m_int + aV.u.m_double;
454 case value::ARRAY_DOUBLE:{
455 int tmp = aThis.u.m_int;
456 //In the below, this becomes a value::ARRAY_DOUBLE.
457 aThis.set(aV.u.m_array_double->orders(),
458 aV.u.m_array_double->vector());
459 aThis.u.m_array_double->add(double(tmp));
463 case value::VOID_STAR:
467 //case value::UNSIGNED_CHAR:
469 case value::UNSIGNED_SHORT :
470 case value::UNSIGNED_INT64 :
471 case value::DOUBLE_STAR:
472 case value::FLOAT_STAR:
473 case value::INT_STAR:
474 case value::UNSIGNED_INT:
475 //case value::ARRAY_UNSIGNED_CHAR:
476 //case value::ARRAY_CHAR:
477 case value::ARRAY_UNSIGNED_SHORT:
478 case value::ARRAY_SHORT:
479 case value::ARRAY_UNSIGNED_INT:
480 case value::ARRAY_INT:
481 case value::ARRAY_UNSIGNED_INT64:
482 case value::ARRAY_INT64:
483 case value::ARRAY_FLOAT:
484 //case value::ARRAY_DOUBLE:
485 case value::ARRAY_BOOL:
486 case value::ARRAY_STRING:
492 case value::UNSIGNED_SHORT :
493 aThis.u.m_float += aV.u.m_unsigned_short;
495 case value::UNSIGNED_INT:
496 aThis.u.m_float += aV.u.m_unsigned_int;
499 aThis.u.m_float += aV.u.m_short;
502 aThis.u.m_float += aV.u.m_int;
505 aThis.u.m_float += aV.u.m_float;
508 aThis.u.m_float += (float)aV.u.m_double;
510 case value::ARRAY_DOUBLE:{
511 double tmp = aThis.u.m_float;
512 //In the below this becomes a value::ARRAY_DOUBLE.
513 aThis.set(aV.u.m_array_double->orders(),
514 aV.u.m_array_double->vector());
515 aThis.u.m_array_double->add(tmp);
519 case value::VOID_STAR:
522 //case value::UNSIGNED_CHAR:
524 case value::UNSIGNED_INT64 :
525 case value::DOUBLE_STAR:
526 case value::FLOAT_STAR:
527 case value::INT_STAR:
528 //case value::ARRAY_UNSIGNED_CHAR:
529 //case value::ARRAY_CHAR:
530 case value::ARRAY_UNSIGNED_SHORT:
531 case value::ARRAY_SHORT:
532 case value::ARRAY_UNSIGNED_INT:
533 case value::ARRAY_INT:
534 case value::ARRAY_UNSIGNED_INT64:
535 case value::ARRAY_INT64:
536 case value::ARRAY_FLOAT:
537 //case value::ARRAY_DOUBLE:
538 case value::ARRAY_BOOL:
539 case value::ARRAY_STRING:
546 aThis.u.m_double += aV.u.m_short;
549 aThis.u.m_double += aV.u.m_int;
552 aThis.u.m_double += aV.u.m_float;
555 aThis.u.m_double += aV.u.m_double;
557 case value::UNSIGNED_SHORT :
558 aThis.u.m_double += aV.u.m_unsigned_short;
560 case value::UNSIGNED_INT:
561 aThis.u.m_double += aV.u.m_unsigned_int;
563 case value::ARRAY_DOUBLE:{
564 double tmp = aThis.u.m_double;
565 //In the below this becomes a value::ARRAY_DOUBLE.
566 aThis.set(aV.u.m_array_double->orders(),
567 aV.u.m_array_double->vector());
568 aThis.u.m_array_double->add(tmp);
572 case value::VOID_STAR:
575 //case value::UNSIGNED_CHAR:
577 case value::UNSIGNED_INT64 :
578 case value::DOUBLE_STAR:
579 case value::FLOAT_STAR:
580 case value::INT_STAR:
581 //case value::ARRAY_UNSIGNED_CHAR:
582 //case value::ARRAY_CHAR:
583 case value::ARRAY_UNSIGNED_SHORT:
584 case value::ARRAY_SHORT:
585 case value::ARRAY_UNSIGNED_INT:
586 case value::ARRAY_INT:
587 case value::ARRAY_UNSIGNED_INT64:
588 case value::ARRAY_INT64:
589 case value::ARRAY_FLOAT:
590 //case value::ARRAY_DOUBLE:
591 case value::ARRAY_BOOL:
592 case value::ARRAY_STRING:
596 case value::UNSIGNED_INT:
598 case value::UNSIGNED_INT:
599 aThis.u.m_unsigned_int += aV.u.m_unsigned_int;
602 int tmp = aThis.u.m_unsigned_int + aV.u.m_int;
606 float tmp = float(aThis.u.m_unsigned_int) + aV.u.m_float;
610 double tmp = double(aThis.u.m_unsigned_int) + aV.u.m_double;
613 case value::ARRAY_DOUBLE:{
614 unsigned int tmp = aThis.u.m_unsigned_int;
615 //In the below this becomes a value::ARRAY_DOUBLE.
616 aThis.set(aV.u.m_array_double->orders(),
617 aV.u.m_array_double->vector());
618 aThis.u.m_array_double->add(double(tmp));
622 case value::VOID_STAR:
626 //case value::UNSIGNED_CHAR:
628 case value::UNSIGNED_SHORT :
629 case value::UNSIGNED_INT64 :
630 case value::DOUBLE_STAR:
631 case value::FLOAT_STAR:
632 case value::INT_STAR:
633 //case value::ARRAY_UNSIGNED_CHAR:
634 //case value::ARRAY_CHAR:
635 case value::ARRAY_UNSIGNED_SHORT:
636 case value::ARRAY_SHORT:
637 case value::ARRAY_UNSIGNED_INT:
638 case value::ARRAY_INT:
639 case value::ARRAY_UNSIGNED_INT64:
640 case value::ARRAY_INT64:
641 case value::ARRAY_FLOAT:
642 //case value::ARRAY_DOUBLE:
643 case value::ARRAY_BOOL:
644 case value::ARRAY_STRING:
651 aThis.set((*aThis.u.m_string)+(*aV.u.m_string));
656 case value::VOID_STAR:
661 //case value::UNSIGNED_CHAR:
663 case value::UNSIGNED_SHORT :
664 case value::UNSIGNED_INT:
665 case value::UNSIGNED_INT64 :
666 case value::DOUBLE_STAR:
667 case value::FLOAT_STAR:
668 case value::INT_STAR:
669 //case value::ARRAY_UNSIGNED_CHAR:
670 //case value::ARRAY_CHAR:
671 case value::ARRAY_UNSIGNED_SHORT:
672 case value::ARRAY_SHORT:
673 case value::ARRAY_UNSIGNED_INT:
674 case value::ARRAY_INT:
675 case value::ARRAY_UNSIGNED_INT64:
676 case value::ARRAY_INT64:
677 case value::ARRAY_FLOAT:
678 case value::ARRAY_DOUBLE:
679 case value::ARRAY_BOOL:
680 case value::ARRAY_STRING:
684 case value::ARRAY_DOUBLE:
687 aThis.u.m_array_double->add(aV.u.m_int);
689 case value::UNSIGNED_INT:
690 aThis.u.m_array_double->add(aV.u.m_unsigned_int);
693 aThis.u.m_array_double->add(aV.u.m_double);
695 case value::ARRAY_DOUBLE:
696 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
697 aError = "Value::add : vector orders mismatch.";
701 aThis.u.m_array_double->add(*aV.u.m_array_double);
704 case value::VOID_STAR:
709 //case value::UNSIGNED_CHAR:
711 case value::UNSIGNED_SHORT :
712 case value::UNSIGNED_INT64 :
713 case value::DOUBLE_STAR:
714 case value::FLOAT_STAR:
715 case value::INT_STAR:
717 //case value::ARRAY_UNSIGNED_CHAR:
718 //case value::ARRAY_CHAR:
719 case value::ARRAY_UNSIGNED_SHORT:
720 case value::ARRAY_SHORT:
721 case value::ARRAY_UNSIGNED_INT:
722 case value::ARRAY_INT:
723 case value::ARRAY_UNSIGNED_INT64:
724 case value::ARRAY_INT64:
725 case value::ARRAY_FLOAT:
726 //case value::ARRAY_DOUBLE:
727 case value::ARRAY_BOOL:
728 case value::ARRAY_STRING:
733 case value::VOID_STAR:
737 //case value::UNSIGNED_CHAR:
739 case value::UNSIGNED_SHORT :
740 case value::UNSIGNED_INT64 :
741 case value::DOUBLE_STAR:
742 case value::FLOAT_STAR:
743 case value::INT_STAR:
744 //case value::ARRAY_UNSIGNED_CHAR:
745 //case value::ARRAY_CHAR:
746 case value::ARRAY_UNSIGNED_SHORT:
747 case value::ARRAY_SHORT:
748 case value::ARRAY_UNSIGNED_INT:
749 case value::ARRAY_INT:
750 case value::ARRAY_UNSIGNED_INT64:
751 case value::ARRAY_INT64:
752 case value::ARRAY_FLOAT:
753 //case value::ARRAY_DOUBLE:
754 case value::ARRAY_BOOL:
755 case value::ARRAY_STRING:
758 aError = std::string("Value::add :" )
759 + " can't apply on type " + value::stype(oType)
760 + " and type " + aV.stype();
765 inline bool value::subtract(value& aThis,const value& aV,std::string& aError){
766 value::e_type oType = aThis.m_type;
767 switch(aThis.m_type) {
771 aThis.u.m_int -= aV.u.m_int;
774 double tmp = aThis.u.m_int - aV.u.m_double;
778 float tmp = aThis.u.m_int - aV.u.m_float;
781 case value::ARRAY_DOUBLE:{
782 int tmp = aThis.u.m_int;
783 //In the below, this becomes a value::ARRAY_DOUBLE.
784 aThis.set(aV.u.m_array_double->orders(),
785 aV.u.m_array_double->vector());
786 aThis.u.m_array_double->multiply(-1);
787 aThis.u.m_array_double->add(double(tmp));
790 case value::VOID_STAR:
794 //case value::UNSIGNED_CHAR:
796 case value::UNSIGNED_SHORT :
797 case value::UNSIGNED_INT:
798 case value::UNSIGNED_INT64 :
799 case value::DOUBLE_STAR:
800 case value::FLOAT_STAR:
801 case value::INT_STAR:
803 //case value::ARRAY_UNSIGNED_CHAR:
804 //case value::ARRAY_CHAR:
805 case value::ARRAY_UNSIGNED_SHORT:
806 case value::ARRAY_SHORT:
807 case value::ARRAY_UNSIGNED_INT:
808 case value::ARRAY_INT:
809 case value::ARRAY_UNSIGNED_INT64:
810 case value::ARRAY_INT64:
811 case value::ARRAY_FLOAT:
812 //case value::ARRAY_DOUBLE:
813 case value::ARRAY_BOOL:
814 case value::ARRAY_STRING:
821 double tmp = double(aThis.u.m_float) - aV.u.m_double;
824 case value::UNSIGNED_SHORT :
825 aThis.u.m_float -= aV.u.m_unsigned_short;
827 case value::UNSIGNED_INT:
828 aThis.u.m_float -= aV.u.m_unsigned_int;
831 aThis.u.m_float -= aV.u.m_int;
834 aThis.u.m_float -= aV.u.m_short;
837 aThis.u.m_float -= aV.u.m_float;
840 double tmp = double(aThis.u.m_float) - aV.u.m_int64;
843 case value::UNSIGNED_INT64:{
844 double tmp = double(aThis.u.m_float) - aV.u.m_unsigned_int64;
847 case value::ARRAY_DOUBLE:{
848 double tmp = aThis.u.m_float;
849 //In the below, this becomes a value::ARRAY_DOUBLE.
850 aThis.set(aV.u.m_array_double->orders(),
851 aV.u.m_array_double->vector());
852 aThis.u.m_array_double->multiply(-1);
853 aThis.u.m_array_double->add(tmp);
856 case value::VOID_STAR:
858 //case value::UNSIGNED_CHAR:
860 case value::DOUBLE_STAR:
861 case value::FLOAT_STAR:
862 case value::INT_STAR:
864 //case value::ARRAY_UNSIGNED_CHAR:
865 //case value::ARRAY_CHAR:
866 case value::ARRAY_UNSIGNED_SHORT:
867 case value::ARRAY_SHORT:
868 case value::ARRAY_UNSIGNED_INT:
869 case value::ARRAY_INT:
870 case value::ARRAY_UNSIGNED_INT64:
871 case value::ARRAY_INT64:
872 case value::ARRAY_FLOAT:
873 //case value::ARRAY_DOUBLE:
874 case value::ARRAY_BOOL:
875 case value::ARRAY_STRING:
882 aThis.u.m_double -= aV.u.m_double;
884 case value::UNSIGNED_SHORT :
885 aThis.u.m_double -= aV.u.m_unsigned_short;
887 case value::UNSIGNED_INT:
888 aThis.u.m_double -= aV.u.m_unsigned_int;
891 aThis.u.m_double -= aV.u.m_int;
894 aThis.u.m_double -= aV.u.m_short;
897 aThis.u.m_double -= aV.u.m_int64;
900 aThis.u.m_double -= aV.u.m_float;
902 case value::UNSIGNED_INT64 :
903 aThis.u.m_double -= aV.u.m_unsigned_int64;
905 case value::ARRAY_DOUBLE:{
906 double tmp = aThis.u.m_double;
907 //In the below, this becomes a value::ARRAY_DOUBLE.
908 aThis.set(aV.u.m_array_double->orders(),
909 aV.u.m_array_double->vector());
910 aThis.u.m_array_double->multiply(-1);
911 aThis.u.m_array_double->add(tmp);
914 case value::VOID_STAR:
916 //case value::UNSIGNED_CHAR:
918 case value::DOUBLE_STAR:
919 case value::FLOAT_STAR:
920 case value::INT_STAR:
922 //case value::ARRAY_UNSIGNED_CHAR:
923 //case value::ARRAY_CHAR:
924 case value::ARRAY_UNSIGNED_SHORT:
925 case value::ARRAY_SHORT:
926 case value::ARRAY_UNSIGNED_INT:
927 case value::ARRAY_INT:
928 case value::ARRAY_UNSIGNED_INT64:
929 case value::ARRAY_INT64:
930 case value::ARRAY_FLOAT:
931 //case value::ARRAY_DOUBLE:
932 case value::ARRAY_BOOL:
933 case value::ARRAY_STRING:
937 case value::UNSIGNED_INT:
939 case value::UNSIGNED_INT:
940 if(aThis.u.m_unsigned_int>=aV.u.m_unsigned_int) {
941 aThis.u.m_unsigned_int -= aV.u.m_unsigned_int;
943 int i = int(aThis.u.m_unsigned_int) - aV.u.m_unsigned_int;
948 double d = double(aThis.u.m_unsigned_int) - aV.u.m_double;
952 float d = float(aThis.u.m_unsigned_int) - aV.u.m_float;
956 int d = int(aThis.u.m_unsigned_int) - aV.u.m_int;
959 case value::ARRAY_DOUBLE:{
960 unsigned int tmp = aThis.u.m_unsigned_int;
961 //In the below, this becomes a value::ARRAY_DOUBLE.
962 aThis.set(aV.u.m_array_double->orders(),
963 aV.u.m_array_double->vector());
964 aThis.u.m_array_double->multiply(-1);
965 aThis.u.m_array_double->add(double(tmp));
968 case value::VOID_STAR:
972 //case value::UNSIGNED_CHAR:
974 case value::UNSIGNED_SHORT :
975 case value::UNSIGNED_INT64 :
976 case value::DOUBLE_STAR:
977 case value::FLOAT_STAR:
978 case value::INT_STAR:
980 //case value::ARRAY_UNSIGNED_CHAR:
981 //case value::ARRAY_CHAR:
982 case value::ARRAY_UNSIGNED_SHORT:
983 case value::ARRAY_SHORT:
984 case value::ARRAY_UNSIGNED_INT:
985 case value::ARRAY_INT:
986 case value::ARRAY_UNSIGNED_INT64:
987 case value::ARRAY_INT64:
988 case value::ARRAY_FLOAT:
989 //case value::ARRAY_DOUBLE:
990 case value::ARRAY_BOOL:
991 case value::ARRAY_STRING:
995 case value::ARRAY_DOUBLE:
998 aThis.u.m_array_double->add(-aV.u.m_int);
1000 case value::UNSIGNED_INT:
1001 aThis.u.m_array_double->add(-((double)aV.u.m_unsigned_int));
1004 aThis.u.m_array_double->add(-aV.u.m_double);
1006 case value::ARRAY_DOUBLE:{
1007 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
1008 aError = "Value::subtract : vector orders mismatch.";
1012 std::vector<double>& stdv = aThis.u.m_array_double->vector();
1013 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
1014 size_t number = stdv.size();
1015 for(size_t index=0;index<number;index++) {
1016 stdv[index] -= stdv2[index];
1020 case value::VOID_STAR:
1025 //case value::UNSIGNED_CHAR:
1027 case value::UNSIGNED_SHORT :
1028 case value::UNSIGNED_INT64 :
1029 case value::DOUBLE_STAR:
1030 case value::FLOAT_STAR:
1031 case value::INT_STAR:
1033 //case value::ARRAY_UNSIGNED_CHAR:
1034 //case value::ARRAY_CHAR:
1035 case value::ARRAY_UNSIGNED_SHORT:
1036 case value::ARRAY_SHORT:
1037 case value::ARRAY_UNSIGNED_INT:
1038 case value::ARRAY_INT:
1039 case value::ARRAY_UNSIGNED_INT64:
1040 case value::ARRAY_INT64:
1041 case value::ARRAY_FLOAT:
1042 //case value::ARRAY_DOUBLE:
1043 case value::ARRAY_BOOL:
1044 case value::ARRAY_STRING:
1049 case value::VOID_STAR:
1053 //case value::UNSIGNED_CHAR:
1055 case value::UNSIGNED_SHORT :
1056 case value::UNSIGNED_INT64 :
1057 case value::DOUBLE_STAR:
1058 case value::FLOAT_STAR:
1059 case value::INT_STAR:
1061 //case value::ARRAY_UNSIGNED_CHAR:
1062 //case value::ARRAY_CHAR:
1063 case value::ARRAY_UNSIGNED_SHORT:
1064 case value::ARRAY_SHORT:
1065 case value::ARRAY_UNSIGNED_INT:
1066 case value::ARRAY_INT:
1067 case value::ARRAY_UNSIGNED_INT64:
1068 case value::ARRAY_INT64:
1069 case value::ARRAY_FLOAT:
1070 //case value::ARRAY_DOUBLE:
1071 case value::ARRAY_BOOL:
1072 case value::ARRAY_STRING:
1075 aError = std::string("Value::subtract :" )
1076 + " can't apply on type " + value::stype(oType)
1077 + " and type " + aV.stype();
1082 inline bool value::multiply(value& aThis,const value& aV,std::string& aError){
1083 value::e_type oType = aThis.m_type;
1084 switch(aThis.m_type) {
1088 aThis.u.m_int *= aV.u.m_int;
1090 case value::UNSIGNED_INT:
1091 aThis.u.m_int *= aV.u.m_unsigned_int;
1094 aThis.u.m_int *= (int)aV.u.m_double;
1097 aThis.u.m_int *= (int)aV.u.m_float;
1099 case value::ARRAY_DOUBLE:{
1100 int tmp = aThis.u.m_int;
1101 //In the below, this becomes a value::ARRAY_DOUBLE.
1102 aThis.set(aV.u.m_array_double->orders(),
1103 aV.u.m_array_double->vector());
1104 aThis.u.m_array_double->multiply(double(tmp));
1107 case value::VOID_STAR:
1111 //case value::UNSIGNED_CHAR:
1113 case value::UNSIGNED_SHORT :
1114 case value::UNSIGNED_INT64 :
1115 case value::DOUBLE_STAR:
1116 case value::FLOAT_STAR:
1117 case value::INT_STAR:
1119 //case value::ARRAY_UNSIGNED_CHAR:
1120 //case value::ARRAY_CHAR:
1121 case value::ARRAY_UNSIGNED_SHORT:
1122 case value::ARRAY_SHORT:
1123 case value::ARRAY_UNSIGNED_INT:
1124 case value::ARRAY_INT:
1125 case value::ARRAY_UNSIGNED_INT64:
1126 case value::ARRAY_INT64:
1127 case value::ARRAY_FLOAT:
1128 //case value::ARRAY_DOUBLE:
1129 case value::ARRAY_BOOL:
1130 case value::ARRAY_STRING:
1137 aThis.u.m_float *= aV.u.m_short;
1140 aThis.u.m_float *= aV.u.m_int;
1143 aThis.u.m_float *= aV.u.m_float;
1146 aThis.u.m_float *= (float)aV.u.m_double;
1148 case value::UNSIGNED_SHORT :
1149 aThis.u.m_float *= aV.u.m_unsigned_short;
1151 case value::UNSIGNED_INT:
1152 aThis.u.m_float *= aV.u.m_unsigned_int;
1154 case value::ARRAY_DOUBLE:{
1155 double tmp = aThis.u.m_float;
1156 //In the below, this becomes a value::ARRAY_DOUBLE.
1157 aThis.set(aV.u.m_array_double->orders(),
1158 aV.u.m_array_double->vector());
1159 aThis.u.m_array_double->multiply(tmp);
1162 case value::VOID_STAR:
1165 //case value::UNSIGNED_CHAR:
1167 case value::UNSIGNED_INT64 :
1168 case value::DOUBLE_STAR:
1169 case value::FLOAT_STAR:
1170 case value::INT_STAR:
1172 //case value::ARRAY_UNSIGNED_CHAR:
1173 //case value::ARRAY_CHAR:
1174 case value::ARRAY_UNSIGNED_SHORT:
1175 case value::ARRAY_SHORT:
1176 case value::ARRAY_UNSIGNED_INT:
1177 case value::ARRAY_INT:
1178 case value::ARRAY_UNSIGNED_INT64:
1179 case value::ARRAY_INT64:
1180 case value::ARRAY_FLOAT:
1181 //case value::ARRAY_DOUBLE:
1182 case value::ARRAY_BOOL:
1183 case value::ARRAY_STRING:
1190 aThis.u.m_double *= aV.u.m_short;
1193 aThis.u.m_double *= aV.u.m_int;
1196 aThis.u.m_double *= aV.u.m_int64;
1199 aThis.u.m_double *= aV.u.m_float;
1202 aThis.u.m_double *= aV.u.m_double;
1204 case value::UNSIGNED_SHORT :
1205 aThis.u.m_double *= aV.u.m_unsigned_short;
1207 case value::UNSIGNED_INT:
1208 aThis.u.m_double *= aV.u.m_unsigned_int;
1210 case value::ARRAY_DOUBLE:{
1211 double tmp = aThis.u.m_double;
1212 //In the below, this becomes a value::ARRAY_DOUBLE.
1213 aThis.set(aV.u.m_array_double->orders(),
1214 aV.u.m_array_double->vector());
1215 aThis.u.m_array_double->multiply(tmp);
1218 case value::VOID_STAR:
1220 //case value::UNSIGNED_CHAR:
1222 case value::UNSIGNED_INT64 :
1223 case value::DOUBLE_STAR:
1224 case value::FLOAT_STAR:
1225 case value::INT_STAR:
1227 //case value::ARRAY_UNSIGNED_CHAR:
1228 //case value::ARRAY_CHAR:
1229 case value::ARRAY_UNSIGNED_SHORT:
1230 case value::ARRAY_SHORT:
1231 case value::ARRAY_UNSIGNED_INT:
1232 case value::ARRAY_INT:
1233 case value::ARRAY_UNSIGNED_INT64:
1234 case value::ARRAY_INT64:
1235 case value::ARRAY_FLOAT:
1236 //case value::ARRAY_DOUBLE:
1237 case value::ARRAY_BOOL:
1238 case value::ARRAY_STRING:
1242 case value::UNSIGNED_INT:
1245 float tmp = aThis.u.m_unsigned_int * aV.u.m_float;
1246 aThis.set(tmp); //this becomes a value::FLOAT.
1248 case value::DOUBLE:{
1249 double tmp = aThis.u.m_unsigned_int * aV.u.m_double;
1250 aThis.set(tmp); //this becomes a value::DOUBLE.
1253 int tmp = aThis.u.m_unsigned_int * aV.u.m_int;
1254 aThis.set(tmp); //this becomes a value::INT.
1257 int64 tmp = aThis.u.m_unsigned_int * aV.u.m_int64;
1258 aThis.set(tmp); //this becomes a value::INT64.
1260 case value::UNSIGNED_INT:
1261 aThis.u.m_unsigned_int *= aV.u.m_unsigned_int;
1263 case value::ARRAY_DOUBLE:{
1264 unsigned int tmp = aThis.u.m_unsigned_int;
1265 //In the below, this becomes a value::ARRAY_DOUBLE.
1266 aThis.set(aV.u.m_array_double->orders(),
1267 aV.u.m_array_double->vector());
1268 aThis.u.m_array_double->multiply(double(tmp));
1271 case value::VOID_STAR:
1274 //case value::UNSIGNED_CHAR:
1276 case value::UNSIGNED_SHORT :
1277 case value::UNSIGNED_INT64 :
1278 case value::DOUBLE_STAR:
1279 case value::FLOAT_STAR:
1280 case value::INT_STAR:
1282 //case value::ARRAY_UNSIGNED_CHAR:
1283 //case value::ARRAY_CHAR:
1284 case value::ARRAY_UNSIGNED_SHORT:
1285 case value::ARRAY_SHORT:
1286 case value::ARRAY_UNSIGNED_INT:
1287 case value::ARRAY_INT:
1288 case value::ARRAY_UNSIGNED_INT64:
1289 case value::ARRAY_INT64:
1290 case value::ARRAY_FLOAT:
1291 //case value::ARRAY_DOUBLE:
1292 case value::ARRAY_BOOL:
1293 case value::ARRAY_STRING:
1297 case value::ARRAY_DOUBLE:
1300 aThis.u.m_array_double->multiply(aV.u.m_int);
1302 case value::UNSIGNED_INT:
1303 aThis.u.m_array_double->multiply(aV.u.m_unsigned_int);
1306 aThis.u.m_array_double->multiply(aV.u.m_double);
1308 case value::ARRAY_DOUBLE:{
1309 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
1310 aError = "Value::multiply : vector orders mismatch.";
1314 std::vector<double>& stdv = aThis.u.m_array_double->vector();
1315 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
1316 size_t number = stdv.size();
1317 for(size_t index=0;index<number;index++) {
1318 stdv[index] *= stdv2[index];
1322 case value::VOID_STAR:
1327 //case value::UNSIGNED_CHAR:
1329 case value::UNSIGNED_SHORT :
1330 case value::UNSIGNED_INT64 :
1331 case value::DOUBLE_STAR:
1332 case value::FLOAT_STAR:
1333 case value::INT_STAR:
1335 //case value::ARRAY_UNSIGNED_CHAR:
1336 //case value::ARRAY_CHAR:
1337 case value::ARRAY_UNSIGNED_SHORT:
1338 case value::ARRAY_SHORT:
1339 case value::ARRAY_UNSIGNED_INT:
1340 case value::ARRAY_INT:
1341 case value::ARRAY_UNSIGNED_INT64:
1342 case value::ARRAY_INT64:
1343 case value::ARRAY_FLOAT:
1344 //case value::ARRAY_DOUBLE:
1345 case value::ARRAY_BOOL:
1346 case value::ARRAY_STRING:
1352 case value::VOID_STAR:
1356 //case value::UNSIGNED_CHAR:
1358 case value::UNSIGNED_SHORT :
1359 case value::UNSIGNED_INT64 :
1360 case value::DOUBLE_STAR:
1361 case value::FLOAT_STAR:
1362 case value::INT_STAR:
1363 //case value::ARRAY_UNSIGNED_CHAR:
1364 //case value::ARRAY_CHAR:
1365 case value::ARRAY_UNSIGNED_SHORT:
1366 case value::ARRAY_SHORT:
1367 case value::ARRAY_UNSIGNED_INT:
1368 case value::ARRAY_INT:
1369 case value::ARRAY_UNSIGNED_INT64:
1370 case value::ARRAY_INT64:
1371 case value::ARRAY_FLOAT:
1372 //case value::ARRAY_DOUBLE:
1373 case value::ARRAY_BOOL:
1374 case value::ARRAY_STRING:
1377 aError = std::string("Value::multiply :" )
1378 + " can't apply on type " + value::stype(oType)
1379 + " and type " + aV.stype();
1384 inline bool value::divide(value& aThis,const value& aV,std::string& aError){
1385 value::e_type oType = aThis.m_type;
1386 switch(aThis.m_type) {
1391 aError = value::error_div_zero();
1395 int tmp = aThis.u.m_int/aV.u.m_int;
1400 if(aV.u.m_float==0.0F) {
1401 aError = value::error_div_zero();
1405 float tmp = float(aThis.u.m_int)/aV.u.m_float;
1410 if(aV.u.m_double==0) {
1411 aError = value::error_div_zero();
1415 double tmp = double(aThis.u.m_int)/aV.u.m_double;
1419 case value::ARRAY_DOUBLE:{
1420 int tmp = aThis.u.m_int;
1421 //In the below, this becomes a value::ARRAY_DOUBLE.
1422 aThis.set(aV.u.m_array_double->orders(),
1423 aV.u.m_array_double->vector());
1424 if(!aThis.u.m_array_double->invert()) {
1425 aError = value::error_div_zero();
1429 aThis.u.m_array_double->multiply((double)tmp);
1432 case value::VOID_STAR:
1436 //case value::UNSIGNED_CHAR:
1438 case value::UNSIGNED_SHORT :
1439 case value::UNSIGNED_INT:
1440 case value::UNSIGNED_INT64 :
1441 case value::DOUBLE_STAR:
1442 case value::FLOAT_STAR:
1443 case value::INT_STAR:
1445 //case value::ARRAY_UNSIGNED_CHAR:
1446 //case value::ARRAY_CHAR:
1447 case value::ARRAY_UNSIGNED_SHORT:
1448 case value::ARRAY_SHORT:
1449 case value::ARRAY_UNSIGNED_INT:
1450 case value::ARRAY_INT:
1451 case value::ARRAY_UNSIGNED_INT64:
1452 case value::ARRAY_INT64:
1453 case value::ARRAY_FLOAT:
1454 //case value::ARRAY_DOUBLE:
1455 case value::ARRAY_BOOL:
1456 case value::ARRAY_STRING:
1464 aError = value::error_div_zero();
1468 aThis.u.m_float /= aV.u.m_int;
1472 if(aV.u.m_short==0) {
1473 aError = value::error_div_zero();
1477 aThis.u.m_float /= aV.u.m_short;
1481 if(aV.u.m_float==0.0F) {
1482 aError = value::error_div_zero();
1486 aThis.u.m_float /= aV.u.m_float;
1490 if(aV.u.m_double==0.0F) {
1491 aError = value::error_div_zero();
1495 double tmp = double(aThis.u.m_float)/aV.u.m_double;
1499 case value::UNSIGNED_INT:
1500 if(aV.u.m_unsigned_int==0) {
1501 aError = value::error_div_zero();
1505 aThis.u.m_float /= aV.u.m_unsigned_int;
1508 case value::UNSIGNED_SHORT:
1509 if(aV.u.m_unsigned_short==0) {
1510 aError = value::error_div_zero();
1514 aThis.u.m_float /= aV.u.m_unsigned_short;
1517 case value::UNSIGNED_INT64:
1518 if(aV.u.m_unsigned_int64==0) {
1519 aError = value::error_div_zero();
1523 double tmp = double(aThis.u.m_float)/aV.u.m_unsigned_int64;
1528 if(aV.u.m_int64==0) {
1529 aError = value::error_div_zero();
1533 double tmp = double(aThis.u.m_float)/aV.u.m_int64;
1537 case value::ARRAY_DOUBLE:{
1538 double tmp = aThis.u.m_float;
1539 //In the below, this becomes a value::ARRAY_DOUBLE.
1540 aThis.set(aV.u.m_array_double->orders(),
1541 aV.u.m_array_double->vector());
1542 if(!aThis.u.m_array_double->invert()) {
1543 aError = value::error_div_zero();
1547 aThis.u.m_array_double->multiply(tmp);
1551 case value::VOID_STAR:
1553 //case value::UNSIGNED_CHAR:
1555 case value::DOUBLE_STAR:
1556 case value::FLOAT_STAR:
1557 case value::INT_STAR:
1559 //case value::ARRAY_UNSIGNED_CHAR:
1560 //case value::ARRAY_CHAR:
1561 case value::ARRAY_UNSIGNED_SHORT:
1562 case value::ARRAY_SHORT:
1563 case value::ARRAY_UNSIGNED_INT:
1564 case value::ARRAY_INT:
1565 case value::ARRAY_UNSIGNED_INT64:
1566 case value::ARRAY_INT64:
1567 case value::ARRAY_FLOAT:
1568 //case value::ARRAY_DOUBLE:
1569 case value::ARRAY_BOOL:
1570 case value::ARRAY_STRING:
1577 if(aV.u.m_short==0) {
1578 aError = value::error_div_zero();
1582 aThis.u.m_double /= aV.u.m_short;
1587 aError = value::error_div_zero();
1591 aThis.u.m_double /= aV.u.m_int;
1595 if(aV.u.m_int64==0) {
1596 aError = value::error_div_zero();
1600 aThis.u.m_double /= aV.u.m_int64;
1604 if(aV.u.m_float==0.0F) {
1605 aError = value::error_div_zero();
1609 aThis.u.m_double /= aV.u.m_float;
1613 if(aV.u.m_double==0) {
1614 aError = value::error_div_zero();
1618 aThis.u.m_double /= aV.u.m_double;
1621 case value::UNSIGNED_INT:
1622 if(aV.u.m_unsigned_int==0) {
1623 aError = value::error_div_zero();
1627 aThis.u.m_double /= aV.u.m_unsigned_int;
1630 case value::UNSIGNED_SHORT:
1631 if(aV.u.m_unsigned_short==0) {
1632 aError = value::error_div_zero();
1636 aThis.u.m_double /= aV.u.m_unsigned_short;
1639 case value::UNSIGNED_INT64:
1640 if(aV.u.m_unsigned_int64==0) {
1641 aError = value::error_div_zero();
1645 aThis.u.m_double /= aV.u.m_unsigned_int64;
1648 case value::ARRAY_DOUBLE:{
1649 double tmp = aThis.u.m_double;
1650 //In the below, this becomes a value::ARRAY_DOUBLE.
1651 aThis.set(aV.u.m_array_double->orders(),
1652 aV.u.m_array_double->vector());
1653 if(!aThis.u.m_array_double->invert()) {
1654 aError = value::error_div_zero();
1658 aThis.u.m_array_double->multiply(tmp);
1662 case value::VOID_STAR:
1664 //case value::UNSIGNED_CHAR:
1666 case value::DOUBLE_STAR:
1667 case value::FLOAT_STAR:
1668 case value::INT_STAR:
1670 //case value::ARRAY_UNSIGNED_CHAR:
1671 //case value::ARRAY_CHAR:
1672 case value::ARRAY_UNSIGNED_SHORT:
1673 case value::ARRAY_SHORT:
1674 case value::ARRAY_UNSIGNED_INT:
1675 case value::ARRAY_INT:
1676 case value::ARRAY_UNSIGNED_INT64:
1677 case value::ARRAY_INT64:
1678 case value::ARRAY_FLOAT:
1679 //case value::ARRAY_DOUBLE:
1680 case value::ARRAY_BOOL:
1681 case value::ARRAY_STRING:
1685 case value::UNSIGNED_INT:
1687 case value::UNSIGNED_INT:
1688 if(aV.u.m_unsigned_int==0) {
1689 aError = value::error_div_zero();
1693 unsigned int tmp = aThis.u.m_unsigned_int/aV.u.m_unsigned_int;
1698 if(aV.u.m_float==0) {
1699 aError = value::error_div_zero();
1703 float d = float(aThis.u.m_unsigned_int)/aV.u.m_float;
1704 aThis.set(d); //this becomes a value::FLOAT.
1708 if(aV.u.m_double==0) {
1709 aError = value::error_div_zero();
1713 double d = double(aThis.u.m_unsigned_int)/aV.u.m_double;
1714 aThis.set(d); //this becomes a value::DOUBLE.
1717 case value::ARRAY_DOUBLE:{
1718 unsigned int tmp = aThis.u.m_unsigned_int;
1719 //In the below, this becomes a value::ARRAY_DOUBLE.
1720 aThis.set(aV.u.m_array_double->orders(),
1721 aV.u.m_array_double->vector());
1722 if(!aThis.u.m_array_double->invert()) {
1723 aError = value::error_div_zero();
1727 aThis.u.m_array_double->multiply(double(tmp));
1732 case value::VOID_STAR:
1736 //case value::UNSIGNED_CHAR:
1738 case value::UNSIGNED_SHORT :
1739 case value::UNSIGNED_INT64 :
1740 case value::DOUBLE_STAR:
1741 case value::FLOAT_STAR:
1742 case value::INT_STAR:
1744 //case value::ARRAY_UNSIGNED_CHAR:
1745 //case value::ARRAY_CHAR:
1746 case value::ARRAY_UNSIGNED_SHORT:
1747 case value::ARRAY_SHORT:
1748 case value::ARRAY_UNSIGNED_INT:
1749 case value::ARRAY_INT:
1750 case value::ARRAY_UNSIGNED_INT64:
1751 case value::ARRAY_INT64:
1752 case value::ARRAY_FLOAT:
1753 //case value::ARRAY_DOUBLE:
1754 case value::ARRAY_BOOL:
1755 case value::ARRAY_STRING:
1759 case value::ARRAY_DOUBLE:
1763 aError = value::error_div_zero();
1767 double value = 1./aV.u.m_int;
1768 aThis.u.m_array_double->multiply(value);
1771 case value::UNSIGNED_INT:
1772 if(aV.u.m_unsigned_int==0) {
1773 aError = value::error_div_zero();
1777 double value = 1./aV.u.m_unsigned_int;
1778 aThis.u.m_array_double->multiply(value);
1782 if(aV.u.m_double==0) {
1783 aError = value::error_div_zero();
1787 aThis.u.m_array_double->multiply(1./aV.u.m_double);
1790 case value::ARRAY_DOUBLE:{
1791 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
1792 aError = value::error_div_zero(); //FIXME : error_mismatch_orders
1796 std::vector<double>& stdv = aThis.u.m_array_double->vector();
1797 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
1798 bool has_div_zero = false;
1799 size_t number = stdv.size();
1800 for(size_t index=0;index<number;index++) {
1801 if(stdv2[index]==0) {
1802 //FIXME : stdv[index] = nan;
1803 stdv[index] = 0; //PAW convention.
1804 has_div_zero = true;
1806 stdv[index] /= stdv2[index];
1810 aError = value::error_div_zero();
1811 // For OpenPAW/pasigm::SIGMA, continue anyway in case of /0 errors.
1813 //return false; //FIXME : is so, then it will stop Processor.
1814 return true; //FIXME : do we want that ?
1821 case value::VOID_STAR:
1825 //case value::UNSIGNED_CHAR:
1828 case value::UNSIGNED_SHORT :
1829 case value::UNSIGNED_INT64 :
1830 case value::DOUBLE_STAR:
1831 case value::FLOAT_STAR:
1832 case value::INT_STAR:
1833 //case value::ARRAY_UNSIGNED_CHAR:
1834 //case value::ARRAY_CHAR:
1835 case value::ARRAY_UNSIGNED_SHORT:
1836 case value::ARRAY_SHORT:
1837 case value::ARRAY_UNSIGNED_INT:
1838 case value::ARRAY_INT:
1839 case value::ARRAY_UNSIGNED_INT64:
1840 case value::ARRAY_INT64:
1841 case value::ARRAY_FLOAT:
1842 //case value::ARRAY_DOUBLE:
1843 case value::ARRAY_BOOL:
1844 case value::ARRAY_STRING:
1851 case value::VOID_STAR:
1854 //case value::UNSIGNED_CHAR:
1857 case value::UNSIGNED_SHORT :
1858 case value::UNSIGNED_INT64 :
1859 case value::DOUBLE_STAR:
1860 case value::FLOAT_STAR:
1861 case value::INT_STAR:
1862 //case value::ARRAY_UNSIGNED_CHAR:
1863 //case value::ARRAY_CHAR:
1864 case value::ARRAY_UNSIGNED_SHORT:
1865 case value::ARRAY_SHORT:
1866 case value::ARRAY_UNSIGNED_INT:
1867 case value::ARRAY_INT:
1868 case value::ARRAY_UNSIGNED_INT64:
1869 case value::ARRAY_INT64:
1870 case value::ARRAY_FLOAT:
1871 //case value::ARRAY_DOUBLE:
1872 case value::ARRAY_BOOL:
1873 case value::ARRAY_STRING:
1876 aError = std::string("Value::divide :")
1877 + " can't apply on type " + value::stype(oType)
1878 + " and type " + aV.stype();
1883 //////////////////////////////////////////////////////////////////////////////
1884 //////////////////////////////////////////////////////////////////////////////
1885 //////////////////////////////////////////////////////////////////////////////
1887 inline bool value::if_gt(value& aThis,const value& aV,std::string& aError){
1888 value::e_type oType = aThis.m_type;
1889 switch(aThis.m_type) {
1893 aThis.set((bool)(aThis.u.m_int>aV.u.m_int?true:false));
1896 aThis.set((bool)(aThis.u.m_int>aV.u.m_float?true:false));
1899 aThis.set((bool)(aThis.u.m_int>aV.u.m_double?true:false));
1901 case value::UNSIGNED_SHORT :
1902 aThis.set((bool)(aThis.u.m_int>(int)aV.u.m_unsigned_short?true:false));
1904 case value::UNSIGNED_INT:
1905 aThis.set((bool)(aThis.u.m_int>(int)aV.u.m_unsigned_int?true:false));
1907 case value::ARRAY_DOUBLE:{
1908 const std::vector<double>& stdv = aV.u.m_array_double->vector();
1909 size_t number = stdv.size();
1910 for(size_t index=0;index<number;index++) {
1911 if(aThis.u.m_int<=stdv[index]) {
1920 case value::VOID_STAR:
1924 //case value::UNSIGNED_CHAR:
1926 case value::UNSIGNED_INT64 :
1927 case value::DOUBLE_STAR:
1928 case value::FLOAT_STAR:
1929 case value::INT_STAR:
1931 //case value::ARRAY_UNSIGNED_CHAR:
1932 //case value::ARRAY_CHAR:
1933 case value::ARRAY_UNSIGNED_SHORT:
1934 case value::ARRAY_SHORT:
1935 case value::ARRAY_UNSIGNED_INT:
1936 case value::ARRAY_INT:
1937 case value::ARRAY_UNSIGNED_INT64:
1938 case value::ARRAY_INT64:
1939 case value::ARRAY_FLOAT:
1940 //case value::ARRAY_DOUBLE:
1941 case value::ARRAY_BOOL:
1942 case value::ARRAY_STRING:
1949 aThis.set((bool)(aThis.u.m_double>aV.u.m_double?true:false));
1952 aThis.set((bool)(aThis.u.m_double>aV.u.m_float?true:false));
1955 aThis.set((bool)(aThis.u.m_double>aV.u.m_int?true:false));
1957 case value::UNSIGNED_SHORT :
1958 aThis.set((bool)(aThis.u.m_double>aV.u.m_unsigned_short?true:false));
1960 case value::UNSIGNED_INT:
1961 aThis.set((bool)(aThis.u.m_double>aV.u.m_unsigned_int?true:false));
1963 case value::ARRAY_DOUBLE:{
1964 const std::vector<double>& stdv = aV.u.m_array_double->vector();
1965 size_t number = stdv.size();
1966 for(size_t index=0;index<number;index++) {
1967 if(aThis.u.m_double<=stdv[index]) {
1976 case value::VOID_STAR:
1980 //case value::UNSIGNED_CHAR:
1982 case value::UNSIGNED_INT64 :
1983 case value::DOUBLE_STAR:
1984 case value::FLOAT_STAR:
1985 case value::INT_STAR:
1987 //case value::ARRAY_UNSIGNED_CHAR:
1988 //case value::ARRAY_CHAR:
1989 case value::ARRAY_UNSIGNED_SHORT:
1990 case value::ARRAY_SHORT:
1991 case value::ARRAY_UNSIGNED_INT:
1992 case value::ARRAY_INT:
1993 case value::ARRAY_UNSIGNED_INT64:
1994 case value::ARRAY_INT64:
1995 case value::ARRAY_FLOAT:
1996 //case value::ARRAY_DOUBLE:
1997 case value::ARRAY_BOOL:
1998 case value::ARRAY_STRING:
2005 aThis.set((bool)(aThis.u.m_float>aV.u.m_double?true:false));
2008 aThis.set((bool)(aThis.u.m_float>aV.u.m_float?true:false));
2011 aThis.set((bool)(aThis.u.m_float>aV.u.m_int?true:false));
2013 case value::UNSIGNED_SHORT :
2014 aThis.set((bool)(aThis.u.m_float>aV.u.m_unsigned_short?true:false));
2016 case value::UNSIGNED_INT:
2017 aThis.set((bool)(aThis.u.m_float>aV.u.m_unsigned_int?true:false));
2019 case value::ARRAY_DOUBLE:{
2020 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2021 size_t number = stdv.size();
2022 for(size_t index=0;index<number;index++) {
2023 if(aThis.u.m_float<=stdv[index]) {
2032 case value::VOID_STAR:
2036 //case value::UNSIGNED_CHAR:
2038 case value::UNSIGNED_INT64 :
2039 case value::DOUBLE_STAR:
2040 case value::FLOAT_STAR:
2041 case value::INT_STAR:
2043 //case value::ARRAY_UNSIGNED_CHAR:
2044 //case value::ARRAY_CHAR:
2045 case value::ARRAY_UNSIGNED_SHORT:
2046 case value::ARRAY_SHORT:
2047 case value::ARRAY_UNSIGNED_INT:
2048 case value::ARRAY_INT:
2049 case value::ARRAY_UNSIGNED_INT64:
2050 case value::ARRAY_INT64:
2051 case value::ARRAY_FLOAT:
2052 //case value::ARRAY_DOUBLE:
2053 case value::ARRAY_BOOL:
2054 case value::ARRAY_STRING:
2058 case value::VOID_STAR:
2060 case value::VOID_STAR:
2061 aThis.set((bool)(aThis.u.m_void_star>aV.u.m_void_star?true:false));
2070 //case value::UNSIGNED_CHAR:
2072 case value::UNSIGNED_SHORT :
2073 case value::UNSIGNED_INT:
2074 case value::UNSIGNED_INT64 :
2075 case value::DOUBLE_STAR:
2076 case value::FLOAT_STAR:
2077 case value::INT_STAR:
2079 //case value::ARRAY_UNSIGNED_CHAR:
2080 //case value::ARRAY_CHAR:
2081 case value::ARRAY_UNSIGNED_SHORT:
2082 case value::ARRAY_SHORT:
2083 case value::ARRAY_UNSIGNED_INT:
2084 case value::ARRAY_INT:
2085 case value::ARRAY_UNSIGNED_INT64:
2086 case value::ARRAY_INT64:
2087 case value::ARRAY_FLOAT:
2088 case value::ARRAY_DOUBLE:
2089 case value::ARRAY_BOOL:
2090 case value::ARRAY_STRING:
2094 case value::UNSIGNED_INT:
2096 case value::UNSIGNED_INT:
2097 aThis.set((bool)(aThis.u.m_unsigned_int >aV.u.m_unsigned_int ?true:false));
2100 aThis.set((bool)((int)aThis.u.m_unsigned_int >aV.u.m_int?true:false));
2103 aThis.set((bool)(double(aThis.u.m_unsigned_int)>aV.u.m_double?true:false));
2106 aThis.set((bool)(float(aThis.u.m_unsigned_int)>aV.u.m_float?true:false));
2109 case value::VOID_STAR:
2113 //case value::UNSIGNED_CHAR:
2115 case value::UNSIGNED_SHORT :
2116 case value::UNSIGNED_INT64 :
2117 case value::DOUBLE_STAR:
2118 case value::FLOAT_STAR:
2119 case value::INT_STAR:
2121 //case value::ARRAY_UNSIGNED_CHAR:
2122 //case value::ARRAY_CHAR:
2123 case value::ARRAY_UNSIGNED_SHORT:
2124 case value::ARRAY_SHORT:
2125 case value::ARRAY_UNSIGNED_INT:
2126 case value::ARRAY_INT:
2127 case value::ARRAY_UNSIGNED_INT64:
2128 case value::ARRAY_INT64:
2129 case value::ARRAY_FLOAT:
2130 case value::ARRAY_DOUBLE:
2131 case value::ARRAY_BOOL:
2132 case value::ARRAY_STRING:
2136 case value::ARRAY_DOUBLE:
2139 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2140 size_t number = stdv.size();
2141 for(size_t index=0;index<number;index++) {
2142 if(stdv[index]<=aV.u.m_int) {
2151 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2152 size_t number = stdv.size();
2153 for(size_t index=0;index<number;index++) {
2154 if(stdv[index]<=aV.u.m_float) {
2162 case value::DOUBLE:{
2163 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2164 size_t number = stdv.size();
2165 for(size_t index=0;index<number;index++) {
2166 if(stdv[index]<=aV.u.m_double) {
2174 case value::UNSIGNED_INT:{
2175 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2176 size_t number = stdv.size();
2177 for(size_t index=0;index<number;index++) {
2178 if(stdv[index]<=aV.u.m_unsigned_int ) {
2186 case value::ARRAY_DOUBLE:{
2187 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2188 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
2189 if(stdv.size()!=stdv2.size()) break;
2190 size_t number = stdv.size();
2191 for(size_t index=0;index<number;index++) {
2192 if(stdv[index]<=stdv2[index]) {
2201 case value::VOID_STAR:
2205 //case value::UNSIGNED_CHAR:
2207 case value::UNSIGNED_SHORT :
2208 case value::UNSIGNED_INT64 :
2209 case value::DOUBLE_STAR:
2210 case value::FLOAT_STAR:
2211 case value::INT_STAR:
2213 //case value::ARRAY_UNSIGNED_CHAR:
2214 //case value::ARRAY_CHAR:
2215 case value::ARRAY_UNSIGNED_SHORT:
2216 case value::ARRAY_SHORT:
2217 case value::ARRAY_UNSIGNED_INT:
2218 case value::ARRAY_INT:
2219 case value::ARRAY_UNSIGNED_INT64:
2220 case value::ARRAY_INT64:
2221 case value::ARRAY_FLOAT:
2222 //case value::ARRAY_DOUBLE:
2223 case value::ARRAY_BOOL:
2224 case value::ARRAY_STRING:
2231 //case value::UNSIGNED_CHAR:
2235 case value::UNSIGNED_SHORT :
2236 case value::UNSIGNED_INT64 :
2237 case value::DOUBLE_STAR:
2238 case value::FLOAT_STAR:
2239 case value::INT_STAR:
2240 //case value::ARRAY_UNSIGNED_CHAR:
2241 //case value::ARRAY_CHAR:
2242 case value::ARRAY_UNSIGNED_SHORT:
2243 case value::ARRAY_SHORT:
2244 case value::ARRAY_UNSIGNED_INT:
2245 case value::ARRAY_INT:
2246 case value::ARRAY_UNSIGNED_INT64:
2247 case value::ARRAY_INT64:
2248 case value::ARRAY_FLOAT:
2249 //case value::ARRAY_DOUBLE:
2250 case value::ARRAY_BOOL:
2251 case value::ARRAY_STRING:
2254 aError = std::string("Value::if_gt() :")
2255 + " can't compare type " + value::stype(oType)
2256 + " with type " + aV.stype();
2261 inline bool value::if_eq(value& aThis,const value& aV,std::string& aError){
2262 value::e_type oType = aThis.m_type;
2263 switch(aThis.m_type) {
2267 aThis.set((bool)(aThis.u.m_int==aV.u.m_int?true:false));
2270 aThis.set((bool)(aThis.u.m_int==aV.u.m_double?true:false));
2273 aThis.set((bool)(aThis.u.m_int==aV.u.m_float?true:false));
2275 case value::UNSIGNED_SHORT :
2276 aThis.set((bool)(aThis.u.m_int==(int)aV.u.m_unsigned_short?true:false));
2278 case value::UNSIGNED_INT:
2279 aThis.set((bool)(aThis.u.m_int==(int)aV.u.m_unsigned_int ?true:false));
2281 case value::ARRAY_DOUBLE:{
2282 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2283 size_t number = stdv.size();
2284 for(size_t index=0;index<number;index++) {
2285 if(aThis.u.m_int!=stdv[index]) {
2296 case value::VOID_STAR:
2300 //case value::UNSIGNED_CHAR:
2302 case value::UNSIGNED_INT64 :
2303 case value::DOUBLE_STAR:
2304 case value::FLOAT_STAR:
2305 case value::INT_STAR:
2307 //case value::ARRAY_UNSIGNED_CHAR:
2308 //case value::ARRAY_CHAR:
2309 case value::ARRAY_UNSIGNED_SHORT:
2310 case value::ARRAY_SHORT:
2311 case value::ARRAY_UNSIGNED_INT:
2312 case value::ARRAY_INT:
2313 case value::ARRAY_UNSIGNED_INT64:
2314 case value::ARRAY_INT64:
2315 case value::ARRAY_FLOAT:
2316 //case value::ARRAY_DOUBLE:
2317 case value::ARRAY_BOOL:
2318 case value::ARRAY_STRING:
2325 aThis.set((bool)(aThis.u.m_float==aV.u.m_float?true:false));
2328 aThis.set((bool)(aThis.u.m_float==aV.u.m_double?true:false));
2331 aThis.set((bool)(aThis.u.m_float==aV.u.m_int?true:false));
2333 case value::UNSIGNED_SHORT :
2334 aThis.set((bool)(aThis.u.m_float==aV.u.m_unsigned_short?true:false));
2336 case value::UNSIGNED_INT:
2337 aThis.set((bool)(aThis.u.m_float==aV.u.m_unsigned_int?true:false));
2339 case value::ARRAY_DOUBLE:{
2340 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2341 size_t number = stdv.size();
2342 for(size_t index=0;index<number;index++) {
2343 if(aThis.u.m_float!=stdv[index]) {
2353 case value::VOID_STAR:
2356 //case value::UNSIGNED_CHAR:
2359 case value::UNSIGNED_INT64 :
2360 case value::DOUBLE_STAR:
2361 case value::FLOAT_STAR:
2362 case value::INT_STAR:
2363 //case value::ARRAY_UNSIGNED_CHAR:
2364 //case value::ARRAY_CHAR:
2365 case value::ARRAY_UNSIGNED_SHORT:
2366 case value::ARRAY_SHORT:
2367 case value::ARRAY_UNSIGNED_INT:
2368 case value::ARRAY_INT:
2369 case value::ARRAY_UNSIGNED_INT64:
2370 case value::ARRAY_INT64:
2371 case value::ARRAY_FLOAT:
2372 //case value::ARRAY_DOUBLE:
2373 case value::ARRAY_BOOL:
2374 case value::ARRAY_STRING:
2381 aThis.set((bool)(aThis.u.m_double==aV.u.m_double?true:false));
2384 aThis.set((bool)(aThis.u.m_double==aV.u.m_float?true:false));
2387 aThis.set((bool)(aThis.u.m_double==aV.u.m_int?true:false));
2389 case value::UNSIGNED_SHORT :
2390 aThis.set((bool)(aThis.u.m_double==aV.u.m_unsigned_short?true:false));
2392 case value::UNSIGNED_INT:
2393 aThis.set((bool)(aThis.u.m_double==aV.u.m_unsigned_int ?true:false));
2395 case value::ARRAY_DOUBLE:{
2396 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2397 size_t number = stdv.size();
2398 for(size_t index=0;index<number;index++) {
2399 if(aThis.u.m_double!=stdv[index]) {
2409 case value::VOID_STAR:
2412 //case value::UNSIGNED_CHAR:
2415 case value::UNSIGNED_INT64 :
2416 case value::DOUBLE_STAR:
2417 case value::FLOAT_STAR:
2418 case value::INT_STAR:
2419 //case value::ARRAY_UNSIGNED_CHAR:
2420 //case value::ARRAY_CHAR:
2421 case value::ARRAY_UNSIGNED_SHORT:
2422 case value::ARRAY_SHORT:
2423 case value::ARRAY_UNSIGNED_INT:
2424 case value::ARRAY_INT:
2425 case value::ARRAY_UNSIGNED_INT64:
2426 case value::ARRAY_INT64:
2427 case value::ARRAY_FLOAT:
2428 //case value::ARRAY_DOUBLE:
2429 case value::ARRAY_BOOL:
2430 case value::ARRAY_STRING:
2437 aThis.set((bool)((*aThis.u.m_string)==(*aV.u.m_string)?true:false));
2441 if(!to<int>(*aThis.u.m_string,v)) break;
2442 aThis.set((bool)(v==aV.u.m_int?true:false));
2446 if(!to<float>(*aThis.u.m_string,v)) break;
2447 aThis.set((bool)(v==aV.u.m_float?true:false));
2451 if(!to<double>(*aThis.u.m_string,v)) break;
2452 aThis.set((bool)(v==aV.u.m_double?true:false));
2454 case value::UNSIGNED_INT:
2455 {typedef unsigned int uint_t;
2457 if(!to<uint_t>(*aThis.u.m_string,v)) break;
2458 aThis.set((bool)(v==aV.u.m_unsigned_int ?true:false));
2462 if(!to(*aThis.u.m_string,v)) break;
2463 aThis.set((bool)(v==aV.u.m_bool?true:false));
2466 case value::VOID_STAR:
2468 //case value::UNSIGNED_CHAR:
2471 case value::UNSIGNED_SHORT :
2472 case value::UNSIGNED_INT64 :
2473 case value::DOUBLE_STAR:
2474 case value::FLOAT_STAR:
2475 case value::INT_STAR:
2476 //case value::ARRAY_UNSIGNED_CHAR:
2477 //case value::ARRAY_CHAR:
2478 case value::ARRAY_UNSIGNED_SHORT:
2479 case value::ARRAY_SHORT:
2480 case value::ARRAY_UNSIGNED_INT:
2481 case value::ARRAY_INT:
2482 case value::ARRAY_UNSIGNED_INT64:
2483 case value::ARRAY_INT64:
2484 case value::ARRAY_FLOAT:
2485 case value::ARRAY_DOUBLE:
2486 case value::ARRAY_BOOL:
2487 case value::ARRAY_STRING:
2491 case value::VOID_STAR:
2493 case value::VOID_STAR:
2494 aThis.set((bool)(aThis.u.m_void_star==aV.u.m_void_star?true:false));
2503 //case value::UNSIGNED_CHAR:
2505 case value::UNSIGNED_SHORT :
2506 case value::UNSIGNED_INT:
2507 case value::UNSIGNED_INT64 :
2508 case value::DOUBLE_STAR:
2509 case value::FLOAT_STAR:
2510 case value::INT_STAR:
2512 //case value::ARRAY_UNSIGNED_CHAR:
2513 //case value::ARRAY_CHAR:
2514 case value::ARRAY_UNSIGNED_SHORT:
2515 case value::ARRAY_SHORT:
2516 case value::ARRAY_UNSIGNED_INT:
2517 case value::ARRAY_INT:
2518 case value::ARRAY_UNSIGNED_INT64:
2519 case value::ARRAY_INT64:
2520 case value::ARRAY_FLOAT:
2521 case value::ARRAY_DOUBLE:
2522 case value::ARRAY_BOOL:
2523 case value::ARRAY_STRING:
2527 case value::UNSIGNED_INT:
2529 case value::UNSIGNED_INT:
2530 aThis.set((bool)(aThis.u.m_unsigned_int ==aV.u.m_unsigned_int ?true:false));
2533 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_int?true:false));
2536 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_float?true:false));
2539 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_double?true:false));
2541 case value::ARRAY_DOUBLE:{
2542 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2543 size_t number = stdv.size();
2544 for(size_t index=0;index<number;index++) {
2545 if(aThis.u.m_unsigned_int !=stdv[index]) {
2555 case value::VOID_STAR:
2558 //case value::UNSIGNED_CHAR:
2560 case value::UNSIGNED_SHORT :
2561 case value::UNSIGNED_INT64 :
2562 case value::DOUBLE_STAR:
2563 case value::FLOAT_STAR:
2564 case value::INT_STAR:
2566 //case value::ARRAY_UNSIGNED_CHAR:
2567 //case value::ARRAY_CHAR:
2568 case value::ARRAY_UNSIGNED_SHORT:
2569 case value::ARRAY_SHORT:
2570 case value::ARRAY_UNSIGNED_INT:
2571 case value::ARRAY_INT:
2572 case value::ARRAY_UNSIGNED_INT64:
2573 case value::ARRAY_INT64:
2574 case value::ARRAY_FLOAT:
2575 //case value::ARRAY_DOUBLE:
2576 case value::ARRAY_BOOL:
2577 case value::ARRAY_STRING:
2584 aThis.u.m_bool = ((aThis.u.m_bool==aV.u.m_bool)?true:false);
2589 case value::VOID_STAR:
2593 //case value::UNSIGNED_CHAR:
2595 case value::UNSIGNED_SHORT :
2596 case value::UNSIGNED_INT:
2597 case value::UNSIGNED_INT64 :
2598 case value::DOUBLE_STAR:
2599 case value::FLOAT_STAR:
2600 case value::INT_STAR:
2602 //case value::ARRAY_UNSIGNED_CHAR:
2603 //case value::ARRAY_CHAR:
2604 case value::ARRAY_UNSIGNED_SHORT:
2605 case value::ARRAY_SHORT:
2606 case value::ARRAY_UNSIGNED_INT:
2607 case value::ARRAY_INT:
2608 case value::ARRAY_UNSIGNED_INT64:
2609 case value::ARRAY_INT64:
2610 case value::ARRAY_FLOAT:
2611 case value::ARRAY_DOUBLE:
2612 case value::ARRAY_BOOL:
2613 case value::ARRAY_STRING:
2617 case value::ARRAY_DOUBLE:
2620 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2621 size_t number = stdv.size();
2622 for(size_t index=0;index<number;index++) {
2623 if(stdv[index]!=aV.u.m_int) {
2632 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2633 size_t number = stdv.size();
2634 for(size_t index=0;index<number;index++) {
2635 if(stdv[index]!=aV.u.m_float) {
2643 case value::DOUBLE:{
2644 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2645 size_t number = stdv.size();
2646 for(size_t index=0;index<number;index++) {
2647 if(stdv[index]!=aV.u.m_double) {
2655 case value::UNSIGNED_INT:{
2656 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2657 size_t number = stdv.size();
2658 for(size_t index=0;index<number;index++) {
2659 if(stdv[index]!=aV.u.m_unsigned_int ) {
2667 case value::ARRAY_DOUBLE:{
2668 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2669 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
2670 if(stdv.size()!=stdv2.size()) {
2674 size_t number = stdv.size();
2675 for(size_t index=0;index<number;index++) {
2676 if(stdv[index]!=stdv2[index]) {
2685 case value::VOID_STAR:
2688 //case value::UNSIGNED_CHAR:
2692 case value::UNSIGNED_SHORT :
2693 case value::UNSIGNED_INT64 :
2694 case value::DOUBLE_STAR:
2695 case value::FLOAT_STAR:
2696 case value::INT_STAR:
2697 //case value::ARRAY_UNSIGNED_CHAR:
2698 //case value::ARRAY_CHAR:
2699 case value::ARRAY_UNSIGNED_SHORT:
2700 case value::ARRAY_SHORT:
2701 case value::ARRAY_UNSIGNED_INT:
2702 case value::ARRAY_INT:
2703 case value::ARRAY_UNSIGNED_INT64:
2704 case value::ARRAY_INT64:
2705 case value::ARRAY_FLOAT:
2706 //case value::ARRAY_DOUBLE:
2707 case value::ARRAY_BOOL:
2708 case value::ARRAY_STRING:
2715 //case value::UNSIGNED_CHAR:
2717 case value::UNSIGNED_SHORT :
2718 case value::UNSIGNED_INT64 :
2719 case value::DOUBLE_STAR:
2720 case value::FLOAT_STAR:
2721 case value::INT_STAR:
2722 //case value::ARRAY_UNSIGNED_CHAR:
2723 //case value::ARRAY_CHAR:
2724 case value::ARRAY_UNSIGNED_SHORT:
2725 case value::ARRAY_SHORT:
2726 case value::ARRAY_UNSIGNED_INT:
2727 case value::ARRAY_INT:
2728 case value::ARRAY_UNSIGNED_INT64:
2729 case value::ARRAY_INT64:
2730 case value::ARRAY_FLOAT:
2731 //case value::ARRAY_DOUBLE:
2732 case value::ARRAY_BOOL:
2733 case value::ARRAY_STRING:
2736 aError = std::string("Value::if_eq() :")
2737 + " can't compare type " + value::stype(oType)
2738 + " with type " + aV.stype();
2743 inline bool value::if_and(value& aThis,const value& aV,std::string& aError){
2744 value::e_type oType = aThis.m_type;
2745 switch(aThis.m_type) {
2749 aThis.u.m_bool = ((aThis.u.m_bool && aV.u.m_bool)?true:false);
2755 case value::VOID_STAR:
2759 //case value::UNSIGNED_CHAR:
2761 case value::UNSIGNED_SHORT :
2762 case value::UNSIGNED_INT64 :
2763 case value::DOUBLE_STAR:
2764 case value::FLOAT_STAR:
2765 case value::INT_STAR:
2766 case value::UNSIGNED_INT:
2767 //case value::ARRAY_UNSIGNED_CHAR:
2768 //case value::ARRAY_CHAR:
2769 case value::ARRAY_UNSIGNED_SHORT:
2770 case value::ARRAY_SHORT:
2771 case value::ARRAY_UNSIGNED_INT:
2772 case value::ARRAY_INT:
2773 case value::ARRAY_UNSIGNED_INT64:
2774 case value::ARRAY_INT64:
2775 case value::ARRAY_FLOAT:
2776 case value::ARRAY_DOUBLE:
2777 case value::ARRAY_BOOL:
2778 case value::ARRAY_STRING:
2785 case value::VOID_STAR:
2789 //case value::UNSIGNED_CHAR:
2791 case value::UNSIGNED_SHORT :
2792 case value::UNSIGNED_INT:
2793 case value::UNSIGNED_INT64 :
2794 case value::DOUBLE_STAR:
2795 case value::FLOAT_STAR:
2796 case value::INT_STAR:
2798 //case value::ARRAY_UNSIGNED_CHAR:
2799 //case value::ARRAY_CHAR:
2800 case value::ARRAY_UNSIGNED_SHORT:
2801 case value::ARRAY_SHORT:
2802 case value::ARRAY_UNSIGNED_INT:
2803 case value::ARRAY_INT:
2804 case value::ARRAY_UNSIGNED_INT64:
2805 case value::ARRAY_INT64:
2806 case value::ARRAY_FLOAT:
2807 case value::ARRAY_DOUBLE:
2808 case value::ARRAY_BOOL:
2809 case value::ARRAY_STRING:
2812 aError = std::string("Value::if_and :")
2813 + " can't apply on type " + value::stype(oType)
2814 + " and type " + aV.stype();
2819 inline bool value::if_or(value& aThis,const value& aV,std::string& aError){
2820 value::e_type oType = aThis.m_type;
2821 switch(aThis.m_type) {
2825 aThis.u.m_bool = ((aThis.u.m_bool || aV.u.m_bool)?true:false);
2831 case value::VOID_STAR:
2835 //case value::UNSIGNED_CHAR:
2837 case value::UNSIGNED_SHORT :
2838 case value::UNSIGNED_INT64 :
2839 case value::DOUBLE_STAR:
2840 case value::FLOAT_STAR:
2841 case value::INT_STAR:
2842 case value::UNSIGNED_INT:
2843 //case value::ARRAY_UNSIGNED_CHAR:
2844 //case value::ARRAY_CHAR:
2845 case value::ARRAY_UNSIGNED_SHORT:
2846 case value::ARRAY_SHORT:
2847 case value::ARRAY_UNSIGNED_INT:
2848 case value::ARRAY_INT:
2849 case value::ARRAY_UNSIGNED_INT64:
2850 case value::ARRAY_INT64:
2851 case value::ARRAY_FLOAT:
2852 case value::ARRAY_DOUBLE:
2853 case value::ARRAY_BOOL:
2854 case value::ARRAY_STRING:
2861 case value::VOID_STAR:
2865 //case value::UNSIGNED_CHAR:
2867 case value::UNSIGNED_SHORT :
2868 case value::UNSIGNED_INT:
2869 case value::UNSIGNED_INT64 :
2870 case value::DOUBLE_STAR:
2871 case value::FLOAT_STAR:
2872 case value::INT_STAR:
2874 //case value::ARRAY_UNSIGNED_CHAR:
2875 //case value::ARRAY_CHAR:
2876 case value::ARRAY_UNSIGNED_SHORT:
2877 case value::ARRAY_SHORT:
2878 case value::ARRAY_UNSIGNED_INT:
2879 case value::ARRAY_INT:
2880 case value::ARRAY_UNSIGNED_INT64:
2881 case value::ARRAY_INT64:
2882 case value::ARRAY_FLOAT:
2883 case value::ARRAY_DOUBLE:
2884 case value::ARRAY_BOOL:
2885 case value::ARRAY_STRING:
2888 aError = std::string("Value::if_or :")
2889 + " can't apply on type " + value::stype(oType)
2890 + " and type " + aV.stype();
2895 inline bool value::to_double(const value& aThis,double& aValue){
2896 switch(aThis.m_type) {
2898 aValue = aThis.u.m_int;
2901 aValue = aThis.u.m_double;
2903 case value::UNSIGNED_SHORT:
2904 aValue = aThis.u.m_unsigned_short;
2906 case value::UNSIGNED_INT:
2907 aValue = aThis.u.m_unsigned_int;
2910 aValue = aThis.u.m_short;
2913 aValue = (double)aThis.u.m_int64;
2915 case value::UNSIGNED_INT64:
2916 aValue = (double)aThis.u.m_unsigned_int64;
2919 aValue = aThis.u.m_float;
2921 //case value::UNSIGNED_CHAR:
2922 // aValue = aThis.u.m_unsigned_char;
2925 // aValue = aThis.u.m_char;
2928 aValue = aThis.u.m_bool?1:0;
2932 case value::VOID_STAR:
2933 case value::DOUBLE_STAR:
2934 case value::FLOAT_STAR:
2935 case value::INT_STAR:
2936 //case value::ARRAY_UNSIGNED_CHAR:
2937 //case value::ARRAY_CHAR:
2938 case value::ARRAY_UNSIGNED_SHORT:
2939 case value::ARRAY_SHORT:
2940 case value::ARRAY_UNSIGNED_INT:
2941 case value::ARRAY_INT:
2942 case value::ARRAY_UNSIGNED_INT64:
2943 case value::ARRAY_INT64:
2944 case value::ARRAY_FLOAT:
2945 case value::ARRAY_DOUBLE:
2946 case value::ARRAY_BOOL:
2947 case value::ARRAY_STRING:
2954 inline bool value::cxx_type(const value& aThis,std::string& aValue){
2955 switch(aThis.m_type) {
2963 aValue = "std::string";
2977 //case value::UNSIGNED_CHAR:
2978 // aValue = "unsigned char";
2980 case value::UNSIGNED_SHORT:
2981 aValue = "unsigned short";
2983 case value::UNSIGNED_INT:
2984 aValue = "unsigned int";
2986 case value::VOID_STAR:
2989 case value::DOUBLE_STAR:
2992 case value::FLOAT_STAR:
2995 case value::INT_STAR:
3000 case value::UNSIGNED_INT64:
3001 //case value::ARRAY_UNSIGNED_CHAR:
3002 //case value::ARRAY_CHAR:
3003 case value::ARRAY_UNSIGNED_SHORT:
3004 case value::ARRAY_SHORT:
3005 case value::ARRAY_UNSIGNED_INT:
3006 case value::ARRAY_INT:
3007 case value::ARRAY_UNSIGNED_INT64:
3008 case value::ARRAY_INT64:
3009 case value::ARRAY_FLOAT:
3010 case value::ARRAY_DOUBLE:
3011 case value::ARRAY_BOOL:
3012 case value::ARRAY_STRING:
3020 inline bool value::i_set(value& aThis,const Slash::Core::IValue& aValue){
3023 aThis.m_type = aValue.type();
3025 switch(aValue.type()) {
3027 aThis.u.m_unsigned_int64 = 0;
3030 aThis.u.m_char = aValue.get_char();
3033 aThis.u.m_short = aValue.get_short();
3036 aThis.u.m_int = aValue.get_int();
3039 aThis.u.m_int64 = aValue.get_int64();
3041 case value::UNSIGNED_INT64:
3042 aThis.u.m_unsigned_int64 = aValue.get_unsigned_int64();
3044 //case value::UNSIGNED_CHAR:
3045 // aThis.u.m_unsigned_char = aValue.get_unsigned_char();
3047 case value::UNSIGNED_SHORT:
3048 aThis.u.m_unsigned_short = aValue.get_unsigned_short();
3050 case value::UNSIGNED_INT:
3051 aThis.u.m_unsigned_int = aValue.get_unsigned_int();
3053 case value::DOUBLE_STAR:
3054 aThis.u.m_double_star = aValue.get_double_star();
3056 case value::FLOAT_STAR:
3057 aThis.u.m_float_star = aValue.get_float_star();
3059 case value::INT_STAR:
3060 aThis.u.m_int_star = aValue.get_int_star();
3063 aThis.u.m_float = aValue.get_float();
3066 aThis.u.m_double = aValue.get_double();
3068 case value::VOID_STAR:
3069 aThis.u.m_void_star = aValue.get_void_star();
3072 aThis.u.m_bool = aValue.get_bool();
3075 aThis.u.m_string = new std::string(aValue.get_string());
3078 case value::ARRAY_UNSIGNED_CHAR:
3079 {std::vector<unsigned int> is;
3080 const std::vector<unsigned char>& vd = aValue.get_array_unsigned_char(is);
3081 aThis.u.m_array_unsigned_char = new array<unsigned char>();
3082 if(!aThis.u.m_array_unsigned_char->configure(is)){
3083 aThis.set_none();return false;
3085 if(!aThis.u.m_array_unsigned_char->fill(vd)){aThis.set_none();return false;}
3088 case value::ARRAY_CHAR:
3089 {std::vector<unsigned int> is;
3090 const std::vector<char>& vd = aValue.get_array_char(is);
3091 aThis.u.m_array_char = new array<char>();
3092 if(!aThis.u.m_array_char->configure(is)){
3093 aThis.set_none();return false;
3095 if(!aThis.u.m_array_char->fill(vd)){aThis.set_none();return false;}
3097 case value::ARRAY_UNSIGNED_SHORT:
3098 {std::vector<unsigned int> is;
3099 const std::vector<unsigned short>& vd =
3100 aValue.get_array_unsigned_short(is);
3101 aThis.u.m_array_unsigned_short = new array<unsigned short>();
3102 if(!aThis.u.m_array_unsigned_short->configure(is)){
3103 aThis.set_none();return false;
3105 if(!aThis.u.m_array_unsigned_short->fill(vd)){
3106 aThis.set_none();return false;
3110 case value::ARRAY_SHORT:
3111 {std::vector<unsigned int> is;
3112 const std::vector<short>& vd = aValue.get_array_short(is);
3113 aThis.u.m_array_short = new array<short>();
3114 if(!aThis.u.m_array_short->configure(is)){aThis.set_none();return false;}
3115 if(!aThis.u.m_array_short->fill(vd)){aThis.set_none();return false;}
3118 case value::ARRAY_UNSIGNED_INT:
3119 {std::vector<unsigned int> is;
3120 const std::vector<unsigned int>& vd = aValue.get_array_unsigned_int(is);
3121 aThis.u.m_array_unsigned_int = new array<unsigned int>();
3122 if(!aThis.u.m_array_unsigned_int->configure(is)){
3123 aThis.set_none();return false;
3125 if(!aThis.u.m_array_unsigned_int->fill(vd)){
3126 aThis.set_none();return false;
3130 case value::ARRAY_INT:
3131 {std::vector<unsigned int> is;
3132 const std::vector<int>& vd = aValue.get_array_int(is);
3133 aThis.u.m_array_int = new array<int>();
3134 if(!aThis.u.m_array_int->configure(is)){aThis.set_none();return false;}
3135 if(!aThis.u.m_array_int->fill(vd)){aThis.set_none();return false;}
3138 case value::ARRAY_UNSIGNED_INT64:
3139 {std::vector<unsigned int> is;
3140 const std::vector<uint64>& vd = aValue.get_array_unsigned_int64(is);
3141 aThis.u.m_array_unsigned_int64 = new array<uint64>();
3142 if(!aThis.u.m_array_unsigned_int64->configure(is)){
3143 aThis.set_none();return false;
3145 if(!aThis.u.m_array_unsigned_int64->fill(vd)){
3146 aThis.set_none();return false;
3150 case value::ARRAY_INT64:
3151 {std::vector<unsigned int> is;
3152 const std::vector<int64>& vd = aValue.get_array_int64(is);
3153 aThis.u.m_array_int64 = new array<int64>();
3154 if(!aThis.u.m_array_int64->configure(is)){aThis.set_none();return false;}
3155 if(!aThis.u.m_array_int64->fill(vd)){aThis.set_none();return false;}
3158 case value::ARRAY_FLOAT:
3159 {std::vector<unsigned int> is;
3160 const std::vector<float>& vd = aValue.get_array_float(is);
3161 aThis.u.m_array_float = new array<float>();
3162 if(!aThis.u.m_array_float->configure(is)){aThis.set_none();return false;}
3163 if(!aThis.u.m_array_float->fill(vd)){aThis.set_none();return false;}
3166 case value::ARRAY_DOUBLE:
3167 {std::vector<unsigned int> is;
3168 const std::vector<double>& vd = aValue.get_array_double(is);
3169 aThis.u.m_array_double = new array<double>();
3170 if(!aThis.u.m_array_double->configure(is)){aThis.set_none();return false;}
3171 if(!aThis.u.m_array_double->fill(vd)){aThis.set_none();return false;}
3174 case value::ARRAY_BOOL:
3175 {std::vector<unsigned int> is;
3176 const std::vector<bool>& vd = aValue.get_array_bool(is);
3177 aThis.u.m_array_bool = new array<bool>();
3178 if(!aThis.u.m_array_bool->configure(is)){aThis.set_none();return false;}
3179 if(!aThis.u.m_array_bool->fill(vd)){aThis.set_none();return false;}
3182 case value::ARRAY_STRING:
3183 {std::vector<unsigned int> is;
3184 const std::vector<std::string>& vd = aValue.get_array_string(is);
3185 aThis.u.m_array_string = new array<std::string>();
3186 if(!aThis.u.m_array_string->configure(is)){aThis.set_none();return false;}
3187 if(!aThis.u.m_array_string->fill(vd)){aThis.set_none();return false;}
3197 inline std::string value::to_string(const value& aThis){
3199 switch(aThis.m_type) {
3201 sprintf(s,5,"(nil)");
3204 sprintf(s,16,"%d",aThis.u.m_int);
3207 sprintf(s,16,"%g",aThis.u.m_double);
3209 case value::VOID_STAR:
3210 sprintf(s,32,upointer_format_x(),(upointer)aThis.u.m_void_star);
3212 case value::UNSIGNED_SHORT:
3213 sprintf(s,16,"%u",aThis.u.m_unsigned_short);
3215 case value::UNSIGNED_INT:
3216 sprintf(s,16,"%u",aThis.u.m_unsigned_int);
3219 sprintf(s,5,"%s",aThis.u.m_bool?"true":"false");
3222 sprintf(s,16,"%d",aThis.u.m_short);
3225 sprintf(s,16,int64_format(),aThis.u.m_int64);
3227 case value::UNSIGNED_INT64:{
3228 sprintf(s,16,int64_format(),aThis.u.m_unsigned_int64);
3231 sprintf(s,16,"%g",aThis.u.m_float);
3233 //case value::UNSIGNED_CHAR:
3234 // sprintf(s,16,"%c",aThis.u.m_unsigned_char);
3237 // sprintf(s,16,"%c",aThis.u.m_char);
3239 case value::DOUBLE_STAR:
3240 sprintf(s,32,upointer_format_x(),(upointer)aThis.u.m_double_star);
3242 case value::FLOAT_STAR:
3243 sprintf(s,32,upointer_format_x(),(upointer)aThis.u.m_float_star);
3245 case value::INT_STAR:
3246 sprintf(s,32,upointer_format_x(),(upointer)aThis.u.m_int_star);
3249 return *aThis.u.m_string;
3251 //case value::ARRAY_UNSIGNED_CHAR:
3252 // return tos<unsigned char>(aThis.u.m_array_unsigned_char->vector());
3253 //case value::ARRAY_CHAR:
3254 // return tos<char>(aThis.u.m_array_char->vector());
3255 case value::ARRAY_UNSIGNED_SHORT:
3256 if(!nums2s<unsigned short>(aThis.u.m_array_unsigned_short->vector(),s)) {}
3258 case value::ARRAY_SHORT:
3259 if(!nums2s<short>(aThis.u.m_array_short->vector(),s)) {}
3262 case value::ARRAY_UNSIGNED_INT:
3263 if(!nums2s<unsigned int>(aThis.u.m_array_unsigned_int->vector(),s)) {}
3265 case value::ARRAY_INT:
3266 if(!nums2s<int>(aThis.u.m_array_int->vector(),s)) {}
3269 case value::ARRAY_UNSIGNED_INT64:
3270 if(!nums2s<uint64>(aThis.u.m_array_unsigned_int64->vector(),s)) {}
3272 case value::ARRAY_INT64:
3273 if(!nums2s<int64>(aThis.u.m_array_int64->vector(),s)) {}
3276 case value::ARRAY_FLOAT:
3277 if(!nums2s<float>(aThis.u.m_array_float->vector(),s)) {}
3279 case value::ARRAY_DOUBLE:
3280 if(!nums2s<double>(aThis.u.m_array_double->vector(),s)) {}
3282 case value::ARRAY_BOOL:
3283 b2s(aThis.u.m_array_bool->vector(),s);
3285 case value::ARRAY_STRING:
3286 if(!nums2s<std::string>(aThis.u.m_array_string->vector(),s)) {}
3289 return "unknown"; //it should not happen.