Public Member Functions | Protected Member Functions | Private Attributes | List of all members
grpc::ProtoBufferReader Class Reference

#include <proto_buffer_reader.h>

Inheritance diagram for grpc::ProtoBufferReader:
Inheritance graph
[legend]

Public Member Functions

void BackUp (int count) override
 
int64_t ByteCount () const override
 Returns the total number of bytes read since this object was created. More...
 
bool Next (const void **data, int *size) override
 
 ProtoBufferReader (ByteBuffer *buffer)
 
bool Skip (int count) override
 
Status status () const
 Returns the status of the buffer reader. More...
 
 ~ProtoBufferReader () override
 

Protected Member Functions

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

Private Attributes

int64_t backup_count_
 how far backed up in the stream we are More...
 
int64_t byte_count_
 total bytes read since object creation More...
 
grpc_byte_buffer_reader reader_
 
grpc_sliceslice_
 current slice passed back to the caller More...
 
Status status_
 status of the entire object More...
 

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

Definition at line 48 of file impl/codegen/proto_buffer_reader.h.

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

Definition at line 52 of file impl/codegen/proto_buffer_reader.h.

◆ ~ProtoBufferReader()

grpc::ProtoBufferReader::~ProtoBufferReader ( )
inlineoverride

Definition at line 64 of file impl/codegen/proto_buffer_reader.h.

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.

Definition at line 103 of file impl/codegen/proto_buffer_reader.h.

◆ backup_count()

int64_t grpc::ProtoBufferReader::backup_count ( )
inlineprotected

Definition at line 134 of file impl/codegen/proto_buffer_reader.h.

◆ ByteCount()

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

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

Definition at line 126 of file impl/codegen/proto_buffer_reader.h.

◆ mutable_slice_ptr()

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

Definition at line 138 of file impl/codegen/proto_buffer_reader.h.

◆ 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

Definition at line 72 of file impl/codegen/proto_buffer_reader.h.

◆ reader()

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

Definition at line 136 of file impl/codegen/proto_buffer_reader.h.

◆ set_backup_count()

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

Definition at line 135 of file impl/codegen/proto_buffer_reader.h.

◆ set_byte_count()

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

Definition at line 133 of file impl/codegen/proto_buffer_reader.h.

◆ 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.

Definition at line 110 of file impl/codegen/proto_buffer_reader.h.

◆ slice()

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

Definition at line 137 of file impl/codegen/proto_buffer_reader.h.

◆ status()

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

Returns the status of the buffer reader.

Definition at line 98 of file impl/codegen/proto_buffer_reader.h.

Member Data Documentation

◆ backup_count_

int64_t grpc::ProtoBufferReader::backup_count_
private

how far backed up in the stream we are

Definition at line 142 of file impl/codegen/proto_buffer_reader.h.

◆ byte_count_

int64_t grpc::ProtoBufferReader::byte_count_
private

total bytes read since object creation

Definition at line 141 of file impl/codegen/proto_buffer_reader.h.

◆ reader_

grpc_byte_buffer_reader grpc::ProtoBufferReader::reader_
private

internal object to read grpc_slice from the grpc_byte_buffer

Definition at line 143 of file impl/codegen/proto_buffer_reader.h.

◆ slice_

grpc_slice* grpc::ProtoBufferReader::slice_
private

current slice passed back to the caller

Definition at line 145 of file impl/codegen/proto_buffer_reader.h.

◆ status_

Status grpc::ProtoBufferReader::status_
private

status of the entire object

Definition at line 146 of file impl/codegen/proto_buffer_reader.h.


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


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:31