|
FastLED 3.9.15
|
C++20 std::format-style string formatting for fl::string.
Provides fl::format() function with Python/fmtlib-style {} placeholders.
Basic usage: fl::format("Hello {}!", "World") -> "Hello World!" fl::format("{} + {} = {}", 2, 3, 5) -> "2 + 3 = 5"
Indexed arguments: fl::format("{1} before {0}", "A", "B") -> "B before A"
Format specifiers (after colon): fl::format("{:d}", 42) -> "42" (decimal) fl::format("{:x}", 255) -> "ff" (hex lowercase) fl::format("{:X}", 255) -> "FF" (hex uppercase) fl::format("{:b}", 5) -> "101" (binary) fl::format("{:o}", 8) -> "10" (octal) fl::format("{:f}", 3.14) -> "3.140000" (fixed float) fl::format("{:.2f}", 3.14159) -> "3.14" (precision) fl::format("{:c}", 65) -> "A" (character)
Width and alignment: fl::format("{:10}", 42) -> " 42" (right-align default) fl::format("{:<10}", 42) -> "42 " (left-align) fl::format("{:>10}", 42) -> " 42" (right-align) fl::format("{:^10}", 42) -> " 42 " (center) fl::format("{:*^10}", 42) -> "****42****" (fill char) fl::format("{:05}", 42) -> "00042" (zero-pad)
Signs and prefixes: fl::format("{:+}", 42) -> "+42" (always show sign) fl::format("{:#x}", 255) -> "0xff" (alternate form) fl::format("{:#b}", 5) -> "0b101" (binary prefix)
Escaping braces: fl::format("{{}}}") -> "{}"
Definition in file format.h.
#include "fl/stl/string.h"#include "fl/stl/charconv.h"#include "fl/stl/bit_cast.h"#include "fl/stl/type_traits.h"#include "fl/stl/int.h"#include "fl/stl/noexcept.h"
Include dependency graph for format.h:Go to the source code of this file.
Classes | |
| class | fl::format_detail::FormatArg |
| struct | fl::format_detail::FormatSpec |
Namespaces | |
| namespace | fl |
| Base definition for an LED controller. | |
| namespace | fl::format_detail |
Functions | |
| void | fl::format_detail::apply_width_align (fl::string &result, const fl::string &value, const FormatSpec &spec) |
| fl::string | fl::format (const char *fmt) |
| Format with no arguments. | |
| template<typename... Args> | |
| fl::string | fl::format (const char *fmt, const Args &... args) |
| Format with variadic arguments. | |
| fl::string | fl::format_detail::format_float (double value, const FormatSpec &spec) |
| fl::string | fl::format_detail::format_impl (const char *fmt, const FormatArg *args, int num_args) |
| template<typename T> | |
| fl::string | fl::format_detail::format_integer (T value, const FormatSpec &spec) |
| fl::string | fl::format_detail::format_pointer (const void *ptr, const FormatSpec &spec) |
| fl::string | fl::format_detail::format_string (const char *value, const FormatSpec &spec) |
| const char * | fl::format_detail::parse_format_spec (const char *p, FormatSpec &spec) |