GRPC C++  1.66.0
Public Member Functions | Protected Member Functions
grpc::ProtoBufferReader Class Reference

This is a specialization of the protobuf class ZeroCopyInputStream The principle is to get one chunk of data at a time from the proto layer, with options to backup (re-see some bytes) or skip (forward past some bytes) More...

#include <proto_buffer_reader.h>

Public Member Functions

 ProtoBufferReader (ByteBuffer *buffer)
 Constructs buffer reader from buffer. More...
 
 ~ProtoBufferReader () override
 
bool Next (const void **data, int *size) override
 Give the proto library a chunk of data from the stream. More...
 
Status status () const
 Returns the status of the buffer reader. More...
 
void BackUp (int count) override
 The proto library calls this to indicate that we should back up count bytes that have already been returned by the last call of Next. More...
 
bool Skip (int count) override
 The proto library calls this to skip over count bytes. More...
 
int64_t ByteCount () const override
 Returns the total number of bytes read since this object was created. More...
 

Protected Member Functions

void set_byte_count (int64_t byte_count)
 
int64_t backup_count ()
 
void set_backup_count (int64_t backup_count)
 
grpc_byte_buffer_readerreader ()
 
grpc_sliceslice ()
 
grpc_slice ** mutable_slice_ptr ()
 

Detailed Description

This is a specialization of the protobuf class ZeroCopyInputStream The principle is to get one chunk of data at a time from the proto layer, with options to backup (re-see some bytes) or skip (forward past some bytes)

Read more about ZeroCopyInputStream interface here: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyInputStream

Constructor & Destructor Documentation

◆ ProtoBufferReader()

grpc::ProtoBufferReader::ProtoBufferReader ( ByteBuffer buffer)
inlineexplicit

Constructs buffer reader from buffer.

Will set status() to non ok if buffer is invalid (the internal buffer has not been initialized).

Implemented through a grpc_byte_buffer_reader which iterates over the slices that make up a byte buffer

◆ ~ProtoBufferReader()

grpc::ProtoBufferReader::~ProtoBufferReader ( )
inlineoverride

Member Function Documentation

◆ BackUp()

void grpc::ProtoBufferReader::BackUp ( int  count)
inlineoverride

The proto library calls this to indicate that we should back up count bytes that have already been returned by the last call of Next.

So do the backup and have that ready for a later Next.

◆ backup_count()

int64_t grpc::ProtoBufferReader::backup_count ( )
inlineprotected

◆ ByteCount()

int64_t grpc::ProtoBufferReader::ByteCount ( ) const
inlineoverride

Returns the total number of bytes read since this object was created.

◆ mutable_slice_ptr()

grpc_slice** grpc::ProtoBufferReader::mutable_slice_ptr ( )
inlineprotected

◆ Next()

bool grpc::ProtoBufferReader::Next ( const void **  data,
int *  size 
)
inlineoverride

Give the proto library a chunk of data from the stream.

The caller may safely read from data[0, size - 1].

If we have backed up previously, we need to return the backed-up slice

Otherwise get the next slice from the byte buffer reader

◆ reader()

grpc_byte_buffer_reader* grpc::ProtoBufferReader::reader ( )
inlineprotected

◆ set_backup_count()

void grpc::ProtoBufferReader::set_backup_count ( int64_t  backup_count)
inlineprotected

◆ set_byte_count()

void grpc::ProtoBufferReader::set_byte_count ( int64_t  byte_count)
inlineprotected

◆ Skip()

bool grpc::ProtoBufferReader::Skip ( int  count)
inlineoverride

The proto library calls this to skip over count bytes.

Implement this using Next and BackUp combined.

◆ slice()

grpc_slice* grpc::ProtoBufferReader::slice ( )
inlineprotected

◆ status()

Status grpc::ProtoBufferReader::status ( ) const
inline

Returns the status of the buffer reader.


The documentation for this class was generated from the following file: