| 3164 | } |
| 3165 | |
| 3166 | JSONCPP_STRING Value::asString() const { |
| 3167 | switch (type_) { |
| 3168 | case nullValue: |
| 3169 | return ""; |
| 3170 | case stringValue: |
| 3171 | { |
| 3172 | if (value_.string_ == 0) return ""; |
| 3173 | unsigned this_len; |
| 3174 | char const* this_str; |
| 3175 | decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); |
| 3176 | return JSONCPP_STRING(this_str, this_len); |
| 3177 | } |
| 3178 | case booleanValue: |
| 3179 | return value_.bool_ ? "true" : "false"; |
| 3180 | case intValue: |
| 3181 | return valueToString(value_.int_); |
| 3182 | case uintValue: |
| 3183 | return valueToString(value_.uint_); |
| 3184 | case realValue: |
| 3185 | return valueToString(value_.real_); |
| 3186 | default: |
| 3187 | JSON_FAIL_MESSAGE("Type is not convertible to string"); |
| 3188 | } |
| 3189 | } |
| 3190 | |
| 3191 | #ifdef JSON_USE_CPPTL |
| 3192 | CppTL::ConstString Value::asConstString() const { |