| 3064 | } |
| 3065 | |
| 3066 | String Value::asString() const { |
| 3067 | switch (type()) { |
| 3068 | case nullValue: |
| 3069 | return ""; |
| 3070 | case stringValue: { |
| 3071 | if (value_.string_ == nullptr) |
| 3072 | return ""; |
| 3073 | unsigned this_len; |
| 3074 | char const* this_str; |
| 3075 | decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len, |
| 3076 | &this_str); |
| 3077 | return String(this_str, this_len); |
| 3078 | } |
| 3079 | case booleanValue: |
| 3080 | return value_.bool_ ? "true" : "false"; |
| 3081 | case intValue: |
| 3082 | return valueToString(value_.int_); |
| 3083 | case uintValue: |
| 3084 | return valueToString(value_.uint_); |
| 3085 | case realValue: |
| 3086 | return valueToString(value_.real_); |
| 3087 | default: |
| 3088 | JSON_FAIL_MESSAGE("Type is not convertible to string"); |
| 3089 | } |
| 3090 | } |
| 3091 | |
| 3092 | Value::Int Value::asInt() const { |
| 3093 | switch (type()) { |
no test coverage detected