| 700 | } |
| 701 | |
| 702 | int32_t Value::toInt() const noexcept { |
| 703 | switch (getType()) { |
| 704 | case ValueType::Int: |
| 705 | return _data.i; |
| 706 | case ValueType::Double: |
| 707 | return static_cast<int32_t>(toDouble()); |
| 708 | case ValueType::Long: |
| 709 | return static_cast<int32_t>(_data.l); |
| 710 | case ValueType::InternedString: |
| 711 | case ValueType::StaticString: |
| 712 | return atoi(toStringBox().getCStr()); // NOLINT(cert-err34-c) |
| 713 | case ValueType::Bool: |
| 714 | return static_cast<int32_t>(_data.i); |
| 715 | default: |
| 716 | return 0; |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | int64_t Value::toLong() const noexcept { |
| 721 | switch (getType()) { |
no test coverage detected