| 3024 | } |
| 3025 | |
| 3026 | String Value::asString() const { |
| 3027 | switch (type()) { |
| 3028 | case nullValue: |
| 3029 | return ""; |
| 3030 | case stringValue: { |
| 3031 | if (value_.string_ == nullptr) |
| 3032 | return ""; |
| 3033 | unsigned this_len; |
| 3034 | char const *this_str; |
| 3035 | decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len, |
| 3036 | &this_str); |
| 3037 | return String(this_str, this_len); |
| 3038 | } |
| 3039 | case booleanValue: |
| 3040 | return value_.bool_ ? "true" : "false"; |
| 3041 | case intValue: |
| 3042 | return valueToString(value_.int_); |
| 3043 | case uintValue: |
| 3044 | return valueToString(value_.uint_); |
| 3045 | case realValue: |
| 3046 | return valueToString(value_.real_); |
| 3047 | default: |
| 3048 | JSON_FAIL_MESSAGE("Type is not convertible to string"); |
| 3049 | } |
| 3050 | } |
| 3051 | |
| 3052 | #ifdef JSON_USE_CPPTL |
| 3053 | CppTL::ConstString Value::asConstString() const { |