This is a helper class that writes format specifiers for the
<<
operator of mwx::stream
.Within the library, it is aliased as Using format=mwx::mwx_format;
.
Serial << format("formatted print: %.2f", (double)3123 / 100.) << mwx::crlf;
// formatted print: 31.23[newline]
The maximum number of arguments that can be registered in the variable argument list is 8. If parameters include 64-bit types such as double or uint64_t, the number of arguments is limited. Exceeding this limit will result in a compile-time error due to static_assert.
- Store the argument list received by the constructor into internal class variables using parameter pack expansion
- When
operator <<
is called, callfctprintf()
and write data to the stream
Constructor
format(const char *fmt, ...)
The constructor saves the format pointer and parameters. The following <<
operator call interprets the format and performs output processing.
Parameter | Description |
---|---|
fmt | Format string. See TWESDK/TWENET/current/src/printf/README.md |
... | Parameters corresponding to the format string. ※ The maximum number is 4; using 5 or more parameters will cause a compile error. ※ Consistency with the format is not checked, so unsafe for inconsistent input. |
fmt
must remain accessible until this object is destroyed.