FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Defines C++-like streams API, based on circular buffers for input or output. More...
Classes | |
class | ios_base |
Base class for formatted streams. More... | |
class | istream |
Input stream wrapper to provide formatted input API, a la C++. More... | |
class | istreambuf |
Input API based on a ring buffer. More... | |
class | null_ostream |
Implements an empty formatted output that does nothing. More... | |
class | ostream |
Output stream wrapper to provide formatted output API, a la C++. More... | |
class | ostreambuf |
Output API based on a ring buffer. More... | |
Typedefs | |
using | ios = ios_base |
Alias for ios_base , allowing to write shorter code, eg ios::eofbit . More... | |
Functions | |
constexpr const setw_ | setw (uint8_t width) |
Set the field width to be used on output (and some input) operations. More... | |
constexpr const setprecision_ | setprecision (uint8_t precision) |
Set the decimal precision to be used to format floating-point values on output operations. More... | |
constexpr const setbase_ | setbase (int base) |
Set the ios::basefield to one of its possible values (ios::dec, ios::bin, ios::oct or ios::hex) according to base , which must be one of 10, 2, 8 or 16. More... | |
constexpr const setfill_ | setfill (char fill) |
Set a new fill character. More... | |
constexpr const setiosflags_ | setiosflags (ios::fmtflags mask) |
Set the format flags specified by mask . More... | |
constexpr const resetiosflags_ | resetiosflags (ios::fmtflags mask) |
Unset the format flags specified by mask . More... | |
template<typename FSTREAM > | |
void | skipws (FSTREAM &stream) |
Manipulator for an input stream, which will activate whitespace discarding before formatted input operations on that stream. More... | |
template<typename FSTREAM > | |
void | noskipws (FSTREAM &stream) |
Manipulator for an input stream, which will deactivate whitespace discarding before formatted input operations on that stream. More... | |
template<typename FSTREAM > | |
void | bin (FSTREAM &stream) |
Manipulator for an output or input stream, which will set the base, used to represent (output) or interpret (input) integral numerical values, to binary. More... | |
template<typename FSTREAM > | |
void | oct (FSTREAM &stream) |
Manipulator for an output or input stream, which will set the base, used to represent (output) or interpret (input) integral numerical values, to octal. More... | |
template<typename FSTREAM > | |
void | dec (FSTREAM &stream) |
Manipulator for an output or input stream, which will set the base, used to represent (output) or interpret (input) integral numerical values, to decimal. More... | |
template<typename FSTREAM > | |
void | hex (FSTREAM &stream) |
Manipulator for an output or input stream, which will set the base, used to represent (output) or interpret (input) integral numerical values, to hexadecimal. More... | |
template<typename FSTREAM > | |
void | boolalpha (FSTREAM &stream) |
Set the ios::boolalpha format flag for stream . More... | |
template<typename FSTREAM > | |
void | noboolalpha (FSTREAM &stream) |
Clear the ios::boolalpha format flag for stream . More... | |
template<typename FSTREAM > | |
void | showbase (FSTREAM &stream) |
Set the ios::showbase format flag for stream . More... | |
template<typename FSTREAM > | |
void | noshowbase (FSTREAM &stream) |
Clear the ios::showbase format flag for stream . More... | |
template<typename FSTREAM > | |
void | showpos (FSTREAM &stream) |
Set the ios::showpos format flag for stream . More... | |
template<typename FSTREAM > | |
void | noshowpos (FSTREAM &stream) |
Clear the ios::showpos format flag for stream . More... | |
template<typename FSTREAM > | |
void | uppercase (FSTREAM &stream) |
Set the ios::uppercase format flag for stream . More... | |
template<typename FSTREAM > | |
void | nouppercase (FSTREAM &stream) |
Clear the ios::uppercase format flag for stream . More... | |
template<typename FSTREAM > | |
void | unitbuf (FSTREAM &stream) |
Set the ios::unitbuf format flag for stream . More... | |
template<typename FSTREAM > | |
void | nounitbuf (FSTREAM &stream) |
Clear the ios::unitbuf format flag for stream . More... | |
template<typename FSTREAM > | |
void | left (FSTREAM &stream) |
Set the ios::adjustfield format flag for stream to ios::left, thus adjusting next output to the left. More... | |
template<typename FSTREAM > | |
void | right (FSTREAM &stream) |
Set the ios::adjustfield format flag for stream to ios::right, thus adjusting next output to the right. More... | |
template<typename FSTREAM > | |
void | defaultfloat (FSTREAM &stream) |
Set the ios::floatfield format flag for stream to ios::defaultfloat. More... | |
template<typename FSTREAM > | |
void | fixed (FSTREAM &stream) |
Set the ios::floatfield format flag for stream to ios::fixed. More... | |
template<typename FSTREAM > | |
void | scientific (FSTREAM &stream) |
Set the ios::floatfield format flag for stream to ios::scientific. More... | |
template<typename FSTREAM > | |
void | ws (FSTREAM &stream) |
Manipulator for an input stream, which will swallow all white spaces from that stream. More... | |
template<typename FSTREAM > | |
void | flush (FSTREAM &stream) |
Manipulator for an output stream, which will flush the stream buffer. More... | |
template<typename FSTREAM > | |
void | endl (FSTREAM &stream) |
Manipulator for an output stream, which will insert a new-line character and flush the stream buffer. More... | |
Defines C++-like streams API, based on circular buffers for input or output.
Typical usage of an output "stream":
Note that these streams are generally created for you by higher level API, such as serial::hard::UART
and similar classes.
using streams::ios = typedef ios_base |
Alias for ios_base
, allowing to write shorter code, eg ios::eofbit
.
|
constexpr |
Set the field width to be used on output (and some input) operations.
This method should only be used as a stream manipulator.
The folowing example displays 123
right-aligned on 10 positions, i.e. with 7 fill characters prepended:
Note that setw()
is effective only for one input or output operation, and thus must be called before each operation.
|
constexpr |
Set the decimal precision to be used to format floating-point values on output operations.
This method should only be used as a stream manipulator.
The folowing example displays 123.456789
with various precision, i.e. various number of decimals afeter the decimal point:
|
constexpr |
Set the ios::basefield to one of its possible values (ios::dec, ios::bin, ios::oct or ios::hex) according to base
, which must be one of 10, 2, 8 or 16.
This method should only be used as a stream manipulator.
The folowing example displays 123
under all available bases:
Note that it is generally preferrable to use the other manipulators.
|
constexpr |
Set a new fill character.
This method should only be used as a stream manipulator.
The following example displays 123
in hexadecimal form on 4 positions, padded with 0
if necessary:
|
constexpr |
Set the format flags specified by mask
.
This method should only be used as a stream manipulator.
Behaves as if ios::setf
was called with mask
as argument, on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams). See ios::fmtflags for more information on the particular flags that can be modified with this manipulator function.
|
constexpr |
Unset the format flags specified by mask
.
This method should only be used as a stream manipulator.
Behaves as if ios::unsetf
was called with mask
as argument, on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams). See ios::fmtflags for more information on the particular flags that can be modified with this manipulator function.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Set the ios::boolalpha format flag for stream
.
When the boolalpha format flag is set, bool values are inserted/extracted by their textual representation: either true
or false
, instead of integral values.
This flag can be unset with the noboolalpha
manipulator.
|
inline |
Clear the ios::boolalpha format flag for stream
.
When the boolalpha format flag is not set, bool values are inserted/extracted as integral values (0
and 1
) instead of their textual representations: true
or false
. This flag can be set with the boolalpha
manipulator.
|
inline |
Set the ios::showbase format flag for stream
.
When the showbase format flag is set, numerical integer values inserted into output streams are prefixed with the same prefixes used by C++ literal constants: 0x
for hexadecimal values (see hex
), 0
for octal values (see oct
), 0b
for binary values (see bin
) and no prefix for decimal-base values (see dec
).
This option can be unset with the noshowbase
manipulator.
|
inline |
Clear the ios::showbase format flag for stream
.
When the showbase format flag is not set, numerical integer values are inserted into stream
without prefixing them with any numerical base prefix (i.e. 0x
for hexadecimal values, 0
for octal values, 0b
for binary values and no prefix for decimal-base values).
This option can be set with the showbase
manipulator.
|
inline |
Set the ios::showpos format flag for stream
.
When the showpos format flag is set, a plus sign (+) precedes every non-negative numerical value inserted into stream
(including zeros).
This flag can be unset with the noshowpos
manipulator.
|
inline |
Clear the ios::showpos format flag for stream
.
When the showpos format flag is not set, no plus signs precede positive values inserted into stream
.
This flag can be set with the noshowpos
manipulator.
|
inline |
Set the ios::uppercase format flag for stream
.
When the uppercase format flag is set, uppercase (capital) letters are used instead of lowercase for representations on output operations involving stream-generated letters, like hexadecimal representations.
This flag can be unset with the nouppercase
manipulator, not forcing the use of uppercase for generated letters.
|
inline |
Clear the ios::uppercase format flag for stream
.
When the uppercase format flag is notset, the letters automatically generated by stream
for certain representations (like hexadecimal representations) are displayed as lwoercase.
This flag can be set with the uppercase
manipulator, forcing the use of uppercase for generated letters.
|
inline |
Set the ios::unitbuf format flag for stream
.
When the unitbuf flag is set, the associated buffer is flushed after each insertion operation.
This flag can be unset with the nounitbuf
manipulator, not forcing flushes after every insertion.
|
inline |
Clear the ios::unitbuf format flag for stream
.
When the unitbuf flag is not set, the associated buffer is not forced to be flushed after every insertion operation. With this mode, you can force buffer flush any time by using flush
manipulator, or using endl
which will output a new line follwoed by a buffer flush.
This flag can be set with the unitbuf
manipulator, forcing flushes after every insertion.
|
inline |
Set the ios::adjustfield format flag for stream
to ios::left, thus adjusting next output to the left.
When adjustfield is set to left, the output is padded to the field width (ios::width()
) by inserting fill characters (ios::fill()
) at the end, effectively adjusting the field to the left.
|
inline |
Set the ios::adjustfield format flag for stream
to ios::right, thus adjusting next output to the right.
When adjustfield is set to right, the output is padded to the field width (ios::width()
) by inserting fill characters (ios::fill()
) at the beginning, effectively adjusting the field to the right.
|
inline |
Set the ios::floatfield format flag for stream
to ios::defaultfloat.
When floatfield is set to defaultfloat, floating-point values are written using the default notation: the representation uses as many meaningful digits as needed up to the stream's decimal precision (ios::precision()
), counting both the digits before and after the decimal point (if any).
NOTE: current implementation behaves the same as fixed
.
|
inline |
Set the ios::floatfield format flag for stream
to ios::fixed.
When floatfield is set to fixed, floating-point values are written using fixed-point notation: the value is represented with exactly as many digits in the decimal part as specified by the precision field (ios::precision()
) and with no exponent part.
|
inline |
Set the ios::floatfield format flag for stream
to ios::scientific.
When floatfield is set to scientific, floating-point values are written using scientific notation: the value is represented always with only one digit before the decimal point, followed by the decimal point and as many decimal digits as the precision field (ios::precision()
). Finally, this notation always includes an exponential part consisting on the letter e
followed by an optional sign and two exponential digits.
|
inline |
Manipulator for an input stream, which will swallow all white spaces from that stream.
The following sample code puts the next non white space character of in
into c
:
|
inline |