| 718 | } |
| 719 | |
| 720 | int64_t Value::toLong() const noexcept { |
| 721 | switch (getType()) { |
| 722 | case ValueType::Long: |
| 723 | return _data.l; |
| 724 | case ValueType::Int: |
| 725 | return static_cast<int64_t>(_data.i); |
| 726 | case ValueType::Double: |
| 727 | return static_cast<int64_t>(toDouble()); |
| 728 | case ValueType::InternedString: |
| 729 | case ValueType::StaticString: |
| 730 | return atoll(toStringBox().getCStr()); // NOLINT(cert-err34-c) |
| 731 | case ValueType::Bool: |
| 732 | return static_cast<int64_t>(_data.b); |
| 733 | default: |
| 734 | return 0; |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | ValueType Value::getType() const noexcept { |
| 739 | return _type; |