COSA
An Object-Oriented Platform for Arduino Programming
|
#include <IOStream.hh>
Classes | |
class | Device |
Public Types | |
enum | Base { bcd = 0, bin = 2, oct = 8, dec = 10, hex = 16 } |
enum | Mode { CR_MODE = 0, LF_MODE = 1, CRLF_MODE = 2 } |
typedef IOStream &(* | Manipulator) (IOStream &) |
Public Member Functions | |
IOStream (Device *dev) | |
IOStream () | |
Device * | device () const |
Device * | device (Device *dev) |
str_P | eol () const |
str_P | EOL () const |
void | eol (str_P s) |
int8_t | width (int8_t value) |
uint8_t | precision (uint8_t value) |
void | print (int value, Base base=dec) |
void | print (long int value, Base base=dec) |
void | print (unsigned int value, Base base=dec) |
void | print (unsigned long int value, Base base=dec) |
void | print (unsigned int value, uint8_t digits, Base base) |
void | print (unsigned long int value, uint8_t digits, Base base) |
void | print (double value, int8_t width, uint8_t prec) |
void | print (uint32_t src, const void *ptr, size_t size, Base base=dec, uint8_t max=16) |
void | print (const void *ptr, size_t size, Base base=dec, uint8_t max=16) |
void | print (void *ptr) |
void | print (const void *ptr) |
void | print (char c) |
void | print (const char *s) |
void | print (str_P s) |
void | println () |
void | vprintf (str_P format, va_list args) |
void | printf (str_P format,...) |
void | print (IOStream::Device *buffer) |
void | flush () |
char * | scan (char *s, size_t count) |
char * | readline (char *buf, size_t size, bool echo=true) |
IOStream & | operator<< (Manipulator func) |
IOStream & | operator<< (int n) |
IOStream & | operator<< (long int n) |
IOStream & | operator<< (double n) |
IOStream & | operator<< (unsigned int n) |
IOStream & | operator<< (unsigned long int n) |
IOStream & | operator<< (void *ptr) |
IOStream & | operator<< (const void *ptr) |
IOStream & | operator<< (char c) |
IOStream & | operator<< (char *s) |
IOStream & | operator<< (const char *s) |
IOStream & | operator<< (str_P s) |
IOStream & | operator<< (IOStream &buffer) |
IOStream & | operator<< (const iovec_t *vec) |
Static Public Member Functions | |
static char * | ultoa (unsigned long __val, char *__s, int base) |
static char * | ltoa (long __val, char *__s, int base) |
static char * | utoa (unsigned int __val, char *__s, int base) |
static char * | itoa (int __val, char *__s, int base) |
Static Public Attributes | |
static const int | EOF = -1 |
static const char | CR [] |
static const char | LF [] = "\r" |
static const char | CRLF [] = "\r\n" |
Protected Member Functions | |
void | print_prefix (Base base) |
Protected Attributes | |
Device * | m_dev |
Delegated device. More... | |
Base | m_base |
Base for next output operator. More... | |
int8_t | m_width |
Minimum width of output string. More... | |
uint8_t | m_prec |
Number of digits after decimal sign. More... | |
str_P | m_eols |
End of line string (program memory). More... | |
Static Protected Attributes | |
static const size_t | BUF_MAX = sizeof(uint32_t) * CHARBITS + 1 |
Friends | |
IOStream & | bcd (IOStream &outs) |
IOStream & | bin (IOStream &outs) |
IOStream & | oct (IOStream &outs) |
IOStream & | dec (IOStream &outs) |
IOStream & | hex (IOStream &outs) |
IOStream & | flush (IOStream &outs) |
Basic in-/output stream support class. Requires implementation of Stream::Device.
Definition at line 30 of file IOStream.hh.
Stream manipulator function prototype. To allow implementation of base change and end of line.
[in] | iostream. |
Definition at line 538 of file IOStream.hh.
enum IOStream::Base |
enum IOStream::Mode |
IOStream::IOStream | ( | Device * | dev | ) |
Construct stream with given device.
[in] | dev | stream device. |
Definition at line 29 of file IOStream.cpp.
IOStream::IOStream | ( | ) |
Definition at line 37 of file IOStream.cpp.
|
inline |
Set io stream device.
[in] | dev | stream device. |
Definition at line 275 of file IOStream.hh.
|
inline |
Get io stream end of line string.
Definition at line 286 of file IOStream.hh.
|
inline |
Get io stream end of line string.
Definition at line 295 of file IOStream.hh.
|
inline |
Set io stream end of line string.
[in] | s | string for end of line. |
Definition at line 304 of file IOStream.hh.
|
inline |
Flush contents of iostream to stream.
Definition at line 504 of file IOStream.hh.
|
static |
Definition at line 144 of file IOStream_dtoa.cpp.
|
static |
Definition at line 129 of file IOStream_dtoa.cpp.
|
inline |
Output operator for stream manipulator. Apply function.
[in] | func | iostream manipulator. |
Definition at line 545 of file IOStream.hh.
|
inline |
Print integer as string in the current base to stream. Reset base to decimal.
[in] | n | value to print. |
Definition at line 556 of file IOStream.hh.
|
inline |
Print long integer as string in the current base to stream. Reset base to decimal.
[in] | n | value to print. |
Definition at line 569 of file IOStream.hh.
|
inline |
Print double as string with the current field min width and number of decimals. Reset base to decimal.
[in] | n | value to print. |
Definition at line 583 of file IOStream.hh.
|
inline |
Print unsigned integer as string in the current base to stream. Reset base to decimal.
[in] | n | value to print. |
Definition at line 596 of file IOStream.hh.
|
inline |
Print unsigned long integer as string in the current base to stream. Reset base to decimal.
[in] | n | value to print. |
Definition at line 609 of file IOStream.hh.
|
inline |
Print pointer as a hexadecimal number string to stream.
[in] | ptr | pointer to print. |
Definition at line 621 of file IOStream.hh.
|
inline |
Print program memory pointer as a hexadecimal number string to stream.
[in] | ptr | program memory pointer to print. |
Definition at line 634 of file IOStream.hh.
|
inline |
Print character to stream.
[in] | c | character to print. |
Definition at line 646 of file IOStream.hh.
|
inline |
Print null terminated string to stream.
[in] | s | string to print. |
Definition at line 657 of file IOStream.hh.
|
inline |
Print null terminated string in program memory to stream.
[in] | s | string in program memory to print. |
Definition at line 668 of file IOStream.hh.
Print null terminated string in program memory to stream.
[in] | s | string in program memory to print. |
Definition at line 679 of file IOStream.hh.
Print contents of iobuffer to stream.
[in] | buffer | input/output buffer. |
Definition at line 690 of file IOStream.hh.
Print contents of iovector to stream.
[in] | vec | iovector. |
Definition at line 701 of file IOStream.hh.
|
inline |
Set number of digits after decimal point for double numbers.
[in] | value | precision. |
Definition at line 327 of file IOStream.hh.
Print integer as string with given base to stream.
[in] | value | to print. |
[in] | base | to represent value in (default 10). |
Definition at line 46 of file IOStream.cpp.
Print long integer 32-bit value in given base torace stream.
[in] | value | to print. |
[in] | base | to represent value in (default 10). |
Definition at line 65 of file IOStream.cpp.
Print unsigned integer as string with given base to stream.
[in] | value | to print. |
[in] | base | to represent value in (default 10). |
Definition at line 73 of file IOStream.cpp.
Print unsigned long integer 32-bit value in given base to stream.
[in] | value | to print. |
[in] | base | to represent value in (default 10). |
Definition at line 81 of file IOStream.cpp.
void IOStream::print | ( | unsigned int | value, |
uint8_t | digits, | ||
Base | base | ||
) |
Print unsigned integer as string with given base to stream.
[in] | value | to print. |
[in] | digits | to print. |
[in] | base | to represent value in. |
Definition at line 89 of file IOStream.cpp.
void IOStream::print | ( | unsigned long int | value, |
uint8_t | digits, | ||
Base | base | ||
) |
Print unsigned long integer 32-bit value in given base to stream.
[in] | value | to print. |
[in] | digits | to print. |
[in] | base | to represent value in. |
Definition at line 99 of file IOStream.cpp.
void IOStream::print | ( | double | value, |
int8_t | width, | ||
uint8_t | prec | ||
) |
Print double with the minimum field width of the output string (including the '.' and the possible sign for negative values) is given in width, and prec determines the number of digits after the decimal sign. width is signed value, negative for left adjustment.
[in] | value | to print. |
[in] | width | minimum field width. |
[in] | prec | number of digits. |
Definition at line 109 of file IOStream.cpp.
void IOStream::print | ( | uint32_t | src, |
const void * | ptr, | ||
size_t | size, | ||
Base | base = dec , |
||
uint8_t | max = 16 |
||
) |
Print buffer contents in given base to stream.
[in] | src | address prefix. |
[in] | ptr | pointer to data memory. |
[in] | size | number of bytes. |
[in] | base | to represent value in (default 10). |
[in] | max | number of numbers per line (default 16). |
Definition at line 136 of file IOStream.cpp.
Print buffer contents in given base to stream.
[in] | ptr | pointer to data memory. |
[in] | size | number of bytes. |
[in] | base | to represent value in (default 10). |
[in] | max | number of numbers per line (default 16). |
Definition at line 408 of file IOStream.hh.
|
inline |
Print pointer as a hexadecimal number to stream.
[in] | ptr | pointer to data memory. |
Definition at line 418 of file IOStream.hh.
|
inline |
Print pointer to program memory as a hexadecimal number to stream.
[in] | ptr | pointer to program memory. |
Definition at line 428 of file IOStream.hh.
|
inline |
Print character to stream.
[in] | c | character to print. |
Definition at line 437 of file IOStream.hh.
|
inline |
Print string in data memory to stream.
[in] | s | pointer to data memory string. |
Definition at line 447 of file IOStream.hh.
|
inline |
Print string in program memory to stream. Use macro PSTR() to generate a string constants in program memory.
[in] | s | pointer to program memory string. |
Definition at line 458 of file IOStream.hh.
void IOStream::print | ( | IOStream::Device * | buffer | ) |
Print contents of iostream to stream.
[in] | buffer | input/output buffer. |
Definition at line 117 of file IOStream.cpp.
|
protected |
Print number prefix for non decimal base.
[in] | base | representation. |
Definition at line 125 of file IOStream.cpp.
|
inline |
Formated print with variable argument list. The format string should be in program memory. Use the macro PSTR().
[in] | format | string in program memory. |
[in] | ... | variable argument list. |
Definition at line 487 of file IOStream.hh.
|
inline |
Print end of line to stream.
Definition at line 467 of file IOStream.hh.
char * IOStream::readline | ( | char * | buf, |
size_t | size, | ||
bool | echo = true |
||
) |
Read line into the given buffer. Characters received from the device is appended to the end of the string until end of line is received. The buffer pointer is returned with a complete line has been received otherwise NULL. The function will append until the given size of reached.
[in] | buf | buffer for received line. |
[in] | size | of buffer. |
[in] | echo | character mode (Default true). |
Definition at line 262 of file IOStream.cpp.
char * IOStream::scan | ( | char * | s, |
size_t | count | ||
) |
Scan next token from the input stream. Returns pointer to string or NULL if not stream is empty.
[in] | s | string buffer to read into. |
[in] | count | max number of bytes to read. |
Definition at line 224 of file IOStream.cpp.
|
static |
Definition at line 51 of file IOStream_dtoa.cpp.
|
static |
Definition at line 138 of file IOStream_dtoa.cpp.
void IOStream::vprintf | ( | str_P | format, |
va_list | args | ||
) |
Format print with variable argument list. The format string should be in program memory. Use the macro PSTR().
[in] | format | string in program memory. |
[in] | args | variable argument list. |
Definition at line 163 of file IOStream.cpp.
|
inline |
Set minimum width for double numbers. The width is signed value, negative for left adjustment.
[in] | value | width. |
Definition at line 315 of file IOStream.hh.
Set current base to bcd for next operator print.
[in] | outs | stream. |
Definition at line 745 of file IOStream.hh.
Set current base to binary(2) for next operator print.
[in] | outs | stream. |
Definition at line 757 of file IOStream.hh.
Set current base to deciaml(10) for next operator print.
[in] | outs | stream. |
Definition at line 781 of file IOStream.hh.
Flush buffer to device.
[in] | outs | stream. |
Definition at line 853 of file IOStream.hh.
Set current base to hexadecimal(16) for next operator print.
[in] | outs | stream to set base. |
Definition at line 793 of file IOStream.hh.
Set current base to octal(8) for next operator print.
[in] | outs | stream. |
Definition at line 769 of file IOStream.hh.
|
staticprotected |
Maximum size of required buffer for string conversion.
Definition at line 730 of file IOStream.hh.
|
static |
End Of Line character sequences
Definition at line 36 of file IOStream.hh.
|
static |
Definition at line 38 of file IOStream.hh.
|
static |
End Of File, returned when device operations fails (empty or full).
Definition at line 33 of file IOStream.hh.
|
static |
Definition at line 37 of file IOStream.hh.
|
protected |
Base for next output operator.
Definition at line 724 of file IOStream.hh.
|
protected |
Delegated device.
Definition at line 723 of file IOStream.hh.
|
protected |
End of line string (program memory).
Definition at line 727 of file IOStream.hh.
|
protected |
Number of digits after decimal sign.
Definition at line 726 of file IOStream.hh.
|
protected |
Minimum width of output string.
Definition at line 725 of file IOStream.hh.