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);
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 !=
nullptr;
137 byte_count_ -= count;
141 int64_t
ByteCount()
const override {
return byte_count_; }
154 const int block_size_;
155 const int total_size_;
A sequence of bytes.
Definition: byte_buffer.h:60
bool Valid() const
Is this ByteBuffer valid?
Definition: byte_buffer.h:163
virtual grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split)=0
virtual void grpc_slice_unref(grpc_slice slice)=0
virtual grpc_byte_buffer * grpc_raw_byte_buffer_create(grpc_slice *slice, size_t nslices)=0
virtual grpc_slice grpc_slice_malloc(size_t length)=0
virtual void grpc_slice_buffer_pop(grpc_slice_buffer *sb)=0
virtual void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)=0
This is a specialization of the protobuf class ZeroCopyOutputStream.
Definition: proto_buffer_writer.h:53
ProtoBufferWriter(ByteBuffer *byte_buffer, int block_size, int total_size)
Constructor for this derived class.
Definition: proto_buffer_writer.h:60
grpc_slice_buffer * slice_buffer()
Definition: proto_buffer_writer.h:148
void set_byte_count(int64_t byte_count)
Definition: proto_buffer_writer.h:149
friend class internal::ProtoBufferWriterPeer
Definition: proto_buffer_writer.h:153
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
~ProtoBufferWriter() override
Definition: proto_buffer_writer.h:73
int64_t ByteCount() const override
Returns the total number of bytes written since this object was created.
Definition: proto_buffer_writer.h:141
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
#define GRPC_SLICE_SET_LENGTH(slice, newlen)
Definition: slice.h:102
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:96
#define GRPC_SLICE_INLINED_SIZE
Definition: slice.h:47
#define GRPC_SLICE_LENGTH(slice)
Definition: slice.h:99
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
::google::protobuf::io::ZeroCopyOutputStream ZeroCopyOutputStream
Definition: config_protobuf.h:98
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
CoreCodegenInterface * g_core_codegen_interface
Null-initializes the global gRPC variables for the codegen library.
Definition: completion_queue.h:96
const int kProtoBufferWriterMaxBufferLength
Definition: proto_buffer_writer.h:44
grpc_slice_buffer slice_buffer
Definition: grpc_types.h:49
Definition: grpc_types.h:40
union grpc_byte_buffer::grpc_byte_buffer_data data
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
struct grpc_slice_refcount * refcount
Definition: slice.h:61
struct grpc_byte_buffer::grpc_byte_buffer_data::grpc_compressed_buffer raw