MCPcopy Create free account
hub / github.com/FastLED/FastLED / format_arg

Function format_arg

src/fl/stl/stdio.h:363–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361// Format non-pointer types (d, i, u, o, x, X, f, c, s)
362template<typename T>
363typename fl::enable_if<!fl::is_pointer<T>::value>::type
364format_arg(sstream& stream, const FormatSpec& spec, const T& arg) FL_NOEXCEPT {
365 fl::string result;
366 bool is_numeric = false;
367
368 switch (spec.type) {
369 case 'd':
370 case 'i': {
371 if (!fl::is_integral<T>::value) {
372 result = "<type_error>";
373 break;
374 }
375 is_numeric = true;
376
377 // Convert to string
378 sstream temp;
379 temp << arg;
380 result = temp.str();
381
382 // Handle sign flags
383 bool is_negative = !result.empty() && result[0] == '-';
384 if (!is_negative) {
385 if (spec.show_sign) {
386 result = fl::string("+") + result;
387 } else if (spec.space_sign) {
388 result = fl::string(" ") + result;
389 }
390 }
391 break;
392 }
393
394 case 'u': {
395 if (!fl::is_integral<T>::value) {
396 result = "<type_error>";
397 break;
398 }
399 is_numeric = true;
400
401 // Convert to string
402 sstream temp;
403 temp << arg;
404 result = temp.str();
405 break;
406 }
407
408 case 'o': {
409 if (!fl::is_integral<T>::value) {
410 result = "<type_error>";
411 break;
412 }
413 is_numeric = true;
414
415 // Convert to octal
416 result = to_octal(arg);
417
418 // Alternate form: prefix with 0 (but not for zero itself)
419 if (spec.alt_form && arg != 0) {
420 result = fl::string("0") + result;

Callers 1

format_implFunction · 0.85

Calls 8

to_octalFunction · 0.85
to_hexFunction · 0.85
apply_widthFunction · 0.85
pointer_to_uptrFunction · 0.85
stringClass · 0.70
format_floatFunction · 0.70
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected