Skip to content

Commit

Permalink
Automated rollback of commit 6b9d5c4.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698499250
  • Loading branch information
honglooker authored and copybara-github committed Nov 20, 2024
1 parent db71344 commit 6ce48c2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions hpb/hpb.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ ABSL_MUST_USE_RESULT bool Parse(Ptr<T> message, absl::string_view bytes) {
arena) == kUpb_DecodeStatus_Ok;
}

template <typename T>
ABSL_MUST_USE_RESULT bool Parse(T* message, absl::string_view bytes) {
return Parse(Ptr(message), bytes);
}

template <typename T>
absl::StatusOr<T> Parse(absl::string_view bytes, int options = 0) {
T message;
Expand All @@ -114,6 +109,19 @@ absl::StatusOr<T> Parse(absl::string_view bytes, int options = 0) {
return MessageDecodeError(status);
}

template <typename T>
ABSL_MUST_USE_RESULT bool Parse(T* message, absl::string_view bytes) {
static_assert(!std::is_const_v<T>);
upb_Message_Clear(hpb::interop::upb::GetMessage(message),
::hpb::interop::upb::GetMiniTable(message));
auto* arena = hpb::interop::upb::GetArena(message);
return upb_Decode(bytes.data(), bytes.size(),
hpb::interop::upb::GetMessage(message),
::hpb::interop::upb::GetMiniTable(message),
/* extreg= */ nullptr, /* options= */ 0,
arena) == kUpb_DecodeStatus_Ok;
}

template <typename T>
absl::StatusOr<T> Parse(absl::string_view bytes,
const ::hpb::ExtensionRegistry& extension_registry,
Expand Down

0 comments on commit 6ce48c2

Please sign in to comment.