mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
Kernel: Add an error propagating KString::format(..) API :^)
In the continuous effort of better handling OOM in the kernel, we want to move away from all AK::String usage. One of the final pieces left to accomplish this goal is replacing all of the usages of `String::formatted` with something that can actually propagate failure. The StringBuilder API was enhanced in the recent past to propagate failure and thus a slightly modified version of what exists in `AK::format` will work well for implementing failable format with `KString`.
This commit is contained in:
parent
cd41af5ac2
commit
4cc41ea186
2 changed files with 18 additions and 0 deletions
|
@ -21,6 +21,15 @@ public:
|
|||
[[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> try_create(StringView);
|
||||
[[nodiscard]] static NonnullOwnPtr<KString> must_create(StringView);
|
||||
|
||||
[[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> vformatted(StringView fmtstr, AK::TypeErasedFormatParams&);
|
||||
|
||||
template<typename... Parameters>
|
||||
[[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> formatted(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters)
|
||||
{
|
||||
AK::VariadicFormatParams variadic_format_parameters { parameters... };
|
||||
return vformatted(fmtstr.view(), variadic_format_parameters);
|
||||
}
|
||||
|
||||
void operator delete(void*);
|
||||
|
||||
ErrorOr<NonnullOwnPtr<KString>> try_clone() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue