|
fiber
|
fiber::OStream provides a lightweight and flexible output streaming interface, optimized for embedded systems with limited resources. It offers:
These must be initialized by the user to point to a concrete OStream implementation. Creating a Custom Output Stream.
To create your own output stream (e.g., UART, USB), derive from fiber::OStream:
Mandatory methods to override:
void put(char c)void flush()Recommended for performance:
void write(const char* str, size_t len)Optional:
void newl() define how to end a line (default: \n)void endl() default: newline + flushStream the following types naturally with operator<<:
Example:
You can use the following functions inside streaming expressions:
fiber::newl(stream): Write newline (\n) - may be overridden by the user by overrideing OStream::newl()fiber::flush(stream): Flush the streamfiber::endl(stream): Write newline and flushFormat strings with padding, minimum width, alignment:
All following formating types use and provide the functionalities of fiber::FormatStr.
Configure booleans to print as true/false or 1/0:
Enhanced integer output, with thousands, alignment, and sign padding
Allows to add a suffix to integers that will be aligned with the integer.
Flexible floating-point output in scientific, engineering and full formating:
Custom FormatHex options allows including or excluding the hex header 0x as well as upper/lower case and optional leading zeros or compact notation.
Note: Pointers are automatically formatted as hexadecimal.
Using format_chrono(duration) you can create an fiber::FormatIntSuffix from std::chrono::duration types with automatically appropriate units (determined at compile time).
You can customize the formatting behavior at compile time by defining multiple compiler macros or CMake options.
For a complete overview of available compile options and their effect on formatting, refer to the page: Compile Options & Flags, specifically section Formatting