19 #ifndef GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H 20 #define GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H 22 #include <type_traits> 44 template <
class ProtoBufferWriter,
class T>
49 "ProtoBufferWriter must be a subclass of " 50 "::protobuf::io::ZeroCopyOutputStream");
52 int byte_size = msg.ByteSize();
54 Slice slice(byte_size);
57 const_cast<uint8_t*>(slice.
begin())));
61 return g_core_codegen_interface->ok();
64 return msg.SerializeToZeroCopyStream(&writer)
65 ? g_core_codegen_interface->ok()
70 template <
class ProtoBufferReader,
class T>
74 "ProtoBufferReader must be a subclass of " 75 "::protobuf::io::ZeroCopyInputStream");
76 if (buffer ==
nullptr) {
79 Status result = g_core_codegen_interface->
ok();
86 decoder.SetTotalBytesLimit(INT_MAX, INT_MAX);
87 if (!msg->ParseFromCodedStream(&decoder)) {
90 if (!decoder.ConsumedEntireMessage()) {
100 #ifdef GRPC_OPEN_SOURCE_PROTO 106 grpc::protobuf::Message, T>::value>::type> {
110 return GenericSerialize<ProtoBufferWriter, T>(msg, bb, own_buffer);
114 return GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
121 #endif // GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H void Clear()
Remove all data.
Definition: byte_buffer.h:100
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:138
const uint8_t * end() const
Raw pointer to the end (one byte past the last element) of the slice.
Definition: slice.h:107
This is a specialization of the protobuf class ZeroCopyOutputStream.
Definition: proto_buffer_writer.h:53
Status GenericDeserialize(ByteBuffer *buffer, grpc::protobuf::Message *msg)
Definition: proto_utils.h:71
A wrapper around grpc_slice.
Definition: slice.h:35
const uint8_t * begin() const
Raw pointer to the beginning (first element) of the slice.
Definition: slice.h:104
const int kProtoBufferWriterMaxBufferLength
Definition: proto_buffer_writer.h:44
void Swap(ByteBuffer *other)
Swap the state of *this and *other.
Definition: byte_buffer.h:126
Status status() const
Returns the status of the buffer reader.
Definition: proto_buffer_reader.h:97
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:58
#define GRPC_SLICE_INLINED_SIZE
Definition: slice.h:68
::google::protobuf::io::ZeroCopyInputStream ZeroCopyInputStream
Definition: config_protobuf.h:88
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:31
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:46
bool ok() const
Is the status OK?
Definition: status.h:118
Did it work? If it didn't, why?
Definition: status.h:31
This is a specialization of the protobuf class ZeroCopyInputStream The principle is to get one chunk ...
Definition: proto_buffer_reader.h:46
::google::protobuf::io::ZeroCopyOutputStream ZeroCopyOutputStream
Definition: config_protobuf.h:87
Status GenericSerialize(const grpc::protobuf::Message &msg, ByteBuffer *bb, bool *own_buffer)
Definition: proto_utils.h:45
Internal errors.
Definition: status_code_enum.h:119
A sequence of bytes.
Definition: byte_buffer.h:53
::google::protobuf::Message Message
Definition: config_protobuf.h:72
::google::protobuf::io::CodedInputStream CodedInputStream
Definition: config_protobuf.h:89