diff --git a/src/util/format/builder.cpp b/src/util/format/builder.cpp index bed899a..03216a8 100644 --- a/src/util/format/builder.cpp +++ b/src/util/format/builder.cpp @@ -28,7 +28,7 @@ void Builder::putLiteral(std::string_view literal) } } -void Builder::putU64(size_t value, size_t width, Align align, char fill, Sign sign, bool isNegative) const +void Builder::putU64(size_t value, char fill, Align align, Sign sign, size_t width, bool isNegative) const { std::string string = (std::stringstream {} << value).str(); @@ -79,11 +79,11 @@ void Builder::putU64(size_t value, size_t width, Align align, char fill, Sign si }; } -void Builder::putI64(int64_t value, size_t width, Align align, char fill, Sign sign) const +void Builder::putI64(int64_t value, char fill, Align align, Sign sign, size_t width) const { - auto const isNegative = value < 0; - value = isNegative ? -value : value; - putU64(static_cast(value), width, align, fill, sign, isNegative); + bool isNegative = value < 0; + value = isNegative ? -value : value; + putU64(static_cast(value), fill, align, sign, width, isNegative); } void Builder::putF64(double number, uint8_t precision) const @@ -99,7 +99,7 @@ void Builder::putF64(double number, uint8_t precision) const m_builder << string; } -void Builder::putString(std::string_view string, size_t width, Align align, char fill) const +void Builder::putString(std::string_view string, char fill, Align align, size_t width) const { size_t length = string.length(); if (width < length) { diff --git a/src/util/format/builder.h b/src/util/format/builder.h index a6848ce..460a0b2 100644 --- a/src/util/format/builder.h +++ b/src/util/format/builder.h @@ -36,11 +36,11 @@ public: void putLiteral(std::string_view literal); - void putU64(size_t value, size_t width = 0, Align align = Align::Right, char fill = ' ', Sign sign = Sign::Negative, bool isNegative = false) const; - void putI64(int64_t value, size_t width = 0, Align align = Align::Right, char fill = ' ', Sign sign = Sign::Negative) const; + void putU64(size_t value, char fill = ' ', Align align = Align::Right, Sign sign = Sign::Negative, size_t width = 0, bool isNegative = false) const; + void putI64(int64_t value, char fill = ' ', Align align = Align::Right, Sign sign = Sign::Negative, size_t width = 0) const; void putF64(double number, uint8_t precision = 6) const; void putCharacter(char character) const { m_builder.write(&character, 1); } - void putString(std::string_view string, size_t width = 0, Align align = Align::Left, char fill = ' ') const; + void putString(std::string_view string, char fill = ' ', Align align = Align::Left, size_t width = 0) const; void putPointer(const void* pointer) const { m_builder << pointer; } const std::stringstream& builder() const { return m_builder; } diff --git a/src/util/format/formatter.cpp b/src/util/format/formatter.cpp index 5652991..78fc283 100644 --- a/src/util/format/formatter.cpp +++ b/src/util/format/formatter.cpp @@ -35,7 +35,7 @@ void Formatter::format(Builder& builder, bool value) const template<> void Formatter::format(Builder& builder, std::string_view value) const { - builder.putString(value, specifier.width, specifier.align, specifier.fill); + builder.putString(value, specifier.fill, specifier.align, specifier.width); } void Formatter::parse(Parser& parser) @@ -51,7 +51,9 @@ void Formatter::format(Builder& builder, const char* value) const return; } - builder.putString(value != nullptr ? std::string_view { value, strlen(value) } : "nullptr"); + Formatter::format( + builder, + value != nullptr ? std::string_view { value, strlen(value) } : "nullptr"); } // Pointer diff --git a/src/util/format/formatter.h b/src/util/format/formatter.h index def836c..b466955 100644 --- a/src/util/format/formatter.h +++ b/src/util/format/formatter.h @@ -93,11 +93,11 @@ struct Formatter { { if (std::is_signed_v) { builder.putI64( - value, specifier.width, specifier.align, specifier.fill, specifier.sign); + value, specifier.fill, specifier.align, specifier.sign, specifier.width); } if (std::is_unsigned_v) { builder.putU64( - value, specifier.width, specifier.align, specifier.fill, specifier.sign); + value, specifier.fill, specifier.align, specifier.sign, specifier.width); } } };