Provides formatted output to stream. More...

#include <Print.h>

Inheritance diagram for Print:

Classes

class  has_printTo
 

Public Member Functions

virtual ~Print ()
 
int getWriteError ()
 Gets last error. More...
 
void clearWriteError ()
 Clears the last write error. More...
 
virtual size_t write (uint8_t c)=0
 Writes a single character to output stream. More...
 
size_t write (const char *str)
 Writes a c-string to output stream. More...
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Writes characters from a buffer to output stream. More...
 
size_t write (const char *buffer, size_t size)
 Writes characters from a buffer to output stream. More...
 
size_t print (char c)
 Prints a single character to output stream. More...
 
size_t print (const char str[])
 Prints a c-string to output stream. More...
 
size_t print (double num, int digits=2)
 Print a floating-point number to output stream. More...
 
template<typename T >
std::enable_if< has_printTo< T >::value, size_t >::type print (const T &obj)
 Prints a Printable object to output stream. More...
 
size_t print (const String &s)
 Prints a String to output stream. More...
 
template<typename E >
std::enable_if< std::is_enum< E >::value &&!std::is_convertible< E, int >::value, size_t >::type print (E value)
 enums can be printed as strings provided they have a toString(E) implementation. More...
 
size_t println ()
 Prints a newline to output stream. More...
 
template<typename... Args>
size_t println (const Args &... args)
 Print value plus newline to output stream. More...
 
size_t printf (const char *fmt,...)
 Prints a formatted c-string to output stream. More...
 
Print an integral number to output stream
Parameters
numNumber to print
baseThe base for output (Default: Decimal (base 10))
Return values
size_tQuantity of characters written to stream
size_t print (unsigned long num, uint8_t base=DEC)
 
template<typename... Args>
size_t print (unsigned long num, Args... args)
 
template<typename... Args>
size_t print (const unsigned long long &num, Args... args)
 
size_t print (long num, uint8_t base=DEC)
 
template<typename... Args>
size_t print (long num, Args... args)
 
template<typename... Args>
size_t print (const long long &num, Args... args)
 
template<typename... Args>
size_t print (unsigned int num, Args... args)
 
template<typename... Args>
size_t print (unsigned char num, Args... args)
 
template<typename... Args>
size_t print (int num, Args... args)
 

Protected Member Functions

void setWriteError (int err=1)
 

Detailed Description

Provides formatted output to stream.

Constructor & Destructor Documentation

◆ ~Print()

virtual Print::~Print ( )
inlinevirtual

Member Function Documentation

◆ clearWriteError()

void Print::clearWriteError ( )
inline

Clears the last write error.

◆ getWriteError()

int Print::getWriteError ( )
inline

Gets last error.

Return values
intError number of last write error

◆ print() [1/15]

size_t Print::print ( char  c)
inline

Prints a single character to output stream.

Parameters
cCharacter to print
Return values
size_tQuantity of characters written to stream

◆ print() [2/15]

size_t Print::print ( const char  str[])
inline

Prints a c-string to output stream.

Parameters
strc-string to print
Return values
size_tQuantity of characters written to output stream

◆ print() [3/15]

template<typename... Args>
size_t Print::print ( const long long &  num,
Args...  args 
)
inline

◆ print() [4/15]

size_t Print::print ( const String s)
inline

Prints a String to output stream.

Parameters
sString to print
Return values
size_tQuantity of characters written to stream

◆ print() [5/15]

template<typename T >
std::enable_if<has_printTo<T>::value, size_t>::type Print::print ( const T &  obj)
inline

Prints a Printable object to output stream.

Parameters
objObject to print
Return values
size_tQuantity of characters written to stream

◆ print() [6/15]

template<typename... Args>
size_t Print::print ( const unsigned long long &  num,
Args...  args 
)
inline

◆ print() [7/15]

size_t Print::print ( double  num,
int  digits = 2 
)
inline

Print a floating-point number to output stream.

Parameters
numNumber to print
digitsThe decimal places to print (Default: 2, e.g. 21.35)
Return values
size_tQuantity of characters written to stream

◆ print() [8/15]

template<typename E >
std::enable_if<std::is_enum<E>::value && !std::is_convertible<E, int>::value, size_t>::type Print::print ( value)
inline

enums can be printed as strings provided they have a toString(E) implementation.

◆ print() [9/15]

template<typename... Args>
size_t Print::print ( int  num,
Args...  args 
)
inline

◆ print() [10/15]

template<typename... Args>
size_t Print::print ( long  num,
Args...  args 
)
inline

◆ print() [11/15]

size_t Print::print ( long  num,
uint8_t  base = DEC 
)
inline

◆ print() [12/15]

template<typename... Args>
size_t Print::print ( unsigned char  num,
Args...  args 
)
inline

◆ print() [13/15]

template<typename... Args>
size_t Print::print ( unsigned int  num,
Args...  args 
)
inline

◆ print() [14/15]

template<typename... Args>
size_t Print::print ( unsigned long  num,
Args...  args 
)
inline

◆ print() [15/15]

size_t Print::print ( unsigned long  num,
uint8_t  base = DEC 
)
inline

◆ printf()

size_t Print::printf ( const char *  fmt,
  ... 
)

Prints a formatted c-string to output stream.

Parameters
fmtPointer to formatted c-string to print
...Parameters for placeholders within formatted string
Return values
size_tQuantity of characters written to stream
Note
Use standard printf placeholders, e.g. d for integer, s for c-string, etc.

◆ println() [1/2]

size_t Print::println ( )
inline

Prints a newline to output stream.

Return values
size_tQuantity of characters written to stream

◆ println() [2/2]

template<typename... Args>
size_t Print::println ( const Args &...  args)
inline

Print value plus newline to output stream.

Return values
size_tQuantity of characters written to stream

◆ setWriteError()

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

◆ write() [1/4]

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

Writes characters from a buffer to output stream.

Parameters
bufferPointer to character buffer
sizeQuantity of characters to write
Return values
size_tQuantity of characters written to stream

◆ write() [2/4]

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

Writes a c-string to output stream.

Parameters
strPointer to c-string
Return values
size_tQuantity of characters written to stream

◆ write() [3/4]

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

◆ write() [4/4]

virtual size_t Print::write ( uint8_t  c)
pure virtual

Writes a single character to output stream.

Parameters
cCharacter to write to output stream
Return values
size_tQuantity of characters written to output stream

Implemented in TwoWire, ReadWriteStream, IDataSourceStream, CircularBuffer, Graphics::TextBuilder, Graphics::Console, Hosted::Transport::TcpClientStream, Hosted::Serial, and Host::OutputStream.


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