| 745 | } |
| 746 | |
| 747 | Value::UInt |
| 748 | Value::asUInt() const |
| 749 | { |
| 750 | switch ( type_ ) |
| 751 | { |
| 752 | case nullValue: |
| 753 | return 0; |
| 754 | case intValue: |
| 755 | //JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" ); |
| 756 | JSON_ASSERT( value_.int_ >= 0 ); |
| 757 | return value_.int_; |
| 758 | case uintValue: |
| 759 | return value_.uint_; |
| 760 | case realValue: |
| 761 | //JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt, "Real out of unsigned integer range" ); |
| 762 | JSON_ASSERT( value_.real_ >= 0 && value_.real_ <= maxUInt ); |
| 763 | return UInt( value_.real_ ); |
| 764 | case booleanValue: |
| 765 | return value_.bool_ ? 1 : 0; |
| 766 | case stringValue: |
| 767 | case arrayValue: |
| 768 | case objectValue: |
| 769 | //JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" ); |
| 770 | JSON_ASSERT( false ); |
| 771 | default: |
| 772 | JSON_ASSERT_UNREACHABLE; |
| 773 | } |
| 774 | return 0; // unreachable; |
| 775 | } |
| 776 | |
| 777 | double |
| 778 | Value::asDouble() const |