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