Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_PROTO_UTILS_H
20 #define GRPCPP_IMPL_PROTO_UTILS_H
22 #include <type_traits>
42 template <
class ProtoBufferWriter,
class T>
47 "ProtoBufferWriter must be a subclass of "
48 "::protobuf::io::ZeroCopyOutputStream");
50 int byte_size =
static_cast<int>(msg.ByteSizeLong());
52 Slice slice(byte_size);
54 GPR_ASSERT(slice.
end() == msg.SerializeWithCachedSizesToArray(
55 const_cast<uint8_t*
>(slice.
begin())));
62 return msg.SerializeToZeroCopyStream(&writer)
68 template <
class ProtoBufferReader,
class T>
73 "ProtoBufferReader must be a subclass of "
74 "::protobuf::io::ZeroCopyInputStream");
75 if (buffer ==
nullptr) {
84 if (!msg->ParseFromZeroCopyStream(&reader)) {
94 #ifdef GRPC_OPEN_SOURCE_PROTO
99 class SerializationTraits<
100 T, typename
std::enable_if<
101 std::is_base_of<grpc::protobuf::MessageLite, T>::value>::type> {
104 ByteBuffer* bb,
bool* own_buffer) {
105 return GenericSerialize<ProtoBufferWriter, T>(msg, bb, own_buffer);
108 static Status Deserialize(ByteBuffer* buffer,
110 return GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
117 #endif // GRPCPP_IMPL_PROTO_UTILS_H
This is a specialization of the protobuf class ZeroCopyOutputStream.
Definition: proto_buffer_writer.h:55
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
::google::protobuf::io::ZeroCopyOutputStream ZeroCopyOutputStream
Definition: config_protobuf.h:104
const uint8_t * begin() const
Raw pointer to the beginning (first element) of the slice.
Definition: slice.h:102
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:95
::google::protobuf::io::ZeroCopyInputStream ZeroCopyInputStream
Definition: config_protobuf.h:105
bool ok() const
Is the status OK?
Definition: status.h:126
const uint8_t * end() const
Raw pointer to the end (one byte past the last element) of the slice.
Definition: slice.h:105
Status GenericSerialize(const grpc::protobuf::MessageLite &msg, ByteBuffer *bb, bool *own_buffer)
Definition: proto_utils.h:43
Did it work? If it didn't, why?
Definition: status.h:35
void Clear()
Remove all data.
Definition: byte_buffer.h:128
A sequence of bytes.
Definition: byte_buffer.h:60
void Swap(ByteBuffer *other)
Swap the state of *this and *other.
Definition: byte_buffer.h:152
This is a specialization of the protobuf class ZeroCopyInputStream The principle is to get one chunk ...
Definition: proto_buffer_reader.h:47
Status GenericDeserialize(ByteBuffer *buffer, grpc::protobuf::MessageLite *msg)
Definition: proto_utils.h:69
const int kProtoBufferWriterMaxBufferLength
Definition: proto_buffer_writer.h:46
A wrapper around grpc_slice.
Definition: slice.h:33
Status status() const
Returns the status of the buffer reader.
Definition: proto_buffer_reader.h:95
static const Status & OK
An OK pre-defined instance.
Definition: status.h:113
Definition: async_unary_call.h:405
::absl::Status Status
Definition: config_protobuf.h:97
#define GRPC_SLICE_INLINED_SIZE
Definition: slice_type.h:47
::google::protobuf::MessageLite MessageLite
Definition: config_protobuf.h:83
@ INTERNAL
Internal errors.
Definition: status_code_enum.h:121