FastLED 3.10.6
Loading...
Searching...
No Matches

◆ format_arg() [1/7]

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

Definition at line 670 of file stdio.h.

670 {
672
673 bool is_numeric = false;
674
675 switch (spec.type) {
676 case 's':
677 if (arg) {
678 result = arg;
679 } else {
680 result = "(null)";
681 }
682 break;
683 case 'p': {
684 // Pointer format for const char*
685 is_numeric = true;
686 const void* ptr = static_cast<const void*>(arg);
687 fl::uptr addr = reinterpret_cast<fl::uptr>(ptr); // ok reinterpret cast
688 result = fl::string("0x") + fl::to_hex(addr, false);
689 break;
690 }
691 case 'x':
692 result = "<string_not_hex>";
693 break;
694 case 'd':
695 case 'i':
696 case 'u':
697 case 'o':
698 case 'f':
699 case 'c':
700 result = "<type_error>";
701 break;
702 default:
703 result = "<unknown_format>";
704 break;
705 }
706
707 // Apply width and padding
708 result = apply_width(result, spec, is_numeric);
709 stream << result;
710}
fl::string apply_width(const fl::string &str, const FormatSpec &spec, bool is_numeric=false) FL_NO_EXCEPT
Definition stdio.h:247
fl::string to_hex(T value, bool uppercase=false, bool pad_to_width=false) FL_NO_EXCEPT
Convert an integer value to hexadecimal string representation.
Definition string.h:526
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References apply_width(), fl::FL_NO_EXCEPT, fl::to_hex(), and fl::printf_detail::FormatSpec::type.

+ Here is the call graph for this function: