Base Framework
Public Member Functions | List of all members
MemoryInputStream Class Reference

#include <base/io/MemoryInputStream.h>

Inherits InputStream.

Public Member Functions

 MemoryInputStream (const uint8 *_src, const uint8 *_end)
 
 MemoryInputStream (const String &text)
 
unsigned int available () const noexcept
 
unsigned int read (uint8 *dest, unsigned int size, bool nonblocking)
 
unsigned int skip (unsigned int count) noexcept
 
void close () noexcept
 
void wait () const noexcept
 
bool wait (unsigned int timeout) const noexcept
 
- Public Member Functions inherited from Stream
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

Memory input stream.

Member Function Documentation

◆ available()

unsigned int MemoryInputStream::available ( ) const
inlinevirtualnoexcept

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.

Implements InputStream.

◆ close()

void MemoryInputStream::close ( )
inlinevirtualnoexcept

Closes the stream and releases any system resources associated with the stream.

Implements Stream.

◆ read()

unsigned int MemoryInputStream::read ( uint8 *  buffer,
unsigned int  size,
bool  nonblocking 
)
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.

Implements InputStream.

◆ skip()

unsigned int MemoryInputStream::skip ( unsigned int  count)
inlinevirtualnoexcept

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.

Implements InputStream.

◆ wait() [1/2]

void MemoryInputStream::wait ( ) const
inlinevirtualnoexcept

Blocking wait for input to become available.

Implements InputStream.

◆ wait() [2/2]

bool MemoryInputStream::wait ( unsigned int  timeout) const
inlinevirtualnoexcept

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.

Implements InputStream.