COSA
An Object-Oriented Platform for Arduino Programming
IOBuffer< SIZE > Class Template Reference

#include <IOBuffer.hh>

Inheritance diagram for IOBuffer< SIZE >:
Inheritance graph
Collaboration diagram for IOBuffer< SIZE >:
Collaboration graph

Public Member Functions

 IOBuffer ()
 
bool is_empty ()
 
bool is_full ()
 
virtual int available ()
 
virtual int room ()
 
virtual int putchar (char c)
 
virtual int peekchar ()
 
virtual int peekchar (char c)
 
virtual int getchar ()
 
virtual int flush ()
 
virtual void empty ()
 
 operator const char * ()
 
void non_blocking ()
 
void blocking ()
 
bool is_blocking () const
 
void eol (Mode mode)
 
Mode eol () const
 
virtual int puts (const char *s)
 
virtual int puts (str_P s)
 
virtual int write (const void *buf, size_t size)
 
virtual int write (const iovec_t *vec)
 
virtual int write_P (const void *buf, size_t size)
 
virtual char * gets (char *s, size_t count)
 
virtual int read (void *buf, size_t size)
 
virtual int read (iovec_t *vec)
 

Protected Attributes

bool m_blocking
 
Mode m_eol
 

Detailed Description

template<uint16_t SIZE>
class IOBuffer< SIZE >

Circular buffer template class for IOStreams. May be used as a string buffer device, or to connect different IOStreams. See UART.hh for an example. Buffer size should be power of 2 and max 32Kbyte.

Parameters
[in]SIZEnumber of bytes in buffer.

Definition at line 36 of file IOBuffer.hh.

Constructor & Destructor Documentation

template<uint16_t SIZE>
IOBuffer< SIZE >::IOBuffer ( )
inline

Constuct buffer object for stream operations.

Definition at line 42 of file IOBuffer.hh.

Member Function Documentation

template<uint16_t SIZE>
virtual int IOBuffer< SIZE >::available ( )
inlinevirtual

Number of bytes available in buffer before empty.

Returns
bytes.

Reimplemented from IOStream::Device.

Definition at line 73 of file IOBuffer.hh.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

template<uint16_t SIZE>
virtual void IOBuffer< SIZE >::empty ( )
inlinevirtual

Empty the buffer.

Reimplemented from IOStream::Device.

Definition at line 130 of file IOBuffer.hh.

void IOStream::Device::eol ( Mode  mode)
inlineinherited

Set end of line mode.

Parameters
[in]modefor end of line.

Definition at line 103 of file IOStream.hh.

Mode IOStream::Device::eol ( ) const
inlineinherited

Get end of line mode.

Returns
mode.

Definition at line 112 of file IOStream.hh.

template<uint16_t SIZE>
int IOBuffer< SIZE >::flush ( )
virtual

Wait for the buffer to become empty.

Returns
zero(0) or negative error code.

Reimplemented from IOStream::Device.

Definition at line 198 of file IOBuffer.hh.

template<uint16_t SIZE>
int IOBuffer< SIZE >::getchar ( )
virtual

Read character from buffer.

Returns
character or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 188 of file IOBuffer.hh.

char * IOStream::Device::gets ( char *  s,
size_t  count 
)
virtualinherited

Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.

Parameters
[in]sstring buffer to read into.
[in]countmax number of bytes to read.
Returns
string pointer or NULL.

Definition at line 118 of file IOStream_Device.cpp.

bool IOStream::Device::is_blocking ( ) const
inlineinherited

Is blocking mode?

Returns
bool.

Definition at line 94 of file IOStream.hh.

template<uint16_t SIZE>
bool IOBuffer< SIZE >::is_empty ( )
inline

Return true(1) if the buffer is empty, otherwise false(0).

Returns
bool

Definition at line 52 of file IOBuffer.hh.

template<uint16_t SIZE>
bool IOBuffer< SIZE >::is_full ( )
inline

Return true(1) if the buffer is full, otherwise false(0).

Returns
bool

Definition at line 62 of file IOBuffer.hh.

void IOStream::Device::non_blocking ( )
inlineinherited

Set non-blocking mode.

Definition at line 77 of file IOStream.hh.

template<uint16_t SIZE>
IOBuffer< SIZE >::operator const char * ( )
inline

Cast iobuffer to a character pointer.

Definition at line 139 of file IOBuffer.hh.

template<uint16_t SIZE>
int IOBuffer< SIZE >::peekchar ( )
virtual

Peek at the next character from buffer.

Returns
character or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 165 of file IOBuffer.hh.

template<uint16_t SIZE>
int IOBuffer< SIZE >::peekchar ( char  c)
virtual

Peek for the given character in the stream. Return number of character or EOF(-1).

Returns
number of characters or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 174 of file IOBuffer.hh.

template<uint16_t SIZE>
int IOBuffer< SIZE >::putchar ( char  c)
virtual

Write character to buffer.

Parameters
[in]ccharacter to write.
Returns
character written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 154 of file IOBuffer.hh.

int IOStream::Device::puts ( const char *  s)
virtualinherited

Write null terminated string to device. Terminating null is not written.

Parameters
[in]sstring to write.
Returns
zero(0) or negative error code.

Definition at line 43 of file IOStream_Device.cpp.

int IOStream::Device::puts ( str_P  s)
virtualinherited

Write null terminated string from program memory to device. Terminating null is not written.

Parameters
[in]sstring in program memory to write.
Returns
zero(0) or negative error code.

Definition at line 54 of file IOStream_Device.cpp.

int IOStream::Device::read ( void *  buf,
size_t  size 
)
virtualinherited

Read data to given buffer with given size from device.

Parameters
[in]bufbuffer to read into.
[in]sizenumber of bytes to read.
Returns
number of bytes read or EOF(-1).

Reimplemented in FAT16::File, W5200::Driver, W5500::Driver, W5100::Driver, CFFS::File, Socket, and CC3000::Driver.

Definition at line 144 of file IOStream_Device.cpp.

int IOStream::Device::read ( iovec_t vec)
virtualinherited

Read data to given buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to read into.
Returns
number of bytes read or EOF(-1).

Definition at line 157 of file IOStream_Device.cpp.

template<uint16_t SIZE>
virtual int IOBuffer< SIZE >::room ( )
inlinevirtual

Number of bytes room in buffer before full.

Returns
bytes.

Reimplemented from IOStream::Device.

Definition at line 84 of file IOBuffer.hh.

int IOStream::Device::write ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in FAT16::File, HD44780, CFFS::File, VLCD, Socket, and CC3000::Driver.

Definition at line 65 of file IOStream_Device.cpp.

int IOStream::Device::write ( const iovec_t vec)
virtualinherited

Write data from buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to write.
Returns
number of bytes written or EOF(-1).

Definition at line 87 of file IOStream_Device.cpp.

int IOStream::Device::write_P ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer in program memory with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in CFFS::File, Socket, and CC3000::Driver.

Definition at line 76 of file IOStream_Device.cpp.

Member Data Documentation

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.


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