Go to the documentation of this file.
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.ByteSizeLong();
54 Slice slice(byte_size);
57 const_cast<uint8_t*>(slice.
begin())));
64 return msg.SerializeToZeroCopyStream(&writer)
70 template <
class ProtoBufferReader,
class T>
75 "ProtoBufferReader must be a subclass of "
76 "::protobuf::io::ZeroCopyInputStream");
77 if (buffer ==
nullptr) {
86 if (!msg->ParseFromZeroCopyStream(&reader)) {
96 #ifdef GRPC_OPEN_SOURCE_PROTO
101 class SerializationTraits<
102 T, typename
std::enable_if<
103 std::is_base_of<grpc::protobuf::MessageLite, T>::value>::type> {
106 ByteBuffer* bb,
bool* own_buffer) {
107 return GenericSerialize<ProtoBufferWriter, T>(msg, bb, own_buffer);
110 static Status Deserialize(ByteBuffer* buffer,
112 return GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
119 #endif // GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H
This is a specialization of the protobuf class ZeroCopyOutputStream.
Definition: proto_buffer_writer.h:53
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
::google::protobuf::io::ZeroCopyOutputStream ZeroCopyOutputStream
Definition: config_protobuf.h:96
const uint8_t * begin() const
Raw pointer to the beginning (first element) of the slice.
Definition: slice.h:104
::google::protobuf::io::ZeroCopyInputStream ZeroCopyInputStream
Definition: config_protobuf.h:97
virtual const Status & ok()=0
bool ok() const
Is the status OK?
Definition: status.h:118
const uint8_t * end() const
Raw pointer to the end (one byte past the last element) of the slice.
Definition: slice.h:107
Status GenericSerialize(const grpc::protobuf::MessageLite &msg, ByteBuffer *bb, bool *own_buffer)
Definition: proto_utils.h:45
Did it work? If it didn't, why?
Definition: status.h:31
void Clear()
Remove all data.
Definition: byte_buffer.h:128
A sequence of bytes.
Definition: byte_buffer.h:67
void Swap(ByteBuffer *other)
Swap the state of *this and *other.
Definition: byte_buffer.h:156
This is a specialization of the protobuf class ZeroCopyInputStream The principle is to get one chunk ...
Definition: proto_buffer_reader.h:46
Status GenericDeserialize(ByteBuffer *buffer, grpc::protobuf::MessageLite *msg)
Definition: proto_utils.h:71
const int kProtoBufferWriterMaxBufferLength
Definition: proto_buffer_writer.h:44
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
A wrapper around grpc_slice.
Definition: slice.h:35
Status status() const
Returns the status of the buffer reader.
Definition: proto_buffer_reader.h:96
Definition: async_unary_call_impl.h:301
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue_impl.h:93
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
#define GRPC_SLICE_INLINED_SIZE
Definition: slice.h:47
::google::protobuf::MessageLite MessageLite
Definition: config_protobuf.h:76
Internal errors.
Definition: status_code_enum.h:119