#include <proto_buffer_writer.h>
Public Member Functions | |
void | BackUp (int count) override |
int64_t | ByteCount () const override |
Returns the total number of bytes written since this object was created. More... | |
bool | Next (void **data, int *size) override |
ProtoBufferWriter (ByteBuffer *byte_buffer, int block_size, int total_size) | |
~ProtoBufferWriter () override | |
Protected Member Functions | |
void | set_byte_count (int64_t byte_count) |
grpc_slice_buffer * | slice_buffer () |
Private Attributes | |
grpc_slice | backup_slice_ |
const int | block_size_ |
size to alloc for each new grpc_slice needed More... | |
int64_t | byte_count_ |
bytes written since this object was created More... | |
bool | have_backup_ |
if we are holding a backup slice or not More... | |
grpc_slice | slice_ |
current slice passed back to the caller More... | |
grpc_slice_buffer * | slice_buffer_ |
internal buffer of slices holding the serialized data More... | |
const int | total_size_ |
byte size of proto being serialized More... | |
Friends | |
class | internal::ProtoBufferWriterPeer |
This is a specialization of the protobuf class ZeroCopyOutputStream. The principle is to give the proto layer one buffer of bytes at a time that it can use to serialize the next portion of the message, with the option to "backup" if more buffer is given than required at the last buffer.
Read more about ZeroCopyOutputStream interface here: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyOutputStream
Definition at line 55 of file impl/codegen/proto_buffer_writer.h.
|
inline |
Constructor for this derived class
[out] | byte_buffer | A pointer to the grpc::ByteBuffer created |
block_size | How big are the chunks to allocate at a time | |
total_size | How many total bytes are required for this proto |
Create an empty raw byte buffer and look at its underlying slice buffer
Definition at line 62 of file impl/codegen/proto_buffer_writer.h.
|
inlineoverride |
Definition at line 75 of file impl/codegen/proto_buffer_writer.h.
|
inlineoverride |
Backup by count bytes because Next returned more bytes than needed (only used in the last buffer). count must be less than or equal too the last buffer returned from next.
Definition at line 125 of file impl/codegen/proto_buffer_writer.h.
|
inlineoverride |
Returns the total number of bytes written since this object was created.
Definition at line 155 of file impl/codegen/proto_buffer_writer.h.
Give the proto library the next buffer of bytes and its size. It is safe for the caller to write from data[0, size - 1].
If we have a backup slice, we should use it first
Definition at line 83 of file impl/codegen/proto_buffer_writer.h.
|
inlineprotected |
Definition at line 163 of file impl/codegen/proto_buffer_writer.h.
|
inlineprotected |
Definition at line 162 of file impl/codegen/proto_buffer_writer.h.
|
friend |
Definition at line 167 of file impl/codegen/proto_buffer_writer.h.
|
private |
holds space we can still write to, if the caller has called BackUp
Definition at line 174 of file impl/codegen/proto_buffer_writer.h.
size to alloc for each new grpc_slice needed
Definition at line 168 of file impl/codegen/proto_buffer_writer.h.
|
private |
bytes written since this object was created
Definition at line 170 of file impl/codegen/proto_buffer_writer.h.
|
private |
if we are holding a backup slice or not
Definition at line 173 of file impl/codegen/proto_buffer_writer.h.
|
private |
current slice passed back to the caller
Definition at line 176 of file impl/codegen/proto_buffer_writer.h.
|
private |
internal buffer of slices holding the serialized data
Definition at line 172 of file impl/codegen/proto_buffer_writer.h.
byte size of proto being serialized
Definition at line 169 of file impl/codegen/proto_buffer_writer.h.