| 634 | #endif |
| 635 | |
| 636 | Value::Int Value::asInt() const { |
| 637 | switch (type_) { |
| 638 | case intValue: |
| 639 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 640 | return Int(value_.int_); |
| 641 | case uintValue: |
| 642 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 643 | return Int(value_.uint_); |
| 644 | case realValue: |
| 645 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 646 | "double out of Int range"); |
| 647 | return Int(value_.real_); |
| 648 | case nullValue: |
| 649 | return 0; |
| 650 | case booleanValue: |
| 651 | return value_.bool_ ? 1 : 0; |
| 652 | default: |
| 653 | break; |
| 654 | } |
| 655 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 656 | } |
| 657 | |
| 658 | Value::UInt Value::asUInt() const { |
| 659 | switch (type_) { |
no test coverage detected