Base Framework
Public Member Functions | List of all members
InputStream Class Referenceabstract

Input stream. More...

#include <base/io/InputStream.h>

Inherits Stream.

Inherited by FileDescriptorInputStream [virtual], FileInputStream, FilterInputStream [virtual], MemoryInputStream, Pipe [virtual], RandomInputStream, StreamSocket [virtual], and StringInputStream.

Public Member Functions

virtual unsigned int available () const =0
 
virtual unsigned int read (uint8 *buffer, unsigned int size, bool nonblocking)=0
 
virtual unsigned int skip (unsigned int count)=0
 
virtual void wait () const =0
 
virtual bool wait (unsigned int timeout) const =0
 
- Public Member Functions inherited from Stream
virtual void close ()=0
 
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Detailed Description

Input stream.

Class representing an input stream of bytes.

Version
1.0

Member Function Documentation

◆ available()

virtual unsigned int InputStream::available ( ) const
pure virtual

Returns the number of bytes that can be read or skipped over without blocking under normal circumstances. The number of returned bytes may be less than the true number of bytes available. Attempting to read the number of bytes returned by the function may block the calling thread if some process has acquired a lock on the object (e.g. file locking).

Returns
Available number of bytes in stream.

Implemented in RandomInputStream, MemoryInputStream, StreamSocket, BufferedInputStream, FormatInputStream, FileDescriptorInputStream, Pipe, FileInputStream, StringInputStream, and FilterInputStream.

◆ read()

virtual unsigned int InputStream::read ( uint8 *  buffer,
unsigned int  size,
bool  nonblocking 
)
pure virtual

Fills the specified buffer with bytes from the stream. In blocking mode the method does not return until all bytes have been read. In non-blocking mode the total bytes read may be any number below or equal to the requested number of bytes. Attempting to read beyond the end of a stream in blocking mode results in an EndOfFile exception.

Parameters
bufferThe buffer to receive the bytes.
sizeThe size of the buffer.
nonblockingSpecifies that the method may not block.
Returns
The actual number of bytes read from the stream.

Implemented in MemoryInputStream, StreamSocket, FormatInputStream, BufferedInputStream, FileDescriptorInputStream, Pipe, FilterInputStream, FileInputStream, StringInputStream, and RandomInputStream.

◆ skip()

virtual unsigned int InputStream::skip ( unsigned int  count)
pure virtual

Skips a specified number of bytes. Blocks if asked to skip more bytes than available.

Parameters
countThe number of bytes to skip.
Returns
The actual number of bytes skipped.

Implemented in RandomInputStream, MemoryInputStream, StreamSocket, BufferedInputStream, FileDescriptorInputStream, FilterInputStream, StringInputStream, Pipe, and FileInputStream.

◆ wait() [1/2]

virtual void InputStream::wait ( ) const
pure virtual

◆ wait() [2/2]

virtual bool InputStream::wait ( unsigned int  timeout) const
pure virtual

Blocking wait for input to become available.

Parameters
timeoutThe timeout periode in microseconds.
Returns
True, if data is available. False, if the timeout periode expired.

Implemented in RandomInputStream, MemoryInputStream, StreamSocket, BufferedInputStream, FileDescriptorInputStream, Pipe, FilterInputStream, and FileInputStream.