FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Base class for formatted streams. More...
#include <fastarduino/ios.h>
Public Types | |
using | iostate = uint8_t |
Bitmask type to represent stream state flags. More... | |
using | fmtflags = uint16_t |
Bitmask type to represent stream format flags. More... | |
Public Member Functions | |
iostate | rdstate () const |
Return the current stream error state. More... | |
void | setstate (iostate state) |
Set the stream error flags state in addition to currently set flags. More... | |
void | clear (iostate state=goodbit) |
Set the stream error state flags by assigning them the value of state . More... | |
bool | good () const |
bool | eof () const |
Return true if the associated stream has reached end-of-file. More... | |
bool | fail () const |
Return true if an error has occurred on the associated stream, since last time state was reset (clear() was called). More... | |
bool | bad () const |
Return true if a non-recoverable error has occurred on the associated stream. More... | |
bool | operator! () const |
Return true if an error has occurred on the associated stream, since last time state was reset (clear() was called). More... | |
operator bool () const | |
Check that the current stream has no errors. More... | |
void | flags (fmtflags flags) |
Set new format flags for this stream. More... | |
fmtflags | flags () const |
Return the format flags currently selected in this stream. More... | |
void | setf (fmtflags flags) |
Set this stream's format flags whose bits are set in flags , leaving unchanged the rest. More... | |
void | setf (fmtflags flags, fmtflags mask) |
Set this stream's format flags whose bits are set in both flags and mask , and clears the format flags whose bits are set in mask but not in flags . More... | |
void | unsetf (fmtflags flags) |
Clear this stream's format flags whose bits are set in flags . More... | |
char | fill () const |
Return the fill character. More... | |
void | fill (char fill) |
Set fill as new fill character for this stream. More... | |
void | width (uint8_t width) |
Set minimum width used for displaying values. More... | |
uint8_t | width () const |
Get the current minimum width value (default = 0 ) used for formatted output. More... | |
void | precision (uint8_t precision) |
Set precision (number of digits after decimal point) used for displaying floating values. More... | |
uint8_t | precision () const |
Get the current precision (default = 6 ) used for formatted floating values output. More... | |
ios_base & | copyfmt (const ios_base &rhs) |
Copy formatting information from rhs to this stream. More... | |
Static Public Attributes | |
static constexpr iostate | eofbit = 0x01 |
This bit is set if the stream has unexpectedly reached its end during an extraction. More... | |
static constexpr iostate | failbit = 0x02 |
This bit is set when an input or operation failed due to a formatting error during extraction. More... | |
static constexpr iostate | badbit = 0x04 |
This bit is set when an irrecoverable stream error has occurred, e.g. More... | |
static constexpr iostate | goodbit = 0 |
No error; always 0 . More... | |
static constexpr fmtflags | dec = 0x0001 |
Read or write integral values using decimal (0..9) base format. More... | |
static constexpr fmtflags | bin = 0x0002 |
Read or write integral values using binary (0,1) base format. More... | |
static constexpr fmtflags | oct = 0x0004 |
Read or write integral values using octal (0..7) base format. More... | |
static constexpr fmtflags | hex = 0x0008 |
Read or write integral values using hexadecimal (0..9,A..F) base format. More... | |
static constexpr fmtflags | basefield = dec | bin | oct | hex |
Bitmask constant used with setf(fmtflags, fmtflags) when changing the output base format. More... | |
static constexpr fmtflags | left = 0x0010 |
Pad all output to width() characters, with fill() character appended at the end so that the output appears left-adjusted. More... | |
static constexpr fmtflags | right = 0x0020 |
Pad all output to width() characters, with fill() character added at the beginning so that the output appears right-adjusted. More... | |
static constexpr fmtflags | adjustfield = left | right |
Bitmask constant used with setf(fmtflags, fmtflags) when changing the output adjustment. More... | |
static constexpr fmtflags | scientific = 0x0040 |
Write floating point values in fixed-point notation. More... | |
static constexpr fmtflags | fixed = 0x0080 |
Write floating point values in scientific notation. More... | |
static constexpr fmtflags | floatfield = scientific | fixed |
Bitmask constant used with setf(fmtflags, fmtflags) when changing the floating point output representation. More... | |
static constexpr fmtflags | boolalpha = 0x0200 |
Read or write bool values as alphabetic string (true or false ). More... | |
static constexpr fmtflags | showbase = 0x0400 |
Write integral values prefixed by their base: More... | |
static constexpr fmtflags | showpos = 0x1000 |
Write non-negative numerical values preceded by + . More... | |
static constexpr fmtflags | skipws = 0x2000 |
Skip leading spaces on certain extraction (read) operations. More... | |
static constexpr fmtflags | unitbuf = 0x4000 |
Flush output after each insertion operation. More... | |
static constexpr fmtflags | uppercase = 0x8000U |
Write uppercase letters instead of lowercase in certain insertion operations. More... | |
static constexpr uint8_t | MAX_PRECISION = 16 |
The maximum allowed precision. More... | |
Base class for formatted streams.
Allows defining base, width and precision for numbers display.
using streams::ios_base::iostate = uint8_t |
Bitmask type to represent stream state flags.
This type is used as parameter or return value by methods setstate
, rdstate
and clear
.
The values passed and retrieved by these methods can be any valid combination of the predefined constants:
using streams::ios_base::fmtflags = uint16_t |
Bitmask type to represent stream format flags.
This type is used as parameter or return value by methods flags
, setf
and unsetf
. The values passed and retrieved by these methods can be any valid combination of the predefined constants:
|
inline |
|
inline |
Set the stream error state flags by assigning them the value of state
.
By default, assigns ios::goodbit which has the effect of clearing all error state flags.
|
inline |
|
inline |
|
inline |
Return true
if an error has occurred on the associated stream, since last time state was reset (clear()
was called).
Specifically, returns true
if ios::badbit
or ios::failbit
is set in rdstate()
.
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
Set this stream's format flags whose bits are set in flags
, leaving unchanged the rest.
This is equivalent to flags(flags | flags());
.
This method is used to set independent flags.
Set this stream's format flags whose bits are set in both flags
and mask
, and clears the format flags whose bits are set in mask
but not in flags
.
This is equivalent to flags((flags & mask) | (flags() & ~mask));
.
This method is used to set a value for one of a group of related flags, using one of the field bitmasks as the mask
argument:
flags | mask |
---|---|
left, right | adjustfield |
dec, bin, oct, hex | basefield |
scientific, fixed | floatfield |
|
inline |
Clear this stream's format flags whose bits are set in flags
.
|
inline |
|
inline |
|
inline |
Set minimum width used for displaying values.
If a value's representation needs less than width
characters for display, then additional characters will be added before or after the value. The filler character is determined by fill()
, a space by default. Padding side is determined by flags()
: left
or right
. Note that if the value representation needs more than width
characters, then width
will have no effect on display.
width | the new width to use for next formatted output |
|
inline |
|
inline |
|
inline |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Bitmask constant used with setf(fmtflags, fmtflags)
when changing the output adjustment.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Bitmask constant used with setf(fmtflags, fmtflags)
when changing the floating point output representation.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |