Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
#ifndef GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__ |
|
#define GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__ |
|
|
|
#include <cstdint> |
|
#include <utility> |
|
|
|
#include "upb/mem/arena.h" |
|
#include "upb/message/message.h" |
|
|
|
namespace hpb::internal { |
|
|
|
struct PrivateAccess { |
|
template <typename T> |
|
static auto* GetInternalMsg(T&& message) { |
|
return message->msg(); |
|
} |
|
template <typename T> |
|
static auto Proxy(upb_Message* p, upb_Arena* arena) { |
|
return typename T::Proxy(p, arena); |
|
} |
|
template <typename T> |
|
static auto CProxy(const upb_Message* p, upb_Arena* arena) { |
|
return typename T::CProxy(p, arena); |
|
} |
|
template <typename T> |
|
static auto CreateMessage(upb_Arena* arena) { |
|
return typename T::Proxy(upb_Message_New(T::minitable(), arena), arena); |
|
} |
|
|
|
template <typename ExtensionId> |
|
static constexpr uint32_t GetExtensionNumber(const ExtensionId& id) { |
|
return id.number(); |
|
} |
|
}; |
|
|
|
template <typename T> |
|
auto* GetInternalMsg(T&& message) { |
|
return PrivateAccess::GetInternalMsg(std::forward<T>(message)); |
|
} |
|
|
|
template <typename T> |
|
typename T::Proxy CreateMessageProxy(upb_Message* msg, upb_Arena* arena) { |
|
return typename T::Proxy(msg, arena); |
|
} |
|
|
|
} // namespace hpb::internal |
|
|
|
#endif // GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__
|
|
|