| 2792 | #endif |
| 2793 | |
| 2794 | Value::Int Value::asInt() const { |
| 2795 | switch (type_) { |
| 2796 | case intValue: |
| 2797 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 2798 | return Int(value_.int_); |
| 2799 | case uintValue: |
| 2800 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 2801 | return Int(value_.uint_); |
| 2802 | case realValue: |
| 2803 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 2804 | "double out of Int range"); |
| 2805 | return Int(value_.real_); |
| 2806 | case nullValue: |
| 2807 | return 0; |
| 2808 | case booleanValue: |
| 2809 | return value_.bool_ ? 1 : 0; |
| 2810 | default: |
| 2811 | break; |
| 2812 | } |
| 2813 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 2814 | } |
| 2815 | |
| 2816 | Value::UInt Value::asUInt() const { |
| 2817 | switch (type_) { |
no test coverage detected