mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
AK: Define a formatter for char16_t
This commit is contained in:
parent
2618956b6f
commit
b6dc5050d2
|
|
@ -990,6 +990,21 @@ ErrorOr<void> Formatter<char>::format(FormatBuilder& builder, char value)
|
||||||
return formatter.format(builder, { &value, 1 });
|
return formatter.format(builder, { &value, 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> Formatter<char16_t>::format(FormatBuilder& builder, char16_t value)
|
||||||
|
{
|
||||||
|
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
||||||
|
Formatter<u16> formatter { *this };
|
||||||
|
return formatter.format(builder, value);
|
||||||
|
} else {
|
||||||
|
StringBuilder codepoint;
|
||||||
|
codepoint.append_code_point(value);
|
||||||
|
|
||||||
|
Formatter<StringView> formatter { *this };
|
||||||
|
return formatter.format(builder, codepoint.string_view());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<void> Formatter<char32_t>::format(FormatBuilder& builder, char32_t value)
|
ErrorOr<void> Formatter<char32_t>::format(FormatBuilder& builder, char32_t value)
|
||||||
{
|
{
|
||||||
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
||||||
|
|
@ -1003,6 +1018,7 @@ ErrorOr<void> Formatter<char32_t>::format(FormatBuilder& builder, char32_t value
|
||||||
return formatter.format(builder, codepoint.string_view());
|
return formatter.format(builder, codepoint.string_view());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Formatter<bool>::format(FormatBuilder& builder, bool value)
|
ErrorOr<void> Formatter<bool>::format(FormatBuilder& builder, bool value)
|
||||||
{
|
{
|
||||||
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
||||||
|
|
@ -1015,6 +1031,7 @@ ErrorOr<void> Formatter<bool>::format(FormatBuilder& builder, bool value)
|
||||||
return formatter.format(builder, value ? "true"sv : "false"sv);
|
return formatter.format(builder, value ? "true"sv : "false"sv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Formatter<long double>::format(FormatBuilder& builder, long double value)
|
ErrorOr<void> Formatter<long double>::format(FormatBuilder& builder, long double value)
|
||||||
{
|
{
|
||||||
u8 base;
|
u8 base;
|
||||||
|
|
|
||||||
|
|
@ -547,8 +547,12 @@ struct Formatter<char> : StandardFormatter {
|
||||||
ErrorOr<void> format(FormatBuilder&, char);
|
ErrorOr<void> format(FormatBuilder&, char);
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
|
struct Formatter<char16_t> : StandardFormatter {
|
||||||
|
ErrorOr<void> format(FormatBuilder&, char16_t);
|
||||||
|
};
|
||||||
|
template<>
|
||||||
struct Formatter<char32_t> : StandardFormatter {
|
struct Formatter<char32_t> : StandardFormatter {
|
||||||
ErrorOr<void> format(FormatBuilder& builder, char32_t);
|
ErrorOr<void> format(FormatBuilder&, char32_t);
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct Formatter<bool> : StandardFormatter {
|
struct Formatter<bool> : StandardFormatter {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user