Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H
20 #define GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H
22 #include <type_traits>
41 class ProtoBufferWriterPeer;
61 : block_size_(block_size),
62 total_size_(total_size),
69 byte_buffer->set_buffer(bp);
70 slice_buffer_ = &bp->data.raw.slice_buffer;
81 bool Next(
void** data,
int* size)
override {
89 size_t remain = static_cast<size_t>(total_size_ - byte_count_);
92 slice_ = backup_slice_;
100 size_t allocate_length =
101 remain > static_cast<size_t>(block_size_) ? block_size_ : remain;
126 backup_slice_ = slice_;
136 have_backup_ = backup_slice_.
refcount != NULL;
137 byte_count_ -= count;
141 int64_t
ByteCount()
const override {
return byte_count_; }
154 const int block_size_;
155 const int total_size_;
167 #endif // GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H
~ProtoBufferWriter()
Definition: proto_buffer_writer.h:73
This is a specialization of the protobuf class ZeroCopyOutputStream.
Definition: proto_buffer_writer.h:53
virtual grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split)=0
#define GRPC_SLICE_LENGTH(slice)
Definition: slice.h:99
struct grpc_slice_refcount * refcount
Definition: slice.h:61
bool Next(void **data, int *size) override
Give the proto library the next buffer of bytes and its size.
Definition: proto_buffer_writer.h:81
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
virtual void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)=0
::google::protobuf::io::ZeroCopyOutputStream ZeroCopyOutputStream
Definition: config_protobuf.h:96
ProtoBufferWriter(ByteBuffer *byte_buffer, int block_size, int total_size)
Constructor for this derived class.
Definition: proto_buffer_writer.h:60
Definition: grpc_types.h:40
A sequence of bytes.
Definition: byte_buffer.h:67
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
virtual grpc_byte_buffer * grpc_raw_byte_buffer_create(grpc_slice *slice, size_t nslices)=0
const int kProtoBufferWriterMaxBufferLength
Definition: proto_buffer_writer.h:44
grpc_slice_buffer * slice_buffer()
Definition: proto_buffer_writer.h:148
virtual grpc_slice grpc_slice_malloc(size_t length)=0
int64_t ByteCount() const override
Returns the total number of bytes written since this object was created.
Definition: proto_buffer_writer.h:141
virtual void grpc_slice_buffer_pop(grpc_slice_buffer *sb)=0
virtual void grpc_slice_unref(grpc_slice slice)=0
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:96
#define GRPC_SLICE_SET_LENGTH(slice, newlen)
Definition: slice.h:102
bool Valid() const
Is this ByteBuffer valid?
Definition: byte_buffer.h:163
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
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78
void BackUp(int count) override
Backup by count bytes because Next returned more bytes than needed (only used in the last buffer).
Definition: proto_buffer_writer.h:118
void set_byte_count(int64_t byte_count)
Definition: proto_buffer_writer.h:149
friend class internal::ProtoBufferWriterPeer
Definition: proto_buffer_writer.h:153