diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-18 16:48:02 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-19 11:29:48 +0000 |
commit | 5063e218af602a7dcf5323ad07e5521c9ce99057 (patch) | |
tree | 407127319ae7bc4f3159b10f11136c8eae03d513 /AK/Format.h | |
parent | 027aee2c6616f63523dc4ada723910b92f522292 (diff) | |
download | serenity-5063e218af602a7dcf5323ad07e5521c9ce99057.zip |
AK: Move the AK::FixedPoint formatter to FixedPoint.h
This does not need to be defined in Format.h. This causes FixedPoint.h
to be included everywhere. This is particularly going to be an issue
when trying to include <CoreServices/CoreServices.h> on macOS. The macOS
SDK defines its own FixedPoint structure which will conflict with ours.
Diffstat (limited to 'AK/Format.h')
-rw-r--r-- | AK/Format.h | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/AK/Format.h b/AK/Format.h index ed31bb4f4c..6f9ffe1d9b 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -12,7 +12,6 @@ #include <AK/AnyOf.h> #include <AK/Array.h> #include <AK/Error.h> -#include <AK/FixedPoint.h> #include <AK/Forward.h> #include <AK/Optional.h> #include <AK/StringView.h> @@ -534,44 +533,6 @@ struct Formatter<long double> : StandardFormatter { }; #endif -template<size_t precision, typename Underlying> -struct Formatter<FixedPoint<precision, Underlying>> : StandardFormatter { - Formatter() = default; - explicit Formatter(StandardFormatter formatter) - : StandardFormatter(formatter) - { - } - - ErrorOr<void> format(FormatBuilder& builder, FixedPoint<precision, Underlying> value) - { - u8 base; - bool upper_case; - FormatBuilder::RealNumberDisplayMode real_number_display_mode = FormatBuilder::RealNumberDisplayMode::General; - if (m_mode == Mode::Default || m_mode == Mode::FixedPoint) { - base = 10; - upper_case = false; - if (m_mode == Mode::FixedPoint) - real_number_display_mode = FormatBuilder::RealNumberDisplayMode::FixedPoint; - } else if (m_mode == Mode::Hexfloat) { - base = 16; - upper_case = false; - } else if (m_mode == Mode::HexfloatUppercase) { - base = 16; - upper_case = true; - } else { - VERIFY_NOT_REACHED(); - } - - m_width = m_width.value_or(0); - m_precision = m_precision.value_or(6); - - i64 integer = value.ltrunk(); - constexpr u64 one = static_cast<Underlying>(1) << precision; - u64 fraction_raw = value.raw() & (one - 1); - return builder.put_fixed_point(integer, fraction_raw, one, base, upper_case, m_zero_pad, m_align, m_width.value(), m_precision.value(), m_fill, m_sign_mode, real_number_display_mode); - } -}; - template<> struct Formatter<nullptr_t> : Formatter<FlatPtr> { ErrorOr<void> format(FormatBuilder& builder, nullptr_t) |