ESP32 PSRAM Library
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Stream Class Referenceabstract

Base class for all character and binary stream operations. More...

#include <Stream.h>

Inheritance diagram for Stream:
Print esp32_psram::InMemoryFile< VectorType > esp32_psram::RingBufferStream< VectorType >

Public Types

using oneShotMs = esp8266::polledTimeout::oneShotFastMs
 Time management for stream operations.
 
enum class  Report {
  Success = 0 , TimedOut , ReadError , WriteError ,
  ShortOperation
}
 Status codes for stream transfer operations. More...
 

Public Member Functions

 Stream ()
 Default constructor.
 
virtual ~Stream ()
 Virtual destructor.
 
virtual int available ()=0
 Get the number of bytes available to read. More...
 
virtual int availableForWrite ()
 Get the number of bytes available in the write buffer. More...
 
void clearWriteError ()
 Clear the write error state.
 
bool find (char target)
 Search for a single character in the stream. More...
 
bool find (const char *target)
 Search for a string in the stream. More...
 
bool find (const char *target, size_t length)
 Search for a string of given length in the stream. More...
 
bool find (const uint8_t *target, size_t length)
 Search for a string of given length in the stream (uint8_t variant) More...
 
bool find (uint8_t *target)
 Search for a string in the stream (uint8_t variant) More...
 
bool findUntil (const char *target, const char *terminator)
 Search for a string until a terminator is found. More...
 
bool findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen)
 Search for a string of given length until a terminator is found. More...
 
bool findUntil (const uint8_t *target, const char *terminator)
 Search for a string until a terminator is found (uint8_t variant) More...
 
bool findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
 Search for a string of given length until a terminator is found (uint8_t variant) More...
 
virtual void flush ()
 Flush the output buffer. More...
 
Report getLastSendReport () const
 Get the result of the last send operation. More...
 
unsigned long getTimeout () const
 Get the current timeout setting. More...
 
int getWriteError ()
 Get the current write error state. More...
 
virtual bool hasPeekBufferAPI () const
 Check if this stream implements the peek buffer API. More...
 
virtual bool inputCanTimeout ()
 Check if input operations can timeout. More...
 
virtual bool outputCanTimeout ()
 Check if the output can timeout. More...
 
float parseFloat ()
 Parse a float from the stream. More...
 
long parseInt ()
 Parse an integer from the stream. More...
 
virtual int peek ()=0
 Peek at the next byte without removing it from the stream. More...
 
virtual size_t peekAvailable ()
 Get the number of bytes available in the peek buffer. More...
 
virtual const char * peekBuffer ()
 Get a pointer to the peek buffer. More...
 
virtual void peekConsume (size_t consume)
 Consume bytes from the peek buffer. More...
 
size_t print (char)
 Print a single character. More...
 
size_t size_t size_t print (const __FlashStringHelper *)
 Print a flash string. More...
 
size_t print (const char[])
 Print a null-terminated string. More...
 
size_t print (const Printable &)
 Print a Printable object. More...
 
size_t print (const String &)
 Print a String object. More...
 
size_t print (double, int=2)
 Print a floating point value. More...
 
size_t print (int, int=DEC)
 Print an integer value. More...
 
size_t print (long long, int=DEC)
 Print a long long integer value. More...
 
size_t print (long, int=DEC)
 Print a long integer value. More...
 
size_t print (unsigned char, int=DEC)
 Print an unsigned byte value. More...
 
size_t print (unsigned int, int=DEC)
 Print an unsigned integer value. More...
 
size_t print (unsigned long long, int=DEC)
 Print an unsigned long long integer value. More...
 
size_t print (unsigned long, int=DEC)
 Print an unsigned long integer value. More...
 
size_t printf (const char *format,...) __attribute__((format(printf
 Print formatted data (printf style) More...
 
size_t size_t printf_P (PGM_P format,...) __attribute__((format(printf
 Print formatted data from program memory (printf style) More...
 
size_t println (char)
 Print a single character followed by a newline. More...
 
size_t println (const __FlashStringHelper *)
 Print a flash string followed by a newline. More...
 
size_t println (const char[])
 Print a null-terminated string followed by a newline. More...
 
size_t println (const Printable &)
 Print a Printable object followed by a newline. More...
 
size_t println (const String &s)
 Print a String object followed by a newline. More...
 
size_t println (double, int=2)
 Print a floating point value followed by a newline. More...
 
size_t println (int, int=DEC)
 Print an integer value followed by a newline. More...
 
size_t println (long long, int=DEC)
 Print a long long integer value followed by a newline. More...
 
size_t println (long, int=DEC)
 Print a long integer value followed by a newline. More...
 
size_t println (unsigned char, int=DEC)
 Print an unsigned byte value followed by a newline. More...
 
size_t println (unsigned int, int=DEC)
 Print an unsigned integer value followed by a newline. More...
 
size_t println (unsigned long long, int=DEC)
 Print an unsigned long long integer value followed by a newline. More...
 
size_t println (unsigned long, int=DEC)
 Print an unsigned long integer value followed by a newline. More...
 
size_t println (void)
 Print just a newline. More...
 
template<>
size_t printNumber (double number, uint8_t digits)
 Specialized template for printing floating point numbers. More...
 
virtual int read ()=0
 Read a single byte from the stream. More...
 
int read (char *buffer, size_t len)
 Read multiple bytes from the stream (char variant) More...
 
virtual int read (uint8_t *buffer, size_t len)
 Read multiple bytes from the stream. More...
 
virtual size_t readBytes (char *buffer, size_t length)
 Read bytes from the stream into a buffer. More...
 
virtual size_t readBytes (uint8_t *buffer, size_t length)
 Read bytes from the stream into a buffer (uint8_t variant) More...
 
size_t readBytesUntil (char terminator, char *buffer, size_t length)
 Read bytes until a terminator character is found. More...
 
size_t readBytesUntil (char terminator, uint8_t *buffer, size_t length)
 Read bytes until a terminator character is found (uint8_t variant) More...
 
virtual String readString ()
 Read a string from the stream. More...
 
String readStringUntil (char terminator)
 Read a string until a terminator character is found. More...
 
String readStringUntil (const char *terminator, uint32_t untilTotalNumberOfOccurrences=1)
 Read a string until a terminator string is found a specific number of times. More...
 
size_t sendAll (Print &to, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer all data with timeout (deprecated) More...
 
size_t sendAll (Print *to, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer all data with timeout (deprecated) More...
 
size_t sendAll (Stream &&to, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer all data with timeout. More...
 
size_t sendAll (Stream &to, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer all data with timeout. More...
 
size_t sendAll (Stream *to, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer all data with timeout. More...
 
size_t sendAvailable (Print &to)
 Transfer available data without waiting (deprecated) More...
 
size_t sendAvailable (Print *to)
 Transfer available data without waiting (deprecated) More...
 
size_t sendAvailable (Stream &&to)
 Transfer available data without waiting. More...
 
size_t sendAvailable (Stream &to)
 Transfer available data without waiting. More...
 
size_t sendAvailable (Stream *to)
 Transfer available data without waiting. More...
 
size_t sendSize (Print &to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer a specific amount of data with timeout (deprecated) More...
 
size_t sendSize (Print *to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer a specific amount of data with timeout (deprecated) More...
 
size_t sendSize (Stream &&to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer a specific amount of data with timeout. More...
 
size_t sendSize (Stream &to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer a specific amount of data with timeout. More...
 
size_t sendSize (Stream *to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer a specific amount of data with timeout. More...
 
size_t sendUntil (Print &to, const int readUntilChar, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer data until a specific character is found (deprecated) More...
 
size_t sendUntil (Print *to, const int readUntilChar, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer data until a specific character is found (deprecated) More...
 
size_t sendUntil (Stream &&to, const int readUntilChar, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer data until a specific character is found. More...
 
size_t sendUntil (Stream &to, const int readUntilChar, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer data until a specific character is found. More...
 
size_t sendUntil (Stream *to, const int readUntilChar, const oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Transfer data until a specific character is found. More...
 
void setTimeout (unsigned long timeout)
 Set the timeout for stream operations. More...
 
virtual ssize_t streamRemaining ()
 Get the number of bytes remaining in the stream. More...
 
size_t write (char c)
 Write a char value as a byte. More...
 
size_t write (const char *buffer, size_t size)
 Write a buffer of characters to the output. More...
 
size_t write (const char *str)
 Write a null-terminated string to the output. More...
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Write a buffer of bytes to the output. More...
 
size_t write (int t)
 Write an int value as a byte. More...
 
size_t write (int8_t c)
 Write a signed byte as an unsigned byte. More...
 
size_t write (long long t)
 Write a long long value as a byte. More...
 
size_t write (long t)
 Write a long value as a byte. More...
 
size_t write (short t)
 Write a short value as a byte. More...
 
virtual size_t write (uint8_t)=0
 Write a single byte to the output. More...
 
size_t write (unsigned int t)
 Write an unsigned int value as a byte. More...
 
size_t write (unsigned long long t)
 Write an unsigned long long value as a byte. More...
 
size_t write (unsigned long t)
 Write an unsigned long value as a byte. More...
 
size_t write (unsigned short t)
 Write an unsigned short value as a byte. More...
 

Static Public Attributes

static constexpr int temporaryStackBufferSize = 64
 Size of temporary stack buffer for stream transfers.
 

Protected Member Functions

float parseFloat (char skipChar)
 Parse a float with custom skip character. More...
 
long parseInt (char skipChar)
 Parse an integer with custom skip character. More...
 
int peekNextDigit (bool detectDecimal=false)
 Peek at the next digit in the stream. More...
 
size_t sendGeneric (Print *to, const ssize_t len=-1, const int readUntilChar=-1, oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Generic transfer method for Print objects (deprecated) More...
 
size_t sendGeneric (Stream *to, const ssize_t len=-1, const int readUntilChar=-1, oneShotMs::timeType timeoutMs=oneShotMs::neverExpires)
 Generic transfer method for Stream objects. More...
 
size_t SendGenericPeekBuffer (Print *to, const ssize_t len, const int readUntilChar, const oneShotMs::timeType timeoutMs)
 Transfer using peek buffer API. More...
 
size_t SendGenericRegular (Print *to, const ssize_t len, const oneShotMs::timeType timeoutMs)
 Transfer using regular read. More...
 
size_t SendGenericRegularUntil (Print *to, const ssize_t len, const int readUntilChar, const oneShotMs::timeType timeoutMs)
 Transfer using regular read until character. More...
 
void setReport (Report report)
 Set the result of a send operation. More...
 
void setWriteError (int err=1)
 Set the write error flag. More...
 
int timedPeek ()
 Peek at the next character with timeout. More...
 
int timedRead ()
 Read a character with timeout. More...
 

Protected Attributes

unsigned long _startMillis
 Used for timeout measurement.
 
unsigned long _timeout = 1000
 Number of milliseconds to wait for the next char before aborting timed read.
 

Detailed Description

Base class for all character and binary stream operations.

The Stream class adds buffering, timeout management, parsing operations, and data transfer capabilities to the basic Print class. It provides methods for reading and manipulating data from streams such as Serial ports, network connections, and files.

Member Enumeration Documentation

◆ Report

enum Stream::Report
strong

Status codes for stream transfer operations.

Enumerator
Success 

Operation completed successfully.

TimedOut 

Operation timed out.

ReadError 

Error reading from source.

WriteError 

Error writing to destination.

ShortOperation 

Operation completed but transferred less than requested.

Member Function Documentation

◆ available()

virtual int Stream::available ( )
pure virtual

Get the number of bytes available to read.

Returns
Number of bytes available

Implemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ availableForWrite()

virtual int Print::availableForWrite ( )
inlinevirtualinherited

Get the number of bytes available in the write buffer.

Returns
The number of bytes available in the write buffer (0 by default)
Note
Subclasses should override this if they implement buffering

Reimplemented in esp32_psram::RingBufferStream< VectorType >.

◆ find() [1/5]

bool Stream::find ( char  target)
inline

Search for a single character in the stream.

Parameters
targetCharacter to search for
Returns
true if found, false if timed out

◆ find() [2/5]

bool Stream::find ( const char *  target)

Search for a string in the stream.

Parameters
targetThe string to search for
Returns
true if found, false if timed out

◆ find() [3/5]

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

Search for a string of given length in the stream.

Parameters
targetThe string to search for
lengthLength of the target string
Returns
true if found, false if timed out

◆ find() [4/5]

bool Stream::find ( const uint8_t *  target,
size_t  length 
)
inline

Search for a string of given length in the stream (uint8_t variant)

Parameters
targetThe string to search for
lengthLength of the target string
Returns
true if found, false if timed out

◆ find() [5/5]

bool Stream::find ( uint8_t *  target)
inline

Search for a string in the stream (uint8_t variant)

Parameters
targetThe string to search for
Returns
true if found, false if timed out

◆ findUntil() [1/4]

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

Search for a string until a terminator is found.

Parameters
targetThe string to search for
terminatorString that terminates the search
Returns
true if target found, false if timed out or terminator found first

◆ findUntil() [2/4]

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

Search for a string of given length until a terminator is found.

Parameters
targetThe string to search for
targetLenLength of the target string
terminateString that terminates the search
termLenLength of the terminator string
Returns
true if target found, false if timed out or terminator found first

◆ findUntil() [3/4]

bool Stream::findUntil ( const uint8_t *  target,
const char *  terminator 
)
inline

Search for a string until a terminator is found (uint8_t variant)

Parameters
targetThe string to search for
terminatorString that terminates the search
Returns
true if target found, false if timed out or terminator found first

◆ findUntil() [4/4]

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

Search for a string of given length until a terminator is found (uint8_t variant)

Parameters
targetThe string to search for
targetLenLength of the target string
terminateString that terminates the search
termLenLength of the terminator string
Returns
true if target found, false if timed out or terminator found first

◆ flush()

virtual void Print::flush ( )
inlinevirtualinherited

Flush the output buffer.

This function should wait for all outgoing characters to be sent. The output buffer should be empty after this call. Empty implementation by default in Print class.

Reimplemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ getLastSendReport()

Report Stream::getLastSendReport ( ) const
inline

Get the result of the last send operation.

Returns
Status code indicating success or failure reason

◆ getTimeout()

unsigned long Stream::getTimeout ( ) const
inline

Get the current timeout setting.

Returns
Current timeout in milliseconds

◆ getWriteError()

int Print::getWriteError ( )
inlineinherited

Get the current write error state.

Returns
Current error code (0 = no error)

◆ hasPeekBufferAPI()

virtual bool Stream::hasPeekBufferAPI ( ) const
inlinevirtual

Check if this stream implements the peek buffer API.

Returns
true if peek buffer API is available, false otherwise

◆ inputCanTimeout()

virtual bool Stream::inputCanTimeout ( )
inlinevirtual

Check if input operations can timeout.

Returns
true if input operations can timeout, false otherwise

◆ outputCanTimeout()

virtual bool Print::outputCanTimeout ( )
inlinevirtualinherited

Check if the output can timeout.

By default, write operations can timeout (like for network or serial). Child classes can override this to false (like String).

Returns
true if output operations can timeout, false otherwise

◆ parseFloat() [1/2]

float Stream::parseFloat ( )

Parse a float from the stream.

Returns
The first valid floating point value from the current position
Note
Skips non-digit characters and stops at first non-digit after a number

◆ parseFloat() [2/2]

float Stream::parseFloat ( char  skipChar)
protected

Parse a float with custom skip character.

Parameters
skipCharCharacter to ignore during parsing
Returns
The parsed float value

◆ parseInt() [1/2]

long Stream::parseInt ( )

Parse an integer from the stream.

Returns
The first valid integer value from the current position
Note
Skips non-digit characters and stops at first non-digit after a number

◆ parseInt() [2/2]

long Stream::parseInt ( char  skipChar)
protected

Parse an integer with custom skip character.

Parameters
skipCharCharacter to ignore during parsing
Returns
The parsed integer value

◆ peek()

virtual int Stream::peek ( )
pure virtual

Peek at the next byte without removing it from the stream.

Returns
The next byte, or -1 if no data available

Implemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ peekAvailable()

virtual size_t Stream::peekAvailable ( )
inlinevirtual

Get the number of bytes available in the peek buffer.

Returns
Number of bytes available

◆ peekBuffer()

virtual const char* Stream::peekBuffer ( )
inlinevirtual

Get a pointer to the peek buffer.

Returns
Pointer to the peek buffer, or nullptr if not available
Note
Don't call read() between peekBuffer() and peekConsume()

◆ peekConsume()

virtual void Stream::peekConsume ( size_t  consume)
inlinevirtual

Consume bytes from the peek buffer.

Parameters
consumeNumber of bytes to consume

◆ peekNextDigit()

int Stream::peekNextDigit ( bool  detectDecimal = false)
protected

Peek at the next digit in the stream.

Parameters
detectDecimalWhether to consider decimal points as valid parts of numbers
Returns
The next numeric digit or -1 if timeout or non-digit

◆ print() [1/13]

size_t Print::print ( char  )
inherited

Print a single character.

Parameters
cCharacter to print
Returns
Number of bytes written

◆ print() [2/13]

size_t size_t size_t Print::print ( const __FlashStringHelper *  )
inherited

Print a flash string.

Parameters
strFlash string to print
Returns
Number of bytes written

◆ print() [3/13]

size_t Print::print ( const char  [])
inherited

Print a null-terminated string.

Parameters
strString to print
Returns
Number of bytes written

◆ print() [4/13]

size_t Print::print ( const Printable &  )
inherited

Print a Printable object.

Parameters
objObject to print
Returns
Number of bytes written

◆ print() [5/13]

size_t Print::print ( const String &  )
inherited

Print a String object.

Parameters
sString to print
Returns
Number of bytes written

◆ print() [6/13]

size_t Print::print ( double  ,
int  = 2 
)
inherited

Print a floating point value.

Parameters
nValue to print
digitsNumber of decimal places to display (default: 2)
Returns
Number of bytes written

◆ print() [7/13]

size_t Print::print ( int  ,
int  = DEC 
)
inherited

Print an integer value.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ print() [8/13]

size_t Print::print ( long long  ,
int  = DEC 
)
inherited

Print a long long integer value.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ print() [9/13]

size_t Print::print ( long  ,
int  = DEC 
)
inherited

Print a long integer value.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ print() [10/13]

size_t Print::print ( unsigned char  ,
int  = DEC 
)
inherited

Print an unsigned byte value.

Parameters
bValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ print() [11/13]

size_t Print::print ( unsigned int  ,
int  = DEC 
)
inherited

Print an unsigned integer value.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ print() [12/13]

size_t Print::print ( unsigned long long  ,
int  = DEC 
)
inherited

Print an unsigned long long integer value.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ print() [13/13]

size_t Print::print ( unsigned long  ,
int  = DEC 
)
inherited

Print an unsigned long integer value.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ printf()

size_t Print::printf ( const char *  format,
  ... 
)
inherited

Print formatted data (printf style)

Parameters
formatFormat string
...Variable arguments for format string
Returns
Number of bytes written

◆ printf_P()

size_t size_t Print::printf_P ( PGM_P  format,
  ... 
)
inherited

Print formatted data from program memory (printf style)

Parameters
formatFormat string in program memory
...Variable arguments for format string
Returns
Number of bytes written

◆ println() [1/14]

size_t Print::println ( char  )
inherited

Print a single character followed by a newline.

Parameters
cCharacter to print
Returns
Number of bytes written

◆ println() [2/14]

size_t Print::println ( const __FlashStringHelper *  )
inherited

Print a flash string followed by a newline.

Parameters
strFlash string to print
Returns
Number of bytes written

◆ println() [3/14]

size_t Print::println ( const char  [])
inherited

Print a null-terminated string followed by a newline.

Parameters
strString to print
Returns
Number of bytes written

◆ println() [4/14]

size_t Print::println ( const Printable &  )
inherited

Print a Printable object followed by a newline.

Parameters
objObject to print
Returns
Number of bytes written

◆ println() [5/14]

size_t Print::println ( const String &  s)
inherited

Print a String object followed by a newline.

Parameters
sString to print
Returns
Number of bytes written

◆ println() [6/14]

size_t Print::println ( double  ,
int  = 2 
)
inherited

Print a floating point value followed by a newline.

Parameters
nValue to print
digitsNumber of decimal places to display (default: 2)
Returns
Number of bytes written

◆ println() [7/14]

size_t Print::println ( int  ,
int  = DEC 
)
inherited

Print an integer value followed by a newline.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [8/14]

size_t Print::println ( long long  ,
int  = DEC 
)
inherited

Print a long long integer value followed by a newline.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [9/14]

size_t Print::println ( long  ,
int  = DEC 
)
inherited

Print a long integer value followed by a newline.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [10/14]

size_t Print::println ( unsigned char  ,
int  = DEC 
)
inherited

Print an unsigned byte value followed by a newline.

Parameters
bValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [11/14]

size_t Print::println ( unsigned int  ,
int  = DEC 
)
inherited

Print an unsigned integer value followed by a newline.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [12/14]

size_t Print::println ( unsigned long long  ,
int  = DEC 
)
inherited

Print an unsigned long long integer value followed by a newline.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [13/14]

size_t Print::println ( unsigned long  ,
int  = DEC 
)
inherited

Print an unsigned long integer value followed by a newline.

Parameters
nValue to print
baseNumber base to use (default: DEC)
Returns
Number of bytes written

◆ println() [14/14]

size_t Print::println ( void  )
inherited

Print just a newline.

Returns
Number of bytes written

◆ printNumber()

template<>
size_t Print::printNumber ( double  number,
uint8_t  digits 
)
inherited

Specialized template for printing floating point numbers.

Parameters
numberThe floating point number to print
digitsThe number of decimal places to display
Returns
Number of bytes written

◆ read() [1/3]

virtual int Stream::read ( )
pure virtual

Read a single byte from the stream.

Returns
The next byte, or -1 if no data available

Implemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ read() [2/3]

int Stream::read ( char *  buffer,
size_t  len 
)
inline

Read multiple bytes from the stream (char variant)

Parameters
bufferBuffer to store the data
lenMaximum number of bytes to read
Returns
Number of bytes read

◆ read() [3/3]

virtual int Stream::read ( uint8_t *  buffer,
size_t  len 
)
virtual

Read multiple bytes from the stream.

Parameters
bufferBuffer to store the data
lenMaximum number of bytes to read
Returns
Number of bytes read

◆ readBytes() [1/2]

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

Read bytes from the stream into a buffer.

Parameters
bufferBuffer to store the data
lengthMaximum number of bytes to read
Returns
Number of bytes read (0 means no valid data found)

Reimplemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ readBytes() [2/2]

virtual size_t Stream::readBytes ( uint8_t *  buffer,
size_t  length 
)
inlinevirtual

Read bytes from the stream into a buffer (uint8_t variant)

Parameters
bufferBuffer to store the data
lengthMaximum number of bytes to read
Returns
Number of bytes read (0 means no valid data found)

Reimplemented in esp32_psram::RingBufferStream< VectorType >.

◆ readBytesUntil() [1/2]

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

Read bytes until a terminator character is found.

Parameters
terminatorCharacter that terminates the read
bufferBuffer to store the data
lengthMaximum number of bytes to read
Returns
Number of bytes read (0 means no valid data found)

◆ readBytesUntil() [2/2]

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

Read bytes until a terminator character is found (uint8_t variant)

Parameters
terminatorCharacter that terminates the read
bufferBuffer to store the data
lengthMaximum number of bytes to read
Returns
Number of bytes read (0 means no valid data found)

◆ readString()

virtual String Stream::readString ( )
virtual

Read a string from the stream.

Returns
String containing the data read

◆ readStringUntil() [1/2]

String Stream::readStringUntil ( char  terminator)

Read a string until a terminator character is found.

Parameters
terminatorCharacter that terminates the read
Returns
String containing the data read

◆ readStringUntil() [2/2]

String Stream::readStringUntil ( const char *  terminator,
uint32_t  untilTotalNumberOfOccurrences = 1 
)

Read a string until a terminator string is found a specific number of times.

Parameters
terminatorString that terminates the read
untilTotalNumberOfOccurrencesNumber of times the terminator must be found
Returns
String containing the data read

◆ sendAll() [1/5]

size_t Stream::sendAll ( Print to,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer all data with timeout (deprecated)

Parameters
toDestination stream
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendAll() [2/5]

size_t Stream::sendAll ( Print to,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer all data with timeout (deprecated)

Parameters
toDestination stream
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendAll() [3/5]

size_t Stream::sendAll ( Stream &&  to,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer all data with timeout.

Parameters
toDestination stream
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendAll() [4/5]

size_t Stream::sendAll ( Stream to,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer all data with timeout.

Parameters
toDestination stream
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendAll() [5/5]

size_t Stream::sendAll ( Stream to,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer all data with timeout.

Parameters
toDestination stream
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendAvailable() [1/5]

size_t Stream::sendAvailable ( Print to)
inline

Transfer available data without waiting (deprecated)

Parameters
toDestination stream
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendAvailable() [2/5]

size_t Stream::sendAvailable ( Print to)
inline

Transfer available data without waiting (deprecated)

Parameters
toDestination stream
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendAvailable() [3/5]

size_t Stream::sendAvailable ( Stream &&  to)
inline

Transfer available data without waiting.

Parameters
toDestination stream
Returns
Number of bytes transferred

◆ sendAvailable() [4/5]

size_t Stream::sendAvailable ( Stream to)
inline

Transfer available data without waiting.

Parameters
toDestination stream
Returns
Number of bytes transferred

◆ sendAvailable() [5/5]

size_t Stream::sendAvailable ( Stream to)
inline

Transfer available data without waiting.

Parameters
toDestination stream
Returns
Number of bytes transferred

◆ sendGeneric() [1/2]

size_t Stream::sendGeneric ( Print to,
const ssize_t  len = -1,
const int  readUntilChar = -1,
oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
protected

Generic transfer method for Print objects (deprecated)

Parameters
toDestination stream
lenMaximum number of bytes to transfer (-1 for unlimited)
readUntilCharCharacter to stop at (-1 for none)
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendGeneric() [2/2]

size_t Stream::sendGeneric ( Stream to,
const ssize_t  len = -1,
const int  readUntilChar = -1,
oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
protected

Generic transfer method for Stream objects.

Parameters
toDestination stream
lenMaximum number of bytes to transfer (-1 for unlimited)
readUntilCharCharacter to stop at (-1 for none)
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ SendGenericPeekBuffer()

size_t Stream::SendGenericPeekBuffer ( Print to,
const ssize_t  len,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs 
)
protected

Transfer using peek buffer API.

Parameters
toDestination stream
lenMaximum number of bytes to transfer
readUntilCharCharacter to stop at
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ SendGenericRegular()

size_t Stream::SendGenericRegular ( Print to,
const ssize_t  len,
const oneShotMs::timeType  timeoutMs 
)
protected

Transfer using regular read.

Parameters
toDestination stream
lenMaximum number of bytes to transfer
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ SendGenericRegularUntil()

size_t Stream::SendGenericRegularUntil ( Print to,
const ssize_t  len,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs 
)
protected

Transfer using regular read until character.

Parameters
toDestination stream
lenMaximum number of bytes to transfer
readUntilCharCharacter to stop at
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendSize() [1/5]

size_t Stream::sendSize ( Print to,
const ssize_t  maxLen,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer a specific amount of data with timeout (deprecated)

Parameters
toDestination stream
maxLenMaximum number of bytes to transfer
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendSize() [2/5]

size_t Stream::sendSize ( Print to,
const ssize_t  maxLen,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer a specific amount of data with timeout (deprecated)

Parameters
toDestination stream
maxLenMaximum number of bytes to transfer
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendSize() [3/5]

size_t Stream::sendSize ( Stream &&  to,
const ssize_t  maxLen,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer a specific amount of data with timeout.

Parameters
toDestination stream
maxLenMaximum number of bytes to transfer
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendSize() [4/5]

size_t Stream::sendSize ( Stream to,
const ssize_t  maxLen,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer a specific amount of data with timeout.

Parameters
toDestination stream
maxLenMaximum number of bytes to transfer
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendSize() [5/5]

size_t Stream::sendSize ( Stream to,
const ssize_t  maxLen,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer a specific amount of data with timeout.

Parameters
toDestination stream
maxLenMaximum number of bytes to transfer
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendUntil() [1/5]

size_t Stream::sendUntil ( Print to,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer data until a specific character is found (deprecated)

Parameters
toDestination stream
readUntilCharCharacter to stop at
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendUntil() [2/5]

size_t Stream::sendUntil ( Print to,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer data until a specific character is found (deprecated)

Parameters
toDestination stream
readUntilCharCharacter to stop at
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred
Deprecated:
Use the Stream* variant instead

◆ sendUntil() [3/5]

size_t Stream::sendUntil ( Stream &&  to,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer data until a specific character is found.

Parameters
toDestination stream
readUntilCharCharacter to stop at (the character is read but not transferred)
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendUntil() [4/5]

size_t Stream::sendUntil ( Stream to,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer data until a specific character is found.

Parameters
toDestination stream
readUntilCharCharacter to stop at (the character is read but not transferred)
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ sendUntil() [5/5]

size_t Stream::sendUntil ( Stream to,
const int  readUntilChar,
const oneShotMs::timeType  timeoutMs = oneShotMs::neverExpires 
)
inline

Transfer data until a specific character is found.

Parameters
toDestination stream
readUntilCharCharacter to stop at (the character is read but not transferred)
timeoutMsTimeout in milliseconds
Returns
Number of bytes transferred

◆ setReport()

void Stream::setReport ( Report  report)
inlineprotected

Set the result of a send operation.

Parameters
reportStatus code to set

◆ setTimeout()

void Stream::setTimeout ( unsigned long  timeout)

Set the timeout for stream operations.

Parameters
timeoutMaximum milliseconds to wait for stream data

◆ setWriteError()

void Print::setWriteError ( int  err = 1)
inlineprotectedinherited

Set the write error flag.

Parameters
errError code to set (default: 1)

◆ streamRemaining()

virtual ssize_t Stream::streamRemaining ( )
inlinevirtual

Get the number of bytes remaining in the stream.

Returns
Number of bytes remaining, or -1 if unknown

◆ timedPeek()

int Stream::timedPeek ( )
protected

Peek at the next character with timeout.

Returns
The next character or -1 if timeout

◆ timedRead()

int Stream::timedRead ( )
protected

Read a character with timeout.

Returns
The read character or -1 if timeout

◆ write() [1/14]

size_t Print::write ( char  c)
inlineinherited

Write a char value as a byte.

Parameters
cCharacter to write
Returns
Number of bytes written

◆ write() [2/14]

size_t Print::write ( const char *  buffer,
size_t  size 
)
inlineinherited

Write a buffer of characters to the output.

Parameters
bufferPointer to the character buffer
sizeNumber of characters to write
Returns
Number of bytes written

◆ write() [3/14]

size_t Print::write ( const char *  str)
inlineinherited

Write a null-terminated string to the output.

Parameters
strPointer to the string to write
Returns
Number of bytes written

◆ write() [4/14]

virtual size_t Print::write ( const uint8_t *  buffer,
size_t  size 
)
virtualinherited

Write a buffer of bytes to the output.

Parameters
bufferPointer to the data to write
sizeNumber of bytes to write
Returns
Number of bytes written

Reimplemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ write() [5/14]

size_t Print::write ( int  t)
inlineinherited

Write an int value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [6/14]

size_t Print::write ( int8_t  c)
inlineinherited

Write a signed byte as an unsigned byte.

Parameters
cByte to write
Returns
Number of bytes written

◆ write() [7/14]

size_t Print::write ( long long  t)
inlineinherited

Write a long long value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [8/14]

size_t Print::write ( long  t)
inlineinherited

Write a long value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [9/14]

size_t Print::write ( short  t)
inlineinherited

Write a short value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [10/14]

virtual size_t Print::write ( uint8_t  )
pure virtualinherited

Write a single byte to the output.

Parameters
bThe byte to write
Returns
Number of bytes written (1 on success, 0 on failure)
Note
This is a pure virtual function that must be implemented by subclasses

Implemented in esp32_psram::RingBufferStream< VectorType >, and esp32_psram::InMemoryFile< VectorType >.

◆ write() [11/14]

size_t Print::write ( unsigned int  t)
inlineinherited

Write an unsigned int value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [12/14]

size_t Print::write ( unsigned long long  t)
inlineinherited

Write an unsigned long long value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [13/14]

size_t Print::write ( unsigned long  t)
inlineinherited

Write an unsigned long value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

◆ write() [14/14]

size_t Print::write ( unsigned short  t)
inlineinherited

Write an unsigned short value as a byte.

Parameters
tValue to write
Returns
Number of bytes written

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