scclib
Stable Cloud Computing C++ Library
Public Member Functions | List of all members
scc::util::InStream Class Reference

Input stream wrapper for reader. More...

#include <iostream.h>

Inheritance diagram for scc::util::InStream:
Inheritance graph
[legend]
Collaboration diagram for scc::util::InStream:
Collaboration graph
[legend]

Public Member Functions

 InStream (Reader &, size_t=1024)
 Create reader stream. More...
 
 InStream (const std::shared_ptr< Reader > &, size_t=1024)
 Create reader stream. More...
 
 InStream ()=delete
 No default construct.
 
 InStream (const InStream &)=delete
 Copy construct not allowed.
 
InStreamoperator= (const InStream &)=delete
 Copy assign not allowed.
 
 InStream (InStream &&)
 Move construct.
 
InStreamoperator= (InStream &&)
 Move assign.
 
void read_reset (const std::shared_ptr< Reader > &)
 
std::shared_ptr< Readerread_shared () const
 
virtual size_t recvbuf_size () const
 Size of receive buffer.
 
virtual void recvbuf_size (size_t)
 Resize the receive buffer. More...
 
virtual std::string recv_fail () const
 Failure message from the input stream. More...
 
void clear (std::ios::iostate=std::ios::goodbit)
 

Detailed Description

Input stream wrapper for reader.

Makes Reader objects compatible with std::istream.

Examples
examples/net/netmain.cc, util/unittest/iohelper.cc, and util/unittest/iostream.cc.

Definition at line 58 of file iostream.h.

Constructor & Destructor Documentation

◆ InStream() [1/2]

InStream::InStream ( Reader reader,
size_t  recv_buf_sz = 1024 
)

Create reader stream.

Does not assume ownership of object. Useful for temporary use, otherwise use the shared pointer form.

Parameters
readerReader.
recv_buf_szSize of receive buffer. Number of bytes to be buffered from the underlying reader.

Definition at line 341 of file iostream.cc.

◆ InStream() [2/2]

InStream::InStream ( const std::shared_ptr< Reader > &  reader,
size_t  recv_buf_sz = 1024 
)

Create reader stream.

Parameters
readerReader shared pointer.
recv_buf_szSize of receive buffer. Number of bytes to be buffered from the underlying reader.

Definition at line 348 of file iostream.cc.

Member Function Documentation

◆ recv_fail()

std::string InStream::recv_fail ( ) const
virtual

Failure message from the input stream.

When an exception is thrown during an underlying read, the exception value is set in recv_fail(), and the bad bit is set.

When a read returns 0, the eof bit is set.

Definition at line 419 of file iostream.cc.

◆ recvbuf_size()

void InStream::recvbuf_size ( size_t  sz)
virtual

Resize the receive buffer.

Clears any data currently in the input buffer.

Definition at line 407 of file iostream.cc.


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