This is a specialization of the protobuf class ZeroCopyOutputStream.
More...
#include <proto_buffer_writer.h>
|
| ProtoBufferWriter (ByteBuffer *byte_buffer, int block_size, int total_size) |
| Constructor for this derived class. More...
|
|
| ~ProtoBufferWriter () |
|
bool | Next (void **data, int *size) override |
| Give the proto library the next buffer of bytes and its size. More...
|
|
void | BackUp (int count) override |
| Backup by count bytes because Next returned more bytes than needed (only used in the last buffer). More...
|
|
int64_t | ByteCount () const override |
| Returns the total number of bytes written since this object was created. More...
|
|
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
◆ ProtoBufferWriter()
grpc::ProtoBufferWriter::ProtoBufferWriter |
( |
ByteBuffer * |
byte_buffer, |
|
|
int |
block_size, |
|
|
int |
total_size |
|
) |
| |
|
inline |
Constructor for this derived class.
- Parameters
-
[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
◆ ~ProtoBufferWriter()
grpc::ProtoBufferWriter::~ProtoBufferWriter |
( |
| ) |
|
|
inline |
◆ BackUp()
void grpc::ProtoBufferWriter::BackUp |
( |
int |
count | ) |
|
|
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.
- Remove the partially-used last slice from the slice buffer
- Split it into the needed (if any) and unneeded part
- Add the needed part back to the slice buffer
- Mark that we still have the remaining part (for later use/unref)
◆ ByteCount()
int64_t grpc::ProtoBufferWriter::ByteCount |
( |
| ) |
const |
|
inlineoverride |
Returns the total number of bytes written since this object was created.
◆ Next()
bool grpc::ProtoBufferWriter::Next |
( |
void ** |
data, |
|
|
int * |
size |
|
) |
| |
|
inlineoverride |
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
◆ set_byte_count()
void grpc::ProtoBufferWriter::set_byte_count |
( |
int64_t |
byte_count | ) |
|
|
inlineprotected |
◆ slice_buffer()
◆ internal::ProtoBufferWriterPeer
friend class internal::ProtoBufferWriterPeer |
|
friend |
The documentation for this class was generated from the following file: