| 3295 | } |
| 3296 | |
| 3297 | String Value::asString() const |
| 3298 | { |
| 3299 | switch (type()) |
| 3300 | { |
| 3301 | case nullValue: |
| 3302 | return ""; |
| 3303 | case stringValue: |
| 3304 | { |
| 3305 | if (value_.string_ == nullptr) |
| 3306 | return ""; |
| 3307 | unsigned this_len; |
| 3308 | char const *this_str; |
| 3309 | decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len, &this_str); |
| 3310 | return String(this_str, this_len); |
| 3311 | } |
| 3312 | case booleanValue: |
| 3313 | return value_.bool_ ? "true" : "false"; |
| 3314 | case intValue: |
| 3315 | return valueToString(value_.int_); |
| 3316 | case uintValue: |
| 3317 | return valueToString(value_.uint_); |
| 3318 | case realValue: |
| 3319 | return valueToString(value_.real_); |
| 3320 | default: |
| 3321 | JSON_FAIL_MESSAGE("Type is not convertible to string"); |
| 3322 | } |
| 3323 | } |
| 3324 | |
| 3325 | Value::Int Value::asInt() const |
| 3326 | { |