SpiffsParticleRK
Public Member Functions
Stream Class Referenceabstract

Arduino/Wiring Stream Class. More...

#include <spark_wiring_stream.h>

Inheritance diagram for Stream:
Print SpiffsParticleFile

Public Member Functions

virtual int available ()=0
 Returns the number of a bytes available to read right now. More...
 
virtual int read ()=0
 Read a byte from the stream. More...
 
virtual int peek ()=0
 Read a byte from the stream but do not remove it so read will return the same byte next time. More...
 
virtual void flush ()=0
 For output streams, writes any unwritten buffered data.
 
void setTimeout (system_tick_t timeout)
 Sets the read timeout (default: 1000 milliseconds) More...
 
bool find (char *target)
 Reads data from the stream until the target string is found. More...
 
bool find (char *target, size_t length)
 Reads data from the stream until the target string is found. More...
 
bool findUntil (char *target, char *terminator)
 Reads data from the stream until the target string is found or the terminator string is found. More...
 
bool findUntil (char *target, size_t targetLen, char *terminate, size_t termLen)
 Reads data from the stream until the target string is found or the terminator string is found. More...
 
long parseInt ()
 returns the first valid (long) integer value from the current position More...
 
float parseFloat ()
 returns the first valid float value from the current position More...
 
size_t readBytes (char *buffer, size_t length)
 Read chars from stream into buffer. More...
 
size_t readBytesUntil (char terminator, char *buffer, size_t length)
 Read chars from stream into buffer until the character terminator is found. More...
 
String readString ()
 Reads the remainder of the file into a string.
 
String readStringUntil (char terminator)
 Reads the remainder of the file into a string or until terminator is found. More...
 
- Public Member Functions inherited from Print
int getWriteError ()
 Return the last error code. 0 means no error.
 
void clearWriteError ()
 Clear the last error code to 0.
 
virtual size_t write (uint8_t c)=0
 Write a single byte to the stream or file. More...
 
size_t write (const char *str)
 Write a null-terminated c-string the stream or file. More...
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Write a bytes specified by a buffer and length to the stream or file. More...
 
size_t print (const char[])
 Print a null-terminated array of char variables (a c-string) to the stream or file.
 
size_t print (char)
 Print a single character to the stream or file.
 
size_t print (unsigned char value, int base=DEC)
 Print an unsigned char (byte value, 8 bits) in the specified base to the stream or file. More...
 
size_t print (int value, int base=DEC)
 Print an int (32 bit integer) the specified base to the stream or file. More...
 
size_t print (unsigned int value, int base=DEC)
 Print an unsigned int (32 bit unsigned integer) the specified base to the stream or file. More...
 
size_t print (long value, int base=DEC)
 Print a long (32 bit integer) the specified base to the stream or file. More...
 
size_t print (unsigned long value, int base=DEC)
 Print a unsigned long (32 bit unsigned integer) the specified base to the stream or file. More...
 
size_t print (double value, int dec=2)
 Print a double floating point value to the stream or file. More...
 
size_t print (const Printable &)
 Print an object derived from Printable to the stream or file.
 
size_t println (const char[])
 Print a null-terminated array of char variables (a c-string) plus a CRLF end-of-line terminator to the stream or file.
 
size_t println (char value)
 Print a single character plus a CRLF end-of-line terminator to the stream or file.
 
size_t println (unsigned char value, int base=DEC)
 Print an unsigned char (byte value. 8 bits) in the specified base plus a CRLF end-of-line terminator to the stream or file. More...
 
size_t println (int value, int base=DEC)
 Print an int (32 bit integer) the specified base to plus a CRLF end-of-line terminator the stream or file. More...
 
size_t println (unsigned int value, int base=DEC)
 Print an unsigned int (32 bit unsigned integer) the specified base plus a CRLF end-of-line terminator to the stream or file. More...
 
size_t println (long value, int base=DEC)
 Print a long (32 bit signed integer) the specified base plus a CRLF end-of-line terminator to the stream or file. More...
 
size_t println (unsigned long value, int base=DEC)
 Print a unsigned long (32 bit unsigned integer) the specified base plus a CRLF end-of-line terminator to the stream or file. More...
 
size_t println (double value, int dec=2)
 Print a double floating point value plus a CRLF end-of-line terminator to the stream or file. More...
 
size_t println (const Printable &)
 Print an object derived from Printable plus a CRLF end-of-line terminator to the stream or file.
 
size_t println (void)
 Print a CRLF end-of-line terminator to the stream or file.
 
template<typename... Args>
size_t printf (const char *format, Args... args)
 Print using printf-style formatting to the stream or file. More...
 
template<typename... Args>
size_t printlnf (const char *format, Args... args)
 Print using printf-style formatting plus a CRLF end-of-line terminator to the stream or file. More...
 

Detailed Description

Arduino/Wiring Stream Class.

Methods for reading data from a stream, such a serial port, TCP network stream, or a file.

Member Function Documentation

◆ available()

virtual int Stream::available ( )
pure virtual

Returns the number of a bytes available to read right now.

For files, the number of bytes left to read in the file from the current file position.

Implemented in SpiffsParticleFile.

◆ find() [1/2]

bool Stream::find ( char *  target)

Reads data from the stream until the target string is found.

Parameters
targetThe string to search for (null-terminated c-string)
Returns
true if target string is found, false if timed out (see setTimeout)

◆ find() [2/2]

bool Stream::find ( char *  target,
size_t  length 
)

Reads data from the stream until the target string is found.

Parameters
targetThe string to search for. The string is specified by length so it does not need to be null-terminated.
lengthThe number of bytes in target to search for.
Returns
true if target string is found, false if timed out (see setTimeout)

◆ findUntil() [1/2]

bool Stream::findUntil ( char *  target,
char *  terminator 
)

Reads data from the stream until the target string is found or the terminator string is found.

Parameters
targetThe string to search for (null-terminated c-string)
terminatorThe terminator string to search for (null-terminated c-string)
Returns
true if target string is found, false if timed out (see setTimeout)

◆ findUntil() [2/2]

bool Stream::findUntil ( char *  target,
size_t  targetLen,
char *  terminate,
size_t  termLen 
)

Reads data from the stream until the target string is found or the terminator string is found.

Parameters
targetThe string to search for. The string is specified by length so it does not need to be null-terminated.
lengthThe number of bytes in target to search for.
terminatorThe terminator string to search for. The string is specified by length so it does not need to be null-terminated.
termLenThe number of bytes in terminator to search for.
Returns
true if target string is found, false if timed out (see setTimeout)

◆ parseFloat()

float Stream::parseFloat ( )

returns the first valid float value from the current position

Initial characters that are not digits (or the minus sign or .) are skipped float is terminated by the first character that is not a float character. Decimal part is separate by '.'.

◆ parseInt()

long Stream::parseInt ( )

returns the first valid (long) integer value from the current position

Initial characters that are not digits (or the minus sign) are skipped integer is terminated by the first character that is not a digit.

◆ peek()

virtual int Stream::peek ( )
pure virtual

Read a byte from the stream but do not remove it so read will return the same byte next time.

Returns
A byte value 0 - 255, or -1 if there are no bytes available.

For files, the current file position is left unchanged.

Implemented in SpiffsParticleFile.

◆ read()

virtual int Stream::read ( )
pure virtual

Read a byte from the stream.

Returns
A byte value 0 - 255, or -1 if there are no bytes available.

Implemented in SpiffsParticleFile.

◆ readBytes()

size_t Stream::readBytes ( char *  buffer,
size_t  length 
)

Read chars from stream into buffer.

Parameters
bufferThe buffer to read into
lengthThe number of bytes to read
Returns
the number of characters placed in the buffer (0 means no valid data found)

◆ readBytesUntil()

size_t Stream::readBytesUntil ( char  terminator,
char *  buffer,
size_t  length 
)

Read chars from stream into buffer until the character terminator is found.

Parameters
terminatorThe character to stop reading
bufferThe buffer to read into
lengthThe number of bytes to read
Returns
the number of characters placed in the buffer (0 means no valid data found)

The terminator could be some thing like \n (newline), \t (tab), etc. depending on the data you are parsing.

◆ readStringUntil()

String Stream::readStringUntil ( char  terminator)

Reads the remainder of the file into a string or until terminator is found.

Parameters
terminatorThe character to stop reading at.

◆ setTimeout()

void Stream::setTimeout ( system_tick_t  timeout)

Sets the read timeout (default: 1000 milliseconds)

This makes more sense for network and serial streams.


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