| 3090 | } |
| 3091 | |
| 3092 | Value::Int Value::asInt() const { |
| 3093 | switch (type()) { |
| 3094 | case intValue: |
| 3095 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 3096 | return Int(value_.int_); |
| 3097 | case uintValue: |
| 3098 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 3099 | return Int(value_.uint_); |
| 3100 | case realValue: |
| 3101 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 3102 | "double out of Int range"); |
| 3103 | return Int(value_.real_); |
| 3104 | case nullValue: |
| 3105 | return 0; |
| 3106 | case booleanValue: |
| 3107 | return value_.bool_ ? 1 : 0; |
| 3108 | default: |
| 3109 | break; |
| 3110 | } |
| 3111 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 3112 | } |
| 3113 | |
| 3114 | Value::UInt Value::asUInt() const { |
| 3115 | switch (type()) { |
no test coverage detected