Avro C++
Public Member Functions | Public Attributes | List of all members
avro::StreamReader Struct Reference

A convenience class for reading from an InputStream. More...

#include <Stream.hh>

Public Member Functions

 StreamReader ()
 Constructs an empty reader.
 
 StreamReader (InputStream &in)
 Constructs a reader with the given underlying stream.
 
void reset (InputStream &is)
 Replaces the current input stream with the given one after backing up the original one if required.
 
uint8_t read ()
 Read just one byte from the underlying stream. More...
 
void readBytes (uint8_t *b, size_t n)
 Reads the given number of bytes from the underlying stream. More...
 
void skipBytes (size_t n)
 Skips the given number of bytes. More...
 
bool fill ()
 Get as many byes from the underlying stream as possible in a single chunk. More...
 
void more ()
 Tries to get more data and if it cannot, throws an exception.
 
bool hasMore ()
 Returns true if and only if the end of stream is not reached.
 
void drain (bool unRead)
 Returns unused bytes back to the underlying stream. More...
 

Public Attributes

InputStreamin_
 The underlying input stream.
 
const uint8_t * next_
 The next location to read from.
 
const uint8_t * end_
 One past the last valid location.
 

Detailed Description

A convenience class for reading from an InputStream.

Member Function Documentation

◆ drain()

void avro::StreamReader::drain ( bool  unRead)
inline

Returns unused bytes back to the underlying stream.

If unRead is true the last byte read is also pushed back.

References avro::InputStream::backup(), end_, in_, and next_.

◆ fill()

bool avro::StreamReader::fill ( )
inline

Get as many byes from the underlying stream as possible in a single chunk.

Returns
true if some data could be obtained. False is no more data is available on the stream.

References end_, in_, avro::InputStream::next(), and next_.

Referenced by hasMore(), and more().

◆ read()

uint8_t avro::StreamReader::read ( )
inline

Read just one byte from the underlying stream.

If there are no more data, throws an exception.

References end_, more(), and next_.

◆ readBytes()

void avro::StreamReader::readBytes ( uint8_t *  b,
size_t  n 
)
inline

Reads the given number of bytes from the underlying stream.

If there are not that many bytes, throws an exception.

References end_, more(), and next_.

◆ skipBytes()

void avro::StreamReader::skipBytes ( size_t  n)
inline

Skips the given number of bytes.

Of there are not so that many bytes, throws an exception.

References end_, in_, next_, and avro::InputStream::skip().


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