| 3059 | } |
| 3060 | |
| 3061 | std::string Value::asString() const { |
| 3062 | switch (type_) { |
| 3063 | case nullValue: |
| 3064 | return ""; |
| 3065 | case stringValue: |
| 3066 | { |
| 3067 | if (value_.string_ == 0) return ""; |
| 3068 | unsigned this_len; |
| 3069 | char const* this_str; |
| 3070 | decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); |
| 3071 | return std::string(this_str, this_len); |
| 3072 | } |
| 3073 | case booleanValue: |
| 3074 | return value_.bool_ ? "true" : "false"; |
| 3075 | case intValue: |
| 3076 | return valueToString(value_.int_); |
| 3077 | case uintValue: |
| 3078 | return valueToString(value_.uint_); |
| 3079 | case realValue: |
| 3080 | return valueToString(value_.real_); |
| 3081 | default: |
| 3082 | if ( default_value_ ) |
| 3083 | return default_value_->asString(); |
| 3084 | else |
| 3085 | return ""; |
| 3086 | } |
| 3087 | } |
| 3088 | |
| 3089 | #ifdef JSON_USE_CPPTL |
| 3090 | CppTL::ConstString Value::asConstString() const { |
no test coverage detected