FastLED 3.9.15
Loading...
Searching...
No Matches

◆ format_arg() [1/4]

void fl::printf_detail::format_arg ( sstream & stream,
const FormatSpec & spec,
const char * arg )
inline

Definition at line 514 of file stdio.h.

514 {
516
517 bool is_numeric = false;
518
519 switch (spec.type) {
520 case 's':
521 if (arg) {
522 result = arg;
523 } else {
524 result = "(null)";
525 }
526 break;
527 case 'p': {
528 // Pointer format for const char*
529 is_numeric = true;
530 const void* ptr = static_cast<const void*>(arg);
531 fl::uptr addr = reinterpret_cast<fl::uptr>(ptr); // ok reinterpret cast
532 result = fl::string("0x") + fl::to_hex(addr, false);
533 break;
534 }
535 case 'x':
536 result = "<string_not_hex>";
537 break;
538 case 'd':
539 case 'i':
540 case 'u':
541 case 'o':
542 case 'f':
543 case 'c':
544 result = "<type_error>";
545 break;
546 default:
547 result = "<unknown_format>";
548 break;
549 }
550
551 // Apply width and padding
552 result = apply_width(result, spec, is_numeric);
553 stream << result;
554}
fl::string apply_width(const fl::string &str, const FormatSpec &spec, bool is_numeric=false) FL_NOEXCEPT
Definition stdio.h:220
fl::string to_hex(T value, bool uppercase=false, bool pad_to_width=false) FL_NOEXCEPT
Convert an integer value to hexadecimal string representation.
Definition string.h:517
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References apply_width(), FL_NOEXCEPT, and fl::to_hex().

+ Here is the call graph for this function: