GRPC C++
1.70.1
include
grpcpp
impl
proto_utils.h
Go to the documentation of this file.
1
//
2
//
3
// Copyright 2015 gRPC authors.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
//
18
19
#ifndef GRPCPP_IMPL_PROTO_UTILS_H
20
#define GRPCPP_IMPL_PROTO_UTILS_H
21
22
#include <
grpc/byte_buffer_reader.h
>
23
#include <
grpc/impl/grpc_types.h
>
24
#include <
grpc/slice.h
>
25
#include <
grpcpp/impl/codegen/config_protobuf.h
>
26
#include <
grpcpp/impl/generic_serialize.h
>
27
#include <
grpcpp/impl/serialization_traits.h
>
28
#include <
grpcpp/support/byte_buffer.h
>
29
#include <
grpcpp/support/proto_buffer_reader.h
>
30
#include <
grpcpp/support/proto_buffer_writer.h
>
31
#include <
grpcpp/support/slice.h
>
32
#include <
grpcpp/support/status.h
>
33
34
#include <type_traits>
35
38
39
namespace
grpc
{
40
41
// This class provides a protobuf serializer. It translates between protobuf
42
// objects and grpc_byte_buffers. More information about SerializationTraits can
43
// be found in include/grpcpp/impl/codegen/serialization_traits.h.
44
template
<
class
T>
45
class
SerializationTraits
<
46
T, typename
std
::enable_if<
47
std::is_base_of<grpc::protobuf::MessageLite, T>::value>::type> {
48
public
:
49
static
Status
Serialize
(
const
grpc::protobuf::MessageLite
& msg,
50
ByteBuffer
* bb,
bool
* own_buffer) {
51
return
GenericSerialize<ProtoBufferWriter, T>(msg, bb, own_buffer);
52
}
53
54
static
Status
Deserialize
(
ByteBuffer
* buffer,
55
grpc::protobuf::MessageLite
* msg) {
56
return
GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
57
}
58
};
59
60
}
// namespace grpc
61
62
#endif // GRPCPP_IMPL_PROTO_UTILS_H
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition:
alarm.h:33
grpc::SerializationTraits< T, typename std::enable_if< std::is_base_of< grpc::protobuf::MessageLite, T >::value >::type >::Serialize
static Status Serialize(const grpc::protobuf::MessageLite &msg, ByteBuffer *bb, bool *own_buffer)
Definition:
proto_utils.h:49
grpc::SerializationTraits< T, typename std::enable_if< std::is_base_of< grpc::protobuf::MessageLite, T >::value >::type >::Deserialize
static Status Deserialize(ByteBuffer *buffer, grpc::protobuf::MessageLite *msg)
Definition:
proto_utils.h:54
status.h
proto_buffer_reader.h
byte_buffer_reader.h
grpc_types.h
grpc::Status
Did it work? If it didn't, why?
Definition:
status.h:34
grpc::ByteBuffer
A sequence of bytes.
Definition:
byte_buffer.h:59
proto_buffer_writer.h
grpc::SerializationTraits
Defines how to serialize and deserialize some type.
Definition:
serialization_traits.h:58
serialization_traits.h
config_protobuf.h
slice.h
byte_buffer.h
std
Definition:
async_unary_call.h:406
generic_serialize.h
slice.h
grpc::protobuf::MessageLite
::google::protobuf::MessageLite MessageLite
Definition:
config_protobuf.h:90
Generated on Fri Jan 31 2025 21:28:59 for GRPC C++ by
1.8.17