aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++/byte_buffer.h
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-07-06 14:05:54 -0700
committerGravatar yang-g <yangg@google.com>2015-07-06 14:05:54 -0700
commit5ea46ab2482c3724fbc7fd0aab55f324fb65999c (patch)
tree55eebc4aae8f06f931c8f75ddf84d56595f99fa1 /include/grpc++/byte_buffer.h
parent3abe60b9d08ff5a784a39f7c4a10c631547c3526 (diff)
parentd426864934ac60f46e538ba81932e405fa8949b1 (diff)
merge with upstream and resolve conflicts
Diffstat (limited to 'include/grpc++/byte_buffer.h')
-rw-r--r--include/grpc++/byte_buffer.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/include/grpc++/byte_buffer.h b/include/grpc++/byte_buffer.h
index 3e40eaed1d..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>
@@ -48,7 +50,7 @@ class ByteBuffer GRPC_FINAL {
public:
ByteBuffer() : buffer_(nullptr) {}
- ByteBuffer(Slice* slices, size_t nslices);
+ ByteBuffer(const Slice* slices, size_t nslices);
~ByteBuffer() {
if (buffer_) {
@@ -56,13 +58,16 @@ class ByteBuffer GRPC_FINAL {
}
}
- void Dump(std::vector<Slice>* slices);
+ void Dump(std::vector<Slice>* slices) const;
void Clear();
- size_t Length();
+ 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