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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::array<int64>(*aV.u.m_array_int64);
37 } else if(aV.m_type==value::ARRAY_FLOAT) {
38 aThis.u.m_array_float = new tools::array<float>(*aV.u.m_array_float);
39 } else if(aV.m_type==value::ARRAY_DOUBLE) {
40 aThis.u.m_array_double = new tools::array<double>(*aV.u.m_array_double);
41 } else if(aV.m_type==value::ARRAY_BOOL) {
42 aThis.u.m_array_bool = new tools::array<bool>(*aV.u.m_array_bool);
44 } else if(aV.m_type==value::ARRAY_STRING) {
45 aThis.u.m_array_string =
46 new tools::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 unsigned int number = stdv.size();
344 for(unsigned int 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 aThis.u.m_float -= (float)aV.u.m_double;
823 case value::UNSIGNED_SHORT :
824 aThis.u.m_float -= aV.u.m_unsigned_short;
826 case value::UNSIGNED_INT:
827 aThis.u.m_float -= aV.u.m_unsigned_int;
829 case value::ARRAY_DOUBLE:{
830 double tmp = aThis.u.m_float;
831 //In the below, this becomes a value::ARRAY_DOUBLE.
832 aThis.set(aV.u.m_array_double->orders(),
833 aV.u.m_array_double->vector());
834 aThis.u.m_array_double->multiply(-1);
835 aThis.u.m_array_double->add(tmp);
839 case value::VOID_STAR:
844 //case value::UNSIGNED_CHAR:
846 case value::UNSIGNED_INT64 :
847 case value::DOUBLE_STAR:
848 case value::FLOAT_STAR:
849 case value::INT_STAR:
851 //case value::ARRAY_UNSIGNED_CHAR:
852 //case value::ARRAY_CHAR:
853 case value::ARRAY_UNSIGNED_SHORT:
854 case value::ARRAY_SHORT:
855 case value::ARRAY_UNSIGNED_INT:
856 case value::ARRAY_INT:
857 case value::ARRAY_UNSIGNED_INT64:
858 case value::ARRAY_INT64:
859 case value::ARRAY_FLOAT:
860 //case value::ARRAY_DOUBLE:
861 case value::ARRAY_BOOL:
862 case value::ARRAY_STRING:
869 aThis.u.m_double -= aV.u.m_double;
871 case value::UNSIGNED_SHORT :
872 aThis.u.m_double -= aV.u.m_unsigned_short;
874 case value::UNSIGNED_INT:
875 aThis.u.m_double -= aV.u.m_unsigned_int;
877 case value::ARRAY_DOUBLE:{
878 double tmp = aThis.u.m_double;
879 //In the below, this becomes a value::ARRAY_DOUBLE.
880 aThis.set(aV.u.m_array_double->orders(),
881 aV.u.m_array_double->vector());
882 aThis.u.m_array_double->multiply(-1);
883 aThis.u.m_array_double->add(tmp);
887 case value::VOID_STAR:
892 //case value::UNSIGNED_CHAR:
894 case value::UNSIGNED_INT64 :
895 case value::DOUBLE_STAR:
896 case value::FLOAT_STAR:
897 case value::INT_STAR:
899 //case value::ARRAY_UNSIGNED_CHAR:
900 //case value::ARRAY_CHAR:
901 case value::ARRAY_UNSIGNED_SHORT:
902 case value::ARRAY_SHORT:
903 case value::ARRAY_UNSIGNED_INT:
904 case value::ARRAY_INT:
905 case value::ARRAY_UNSIGNED_INT64:
906 case value::ARRAY_INT64:
907 case value::ARRAY_FLOAT:
908 //case value::ARRAY_DOUBLE:
909 case value::ARRAY_BOOL:
910 case value::ARRAY_STRING:
914 case value::UNSIGNED_INT:
917 //case value::UNSIGNED_INT:
918 // aThis.u.m_unsigned_int -= aV.u.m_unsigned_int;
920 case value::ARRAY_DOUBLE:{
921 unsigned int tmp = aThis.u.m_unsigned_int;
922 //In the below, this becomes a value::ARRAY_DOUBLE.
923 aThis.set(aV.u.m_array_double->orders(),
924 aV.u.m_array_double->vector());
925 aThis.u.m_array_double->multiply(-1);
926 aThis.u.m_array_double->add(double(tmp));
929 double d = double(aThis.u.m_unsigned_int) - aV.u.m_double;
930 aThis.set(d); //this becomes a value::DOUBLE.
934 case value::VOID_STAR:
939 //case value::UNSIGNED_CHAR:
941 case value::UNSIGNED_SHORT :
942 case value::UNSIGNED_INT:
943 case value::UNSIGNED_INT64 :
944 case value::DOUBLE_STAR:
945 case value::FLOAT_STAR:
946 case value::INT_STAR:
948 //case value::ARRAY_UNSIGNED_CHAR:
949 //case value::ARRAY_CHAR:
950 case value::ARRAY_UNSIGNED_SHORT:
951 case value::ARRAY_SHORT:
952 case value::ARRAY_UNSIGNED_INT:
953 case value::ARRAY_INT:
954 case value::ARRAY_UNSIGNED_INT64:
955 case value::ARRAY_INT64:
956 case value::ARRAY_FLOAT:
957 //case value::ARRAY_DOUBLE:
958 case value::ARRAY_BOOL:
959 case value::ARRAY_STRING:
963 case value::ARRAY_DOUBLE:
966 aThis.u.m_array_double->add(-aV.u.m_int);
968 case value::UNSIGNED_INT:
969 aThis.u.m_array_double->add(-((double)aV.u.m_unsigned_int));
972 aThis.u.m_array_double->add(-aV.u.m_double);
974 case value::ARRAY_DOUBLE:{
975 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
976 aError = "Value::subtract : vector orders mismatch.";
980 std::vector<double>& stdv = aThis.u.m_array_double->vector();
981 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
982 unsigned int number = stdv.size();
983 for(unsigned int index=0;index<number;index++) {
984 stdv[index] -= stdv2[index];
988 case value::VOID_STAR:
993 //case value::UNSIGNED_CHAR:
995 case value::UNSIGNED_SHORT :
996 case value::UNSIGNED_INT64 :
997 case value::DOUBLE_STAR:
998 case value::FLOAT_STAR:
999 case value::INT_STAR:
1001 //case value::ARRAY_UNSIGNED_CHAR:
1002 //case value::ARRAY_CHAR:
1003 case value::ARRAY_UNSIGNED_SHORT:
1004 case value::ARRAY_SHORT:
1005 case value::ARRAY_UNSIGNED_INT:
1006 case value::ARRAY_INT:
1007 case value::ARRAY_UNSIGNED_INT64:
1008 case value::ARRAY_INT64:
1009 case value::ARRAY_FLOAT:
1010 //case value::ARRAY_DOUBLE:
1011 case value::ARRAY_BOOL:
1012 case value::ARRAY_STRING:
1017 case value::VOID_STAR:
1021 //case value::UNSIGNED_CHAR:
1023 case value::UNSIGNED_SHORT :
1024 case value::UNSIGNED_INT64 :
1025 case value::DOUBLE_STAR:
1026 case value::FLOAT_STAR:
1027 case value::INT_STAR:
1029 //case value::ARRAY_UNSIGNED_CHAR:
1030 //case value::ARRAY_CHAR:
1031 case value::ARRAY_UNSIGNED_SHORT:
1032 case value::ARRAY_SHORT:
1033 case value::ARRAY_UNSIGNED_INT:
1034 case value::ARRAY_INT:
1035 case value::ARRAY_UNSIGNED_INT64:
1036 case value::ARRAY_INT64:
1037 case value::ARRAY_FLOAT:
1038 //case value::ARRAY_DOUBLE:
1039 case value::ARRAY_BOOL:
1040 case value::ARRAY_STRING:
1043 aError = std::string("Value::subtract :" )
1044 + " can't apply on type " + value::stype(oType)
1045 + " and type " + aV.stype();
1050 inline bool value::multiply(value& aThis,const value& aV,std::string& aError){
1051 value::e_type oType = aThis.m_type;
1052 switch(aThis.m_type) {
1056 aThis.u.m_int *= aV.u.m_int;
1059 aThis.u.m_int *= (int)aV.u.m_double;
1062 aThis.u.m_int *= (int)aV.u.m_float;
1064 case value::ARRAY_DOUBLE:{
1065 int tmp = aThis.u.m_int;
1066 //In the below, this becomes a value::ARRAY_DOUBLE.
1067 aThis.set(aV.u.m_array_double->orders(),
1068 aV.u.m_array_double->vector());
1069 aThis.u.m_array_double->multiply(double(tmp));
1072 case value::VOID_STAR:
1076 //case value::UNSIGNED_CHAR:
1078 case value::UNSIGNED_SHORT :
1079 case value::UNSIGNED_INT64 :
1080 case value::DOUBLE_STAR:
1081 case value::FLOAT_STAR:
1082 case value::INT_STAR:
1083 case value::UNSIGNED_INT:
1085 //case value::ARRAY_UNSIGNED_CHAR:
1086 //case value::ARRAY_CHAR:
1087 case value::ARRAY_UNSIGNED_SHORT:
1088 case value::ARRAY_SHORT:
1089 case value::ARRAY_UNSIGNED_INT:
1090 case value::ARRAY_INT:
1091 case value::ARRAY_UNSIGNED_INT64:
1092 case value::ARRAY_INT64:
1093 case value::ARRAY_FLOAT:
1094 //case value::ARRAY_DOUBLE:
1095 case value::ARRAY_BOOL:
1096 case value::ARRAY_STRING:
1103 aThis.u.m_float *= aV.u.m_short;
1106 aThis.u.m_float *= aV.u.m_int;
1109 aThis.u.m_float *= aV.u.m_float;
1112 aThis.u.m_float *= (float)aV.u.m_double;
1114 case value::UNSIGNED_SHORT :
1115 aThis.u.m_float *= aV.u.m_unsigned_short;
1117 case value::UNSIGNED_INT:
1118 aThis.u.m_float *= aV.u.m_unsigned_int;
1120 case value::ARRAY_DOUBLE:{
1121 double tmp = aThis.u.m_float;
1122 //In the below, this becomes a value::ARRAY_DOUBLE.
1123 aThis.set(aV.u.m_array_double->orders(),
1124 aV.u.m_array_double->vector());
1125 aThis.u.m_array_double->multiply(tmp);
1128 case value::VOID_STAR:
1131 //case value::UNSIGNED_CHAR:
1133 case value::UNSIGNED_INT64 :
1134 case value::DOUBLE_STAR:
1135 case value::FLOAT_STAR:
1136 case value::INT_STAR:
1138 //case value::ARRAY_UNSIGNED_CHAR:
1139 //case value::ARRAY_CHAR:
1140 case value::ARRAY_UNSIGNED_SHORT:
1141 case value::ARRAY_SHORT:
1142 case value::ARRAY_UNSIGNED_INT:
1143 case value::ARRAY_INT:
1144 case value::ARRAY_UNSIGNED_INT64:
1145 case value::ARRAY_INT64:
1146 case value::ARRAY_FLOAT:
1147 //case value::ARRAY_DOUBLE:
1148 case value::ARRAY_BOOL:
1149 case value::ARRAY_STRING:
1156 aThis.u.m_double *= aV.u.m_short;
1159 aThis.u.m_double *= aV.u.m_int;
1162 aThis.u.m_double *= aV.u.m_int64;
1165 aThis.u.m_double *= aV.u.m_float;
1168 aThis.u.m_double *= aV.u.m_double;
1170 case value::UNSIGNED_SHORT :
1171 aThis.u.m_double *= aV.u.m_unsigned_short;
1173 case value::UNSIGNED_INT:
1174 aThis.u.m_double *= aV.u.m_unsigned_int;
1176 case value::ARRAY_DOUBLE:{
1177 double tmp = aThis.u.m_double;
1178 //In the below, this becomes a value::ARRAY_DOUBLE.
1179 aThis.set(aV.u.m_array_double->orders(),
1180 aV.u.m_array_double->vector());
1181 aThis.u.m_array_double->multiply(tmp);
1184 case value::VOID_STAR:
1186 //case value::UNSIGNED_CHAR:
1188 case value::UNSIGNED_INT64 :
1189 case value::DOUBLE_STAR:
1190 case value::FLOAT_STAR:
1191 case value::INT_STAR:
1193 //case value::ARRAY_UNSIGNED_CHAR:
1194 //case value::ARRAY_CHAR:
1195 case value::ARRAY_UNSIGNED_SHORT:
1196 case value::ARRAY_SHORT:
1197 case value::ARRAY_UNSIGNED_INT:
1198 case value::ARRAY_INT:
1199 case value::ARRAY_UNSIGNED_INT64:
1200 case value::ARRAY_INT64:
1201 case value::ARRAY_FLOAT:
1202 //case value::ARRAY_DOUBLE:
1203 case value::ARRAY_BOOL:
1204 case value::ARRAY_STRING:
1208 case value::UNSIGNED_INT:
1211 float tmp = aThis.u.m_unsigned_int * aV.u.m_float;
1212 aThis.set(tmp); //this becomes a value::FLOAT.
1214 case value::DOUBLE:{
1215 double tmp = aThis.u.m_unsigned_int * aV.u.m_double;
1216 aThis.set(tmp); //this becomes a value::DOUBLE.
1219 int tmp = aThis.u.m_unsigned_int * aV.u.m_int;
1220 aThis.set(tmp); //this becomes a value::INT.
1223 int64 tmp = aThis.u.m_unsigned_int * aV.u.m_int64;
1224 aThis.set(tmp); //this becomes a value::INT64.
1226 case value::UNSIGNED_INT:
1227 aThis.u.m_unsigned_int *= aV.u.m_unsigned_int;
1229 case value::ARRAY_DOUBLE:{
1230 unsigned int tmp = aThis.u.m_unsigned_int;
1231 //In the below, this becomes a value::ARRAY_DOUBLE.
1232 aThis.set(aV.u.m_array_double->orders(),
1233 aV.u.m_array_double->vector());
1234 aThis.u.m_array_double->multiply(double(tmp));
1237 case value::VOID_STAR:
1240 //case value::UNSIGNED_CHAR:
1242 case value::UNSIGNED_SHORT :
1243 case value::UNSIGNED_INT64 :
1244 case value::DOUBLE_STAR:
1245 case value::FLOAT_STAR:
1246 case value::INT_STAR:
1248 //case value::ARRAY_UNSIGNED_CHAR:
1249 //case value::ARRAY_CHAR:
1250 case value::ARRAY_UNSIGNED_SHORT:
1251 case value::ARRAY_SHORT:
1252 case value::ARRAY_UNSIGNED_INT:
1253 case value::ARRAY_INT:
1254 case value::ARRAY_UNSIGNED_INT64:
1255 case value::ARRAY_INT64:
1256 case value::ARRAY_FLOAT:
1257 //case value::ARRAY_DOUBLE:
1258 case value::ARRAY_BOOL:
1259 case value::ARRAY_STRING:
1263 case value::ARRAY_DOUBLE:
1266 aThis.u.m_array_double->multiply(aV.u.m_int);
1268 case value::UNSIGNED_INT:
1269 aThis.u.m_array_double->multiply(aV.u.m_unsigned_int);
1272 aThis.u.m_array_double->multiply(aV.u.m_double);
1274 case value::ARRAY_DOUBLE:{
1275 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
1276 aError = "Value::multiply : vector orders mismatch.";
1280 std::vector<double>& stdv = aThis.u.m_array_double->vector();
1281 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
1282 unsigned int number = stdv.size();
1283 for(unsigned int index=0;index<number;index++) {
1284 stdv[index] *= stdv2[index];
1288 case value::VOID_STAR:
1293 //case value::UNSIGNED_CHAR:
1295 case value::UNSIGNED_SHORT :
1296 case value::UNSIGNED_INT64 :
1297 case value::DOUBLE_STAR:
1298 case value::FLOAT_STAR:
1299 case value::INT_STAR:
1301 //case value::ARRAY_UNSIGNED_CHAR:
1302 //case value::ARRAY_CHAR:
1303 case value::ARRAY_UNSIGNED_SHORT:
1304 case value::ARRAY_SHORT:
1305 case value::ARRAY_UNSIGNED_INT:
1306 case value::ARRAY_INT:
1307 case value::ARRAY_UNSIGNED_INT64:
1308 case value::ARRAY_INT64:
1309 case value::ARRAY_FLOAT:
1310 //case value::ARRAY_DOUBLE:
1311 case value::ARRAY_BOOL:
1312 case value::ARRAY_STRING:
1318 case value::VOID_STAR:
1322 //case value::UNSIGNED_CHAR:
1324 case value::UNSIGNED_SHORT :
1325 case value::UNSIGNED_INT64 :
1326 case value::DOUBLE_STAR:
1327 case value::FLOAT_STAR:
1328 case value::INT_STAR:
1329 //case value::ARRAY_UNSIGNED_CHAR:
1330 //case value::ARRAY_CHAR:
1331 case value::ARRAY_UNSIGNED_SHORT:
1332 case value::ARRAY_SHORT:
1333 case value::ARRAY_UNSIGNED_INT:
1334 case value::ARRAY_INT:
1335 case value::ARRAY_UNSIGNED_INT64:
1336 case value::ARRAY_INT64:
1337 case value::ARRAY_FLOAT:
1338 //case value::ARRAY_DOUBLE:
1339 case value::ARRAY_BOOL:
1340 case value::ARRAY_STRING:
1343 aError = std::string("Value::multiply :" )
1344 + " can't apply on type " + value::stype(oType)
1345 + " and type " + aV.stype();
1350 inline bool value::divide(value& aThis,const value& aV,std::string& aError){
1351 value::e_type oType = aThis.m_type;
1352 switch(aThis.m_type) {
1356 if(aV.u.m_float==0.0F) {
1357 aError = value::error_div_zero();
1361 float tmp = float(aThis.u.m_int)/aV.u.m_float;
1366 if(aV.u.m_double==0) {
1367 aError = value::error_div_zero();
1371 double tmp = double(aThis.u.m_int)/aV.u.m_double;
1375 case value::ARRAY_DOUBLE:{
1376 int tmp = aThis.u.m_int;
1377 //In the below, this becomes a value::ARRAY_DOUBLE.
1378 aThis.set(aV.u.m_array_double->orders(),
1379 aV.u.m_array_double->vector());
1380 if(!aThis.u.m_array_double->invert()) {
1381 aError = value::error_div_zero();
1385 aThis.u.m_array_double->multiply((double)tmp);
1389 case value::VOID_STAR:
1393 //case value::UNSIGNED_CHAR:
1395 case value::UNSIGNED_SHORT :
1396 case value::UNSIGNED_INT:
1397 case value::UNSIGNED_INT64 :
1398 case value::DOUBLE_STAR:
1399 case value::FLOAT_STAR:
1400 case value::INT_STAR:
1402 //case value::ARRAY_UNSIGNED_CHAR:
1403 //case value::ARRAY_CHAR:
1404 case value::ARRAY_UNSIGNED_SHORT:
1405 case value::ARRAY_SHORT:
1406 case value::ARRAY_UNSIGNED_INT:
1407 case value::ARRAY_INT:
1408 case value::ARRAY_UNSIGNED_INT64:
1409 case value::ARRAY_INT64:
1410 case value::ARRAY_FLOAT:
1411 //case value::ARRAY_DOUBLE:
1412 case value::ARRAY_BOOL:
1413 case value::ARRAY_STRING:
1421 aError = value::error_div_zero();
1425 aThis.u.m_float /= aV.u.m_int;
1429 if(aV.u.m_float==0.0F) {
1430 aError = value::error_div_zero();
1434 aThis.u.m_float /= aV.u.m_float;
1438 if(aV.u.m_float==0.0F) {
1439 aError = value::error_div_zero();
1443 aThis.u.m_float /= (float)aV.u.m_double;
1446 case value::UNSIGNED_INT:
1447 if(aV.u.m_unsigned_int==0) {
1448 aError = value::error_div_zero();
1452 aThis.u.m_float /= aV.u.m_unsigned_int;
1455 case value::ARRAY_DOUBLE:{
1456 double tmp = aThis.u.m_float;
1457 //In the below, this becomes a value::ARRAY_DOUBLE.
1458 aThis.set(aV.u.m_array_double->orders(),
1459 aV.u.m_array_double->vector());
1460 if(!aThis.u.m_array_double->invert()) {
1461 aError = value::error_div_zero();
1465 aThis.u.m_array_double->multiply(tmp);
1469 case value::VOID_STAR:
1473 //case value::UNSIGNED_CHAR:
1475 case value::UNSIGNED_SHORT :
1476 case value::UNSIGNED_INT64 :
1477 case value::DOUBLE_STAR:
1478 case value::FLOAT_STAR:
1479 case value::INT_STAR:
1481 //case value::ARRAY_UNSIGNED_CHAR:
1482 //case value::ARRAY_CHAR:
1483 case value::ARRAY_UNSIGNED_SHORT:
1484 case value::ARRAY_SHORT:
1485 case value::ARRAY_UNSIGNED_INT:
1486 case value::ARRAY_INT:
1487 case value::ARRAY_UNSIGNED_INT64:
1488 case value::ARRAY_INT64:
1489 case value::ARRAY_FLOAT:
1490 //case value::ARRAY_DOUBLE:
1491 case value::ARRAY_BOOL:
1492 case value::ARRAY_STRING:
1499 if(aV.u.m_short==0) {
1500 aError = value::error_div_zero();
1504 aThis.u.m_double /= aV.u.m_short;
1509 aError = value::error_div_zero();
1513 aThis.u.m_double /= aV.u.m_int;
1517 if(aV.u.m_float==0.0F) {
1518 aError = value::error_div_zero();
1522 aThis.u.m_double /= aV.u.m_float;
1526 if(aV.u.m_double==0) {
1527 aError = value::error_div_zero();
1531 aThis.u.m_double /= aV.u.m_double;
1534 case value::UNSIGNED_INT:
1535 if(aV.u.m_unsigned_int==0) {
1536 aError = value::error_div_zero();
1540 aThis.u.m_double /= aV.u.m_unsigned_int;
1543 case value::ARRAY_DOUBLE:{
1544 double tmp = aThis.u.m_double;
1545 //In the below, this becomes a value::ARRAY_DOUBLE.
1546 aThis.set(aV.u.m_array_double->orders(),
1547 aV.u.m_array_double->vector());
1548 if(!aThis.u.m_array_double->invert()) {
1549 aError = value::error_div_zero();
1553 aThis.u.m_array_double->multiply(tmp);
1557 case value::VOID_STAR:
1560 //case value::UNSIGNED_CHAR:
1562 case value::UNSIGNED_SHORT :
1563 case value::UNSIGNED_INT64 :
1564 case value::DOUBLE_STAR:
1565 case value::FLOAT_STAR:
1566 case value::INT_STAR:
1568 //case value::ARRAY_UNSIGNED_CHAR:
1569 //case value::ARRAY_CHAR:
1570 case value::ARRAY_UNSIGNED_SHORT:
1571 case value::ARRAY_SHORT:
1572 case value::ARRAY_UNSIGNED_INT:
1573 case value::ARRAY_INT:
1574 case value::ARRAY_UNSIGNED_INT64:
1575 case value::ARRAY_INT64:
1576 case value::ARRAY_FLOAT:
1577 //case value::ARRAY_DOUBLE:
1578 case value::ARRAY_BOOL:
1579 case value::ARRAY_STRING:
1583 case value::UNSIGNED_INT:
1585 //case value::UNSIGNED_INT:
1586 // if(aV.u.m_unsigned_int==0) {
1587 // aError = value::error_div_zero();
1588 // aThis.set_none();
1592 // aThis.set((double)(aThis.u.m_unsigned_int / aV.u.m_unsigned_int ));
1595 case value::ARRAY_DOUBLE:{
1596 unsigned int tmp = aThis.u.m_unsigned_int;
1597 //In the below, this becomes a value::ARRAY_DOUBLE.
1598 aThis.set(aV.u.m_array_double->orders(),
1599 aV.u.m_array_double->vector());
1600 if(!aThis.u.m_array_double->invert()) {
1601 aError = value::error_div_zero();
1605 aThis.u.m_array_double->multiply(double(tmp));
1609 if(aV.u.m_float==0) {
1610 aError = value::error_div_zero();
1614 float d = float(aThis.u.m_unsigned_int)/aV.u.m_float;
1615 aThis.set(d); //this becomes a value::FLOAT.
1619 if(aV.u.m_double==0) {
1620 aError = value::error_div_zero();
1624 double d = double(aThis.u.m_unsigned_int)/aV.u.m_double;
1625 aThis.set(d); //this becomes a value::DOUBLE.
1630 case value::VOID_STAR:
1634 //case value::UNSIGNED_CHAR:
1636 case value::UNSIGNED_SHORT :
1637 case value::UNSIGNED_INT:
1638 case value::UNSIGNED_INT64 :
1639 case value::DOUBLE_STAR:
1640 case value::FLOAT_STAR:
1641 case value::INT_STAR:
1643 //case value::ARRAY_UNSIGNED_CHAR:
1644 //case value::ARRAY_CHAR:
1645 case value::ARRAY_UNSIGNED_SHORT:
1646 case value::ARRAY_SHORT:
1647 case value::ARRAY_UNSIGNED_INT:
1648 case value::ARRAY_INT:
1649 case value::ARRAY_UNSIGNED_INT64:
1650 case value::ARRAY_INT64:
1651 case value::ARRAY_FLOAT:
1652 //case value::ARRAY_DOUBLE:
1653 case value::ARRAY_BOOL:
1654 case value::ARRAY_STRING:
1658 case value::ARRAY_DOUBLE:
1662 aError = value::error_div_zero();
1666 double value = 1./aV.u.m_int;
1667 aThis.u.m_array_double->multiply(value);
1670 case value::UNSIGNED_INT:
1671 if(aV.u.m_unsigned_int==0) {
1672 aError = value::error_div_zero();
1676 double value = 1./aV.u.m_unsigned_int;
1677 aThis.u.m_array_double->multiply(value);
1681 if(aV.u.m_double==0) {
1682 aError = value::error_div_zero();
1686 aThis.u.m_array_double->multiply(1./aV.u.m_double);
1689 case value::ARRAY_DOUBLE:{
1690 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
1691 aError = value::error_div_zero(); //FIXME : error_mismatch_orders
1695 std::vector<double>& stdv = aThis.u.m_array_double->vector();
1696 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
1697 bool has_div_zero = false;
1698 unsigned int number = stdv.size();
1699 for(unsigned int index=0;index<number;index++) {
1700 if(stdv2[index]==0) {
1701 //FIXME : stdv[index] = nan;
1702 stdv[index] = 0; //PAW convention.
1703 has_div_zero = true;
1705 stdv[index] /= stdv2[index];
1709 aError = value::error_div_zero();
1710 // For OpenPAW/pasigm::SIGMA, continue anyway in case of /0 errors.
1712 //return false; //FIXME : is so, then it will stop Processor.
1713 return true; //FIXME : do we want that ?
1720 case value::VOID_STAR:
1724 //case value::UNSIGNED_CHAR:
1727 case value::UNSIGNED_SHORT :
1728 case value::UNSIGNED_INT64 :
1729 case value::DOUBLE_STAR:
1730 case value::FLOAT_STAR:
1731 case value::INT_STAR:
1732 //case value::ARRAY_UNSIGNED_CHAR:
1733 //case value::ARRAY_CHAR:
1734 case value::ARRAY_UNSIGNED_SHORT:
1735 case value::ARRAY_SHORT:
1736 case value::ARRAY_UNSIGNED_INT:
1737 case value::ARRAY_INT:
1738 case value::ARRAY_UNSIGNED_INT64:
1739 case value::ARRAY_INT64:
1740 case value::ARRAY_FLOAT:
1741 //case value::ARRAY_DOUBLE:
1742 case value::ARRAY_BOOL:
1743 case value::ARRAY_STRING:
1750 case value::VOID_STAR:
1753 //case value::UNSIGNED_CHAR:
1756 case value::UNSIGNED_SHORT :
1757 case value::UNSIGNED_INT64 :
1758 case value::DOUBLE_STAR:
1759 case value::FLOAT_STAR:
1760 case value::INT_STAR:
1761 //case value::ARRAY_UNSIGNED_CHAR:
1762 //case value::ARRAY_CHAR:
1763 case value::ARRAY_UNSIGNED_SHORT:
1764 case value::ARRAY_SHORT:
1765 case value::ARRAY_UNSIGNED_INT:
1766 case value::ARRAY_INT:
1767 case value::ARRAY_UNSIGNED_INT64:
1768 case value::ARRAY_INT64:
1769 case value::ARRAY_FLOAT:
1770 //case value::ARRAY_DOUBLE:
1771 case value::ARRAY_BOOL:
1772 case value::ARRAY_STRING:
1775 aError = std::string("Value::divide :")
1776 + " can't apply on type " + value::stype(oType)
1777 + " and type " + aV.stype();
1782 //////////////////////////////////////////////////////////////////////////////
1783 //////////////////////////////////////////////////////////////////////////////
1784 //////////////////////////////////////////////////////////////////////////////
1786 inline bool value::if_gt(value& aThis,const value& aV,std::string& aError){
1787 value::e_type oType = aThis.m_type;
1788 switch(aThis.m_type) {
1792 aThis.set((bool)(aThis.u.m_int>aV.u.m_int?true:false));
1795 aThis.set((bool)(aThis.u.m_int>aV.u.m_float?true:false));
1798 aThis.set((bool)(aThis.u.m_int>aV.u.m_double?true:false));
1800 case value::UNSIGNED_SHORT :
1801 aThis.set((bool)(aThis.u.m_int>(int)aV.u.m_unsigned_short?true:false));
1803 case value::UNSIGNED_INT:
1804 aThis.set((bool)(aThis.u.m_int>(int)aV.u.m_unsigned_int?true:false));
1806 case value::ARRAY_DOUBLE:{
1807 const std::vector<double>& stdv = aV.u.m_array_double->vector();
1808 unsigned int number = stdv.size();
1809 for(unsigned int index=0;index<number;index++) {
1810 if(aThis.u.m_int<=stdv[index]) {
1819 case value::VOID_STAR:
1823 //case value::UNSIGNED_CHAR:
1825 case value::UNSIGNED_INT64 :
1826 case value::DOUBLE_STAR:
1827 case value::FLOAT_STAR:
1828 case value::INT_STAR:
1830 //case value::ARRAY_UNSIGNED_CHAR:
1831 //case value::ARRAY_CHAR:
1832 case value::ARRAY_UNSIGNED_SHORT:
1833 case value::ARRAY_SHORT:
1834 case value::ARRAY_UNSIGNED_INT:
1835 case value::ARRAY_INT:
1836 case value::ARRAY_UNSIGNED_INT64:
1837 case value::ARRAY_INT64:
1838 case value::ARRAY_FLOAT:
1839 //case value::ARRAY_DOUBLE:
1840 case value::ARRAY_BOOL:
1841 case value::ARRAY_STRING:
1848 aThis.set((bool)(aThis.u.m_double>aV.u.m_double?true:false));
1851 aThis.set((bool)(aThis.u.m_double>aV.u.m_float?true:false));
1854 aThis.set((bool)(aThis.u.m_double>aV.u.m_int?true:false));
1856 case value::UNSIGNED_SHORT :
1857 aThis.set((bool)(aThis.u.m_double>aV.u.m_unsigned_short?true:false));
1859 case value::UNSIGNED_INT:
1860 aThis.set((bool)(aThis.u.m_double>aV.u.m_unsigned_int?true:false));
1862 case value::ARRAY_DOUBLE:{
1863 const std::vector<double>& stdv = aV.u.m_array_double->vector();
1864 unsigned int number = stdv.size();
1865 for(unsigned int index=0;index<number;index++) {
1866 if(aThis.u.m_double<=stdv[index]) {
1875 case value::VOID_STAR:
1879 //case value::UNSIGNED_CHAR:
1881 case value::UNSIGNED_INT64 :
1882 case value::DOUBLE_STAR:
1883 case value::FLOAT_STAR:
1884 case value::INT_STAR:
1886 //case value::ARRAY_UNSIGNED_CHAR:
1887 //case value::ARRAY_CHAR:
1888 case value::ARRAY_UNSIGNED_SHORT:
1889 case value::ARRAY_SHORT:
1890 case value::ARRAY_UNSIGNED_INT:
1891 case value::ARRAY_INT:
1892 case value::ARRAY_UNSIGNED_INT64:
1893 case value::ARRAY_INT64:
1894 case value::ARRAY_FLOAT:
1895 //case value::ARRAY_DOUBLE:
1896 case value::ARRAY_BOOL:
1897 case value::ARRAY_STRING:
1904 aThis.set((bool)(aThis.u.m_float>aV.u.m_double?true:false));
1907 aThis.set((bool)(aThis.u.m_float>aV.u.m_float?true:false));
1910 aThis.set((bool)(aThis.u.m_float>aV.u.m_int?true:false));
1912 case value::UNSIGNED_SHORT :
1913 aThis.set((bool)(aThis.u.m_float>aV.u.m_unsigned_short?true:false));
1915 case value::UNSIGNED_INT:
1916 aThis.set((bool)(aThis.u.m_float>aV.u.m_unsigned_int?true:false));
1918 case value::ARRAY_DOUBLE:{
1919 const std::vector<double>& stdv = aV.u.m_array_double->vector();
1920 unsigned int number = stdv.size();
1921 for(unsigned int index=0;index<number;index++) {
1922 if(aThis.u.m_float<=stdv[index]) {
1931 case value::VOID_STAR:
1935 //case value::UNSIGNED_CHAR:
1937 case value::UNSIGNED_INT64 :
1938 case value::DOUBLE_STAR:
1939 case value::FLOAT_STAR:
1940 case value::INT_STAR:
1942 //case value::ARRAY_UNSIGNED_CHAR:
1943 //case value::ARRAY_CHAR:
1944 case value::ARRAY_UNSIGNED_SHORT:
1945 case value::ARRAY_SHORT:
1946 case value::ARRAY_UNSIGNED_INT:
1947 case value::ARRAY_INT:
1948 case value::ARRAY_UNSIGNED_INT64:
1949 case value::ARRAY_INT64:
1950 case value::ARRAY_FLOAT:
1951 //case value::ARRAY_DOUBLE:
1952 case value::ARRAY_BOOL:
1953 case value::ARRAY_STRING:
1957 case value::VOID_STAR:
1959 case value::VOID_STAR:
1960 aThis.set((bool)(aThis.u.m_void_star>aV.u.m_void_star?true:false));
1969 //case value::UNSIGNED_CHAR:
1971 case value::UNSIGNED_SHORT :
1972 case value::UNSIGNED_INT:
1973 case value::UNSIGNED_INT64 :
1974 case value::DOUBLE_STAR:
1975 case value::FLOAT_STAR:
1976 case value::INT_STAR:
1978 //case value::ARRAY_UNSIGNED_CHAR:
1979 //case value::ARRAY_CHAR:
1980 case value::ARRAY_UNSIGNED_SHORT:
1981 case value::ARRAY_SHORT:
1982 case value::ARRAY_UNSIGNED_INT:
1983 case value::ARRAY_INT:
1984 case value::ARRAY_UNSIGNED_INT64:
1985 case value::ARRAY_INT64:
1986 case value::ARRAY_FLOAT:
1987 case value::ARRAY_DOUBLE:
1988 case value::ARRAY_BOOL:
1989 case value::ARRAY_STRING:
1993 case value::UNSIGNED_INT:
1995 case value::UNSIGNED_INT:
1996 aThis.set((bool)(aThis.u.m_unsigned_int >aV.u.m_unsigned_int ?true:false));
1999 aThis.set((bool)((int)aThis.u.m_unsigned_int >aV.u.m_int?true:false));
2002 case value::VOID_STAR:
2008 //case value::UNSIGNED_CHAR:
2010 case value::UNSIGNED_SHORT :
2011 case value::UNSIGNED_INT64 :
2012 case value::DOUBLE_STAR:
2013 case value::FLOAT_STAR:
2014 case value::INT_STAR:
2016 //case value::ARRAY_UNSIGNED_CHAR:
2017 //case value::ARRAY_CHAR:
2018 case value::ARRAY_UNSIGNED_SHORT:
2019 case value::ARRAY_SHORT:
2020 case value::ARRAY_UNSIGNED_INT:
2021 case value::ARRAY_INT:
2022 case value::ARRAY_UNSIGNED_INT64:
2023 case value::ARRAY_INT64:
2024 case value::ARRAY_FLOAT:
2025 case value::ARRAY_DOUBLE:
2026 case value::ARRAY_BOOL:
2027 case value::ARRAY_STRING:
2031 case value::ARRAY_DOUBLE:
2034 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2035 unsigned int number = stdv.size();
2036 for(unsigned int index=0;index<number;index++) {
2037 if(stdv[index]<=aV.u.m_int) {
2046 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2047 unsigned int number = stdv.size();
2048 for(unsigned int index=0;index<number;index++) {
2049 if(stdv[index]<=aV.u.m_float) {
2057 case value::DOUBLE:{
2058 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2059 unsigned int number = stdv.size();
2060 for(unsigned int index=0;index<number;index++) {
2061 if(stdv[index]<=aV.u.m_double) {
2069 case value::UNSIGNED_INT:{
2070 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2071 unsigned int number = stdv.size();
2072 for(unsigned int index=0;index<number;index++) {
2073 if(stdv[index]<=aV.u.m_unsigned_int ) {
2081 case value::ARRAY_DOUBLE:{
2082 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2083 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
2084 if(stdv.size()!=stdv2.size()) break;
2085 unsigned int number = stdv.size();
2086 for(unsigned int index=0;index<number;index++) {
2087 if(stdv[index]<=stdv2[index]) {
2096 case value::VOID_STAR:
2100 //case value::UNSIGNED_CHAR:
2102 case value::UNSIGNED_SHORT :
2103 case value::UNSIGNED_INT64 :
2104 case value::DOUBLE_STAR:
2105 case value::FLOAT_STAR:
2106 case value::INT_STAR:
2108 //case value::ARRAY_UNSIGNED_CHAR:
2109 //case value::ARRAY_CHAR:
2110 case value::ARRAY_UNSIGNED_SHORT:
2111 case value::ARRAY_SHORT:
2112 case value::ARRAY_UNSIGNED_INT:
2113 case value::ARRAY_INT:
2114 case value::ARRAY_UNSIGNED_INT64:
2115 case value::ARRAY_INT64:
2116 case value::ARRAY_FLOAT:
2117 //case value::ARRAY_DOUBLE:
2118 case value::ARRAY_BOOL:
2119 case value::ARRAY_STRING:
2126 //case value::UNSIGNED_CHAR:
2130 case value::UNSIGNED_SHORT :
2131 case value::UNSIGNED_INT64 :
2132 case value::DOUBLE_STAR:
2133 case value::FLOAT_STAR:
2134 case value::INT_STAR:
2135 //case value::ARRAY_UNSIGNED_CHAR:
2136 //case value::ARRAY_CHAR:
2137 case value::ARRAY_UNSIGNED_SHORT:
2138 case value::ARRAY_SHORT:
2139 case value::ARRAY_UNSIGNED_INT:
2140 case value::ARRAY_INT:
2141 case value::ARRAY_UNSIGNED_INT64:
2142 case value::ARRAY_INT64:
2143 case value::ARRAY_FLOAT:
2144 //case value::ARRAY_DOUBLE:
2145 case value::ARRAY_BOOL:
2146 case value::ARRAY_STRING:
2149 aError = std::string("Value::if_gt() :")
2150 + " can't compare type " + value::stype(oType)
2151 + " with type " + aV.stype();
2156 inline bool value::if_eq(value& aThis,const value& aV,std::string& aError){
2157 value::e_type oType = aThis.m_type;
2158 switch(aThis.m_type) {
2162 aThis.set((bool)(aThis.u.m_int==aV.u.m_int?true:false));
2165 aThis.set((bool)(aThis.u.m_int==aV.u.m_double?true:false));
2168 aThis.set((bool)(aThis.u.m_int==aV.u.m_float?true:false));
2170 case value::UNSIGNED_SHORT :
2171 aThis.set((bool)(aThis.u.m_int==(int)aV.u.m_unsigned_short?true:false));
2173 case value::UNSIGNED_INT:
2174 aThis.set((bool)(aThis.u.m_int==(int)aV.u.m_unsigned_int ?true:false));
2176 case value::ARRAY_DOUBLE:{
2177 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2178 unsigned int number = stdv.size();
2179 for(unsigned int index=0;index<number;index++) {
2180 if(aThis.u.m_int!=stdv[index]) {
2191 case value::VOID_STAR:
2195 //case value::UNSIGNED_CHAR:
2197 case value::UNSIGNED_INT64 :
2198 case value::DOUBLE_STAR:
2199 case value::FLOAT_STAR:
2200 case value::INT_STAR:
2202 //case value::ARRAY_UNSIGNED_CHAR:
2203 //case value::ARRAY_CHAR:
2204 case value::ARRAY_UNSIGNED_SHORT:
2205 case value::ARRAY_SHORT:
2206 case value::ARRAY_UNSIGNED_INT:
2207 case value::ARRAY_INT:
2208 case value::ARRAY_UNSIGNED_INT64:
2209 case value::ARRAY_INT64:
2210 case value::ARRAY_FLOAT:
2211 //case value::ARRAY_DOUBLE:
2212 case value::ARRAY_BOOL:
2213 case value::ARRAY_STRING:
2220 aThis.set((bool)(aThis.u.m_float==aV.u.m_float?true:false));
2223 aThis.set((bool)(aThis.u.m_float==aV.u.m_double?true:false));
2226 aThis.set((bool)(aThis.u.m_float==aV.u.m_int?true:false));
2228 case value::UNSIGNED_SHORT :
2229 aThis.set((bool)(aThis.u.m_float==aV.u.m_unsigned_short?true:false));
2231 case value::UNSIGNED_INT:
2232 aThis.set((bool)(aThis.u.m_float==aV.u.m_unsigned_int?true:false));
2234 case value::ARRAY_DOUBLE:{
2235 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2236 unsigned int number = stdv.size();
2237 for(unsigned int index=0;index<number;index++) {
2238 if(aThis.u.m_float!=stdv[index]) {
2248 case value::VOID_STAR:
2251 //case value::UNSIGNED_CHAR:
2254 case value::UNSIGNED_INT64 :
2255 case value::DOUBLE_STAR:
2256 case value::FLOAT_STAR:
2257 case value::INT_STAR:
2258 //case value::ARRAY_UNSIGNED_CHAR:
2259 //case value::ARRAY_CHAR:
2260 case value::ARRAY_UNSIGNED_SHORT:
2261 case value::ARRAY_SHORT:
2262 case value::ARRAY_UNSIGNED_INT:
2263 case value::ARRAY_INT:
2264 case value::ARRAY_UNSIGNED_INT64:
2265 case value::ARRAY_INT64:
2266 case value::ARRAY_FLOAT:
2267 //case value::ARRAY_DOUBLE:
2268 case value::ARRAY_BOOL:
2269 case value::ARRAY_STRING:
2276 aThis.set((bool)(aThis.u.m_double==aV.u.m_double?true:false));
2279 aThis.set((bool)(aThis.u.m_double==aV.u.m_float?true:false));
2282 aThis.set((bool)(aThis.u.m_double==aV.u.m_int?true:false));
2284 case value::UNSIGNED_SHORT :
2285 aThis.set((bool)(aThis.u.m_double==aV.u.m_unsigned_short?true:false));
2287 case value::UNSIGNED_INT:
2288 aThis.set((bool)(aThis.u.m_double==aV.u.m_unsigned_int ?true:false));
2290 case value::ARRAY_DOUBLE:{
2291 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2292 unsigned int number = stdv.size();
2293 for(unsigned int index=0;index<number;index++) {
2294 if(aThis.u.m_double!=stdv[index]) {
2304 case value::VOID_STAR:
2307 //case value::UNSIGNED_CHAR:
2310 case value::UNSIGNED_INT64 :
2311 case value::DOUBLE_STAR:
2312 case value::FLOAT_STAR:
2313 case value::INT_STAR:
2314 //case value::ARRAY_UNSIGNED_CHAR:
2315 //case value::ARRAY_CHAR:
2316 case value::ARRAY_UNSIGNED_SHORT:
2317 case value::ARRAY_SHORT:
2318 case value::ARRAY_UNSIGNED_INT:
2319 case value::ARRAY_INT:
2320 case value::ARRAY_UNSIGNED_INT64:
2321 case value::ARRAY_INT64:
2322 case value::ARRAY_FLOAT:
2323 //case value::ARRAY_DOUBLE:
2324 case value::ARRAY_BOOL:
2325 case value::ARRAY_STRING:
2332 aThis.set((bool)((*aThis.u.m_string)==(*aV.u.m_string)?true:false));
2336 if(!tools::to<int>(*aThis.u.m_string,v)) break;
2337 aThis.set((bool)(v==aV.u.m_int?true:false));
2341 if(!tools::to<float>(*aThis.u.m_string,v)) break;
2342 aThis.set((bool)(v==aV.u.m_float?true:false));
2346 if(!tools::to<double>(*aThis.u.m_string,v)) break;
2347 aThis.set((bool)(v==aV.u.m_double?true:false));
2349 case value::UNSIGNED_INT:
2350 {typedef unsigned int uint_t;
2352 if(!tools::to<uint_t>(*aThis.u.m_string,v)) break;
2353 aThis.set((bool)(v==aV.u.m_unsigned_int ?true:false));
2357 if(!tools::to(*aThis.u.m_string,v)) break;
2358 aThis.set((bool)(v==aV.u.m_bool?true:false));
2361 case value::VOID_STAR:
2363 //case value::UNSIGNED_CHAR:
2366 case value::UNSIGNED_SHORT :
2367 case value::UNSIGNED_INT64 :
2368 case value::DOUBLE_STAR:
2369 case value::FLOAT_STAR:
2370 case value::INT_STAR:
2371 //case value::ARRAY_UNSIGNED_CHAR:
2372 //case value::ARRAY_CHAR:
2373 case value::ARRAY_UNSIGNED_SHORT:
2374 case value::ARRAY_SHORT:
2375 case value::ARRAY_UNSIGNED_INT:
2376 case value::ARRAY_INT:
2377 case value::ARRAY_UNSIGNED_INT64:
2378 case value::ARRAY_INT64:
2379 case value::ARRAY_FLOAT:
2380 case value::ARRAY_DOUBLE:
2381 case value::ARRAY_BOOL:
2382 case value::ARRAY_STRING:
2386 case value::VOID_STAR:
2388 case value::VOID_STAR:
2389 aThis.set((bool)(aThis.u.m_void_star==aV.u.m_void_star?true:false));
2398 //case value::UNSIGNED_CHAR:
2400 case value::UNSIGNED_SHORT :
2401 case value::UNSIGNED_INT:
2402 case value::UNSIGNED_INT64 :
2403 case value::DOUBLE_STAR:
2404 case value::FLOAT_STAR:
2405 case value::INT_STAR:
2407 //case value::ARRAY_UNSIGNED_CHAR:
2408 //case value::ARRAY_CHAR:
2409 case value::ARRAY_UNSIGNED_SHORT:
2410 case value::ARRAY_SHORT:
2411 case value::ARRAY_UNSIGNED_INT:
2412 case value::ARRAY_INT:
2413 case value::ARRAY_UNSIGNED_INT64:
2414 case value::ARRAY_INT64:
2415 case value::ARRAY_FLOAT:
2416 case value::ARRAY_DOUBLE:
2417 case value::ARRAY_BOOL:
2418 case value::ARRAY_STRING:
2422 case value::UNSIGNED_INT:
2424 case value::UNSIGNED_INT:
2425 aThis.set((bool)(aThis.u.m_unsigned_int ==aV.u.m_unsigned_int ?true:false));
2428 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_int?true:false));
2431 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_float?true:false));
2434 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_double?true:false));
2436 case value::ARRAY_DOUBLE:{
2437 const std::vector<double>& stdv = aV.u.m_array_double->vector();
2438 unsigned int number = stdv.size();
2439 for(unsigned int index=0;index<number;index++) {
2440 if(aThis.u.m_unsigned_int !=stdv[index]) {
2450 case value::VOID_STAR:
2453 //case value::UNSIGNED_CHAR:
2455 case value::UNSIGNED_SHORT :
2456 case value::UNSIGNED_INT64 :
2457 case value::DOUBLE_STAR:
2458 case value::FLOAT_STAR:
2459 case value::INT_STAR:
2461 //case value::ARRAY_UNSIGNED_CHAR:
2462 //case value::ARRAY_CHAR:
2463 case value::ARRAY_UNSIGNED_SHORT:
2464 case value::ARRAY_SHORT:
2465 case value::ARRAY_UNSIGNED_INT:
2466 case value::ARRAY_INT:
2467 case value::ARRAY_UNSIGNED_INT64:
2468 case value::ARRAY_INT64:
2469 case value::ARRAY_FLOAT:
2470 //case value::ARRAY_DOUBLE:
2471 case value::ARRAY_BOOL:
2472 case value::ARRAY_STRING:
2479 aThis.u.m_bool = ((aThis.u.m_bool==aV.u.m_bool)?true:false);
2484 case value::VOID_STAR:
2488 //case value::UNSIGNED_CHAR:
2490 case value::UNSIGNED_SHORT :
2491 case value::UNSIGNED_INT:
2492 case value::UNSIGNED_INT64 :
2493 case value::DOUBLE_STAR:
2494 case value::FLOAT_STAR:
2495 case value::INT_STAR:
2497 //case value::ARRAY_UNSIGNED_CHAR:
2498 //case value::ARRAY_CHAR:
2499 case value::ARRAY_UNSIGNED_SHORT:
2500 case value::ARRAY_SHORT:
2501 case value::ARRAY_UNSIGNED_INT:
2502 case value::ARRAY_INT:
2503 case value::ARRAY_UNSIGNED_INT64:
2504 case value::ARRAY_INT64:
2505 case value::ARRAY_FLOAT:
2506 case value::ARRAY_DOUBLE:
2507 case value::ARRAY_BOOL:
2508 case value::ARRAY_STRING:
2512 case value::ARRAY_DOUBLE:
2515 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2516 unsigned int number = stdv.size();
2517 for(unsigned int index=0;index<number;index++) {
2518 if(stdv[index]!=aV.u.m_int) {
2527 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2528 unsigned int number = stdv.size();
2529 for(unsigned int index=0;index<number;index++) {
2530 if(stdv[index]!=aV.u.m_float) {
2538 case value::DOUBLE:{
2539 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2540 unsigned int number = stdv.size();
2541 for(unsigned int index=0;index<number;index++) {
2542 if(stdv[index]!=aV.u.m_double) {
2550 case value::UNSIGNED_INT:{
2551 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2552 unsigned int number = stdv.size();
2553 for(unsigned int index=0;index<number;index++) {
2554 if(stdv[index]!=aV.u.m_unsigned_int ) {
2562 case value::ARRAY_DOUBLE:{
2563 const std::vector<double>& stdv = aThis.u.m_array_double->vector();
2564 const std::vector<double>& stdv2 = aV.u.m_array_double->vector();
2565 if(stdv.size()!=stdv2.size()) {
2569 unsigned int number = stdv.size();
2570 for(unsigned int index=0;index<number;index++) {
2571 if(stdv[index]!=stdv2[index]) {
2580 case value::VOID_STAR:
2583 //case value::UNSIGNED_CHAR:
2587 case value::UNSIGNED_SHORT :
2588 case value::UNSIGNED_INT64 :
2589 case value::DOUBLE_STAR:
2590 case value::FLOAT_STAR:
2591 case value::INT_STAR:
2592 //case value::ARRAY_UNSIGNED_CHAR:
2593 //case value::ARRAY_CHAR:
2594 case value::ARRAY_UNSIGNED_SHORT:
2595 case value::ARRAY_SHORT:
2596 case value::ARRAY_UNSIGNED_INT:
2597 case value::ARRAY_INT:
2598 case value::ARRAY_UNSIGNED_INT64:
2599 case value::ARRAY_INT64:
2600 case value::ARRAY_FLOAT:
2601 //case value::ARRAY_DOUBLE:
2602 case value::ARRAY_BOOL:
2603 case value::ARRAY_STRING:
2610 //case value::UNSIGNED_CHAR:
2612 case value::UNSIGNED_SHORT :
2613 case value::UNSIGNED_INT64 :
2614 case value::DOUBLE_STAR:
2615 case value::FLOAT_STAR:
2616 case value::INT_STAR:
2617 //case value::ARRAY_UNSIGNED_CHAR:
2618 //case value::ARRAY_CHAR:
2619 case value::ARRAY_UNSIGNED_SHORT:
2620 case value::ARRAY_SHORT:
2621 case value::ARRAY_UNSIGNED_INT:
2622 case value::ARRAY_INT:
2623 case value::ARRAY_UNSIGNED_INT64:
2624 case value::ARRAY_INT64:
2625 case value::ARRAY_FLOAT:
2626 //case value::ARRAY_DOUBLE:
2627 case value::ARRAY_BOOL:
2628 case value::ARRAY_STRING:
2631 aError = std::string("Value::if_eq() :")
2632 + " can't compare type " + value::stype(oType)
2633 + " with type " + aV.stype();
2638 inline bool value::if_and(value& aThis,const value& aV,std::string& aError){
2639 value::e_type oType = aThis.m_type;
2640 switch(aThis.m_type) {
2644 aThis.u.m_bool = ((aThis.u.m_bool && aV.u.m_bool)?true:false);
2650 case value::VOID_STAR:
2654 //case value::UNSIGNED_CHAR:
2656 case value::UNSIGNED_SHORT :
2657 case value::UNSIGNED_INT64 :
2658 case value::DOUBLE_STAR:
2659 case value::FLOAT_STAR:
2660 case value::INT_STAR:
2661 case value::UNSIGNED_INT:
2662 //case value::ARRAY_UNSIGNED_CHAR:
2663 //case value::ARRAY_CHAR:
2664 case value::ARRAY_UNSIGNED_SHORT:
2665 case value::ARRAY_SHORT:
2666 case value::ARRAY_UNSIGNED_INT:
2667 case value::ARRAY_INT:
2668 case value::ARRAY_UNSIGNED_INT64:
2669 case value::ARRAY_INT64:
2670 case value::ARRAY_FLOAT:
2671 case value::ARRAY_DOUBLE:
2672 case value::ARRAY_BOOL:
2673 case value::ARRAY_STRING:
2680 case value::VOID_STAR:
2684 //case value::UNSIGNED_CHAR:
2686 case value::UNSIGNED_SHORT :
2687 case value::UNSIGNED_INT:
2688 case value::UNSIGNED_INT64 :
2689 case value::DOUBLE_STAR:
2690 case value::FLOAT_STAR:
2691 case value::INT_STAR:
2693 //case value::ARRAY_UNSIGNED_CHAR:
2694 //case value::ARRAY_CHAR:
2695 case value::ARRAY_UNSIGNED_SHORT:
2696 case value::ARRAY_SHORT:
2697 case value::ARRAY_UNSIGNED_INT:
2698 case value::ARRAY_INT:
2699 case value::ARRAY_UNSIGNED_INT64:
2700 case value::ARRAY_INT64:
2701 case value::ARRAY_FLOAT:
2702 case value::ARRAY_DOUBLE:
2703 case value::ARRAY_BOOL:
2704 case value::ARRAY_STRING:
2707 aError = std::string("Value::if_and :")
2708 + " can't apply on type " + value::stype(oType)
2709 + " and type " + aV.stype();
2714 inline bool value::if_or(value& aThis,const value& aV,std::string& aError){
2715 value::e_type oType = aThis.m_type;
2716 switch(aThis.m_type) {
2720 aThis.u.m_bool = ((aThis.u.m_bool || aV.u.m_bool)?true:false);
2726 case value::VOID_STAR:
2730 //case value::UNSIGNED_CHAR:
2732 case value::UNSIGNED_SHORT :
2733 case value::UNSIGNED_INT64 :
2734 case value::DOUBLE_STAR:
2735 case value::FLOAT_STAR:
2736 case value::INT_STAR:
2737 case value::UNSIGNED_INT:
2738 //case value::ARRAY_UNSIGNED_CHAR:
2739 //case value::ARRAY_CHAR:
2740 case value::ARRAY_UNSIGNED_SHORT:
2741 case value::ARRAY_SHORT:
2742 case value::ARRAY_UNSIGNED_INT:
2743 case value::ARRAY_INT:
2744 case value::ARRAY_UNSIGNED_INT64:
2745 case value::ARRAY_INT64:
2746 case value::ARRAY_FLOAT:
2747 case value::ARRAY_DOUBLE:
2748 case value::ARRAY_BOOL:
2749 case value::ARRAY_STRING:
2756 case value::VOID_STAR:
2760 //case value::UNSIGNED_CHAR:
2762 case value::UNSIGNED_SHORT :
2763 case value::UNSIGNED_INT:
2764 case value::UNSIGNED_INT64 :
2765 case value::DOUBLE_STAR:
2766 case value::FLOAT_STAR:
2767 case value::INT_STAR:
2769 //case value::ARRAY_UNSIGNED_CHAR:
2770 //case value::ARRAY_CHAR:
2771 case value::ARRAY_UNSIGNED_SHORT:
2772 case value::ARRAY_SHORT:
2773 case value::ARRAY_UNSIGNED_INT:
2774 case value::ARRAY_INT:
2775 case value::ARRAY_UNSIGNED_INT64:
2776 case value::ARRAY_INT64:
2777 case value::ARRAY_FLOAT:
2778 case value::ARRAY_DOUBLE:
2779 case value::ARRAY_BOOL:
2780 case value::ARRAY_STRING:
2783 aError = std::string("Value::if_or :")
2784 + " can't apply on type " + value::stype(oType)
2785 + " and type " + aV.stype();
2790 inline bool value::to_double(const value& aThis,double& aValue){
2791 switch(aThis.m_type) {
2793 aValue = aThis.u.m_int;
2796 aValue = aThis.u.m_double;
2798 case value::UNSIGNED_SHORT:
2799 aValue = aThis.u.m_unsigned_short;
2801 case value::UNSIGNED_INT:
2802 aValue = aThis.u.m_unsigned_int;
2805 aValue = aThis.u.m_short;
2808 aValue = (double)aThis.u.m_int64;
2810 case value::UNSIGNED_INT64:
2811 aValue = (double)aThis.u.m_unsigned_int64;
2814 aValue = aThis.u.m_float;
2816 //case value::UNSIGNED_CHAR:
2817 // aValue = aThis.u.m_unsigned_char;
2820 // aValue = aThis.u.m_char;
2823 aValue = aThis.u.m_bool?1:0;
2827 case value::VOID_STAR:
2828 case value::DOUBLE_STAR:
2829 case value::FLOAT_STAR:
2830 case value::INT_STAR:
2831 //case value::ARRAY_UNSIGNED_CHAR:
2832 //case value::ARRAY_CHAR:
2833 case value::ARRAY_UNSIGNED_SHORT:
2834 case value::ARRAY_SHORT:
2835 case value::ARRAY_UNSIGNED_INT:
2836 case value::ARRAY_INT:
2837 case value::ARRAY_UNSIGNED_INT64:
2838 case value::ARRAY_INT64:
2839 case value::ARRAY_FLOAT:
2840 case value::ARRAY_DOUBLE:
2841 case value::ARRAY_BOOL:
2842 case value::ARRAY_STRING:
2849 inline bool value::cxx_type(const value& aThis,std::string& aValue){
2850 switch(aThis.m_type) {
2858 aValue = "std::string";
2872 //case value::UNSIGNED_CHAR:
2873 // aValue = "unsigned char";
2875 case value::UNSIGNED_SHORT:
2876 aValue = "unsigned short";
2878 case value::UNSIGNED_INT:
2879 aValue = "unsigned int";
2881 case value::VOID_STAR:
2884 case value::DOUBLE_STAR:
2887 case value::FLOAT_STAR:
2890 case value::INT_STAR:
2895 case value::UNSIGNED_INT64:
2896 //case value::ARRAY_UNSIGNED_CHAR:
2897 //case value::ARRAY_CHAR:
2898 case value::ARRAY_UNSIGNED_SHORT:
2899 case value::ARRAY_SHORT:
2900 case value::ARRAY_UNSIGNED_INT:
2901 case value::ARRAY_INT:
2902 case value::ARRAY_UNSIGNED_INT64:
2903 case value::ARRAY_INT64:
2904 case value::ARRAY_FLOAT:
2905 case value::ARRAY_DOUBLE:
2906 case value::ARRAY_BOOL:
2907 case value::ARRAY_STRING:
2915 inline bool value::i_set(value& aThis,const Slash::Core::IValue& aValue){
2918 aThis.m_type = aValue.type();
2920 switch(aValue.type()) {
2922 aThis.u.m_unsigned_int64 = 0;
2925 aThis.u.m_char = aValue.get_char();
2928 aThis.u.m_short = aValue.get_short();
2931 aThis.u.m_int = aValue.get_int();
2934 aThis.u.m_int64 = aValue.get_int64();
2936 case value::UNSIGNED_INT64:
2937 aThis.u.m_unsigned_int64 = aValue.get_unsigned_int64();
2939 //case value::UNSIGNED_CHAR:
2940 // aThis.u.m_unsigned_char = aValue.get_unsigned_char();
2942 case value::UNSIGNED_SHORT:
2943 aThis.u.m_unsigned_short = aValue.get_unsigned_short();
2945 case value::UNSIGNED_INT:
2946 aThis.u.m_unsigned_int = aValue.get_unsigned_int();
2948 case value::DOUBLE_STAR:
2949 aThis.u.m_double_star = aValue.get_double_star();
2951 case value::FLOAT_STAR:
2952 aThis.u.m_float_star = aValue.get_float_star();
2954 case value::INT_STAR:
2955 aThis.u.m_int_star = aValue.get_int_star();
2958 aThis.u.m_float = aValue.get_float();
2961 aThis.u.m_double = aValue.get_double();
2963 case value::VOID_STAR:
2964 aThis.u.m_void_star = aValue.get_void_star();
2967 aThis.u.m_bool = aValue.get_bool();
2970 aThis.u.m_string = new std::string(aValue.get_string());
2973 case value::ARRAY_UNSIGNED_CHAR:
2974 {std::vector<unsigned int> is;
2975 const std::vector<unsigned char>& vd = aValue.get_array_unsigned_char(is);
2976 aThis.u.m_array_unsigned_char = new tools::array<unsigned char>();
2977 if(!aThis.u.m_array_unsigned_char->configure(is)){
2978 aThis.set_none();return false;
2980 if(!aThis.u.m_array_unsigned_char->fill(vd)){aThis.set_none();return false;}
2983 case value::ARRAY_CHAR:
2984 {std::vector<unsigned int> is;
2985 const std::vector<char>& vd = aValue.get_array_char(is);
2986 aThis.u.m_array_char = new tools::array<char>();
2987 if(!aThis.u.m_array_char->configure(is)){
2988 aThis.set_none();return false;
2990 if(!aThis.u.m_array_char->fill(vd)){aThis.set_none();return false;}
2992 case value::ARRAY_UNSIGNED_SHORT:
2993 {std::vector<unsigned int> is;
2994 const std::vector<unsigned short>& vd =
2995 aValue.get_array_unsigned_short(is);
2996 aThis.u.m_array_unsigned_short = new tools::array<unsigned short>();
2997 if(!aThis.u.m_array_unsigned_short->configure(is)){
2998 aThis.set_none();return false;
3000 if(!aThis.u.m_array_unsigned_short->fill(vd)){
3001 aThis.set_none();return false;
3005 case value::ARRAY_SHORT:
3006 {std::vector<unsigned int> is;
3007 const std::vector<short>& vd = aValue.get_array_short(is);
3008 aThis.u.m_array_short = new tools::array<short>();
3009 if(!aThis.u.m_array_short->configure(is)){aThis.set_none();return false;}
3010 if(!aThis.u.m_array_short->fill(vd)){aThis.set_none();return false;}
3013 case value::ARRAY_UNSIGNED_INT:
3014 {std::vector<unsigned int> is;
3015 const std::vector<unsigned int>& vd = aValue.get_array_unsigned_int(is);
3016 aThis.u.m_array_unsigned_int = new tools::array<unsigned int>();
3017 if(!aThis.u.m_array_unsigned_int->configure(is)){
3018 aThis.set_none();return false;
3020 if(!aThis.u.m_array_unsigned_int->fill(vd)){
3021 aThis.set_none();return false;
3025 case value::ARRAY_INT:
3026 {std::vector<unsigned int> is;
3027 const std::vector<int>& vd = aValue.get_array_int(is);
3028 aThis.u.m_array_int = new tools::array<int>();
3029 if(!aThis.u.m_array_int->configure(is)){aThis.set_none();return false;}
3030 if(!aThis.u.m_array_int->fill(vd)){aThis.set_none();return false;}
3033 case value::ARRAY_UNSIGNED_INT64:
3034 {std::vector<unsigned int> is;
3035 const std::vector<uint64>& vd = aValue.get_array_unsigned_int64(is);
3036 aThis.u.m_array_unsigned_int64 = new tools::array<uint64>();
3037 if(!aThis.u.m_array_unsigned_int64->configure(is)){
3038 aThis.set_none();return false;
3040 if(!aThis.u.m_array_unsigned_int64->fill(vd)){
3041 aThis.set_none();return false;
3045 case value::ARRAY_INT64:
3046 {std::vector<unsigned int> is;
3047 const std::vector<int64>& vd = aValue.get_array_int64(is);
3048 aThis.u.m_array_int64 = new tools::array<int64>();
3049 if(!aThis.u.m_array_int64->configure(is)){aThis.set_none();return false;}
3050 if(!aThis.u.m_array_int64->fill(vd)){aThis.set_none();return false;}
3053 case value::ARRAY_FLOAT:
3054 {std::vector<unsigned int> is;
3055 const std::vector<float>& vd = aValue.get_array_float(is);
3056 aThis.u.m_array_float = new tools::array<float>();
3057 if(!aThis.u.m_array_float->configure(is)){aThis.set_none();return false;}
3058 if(!aThis.u.m_array_float->fill(vd)){aThis.set_none();return false;}
3061 case value::ARRAY_DOUBLE:
3062 {std::vector<unsigned int> is;
3063 const std::vector<double>& vd = aValue.get_array_double(is);
3064 aThis.u.m_array_double = new tools::array<double>();
3065 if(!aThis.u.m_array_double->configure(is)){aThis.set_none();return false;}
3066 if(!aThis.u.m_array_double->fill(vd)){aThis.set_none();return false;}
3069 case value::ARRAY_BOOL:
3070 {std::vector<unsigned int> is;
3071 const std::vector<bool>& vd = aValue.get_array_bool(is);
3072 aThis.u.m_array_bool = new tools::array<bool>();
3073 if(!aThis.u.m_array_bool->configure(is)){aThis.set_none();return false;}
3074 if(!aThis.u.m_array_bool->fill(vd)){aThis.set_none();return false;}
3077 case value::ARRAY_STRING:
3078 {std::vector<unsigned int> is;
3079 const std::vector<std::string>& vd = aValue.get_array_string(is);
3080 aThis.u.m_array_string = new tools::array<std::string>();
3081 if(!aThis.u.m_array_string->configure(is)){aThis.set_none();return false;}
3082 if(!aThis.u.m_array_string->fill(vd)){aThis.set_none();return false;}
3092 inline std::string value::to_string(const value& aThis){
3094 switch(aThis.m_type) {
3096 tools::sprintf(s,5,"(nil)");
3099 tools::sprintf(s,16,"%d",aThis.u.m_int);
3102 tools::sprintf(s,16,"%g",aThis.u.m_double);
3104 case value::VOID_STAR:
3105 tools::sprintf(s,16,"0x%lx",(unsigned long)aThis.u.m_void_star);
3107 case value::UNSIGNED_SHORT:
3108 tools::sprintf(s,16,"%u",aThis.u.m_unsigned_short);
3110 case value::UNSIGNED_INT:
3111 tools::sprintf(s,16,"%u",aThis.u.m_unsigned_int);
3114 tools::sprintf(s,5,"%s",aThis.u.m_bool?"true":"false");
3117 tools::sprintf(s,16,"%d",aThis.u.m_short);
3120 tools::sprintf(s,16,tools::int64_format(),aThis.u.m_int64);
3122 case value::UNSIGNED_INT64:{
3123 tools::sprintf(s,16,tools::int64_format(),aThis.u.m_unsigned_int64);
3126 tools::sprintf(s,16,"%g",aThis.u.m_float);
3128 //case value::UNSIGNED_CHAR:
3129 // tools::sprintf(s,16,"%c",aThis.u.m_unsigned_char);
3132 // tools::sprintf(s,16,"%c",aThis.u.m_char);
3134 case value::DOUBLE_STAR:
3135 tools::sprintf(s,16,"0x%lx",(unsigned long)aThis.u.m_double_star);
3137 case value::FLOAT_STAR:
3138 tools::sprintf(s,16,"0x%lx",(unsigned long)aThis.u.m_float_star);
3140 case value::INT_STAR:
3141 tools::sprintf(s,16,"0x%lx",(unsigned long)aThis.u.m_int_star);
3144 return *aThis.u.m_string;
3146 //case value::ARRAY_UNSIGNED_CHAR:
3147 // return tools::tos<unsigned char>(aThis.u.m_array_unsigned_char->vector());
3148 //case value::ARRAY_CHAR:
3149 // return tools::tos<char>(aThis.u.m_array_char->vector());
3150 case value::ARRAY_UNSIGNED_SHORT:
3151 if(!tools::nums2s<unsigned short>(aThis.u.m_array_unsigned_short->vector(),s)) {}
3153 case value::ARRAY_SHORT:
3154 if(!tools::nums2s<short>(aThis.u.m_array_short->vector(),s)) {}
3157 case value::ARRAY_UNSIGNED_INT:
3158 if(!tools::nums2s<unsigned int>(aThis.u.m_array_unsigned_int->vector(),s)) {}
3160 case value::ARRAY_INT:
3161 if(!tools::nums2s<int>(aThis.u.m_array_int->vector(),s)) {}
3164 case value::ARRAY_UNSIGNED_INT64:
3165 if(!tools::nums2s<uint64>(aThis.u.m_array_unsigned_int64->vector(),s)) {}
3167 case value::ARRAY_INT64:
3168 if(!tools::nums2s<int64>(aThis.u.m_array_int64->vector(),s)) {}
3171 case value::ARRAY_FLOAT:
3172 if(!tools::nums2s<float>(aThis.u.m_array_float->vector(),s)) {}
3174 case value::ARRAY_DOUBLE:
3175 if(!tools::nums2s<double>(aThis.u.m_array_double->vector(),s)) {}
3177 case value::ARRAY_BOOL:
3178 tools::b2s(aThis.u.m_array_bool->vector(),s);
3180 case value::ARRAY_STRING:
3181 if(!tools::nums2s<std::string>(aThis.u.m_array_string->vector(),s)) {}
3184 return "unknow"; //it should not happen.