Arduino-Storage
External Memory Storage library for Arduino
Storage::Stream Class Reference

#include <Storage.h>

Inheritance diagram for Storage::Stream:
Inheritance graph
Collaboration diagram for Storage::Stream:
Collaboration graph

Public Member Functions

 Stream (Storage &mem, size_t size)
 
uint32_t addr ()
 
virtual size_t write (uint8_t byte)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
virtual int available ()
 
virtual int peek ()
 
virtual int read ()
 
virtual void flush ()
 

Public Attributes

size_t SIZE
 

Protected Attributes

Storagem_mem
 
const uint32_t m_addr
 
uint16_t m_put
 
uint16_t m_get
 
uint16_t m_count
 

Detailed Description

Stream of given size on given storage. Write/print intermediate data to the stream that may later be read and transfered. Multiple stream may be created on the same device.

Definition at line 253 of file Storage.h.

Constructor & Destructor Documentation

Storage::Stream::Stream ( Storage mem,
size_t  size 
)
inline

Construct stream on given storage device with the given size.

Parameters
[in]memstorage device for stream.
[in]sizenumber of bytes in stream.

Definition at line 260 of file Storage.h.

Member Function Documentation

uint32_t Storage::Stream::addr ( )
inline

Returns storage address for stream.

Returns
address.

Definition at line 274 of file Storage.h.

virtual int Storage::Stream::available ( )
inlinevirtual

Returns number of bytes available for read().

Returns
bytes available.

Definition at line 329 of file Storage.h.

virtual void Storage::Stream::flush ( )
inlinevirtual

Flush all data and reset stream.

Definition at line 369 of file Storage.h.

virtual int Storage::Stream::peek ( )
inlinevirtual

Return next byte in stream (without removing) if available otherwise negative error code(-1).

Returns
next byte or negative error code.

Definition at line 340 of file Storage.h.

virtual int Storage::Stream::read ( )
inlinevirtual

Return next byte if available otherwise negative error code(-1).

Returns
next byte or negative error code.

Definition at line 354 of file Storage.h.

virtual size_t Storage::Stream::write ( uint8_t  byte)
inlinevirtual

Write given byte to stream. Return number of bytes written, zero if full.

Parameters
[in]byteto write.
Returns
number of bytes written(1).

Definition at line 286 of file Storage.h.

virtual size_t Storage::Stream::write ( const uint8_t *  buffer,
size_t  size 
)
inlinevirtual

Write given buffer and number of bytes to stream. Return number of bytes written, or zero if stream is full.

Parameters
[in]bufferto write.
[in]sizenumber of byets to write.
Returns
number of bytes.

Definition at line 304 of file Storage.h.

Member Data Documentation

const uint32_t Storage::Stream::m_addr
protected

Address on storage for the stream data.

Definition at line 384 of file Storage.h.

uint16_t Storage::Stream::m_count
protected

Number of bytes available.

Definition at line 393 of file Storage.h.

uint16_t Storage::Stream::m_get
protected

Index for the next read/peek.

Definition at line 390 of file Storage.h.

Storage& Storage::Stream::m_mem
protected

Storage device for the stream.

Definition at line 381 of file Storage.h.

uint16_t Storage::Stream::m_put
protected

Index for the next write.

Definition at line 387 of file Storage.h.

size_t Storage::Stream::SIZE

Total size of the stream.

Definition at line 377 of file Storage.h.


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