mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
This commit is contained in:
parent
008355c222
commit
216e21a1fa
87 changed files with 450 additions and 448 deletions
|
@ -46,28 +46,27 @@ namespace AK {
|
|||
|
||||
template<>
|
||||
struct Formatter<Kernel::KString> : Formatter<StringView> {
|
||||
void format(FormatBuilder& builder, Kernel::KString const& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, Kernel::KString const& value)
|
||||
{
|
||||
Formatter<StringView>::format(builder, value.view());
|
||||
return Formatter<StringView>::format(builder, value.view());
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Formatter<OwnPtr<Kernel::KString>> : Formatter<StringView> {
|
||||
void format(FormatBuilder& builder, OwnPtr<Kernel::KString> const& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, OwnPtr<Kernel::KString> const& value)
|
||||
{
|
||||
if (value)
|
||||
Formatter<StringView>::format(builder, value->view());
|
||||
else
|
||||
Formatter<StringView>::format(builder, "[out of memory]"sv);
|
||||
return Formatter<StringView>::format(builder, value->view());
|
||||
return Formatter<StringView>::format(builder, "[out of memory]"sv);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Formatter<NonnullOwnPtr<Kernel::KString>> : Formatter<StringView> {
|
||||
void format(FormatBuilder& builder, NonnullOwnPtr<Kernel::KString> const& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, NonnullOwnPtr<Kernel::KString> const& value)
|
||||
{
|
||||
Formatter<StringView>::format(builder, value->view());
|
||||
return Formatter<StringView>::format(builder, value->view());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue