File indexing completed on 2025-01-18 09:57:50
0001
0002 #include "sto"
0003
0004 namespace tools {
0005
0006 inline bool value::assign(value& aThis,const value& aV,std::string& aError){
0007 if(aThis.m_type==aV.m_type) {
0008 aThis.reset();
0009 if(aV.m_type==value::STRING) {
0010 aThis.u.m_string = new std::string(*aV.u.m_string);
0011
0012
0013
0014
0015
0016
0017
0018 } else if(aV.m_type==value::ARRAY_UNSIGNED_SHORT) {
0019 aThis.u.m_array_unsigned_short =
0020 new array<unsigned short>(*aV.u.m_array_unsigned_short);
0021 } else if(aV.m_type==value::ARRAY_SHORT) {
0022 aThis.u.m_array_short = new array<short>(*aV.u.m_array_short);
0023
0024 } else if(aV.m_type==value::ARRAY_UNSIGNED_INT) {
0025 aThis.u.m_array_unsigned_int =
0026 new array<unsigned int>(*aV.u.m_array_unsigned_int);
0027 } else if(aV.m_type==value::ARRAY_INT) {
0028 aThis.u.m_array_int = new array<int>(*aV.u.m_array_int);
0029
0030 } else if(aV.m_type==value::ARRAY_UNSIGNED_INT64) {
0031 aThis.u.m_array_unsigned_int64 =
0032 new array<uint64>(*aV.u.m_array_unsigned_int64);
0033 } else if(aV.m_type==value::ARRAY_INT64) {
0034 aThis.u.m_array_int64 =
0035 new array<int64>(*aV.u.m_array_int64);
0036
0037 } else if(aV.m_type==value::ARRAY_FLOAT) {
0038 aThis.u.m_array_float = new array<float>(*aV.u.m_array_float);
0039 } else if(aV.m_type==value::ARRAY_DOUBLE) {
0040 aThis.u.m_array_double = new array<double>(*aV.u.m_array_double);
0041 } else if(aV.m_type==value::ARRAY_BOOL) {
0042 aThis.u.m_array_bool = new array<bool>(*aV.u.m_array_bool);
0043
0044 } else if(aV.m_type==value::ARRAY_STRING) {
0045 aThis.u.m_array_string =
0046 new array<std::string>(*aV.u.m_array_string);
0047
0048 } else {
0049 aThis.u = aV.u;
0050 }
0051 return true;
0052 } else {
0053 switch(aThis.m_type) {
0054 case value::INT:
0055 break;
0056 case value::DOUBLE:
0057 switch(aV.m_type) {
0058 case value::INT:
0059 aThis.u.m_double = aV.u.m_int;
0060 return true;
0061 case value::UNSIGNED_SHORT :
0062 aThis.u.m_double = aV.u.m_unsigned_short;
0063 return true;
0064 case value::UNSIGNED_INT:
0065 aThis.u.m_double = aV.u.m_unsigned_int;
0066 return true;
0067 case value::NONE:
0068 case value::DOUBLE:
0069 case value::VOID_STAR:
0070 case value::BOOL:
0071 case value::SHORT:
0072 case value::INT64:
0073 case value::FLOAT:
0074
0075
0076 case value::UNSIGNED_INT64 :
0077 case value::DOUBLE_STAR:
0078 case value::FLOAT_STAR:
0079 case value::INT_STAR:
0080 case value::STRING:
0081
0082
0083 case value::ARRAY_UNSIGNED_SHORT:
0084 case value::ARRAY_SHORT:
0085 case value::ARRAY_UNSIGNED_INT:
0086 case value::ARRAY_INT:
0087 case value::ARRAY_UNSIGNED_INT64:
0088 case value::ARRAY_INT64:
0089 case value::ARRAY_FLOAT:
0090 case value::ARRAY_DOUBLE:
0091 case value::ARRAY_BOOL:
0092 case value::ARRAY_STRING:
0093 break;
0094 }
0095 break;
0096 case value::STRING:
0097 break;
0098 case value::VOID_STAR:
0099 break;
0100 case value::UNSIGNED_INT:
0101 break;
0102 case value::BOOL:
0103 break;
0104 case value::SHORT:
0105 switch(aV.m_type) {
0106 case value::INT:
0107 aThis.u.m_short = (short)aV.u.m_int;
0108 return true;
0109 case value::NONE:
0110 case value::DOUBLE:
0111 case value::VOID_STAR:
0112 case value::BOOL:
0113 case value::SHORT:
0114 case value::INT64:
0115 case value::FLOAT:
0116
0117
0118 case value::UNSIGNED_SHORT :
0119 case value::UNSIGNED_INT:
0120 case value::UNSIGNED_INT64 :
0121 case value::DOUBLE_STAR:
0122 case value::FLOAT_STAR:
0123 case value::INT_STAR:
0124 case value::STRING:
0125
0126
0127 case value::ARRAY_UNSIGNED_SHORT:
0128 case value::ARRAY_SHORT:
0129 case value::ARRAY_UNSIGNED_INT:
0130 case value::ARRAY_INT:
0131 case value::ARRAY_UNSIGNED_INT64:
0132 case value::ARRAY_INT64:
0133 case value::ARRAY_FLOAT:
0134 case value::ARRAY_DOUBLE:
0135 case value::ARRAY_BOOL:
0136 case value::ARRAY_STRING:
0137 break;
0138 }
0139 break;
0140 case value::FLOAT:
0141 switch(aV.m_type) {
0142 case value::INT:
0143 aThis.u.m_float = (float)aV.u.m_int;
0144 return true;
0145 case value::DOUBLE:
0146 aThis.u.m_float = (float)aV.u.m_double;
0147 return true;
0148 case value::NONE:
0149 case value::VOID_STAR:
0150 case value::BOOL:
0151 case value::SHORT:
0152 case value::INT64:
0153 case value::FLOAT:
0154
0155
0156 case value::UNSIGNED_SHORT :
0157 case value::UNSIGNED_INT:
0158 case value::UNSIGNED_INT64 :
0159 case value::DOUBLE_STAR:
0160 case value::FLOAT_STAR:
0161 case value::INT_STAR:
0162 case value::STRING:
0163
0164
0165 case value::ARRAY_UNSIGNED_SHORT:
0166 case value::ARRAY_SHORT:
0167 case value::ARRAY_UNSIGNED_INT:
0168 case value::ARRAY_INT:
0169 case value::ARRAY_UNSIGNED_INT64:
0170 case value::ARRAY_INT64:
0171 case value::ARRAY_FLOAT:
0172 case value::ARRAY_DOUBLE:
0173 case value::ARRAY_BOOL:
0174 case value::ARRAY_STRING:
0175 break;
0176 }
0177 break;
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 case value::NONE:
0256 case value::INT64:
0257 case value::UNSIGNED_SHORT :
0258 case value::UNSIGNED_INT64 :
0259 switch(aV.m_type) {
0260 case value::INT:
0261 aThis.u.m_int64 = aV.u.m_int;
0262 return true;
0263 case value::UNSIGNED_SHORT :
0264 aThis.u.m_int64 = aV.u.m_unsigned_short;
0265 return true;
0266 case value::UNSIGNED_INT:
0267 aThis.u.m_int64 = aV.u.m_unsigned_int;
0268 return true;
0269 case value::NONE:
0270 case value::DOUBLE:
0271 case value::VOID_STAR:
0272 case value::BOOL:
0273 case value::SHORT:
0274 case value::INT64:
0275 case value::FLOAT:
0276
0277
0278 case value::UNSIGNED_INT64 :
0279 case value::DOUBLE_STAR:
0280 case value::FLOAT_STAR:
0281 case value::INT_STAR:
0282 case value::STRING:
0283
0284
0285 case value::ARRAY_UNSIGNED_SHORT:
0286 case value::ARRAY_SHORT:
0287 case value::ARRAY_UNSIGNED_INT:
0288 case value::ARRAY_INT:
0289 case value::ARRAY_UNSIGNED_INT64:
0290 case value::ARRAY_INT64:
0291 case value::ARRAY_FLOAT:
0292 case value::ARRAY_DOUBLE:
0293 case value::ARRAY_BOOL:
0294 case value::ARRAY_STRING:
0295 break;
0296 }
0297 break;
0298 case value::DOUBLE_STAR:
0299 case value::FLOAT_STAR:
0300 case value::INT_STAR:
0301
0302
0303 case value::ARRAY_UNSIGNED_SHORT:
0304 case value::ARRAY_SHORT:
0305 case value::ARRAY_UNSIGNED_INT:
0306 case value::ARRAY_INT:
0307 case value::ARRAY_UNSIGNED_INT64:
0308 case value::ARRAY_INT64:
0309 case value::ARRAY_FLOAT:
0310 case value::ARRAY_DOUBLE:
0311 case value::ARRAY_BOOL:
0312 case value::ARRAY_STRING:
0313 break;
0314 }
0315 aError = std::string("value::assign :")
0316 + " unable to assign " + aV.stype()
0317 + " to " + aThis.stype();
0318 aThis.set_none();
0319 return false;
0320 }
0321 }
0322
0323 inline bool value::minus(value& aThis,std::string& aError){
0324 value::e_type oType = aThis.m_type;
0325 switch(aThis.m_type) {
0326 case value::INT:
0327 aThis.u.m_int = -aThis.u.m_int;
0328 return true;
0329 case value::DOUBLE:
0330 aThis.u.m_double = -aThis.u.m_double;
0331 return true;
0332 case value::SHORT:
0333 aThis.u.m_short = -aThis.u.m_short;
0334 return true;
0335 case value::INT64:
0336 aThis.u.m_int64 = -aThis.u.m_int64;
0337 return true;
0338 case value::FLOAT:
0339 aThis.u.m_float = -1.0F * aThis.u.m_float;
0340 return true;
0341 case value::ARRAY_DOUBLE:{
0342 std::vector<double>& stdv = aThis.u.m_array_double->vector();
0343 size_t number = stdv.size();
0344 for(size_t index=0;index<number;index++) stdv[index] = -stdv[index];
0345 return true;}
0346
0347
0348
0349
0350
0351
0352
0353 case value::UNSIGNED_SHORT:{
0354 short tmp = -1*aThis.u.m_unsigned_short;
0355 aThis.set(tmp);
0356 return true;}
0357 case value::UNSIGNED_INT:{
0358 int tmp = -1*aThis.u.m_unsigned_int;
0359 aThis.set(tmp);
0360 return true;}
0361 case value::UNSIGNED_INT64 :{
0362 int64 tmp = -1*aThis.u.m_unsigned_int64;
0363 aThis.set(tmp);
0364 return true;}
0365 case value::BOOL:
0366 case value::NONE:
0367 case value::STRING:
0368 case value::VOID_STAR:
0369 case value::DOUBLE_STAR:
0370 case value::FLOAT_STAR:
0371 case value::INT_STAR:
0372
0373
0374 case value::ARRAY_UNSIGNED_SHORT:
0375 case value::ARRAY_SHORT:
0376 case value::ARRAY_UNSIGNED_INT:
0377 case value::ARRAY_INT:
0378 case value::ARRAY_UNSIGNED_INT64:
0379 case value::ARRAY_INT64:
0380 case value::ARRAY_FLOAT:
0381
0382 case value::ARRAY_BOOL:
0383 case value::ARRAY_STRING:
0384 break;
0385 }
0386 aError = std::string("value::minus :")
0387 + " can't apply on type " + value::stype(oType);
0388 aThis.set_none();
0389 return false;
0390 }
0391
0392 inline bool value::do_not(value& aThis,std::string& aError){
0393 value::e_type oType = aThis.m_type;
0394 switch(aThis.m_type) {
0395 case value::BOOL:
0396 aThis.u.m_bool = aThis.u.m_bool?false:true;
0397 return true;
0398 case value::INT:
0399 case value::DOUBLE:
0400 case value::STRING:
0401 case value::VOID_STAR:
0402 case value::UNSIGNED_SHORT :
0403 case value::UNSIGNED_INT:
0404 case value::SHORT:
0405 case value::FLOAT:
0406
0407
0408 case value::NONE:
0409 case value::INT64:
0410 case value::UNSIGNED_INT64 :
0411 case value::DOUBLE_STAR:
0412 case value::FLOAT_STAR:
0413 case value::INT_STAR:
0414
0415
0416 case value::ARRAY_UNSIGNED_SHORT:
0417 case value::ARRAY_SHORT:
0418 case value::ARRAY_UNSIGNED_INT:
0419 case value::ARRAY_INT:
0420 case value::ARRAY_UNSIGNED_INT64:
0421 case value::ARRAY_INT64:
0422 case value::ARRAY_FLOAT:
0423 case value::ARRAY_DOUBLE:
0424 case value::ARRAY_BOOL:
0425 case value::ARRAY_STRING:
0426 break;
0427 }
0428 aError = std::string("value::do_not :")
0429 + " can't apply on type " + value::stype(oType);
0430 aThis.set_none();
0431 return false;
0432 }
0433
0434
0435
0436
0437
0438 inline bool value::add(value& aThis,const value& aV,std::string& aError){
0439 value::e_type oType = aThis.m_type;
0440 switch(aThis.m_type) {
0441 case value::INT:
0442 switch(aV.m_type) {
0443 case value::INT:
0444 aThis.u.m_int += aV.u.m_int;
0445 return true;
0446 case value::FLOAT:{
0447 float tmp = aThis.u.m_int + aV.u.m_float;
0448 aThis.set(tmp);
0449 return true;}
0450 case value::DOUBLE:{
0451 double tmp = aThis.u.m_int + aV.u.m_double;
0452 aThis.set(tmp);
0453 return true;}
0454 case value::ARRAY_DOUBLE:{
0455 int tmp = aThis.u.m_int;
0456
0457 aThis.set(aV.u.m_array_double->orders(),
0458 aV.u.m_array_double->vector());
0459 aThis.u.m_array_double->add(double(tmp));
0460 return true;}
0461 case value::NONE:
0462 case value::STRING:
0463 case value::VOID_STAR:
0464 case value::BOOL:
0465 case value::SHORT:
0466 case value::INT64:
0467
0468
0469 case value::UNSIGNED_SHORT :
0470 case value::UNSIGNED_INT64 :
0471 case value::DOUBLE_STAR:
0472 case value::FLOAT_STAR:
0473 case value::INT_STAR:
0474 case value::UNSIGNED_INT:
0475
0476
0477 case value::ARRAY_UNSIGNED_SHORT:
0478 case value::ARRAY_SHORT:
0479 case value::ARRAY_UNSIGNED_INT:
0480 case value::ARRAY_INT:
0481 case value::ARRAY_UNSIGNED_INT64:
0482 case value::ARRAY_INT64:
0483 case value::ARRAY_FLOAT:
0484
0485 case value::ARRAY_BOOL:
0486 case value::ARRAY_STRING:
0487 break;
0488 }
0489 break;
0490 case value::FLOAT:
0491 switch(aV.m_type) {
0492 case value::UNSIGNED_SHORT :
0493 aThis.u.m_float += aV.u.m_unsigned_short;
0494 return true;
0495 case value::UNSIGNED_INT:
0496 aThis.u.m_float += aV.u.m_unsigned_int;
0497 return true;
0498 case value::SHORT:
0499 aThis.u.m_float += aV.u.m_short;
0500 return true;
0501 case value::INT:
0502 aThis.u.m_float += aV.u.m_int;
0503 return true;
0504 case value::FLOAT:
0505 aThis.u.m_float += aV.u.m_float;
0506 return true;
0507 case value::DOUBLE:
0508 aThis.u.m_float += (float)aV.u.m_double;
0509 return true;
0510 case value::ARRAY_DOUBLE:{
0511 double tmp = aThis.u.m_float;
0512
0513 aThis.set(aV.u.m_array_double->orders(),
0514 aV.u.m_array_double->vector());
0515 aThis.u.m_array_double->add(tmp);
0516 return true;}
0517 case value::NONE:
0518 case value::STRING:
0519 case value::VOID_STAR:
0520 case value::BOOL:
0521 case value::INT64:
0522
0523
0524 case value::UNSIGNED_INT64 :
0525 case value::DOUBLE_STAR:
0526 case value::FLOAT_STAR:
0527 case value::INT_STAR:
0528
0529
0530 case value::ARRAY_UNSIGNED_SHORT:
0531 case value::ARRAY_SHORT:
0532 case value::ARRAY_UNSIGNED_INT:
0533 case value::ARRAY_INT:
0534 case value::ARRAY_UNSIGNED_INT64:
0535 case value::ARRAY_INT64:
0536 case value::ARRAY_FLOAT:
0537
0538 case value::ARRAY_BOOL:
0539 case value::ARRAY_STRING:
0540 break;
0541 }
0542 break;
0543 case value::DOUBLE:
0544 switch(aV.m_type) {
0545 case value::SHORT:
0546 aThis.u.m_double += aV.u.m_short;
0547 return true;
0548 case value::INT:
0549 aThis.u.m_double += aV.u.m_int;
0550 return true;
0551 case value::FLOAT:
0552 aThis.u.m_double += aV.u.m_float;
0553 return true;
0554 case value::DOUBLE:
0555 aThis.u.m_double += aV.u.m_double;
0556 return true;
0557 case value::UNSIGNED_SHORT :
0558 aThis.u.m_double += aV.u.m_unsigned_short;
0559 return true;
0560 case value::UNSIGNED_INT:
0561 aThis.u.m_double += aV.u.m_unsigned_int;
0562 return true;
0563 case value::ARRAY_DOUBLE:{
0564 double tmp = aThis.u.m_double;
0565
0566 aThis.set(aV.u.m_array_double->orders(),
0567 aV.u.m_array_double->vector());
0568 aThis.u.m_array_double->add(tmp);
0569 return true;}
0570 case value::NONE:
0571 case value::STRING:
0572 case value::VOID_STAR:
0573 case value::BOOL:
0574 case value::INT64:
0575
0576
0577 case value::UNSIGNED_INT64 :
0578 case value::DOUBLE_STAR:
0579 case value::FLOAT_STAR:
0580 case value::INT_STAR:
0581
0582
0583 case value::ARRAY_UNSIGNED_SHORT:
0584 case value::ARRAY_SHORT:
0585 case value::ARRAY_UNSIGNED_INT:
0586 case value::ARRAY_INT:
0587 case value::ARRAY_UNSIGNED_INT64:
0588 case value::ARRAY_INT64:
0589 case value::ARRAY_FLOAT:
0590
0591 case value::ARRAY_BOOL:
0592 case value::ARRAY_STRING:
0593 break;
0594 }
0595 break;
0596 case value::UNSIGNED_INT:
0597 switch(aV.m_type) {
0598 case value::UNSIGNED_INT:
0599 aThis.u.m_unsigned_int += aV.u.m_unsigned_int;
0600 return true;
0601 case value::INT:{
0602 int tmp = aThis.u.m_unsigned_int + aV.u.m_int;
0603 aThis.set(tmp);
0604 return true;}
0605 case value::FLOAT:{
0606 float tmp = float(aThis.u.m_unsigned_int) + aV.u.m_float;
0607 aThis.set(tmp);
0608 return true;}
0609 case value::DOUBLE:{
0610 double tmp = double(aThis.u.m_unsigned_int) + aV.u.m_double;
0611 aThis.set(tmp);
0612 return true;}
0613 case value::ARRAY_DOUBLE:{
0614 unsigned int tmp = aThis.u.m_unsigned_int;
0615
0616 aThis.set(aV.u.m_array_double->orders(),
0617 aV.u.m_array_double->vector());
0618 aThis.u.m_array_double->add(double(tmp));
0619 return true;}
0620 case value::NONE:
0621 case value::STRING:
0622 case value::VOID_STAR:
0623 case value::BOOL:
0624 case value::SHORT:
0625 case value::INT64:
0626
0627
0628 case value::UNSIGNED_SHORT :
0629 case value::UNSIGNED_INT64 :
0630 case value::DOUBLE_STAR:
0631 case value::FLOAT_STAR:
0632 case value::INT_STAR:
0633
0634
0635 case value::ARRAY_UNSIGNED_SHORT:
0636 case value::ARRAY_SHORT:
0637 case value::ARRAY_UNSIGNED_INT:
0638 case value::ARRAY_INT:
0639 case value::ARRAY_UNSIGNED_INT64:
0640 case value::ARRAY_INT64:
0641 case value::ARRAY_FLOAT:
0642
0643 case value::ARRAY_BOOL:
0644 case value::ARRAY_STRING:
0645 break;
0646 }
0647 break;
0648 case value::STRING:
0649 switch(aV.m_type) {
0650 case value::STRING:
0651 aThis.set((*aThis.u.m_string)+(*aV.u.m_string));
0652 return true;
0653 case value::NONE:
0654 case value::INT:
0655 case value::DOUBLE:
0656 case value::VOID_STAR:
0657 case value::BOOL:
0658 case value::SHORT:
0659 case value::INT64:
0660 case value::FLOAT:
0661
0662
0663 case value::UNSIGNED_SHORT :
0664 case value::UNSIGNED_INT:
0665 case value::UNSIGNED_INT64 :
0666 case value::DOUBLE_STAR:
0667 case value::FLOAT_STAR:
0668 case value::INT_STAR:
0669
0670
0671 case value::ARRAY_UNSIGNED_SHORT:
0672 case value::ARRAY_SHORT:
0673 case value::ARRAY_UNSIGNED_INT:
0674 case value::ARRAY_INT:
0675 case value::ARRAY_UNSIGNED_INT64:
0676 case value::ARRAY_INT64:
0677 case value::ARRAY_FLOAT:
0678 case value::ARRAY_DOUBLE:
0679 case value::ARRAY_BOOL:
0680 case value::ARRAY_STRING:
0681 break;
0682 }
0683 break;
0684 case value::ARRAY_DOUBLE:
0685 switch(aV.m_type) {
0686 case value::INT:
0687 aThis.u.m_array_double->add(aV.u.m_int);
0688 return true;
0689 case value::UNSIGNED_INT:
0690 aThis.u.m_array_double->add(aV.u.m_unsigned_int);
0691 return true;
0692 case value::DOUBLE:
0693 aThis.u.m_array_double->add(aV.u.m_double);
0694 return true;
0695 case value::ARRAY_DOUBLE:
0696 if(aThis.u.m_array_double->orders()!=aV.u.m_array_double->orders()) {
0697 aError = "Value::add : vector orders mismatch.";
0698 aThis.set_none();
0699 return false;
0700 }
0701 aThis.u.m_array_double->add(*aV.u.m_array_double);
0702 return true;
0703 case value::NONE:
0704 case value::VOID_STAR:
0705 case value::BOOL:
0706 case value::SHORT:
0707 case value::INT64:
0708 case value::FLOAT:
0709
0710
0711 case value::UNSIGNED_SHORT :
0712 case value::UNSIGNED_INT64 :
0713 case value::DOUBLE_STAR:
0714 case value::FLOAT_STAR:
0715 case value::INT_STAR:
0716 case value::STRING:
0717
0718
0719 case value::ARRAY_UNSIGNED_SHORT:
0720 case value::ARRAY_SHORT:
0721 case value::ARRAY_UNSIGNED_INT:
0722 case value::ARRAY_INT:
0723 case value::ARRAY_UNSIGNED_INT64:
0724 case value::ARRAY_INT64:
0725 case value::ARRAY_FLOAT:
0726
0727 case value::ARRAY_BOOL:
0728 case value::ARRAY_STRING:
0729 break;
0730 }
0731 break;
0732 case value::NONE:
0733 case value::VOID_STAR:
0734 case value::BOOL:
0735 case value::SHORT:
0736 case value::INT64:
0737
0738
0739 case value::UNSIGNED_SHORT :
0740 case value::UNSIGNED_INT64 :
0741 case value::DOUBLE_STAR:
0742 case value::FLOAT_STAR:
0743 case value::INT_STAR:
0744
0745
0746 case value::ARRAY_UNSIGNED_SHORT:
0747 case value::ARRAY_SHORT:
0748 case value::ARRAY_UNSIGNED_INT:
0749 case value::ARRAY_INT:
0750 case value::ARRAY_UNSIGNED_INT64:
0751 case value::ARRAY_INT64:
0752 case value::ARRAY_FLOAT:
0753
0754 case value::ARRAY_BOOL:
0755 case value::ARRAY_STRING:
0756 break;
0757 }
0758 aError = std::string("Value::add :" )
0759 + " can't apply on type " + value::stype(oType)
0760 + " and type " + aV.stype();
0761 aThis.set_none();
0762 return false;
0763 }
0764
0765 inline bool value::subtract(value& aThis,const value& aV,std::string& aError){
0766 value::e_type oType = aThis.m_type;
0767 switch(aThis.m_type) {
0768 case value::INT:
0769 switch(aV.m_type) {
0770 case value::INT:
0771 aThis.u.m_int -= aV.u.m_int;
0772 return true;
0773 case value::DOUBLE:{
0774 double tmp = aThis.u.m_int - aV.u.m_double;
0775 aThis.set(tmp);
0776 return true;}
0777 case value::FLOAT:{
0778 float tmp = aThis.u.m_int - aV.u.m_float;
0779 aThis.set(tmp);
0780 return true;}
0781 case value::ARRAY_DOUBLE:{
0782 int tmp = aThis.u.m_int;
0783
0784 aThis.set(aV.u.m_array_double->orders(),
0785 aV.u.m_array_double->vector());
0786 aThis.u.m_array_double->multiply(-1);
0787 aThis.u.m_array_double->add(double(tmp));
0788 return true;}
0789 case value::NONE:
0790 case value::VOID_STAR:
0791 case value::BOOL:
0792 case value::SHORT:
0793 case value::INT64:
0794
0795
0796 case value::UNSIGNED_SHORT :
0797 case value::UNSIGNED_INT:
0798 case value::UNSIGNED_INT64 :
0799 case value::DOUBLE_STAR:
0800 case value::FLOAT_STAR:
0801 case value::INT_STAR:
0802 case value::STRING:
0803
0804
0805 case value::ARRAY_UNSIGNED_SHORT:
0806 case value::ARRAY_SHORT:
0807 case value::ARRAY_UNSIGNED_INT:
0808 case value::ARRAY_INT:
0809 case value::ARRAY_UNSIGNED_INT64:
0810 case value::ARRAY_INT64:
0811 case value::ARRAY_FLOAT:
0812
0813 case value::ARRAY_BOOL:
0814 case value::ARRAY_STRING:
0815 break;
0816 }
0817 break;
0818 case value::FLOAT:
0819 switch(aV.m_type) {
0820 case value::DOUBLE:{
0821 double tmp = double(aThis.u.m_float) - aV.u.m_double;
0822 aThis.set(tmp);
0823 return true;}
0824 case value::UNSIGNED_SHORT :
0825 aThis.u.m_float -= aV.u.m_unsigned_short;
0826 return true;
0827 case value::UNSIGNED_INT:
0828 aThis.u.m_float -= aV.u.m_unsigned_int;
0829 return true;
0830 case value::INT:
0831 aThis.u.m_float -= aV.u.m_int;
0832 return true;
0833 case value::SHORT:
0834 aThis.u.m_float -= aV.u.m_short;
0835 return true;
0836 case value::FLOAT:
0837 aThis.u.m_float -= aV.u.m_float;
0838 return true;
0839 case value::INT64:{
0840 double tmp = double(aThis.u.m_float) - aV.u.m_int64;
0841 aThis.set(tmp);
0842 return true;}
0843 case value::UNSIGNED_INT64:{
0844 double tmp = double(aThis.u.m_float) - aV.u.m_unsigned_int64;
0845 aThis.set(tmp);
0846 return true;}
0847 case value::ARRAY_DOUBLE:{
0848 double tmp = aThis.u.m_float;
0849
0850 aThis.set(aV.u.m_array_double->orders(),
0851 aV.u.m_array_double->vector());
0852 aThis.u.m_array_double->multiply(-1);
0853 aThis.u.m_array_double->add(tmp);
0854 return true;}
0855 case value::NONE:
0856 case value::VOID_STAR:
0857 case value::BOOL:
0858
0859
0860 case value::DOUBLE_STAR:
0861 case value::FLOAT_STAR:
0862 case value::INT_STAR:
0863 case value::STRING:
0864
0865
0866 case value::ARRAY_UNSIGNED_SHORT:
0867 case value::ARRAY_SHORT:
0868 case value::ARRAY_UNSIGNED_INT:
0869 case value::ARRAY_INT:
0870 case value::ARRAY_UNSIGNED_INT64:
0871 case value::ARRAY_INT64:
0872 case value::ARRAY_FLOAT:
0873
0874 case value::ARRAY_BOOL:
0875 case value::ARRAY_STRING:
0876 break;
0877 }
0878 break;
0879 case value::DOUBLE:
0880 switch(aV.m_type) {
0881 case value::DOUBLE:
0882 aThis.u.m_double -= aV.u.m_double;
0883 return true;
0884 case value::UNSIGNED_SHORT :
0885 aThis.u.m_double -= aV.u.m_unsigned_short;
0886 return true;
0887 case value::UNSIGNED_INT:
0888 aThis.u.m_double -= aV.u.m_unsigned_int;
0889 return true;
0890 case value::INT:
0891 aThis.u.m_double -= aV.u.m_int;
0892 return true;
0893 case value::SHORT:
0894 aThis.u.m_double -= aV.u.m_short;
0895 return true;
0896 case value::INT64:
0897 aThis.u.m_double -= aV.u.m_int64;
0898 return true;
0899 case value::FLOAT:
0900 aThis.u.m_double -= aV.u.m_float;
0901 return true;
0902 case value::UNSIGNED_INT64 :
0903 aThis.u.m_double -= aV.u.m_unsigned_int64;
0904 return true;
0905 case value::ARRAY_DOUBLE:{
0906 double tmp = aThis.u.m_double;
0907
0908 aThis.set(aV.u.m_array_double->orders(),
0909 aV.u.m_array_double->vector());
0910 aThis.u.m_array_double->multiply(-1);
0911 aThis.u.m_array_double->add(tmp);
0912 return true;}
0913 case value::NONE:
0914 case value::VOID_STAR:
0915 case value::BOOL:
0916
0917
0918 case value::DOUBLE_STAR:
0919 case value::FLOAT_STAR:
0920 case value::INT_STAR:
0921 case value::STRING:
0922
0923
0924 case value::ARRAY_UNSIGNED_SHORT:
0925 case value::ARRAY_SHORT:
0926 case value::ARRAY_UNSIGNED_INT:
0927 case value::ARRAY_INT:
0928 case value::ARRAY_UNSIGNED_INT64:
0929 case value::ARRAY_INT64:
0930 case value::ARRAY_FLOAT:
0931
0932 case value::ARRAY_BOOL:
0933 case value::ARRAY_STRING:
0934 break;
0935 }
0936 break;
0937 case value::UNSIGNED_INT:
0938 switch(aV.m_type) {
0939 case value::UNSIGNED_INT:
0940 if(aThis.u.m_unsigned_int>=aV.u.m_unsigned_int) {
0941 aThis.u.m_unsigned_int -= aV.u.m_unsigned_int;
0942 } else {
0943 int i = int(aThis.u.m_unsigned_int) - aV.u.m_unsigned_int;
0944 aThis.set(i);
0945 }
0946 return true;
0947 case value::DOUBLE:{
0948 double d = double(aThis.u.m_unsigned_int) - aV.u.m_double;
0949 aThis.set(d);
0950 return true;}
0951 case value::FLOAT:{
0952 float d = float(aThis.u.m_unsigned_int) - aV.u.m_float;
0953 aThis.set(d);
0954 return true;}
0955 case value::INT:{
0956 int d = int(aThis.u.m_unsigned_int) - aV.u.m_int;
0957 aThis.set(d);
0958 return true;}
0959 case value::ARRAY_DOUBLE:{
0960 unsigned int tmp = aThis.u.m_unsigned_int;
0961
0962 aThis.set(aV.u.m_array_double->orders(),
0963 aV.u.m_array_double->vector());
0964 aThis.u.m_array_double->multiply(-1);
0965 aThis.u.m_array_double->add(double(tmp));
0966 return true;}
0967 case value::NONE:
0968 case value::VOID_STAR:
0969 case value::BOOL:
0970 case value::SHORT:
0971 case value::INT64:
0972
0973
0974 case value::UNSIGNED_SHORT :
0975 case value::UNSIGNED_INT64 :
0976 case value::DOUBLE_STAR:
0977 case value::FLOAT_STAR:
0978 case value::INT_STAR:
0979 case value::STRING:
0980
0981
0982 case value::ARRAY_UNSIGNED_SHORT:
0983 case value::ARRAY_SHORT:
0984 case value::ARRAY_UNSIGNED_INT:
0985 case value::ARRAY_INT:
0986 case value::ARRAY_UNSIGNED_INT64:
0987 case value::ARRAY_INT64:
0988 case value::ARRAY_FLOAT:
0989
0990 case value::ARRAY_BOOL:
0991 case value::ARRAY_STRING:
0992 break;
0993 }
0994 break;
0995 case value::ARRAY_DOUBLE:
0996 switch(aV.m_type) {
0997 case value::INT:
0998 aThis.u.m_array_double->add(-aV.u.m_int);
0999 return true;
1000 case value::UNSIGNED_INT:
1001 aThis.u.m_array_double->add(-((double)aV.u.m_unsigned_int));
1002 return true;
1003 case value::DOUBLE:
1004 aThis.u.m_array_double->add(-aV.u.m_double);
1005 return true;
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.";
1009 aThis.set_none();
1010 return false;
1011 }
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];
1017 }
1018 return true;}
1019 case value::NONE:
1020 case value::VOID_STAR:
1021 case value::BOOL:
1022 case value::SHORT:
1023 case value::INT64:
1024 case value::FLOAT:
1025
1026
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:
1032 case value::STRING:
1033
1034
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
1043 case value::ARRAY_BOOL:
1044 case value::ARRAY_STRING:
1045 break;
1046 }
1047 break;
1048 case value::NONE:
1049 case value::VOID_STAR:
1050 case value::BOOL:
1051 case value::SHORT:
1052 case value::INT64:
1053
1054
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:
1060 case value::STRING:
1061
1062
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
1071 case value::ARRAY_BOOL:
1072 case value::ARRAY_STRING:
1073 break;
1074 }
1075 aError = std::string("Value::subtract :" )
1076 + " can't apply on type " + value::stype(oType)
1077 + " and type " + aV.stype();
1078 aThis.set_none();
1079 return false;
1080 }
1081
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) {
1085 case value::INT:
1086 switch(aV.m_type) {
1087 case value::INT:
1088 aThis.u.m_int *= aV.u.m_int;
1089 return true;
1090 case value::UNSIGNED_INT:
1091 aThis.u.m_int *= aV.u.m_unsigned_int;
1092 return true;
1093 case value::DOUBLE:
1094 aThis.u.m_int *= (int)aV.u.m_double;
1095 return true;
1096 case value::FLOAT:
1097 aThis.u.m_int *= (int)aV.u.m_float;
1098 return true;
1099 case value::ARRAY_DOUBLE:{
1100 int tmp = aThis.u.m_int;
1101
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));
1105 return true;}
1106 case value::NONE:
1107 case value::VOID_STAR:
1108 case value::BOOL:
1109 case value::SHORT:
1110 case value::INT64:
1111
1112
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:
1118 case value::STRING:
1119
1120
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
1129 case value::ARRAY_BOOL:
1130 case value::ARRAY_STRING:
1131 break;
1132 }
1133 break;
1134 case value::FLOAT:
1135 switch(aV.m_type) {
1136 case value::SHORT:
1137 aThis.u.m_float *= aV.u.m_short;
1138 return true;
1139 case value::INT:
1140 aThis.u.m_float *= aV.u.m_int;
1141 return true;
1142 case value::FLOAT:
1143 aThis.u.m_float *= aV.u.m_float;
1144 return true;
1145 case value::DOUBLE:
1146 aThis.u.m_float *= (float)aV.u.m_double;
1147 return true;
1148 case value::UNSIGNED_SHORT :
1149 aThis.u.m_float *= aV.u.m_unsigned_short;
1150 return true;
1151 case value::UNSIGNED_INT:
1152 aThis.u.m_float *= aV.u.m_unsigned_int;
1153 return true;
1154 case value::ARRAY_DOUBLE:{
1155 double tmp = aThis.u.m_float;
1156
1157 aThis.set(aV.u.m_array_double->orders(),
1158 aV.u.m_array_double->vector());
1159 aThis.u.m_array_double->multiply(tmp);
1160 return true;}
1161 case value::NONE:
1162 case value::VOID_STAR:
1163 case value::BOOL:
1164 case value::INT64:
1165
1166
1167 case value::UNSIGNED_INT64 :
1168 case value::DOUBLE_STAR:
1169 case value::FLOAT_STAR:
1170 case value::INT_STAR:
1171 case value::STRING:
1172
1173
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
1182 case value::ARRAY_BOOL:
1183 case value::ARRAY_STRING:
1184 break;
1185 }
1186 break;
1187 case value::DOUBLE:
1188 switch(aV.m_type) {
1189 case value::SHORT:
1190 aThis.u.m_double *= aV.u.m_short;
1191 return true;
1192 case value::INT:
1193 aThis.u.m_double *= aV.u.m_int;
1194 return true;
1195 case value::INT64:
1196 aThis.u.m_double *= aV.u.m_int64;
1197 return true;
1198 case value::FLOAT:
1199 aThis.u.m_double *= aV.u.m_float;
1200 return true;
1201 case value::DOUBLE:
1202 aThis.u.m_double *= aV.u.m_double;
1203 return true;
1204 case value::UNSIGNED_SHORT :
1205 aThis.u.m_double *= aV.u.m_unsigned_short;
1206 return true;
1207 case value::UNSIGNED_INT:
1208 aThis.u.m_double *= aV.u.m_unsigned_int;
1209 return true;
1210 case value::ARRAY_DOUBLE:{
1211 double tmp = aThis.u.m_double;
1212
1213 aThis.set(aV.u.m_array_double->orders(),
1214 aV.u.m_array_double->vector());
1215 aThis.u.m_array_double->multiply(tmp);
1216 return true;}
1217 case value::NONE:
1218 case value::VOID_STAR:
1219 case value::BOOL:
1220
1221
1222 case value::UNSIGNED_INT64 :
1223 case value::DOUBLE_STAR:
1224 case value::FLOAT_STAR:
1225 case value::INT_STAR:
1226 case value::STRING:
1227
1228
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
1237 case value::ARRAY_BOOL:
1238 case value::ARRAY_STRING:
1239 break;
1240 }
1241 break;
1242 case value::UNSIGNED_INT:
1243 switch(aV.m_type) {
1244 case value::FLOAT:{
1245 float tmp = aThis.u.m_unsigned_int * aV.u.m_float;
1246 aThis.set(tmp);
1247 return true;}
1248 case value::DOUBLE:{
1249 double tmp = aThis.u.m_unsigned_int * aV.u.m_double;
1250 aThis.set(tmp);
1251 return true;}
1252 case value::INT:{
1253 int tmp = aThis.u.m_unsigned_int * aV.u.m_int;
1254 aThis.set(tmp);
1255 return true;}
1256 case value::INT64:{
1257 int64 tmp = aThis.u.m_unsigned_int * aV.u.m_int64;
1258 aThis.set(tmp);
1259 return true;}
1260 case value::UNSIGNED_INT:
1261 aThis.u.m_unsigned_int *= aV.u.m_unsigned_int;
1262 return true;
1263 case value::ARRAY_DOUBLE:{
1264 unsigned int tmp = aThis.u.m_unsigned_int;
1265
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));
1269 return true;}
1270 case value::NONE:
1271 case value::VOID_STAR:
1272 case value::BOOL:
1273 case value::SHORT:
1274
1275
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:
1281 case value::STRING:
1282
1283
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
1292 case value::ARRAY_BOOL:
1293 case value::ARRAY_STRING:
1294 break;
1295 }
1296 break;
1297 case value::ARRAY_DOUBLE:
1298 switch(aV.m_type) {
1299 case value::INT:
1300 aThis.u.m_array_double->multiply(aV.u.m_int);
1301 return true;
1302 case value::UNSIGNED_INT:
1303 aThis.u.m_array_double->multiply(aV.u.m_unsigned_int);
1304 return true;
1305 case value::DOUBLE:
1306 aThis.u.m_array_double->multiply(aV.u.m_double);
1307 return true;
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.";
1311 aThis.set_none();
1312 return false;
1313 }
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];
1319 }
1320 return true;}
1321 case value::NONE:
1322 case value::VOID_STAR:
1323 case value::BOOL:
1324 case value::SHORT:
1325 case value::INT64:
1326 case value::FLOAT:
1327
1328
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:
1334 case value::STRING:
1335
1336
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
1345 case value::ARRAY_BOOL:
1346 case value::ARRAY_STRING:
1347 break;
1348 }
1349 break;
1350 case value::NONE:
1351 case value::STRING:
1352 case value::VOID_STAR:
1353 case value::BOOL:
1354 case value::SHORT:
1355 case value::INT64:
1356
1357
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
1364
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
1373 case value::ARRAY_BOOL:
1374 case value::ARRAY_STRING:
1375 break;
1376 }
1377 aError = std::string("Value::multiply :" )
1378 + " can't apply on type " + value::stype(oType)
1379 + " and type " + aV.stype();
1380 aThis.set_none();
1381 return false;
1382 }
1383
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) {
1387 case value::INT:
1388 switch(aV.m_type) {
1389 case value::INT:
1390 if(aV.u.m_int==0) {
1391 aError = value::error_div_zero();
1392 aThis.set_none();
1393 return false;
1394 } else {
1395 int tmp = aThis.u.m_int/aV.u.m_int;
1396 aThis.set(tmp);
1397 return true;
1398 }
1399 case value::FLOAT:
1400 if(aV.u.m_float==0.0F) {
1401 aError = value::error_div_zero();
1402 aThis.set_none();
1403 return false;
1404 } else {
1405 float tmp = float(aThis.u.m_int)/aV.u.m_float;
1406 aThis.set(tmp);
1407 return true;
1408 }
1409 case value::DOUBLE:
1410 if(aV.u.m_double==0) {
1411 aError = value::error_div_zero();
1412 aThis.set_none();
1413 return false;
1414 } else {
1415 double tmp = double(aThis.u.m_int)/aV.u.m_double;
1416 aThis.set(tmp);
1417 return true;
1418 }
1419 case value::ARRAY_DOUBLE:{
1420 int tmp = aThis.u.m_int;
1421
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();
1426 aThis.set_none();
1427 return false;
1428 }
1429 aThis.u.m_array_double->multiply((double)tmp);
1430 return true;}
1431 case value::NONE:
1432 case value::VOID_STAR:
1433 case value::BOOL:
1434 case value::SHORT:
1435 case value::INT64:
1436
1437
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:
1444 case value::STRING:
1445
1446
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
1455 case value::ARRAY_BOOL:
1456 case value::ARRAY_STRING:
1457 break;
1458 }
1459 break;
1460 case value::FLOAT:
1461 switch(aV.m_type) {
1462 case value::INT:
1463 if(aV.u.m_int==0) {
1464 aError = value::error_div_zero();
1465 aThis.set_none();
1466 return false;
1467 } else {
1468 aThis.u.m_float /= aV.u.m_int;
1469 return true;
1470 }
1471 case value::SHORT:
1472 if(aV.u.m_short==0) {
1473 aError = value::error_div_zero();
1474 aThis.set_none();
1475 return false;
1476 } else {
1477 aThis.u.m_float /= aV.u.m_short;
1478 return true;
1479 }
1480 case value::FLOAT:
1481 if(aV.u.m_float==0.0F) {
1482 aError = value::error_div_zero();
1483 aThis.set_none();
1484 return false;
1485 } else {
1486 aThis.u.m_float /= aV.u.m_float;
1487 return true;
1488 }
1489 case value::DOUBLE:
1490 if(aV.u.m_double==0.0F) {
1491 aError = value::error_div_zero();
1492 aThis.set_none();
1493 return false;
1494 } else {
1495 double tmp = double(aThis.u.m_float)/aV.u.m_double;
1496 aThis.set(tmp);
1497 return true;
1498 }
1499 case value::UNSIGNED_INT:
1500 if(aV.u.m_unsigned_int==0) {
1501 aError = value::error_div_zero();
1502 aThis.set_none();
1503 return false;
1504 } else {
1505 aThis.u.m_float /= aV.u.m_unsigned_int;
1506 return true;
1507 }
1508 case value::UNSIGNED_SHORT:
1509 if(aV.u.m_unsigned_short==0) {
1510 aError = value::error_div_zero();
1511 aThis.set_none();
1512 return false;
1513 } else {
1514 aThis.u.m_float /= aV.u.m_unsigned_short;
1515 return true;
1516 }
1517 case value::UNSIGNED_INT64:
1518 if(aV.u.m_unsigned_int64==0) {
1519 aError = value::error_div_zero();
1520 aThis.set_none();
1521 return false;
1522 } else {
1523 double tmp = double(aThis.u.m_float)/aV.u.m_unsigned_int64;
1524 aThis.set(tmp);
1525 return true;
1526 }
1527 case value::INT64:
1528 if(aV.u.m_int64==0) {
1529 aError = value::error_div_zero();
1530 aThis.set_none();
1531 return false;
1532 } else {
1533 double tmp = double(aThis.u.m_float)/aV.u.m_int64;
1534 aThis.set(tmp);
1535 return true;
1536 }
1537 case value::ARRAY_DOUBLE:{
1538 double tmp = aThis.u.m_float;
1539
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();
1544 aThis.set_none();
1545 return false;
1546 }
1547 aThis.u.m_array_double->multiply(tmp);
1548 return true;}
1549
1550 case value::NONE:
1551 case value::VOID_STAR:
1552 case value::BOOL:
1553
1554
1555 case value::DOUBLE_STAR:
1556 case value::FLOAT_STAR:
1557 case value::INT_STAR:
1558 case value::STRING:
1559
1560
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
1569 case value::ARRAY_BOOL:
1570 case value::ARRAY_STRING:
1571 break;
1572 }
1573 break;
1574 case value::DOUBLE:
1575 switch(aV.m_type) {
1576 case value::SHORT:
1577 if(aV.u.m_short==0) {
1578 aError = value::error_div_zero();
1579 aThis.set_none();
1580 return false;
1581 } else {
1582 aThis.u.m_double /= aV.u.m_short;
1583 return true;
1584 }
1585 case value::INT:
1586 if(aV.u.m_int==0) {
1587 aError = value::error_div_zero();
1588 aThis.set_none();
1589 return false;
1590 } else {
1591 aThis.u.m_double /= aV.u.m_int;
1592 return true;
1593 }
1594 case value::INT64:
1595 if(aV.u.m_int64==0) {
1596 aError = value::error_div_zero();
1597 aThis.set_none();
1598 return false;
1599 } else {
1600 aThis.u.m_double /= aV.u.m_int64;
1601 return true;
1602 }
1603 case value::FLOAT:
1604 if(aV.u.m_float==0.0F) {
1605 aError = value::error_div_zero();
1606 aThis.set_none();
1607 return false;
1608 } else {
1609 aThis.u.m_double /= aV.u.m_float;
1610 return true;
1611 }
1612 case value::DOUBLE:
1613 if(aV.u.m_double==0) {
1614 aError = value::error_div_zero();
1615 aThis.set_none();
1616 return false;
1617 } else {
1618 aThis.u.m_double /= aV.u.m_double;
1619 return true;
1620 }
1621 case value::UNSIGNED_INT:
1622 if(aV.u.m_unsigned_int==0) {
1623 aError = value::error_div_zero();
1624 aThis.set_none();
1625 return false;
1626 } else {
1627 aThis.u.m_double /= aV.u.m_unsigned_int;
1628 return true;
1629 }
1630 case value::UNSIGNED_SHORT:
1631 if(aV.u.m_unsigned_short==0) {
1632 aError = value::error_div_zero();
1633 aThis.set_none();
1634 return false;
1635 } else {
1636 aThis.u.m_double /= aV.u.m_unsigned_short;
1637 return true;
1638 }
1639 case value::UNSIGNED_INT64:
1640 if(aV.u.m_unsigned_int64==0) {
1641 aError = value::error_div_zero();
1642 aThis.set_none();
1643 return false;
1644 } else {
1645 aThis.u.m_double /= aV.u.m_unsigned_int64;
1646 return true;
1647 }
1648 case value::ARRAY_DOUBLE:{
1649 double tmp = aThis.u.m_double;
1650
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();
1655 aThis.set_none();
1656 return false;
1657 }
1658 aThis.u.m_array_double->multiply(tmp);
1659 return true;}
1660
1661 case value::NONE:
1662 case value::VOID_STAR:
1663 case value::BOOL:
1664
1665
1666 case value::DOUBLE_STAR:
1667 case value::FLOAT_STAR:
1668 case value::INT_STAR:
1669 case value::STRING:
1670
1671
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
1680 case value::ARRAY_BOOL:
1681 case value::ARRAY_STRING:
1682 break;
1683 }
1684 break;
1685 case value::UNSIGNED_INT:
1686 switch(aV.m_type) {
1687 case value::UNSIGNED_INT:
1688 if(aV.u.m_unsigned_int==0) {
1689 aError = value::error_div_zero();
1690 aThis.set_none();
1691 return false;
1692 } else {
1693 unsigned int tmp = aThis.u.m_unsigned_int/aV.u.m_unsigned_int;
1694 aThis.set(tmp);
1695 return true;
1696 }
1697 case value::FLOAT:
1698 if(aV.u.m_float==0) {
1699 aError = value::error_div_zero();
1700 aThis.set_none();
1701 return false;
1702 } else {
1703 float d = float(aThis.u.m_unsigned_int)/aV.u.m_float;
1704 aThis.set(d);
1705 return true;
1706 }
1707 case value::DOUBLE:
1708 if(aV.u.m_double==0) {
1709 aError = value::error_div_zero();
1710 aThis.set_none();
1711 return false;
1712 } else {
1713 double d = double(aThis.u.m_unsigned_int)/aV.u.m_double;
1714 aThis.set(d);
1715 return true;
1716 }
1717 case value::ARRAY_DOUBLE:{
1718 unsigned int tmp = aThis.u.m_unsigned_int;
1719
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();
1724 aThis.set_none();
1725 return false;
1726 }
1727 aThis.u.m_array_double->multiply(double(tmp));
1728 return true;}
1729
1730 case value::NONE:
1731 case value::INT:
1732 case value::VOID_STAR:
1733 case value::BOOL:
1734 case value::SHORT:
1735 case value::INT64:
1736
1737
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:
1743 case value::STRING:
1744
1745
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
1754 case value::ARRAY_BOOL:
1755 case value::ARRAY_STRING:
1756 break;
1757 }
1758 break;
1759 case value::ARRAY_DOUBLE:
1760 switch(aV.m_type) {
1761 case value::INT:
1762 if(aV.u.m_int==0) {
1763 aError = value::error_div_zero();
1764 aThis.set_none();
1765 return false;
1766 } else {
1767 double value = 1./aV.u.m_int;
1768 aThis.u.m_array_double->multiply(value);
1769 return true;
1770 }
1771 case value::UNSIGNED_INT:
1772 if(aV.u.m_unsigned_int==0) {
1773 aError = value::error_div_zero();
1774 aThis.set_none();
1775 return false;
1776 } else {
1777 double value = 1./aV.u.m_unsigned_int;
1778 aThis.u.m_array_double->multiply(value);
1779 return true;
1780 }
1781 case value::DOUBLE:
1782 if(aV.u.m_double==0) {
1783 aError = value::error_div_zero();
1784 aThis.set_none();
1785 return false;
1786 } else {
1787 aThis.u.m_array_double->multiply(1./aV.u.m_double);
1788 return true;
1789 }
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();
1793 aThis.set_none();
1794 return false;
1795 }
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
1803 stdv[index] = 0;
1804 has_div_zero = true;
1805 } else {
1806 stdv[index] /= stdv2[index];
1807 }
1808 }
1809 if(has_div_zero) {
1810 aError = value::error_div_zero();
1811
1812
1813
1814 return true;
1815 }
1816
1817 return true;}
1818
1819 case value::NONE:
1820 case value::STRING:
1821 case value::VOID_STAR:
1822 case value::BOOL:
1823 case value::SHORT:
1824 case value::FLOAT:
1825
1826
1827 case value::INT64:
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
1834
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
1843 case value::ARRAY_BOOL:
1844 case value::ARRAY_STRING:
1845 break;
1846 }
1847 break;
1848
1849 case value::NONE:
1850 case value::STRING:
1851 case value::VOID_STAR:
1852 case value::BOOL:
1853 case value::SHORT:
1854
1855
1856 case value::INT64:
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
1863
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
1872 case value::ARRAY_BOOL:
1873 case value::ARRAY_STRING:
1874 break;
1875 }
1876 aError = std::string("Value::divide :")
1877 + " can't apply on type " + value::stype(oType)
1878 + " and type " + aV.stype();
1879 aThis.set_none();
1880 return false;
1881 }
1882
1883
1884
1885
1886
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) {
1890 case value::INT:
1891 switch(aV.m_type) {
1892 case value::INT:
1893 aThis.set((bool)(aThis.u.m_int>aV.u.m_int?true:false));
1894 return true;
1895 case value::FLOAT:
1896 aThis.set((bool)(aThis.u.m_int>aV.u.m_float?true:false));
1897 return true;
1898 case value::DOUBLE:
1899 aThis.set((bool)(aThis.u.m_int>aV.u.m_double?true:false));
1900 return true;
1901 case value::UNSIGNED_SHORT :
1902 aThis.set((bool)(aThis.u.m_int>(int)aV.u.m_unsigned_short?true:false));
1903 return true;
1904 case value::UNSIGNED_INT:
1905 aThis.set((bool)(aThis.u.m_int>(int)aV.u.m_unsigned_int?true:false));
1906 return true;
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]) {
1912 aThis.set(false);
1913 return true;
1914 }
1915 }
1916 aThis.set(true);
1917 return true;
1918 }
1919 case value::NONE:
1920 case value::VOID_STAR:
1921 case value::BOOL:
1922 case value::SHORT:
1923 case value::INT64:
1924
1925
1926 case value::UNSIGNED_INT64 :
1927 case value::DOUBLE_STAR:
1928 case value::FLOAT_STAR:
1929 case value::INT_STAR:
1930 case value::STRING:
1931
1932
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
1941 case value::ARRAY_BOOL:
1942 case value::ARRAY_STRING:
1943 break;
1944 }
1945 break;
1946 case value::DOUBLE:
1947 switch(aV.m_type) {
1948 case value::DOUBLE:
1949 aThis.set((bool)(aThis.u.m_double>aV.u.m_double?true:false));
1950 return true;
1951 case value::FLOAT:
1952 aThis.set((bool)(aThis.u.m_double>aV.u.m_float?true:false));
1953 return true;
1954 case value::INT:
1955 aThis.set((bool)(aThis.u.m_double>aV.u.m_int?true:false));
1956 return true;
1957 case value::UNSIGNED_SHORT :
1958 aThis.set((bool)(aThis.u.m_double>aV.u.m_unsigned_short?true:false));
1959 return true;
1960 case value::UNSIGNED_INT:
1961 aThis.set((bool)(aThis.u.m_double>aV.u.m_unsigned_int?true:false));
1962 return true;
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]) {
1968 aThis.set(false);
1969 return true;
1970 }
1971 }
1972 aThis.set(true);
1973 return true;
1974 }
1975 case value::NONE:
1976 case value::VOID_STAR:
1977 case value::BOOL:
1978 case value::SHORT:
1979 case value::INT64:
1980
1981
1982 case value::UNSIGNED_INT64 :
1983 case value::DOUBLE_STAR:
1984 case value::FLOAT_STAR:
1985 case value::INT_STAR:
1986 case value::STRING:
1987
1988
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
1997 case value::ARRAY_BOOL:
1998 case value::ARRAY_STRING:
1999 break;
2000 }
2001 break;
2002 case value::FLOAT:
2003 switch(aV.m_type) {
2004 case value::DOUBLE:
2005 aThis.set((bool)(aThis.u.m_float>aV.u.m_double?true:false));
2006 return true;
2007 case value::FLOAT:
2008 aThis.set((bool)(aThis.u.m_float>aV.u.m_float?true:false));
2009 return true;
2010 case value::INT:
2011 aThis.set((bool)(aThis.u.m_float>aV.u.m_int?true:false));
2012 return true;
2013 case value::UNSIGNED_SHORT :
2014 aThis.set((bool)(aThis.u.m_float>aV.u.m_unsigned_short?true:false));
2015 return true;
2016 case value::UNSIGNED_INT:
2017 aThis.set((bool)(aThis.u.m_float>aV.u.m_unsigned_int?true:false));
2018 return true;
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]) {
2024 aThis.set(false);
2025 return true;
2026 }
2027 }
2028 aThis.set(true);
2029 return true;
2030 }
2031 case value::NONE:
2032 case value::VOID_STAR:
2033 case value::BOOL:
2034 case value::SHORT:
2035 case value::INT64:
2036
2037
2038 case value::UNSIGNED_INT64 :
2039 case value::DOUBLE_STAR:
2040 case value::FLOAT_STAR:
2041 case value::INT_STAR:
2042 case value::STRING:
2043
2044
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
2053 case value::ARRAY_BOOL:
2054 case value::ARRAY_STRING:
2055 break;
2056 }
2057 break;
2058 case value::VOID_STAR:
2059 switch(aV.m_type) {
2060 case value::VOID_STAR:
2061 aThis.set((bool)(aThis.u.m_void_star>aV.u.m_void_star?true:false));
2062 return true;
2063 case value::NONE:
2064 case value::INT:
2065 case value::DOUBLE:
2066 case value::BOOL:
2067 case value::SHORT:
2068 case value::INT64:
2069 case value::FLOAT:
2070
2071
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:
2078 case value::STRING:
2079
2080
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:
2091 break;
2092 }
2093 break;
2094 case value::UNSIGNED_INT:
2095 switch(aV.m_type) {
2096 case value::UNSIGNED_INT:
2097 aThis.set((bool)(aThis.u.m_unsigned_int >aV.u.m_unsigned_int ?true:false));
2098 return true;
2099 case value::INT:
2100 aThis.set((bool)((int)aThis.u.m_unsigned_int >aV.u.m_int?true:false));
2101 return true;
2102 case value::DOUBLE:
2103 aThis.set((bool)(double(aThis.u.m_unsigned_int)>aV.u.m_double?true:false));
2104 return true;
2105 case value::FLOAT:
2106 aThis.set((bool)(float(aThis.u.m_unsigned_int)>aV.u.m_float?true:false));
2107 return true;
2108 case value::NONE:
2109 case value::VOID_STAR:
2110 case value::BOOL:
2111 case value::SHORT:
2112 case value::INT64:
2113
2114
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:
2120 case value::STRING:
2121
2122
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:
2133 break;
2134 }
2135 break;
2136 case value::ARRAY_DOUBLE:
2137 switch(aV.m_type) {
2138 case value::INT:{
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) {
2143 aThis.set(false);
2144 return true;
2145 }
2146 }
2147 aThis.set(true);
2148 return true;
2149 }
2150 case value::FLOAT:{
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) {
2155 aThis.set(false);
2156 return true;
2157 }
2158 }
2159 aThis.set(true);
2160 return true;
2161 }
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) {
2167 aThis.set(false);
2168 return true;
2169 }
2170 }
2171 aThis.set(true);
2172 return true;
2173 }
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 ) {
2179 aThis.set(false);
2180 return true;
2181 }
2182 }
2183 aThis.set(true);
2184 return true;
2185 }
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]) {
2193 aThis.set(false);
2194 return true;
2195 }
2196 }
2197 aThis.set(true);
2198 return true;
2199 }
2200 case value::NONE:
2201 case value::VOID_STAR:
2202 case value::BOOL:
2203 case value::SHORT:
2204 case value::INT64:
2205
2206
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:
2212 case value::STRING:
2213
2214
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
2223 case value::ARRAY_BOOL:
2224 case value::ARRAY_STRING:
2225 break;
2226 }
2227 break;
2228 case value::NONE:
2229 case value::BOOL:
2230 case value::SHORT:
2231
2232
2233 case value::STRING:
2234 case value::INT64:
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
2241
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
2250 case value::ARRAY_BOOL:
2251 case value::ARRAY_STRING:
2252 break;
2253 }
2254 aError = std::string("Value::if_gt() :")
2255 + " can't compare type " + value::stype(oType)
2256 + " with type " + aV.stype();
2257 aThis.set_none();
2258 return false;
2259 }
2260
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) {
2264 case value::INT:
2265 switch(aV.m_type) {
2266 case value::INT:
2267 aThis.set((bool)(aThis.u.m_int==aV.u.m_int?true:false));
2268 return true;
2269 case value::DOUBLE:
2270 aThis.set((bool)(aThis.u.m_int==aV.u.m_double?true:false));
2271 return true;
2272 case value::FLOAT:
2273 aThis.set((bool)(aThis.u.m_int==aV.u.m_float?true:false));
2274 return true;
2275 case value::UNSIGNED_SHORT :
2276 aThis.set((bool)(aThis.u.m_int==(int)aV.u.m_unsigned_short?true:false));
2277 return true;
2278 case value::UNSIGNED_INT:
2279 aThis.set((bool)(aThis.u.m_int==(int)aV.u.m_unsigned_int ?true:false));
2280 return true;
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]) {
2286 aThis.set(false);
2287 return true;
2288 }
2289 }
2290 aThis.set(true);
2291 return true;
2292 }
2293
2294 case value::NONE:
2295 case value::STRING:
2296 case value::VOID_STAR:
2297 case value::BOOL:
2298 case value::SHORT:
2299 case value::INT64:
2300
2301
2302 case value::UNSIGNED_INT64 :
2303 case value::DOUBLE_STAR:
2304 case value::FLOAT_STAR:
2305 case value::INT_STAR:
2306
2307
2308
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
2317 case value::ARRAY_BOOL:
2318 case value::ARRAY_STRING:
2319 break;
2320 }
2321 break;
2322 case value::FLOAT:
2323 switch(aV.m_type) {
2324 case value::FLOAT:
2325 aThis.set((bool)(aThis.u.m_float==aV.u.m_float?true:false));
2326 return true;
2327 case value::DOUBLE:
2328 aThis.set((bool)(aThis.u.m_float==aV.u.m_double?true:false));
2329 return true;
2330 case value::INT:
2331 aThis.set((bool)(aThis.u.m_float==aV.u.m_int?true:false));
2332 return true;
2333 case value::UNSIGNED_SHORT :
2334 aThis.set((bool)(aThis.u.m_float==aV.u.m_unsigned_short?true:false));
2335 return true;
2336 case value::UNSIGNED_INT:
2337 aThis.set((bool)(aThis.u.m_float==aV.u.m_unsigned_int?true:false));
2338 return true;
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]) {
2344 aThis.set(false);
2345 return true;
2346 }
2347 }
2348 aThis.set(true);
2349 return true;
2350 }
2351 case value::NONE:
2352 case value::STRING:
2353 case value::VOID_STAR:
2354 case value::BOOL:
2355 case value::SHORT:
2356
2357
2358 case value::INT64:
2359 case value::UNSIGNED_INT64 :
2360 case value::DOUBLE_STAR:
2361 case value::FLOAT_STAR:
2362 case value::INT_STAR:
2363
2364
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
2373 case value::ARRAY_BOOL:
2374 case value::ARRAY_STRING:
2375 break;
2376 }
2377 break;
2378 case value::DOUBLE:
2379 switch(aV.m_type) {
2380 case value::DOUBLE:
2381 aThis.set((bool)(aThis.u.m_double==aV.u.m_double?true:false));
2382 return true;
2383 case value::FLOAT:
2384 aThis.set((bool)(aThis.u.m_double==aV.u.m_float?true:false));
2385 return true;
2386 case value::INT:
2387 aThis.set((bool)(aThis.u.m_double==aV.u.m_int?true:false));
2388 return true;
2389 case value::UNSIGNED_SHORT :
2390 aThis.set((bool)(aThis.u.m_double==aV.u.m_unsigned_short?true:false));
2391 return true;
2392 case value::UNSIGNED_INT:
2393 aThis.set((bool)(aThis.u.m_double==aV.u.m_unsigned_int ?true:false));
2394 return true;
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]) {
2400 aThis.set(false);
2401 return true;
2402 }
2403 }
2404 aThis.set(true);
2405 return true;
2406 }
2407 case value::NONE:
2408 case value::STRING:
2409 case value::VOID_STAR:
2410 case value::BOOL:
2411 case value::SHORT:
2412
2413
2414 case value::INT64:
2415 case value::UNSIGNED_INT64 :
2416 case value::DOUBLE_STAR:
2417 case value::FLOAT_STAR:
2418 case value::INT_STAR:
2419
2420
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
2429 case value::ARRAY_BOOL:
2430 case value::ARRAY_STRING:
2431 break;
2432 }
2433 break;
2434 case value::STRING:
2435 switch(aV.m_type) {
2436 case value::STRING:
2437 aThis.set((bool)((*aThis.u.m_string)==(*aV.u.m_string)?true:false));
2438 return true;
2439 case value::INT:
2440 {int v;
2441 if(!to<int>(*aThis.u.m_string,v)) break;
2442 aThis.set((bool)(v==aV.u.m_int?true:false));
2443 return true;}
2444 case value::FLOAT:
2445 {float v;
2446 if(!to<float>(*aThis.u.m_string,v)) break;
2447 aThis.set((bool)(v==aV.u.m_float?true:false));
2448 return true;}
2449 case value::DOUBLE:
2450 {double v;
2451 if(!to<double>(*aThis.u.m_string,v)) break;
2452 aThis.set((bool)(v==aV.u.m_double?true:false));
2453 return true;}
2454 case value::UNSIGNED_INT:
2455 {typedef unsigned int uint_t;
2456 uint_t v;
2457 if(!to<uint_t>(*aThis.u.m_string,v)) break;
2458 aThis.set((bool)(v==aV.u.m_unsigned_int ?true:false));
2459 return true;}
2460 case value::BOOL:
2461 {bool v;
2462 if(!to(*aThis.u.m_string,v)) break;
2463 aThis.set((bool)(v==aV.u.m_bool?true:false));
2464 return true;}
2465 case value::NONE:
2466 case value::VOID_STAR:
2467 case value::SHORT:
2468
2469
2470 case value::INT64:
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
2477
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:
2488 break;
2489 }
2490 break;
2491 case value::VOID_STAR:
2492 switch(aV.m_type) {
2493 case value::VOID_STAR:
2494 aThis.set((bool)(aThis.u.m_void_star==aV.u.m_void_star?true:false));
2495 return true;
2496 case value::NONE:
2497 case value::INT:
2498 case value::DOUBLE:
2499 case value::BOOL:
2500 case value::SHORT:
2501 case value::INT64:
2502 case value::FLOAT:
2503
2504
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:
2511 case value::STRING:
2512
2513
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:
2524 break;
2525 }
2526 break;
2527 case value::UNSIGNED_INT:
2528 switch(aV.m_type) {
2529 case value::UNSIGNED_INT:
2530 aThis.set((bool)(aThis.u.m_unsigned_int ==aV.u.m_unsigned_int ?true:false));
2531 return true;
2532 case value::INT:
2533 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_int?true:false));
2534 return true;
2535 case value::FLOAT:
2536 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_float?true:false));
2537 return true;
2538 case value::DOUBLE:
2539 aThis.set((bool)((int)aThis.u.m_unsigned_int ==aV.u.m_double?true:false));
2540 return true;
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]) {
2546 aThis.set(false);
2547 return true;
2548 }
2549 }
2550 aThis.set(true);
2551 return true;
2552 }
2553 case value::NONE:
2554 case value::BOOL:
2555 case value::VOID_STAR:
2556 case value::SHORT:
2557 case value::INT64:
2558
2559
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:
2565 case value::STRING:
2566
2567
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
2576 case value::ARRAY_BOOL:
2577 case value::ARRAY_STRING:
2578 break;
2579 }
2580 break;
2581 case value::BOOL:
2582 switch(aV.m_type) {
2583 case value::BOOL:
2584 aThis.u.m_bool = ((aThis.u.m_bool==aV.u.m_bool)?true:false);
2585 return true;
2586 case value::NONE:
2587 case value::INT:
2588 case value::DOUBLE:
2589 case value::VOID_STAR:
2590 case value::SHORT:
2591 case value::INT64:
2592 case value::FLOAT:
2593
2594
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:
2601 case value::STRING:
2602
2603
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:
2614 break;
2615 }
2616 break;
2617 case value::ARRAY_DOUBLE:
2618 switch(aV.m_type) {
2619 case value::INT:{
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) {
2624 aThis.set(false);
2625 return true;
2626 }
2627 }
2628 aThis.set(true);
2629 return true;
2630 }
2631 case value::FLOAT:{
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) {
2636 aThis.set(false);
2637 return true;
2638 }
2639 }
2640 aThis.set(true);
2641 return true;
2642 }
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) {
2648 aThis.set(false);
2649 return true;
2650 }
2651 }
2652 aThis.set(true);
2653 return true;
2654 }
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 ) {
2660 aThis.set(false);
2661 return true;
2662 }
2663 }
2664 aThis.set(true);
2665 return true;
2666 }
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()) {
2671 aThis.set(false);
2672 return true;
2673 }
2674 size_t number = stdv.size();
2675 for(size_t index=0;index<number;index++) {
2676 if(stdv[index]!=stdv2[index]) {
2677 aThis.set(false);
2678 return true;
2679 }
2680 }
2681 aThis.set(true);
2682 return true;
2683 }
2684 case value::NONE:
2685 case value::VOID_STAR:
2686 case value::BOOL:
2687 case value::SHORT:
2688
2689
2690 case value::STRING:
2691 case value::INT64:
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
2698
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
2707 case value::ARRAY_BOOL:
2708 case value::ARRAY_STRING:
2709 break;
2710 }
2711 break;
2712 case value::NONE:
2713 case value::SHORT:
2714 case value::INT64:
2715
2716
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
2723
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
2732 case value::ARRAY_BOOL:
2733 case value::ARRAY_STRING:
2734 break;
2735 }
2736 aError = std::string("Value::if_eq() :")
2737 + " can't compare type " + value::stype(oType)
2738 + " with type " + aV.stype();
2739 aThis.set_none();
2740 return false;
2741 }
2742
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) {
2746 case value::BOOL:
2747 switch(aV.m_type) {
2748 case value::BOOL:
2749 aThis.u.m_bool = ((aThis.u.m_bool && aV.u.m_bool)?true:false);
2750 return true;
2751 case value::INT:
2752 case value::NONE:
2753 case value::DOUBLE:
2754 case value::STRING:
2755 case value::VOID_STAR:
2756 case value::SHORT:
2757 case value::INT64:
2758 case value::FLOAT:
2759
2760
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
2768
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:
2779 break;
2780 }
2781 break;
2782 case value::NONE:
2783 case value::INT:
2784 case value::DOUBLE:
2785 case value::VOID_STAR:
2786 case value::SHORT:
2787 case value::INT64:
2788 case value::FLOAT:
2789
2790
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:
2797 case value::STRING:
2798
2799
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:
2810 break;
2811 }
2812 aError = std::string("Value::if_and :")
2813 + " can't apply on type " + value::stype(oType)
2814 + " and type " + aV.stype();
2815 aThis.set_none();
2816 return false;
2817 }
2818
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) {
2822 case value::BOOL:
2823 switch(aV.m_type) {
2824 case value::BOOL:
2825 aThis.u.m_bool = ((aThis.u.m_bool || aV.u.m_bool)?true:false);
2826 return true;
2827 case value::INT:
2828 case value::NONE:
2829 case value::DOUBLE:
2830 case value::STRING:
2831 case value::VOID_STAR:
2832 case value::SHORT:
2833 case value::INT64:
2834 case value::FLOAT:
2835
2836
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
2844
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:
2855 break;
2856 }
2857 break;
2858 case value::NONE:
2859 case value::INT:
2860 case value::DOUBLE:
2861 case value::VOID_STAR:
2862 case value::SHORT:
2863 case value::INT64:
2864 case value::FLOAT:
2865
2866
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:
2873 case value::STRING:
2874
2875
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:
2886 break;
2887 }
2888 aError = std::string("Value::if_or :")
2889 + " can't apply on type " + value::stype(oType)
2890 + " and type " + aV.stype();
2891 aThis.set_none();
2892 return false;
2893 }
2894
2895 inline bool value::to_double(const value& aThis,double& aValue){
2896 switch(aThis.m_type) {
2897 case value::INT:
2898 aValue = aThis.u.m_int;
2899 return true;
2900 case value::DOUBLE:
2901 aValue = aThis.u.m_double;
2902 return true;
2903 case value::UNSIGNED_SHORT:
2904 aValue = aThis.u.m_unsigned_short;
2905 return true;
2906 case value::UNSIGNED_INT:
2907 aValue = aThis.u.m_unsigned_int;
2908 return true;
2909 case value::SHORT:
2910 aValue = aThis.u.m_short;
2911 return true;
2912 case value::INT64:
2913 aValue = (double)aThis.u.m_int64;
2914 return true;
2915 case value::UNSIGNED_INT64:
2916 aValue = (double)aThis.u.m_unsigned_int64;
2917 return true;
2918 case value::FLOAT:
2919 aValue = aThis.u.m_float;
2920 return true;
2921
2922
2923
2924
2925
2926
2927 case value::BOOL:
2928 aValue = aThis.u.m_bool?1:0;
2929 return true;
2930 case value::NONE:
2931 case value::STRING:
2932 case value::VOID_STAR:
2933 case value::DOUBLE_STAR:
2934 case value::FLOAT_STAR:
2935 case value::INT_STAR:
2936
2937
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:
2948 break;
2949 }
2950 aValue = 0;
2951 return false;
2952 }
2953
2954 inline bool value::cxx_type(const value& aThis,std::string& aValue){
2955 switch(aThis.m_type) {
2956 case value::INT:
2957 aValue = "int";
2958 return true;
2959 case value::DOUBLE:
2960 aValue = "double";
2961 return true;
2962 case value::STRING:
2963 aValue = "std::string";
2964 return true;
2965 case value::BOOL:
2966 aValue = "bool";
2967 return true;
2968 case value::SHORT:
2969 aValue = "short";
2970 return true;
2971 case value::FLOAT:
2972 aValue = "float";
2973 return true;
2974
2975
2976
2977
2978
2979
2980 case value::UNSIGNED_SHORT:
2981 aValue = "unsigned short";
2982 return true;
2983 case value::UNSIGNED_INT:
2984 aValue = "unsigned int";
2985 return true;
2986 case value::VOID_STAR:
2987 aValue = "void*";
2988 return true;
2989 case value::DOUBLE_STAR:
2990 aValue = "double*";
2991 return true;
2992 case value::FLOAT_STAR:
2993 aValue = "float*";
2994 return true;
2995 case value::INT_STAR:
2996 aValue = "int*";
2997 return true;
2998 case value::NONE:
2999 case value::INT64:
3000 case value::UNSIGNED_INT64:
3001
3002
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:
3013 aValue = "";
3014 return false;
3015 }
3016 return false;
3017 }
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197 inline std::string value::to_string(const value& aThis){
3198 std::string _s;
3199 switch(aThis.m_type) {
3200 case value::NONE:
3201 sprintf(_s,5,"(nil)");
3202 return _s;
3203 case value::INT:
3204 sprintf(_s,16,"%d",aThis.u.m_int);
3205 return _s;
3206 case value::DOUBLE:
3207 sprintf(_s,16,"%g",aThis.u.m_double);
3208 return _s;
3209 case value::VOID_STAR:
3210 sprintf(_s,32,upointer_format_x(),(upointer)aThis.u.m_void_star);
3211 return _s;
3212 case value::UNSIGNED_SHORT:
3213 sprintf(_s,16,"%u",aThis.u.m_unsigned_short);
3214 return _s;
3215 case value::UNSIGNED_INT:
3216 sprintf(_s,16,"%u",aThis.u.m_unsigned_int);
3217 return _s;
3218 case value::BOOL:
3219 sprintf(_s,5,"%s",aThis.u.m_bool?"true":"false");
3220 return _s;
3221 case value::SHORT:
3222 sprintf(_s,16,"%d",aThis.u.m_short);
3223 return _s;
3224 case value::INT64:{
3225 sprintf(_s,16,int64_format(),aThis.u.m_int64);
3226 }return _s;
3227 case value::UNSIGNED_INT64:{
3228 sprintf(_s,16,int64_format(),aThis.u.m_unsigned_int64);
3229 }return _s;
3230 case value::FLOAT:
3231 sprintf(_s,16,"%g",aThis.u.m_float);
3232 return _s;
3233
3234
3235
3236
3237
3238
3239 case value::DOUBLE_STAR:
3240 sprintf(_s,32,upointer_format_x(),(upointer)aThis.u.m_double_star);
3241 return _s;
3242 case value::FLOAT_STAR:
3243 sprintf(_s,32,upointer_format_x(),(upointer)aThis.u.m_float_star);
3244 return _s;
3245 case value::INT_STAR:
3246 sprintf(_s,32,upointer_format_x(),(upointer)aThis.u.m_int_star);
3247 return _s;
3248 case value::STRING:
3249 return *aThis.u.m_string;
3250
3251
3252
3253
3254
3255 case value::ARRAY_UNSIGNED_SHORT:
3256 if(!nums2s<unsigned short>(aThis.u.m_array_unsigned_short->vector(),_s)) {}
3257 return _s;
3258 case value::ARRAY_SHORT:
3259 if(!nums2s<short>(aThis.u.m_array_short->vector(),_s)) {}
3260 return _s;
3261
3262 case value::ARRAY_UNSIGNED_INT:
3263 if(!nums2s<unsigned int>(aThis.u.m_array_unsigned_int->vector(),_s)) {}
3264 return _s;
3265 case value::ARRAY_INT:
3266 if(!nums2s<int>(aThis.u.m_array_int->vector(),_s)) {}
3267 return _s;
3268
3269 case value::ARRAY_UNSIGNED_INT64:
3270 if(!nums2s<uint64>(aThis.u.m_array_unsigned_int64->vector(),_s)) {}
3271 return _s;
3272 case value::ARRAY_INT64:
3273 if(!nums2s<int64>(aThis.u.m_array_int64->vector(),_s)) {}
3274 return _s;
3275
3276 case value::ARRAY_FLOAT:
3277 if(!nums2s<float>(aThis.u.m_array_float->vector(),_s)) {}
3278 return _s;
3279 case value::ARRAY_DOUBLE:
3280 if(!nums2s<double>(aThis.u.m_array_double->vector(),_s)) {}
3281 return _s;
3282 case value::ARRAY_BOOL:
3283 b2s(aThis.u.m_array_bool->vector(),_s);
3284 return _s;
3285 case value::ARRAY_STRING:
3286 if(!nums2s<std::string>(aThis.u.m_array_string->vector(),_s)) {}
3287 return _s;
3288 default:
3289 return "unknown";
3290 }
3291 }
3292
3293 }