58template<
typename... Args>
102template<
typename... Args>
147 bool parsing_flags =
true;
148 while (parsing_flags) {
171 parsing_flags =
false;
211 if (spec.
type ==
'X') {
220 if (spec.
type !=
'\0') {
237 unsigned long long val =
static_cast<unsigned long long>(
value);
239 buffer[--
pos] =
'0' + (val & 7);
248 int len =
static_cast<int>(str.
length());
251 if (spec.
width <= len) {
255 int padding = spec.
width - len;
263 if (!str.
empty() && (str[0] ==
'-' || str[0] ==
'+' || str[0] ==
' ')) {
266 for (
int i = 0; i < padding; ++i) {
269 for (
size_t i = 1; i < str.
length(); ++i) {
276 if (str.
length() >= 2 && str[0] ==
'0' && (str[1] ==
'x' || str[1] ==
'X')) {
280 for (
int i = 0; i < padding; ++i) {
283 for (
size_t i = 2; i < str.
length(); ++i) {
294 for (
int i = 0; i < padding; ++i) {
299 for (
int i = 0; i < padding; ++i) {
366 const bool negative =
value < 0.0f;
367 const float magnitude = negative ? -
value :
value;
378 fl::i64 int_part =
static_cast<fl::i64
>(magnitude);
379 float residue = magnitude -
static_cast<float>(int_part);
380 if (residue < 0.0f) {
384 if (precision == 0) {
385 if (residue >= 0.5f) {
389 if (negative && int_part != 0) {
396 fl::i64 multiplier = 1;
397 for (
int i = 0; i < precision; ++i) {
402 static_cast<fl::i64
>(residue *
static_cast<float>(multiplier) + 0.5f);
403 if (frac_part >= multiplier) {
405 frac_part -= multiplier;
412 if (negative && (int_part != 0 || frac_part != 0)) {
423 fl::i64 temp_multiplier = multiplier / 10;
424 while (temp_multiplier > 0) {
425 const fl::i64 digit = (frac_part / temp_multiplier) % 10;
426 stream << static_cast<char>(
'0' +
static_cast<int>(digit));
427 temp_multiplier /= 10;
437 const void* vptr =
static_cast<const void*
>(ptr);
438 return reinterpret_cast<fl::uptr
>(vptr);
493 a.s =
static_cast<fl::i64
>(arg);
494 a.u =
static_cast<fl::u64
>(arg);
502 a.f =
static_cast<float>(arg);
503 a.d =
static_cast<double>(arg);
522 bool is_numeric =
false;
605 temp << static_cast<float>(arg);
617 char ch =
static_cast<char>(arg);
618 char temp_str[2] = {ch,
'\0'};
631 result =
"<unknown_format>";
647 bool is_numeric =
false;
649 if (spec.
type ==
'p') {
673 bool is_numeric =
false;
686 const void* ptr =
static_cast<const void*
>(arg);
687 fl::uptr addr =
reinterpret_cast<fl::uptr
>(ptr);
692 result =
"<string_not_hex>";
703 result =
"<unknown_format>";
851 format_arg(stream, spec,
static_cast<const char*
>(arg));
859 if (spec.
type ==
'%') {
864 stream <<
"<missing_arg>";
870 stream <<
"<missing_arg>";
875 char temp_str[2] = {*
format,
'\0'};
883template<
typename T,
typename... Args>
888 if (spec.
type ==
'%') {
910 char temp_str[2] = {*
format,
'\0'};
960template<
typename... Args>
1008template<
typename... Args>
1011 if (!buffer || size == 0) {
1021 fl::size formatted_len =
result.size();
1024 fl::size copy_len = (formatted_len < size - 1) ? formatted_len : size - 1;
1027 for (fl::size i = 0; i < copy_len; ++i) {
1032 buffer[copy_len] =
'\0';
1036 return static_cast<int>(copy_len);
fl::size length() const FL_NO_EXCEPT
bool empty() const FL_NO_EXCEPT
const char * c_str() const FL_NO_EXCEPT
string str() const FL_NO_EXCEPT
fl::enable_if< fl::is_integral< T >::value >::type format_arg_generic(sstream &stream, const T &arg) FL_NO_EXCEPT
void format_arg(sstream &stream, const FormatSpec &spec, const fl::string &arg) FL_NO_EXCEPT
fl::string apply_width(const fl::string &str, const FormatSpec &spec, bool is_numeric=false) FL_NO_EXCEPT
fl::string to_octal(T value) FL_NO_EXCEPT
fl::string format_float(float value, int precision) FL_NO_EXCEPT
constexpr float kFloatDecimalLimit
void format_impl(sstream &stream, const char *format) FL_NO_EXCEPT
bool float_is_finite(float value) FL_NO_EXCEPT
FormatSpec parse_format_spec(const char *&format) FL_NO_EXCEPT
bool parse_brace(sstream &stream, const char *&format) FL_NO_EXCEPT
void format_floating(sstream &stream, const FormatSpec &spec, const ScalarArg &a) FL_NO_EXCEPT
fl::enable_if< fl::is_integral< T >::value >::type format_scalar_arg(sstream &stream, const FormatSpec &spec, ScalarArg &a, const T &arg) FL_NO_EXCEPT
fl::string format_float_scientific(float value, int precision) FL_NO_EXCEPT
fl::enable_if< fl::is_pointer< T >::value, fl::uptr >::type pointer_to_uptr(const T &ptr) FL_NO_EXCEPT
void format_integral(sstream &stream, const FormatSpec &spec, const ScalarArg &a) FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
void print(const char *str) FL_NO_EXCEPT
constexpr int type_rank< T >::value
int snprintf(char *buffer, fl::size size, const char *format) FL_NO_EXCEPT
fl::string format(const char *fmt) FL_NO_EXCEPT
Format with no arguments.
void printf(const char *format) FL_NO_EXCEPT
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.
expected< T, E > result
Alias for expected (Rust-style naming)
Base definition for an LED controller.