std::unique_ptr Decoder::decode()

in hessian2/basic_codec/string_codec.cc [399:419]


std::unique_ptr<std::string> Decoder::decode() {
  auto out = std::make_unique<std::string>();
  bool has_surrogate = false;

  if (!decodeStringWithReader(*out.get(), has_surrogate, *reader_.get())) {
    return nullptr;
  }

#ifdef COMPATIBLE_WITH_JAVA_HESSIAN_LITE
  if (has_surrogate) {
    std::string new_out = unescapeFourBytesUtf8Char(absl::string_view(*out));
    if (new_out.empty()) {
      return nullptr;
    }

    return std::make_unique<std::string>(std::move(new_out));
  }
#endif

  return out;
}