diff --git a/src/util/format/builder.h b/src/util/format/builder.h index a22e2a6..6c418e1 100644 --- a/src/util/format/builder.h +++ b/src/util/format/builder.h @@ -60,7 +60,6 @@ public: 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, 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; } std::stringstream& builder() { return m_builder; } diff --git a/src/util/format/formatter.cpp b/src/util/format/formatter.cpp index a44cbff..49e3cb6 100644 --- a/src/util/format/formatter.cpp +++ b/src/util/format/formatter.cpp @@ -58,9 +58,14 @@ void Formatter::format(Builder& builder, const char* value) const // Pointer +void Formatter::parse(Parser& parser) +{ + parser.parseSpecifier(specifier, Parser::ParameterType::Pointer); +} + void Formatter::format(Builder& builder, std::nullptr_t) const { - Formatter::format(builder, 0); + Formatter::format(builder, "nullptr"); } } // namespace Util::Format diff --git a/src/util/format/formatter.h b/src/util/format/formatter.h index da1fbe7..bb07259 100644 --- a/src/util/format/formatter.h +++ b/src/util/format/formatter.h @@ -8,7 +8,7 @@ #include #include // size_t -#include // int8_t, int32_t, int64_t, uint8_t, uint32_t +#include // int8_t, int32_t, int64_t, uint8_t, uint32_t, uintptr_t #include #include #include @@ -193,7 +193,7 @@ struct Formatter : Formatter { // Pointer template -struct Formatter { +struct Formatter : Formatter { Specifier specifier; constexpr void parse(Parser& parser) @@ -203,14 +203,14 @@ struct Formatter { void format(Builder& builder, T* value) const { - value == nullptr - ? builder.putString("nullptr") - : builder.putPointer(static_cast(value)); + builder.putU64(reinterpret_cast(value), 16, false, specifier.fill, specifier.align, + Builder::Sign::None, true, false, specifier.width); } }; template<> -struct Formatter : Formatter { +struct Formatter : Formatter { + void parse(Parser& parser); void format(Builder& builder, std::nullptr_t) const; };