| 647 | #endif |
| 648 | |
| 649 | StringContainer Value::asString() const { |
| 650 | switch (type()) { |
| 651 | case nullValue: |
| 652 | return ""; |
| 653 | case stringValue: { |
| 654 | if (value_.string_ == nullptr) |
| 655 | return ""; |
| 656 | unsigned this_len; |
| 657 | char const* this_str; |
| 658 | decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len, &this_str); |
| 659 | return StringContainer(this_str, this_len); |
| 660 | } |
| 661 | case booleanValue: |
| 662 | return value_.bool_ ? "true" : "false"; |
| 663 | case intValue: |
| 664 | return valueToString(value_.int_); |
| 665 | case uintValue: |
| 666 | return valueToString(value_.uint_); |
| 667 | case realValue: |
| 668 | return valueToString(value_.real_); |
| 669 | default: |
| 670 | JSON_FAIL_MESSAGE("Type is not convertible to string"); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | Value::Int Value::asInt() const { |
| 675 | switch (type()) { |
no test coverage detected