aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++/byte_buffer.h
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2015-06-23 10:05:20 -0700
committerGravatar Yang Gao <yangg@google.com>2015-06-23 10:05:20 -0700
commit253aaa6b106673553c5cc94c87f7d8932729e54f (patch)
tree368b96bd7e30d8c71c0905945e23208d9b31499e /include/grpc++/byte_buffer.h
parentf8fedc43d76f171b8f87bb65dc5d253e67db996f (diff)
parent026e600b5bb61743cf6ac86623b622520ae2d353 (diff)
Merge pull request #1969 from ctiller/one-shouldnt-depend-on-protobufs
Remove Protobuf dependency for C++
Diffstat (limited to 'include/grpc++/byte_buffer.h')
-rw-r--r--include/grpc++/byte_buffer.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/include/grpc++/byte_buffer.h b/include/grpc++/byte_buffer.h
index 2c0f2e6944..cb3c6a1159 100644
--- a/include/grpc++/byte_buffer.h
+++ b/include/grpc++/byte_buffer.h
@@ -39,6 +39,8 @@
#include <grpc/support/log.h>
#include <grpc++/config.h>
#include <grpc++/slice.h>
+#include <grpc++/status.h>
+#include <grpc++/impl/serialization_traits.h>
#include <vector>
@@ -62,7 +64,10 @@ class ByteBuffer GRPC_FINAL {
size_t Length() const;
private:
- friend class CallOpBuffer;
+ friend class SerializationTraits<ByteBuffer, void>;
+
+ ByteBuffer(const ByteBuffer&);
+ ByteBuffer& operator=(const ByteBuffer&);
// takes ownership
void set_buffer(grpc_byte_buffer* buf) {
@@ -78,6 +83,22 @@ class ByteBuffer GRPC_FINAL {
grpc_byte_buffer* buffer_;
};
+template <>
+class SerializationTraits<ByteBuffer, void> {
+ public:
+ static Status Deserialize(grpc_byte_buffer* byte_buffer, ByteBuffer* dest,
+ int max_message_size) {
+ dest->set_buffer(byte_buffer);
+ return Status::OK;
+ }
+ static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer,
+ bool* own_buffer) {
+ *buffer = source.buffer();
+ *own_buffer = false;
+ return Status::OK;
+ }
+};
+
} // namespace grpc
#endif // GRPCXX_BYTE_BUFFER_H