mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:27:35 +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
|
@ -66,12 +66,11 @@ namespace AK {
|
|||
|
||||
template<>
|
||||
struct Formatter<GUI::ModelIndex> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const GUI::ModelIndex& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, GUI::ModelIndex const& value)
|
||||
{
|
||||
if (value.internal_data())
|
||||
return Formatter<FormatString>::format(builder, "ModelIndex({},{},{})", value.row(), value.column(), value.internal_data());
|
||||
else
|
||||
return Formatter<FormatString>::format(builder, "ModelIndex({},{})", value.row(), value.column());
|
||||
return Formatter<FormatString>::format(builder, "ModelIndex({},{})", value.row(), value.column());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace AK {
|
|||
|
||||
template<>
|
||||
struct Formatter<GUI::PersistentModelIndex> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const GUI::PersistentModelIndex& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, GUI::PersistentModelIndex const& value)
|
||||
{
|
||||
return Formatter<FormatString>::format(builder, "PersistentModelIndex({},{},{})", value.row(), value.column(), value.internal_data());
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@ private:
|
|||
|
||||
template<>
|
||||
struct AK::Formatter<GUI::TextPosition> : AK::Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const GUI::TextPosition& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, GUI::TextPosition const& value)
|
||||
{
|
||||
if (value.is_valid())
|
||||
Formatter<FormatString>::format(builder, "({},{})", value.line(), value.column());
|
||||
else
|
||||
Formatter<FormatString>::format(builder, "GUI::TextPosition(Invalid)");
|
||||
return Formatter<FormatString>::format(builder, "({},{})", value.line(), value.column());
|
||||
|
||||
return Formatter<FormatString>::format(builder, "GUI::TextPosition(Invalid)");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -68,11 +68,10 @@ private:
|
|||
|
||||
template<>
|
||||
struct AK::Formatter<GUI::TextRange> : AK::Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, const GUI::TextRange& value)
|
||||
ErrorOr<void> format(FormatBuilder& builder, GUI::TextRange const& value)
|
||||
{
|
||||
if (value.is_valid())
|
||||
return Formatter<FormatString>::format(builder, "{}-{}", value.start(), value.end());
|
||||
else
|
||||
return Formatter<FormatString>::format(builder, "GUI::TextRange(Invalid)");
|
||||
return Formatter<FormatString>::format(builder, "GUI::TextRange(Invalid)");
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue