1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16:17:47 +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:
Andreas Kling 2021-11-16 01:15:21 +01:00
parent 008355c222
commit 216e21a1fa
87 changed files with 450 additions and 448 deletions

View file

@ -70,7 +70,7 @@ private:
template<>
struct AK::Formatter<Gfx::AffineTransform> : Formatter<FormatString> {
void format(FormatBuilder& builder, Gfx::AffineTransform value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::AffineTransform const& value)
{
return Formatter<FormatString>::format(builder, "[{} {} {} {} {} {}]", value.a(), value.b(), value.c(), value.d(), value.e(), value.f());
}

View file

@ -75,9 +75,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Endpoint<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, const Gfx::Endpoint<T>& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Endpoint<T> const& value)
{
Formatter<StringView>::format(builder, String::formatted("({}, {}, {})", value.x, value.y, value.z));
return Formatter<StringView>::format(builder, String::formatted("({}, {}, {})", value.x, value.y, value.z));
}
};

View file

@ -352,7 +352,7 @@ bool IPC::decode(IPC::Decoder& decoder, Color& color)
return true;
}
void AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Color const& value)
ErrorOr<void> AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Color const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}

View file

@ -478,7 +478,7 @@ namespace AK {
template<>
struct Formatter<Gfx::Color> : public Formatter<StringView> {
void format(FormatBuilder& builder, Gfx::Color const& value);
ErrorOr<void> format(FormatBuilder&, Gfx::Color const&);
};
}

View file

@ -280,9 +280,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Point<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, Gfx::Point<T> const& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Point<T> const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}
};

View file

@ -726,9 +726,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Rect<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, const Gfx::Rect<T>& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Rect<T> const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}
};

View file

@ -178,9 +178,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Size<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, Gfx::Size<T> const& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Size<T> const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}
};

View file

@ -127,9 +127,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Vector2<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, const Gfx::Vector2<T>& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Vector2<T> const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}
};

View file

@ -144,9 +144,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Vector3<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, const Gfx::Vector3<T>& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Vector3<T> const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}
};

View file

@ -145,9 +145,9 @@ namespace AK {
template<typename T>
struct Formatter<Gfx::Vector4<T>> : Formatter<StringView> {
void format(FormatBuilder& builder, const Gfx::Vector4<T>& value)
ErrorOr<void> format(FormatBuilder& builder, Gfx::Vector4<T> const& value)
{
Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_string());
}
};