| 565 | } |
| 566 | |
| 567 | std::string anyToString(const App::any &value) { |
| 568 | if (is_type(value, typeid(bool))) { |
| 569 | return (cast<bool>(value) ? QObject::tr("True") : QObject::tr("False")).toStdString(); |
| 570 | } |
| 571 | else if (is_type(value, typeid(int))) { |
| 572 | return std::to_string(cast<int>(value)); |
| 573 | } |
| 574 | else if (is_type(value, typeid(long))) { |
| 575 | return std::to_string(cast<long>(value)); |
| 576 | } |
| 577 | else if (is_type(value, typeid(float)) || is_type(value, typeid(double))) { |
| 578 | Quantity q(is_type(value, typeid(float)) ? cast<float>(value) : cast<double>(value)); |
| 579 | return q.getUserString(); |
| 580 | } |
| 581 | else if (is_type(value, typeid(Quantity))) { |
| 582 | const Quantity& q = cast<Quantity>(value); |
| 583 | return q.getUserString(); |
| 584 | } |
| 585 | else if (is_type(value, typeid(const char*))) { |
| 586 | const char* p = cast<const char*>(value); |
| 587 | return p ? std::string(p) : QObject::tr("Null").toStdString(); |
| 588 | } |
| 589 | else if (is_type(value, typeid(std::string))) { |
| 590 | return cast<std::string>(value); |
| 591 | } |
| 592 | else { |
| 593 | Base::PyGILStateLocker lock; |
| 594 | return pyObjectFromAny(value).as_string(); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | bool isAnyEqual(const App::any &v1, const App::any &v2) { |
| 599 | if(v1.empty()) |
no test coverage detected