| 998 | } |
| 999 | |
| 1000 | std::string Scalar::ToString() const { |
| 1001 | if (!this->is_valid) { |
| 1002 | return "null"; |
| 1003 | } |
| 1004 | if (type->id() == Type::DICTIONARY) { |
| 1005 | auto dict_scalar = checked_cast<const DictionaryScalar*>(this); |
| 1006 | return dict_scalar->value.dictionary->ToString() + "[" + |
| 1007 | dict_scalar->value.index->ToString() + "]"; |
| 1008 | } |
| 1009 | auto maybe_repr = CastTo(utf8()); |
| 1010 | if (maybe_repr.ok()) { |
| 1011 | return checked_cast<const StringScalar&>(*maybe_repr.ValueOrDie()).value->ToString(); |
| 1012 | } |
| 1013 | |
| 1014 | std::string result; |
| 1015 | std::shared_ptr<Array> as_array = *MakeArrayFromScalar(*this, 1); |
| 1016 | DCHECK_OK(PrettyPrint(*as_array, PrettyPrintOptions::Defaults(), &result)); |
| 1017 | return result; |
| 1018 | } |
| 1019 | |
| 1020 | struct ScalarParseImpl { |
| 1021 | template <typename T, typename = internal::enable_if_parseable<T>> |
no test coverage detected